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

version» Context lines:

pike.git/src/modules/Image/layers.c:730:    free_object(THIS->image);    THIS->image=NULL;    THIS->img=NULL;       if (THIS->alpha)    free_object(THIS->alpha);    THIS->alpha=NULL;    THIS->alp=NULL;       if (args>=1) { -  if ( Pike_sp[-args].type!=T_OBJECT ) +  if ( TYPEOF(Pike_sp[-args]) != T_OBJECT )    { -  if (Pike_sp[-args].type!=T_INT || +  if (TYPEOF(Pike_sp[-args]) != T_INT ||    Pike_sp[-args].u.integer!=0)    SIMPLE_BAD_ARG_ERROR("Image.Layer->set_image",1,    "object(Image)|int(0)");    }    else if ((img=(struct image*)    get_storage(Pike_sp[-args].u.object,image_program)))    {    THIS->image=Pike_sp[-args].u.object;    add_ref(THIS->image);    THIS->img=img;    THIS->xsize=img->xsize;    THIS->ysize=img->ysize;    }    else    SIMPLE_BAD_ARG_ERROR("Image.Layer->set_image",1,    "object(Image)|int(0)");    }       if (args>=2) { -  if ( Pike_sp[1-args].type!=T_OBJECT ) +  if ( TYPEOF(Pike_sp[1-args]) != T_OBJECT )    { -  if (Pike_sp[1-args].type!=T_INT || +  if (TYPEOF(Pike_sp[1-args]) != T_INT ||    Pike_sp[1-args].u.integer!=0)    SIMPLE_BAD_ARG_ERROR("Image.Layer->set_image",2,    "object(Image)|int(0)");    }    else if ((img=(struct image*)    get_storage(Pike_sp[1-args].u.object,image_program)))    {    if (THIS->img &&    (img->xsize!=THIS->xsize ||    img->ysize!=THIS->ysize))
pike.git/src/modules/Image/layers.c:1064:   **! note:   **! image and alpha channel must be of the same size,   **! or canceled.   */      static void image_layer_set_mode(INT32 args)   {    int i;    if (args!=1)    SIMPLE_TOO_FEW_ARGS_ERROR("Image.Layer->set_mode",1); -  if (Pike_sp[-args].type!=T_STRING) +  if (TYPEOF(Pike_sp[-args]) != T_STRING)    SIMPLE_BAD_ARG_ERROR("Image.Layer->set_mode",1,"string");       for (i=0; i<LAYER_MODES; i++)    if (Pike_sp[-args].u.string==layer_mode[i].ps)    {    THIS->row_func=layer_mode[i].func;    THIS->optimize_alpha=layer_mode[i].optimize_alpha;    THIS->really_optimize_alpha=really_optimize_p(THIS);       pop_n_elems(args);
pike.git/src/modules/Image/layers.c:1138:   **! Set/query fill color and alpha, ie the color used "outside" the   **! image. This is mostly useful if you want to "frame"   **! a layer.   */      static void image_layer_set_fill(INT32 args)   {    if (!args)    SIMPLE_TOO_FEW_ARGS_ERROR("Image.Layer->set_fill",1);    -  if (Pike_sp[-args].type==T_INT && !Pike_sp[-args].u.integer) +  if (TYPEOF(Pike_sp[-args]) == T_INT && !Pike_sp[-args].u.integer)    THIS->fill=black;    else    if (!image_color_arg(-args,&(THIS->fill)))    SIMPLE_BAD_ARG_ERROR("Image.Layer->set_fill",1,"color");       smear_color(THIS->sfill,THIS->fill,SNUMPIXS);       THIS->fill_alpha=white;    if (args>1) { -  if (Pike_sp[1-args].type==T_INT && !Pike_sp[1-args].u.integer) +  if (TYPEOF(Pike_sp[1-args]) == T_INT && !Pike_sp[1-args].u.integer)    ; /* white is good */    else    if (!image_color_arg(1-args,&(THIS->fill_alpha)))    {    smear_color(THIS->sfill_alpha,THIS->fill_alpha,SNUMPIXS);    SIMPLE_BAD_ARG_ERROR("Image.Layer->set_fill",2,"color");    }    }    smear_color(THIS->sfill_alpha,THIS->fill_alpha,SNUMPIXS);   
pike.git/src/modules/Image/layers.c:1349:    pop_stack();    }    else    pop_n_elems(2);   }      static void image_layer_create(INT32 args)   {    if (!args)    return; -  if (Pike_sp[-args].type==T_MAPPING) +  if (TYPEOF(Pike_sp[-args]) == T_MAPPING)    {    pop_n_elems(args-1);    try_parameter_pair("image","alpha",image_layer_set_image);       try_parameter("mode",image_layer_set_mode);    try_parameter("alpha_value",image_layer_set_alpha_value);       try_parameter_pair("xoffset","yoffset",image_layer_set_offset);    try_parameter_pair("fill","fill_alpha",image_layer_set_fill);    try_parameter("tiled",image_layer_set_tiled);    pop_stack();    return;    } -  else if (Pike_sp[-args].type==T_INT && args>1 -  && Pike_sp[1-args].type==T_INT) +  else if (TYPEOF(Pike_sp[-args]) == T_INT && args>1 +  && TYPEOF(Pike_sp[1-args]) == T_INT)    {    rgb_group col=black,alpha=white;       get_all_args("Image.Layer",args,"%d%d", /* watch the type: INT32 */    &(THIS->xsize),&(THIS->ysize));    if (args>2)    if (!image_color_arg(2-args,&col))    SIMPLE_BAD_ARG_ERROR("Image.Layer",3,"Image.Color");       if (args>3)
pike.git/src/modules/Image/layers.c:1396:    push_int(THIS->ysize);    push_int(alpha.r);    push_int(alpha.g);    push_int(alpha.b);    push_object(clone_object(image_program,5));       image_layer_set_image(2);       pop_n_elems(args);    } -  else if (Pike_sp[-args].type==T_OBJECT || args>1) +  else if (TYPEOF(Pike_sp[-args]) == T_OBJECT || args>1)    {    if (args>2)    {    image_layer_set_mode(args-2);    pop_stack();    args=2;    }    image_layer_set_image(args);    pop_stack();    }
pike.git/src/modules/Image/layers.c:1431:   **! "fill":image,   **! "fill_alpha":image   **! "tiled":int,   **! "mode":string   **! ])    */   static void image_layer_cast(INT32 args)   {    if (!args)    SIMPLE_TOO_FEW_ARGS_ERROR("Image.Layer->cast",1); -  if (Pike_sp[-args].type==T_STRING||Pike_sp[-args].u.string->size_shift) +  if (TYPEOF(Pike_sp[-args]) == T_STRING || +  Pike_sp[-args].u.string->size_shift)    {    if (strncmp(Pike_sp[-args].u.string->str,"mapping",7)==0)    {    int n=0;    pop_n_elems(args);       push_constant_text("xsize"); push_int(THIS->xsize); n++;    push_constant_text("ysize"); push_int(THIS->ysize); n++;    push_constant_text("image"); image_layer_image(0); n++;    push_constant_text("alpha"); image_layer_alpha(0); n++;
pike.git/src/modules/Image/layers.c:2908:    struct layer **l;    struct object *o;    struct layer *dest;    struct array *a;    INT_TYPE xoffset=0,yoffset=0,xsize=0,ysize=0;    ONERROR err;       if (!args)    SIMPLE_TOO_FEW_ARGS_ERROR("Image.lay",1);    -  if (Pike_sp[-args].type!=T_ARRAY) +  if (TYPEOF(Pike_sp[-args]) != T_ARRAY)    SIMPLE_BAD_ARG_ERROR("Image.lay",1,    "array(Image.Layer|mapping)");       if (args>1)    {    get_all_args("Image.lay",args-1,"%i%i%i%i",    &xoffset,&yoffset,&xsize,&ysize);    if (xsize<1)    SIMPLE_BAD_ARG_ERROR("Image.lay",4,"int(1..)");    if (ysize<1)
pike.git/src/modules/Image/layers.c:2937:    push_object(clone_object(image_layer_program,0));    return;    }       l=(struct layer**)xalloc(sizeof(struct layer *)*layers);       SET_ONERROR(err, free, l);       for (i=j=0; i<layers; i++)    { -  if (a->item[i].type==T_OBJECT) +  if (TYPEOF(a->item[i]) == T_OBJECT)    {    if (!(l[j]=(struct layer*)get_storage(a->item[i].u.object,    image_layer_program)))    SIMPLE_BAD_ARG_ERROR("Image.lay",1,    "array(Image.Layer|mapping)");    } -  else if (a->item[i].type==T_MAPPING) +  else if (TYPEOF(a->item[i]) == T_MAPPING)    {    push_svalue(a->item+i);    push_object(o=clone_object(image_layer_program,1));    args++;    l[j]=(struct layer*)get_storage(o,image_layer_program);    }    else    SIMPLE_BAD_ARG_ERROR("Image.lay",1,    "array(Image.Layer|mapping)");    if (l[j]->xsize && l[j]->ysize)
pike.git/src/modules/Image/layers.c:3117:    push_constant_text("copy");    f_index(2);    push_int(xi);    push_int(yi);    push_int(xz+xi-1);    push_int(yz+yi-1);    push_int(THIS->fill.r);    push_int(THIS->fill.g);    push_int(THIS->fill.b);    f_call_function(8); -  if (Pike_sp[-1].type!=T_OBJECT || +  if (TYPEOF(Pike_sp[-1]) != T_OBJECT ||    !(img=(struct image*)get_storage(Pike_sp[-1].u.object,image_program)))    Pike_error("No image returned from image->copy\n");    if (img->xsize!=xz || img->ysize!=yz)    Pike_error("Image returned from image->copy had "    "unexpected size (%"PRINTPIKEINT"d,%"PRINTPIKEINT"d,"    " expected %"PRINTPIKEINT"d,%"PRINTPIKEINT"d)\n",    img->xsize,img->ysize,xz,yz);       free_object(l->image);    l->image=Pike_sp[-1].u.object;
pike.git/src/modules/Image/layers.c:3146:    push_constant_text("copy");    f_index(2);    push_int(xi);    push_int(yi);    push_int(xz+xi-1);    push_int(yz+yi-1);    push_int(THIS->fill_alpha.r);    push_int(THIS->fill_alpha.g);    push_int(THIS->fill_alpha.b);    f_call_function(8); -  if (Pike_sp[-1].type!=T_OBJECT || +  if (TYPEOF(Pike_sp[-1]) != T_OBJECT ||    !(img=(struct image*)get_storage(Pike_sp[-1].u.object,image_program)))    Pike_error("No image returned from alpha->copy\n");    if (img->xsize!=xz || img->ysize!=yz)    Pike_error("Image returned from alpha->copy had "    "unexpected size (%"PRINTPIKEINT"d,%"PRINTPIKEINT"d, "    "expected %"PRINTPIKEINT"d,%"PRINTPIKEINT"d)\n",    img->xsize,img->ysize,xz,yz);    free_object(l->alpha);    l->alpha=Pike_sp[-1].u.object;    Pike_sp--;
pike.git/src/modules/Image/layers.c:3251:    push_array_items(Pike_sp->u.array); /* frees */    image_layer_crop(4);   }         static void image_layer__sprintf( INT32 args )   {    int x;    if (args != 2 )    SIMPLE_TOO_FEW_ARGS_ERROR("_sprintf",2); -  if (Pike_sp[-args].type!=T_INT) +  if (TYPEOF(Pike_sp[-args]) != T_INT)    SIMPLE_BAD_ARG_ERROR("_sprintf",0,"integer"); -  if (Pike_sp[1-args].type!=T_MAPPING) +  if (TYPEOF(Pike_sp[1-args]) != T_MAPPING)    SIMPLE_BAD_ARG_ERROR("_sprintf",1,"mapping");       x = Pike_sp[-2].u.integer;       pop_n_elems( 2 );    switch( x )    {    case 't':    push_constant_text("Image.Layer");    return;