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.286 2008/07/31 14:09:04 grubba Exp $ + || $Id: encode.c,v 1.287 2008/10/02 15:49:02 mast 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:1830:    *! Code a value into a string.    *!    *! This function takes a value, and converts it to a string. This string    *! can then be saved, sent to another Pike process, packed or used in    *! any way you like. When you want your value back you simply send this    *! string to @[decode_value()] and it will return the value you encoded.    *!    *! Almost any value can be coded, mappings, floats, arrays, circular    *! structures etc.    *! -  *! To encode objects, programs and functions, a codec object must be -  *! provided. +  *! If @[codec] is specified, it's used as the codec for the decode. +  *! If no codec is specified, the current master object will be used.    *! -  *! If @expr{codec->nameof(o)@} returns @tt{UNDEFINED@} for an object, -  *! @expr{val = o->encode_object(o)@} will be called. The returned value -  *! will be passed to @expr{o->decode_object(o, val)@} when the object is -  *! decoded. +  *! If @expr{@[codec]->nameof(o)@} returns @tt{UNDEFINED@} for an +  *! object, @expr{val = o->encode_object(o)@} will be called. The +  *! returned value will be passed to @expr{o->decode_object(o, val)@} +  *! when the object is decoded.    *!    *! @note    *!    *! When only simple types like int, floats, strings, mappings,    *! multisets and arrays are encoded, the produced string is very    *! portable between pike versions. It can at least be read by any    *! later version.    *!    *! The portability when objects, programs and functions are involved    *! depends mostly on the codec. If the byte code is encoded, i.e.
pike.git/src/encode.c:5148:    return;       case TAG_TYPE:    {    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"); +  if(*l < t) Pike_error("Format error: string too short\n");    push_string(make_shared_binary_string(*v, t));    (*l)-= t;    (*v)+= t;    return;       case TAG_ARRAY:    if(t<0) Pike_error("Format error: length of array is negative.\n");    check_stack(t);    for(i=0;i<t;i++) rec_restore_value(v,l);    f_aggregate(DO_NOT_WARN(t)); /* FIXME: Unbounded stack consumption. */
pike.git/src/encode.c:5181:    for(i=0;i<t;i++)    {    rec_restore_value(v,l);    rec_restore_value(v,l);    }    f_aggregate_mapping(DO_NOT_WARN(t*2)); /* FIXME: Unbounded stack consumption. */    return;       case TAG_OBJECT:    if(t<0) Pike_error("Format error: length of object is negative.\n"); -  if(*l < t) Pike_error("Format error: string to short\n"); +  if(*l < t) Pike_error("Format error: string too short\n");    push_string(make_shared_binary_string(*v, t));    (*l) -= t; (*v) += t;    APPLY_MASTER("objectof", 1);    return;       case TAG_FUNCTION:    if(t<0) Pike_error("Format error: length of function is negative.\n"); -  if(*l < t) Pike_error("Format error: string to short\n"); +  if(*l < t) Pike_error("Format error: string too short\n");    push_string(make_shared_binary_string(*v, t));    (*l) -= t; (*v) += t;    APPLY_MASTER("functionof", 1);    return;       case TAG_PROGRAM:    if(t<0) Pike_error("Format error: length of program is negative.\n"); -  if(*l < t) Pike_error("Format error: string to short\n"); +  if(*l < t) Pike_error("Format error: string too short\n");    push_string(make_shared_binary_string(*v, t));    (*l) -= t; (*v) += t;    APPLY_MASTER("programof", 1);    return;       default:    Pike_error("Format error: Unknown type tag %ld:%ld\n",    PTRDIFF_T_TO_LONG(i), PTRDIFF_T_TO_LONG(t));    }   }