pike.git / src / modules / _Stdio / buffer.cmod

version» Context lines:

pike.git/src/modules/_Stdio/buffer.cmod:1261:    PIKEFUN Buffer add_int8( int i )    {    Buffer *io = THIS;    *io_add_space(io,1,0)=i;    io->len++;    Pike_sp--;    io_trigger_output( io );    ref_push_object(Pike_fp->current_object);    }    +  /*! @decl Buffer add_int8( Gmp.mpz ) +  *! Adds a single byte to the buffer. +  */ +  PIKEFUN Buffer add_int8( object mpz ) +  { +  INT64 i = 0; +  Buffer *io = THIS; +  unsigned char *p = io_add_space(io,1,0); +  if (!low_int64_from_bignum(&i, mpz)) { +  SIMPLE_ARG_TYPE_ERROR("add_int8", 1, "int|Gmp.mpz"); +  } +  *p = i; +  io->len++; +  ref_push_object(Pike_fp->current_object); +  } +     /*! @decl Buffer add_int16( int(16bit) )    *!    *! Add a 16-bit network byte order value to the buffer    */    PIKEFUN Buffer add_int16( int i )    {    Buffer *io = THIS;    unsigned char *p = io_add_space(io,2,0);    p[0] = i>>8;    p[1] = i;    io->len += 2;    io_trigger_output( io );    ref_push_object(Pike_fp->current_object);    }    -  +  /*! @decl Buffer add_int16( Gmp.mpz ) +  *! +  *! Add a 16-bit network byte order value to the buffer +  */ +  PIKEFUN Buffer add_int16( object mpz ) +  { +  INT64 i = 0; +  Buffer *io = THIS; +  unsigned char *p = io_add_space(io,2,0); +  if (!low_int64_from_bignum(&i, mpz)) { +  SIMPLE_ARG_TYPE_ERROR("add_int16", 1, "int|Gmp.mpz"); +  } +  p[0] = i>>8; +  p[1] = i; +  io->len += 2; +  ref_push_object(Pike_fp->current_object); +  } +     /*! @decl Buffer add_int32( int i )    *! Adds a 32 bit network byte order value to the buffer    */    PIKEFUN Buffer add_int32( int i )    {    Buffer *io = THIS;    unsigned char *p = io_add_space(io,4,0);    p[0] = i>>24;    p[1] = i>>16;    p[2] = i>>8;
pike.git/src/modules/_Stdio/buffer.cmod:1300:    }       /*! @decl Buffer add_int32( Gmp.mpz i )    *! Adds a 32 bit network byte order value to the buffer    */    PIKEFUN Buffer add_int32( object mpz )    {    INT64 i = 0;    Buffer *io = THIS;    unsigned char *p = io_add_space(io,4,0); -  if (!int64_from_bignum(&i, mpz)) { +  if (!low_int64_from_bignum(&i, mpz)) {    SIMPLE_ARG_TYPE_ERROR("add_int32", 1, "int|Gmp.mpz");    }    p[0] = i>>24;    p[1] = i>>16;    p[2] = i>>8;    p[3] = i;    io->len += 4;    io_trigger_output( io );    ref_push_object(Pike_fp->current_object);    }
pike.git/src/modules/_Stdio/buffer.cmod:2750:    }    else if( TYPEOF(*x) == PIKE_T_INT )    {    INT_TYPE len = x->u.integer;    if( len <= 0 )    this->buffer = xalloc(1);    else    this->buffer = xalloc(len);    this->allocated = MAXIMUM(len,1);    this->malloced = 1; +  pop_stack();    }    else -  +  {    io_append_svalue( THIS, x ); -  +  pop_stack();    } -  +  }       INIT {    Buffer *this = THIS;    this->max_waste = 0.615;    this->this = Pike_fp->current_object;    }       EXIT {    Buffer *this = THIS;    io_unlink_external_storage( this );