Branch: Tag:

2001-07-01

2001-07-01 14:27:08 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added program encoding type 3.
Added PROG_DYNAMIC_ID_START.

Rev: src/encode.c:1.100
Rev: src/program.c:1.339
Rev: src/program_id.h:1.9

25:   #include "version.h"   #include "bignum.h"    - RCSID("$Id: encode.c,v 1.99 2001/05/14 03:26:57 hubbe Exp $"); + RCSID("$Id: encode.c,v 1.100 2001/07/01 14:27:08 grubba Exp $");      /* #define ENCODE_DEBUG */   
365: Inside #if defined(USE_PIKE_TYPE)
   if(t->cdr)    {    int id = (int)(ptrdiff_t)t->cdr; -  if( id >= 65536 ) +  if( id >= PROG_DYNAMIC_ID_START )    {    struct program *p=id_to_program((ptrdiff_t)t->cdr);    if(p)
457:    addchar(EXTRACT_UCHAR(t++));    x=EXTRACT_INT(t);    t+=sizeof(INT32); -  if(x >= 65536) +  if(x >= PROG_DYNAMIC_ID_START)    {    struct program *p=id_to_program(x);    if(p)
784:    case T_PROGRAM:    {    int d; +  if (val->u.program->id < PROG_DYNAMIC_ID_START) { +  code_entry(type_to_tag(val->type), 3, data); +  push_int(val->u.program->id); +  encode_value2(Pike_sp-1, data); +  pop_stack(); +  break; +  }    if (data->canonic)    Pike_error("Canonical encoding of programs not supported.\n");    check_stack(1);
2006:    Pike_error("Failed to decode program.\n");    break;    +  case 3: +  decode_value2(data); +  if ((Pike_sp[-1].type == T_INT) && +  (Pike_sp[-1].u.integer < PROG_DYNAMIC_ID_START) && +  (Pike_sp[-1].u.integer > 0)) { +  struct program *p = id_to_program(Pike_sp[-1].u.integer); +  if (!p) { +  Pike_error("Failed to decode program %d\n", +  Pike_sp[-1].u.integer); +  } +  pop_stack(); +  push_program(p); +  } else { +  Pike_error("Failed to decode program.\n"); +  } +  break; +     default:    Pike_error("Cannot decode program encoding type %d\n",num);    }