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.268 2008/05/21 13:07:02 grubba Exp $ + || $Id: encode.c,v 1.269 2008/05/21 20:07:41 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:2930:    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");    apply_low(data->codec,fun,2); +  if ((Pike_sp[-1].type == T_ARRAY) && +  ((fun = FIND_LFUN(o->prog, LFUN_CREATE)) != -1)) { +  /* Call lfun::create(@args). */ +  INT32 args; +  Pike_sp--; +  args = Pike_sp->u.array->size; +  if (args) { +  /* Note: Eats reference */ +  push_array_items(Pike_sp->u.array); +  } else { +  free_array(Pike_sp->u.array); +  } +  apply_low(o, fun, args); +  }    pop_stack();    }       break;      #ifdef AUTO_BIGNUM    /* It is possible that we should do this even without    * AUTO_BIGNUM /Hubbe    * However, that requires that some of the bignum functions    * are always available...
pike.git/src/encode.c:3598:    }else{    ptr=&l->next;    }    }    }       /* Go through the linked list of unfinished objects    * to see what objects are now finished.    */    { -  int fun = -1; +  int decode_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_fun = +  find_identifier("decode_object", data->codec->prog); +  if (decode_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);)    { -  +  int fun;    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{
pike.git/src/encode.c:3636:    }       /* 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); +  apply_low(data->codec, decode_fun, 2); +  if ((Pike_sp[-1].type == T_ARRAY) && +  ((fun = FIND_LFUN(o->prog, LFUN_CREATE)) != -1)) { +  /* Call lfun::create(@args). */ +  INT32 args; +  Pike_sp--; +  args = Pike_sp->u.array->size; +  if (args) { +  /* Note: Eats reference to the array. */ +  push_array_items(Pike_sp->u.array); +  } else { +  free_array(Pike_sp->u.array); +  } +  apply_low(o, fun, args); +  }    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;    }