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.273 2008/05/26 15:38:56 grubba Exp $ + || $Id: encode.c,v 1.274 2008/05/28 16:59:43 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:885:    {    case T_INT:    if(Pike_sp[-1].subtype == NUMBER_UNDEFINED)    {    int to_change = data->buf.s.len;    struct svalue tmp = entry_id;       EDB(5,fprintf(stderr, "%*s(UNDEFINED)\n", data->depth, ""));       if (val->subtype) { -  Pike_error("Encoding of subtyped objects is not supported yet.\n"); +  /* Subtyped object. +  * +  * Encode the subtype, and then try encoding the plain object. +  */ +  code_entry(TAG_OBJECT, 4, data); +  code_number(val->subtype, data); +  pop_stack(); +  ref_push_object(val->u.object); +  break;    }       /* We have to remove ourself from the cache */    map_delete(data->encoded, val);       pop_stack();    push_svalue(val);    f_object_program(1);       /* Code the program */
pike.git/src/encode.c:2850:    /* This special case is handled efficiently by merge_multisets. */    merge_multisets (m, l, PIKE_MERGE_DESTR_A | PIKE_ARRAY_OP_ADD);    free_multiset (l);    }    ref_push_multiset(m);    goto decode_done;    }       case TAG_OBJECT:    { +  int subtype = 0; +  if (num == 4) { +  decode_number(subtype, data); +  }    decode_value2(data);       switch(num)    {    case 0:    apply(data->codec,"objectof", 1);    break;       case 1:    {
pike.git/src/encode.c:2977: Inside #if defined(AUTO_BIGNUM)
  #endif    break;    }      #endif    case 3:    pop_stack();    decode_value2(data);    break;    +  case 4: +  /* Subtyped object. */ +  if ((Pike_sp[-1].type != T_OBJECT) || Pike_sp[-1].subtype || +  !Pike_sp[-1].u.object->prog) { +  decode_error(NULL, Pike_sp-1, "Expected plain object. Got: "); +  } +  if ((subtype < 0) || +  (subtype >= Pike_sp[-1].u.object->prog->num_inherits)) { +  decode_error(NULL, Pike_sp-1, +  "Invalid subtype for object: %d (max: %d). Object: ", +  subtype, Pike_sp[-1].u.object->prog->num_inherits); +  } +  Pike_sp[-1].subtype = subtype; +  break; +     default:    Pike_error("Object coding not compatible.\n");    break;    }       if((Pike_sp[-1].type != T_OBJECT) && data->pickyness) {    if (num != 2) {    decode_error(NULL, Pike_sp - 1, "Failed to decode object. Got: ");    } else if (Pike_sp[-1].type != PIKE_T_INT) {    decode_error(NULL, Pike_sp - 1, "Failed to decode bignum. Got: ");