pike.git/
src/
modules/
Image/
colors.c
Branch:
Tag:
Non-build tags
All tags
No tags
2014-08-18
2014-08-18 15:38:59 by Martin Nilsson <nilsson@opera.com>
68ec3f29a244c8dd4c94d6fde8133d2d5697428c (
22
lines) (+
8
/-
14
)
[
Show
|
Annotate
]
Branch:
8.0
Improved cast.
209:
#include "module_support.h" #include "sscanf.h" #include "program_id.h"
+
#include "pike_types.h"
#include "image.h" #include "colortable.h"
223:
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;
763:
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)
1721:
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");
1743:
/* 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);
1843:
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);