pike.git / src / modules / Image / colors.c

version» Context lines:

pike.git/src/modules/Image/colors.c:202:   #include "interpret.h"   #include "svalue.h"   #include "array.h"   #include "mapping.h"   #include "builtin_functions.h"   #include "dmalloc.h"   #include "operators.h"   #include "module_support.h"   #include "sscanf.h"   #include "program_id.h" + #include "pike_types.h"      #include "image.h"   #include "colortable.h"         #define sp Pike_sp      static struct mapping *colors=NULL;   static struct object *colortable=NULL;   static struct array *colornames=NULL;      struct program *image_color_program=NULL;   extern struct program *image_colortable_program;    - static struct pike_string *str_array; - static struct pike_string *str_string; - static struct pike_string *str_int; +    static struct pike_string *str_r;   static struct pike_string *str_g;   static struct pike_string *str_b;   static struct pike_string *str_h;   static struct pike_string *str_s;   static struct pike_string *str_v;      static struct pike_string *no_name;      /* forward */
pike.git/src/modules/Image/colors.c:756:   **! see also: rgb, name   */      static void image_color_cast(INT32 args)   {    if (args!=1 ||    TYPEOF(sp[-1]) != T_STRING)    bad_arg_error("Image.Color.Color->cast",sp-args,args,0,"",sp-args,    "Bad arguments to Image.Color.Color->cast()\n");    -  if (sp[-1].u.string==str_array) +  if (sp[-1].u.string==literal_array_string)    {    image_color_rgb(args);    return;    } -  if (sp[-1].u.string==str_string) +  if (sp[-1].u.string==literal_string_string)    {    image_color_name(args);    return;    } -  if (sp[-1].u.string==str_int) +  if (sp[-1].u.string==literal_int_string)    {    pop_stack();    push_int( (THIS->rgb.r << 8 | THIS->rgb.g) << 8 | THIS->rgb.b );    return;    } -  Pike_error("Image.Color.Color->cast(): Can't cast to that\n"); +  pop_stack(); +  push_undefined();   }      static void image_color__sprintf(INT32 args)   {    int prec,x;       if (args<2)    SIMPLE_TOO_FEW_ARGS_ERROR("_sprintf",2);       if (TYPEOF(sp[-args]) != T_INT)
pike.git/src/modules/Image/colors.c:1714:   static void image_colors_values(INT32 args)   {    pop_n_elems(args);    if (!colors) make_colors();    ref_push_mapping(colors);    f_values(1);   }      void init_image_colors(void)   { -  str_array=make_shared_string("array"); -  str_string=make_shared_string("string"); -  str_int=make_shared_string("int"); +     str_r=make_shared_string("r");    str_g=make_shared_string("g");    str_b=make_shared_string("b");    str_h=make_shared_string("h");    str_s=make_shared_string("s");    str_v=make_shared_string("v");       no_name=make_shared_string("");       /* make color object program */       start_new_program();       ADD_STORAGE(struct color_struct);    set_init_callback(init_color_struct);    set_exit_callback(exit_color_struct);       /* color info methods */    -  ADD_FUNCTION("cast",image_color_cast,tFunc(tStr,tOr(tArray,tStr)),0); +  ADD_FUNCTION("cast",image_color_cast,tFunc(tStr,tOr(tArray,tStr)),ID_PROTECTED);    ADD_FUNCTION("_sprintf",image_color__sprintf,    tFunc(tInt tMap(tStr,tMix),tStr),0);    ADD_FUNCTION("`[]",image_color_index,tFunc(tOr(tStr,tInt),tOr(tInt,tFunction)),0);    ADD_FUNCTION("`->",image_color_index,tFunc(tOr(tStr,tInt),tOr(tInt,tFunction)),0);    ADD_FUNCTION("`==",image_color_equal,tFunc(tOr(tObjImpl_IMAGE_COLOR_COLOR,tInt),    tInt),0);    ADD_FUNCTION("__hash",image_color___hash,tFunc(tNone,tInt),0);       ADD_FUNCTION("_encode", image_color__encode,tFunc(tNone,tArr(tInt)),0);    ADD_FUNCTION("_decode", image_color__decode,tFunc(tInt,tVoid),0);
pike.git/src/modules/Image/colors.c:1836:    free_object(colortable);    free_array(colornames);       colors=NULL;    colortable=NULL;    colornames=NULL;       for (i=0; (size_t)i<sizeof(html_color)/sizeof(html_color[0]); i++)    free_string(html_color[i].pname);    } -  free_string(str_array); -  free_string(str_string); -  free_string(str_int); +     free_string(str_r);    free_string(str_g);    free_string(str_b);    free_string(str_h);    free_string(str_s);    free_string(str_v);       free_string(no_name);   }