[rt #69243] greatly simplify XS for i_bezier_multi()
[imager.git] / typemap.local
CommitLineData
d63caaff
TC
1# definitions we don't want to make visible to the world
2# because they're intended for use specifically by Imager.xs
3
4# internal types used in Imager.xs
5i_channel_list T_IM_CHANNEL_LIST
6i_sample_list T_IM_SAMPLE_LIST
7i_fsample_list T_IM_FSAMPLE_LIST
8
9off_t T_OFF_T
10
11Imager::Internal::Hlines T_PTROBJ
12
31a13473
TC
13Imager::Context T_PTROBJ
14
d63caaff
TC
15#############################################################################
16INPUT
17
18T_OFF_T
19 $var = i_sv_off_t(aTHX_ $arg);
20
21T_IM_CHANNEL_LIST
22 SvGETMAGIC($arg);
23 if (SvOK($arg)) {
24 AV *channels_av;
25 int i;
26 if (!SvROK($arg) || SvTYPE(SvRV($arg)) != SVt_PVAV) {
27 croak(\"$var is not an array ref\");
28 }
29 channels_av = (AV *)SvRV($arg);
30 $var.count = av_len(channels_av) + 1;
31 if ($var.count < 1) {
32 croak(\"$pname: no channels provided\");
33 }
34 $var.channels = malloc_temp(aTHX_ sizeof(int) * $var.count);
35 for (i = 0; i < $var.count; ++i) {
36 SV **entry = av_fetch(channels_av, i, 0);
37 $var.channels[i] = entry ? SvIV(*entry) : 0;
38 }
39 }
40 else {
41 /* assumes we have an image */
42 $var.count = im->channels;
43 $var.channels = NULL;
44 }
45
46T_IM_SAMPLE_LIST
47 SvGETMAGIC($arg);
48 if (!SvOK($arg))
49 croak(\"$var must be a scalar or an arrayref\");
50 if (SvROK($arg)) {
51 i_img_dim i;
52 AV *av;
53 i_sample_t *s;
54 if (SvTYPE(SvRV($arg)) != SVt_PVAV)
55 croak(\"$var must be a scalar or an arrayref\");
56 av = (AV *)SvRV($arg);
57 $var.count = av_len(av) + 1;
58 if ($var.count < 1)
59 croak(\"$pname: no samples provided in $var\");
60 s = malloc_temp(aTHX_ sizeof(i_sample_t) * $var.count);
61 for (i = 0; i < $var.count; ++i) {
62 SV **entry = av_fetch(av, i, 0);
63 s[i] = entry ? SvIV(*entry) : 0;
64 }
65 $var.samples = s;
66 }
67 else {
68 /* non-magic would be preferable here */
69 $var.samples = (const i_sample_t *)SvPVbyte($arg, $var.count);
70 if ($var.count == 0)
71 croak(\"$pname: no samples provided in $var\");
72 }
73
74T_IM_FSAMPLE_LIST
75 SvGETMAGIC($arg);
76 if (!SvOK($arg))
77 croak(\"$var must be a scalar or an arrayref\");
78 if (SvROK($arg)) {
79 i_img_dim i;
80 AV *av;
81 i_fsample_t *s;
82 if (SvTYPE(SvRV($arg)) != SVt_PVAV)
83 croak(\"$var must be a scalar or an arrayref\");
84 av = (AV *)SvRV($arg);
85 $var.count = av_len(av) + 1;
86 if ($var.count < 1)
87 croak(\"$pname: no samples provided in $var\");
88 s = malloc_temp(aTHX_ sizeof(i_fsample_t) * $var.count);
89 for (i = 0; i < $var.count; ++i) {
90 SV **entry = av_fetch(av, i, 0);
91 s[i] = entry ? SvNV(*entry) : 0;
92 }
93 $var.samples = s;
94 }
95 else {
96 /* non-magic would be preferable here */
97 $var.samples = (const i_fsample_t *)SvPVbyte($arg, $var.count);
98 if ($var.count % sizeof(double))
99 croak(\"$pname: $var doesn't not contain a integer number of samples\");
100 $var.count /= sizeof(double);
101 if ($var.count == 0)
102 croak(\"$pname: no samples provided in $var\");
103 }
104
105#############################################################################
106OUTPUT
107
108T_OFF_T
109 $arg = i_new_sv_off_t(aTHX_ $var);