don't match against horizontal lines
[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
dc953dda
TC
15i_palidx T_IV
16double * T_AVARRAY
17int * T_AVARRAY
18i_img_dim * T_AVARRAY
19i_color * T_AVARRAY
20
21
d63caaff
TC
22#############################################################################
23INPUT
24
25T_OFF_T
26 $var = i_sv_off_t(aTHX_ $arg);
27
28T_IM_CHANNEL_LIST
29 SvGETMAGIC($arg);
30 if (SvOK($arg)) {
31 AV *channels_av;
32 int i;
33 if (!SvROK($arg) || SvTYPE(SvRV($arg)) != SVt_PVAV) {
34 croak(\"$var is not an array ref\");
35 }
36 channels_av = (AV *)SvRV($arg);
37 $var.count = av_len(channels_av) + 1;
38 if ($var.count < 1) {
39 croak(\"$pname: no channels provided\");
40 }
41 $var.channels = malloc_temp(aTHX_ sizeof(int) * $var.count);
42 for (i = 0; i < $var.count; ++i) {
43 SV **entry = av_fetch(channels_av, i, 0);
44 $var.channels[i] = entry ? SvIV(*entry) : 0;
45 }
46 }
47 else {
48 /* assumes we have an image */
49 $var.count = im->channels;
50 $var.channels = NULL;
51 }
52
53T_IM_SAMPLE_LIST
54 SvGETMAGIC($arg);
55 if (!SvOK($arg))
56 croak(\"$var must be a scalar or an arrayref\");
57 if (SvROK($arg)) {
58 i_img_dim i;
59 AV *av;
60 i_sample_t *s;
61 if (SvTYPE(SvRV($arg)) != SVt_PVAV)
62 croak(\"$var must be a scalar or an arrayref\");
63 av = (AV *)SvRV($arg);
64 $var.count = av_len(av) + 1;
65 if ($var.count < 1)
66 croak(\"$pname: no samples provided in $var\");
67 s = malloc_temp(aTHX_ sizeof(i_sample_t) * $var.count);
68 for (i = 0; i < $var.count; ++i) {
69 SV **entry = av_fetch(av, i, 0);
70 s[i] = entry ? SvIV(*entry) : 0;
71 }
72 $var.samples = s;
73 }
74 else {
75 /* non-magic would be preferable here */
76 $var.samples = (const i_sample_t *)SvPVbyte($arg, $var.count);
77 if ($var.count == 0)
78 croak(\"$pname: no samples provided in $var\");
79 }
80
81T_IM_FSAMPLE_LIST
82 SvGETMAGIC($arg);
83 if (!SvOK($arg))
84 croak(\"$var must be a scalar or an arrayref\");
85 if (SvROK($arg)) {
86 i_img_dim i;
87 AV *av;
88 i_fsample_t *s;
89 if (SvTYPE(SvRV($arg)) != SVt_PVAV)
90 croak(\"$var must be a scalar or an arrayref\");
91 av = (AV *)SvRV($arg);
92 $var.count = av_len(av) + 1;
93 if ($var.count < 1)
94 croak(\"$pname: no samples provided in $var\");
95 s = malloc_temp(aTHX_ sizeof(i_fsample_t) * $var.count);
96 for (i = 0; i < $var.count; ++i) {
97 SV **entry = av_fetch(av, i, 0);
98 s[i] = entry ? SvNV(*entry) : 0;
99 }
100 $var.samples = s;
101 }
102 else {
103 /* non-magic would be preferable here */
104 $var.samples = (const i_fsample_t *)SvPVbyte($arg, $var.count);
105 if ($var.count % sizeof(double))
106 croak(\"$pname: $var doesn't not contain a integer number of samples\");
107 $var.count /= sizeof(double);
108 if ($var.count == 0)
109 croak(\"$pname: no samples provided in $var\");
110 }
111
dc953dda
TC
112T_AVARRAY
113 STMT_START {
114 SV* const xsub_tmp_sv = $arg;
115 SvGETMAGIC(xsub_tmp_sv);
116 if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVAV){
117 AV *xsub_tmp_av = (AV*)SvRV(xsub_tmp_sv);
118 STRLEN xsub_index;
119 size_$var = av_len(xsub_tmp_av) + 1;
120 $var = $ntype(size_$var);
121 for (xsub_index = 0; xsub_index < size_$var; ++xsub_index) {
122 SV **sv = av_fetch(xsub_tmp_av, xsub_index, 0);
123 if (sv) {
124 ${var}[xsub_index] = Sv${(my $ntt = $ntype) =~ s/Ptr$//; \(ucfirst $ntt)}(*sv, \"$pname\");
125 }
126 }
127 }
128 else{
129 Perl_croak(aTHX_ \"%s: %s is not an ARRAY reference\",
130 ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
131 \"$var\");
132 }
133 } STMT_END
134
d63caaff
TC
135#############################################################################
136OUTPUT
137
138T_OFF_T
139 $arg = i_new_sv_off_t(aTHX_ $var);