pike.git / src / modules / Image / encodings / xcf.c

version» Context lines:

pike.git/src/modules/Image/encodings/xcf.c:14:   #include "object.h"   #include "svalue.h"   #include "threads.h"   #include "interpret.h"   #include "svalue.h"   #include "mapping.h"   #include "pike_error.h"   #include "stralloc.h"   #include "builtin_functions.h"   #include "bignum.h" + #include "pike_types.h"      #include "image.h"   #include "colortable.h"         #define sp Pike_sp   #define fp Pike_fp      extern struct program *image_colortable_program;   extern struct program *image_program;
pike.git/src/modules/Image/encodings/xcf.c:58:    struct pike_string *s;    ptrdiff_t offset;    ptrdiff_t len;   };      static struct program *substring_program;   #define SS(X) ((struct substring*)X->storage)      static void f_substring_cast( INT32 args )   { -  /* FIXME: assumes string */ +  struct pike_string *type = sp[-args].u.string; +  pop_n_elems(args); /* type have at least one more reference. */ +  +  if( type == literal_string_string ) +  {    struct substring *s = SS(fp->current_object); -  pop_n_elems( args ); +     push_string( make_shared_binary_string( (((char *)s->s->str)+s->offset),    s->len ) );    } -  +  else +  push_undefined(); + }      static void f_substring_index( INT32 args )   {    ptrdiff_t i = sp[-1].u.integer;    struct substring *s = SS(fp->current_object);    pop_n_elems( args );       if( i < 0 ) i = s->len + i;    if( i >= s->len ) {    Pike_error("Index out of bounds, %ld > %ld\n", i,
pike.git/src/modules/Image/encodings/xcf.c:100:    x = sp[-2].u.integer;    pop_n_elems( args );       switch( x )    {    case 't':    push_text("SubString");    return;    case 'O':    push_text("SubString( %O /* [+%d .. %d] */ )" ); -  push_text("string"); f_substring_cast( 1 ); +  ref_push_string(literal_string_string); f_substring_cast( 1 );       push_int64( s->len );    push_int64( s->offset );    f_sprintf( 4 );    return;    default:    push_int(0);    return;    }   }
pike.git/src/modules/Image/encodings/xcf.c:1399:    UNSET_ONERROR(err);    free( colortable );    }       pop_n_elems(args);    push_int(0);   }         static struct program *image_encoding_xcf_program=NULL; - void init_image_xcf() + void init_image_xcf(void)   {    ADD_FUNCTION( "___decode", image_xcf____decode, tFunc(tStr,tMapping), 0);       ADD_FUNCTION( "_decode_tiles", image_xcf_f__decode_tiles, tFunction, 0);       add_integer_constant( "PROP_END", PROP_END,0 );    add_integer_constant( "PROP_COLORMAP", PROP_COLORMAP, 0 );    add_integer_constant( "PROP_ACTIVE_LAYER", PROP_ACTIVE_LAYER, 0 );    add_integer_constant( "PROP_ACTIVE_CHANNEL", PROP_ACTIVE_CHANNEL, 0 );    add_integer_constant( "PROP_SELECTION", PROP_SELECTION, 0 );
pike.git/src/modules/Image/encodings/xcf.c:1482:    add_integer_constant( "GRAYA_GIMAGE", GRAYA_GIMAGE, 0 );    add_integer_constant( "INDEXED_GIMAGE", INDEXED_GIMAGE, 0 );    add_integer_constant( "INDEXEDA_GIMAGE", INDEXEDA_GIMAGE, 0 );      #define STRING(X) s_##X = make_shared_binary_string(#X,sizeof( #X )-sizeof(""))   #include "xcf_constant_strings.h"   #undef STRING       start_new_program();    ADD_STORAGE( struct substring ); -  ADD_FUNCTION("cast", f_substring_cast, tFunc(tStr,tMix), 0); +  ADD_FUNCTION("cast", f_substring_cast, tFunc(tStr,tMix), ID_PRIVATE);    ADD_FUNCTION("`[]", f_substring_index, tFunc(tInt,tInt), 0);    ADD_FUNCTION("get_short", f_substring_get_short, tFunc(tInt,tInt), 0 );    ADD_FUNCTION("get_ushort", f_substring_get_ushort, tFunc(tInt,tInt), 0 );    ADD_FUNCTION("get_int", f_substring_get_int, tFunc(tInt,tInt), 0 );    ADD_FUNCTION("get_uint", f_substring_get_uint, tFunc(tInt,tInt), 0 );    ADD_FUNCTION("_sprintf",f_substring__sprintf, tFunc(tInt tMapping,tMix), 0);      /* set_init_callback(init_substring); */    set_exit_callback(free_substring);    substring_program = end_program();   }       - void exit_image_xcf() + void exit_image_xcf(void)   {   #define STRING(X) free_string(s_##X)   #include "xcf_constant_strings.h"   #undef STRING    free_program( substring_program );   }