[rt #69243] modify i_transform() XS to use the AV* typemap
[imager.git] / typemap
CommitLineData
02d1d628
AMH
1#i_img * T_PTR_NULL
2Imager::Color T_PTROBJ
faa9b3e7 3Imager::Color::Float T_PTROBJ
92bda632 4Imager::ImgRaw T_IMAGER_IMAGE
4b19f77a 5Imager::Font::TT T_PTROBJ
02d1d628 6Imager::IO T_PTROBJ
f1ac5027 7Imager::FillHandle T_PTROBJ
02d1d628
AMH
8const char * T_PV
9float T_FLOAT
10float* T_ARRAY
11undef_int T_IV_U
a659442a 12undef_neg_int T_IV_NEGU
02d1d628 13HASH T_HVREF
1bd75e4c 14utf8_str T_UTF8_STR
40068b33 15i_img_dim T_IV
92bda632
TC
16
17# these types are for use by Inline, which can't handle types containing ::
18Imager__Color T_PTROBJ_INV
19Imager__Color__Float T_PTROBJ_INV
20Imager__ImgRaw T_IMAGER_IMAGE
21Imager__FillHandle T_PTROBJ_INV
22Imager__IO T_PTROBJ_INV
23
24# mostly intended for non-Imager-core use
25Imager T_IMAGER_FULL_IMAGE
26
02d1d628
AMH
27#############################################################################
28INPUT
29T_PTR_NULL
5997b792 30 if (SvOK($arg)) $var = INT2PTR($type,SvIV($arg));
02d1d628 31 else $var = NULL
e5744e01 32
92bda632
TC
33# handles Imager objects rather than just raw objects
34T_IMAGER_IMAGE
35 if (sv_derived_from($arg, \"Imager::ImgRaw\")) {
36 IV tmp = SvIV((SV*)SvRV($arg));
37 $var = INT2PTR($type,tmp);
38 }
39 else if (sv_derived_from($arg, \"Imager\") &&
40 SvTYPE(SvRV($arg)) == SVt_PVHV) {
41 HV *hv = (HV *)SvRV($arg);
42 SV **sv = hv_fetch(hv, \"IMG\", 3, 0);
43 if (sv && *sv && sv_derived_from(*sv, \"Imager::ImgRaw\")) {
44 IV tmp = SvIV((SV*)SvRV(*sv));
45 $var = INT2PTR($type,tmp);
46 }
47 else
48 Perl_croak(aTHX_ \"$var is not of type Imager::ImgRaw\");
49 }
50 else
51 Perl_croak(aTHX_ \"$var is not of type Imager::ImgRaw\");
52
53T_IMAGER_FULL_IMAGE
54 if (sv_derived_from($arg, \"Imager\") &&
55 SvTYPE(SvRV($arg)) == SVt_PVHV) {
56 HV *hv = (HV *)SvRV($arg);
57 SV **sv = hv_fetch(hv, \"IMG\", 3, 0);
58 if (sv && *sv && sv_derived_from(*sv, \"Imager::ImgRaw\")) {
59 IV tmp = SvIV((SV*)SvRV(*sv));
60 $var = INT2PTR($type,tmp);
61 }
62 else
63 Perl_croak(aTHX_ \"$var is not of type Imager::ImgRaw\");
64 }
65 else
66 Perl_croak(aTHX_ \"$var is not of type Imager\");
67
68# same as T_PTROBJ, but replace __ with ::, the opposite of the way
69# xsubpp's processing works
70# this is to compensate for Inline's problem with type names containing ::
71T_PTROBJ_INV
72 if (sv_derived_from($arg, \"${(my $ntt=$ntype)=~s/__/::/g;\$ntt}\")) {
73 IV tmp = SvIV((SV*)SvRV($arg));
74 $var = INT2PTR($type,tmp);
75 }
76 else
77 croak(\"$var is not of type ${(my $ntt=$ntype)=~s/__/::/g;\$ntt}\");
78
02d1d628
AMH
79#############################################################################
80OUTPUT
81T_IV_U
82 if ($var == 0) $arg=&PL_sv_undef;
83 else sv_setiv($arg, (IV)$var);
a659442a
TC
84T_IV_NEGU
85 if ($var < 0) $arg=&PL_sv_undef;
86 else sv_setiv($arg, (IV)$var);
02d1d628
AMH
87T_PTR_NULL
88 sv_setiv($arg, (IV)$var);
92bda632
TC
89
90# same as T_PTROBJ
91T_IMAGER_IMAGE
92 sv_setref_pv($arg, \"Imager::ImgRaw\", (void*)$var);
93
94T_PTROBJ_INV
95 sv_setref_pv($arg, \"${(my $ntt=$ntype)=~s/__/::/g;\$ntt}\", (void*)$var);
96
97# ugh, the things we do for ease of use
98# this isn't suitable in some cases
99T_IMAGER_FULL_IMAGE
100 if ($var) {
101 SV *imobj = NEWSV(0, 0);
102 HV *hv = newHV();
92bda632
TC
103 sv_setref_pv(imobj, \"Imager::ImgRaw\", $var);
104 hv_store(hv, "IMG", 3, imobj, 0);
b340c629 105 $arg = sv_2mortal(sv_bless(newRV_noinc((SV*)hv), gv_stashpv("Imager", 1)));
92bda632
TC
106 }
107 else {
108 $arg = &PL_sv_undef;
109 }