pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: encode.c,v 1.267 2008/05/17 13:36:56 grubba Exp $ + || $Id: encode.c,v 1.268 2008/05/21 13:07:02 grubba Exp $   */      #include "global.h"   #include "stralloc.h"   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"   #include "svalue.h"   #include "mapping.h"
pike.git/src/encode.c:2014:   struct unfinished_prog_link   {    struct unfinished_prog_link *next;    struct program *prog;   };      struct unfinished_obj_link   {    struct unfinished_obj_link *next;    struct object *o; +  struct svalue decode_arg;   };      struct decode_data   {    struct pike_string *data_str;    unsigned char *data;    ptrdiff_t len;    ptrdiff_t ptr;    struct mapping *decoded;    struct unfinished_prog_link *unfinished_programs;
pike.git/src/encode.c:2894:    {    int lfun = FIND_LFUN(o->prog, LFUN___INIT);    if (lfun >= 0) {    apply_low(o, lfun, 0);    pop_stack();    }    /* FIXME: Should call LFUN_CREATE here in <= 7.2    * compatibility mode. */    }else{    struct unfinished_obj_link *ol=ALLOC_STRUCT(unfinished_obj_link); -  ol->o=o; +  EDB(2,fprintf(stderr, +  "%*sDecoded an unfinished object to <%d>: ", +  data->depth, "", entry_id.u.integer); +  print_svalue(stderr, Pike_sp-1); +  fputc('\n', stderr);); +  add_ref(ol->o = o);    ol->next=data->unfinished_objects; -  +  ol->decode_arg.type = PIKE_T_INT; +  ol->decode_arg.subtype = NUMBER_UNDEFINED; +  ol->decode_arg.u.integer = 0;    data->unfinished_objects=ol; -  +  decode_value2(data); +  assign_svalue(&ol->decode_arg, Pike_sp-1); +  pop_stack(); +  break;    }    }       EDB(2,fprintf(stderr, "%*sDecoded an object to <%d>: ",    data->depth, "", entry_id.u.integer);    print_svalue(stderr, Pike_sp-1);    fputc('\n', stderr););       ref_push_object(o);    decode_value2(data);
pike.git/src/encode.c:3585:    }else{    ptr=&l->next;    }    }    }       /* Go through the linked list of unfinished objects    * to see what objects are now finished.    */    { +  int fun = -1;    struct unfinished_obj_link *l, **ptr; -  +  if (data->unfinished_objects) { +  if(!data->codec) +  decode_error(Pike_sp - 1, NULL, +  "Cannot decode object without codec.\n"); +  +  fun = find_identifier("decode_object", data->codec->prog); +  if (fun < 0) +  decode_error(Pike_sp - 1, NULL, +  "Cannot decode objects without a " +  "\"decode_object\" function in the codec.\n"); +  }    for(ptr= &data->unfinished_objects ; (l=*ptr);)    {    struct object *o=l->o;    if(o->prog)    {    if(o->prog->flags & PROGRAM_FINISHED)    {    apply_lfun(o, LFUN___INIT, 0);    pop_stack();    /* FIXME: Should call LFUN_CREATE here in <= 7.2    * compatibility mode. */    }else{    ptr=&l->next;    continue;    }    } -  +  +  /* Note: We steal the references from l. */ +  push_object(o); +  *(Pike_sp++) = l->decode_arg; +     *ptr = l->next;    free((char *)l); -  +  +  /* Let the codec do it's job... */ +  apply_low(data->codec, fun, 2); +  pop_stack();    }    }    }else{    struct unfinished_prog_link *l;    l=ALLOC_STRUCT(unfinished_prog_link);    l->prog=p;    l->next=data->unfinished_programs;    data->unfinished_programs=l;    }    }
pike.git/src/encode.c:4633:    {    struct unfinished_prog_link *tmp=data->unfinished_programs;    data->unfinished_programs=tmp->next;    free((char *)tmp);    }       while(data->unfinished_objects)    {    struct unfinished_obj_link *tmp=data->unfinished_objects;    data->unfinished_objects=tmp->next; +  free_svalue(&tmp->decode_arg); +  free_object(tmp->o);    free((char *)tmp);    }      #ifdef PIKE_THREADS    data->thread_state = NULL;    free_object (data->thread_obj);   #endif       free( (char *) data);   }