Permalink
Browse files

[rt #69243] modify i_transform() XS to use the AV* typemap

  • Loading branch information...
1 parent 6465590 commit 5cd5652cdbb24fb83504ab0d021a8179971632db @tonycoz committed May 21, 2013
Showing with 14 additions and 20 deletions.
  1. +3 −3 Changes
  2. +11 −17 Imager.xs
View
@@ -20,9 +20,9 @@ Imager release history. Older releases can be found in Changes.old
- Imager::Color's rgba() method now returns it's values as integers
instead of floating point. (IV instead of NV).
- - The XS for i_poly_aa(), i_poly_aa_cfill(), i_map() and
- i_matrix_transform() now use the AV * typemap instead of rolling
- their own.
+ - The XS for i_poly_aa(), i_poly_aa_cfill(), i_map(), i_transform()
+ and i_matrix_transform() now use the AV * typemap instead of
+ rolling their own.
- some XS code formatting
View
@@ -2509,8 +2509,11 @@ i_get_anonymous_color_histo(im, maxc = 0x40000000)
void
-i_transform(im,opx,opy,parm)
+i_transform(im,opx_av,opy_av,parm_av)
Imager::ImgRaw im
+ AV *opx_av
+ AV *opy_av
+ AV *parm_av
PREINIT:
double* parm;
int *opx;
@@ -2523,31 +2526,22 @@ i_transform(im,opx,opy,parm)
int i;
i_img *result;
PPCODE:
- if (!SvROK(ST(1))) croak("Imager: Parameter 1 must be a reference to an array\n");
- if (!SvROK(ST(2))) croak("Imager: Parameter 2 must be a reference to an array\n");
- if (!SvROK(ST(3))) croak("Imager: Parameter 3 must be a reference to an array\n");
- if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 must be a reference to an array\n");
- if (SvTYPE(SvRV(ST(2))) != SVt_PVAV) croak("Imager: Parameter 2 must be a reference to an array\n");
- if (SvTYPE(SvRV(ST(3))) != SVt_PVAV) croak("Imager: Parameter 3 must be a reference to an array\n");
- av=(AV*)SvRV(ST(1));
- opxl=av_len(av)+1;
+ opxl=av_len(opx_av)+1;
opx=mymalloc( opxl*sizeof(int) );
for(i=0;i<opxl;i++) {
- sv1=(*(av_fetch(av,i,0)));
+ sv1=(*(av_fetch(opx_av,i,0)));
opx[i]=(int)SvIV(sv1);
}
- av=(AV*)SvRV(ST(2));
- opyl=av_len(av)+1;
+ opyl=av_len(opy_av)+1;
opy=mymalloc( opyl*sizeof(int) );
for(i=0;i<opyl;i++) {
- sv1=(*(av_fetch(av,i,0)));
+ sv1=(*(av_fetch(opy_av,i,0)));
opy[i]=(int)SvIV(sv1);
}
- av=(AV*)SvRV(ST(3));
- parmlen=av_len(av)+1;
+ parmlen=av_len(parm_av)+1;
parm=mymalloc( parmlen*sizeof(double) );
- for(i=0;i<parmlen;i++) { /* FIXME: Bug? */
- sv1=(*(av_fetch(av,i,0)));
+ for(i=0;i<parmlen;i++) {
+ sv1=(*(av_fetch(parm_av,i,0)));
parm[i]=(double)SvNV(sv1);
}
result=i_transform(im,opx,opxl,opy,opyl,parm,parmlen);

0 comments on commit 5cd5652

Please sign in to comment.