split Imager's typemap into internal, public and old perl bugfixes
[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
13#############################################################################
14INPUT
15
16T_OFF_T
17 $var = i_sv_off_t(aTHX_ $arg);
18
19T_IM_CHANNEL_LIST
20 SvGETMAGIC($arg);
21 if (SvOK($arg)) {
22 AV *channels_av;
23 int i;
24 if (!SvROK($arg) || SvTYPE(SvRV($arg)) != SVt_PVAV) {
25 croak(\"$var is not an array ref\");
26 }
27 channels_av = (AV *)SvRV($arg);
28 $var.count = av_len(channels_av) + 1;
29 if ($var.count < 1) {
30 croak(\"$pname: no channels provided\");
31 }
32 $var.channels = malloc_temp(aTHX_ sizeof(int) * $var.count);
33 for (i = 0; i < $var.count; ++i) {
34 SV **entry = av_fetch(channels_av, i, 0);
35 $var.channels[i] = entry ? SvIV(*entry) : 0;
36 }
37 }
38 else {
39 /* assumes we have an image */
40 $var.count = im->channels;
41 $var.channels = NULL;
42 }
43
44T_IM_SAMPLE_LIST
45 SvGETMAGIC($arg);
46 if (!SvOK($arg))
47 croak(\"$var must be a scalar or an arrayref\");
48 if (SvROK($arg)) {
49 i_img_dim i;
50 AV *av;
51 i_sample_t *s;
52 if (SvTYPE(SvRV($arg)) != SVt_PVAV)
53 croak(\"$var must be a scalar or an arrayref\");
54 av = (AV *)SvRV($arg);
55 $var.count = av_len(av) + 1;
56 if ($var.count < 1)
57 croak(\"$pname: no samples provided in $var\");
58 s = malloc_temp(aTHX_ sizeof(i_sample_t) * $var.count);
59 for (i = 0; i < $var.count; ++i) {
60 SV **entry = av_fetch(av, i, 0);
61 s[i] = entry ? SvIV(*entry) : 0;
62 }
63 $var.samples = s;
64 }
65 else {
66 /* non-magic would be preferable here */
67 $var.samples = (const i_sample_t *)SvPVbyte($arg, $var.count);
68 if ($var.count == 0)
69 croak(\"$pname: no samples provided in $var\");
70 }
71
72T_IM_FSAMPLE_LIST
73 SvGETMAGIC($arg);
74 if (!SvOK($arg))
75 croak(\"$var must be a scalar or an arrayref\");
76 if (SvROK($arg)) {
77 i_img_dim i;
78 AV *av;
79 i_fsample_t *s;
80 if (SvTYPE(SvRV($arg)) != SVt_PVAV)
81 croak(\"$var must be a scalar or an arrayref\");
82 av = (AV *)SvRV($arg);
83 $var.count = av_len(av) + 1;
84 if ($var.count < 1)
85 croak(\"$pname: no samples provided in $var\");
86 s = malloc_temp(aTHX_ sizeof(i_fsample_t) * $var.count);
87 for (i = 0; i < $var.count; ++i) {
88 SV **entry = av_fetch(av, i, 0);
89 s[i] = entry ? SvNV(*entry) : 0;
90 }
91 $var.samples = s;
92 }
93 else {
94 /* non-magic would be preferable here */
95 $var.samples = (const i_fsample_t *)SvPVbyte($arg, $var.count);
96 if ($var.count % sizeof(double))
97 croak(\"$pname: $var doesn't not contain a integer number of samples\");
98 $var.count /= sizeof(double);
99 if ($var.count == 0)
100 croak(\"$pname: no samples provided in $var\");
101 }
102
103#############################################################################
104OUTPUT
105
106T_OFF_T
107 $arg = i_new_sv_off_t(aTHX_ $var);