Branch: Tag:

2003-06-05

2003-06-05 16:01:26 by Martin Stjernholm <mast@lysator.liu.se>

Make use of the conveniency too..

Rev: src/encode.c:1.182

2:   || 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.181 2003/06/05 15:54:23 mast Exp $ + || $Id: encode.c,v 1.182 2003/06/05 16:01:26 mast Exp $   */      #include "global.h"
27:   #include "bignum.h"   #include "pikecode.h"    - RCSID("$Id: encode.c,v 1.181 2003/06/05 15:54:23 mast Exp $"); + RCSID("$Id: encode.c,v 1.182 2003/06/05 16:01:26 mast Exp $");      /* #define ENCODE_DEBUG */   
847:       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););
922:    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)
974:    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)
1667:    int i;    data=&d;    -  check_all_args("encode_value_canonic", args, BIT_MIXED, BIT_VOID | BIT_OBJECT, +  check_all_args("encode_value_canonic", args, +  BIT_MIXED, +  BIT_VOID | BIT_OBJECT | BIT_ZERO,   #ifdef ENCODE_DEBUG    /* This argument is only an internal debug helper.    * It's intentionally not part of the function
1689:    data->depth = -2;   #endif    -  if(args > 1) +  if(args > 1 && Pike_sp[1-args].type == T_OBJECT)    {    data->codec=Pike_sp[1-args].u.object;    }else{
2417:    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:
2529:    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: {
2597:    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);   
2654:       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)