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.158 2002/11/23 20:05:14 mast Exp $ + || $Id: encode.c,v 1.159 2002/12/07 14:50:57 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.158 2002/11/23 20:05:14 mast Exp $"); + RCSID("$Id: encode.c,v 1.159 2002/12/07 14:50:57 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:743:    check_stack(1);      #ifdef AUTO_BIGNUM    /* This could be implemented a lot more generic,    * 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 -  * doesn't work... /Hubbe +  * won't work... /Hubbe    */    push_int(36);    apply(val->u.object,"digits",1);    if(Pike_sp[-1].type != T_STRING)    Pike_error("Gmp.mpz->digits did not return a string!\n");    encode_value2(Pike_sp-1, data);    pop_stack();    break;    }   #endif
pike.git/src/encode.c:3762:    if(j & 0x80) return (j & 0x7f);       if((j & ~8) > 4)    Pike_error("Format error: Error in format string, invalid integer.\n");    i=0;    while(j & 7) { i=(i<<8) | extract_char(v,l); j--; }    if(j & 8) return -i;    return i;   }    + /*! @class MasterObject +  */ +  + /*! @decl inherit Codec +  *! +  *! The master object is used as a fallback codec by @[encode_value()] +  *! and @[decode_value()] if no codec was given. +  *! +  *! It will also be used as a codec if @[decode_value()] encounters +  *! old-style @[encode_value()]'ed data. +  */ +  + /*! @endclass +  */ +  + /*! @class Codec +  *! +  *! Codec objects are used by @[encode_value()] and @[decode_value()] +  *! to encode and decode objects, functions and programs. +  *! +  *! @note +  *! @[encode_value()] and @[decode_value()] will use the current +  *! master object as fallback codec object if no codec was specified. +  */ +  + /*! @decl mixed nameof(object|function|program x) +  *! +  *! Called by @[encode_value()] to encode objects, functions and programs. +  *! +  *! @returns +  *! Returns something encodable on success, typically a string. +  *! The returned value will be passed to the corresponding +  *! @[objectof()], @[functionof()] or @[programof()] by +  *! @[decode_value()]. +  *! +  *! Returns @[UNDEFINED] on failure. +  *! +  *! @note +  *! @[encode_value()] has fallbacks for some classes of objects, +  *! functions and programs. +  *! +  *! @seealso +  *! @[objectof()], @[functionof()], @[objectof()] +  */ +  + /*! @decl object objectof(string data) +  *! +  *! Decode object encoded in @[data]. +  *! +  *! This function is called by @[decode_value()] when it encounters +  *! encoded objects. +  *! +  *! @param data +  *! Encoding of some object as specified by @[nameof()]. +  *! +  *! @param minor +  *! Minor version. +  *! +  *! @returns +  *! Returns the decoded object. +  *! +  *! @seealso +  *! @[functionof()], @[programof()] +  */ +  + /*! @decl function functionof(string data) +  *! +  *! Decode function encoded in @[data]. +  *! +  *! This function is called by @[decode_value()] when it encounters +  *! encoded functions. +  *! +  *! @param data +  *! Encoding of some function as specified by @[nameof()]. +  *! +  *! @param minor +  *! Minor version. +  *! +  *! @returns +  *! Returns the decoded function. +  *! +  *! @seealso +  *! @[objectof()], @[programof()] +  */ +  + /*! @decl program programof(string data) +  *! +  *! Decode program encoded in @[data]. +  *! +  *! This function is called by @[decode_value()] when it encounters +  *! encoded programs. +  *! +  *! @param data +  *! Encoding of some program as specified by @[nameof()]. +  *! +  *! @param minor +  *! Minor version. +  *! +  *! @returns +  *! Returns the decoded program. +  *! +  *! @seealso +  *! @[functionof()], @[objectof()] +  */ +  + /*! @decl program __register_new_program(program p) +  *! +  *! Called by @[decode_value()] to register a program that is +  *! being decoded. +  *! +  *! @returns +  *! Returns a program os a place-holder program. +  */ +  + /*! @endclass +  */ +    static void rec_restore_value(char **v, ptrdiff_t *l)   {    ptrdiff_t t, i;       i = extract_int(v,l);    t = extract_int(v,l);    switch(i)    {    case TAG_INT:    push_int(DO_NOT_WARN(t));