pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:838:    * but that will have to wait until next time. /Hubbe    */    if(is_bignum_object(val->u.object))    {    code_entry(TAG_OBJECT, 2, data);    /* 256 would be better, but then negative numbers    * won't work... /Hubbe    */    push_int(36);    apply(val->u.object,"digits",1); + #ifdef PIKE_DEBUG    if(TYPEOF(Pike_sp[-1]) != T_STRING)    Pike_error("Gmp.mpz->digits did not return a string!\n"); -  + #endif    encode_value2(Pike_sp-1, data, 0);    pop_stack();    break;    }       if (data->canonic)    Pike_error("Canonical encoding of objects not supported.\n");    push_svalue(val);    apply(encoder_codec (data), "nameof", 1);    EDB(5, fprintf(stderr, "%*s->nameof: ", data->depth, "");
pike.git/src/encode.c:1002:    if(TYPEOF(Pike_sp[-1]) == T_INT &&    SUBTYPEOF(Pike_sp[-1]) == NUMBER_UNDEFINED)    {    struct program *p=val->u.program;    debug_malloc_touch(p);    pop_stack();    if( (p->flags & PROGRAM_HAS_C_METHODS) || p->event_handler )    {    int has_local_c_methods = 0;    for (d = 0; d < p->num_identifiers; d++) { -  if (IDENTIFIER_IS_C_FUNCTION(p->identifiers[d].identifier_flags)) { +  struct identifier *id = p->identifiers + d; +  if (IDENTIFIER_IS_C_FUNCTION(id->identifier_flags) && +  !low_is_variant_dispatcher(id)) {    has_local_c_methods = 1;    break;    }    }    if (has_local_c_methods) {    if(p->parent)    {    /* We have to remove ourselves from the cache for now */    struct svalue tmp = entry_id;    EDB(1, fprintf(stderr,
pike.git/src/encode.c:1374:    */    if ((i < 0) || !is_variant_dispatcher(p, i)) {    Pike_error("Failed to find dispatcher for inherited "    "variant function: %S\n", id->name);    }    if (PTR_FROM_INT(p, i)->inherit_offset) {    Pike_error("Dispatcher for variant function %S "    "is inherited.\n", id->name);    }    gs_flags = ref->id_flags & PTR_FROM_INT(p, i)->id_flags; -  if (id_dumped[PTR_FROM_INT(p, i)->identifier_offset]) { +  if (id_dumped[PTR_FROM_INT(p, i)->identifier_offset] || +  (i < d)) { +  /* Either already dumped, or the dispatcher is in +  * front of us, which indicates that we are overloading +  * an inherited function with a variant. +  */    gs_flags |= ID_VARIANT;    } else {    /* First variant. */    id_dumped[PTR_FROM_INT(p, i)->identifier_offset] = 1;    }    }       if (IDENTIFIER_IS_ALIAS(id->identifier_flags)) {    if ((!id->func.ext_ref.depth) &&    IDENTIFIER_IS_VARIABLE(id->identifier_flags)) {
pike.git/src/encode.c:1831:    data->delayed = allocate_array (0);    SET_SVAL(data->counter, T_INT, NUMBER_NUMBER, integer, COUNTER_START);      #ifdef ENCODE_DEBUG    data->debug = args > 2 ? Pike_sp[2-args].u.integer : 0;    data->depth = -2;   #endif       if(args > 1 && TYPEOF(Pike_sp[1-args]) == T_OBJECT)    { -  if (SUBTYPEOF(Pike_sp[1-args])) { -  Pike_error("encode_value: " -  "The codec may not be a subtyped object yet.\n"); -  } +  if (SUBTYPEOF(Pike_sp[1-args])) +  Pike_error("The codec may not be a subtyped object yet.\n"); +     data->codec=Pike_sp[1-args].u.object;    add_ref (data->codec);    }else{    data->codec=NULL;    }       SET_ONERROR(tmp, free_encode_data, data);    addstr("\266ke0", 4);       encode_value2(Pike_sp-args, data, 1);
pike.git/src/encode.c:1909:    data->delayed = allocate_array (0);    SET_SVAL(data->counter, T_INT, NUMBER_NUMBER, integer, COUNTER_START);      #ifdef ENCODE_DEBUG    data->debug = args > 2 ? Pike_sp[2-args].u.integer : 0;    data->depth = -2;   #endif       if(args > 1 && TYPEOF(Pike_sp[1-args]) == T_OBJECT)    { -  if (SUBTYPEOF(Pike_sp[1-args])) { -  Pike_error("encode_value_canonic: " -  "The codec may not be a subtyped object yet.\n"); -  } +  if (SUBTYPEOF(Pike_sp[1-args])) +  Pike_error("The codec may not be a subtyped object yet.\n"); +     data->codec=Pike_sp[1-args].u.object;    add_ref (data->codec);    }else{    data->codec=NULL;    }       SET_ONERROR(tmp, free_encode_data, data);    addstr("\266ke0", 4);       encode_value2(Pike_sp-args, data, 1);
pike.git/src/encode.c:1996:    if (data->codec) return data->codec;    MAKE_CONST_STRING (decoder_str, "Decoder");    return data->codec = lookup_codec (decoder_str);   }      static void decode_value2(struct decode_data *data);      static int my_extract_char(struct decode_data *data)   {    if(data->ptr >= data->len) -  Pike_error("Decode error: Not enough data in string.\n"); +  Pike_error("Not enough data in string.\n");    return data->data [ data->ptr++ ];   }      static DECLSPEC(noreturn) void decode_error (    struct decode_data *data, struct svalue *decoding, const char *msg, ...)    ATTRIBUTE((noinline,noreturn));      static DECLSPEC(noreturn) void decode_error (    struct decode_data *data, struct svalue *decoding, const char *msg, ...)   {
pike.git/src/encode.c:2122:    if (sz < 0) \    decode_error (data, NULL, "Illegal negative size %td.\n", sz); \    if (sz > data->len - data->ptr) \    decode_error (data, NULL, "Too large size %td (max is %td).\n", \    sz, data->len - data->ptr); \    STR=make_shared_binary_string((char *)(data->data + data->ptr), sz); \    data->ptr += sz; \    } \   }while(0)    - #define getdata(X) do { \ -  long length; \ -  decode_entry(TAG_STRING, length,data); \ -  if(data->pass == 1) \ -  get_string_data(X, length, data); \ -  else \ -  data->ptr+=length; \ -  }while(0) -  - #define getdata3(X) do { \ -  INT32 what, e; \ -  INT64 num; \ -  DECODE("getdata3"); \ -  switch(what & TAG_MASK) \ -  { \ -  case TAG_INT: \ -  X=0; \ -  break; \ -  \ -  case TAG_STRING: \ -  get_string_data(X,num,data); \ -  break; \ -  \ -  default: \ -  decode_error (data, NULL, "Tag is wrong: %d\n", what & TAG_MASK); \ -  } \ - }while(0) -  +    #define decode_number(X,data) do { \    INT32 what, e; \    INT64 num; \    DECODE("decode_number"); \    X=(what & TAG_MASK) | ((unsigned INT64)num<<4); \    EDB(5, fprintf(stderr, "%*s ==>%ld\n", \    data->depth, "", (long) X)); \    }while(0) \      
pike.git/src/encode.c:2375:    get_name_of_type(TYPEOF(Pike_sp[-1])));    }    pop_stack();    }    }       UNSET_ONERROR(err2);    UNSET_ONERROR(err1);   }    -  - static void zap_placeholder(struct object *placeholder) - { -  /* fprintf(stderr, "Destructing placeholder.\n"); */ -  if (placeholder->storage) { -  debug_malloc_touch(placeholder); -  destruct(placeholder); -  } else { -  free_program(placeholder->prog); -  placeholder->prog = NULL; -  debug_malloc_touch(placeholder); -  } -  free_object(placeholder); - } -  -  +    #define SETUP_DECODE_MEMOBJ(TYPE, U, VAR, ALLOCATE,SCOUR) do { \    struct svalue *tmpptr; \    struct svalue tmp; \    if(data->pass > 1 && \    (tmpptr=low_mapping_lookup(data->decoded, & entry_id))) \    { \    tmp=*tmpptr; \    VAR=tmp.u.U; \    SCOUR; \    }else{ \