pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:18:   #include "pike_error.h"   #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"    - RCSID("$Id: encode.c,v 1.84 2001/02/21 13:46:13 grubba Exp $"); + RCSID("$Id: encode.c,v 1.85 2001/02/22 21:15:34 grubba Exp $");      /* #define ENCODE_DEBUG */      #ifdef ENCODE_DEBUG   #define EDB(X) X   #else   #define EDB(X)   #endif      /* The sp macro conflicts with Solaris 2.5.1's <sys/conf.h>. */
pike.git/src/encode.c:256:    num >> 4, data);   }      #ifdef _REENTRANT   static void do_enable_threads(void)   {    exit_threads_disable(NULL);   }   #endif    - static ptrdiff_t encode_type(char *t, struct encode_data *data) + static ptrdiff_t encode_type(unsigned char *t, struct encode_data *data)   { -  char *q=t; +  unsigned char *q = t;   one_more_type:    addchar(EXTRACT_UCHAR(t));    switch(EXTRACT_UCHAR(t++))    {    default:    fatal("error in type string.\n");    /*NOTREACHED*/       break;   
pike.git/src/encode.c:368:       if((val->type == T_OBJECT ||    (val->type==T_FUNCTION && val->subtype!=FUNCTION_BUILTIN)) &&    !val->u.object->prog)    val = &dested;       if((tmp=low_mapping_lookup(data->encoded, val)))    {    code_entry(TAG_AGAIN, tmp->u.integer, data);    return; -  }else{ +  }else if (val->type != T_TYPE) {    mapping_insert(data->encoded, val, &data->counter);    data->counter.u.integer++;    }          switch(val->type)    {    case T_INT:    /* FIXME:    * if INT_TYPE is larger than 32 bits (not currently happening)
pike.git/src/encode.c:390:    * Gmp.mpz objects    */    code_entry(TAG_INT, val->u.integer,data);    break;       case T_STRING:    adddata(val->u.string);    break;       case T_TYPE: +  /* NOTE: Types are added to the encoded mapping AFTER they have +  * been encoded, to simplify decoding. +  */    if (data->canonic)    Pike_error("Canonical encoding of the type type not supported.\n"); -  Pike_error("Encoding of the type type not supported yet!\n"); +  code_entry(TAG_TYPE, val->u.type->len, data); +  encode_type(val->u.type->str, data); +  mapping_insert(data->encoded, val, &data->counter); +  data->counter.u.integer++;    break;       case T_FLOAT:    {    if(val->u.float_number==0.0)    {    code_entry(TAG_FLOAT,0,data);    code_entry(TAG_FLOAT,0,data);    }else{    INT64 x;
pike.git/src/encode.c:681:    }    encode_value2(Pike_sp-1,data);    pop_stack();       adddata3(p->inherits[d].name);    }       for(d=0;d<p->num_identifiers;d++)    {    adddata(p->identifiers[d].name); -  /* FIXME! */ - #ifndef USE_PIKE_TYPE +     encode_type(p->identifiers[d].type->str, data); - #endif /* !USE_PIKE_TYPE */ +     code_number(p->identifiers[d].identifier_flags,data);    code_number(p->identifiers[d].run_time_type,data);    code_number(p->identifiers[d].opt_flags,data);    code_number(p->identifiers[d].func.offset,data);    }       for(d=0;d<p->num_constants;d++)    {    encode_value2(& p->constants[d].sval, data);    adddata3(p->constants[d].name);
pike.git/src/encode.c:1160:    tmp.u.integer=num;    if((tmp2=low_mapping_lookup(data->decoded, &tmp)))    {    push_svalue(tmp2);    }else{    Pike_error("Failed to decode string. (invalid T_AGAIN)\n");    }    return;       case TAG_INT: +  tmp.type = T_INT;    tmp=data->counter;    data->counter.u.integer++;    push_int(num);    break;       case TAG_STRING:    {    struct pike_string *str; -  +  tmp.type = T_INT;    tmp=data->counter;    data->counter.u.integer++;    get_string_data(str, num, data);    push_string(str);    break;    }       case TAG_FLOAT:    {    double res;
pike.git/src/encode.c:1199:    DECODE("float");       EDB(fprintf(stderr, "Exponent: %d\n", num));       push_float(LDEXP(res, num));    break;    }       case TAG_TYPE:    { -  Pike_error("Failed to decode string. " -  "(decode of the type type isn't supported yet).\n"); -  break; +  struct pike_type *t; +  +  decode_type(t, data); +  check_type_string(t); +  push_type_value(t); +  +  tmp.type = T_INT; +  tmp = data->counter; +  data->counter.u.integer++;    } -  +  break;       case TAG_ARRAY:    {    struct array *a;    if(num < 0)    Pike_error("Failed to decode string. (array size is negative)\n");       /* Heruetical */    if(data->ptr + num > data->len)    Pike_error("Failed to decode array. (not enough data)\n");
pike.git/src/encode.c:1758:    return;       case TAG_FLOAT:    if(sizeof(ptrdiff_t) < sizeof(FLOAT_TYPE)) /* FIXME FIXME FIXME FIXME */    Pike_error("Float architecture not supported.\n");    push_int(DO_NOT_WARN(t)); /* WARNING! */    Pike_sp[-1].type = T_FLOAT;    return;       case TAG_TYPE: -  Pike_error("Format error: decoding of the type type not supported yet.\n"); +  { +  Pike_error("Format error: TAG_TYPE not supported yet.\n"); +  }    return;       case TAG_STRING:    if(t<0) Pike_error("Format error: length of string is negative.\n");    if(*l < t) Pike_error("Format error: string to short\n");    push_string(make_shared_binary_string(*v, t));    (*l)-= t;    (*v)+= t;    return;