pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:19:   #include "operators.h"   #include "builtin_functions.h"   #include "module_support.h"   #include "fsort.h"   #include "threads.h"   #include "stuff.h"   #include "version.h"   #include "bignum.h"   #include "pikecode.h"    - RCSID("$Id: encode.c,v 1.140 2002/05/02 14:48:10 mast Exp $"); + RCSID("$Id: encode.c,v 1.141 2002/05/02 16:32:13 mast Exp $");      /* #define ENCODE_DEBUG */      #ifdef ENCODE_DEBUG   /* Pass a nonzero integer as the third arg to encode_value,    * encode_value_canonic and decode_value to activate this debug. */   #define EDB(N,X) do { debug_malloc_touch(data); if (data->debug>=N) {X;} } while (0)   #else   #define EDB(N,X) do { debug_malloc_touch(data); } while (0)   #endif
pike.git/src/encode.c:882:    pop_stack();       push_svalue(val);       /* If we do not exist in cache, use backwards-    * compatible method, otherwise use newfangled    * style=3. -Hubbe    */    if(!low_mapping_lookup(data->encoded, val))    { +  int fun;    EDB(1,fprintf(stderr, "%*sZapping 3 -> 1 in TAG_OBJECT\n",    data->depth, ""));       /* This causes the code_entry above to    * become: code_entry(TAG_OBJECT, 1, data);    * -Hubbe    */    data->buf.s.str[to_change] = 99; -  apply(data->codec,"encode_object",1); +     -  if ((Pike_sp[-1].type == T_INT) && -  (!Pike_sp[-1].u.integer) && -  (Pike_sp[-1].subtype)) { -  /* encode_object() returned UNDEFINED (aka failed). */ -  Pike_error("Failed to encode object.\n"); -  } +  fun = find_identifier("encode_object", data->codec->prog); +  if (fun < 0) +  Pike_error("Cannot encode objects without an " +  "\"encode_object\" function in the codec.\n"); +  apply_low(data->codec,fun,1);       /* Put value back in cache for future reference -Hubbe */    mapping_insert(data->encoded, val, &tmp);    }    break;    }    /* FALL THROUGH */       default:    code_entry(TAG_OBJECT, 0,data);
pike.git/src/encode.c:2027:    case 1:    if(UNSAFE_IS_ZERO(Pike_sp-1))    {    EDB(1,fprintf(stderr, "%*sDecoded a failed object to <%d>: ",    data->depth, "", tmp.u.integer);    print_svalue(stderr, Pike_sp-1);    fputc('\n', stderr););    decode_value2(data);    pop_stack();    }else{ +  int fun;    struct object *o;    /* decode_value_clone_object does not call __INIT, so    * we want to do that ourselves...    */    o=decode_value_clone_object(Pike_sp-1);    debug_malloc_touch(o);    pop_stack();    push_object(o);       if(o->prog)
pike.git/src/encode.c:2061:       EDB(2,fprintf(stderr, "%*sDecoded an object to <%d>: ",    data->depth, "", tmp.u.integer);    print_svalue(stderr, Pike_sp-1);    fputc('\n', stderr););       ref_push_object(o);    decode_value2(data);    if(!data->codec)    Pike_error("Failed to decode (no codec)\n"); -  apply(data->codec,"decode_object",2); +  +  fun = find_identifier("decode_object", data->codec->prog); +  if (fun < 0) +  Pike_error("Cannot decode objects without a " +  "\"decode_object\" function in the codec.\n"); +  apply_low(data->codec,fun,2);    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...