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.179 2003/06/05 15:03:38 mast Exp $ + || $Id: encode.c,v 1.180 2003/06/05 15:30:52 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:20:   #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.179 2003/06/05 15:03:38 mast Exp $"); + RCSID("$Id: encode.c,v 1.180 2003/06/05 15:30:52 grubba Exp $");      /* #define ENCODE_DEBUG */      /* Use the old encoding method for programs. */   /* #define OLD_PIKE_ENCODE_PROGRAM */      #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)
pike.git/src/encode.c:840: Inside #if defined(AUTO_BIGNUM)
   if(Pike_sp[-1].type != T_STRING)    Pike_error("Gmp.mpz->digits did not return a string!\n");    encode_value2(Pike_sp-1, data, 0);    pop_stack();    break;    }   #endif       if (data->canonic)    Pike_error("Canonical encoding of objects not supported.\n"); +  if (data->codec) {    push_svalue(val);    apply(data->codec, "nameof", 1); -  +  } else { +  push_undefined(); +  }    EDB(5, fprintf(stderr, "%*s->nameof: ", data->depth, "");    print_svalue(stderr, Pike_sp-1);    fputc('\n', stderr););    switch(Pike_sp[-1].type)    {    case T_INT:    if(Pike_sp[-1].subtype == NUMBER_UNDEFINED)    {    int to_change = data->buf.s.len;    struct svalue tmp = entry_id;
pike.git/src/encode.c:911:    }    encode_value2(Pike_sp-1, data, 0);    pop_stack();    break;       case T_FUNCTION:    /* FIXME: Ought to have special treatment of trampolines. */    if (data->canonic)    Pike_error("Canonical encoding of functions not supported.\n");    check_stack(1); +  if (data->codec) {    push_svalue(val);    apply(data->codec,"nameof", 1); -  +  } else { +  push_undefined(); +  }    if(Pike_sp[-1].type == T_INT && Pike_sp[-1].subtype==NUMBER_UNDEFINED)    {    if(val->subtype != FUNCTION_BUILTIN)    {    if(find_shared_string_identifier(ID_FROM_INT(val->u.object->prog, val->subtype)->name,    val->u.object->prog)==val->subtype)    {    /* We have to remove ourself from the cache for now */    struct svalue tmp = entry_id;    map_delete(data->encoded, val);
pike.git/src/encode.c:959:    if (val->u.program->id < PROG_DYNAMIC_ID_START) {    code_entry(TAG_PROGRAM, 3, data);    push_int(val->u.program->id);    encode_value2(Pike_sp-1, data, 0);    pop_stack();    break;    }    if (data->canonic)    Pike_error("Canonical encoding of programs not supported.\n");    check_stack(1); +  if (data->codec) {    push_svalue(val);    apply(data->codec,"nameof", 1); -  +  } else { +  push_undefined(); +  }    if(Pike_sp[-1].type == val->type)    Pike_error("Error in master()->nameof(), same type returned.\n");    if(Pike_sp[-1].type == T_INT && Pike_sp[-1].subtype == NUMBER_UNDEFINED)    {    struct program *p=val->u.program;    pop_stack();    if( (p->flags & PROGRAM_HAS_C_METHODS) || p->event_handler )    {    if(p->parent)    {
pike.git/src/encode.c:2382:    goto decode_done;    }       case TAG_OBJECT:    {    decode_value2(data);       switch(num)    {    case 0: +  if (data->codec) {    apply(data->codec,"objectof", 1); -  +  } else { +  decode_error(NULL, Pike_sp-1, +  "Failed to decode object (no codec). Got: "); +  }    break;       case 1:    {    int fun;    /* decode_value_clone_object does not call __INIT, so    * we want to do that ourselves...    */    struct object *o=decode_value_clone_object(Pike_sp-1);   
pike.git/src/encode.c:2489:       break;    }       case TAG_FUNCTION:    decode_value2(data);       switch(num)    {    case 0: +  if (data->codec) {    apply(data->codec,"functionof", 1); -  +  } else { +  decode_error(NULL, Pike_sp-1, +  "Failed to decode function (no codec). Got: "); +  }    break;       case 1: {    struct program *p;    if(Pike_sp[-1].type != T_OBJECT && data->pickyness)    decode_error(NULL, Pike_sp - 1,    "Failed to decode function object. Got: ");       decode_value2(data);    if(Pike_sp[-1].type != T_STRING && data->pickyness)
pike.git/src/encode.c:2552:    EDB(3,    fprintf(stderr, "%*s TAG_PROGRAM(%d)\n",    data->depth, "", num));    switch(num)    {    case 0:    {    struct program *p;       decode_value2(data); +  if (data->codec) {    apply(data->codec,"programof", 1); -  +  } else { +  decode_error(NULL, Pike_sp-1, +  "Failed to decode program (no codec). Got: "); +  }       p = program_from_svalue(Pike_sp-1);       if (!p) {    if(data->pickyness)    decode_error(NULL, Pike_sp - 1,    "Failed to decode program. Got: ");    pop_stack();    push_undefined();    break;
pike.git/src/encode.c:2604:       SET_ONERROR(err3, zap_unfinished_program, p);       if(data->pass == 1)    {    if(! data->supporter.prog)    data->supporter.prog = p;       debug_malloc_touch(p);    ref_push_program(p); +  if (data->codec) {    apply(data->codec, "__register_new_program", 1); -  +  }       /* return a placeholder */    if(Pike_sp[-1].type == T_OBJECT)    {    placeholder=Pike_sp[-1].u.object;    if(placeholder->prog != null_program)    Pike_error("Placeholder object is not a __null_program clone.\n");    dmalloc_touch_svalue(Pike_sp-1);    Pike_sp--;    }