File Coverage

pp-plshade1.c
Criterion Covered Total %
statement 88 90 97.7
branch 71 134 52.9
condition n/a
subroutine n/a
pod n/a
total 159 224 70.9


line stmt bran cond sub pod time code
1              
2             #line 453 "lib/PDL/PP.pm"
3             /*
4             * THIS FILE WAS GENERATED BY PDL::PP from plplot.pd! Do not modify!
5             */
6              
7             #define PDL_FREE_CODE(trans, destroy, comp_free_code, ntpriv_free_code) \
8             if (destroy) { \
9             comp_free_code \
10             } \
11             if ((trans)->dims_redone) { \
12             ntpriv_free_code \
13             }
14              
15             #include "EXTERN.h"
16             #include "perl.h"
17             #include "XSUB.h"
18             #include "pdl.h"
19             #include "pdlcore.h"
20             #define PDL PDL_Graphics_PLplot
21             extern Core* PDL; /* Structure hold core C functions */
22             #line 23 "pp-plshade1.c"
23             #include
24             #include
25             #include
26             #include
27              
28             #ifndef PDL /* this is needed for PDL pre-2.058 */
29             #define PDL PDL_Graphics_PLplot
30             Core* PDL = NULL; PDL_COMMENT("Structure hold core C functions")
31             #endif
32              
33             #define PLPTR_DEFINE(t) typedef t *t ## Ptr; typedef t *t ## Ptr__OUT;
34             PLPTR_DEFINE(PLcGrid)
35             PLPTR_DEFINE(PLcGrid2)
36             #define PLPTR_RECEIVE_IN(t, v, v_in) t *v = (t *)v_in;
37             #define PLPTR_RECEIVE_SV(v) ((PLPointer) (SvROK(v) ? SvIV((SV*)SvRV(v)) : (IV)NULL))
38              
39             void pltr_iv_set(IV iv0, IV iv1, IV iv2);
40             void pltr_callback_set(SV *sv, char *msg);
41             void pltr_callback(PLFLT x, PLFLT y, PLFLT* tx, PLFLT* ty, PLPointer pltr_data);
42             void* get_standard_pltrcb(SV* cb);
43             void defined_callback_set(SV *sv, char *msg);
44             PLINT defined_callback(PLFLT x, PLFLT y);
45             void default_magic(pdl *p, size_t pa);
46             void mapform_callback_set(SV *sv, char *msg);
47             void mapform_callback(PLINT n, PLFLT* x, PLFLT* y);
48             void xform_callback_set(SV *sv, char *msg);
49             void xform_callback(PLFLT x, PLFLT y, PLFLT *xt, PLFLT *yt, PLPointer data);
50             void labelfunc_callback_set(SV *sv, char *msg);
51             void labelfunc_callback(PLINT axis, PLFLT value, char *label_text, PLINT length, void *data);
52              
53             #line 1846 "lib/PDL/PP.pm"
54             typedef struct pdl_params_plshade1 {
55             #line 56 "pp-plshade1.c"
56             SV *defined;
57             SV *pltr;
58             SV *pltr_data;
59             } pdl_params_plshade1;
60              
61              
62             #line 1857 "lib/PDL/PP.pm"
63             pdl_error pdl_plshade1_readdata(pdl_trans *__privtrans) {
64             pdl_error PDL_err = {0, NULL, 0};
65             #line 66 "pp-plshade1.c"
66 11           pdl_params_plshade1 *__params = __privtrans->params; (void)__params;
67 11 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in plshade1:" "broadcast.incs NULL");
68             /* broadcastloop declarations */
69             int __brcloopval;
70             register PDL_Indx __tind0,__tind1; /* counters along dim */
71 11           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
72             /* dims here are how many steps along those dims */
73 11           register PDL_Indx __tinc0_a = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
74 11           register PDL_Indx __tinc0_left = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
75 11           register PDL_Indx __tinc0_right = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0);
76 11           register PDL_Indx __tinc0_bottom = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,0);
77 11           register PDL_Indx __tinc0_top = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,4,0);
78 11           register PDL_Indx __tinc0_shade_min = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,5,0);
79 11           register PDL_Indx __tinc0_shade_max = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,6,0);
80 11           register PDL_Indx __tinc0_sh_cmap = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,7,0);
81 11           register PDL_Indx __tinc0_sh_color = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,8,0);
82 11           register PDL_Indx __tinc0_sh_width = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,9,0);
83 11           register PDL_Indx __tinc0_min_color = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,10,0);
84 11           register PDL_Indx __tinc0_min_width = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,11,0);
85 11           register PDL_Indx __tinc0_max_color = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,12,0);
86 11           register PDL_Indx __tinc0_max_width = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,13,0);
87 11           register PDL_Indx __tinc0_rectangular = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,14,0);
88 11           register PDL_Indx __tinc1_a = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
89 11           register PDL_Indx __tinc1_left = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
90 11           register PDL_Indx __tinc1_right = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1);
91 11           register PDL_Indx __tinc1_bottom = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,1);
92 11           register PDL_Indx __tinc1_top = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,4,1);
93 11           register PDL_Indx __tinc1_shade_min = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,5,1);
94 11           register PDL_Indx __tinc1_shade_max = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,6,1);
95 11           register PDL_Indx __tinc1_sh_cmap = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,7,1);
96 11           register PDL_Indx __tinc1_sh_color = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,8,1);
97 11           register PDL_Indx __tinc1_sh_width = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,9,1);
98 11           register PDL_Indx __tinc1_min_color = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,10,1);
99 11           register PDL_Indx __tinc1_min_width = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,11,1);
100 11           register PDL_Indx __tinc1_max_color = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,12,1);
101 11           register PDL_Indx __tinc1_max_width = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,13,1);
102 11           register PDL_Indx __tinc1_rectangular = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,14,1);
103             #define PDL_BROADCASTLOOP_START_plshade1_readdata PDL_BROADCASTLOOP_START( \
104             readdata, \
105             __privtrans->broadcast, \
106             __privtrans->vtable, \
107             a_datap += __offsp[0]; \
108             left_datap += __offsp[1]; \
109             right_datap += __offsp[2]; \
110             bottom_datap += __offsp[3]; \
111             top_datap += __offsp[4]; \
112             shade_min_datap += __offsp[5]; \
113             shade_max_datap += __offsp[6]; \
114             sh_cmap_datap += __offsp[7]; \
115             sh_color_datap += __offsp[8]; \
116             sh_width_datap += __offsp[9]; \
117             min_color_datap += __offsp[10]; \
118             min_width_datap += __offsp[11]; \
119             max_color_datap += __offsp[12]; \
120             max_width_datap += __offsp[13]; \
121             rectangular_datap += __offsp[14]; \
122             , \
123             ( ,a_datap += __tinc1_a - __tinc0_a * __tdims0 \
124             ,left_datap += __tinc1_left - __tinc0_left * __tdims0 \
125             ,right_datap += __tinc1_right - __tinc0_right * __tdims0 \
126             ,bottom_datap += __tinc1_bottom - __tinc0_bottom * __tdims0 \
127             ,top_datap += __tinc1_top - __tinc0_top * __tdims0 \
128             ,shade_min_datap += __tinc1_shade_min - __tinc0_shade_min * __tdims0 \
129             ,shade_max_datap += __tinc1_shade_max - __tinc0_shade_max * __tdims0 \
130             ,sh_cmap_datap += __tinc1_sh_cmap - __tinc0_sh_cmap * __tdims0 \
131             ,sh_color_datap += __tinc1_sh_color - __tinc0_sh_color * __tdims0 \
132             ,sh_width_datap += __tinc1_sh_width - __tinc0_sh_width * __tdims0 \
133             ,min_color_datap += __tinc1_min_color - __tinc0_min_color * __tdims0 \
134             ,min_width_datap += __tinc1_min_width - __tinc0_min_width * __tdims0 \
135             ,max_color_datap += __tinc1_max_color - __tinc0_max_color * __tdims0 \
136             ,max_width_datap += __tinc1_max_width - __tinc0_max_width * __tdims0 \
137             ,rectangular_datap += __tinc1_rectangular - __tinc0_rectangular * __tdims0 \
138             ), \
139             ( ,a_datap += __tinc0_a \
140             ,left_datap += __tinc0_left \
141             ,right_datap += __tinc0_right \
142             ,bottom_datap += __tinc0_bottom \
143             ,top_datap += __tinc0_top \
144             ,shade_min_datap += __tinc0_shade_min \
145             ,shade_max_datap += __tinc0_shade_max \
146             ,sh_cmap_datap += __tinc0_sh_cmap \
147             ,sh_color_datap += __tinc0_sh_color \
148             ,sh_width_datap += __tinc0_sh_width \
149             ,min_color_datap += __tinc0_min_color \
150             ,min_width_datap += __tinc0_min_width \
151             ,max_color_datap += __tinc0_max_color \
152             ,max_width_datap += __tinc0_max_width \
153             ,rectangular_datap += __tinc0_rectangular \
154             ) \
155             )
156             #define PDL_BROADCASTLOOP_END_plshade1_readdata PDL_BROADCASTLOOP_END( \
157             __privtrans->broadcast, \
158             a_datap -= __tinc1_a * __tdims1 + __offsp[0]; \
159             left_datap -= __tinc1_left * __tdims1 + __offsp[1]; \
160             right_datap -= __tinc1_right * __tdims1 + __offsp[2]; \
161             bottom_datap -= __tinc1_bottom * __tdims1 + __offsp[3]; \
162             top_datap -= __tinc1_top * __tdims1 + __offsp[4]; \
163             shade_min_datap -= __tinc1_shade_min * __tdims1 + __offsp[5]; \
164             shade_max_datap -= __tinc1_shade_max * __tdims1 + __offsp[6]; \
165             sh_cmap_datap -= __tinc1_sh_cmap * __tdims1 + __offsp[7]; \
166             sh_color_datap -= __tinc1_sh_color * __tdims1 + __offsp[8]; \
167             sh_width_datap -= __tinc1_sh_width * __tdims1 + __offsp[9]; \
168             min_color_datap -= __tinc1_min_color * __tdims1 + __offsp[10]; \
169             min_width_datap -= __tinc1_min_width * __tdims1 + __offsp[11]; \
170             max_color_datap -= __tinc1_max_color * __tdims1 + __offsp[12]; \
171             max_width_datap -= __tinc1_max_width * __tdims1 + __offsp[13]; \
172             rectangular_datap -= __tinc1_rectangular * __tdims1 + __offsp[14]; \
173             )
174 11           register PDL_Indx __inc_a_nx = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_a_nx;register PDL_Indx __inc_a_ny = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,1)]; (void)__inc_a_ny;
175             #ifndef PDL_DECLARE_PARAMS_plshade1_1
176             #define PDL_DECLARE_PARAMS_plshade1_1(PDL_TYPE_OP,PDL_PPSYM_OP) \
177             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, a, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
178             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, left, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \
179             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, right, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP) \
180             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, bottom, (__privtrans->pdls[3]), 1, PDL_PPSYM_OP) \
181             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, top, (__privtrans->pdls[4]), 1, PDL_PPSYM_OP) \
182             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, shade_min, (__privtrans->pdls[5]), 1, PDL_PPSYM_OP) \
183             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, shade_max, (__privtrans->pdls[6]), 1, PDL_PPSYM_OP) \
184             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, sh_cmap, (__privtrans->pdls[7]), 1, PDL_PPSYM_OP) \
185             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, sh_color, (__privtrans->pdls[8]), 1, PDL_PPSYM_OP) \
186             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, sh_width, (__privtrans->pdls[9]), 1, PDL_PPSYM_OP) \
187             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, min_color, (__privtrans->pdls[10]), 1, PDL_PPSYM_OP) \
188             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, min_width, (__privtrans->pdls[11]), 1, PDL_PPSYM_OP) \
189             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, max_color, (__privtrans->pdls[12]), 1, PDL_PPSYM_OP) \
190             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, max_width, (__privtrans->pdls[13]), 1, PDL_PPSYM_OP) \
191             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, rectangular, (__privtrans->pdls[14]), 1, PDL_PPSYM_OP)
192             #endif
193             #define PDL_IF_BAD(t,f) f
194 11 50         switch (__privtrans->__datatype) { /* Start generic switch */
195 11           case PDL_D: {
196 11 50         PDL_DECLARE_PARAMS_plshade1_1(PDL_Double,D)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
197 44 50         PDL_BROADCASTLOOP_START_plshade1_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
198             int i, j, size_x, size_y;
199             PLFLT **a;
200             void (*pltrcb) ();
201             PLPointer pltrdt;
202              
203 11           size_x = __privtrans->ind_sizes[0];
204 11           size_y = __privtrans->ind_sizes[1];
205              
206 11           plAlloc2dGrid (&a, size_x, size_y);
207 11 50         if(a == NULL) return PDL->make_error(PDL_EUSERERROR, "Error in plshade1:" "Failed to allocate memory in plshade1_pp");
208              
209 396 100         for (i = 0; i < size_x; i++)
210 18095 100         for (j = 0; j < size_y; j++)
211 17710           a[i][j] = (a_datap)[0+(__inc_a_nx*(i))+(__inc_a_ny*(j))];
212              
213 11           defined_callback_set(__params->defined,
214             "plshade1: defined must be either 0 or a subroutine pointer");
215              
216 11           pltr_callback_set(__params->pltr,
217             "plshade1: pltr must be either 0 or a subroutine pointer");
218              
219 11           pltrcb = get_standard_pltrcb (__params->pltr);
220 11 50         if (pltrcb != pltr_callback)
221 11 50         pltrdt = PLPTR_RECEIVE_SV(__params->pltr_data);
222             else
223 0           pltrdt = __params->pltr_data;
224              
225 11 50         c_plshade ((PLFLT_MATRIX) a, size_x, size_y,
226 11           SvTRUE (__params->defined) ? defined_callback : NULL,
227             (left_datap)[0], (right_datap)[0], (bottom_datap)[0], (top_datap)[0],
228 11           (shade_min_datap)[0], (shade_max_datap)[0], (sh_cmap_datap)[0], (sh_color_datap)[0], (sh_width_datap)[0],
229 11           (min_color_datap)[0], (min_width_datap)[0], (max_color_datap)[0], (max_width_datap)[0],
230 11           plfill, (rectangular_datap)[0], pltrcb, pltrdt);
231              
232 22 50         plFree2dGrid(a, size_x, size_y);}PDL_BROADCASTLOOP_END_plshade1_readdata
    50          
233 11           } break;
234 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in plshade1: unhandled datatype(%d), only handles (D)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
235             }
236             #undef PDL_IF_BAD
237 11           return PDL_err;
238             }
239              
240              
241             #line 1857 "lib/PDL/PP.pm"
242             pdl_error pdl_plshade1_free(pdl_trans *__privtrans, char destroy) {
243             pdl_error PDL_err = {0, NULL, 0};
244             #line 245 "pp-plshade1.c"
245 11           pdl_params_plshade1 *__params = __privtrans->params; (void)__params;
246 11 50         PDL_FREE_CODE(__privtrans, destroy, SvREFCNT_dec(__params->defined); /* CType.get_free */
247             SvREFCNT_dec(__params->pltr); /* CType.get_free */
248             SvREFCNT_dec(__params->pltr_data); /* CType.get_free */
249 11           , ) return PDL_err;
250             }
251              
252             static pdl_datatypes pdl_plshade1_vtable_gentypes[] = { PDL_D, -1 };
253             static PDL_Indx pdl_plshade1_vtable_realdims[] = { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
254             static char *pdl_plshade1_vtable_parnames[] = { "a","left","right","bottom","top","shade_min","shade_max","sh_cmap","sh_color","sh_width","min_color","min_width","max_color","max_width","rectangular" };
255             static short pdl_plshade1_vtable_parflags[] = {
256             0,
257             0,
258             0,
259             0,
260             0,
261             0,
262             0,
263             0,
264             0,
265             0,
266             0,
267             0,
268             0,
269             0,
270             0
271             };
272             static pdl_datatypes pdl_plshade1_vtable_partypes[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
273             static PDL_Indx pdl_plshade1_vtable_realdims_starts[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
274             static PDL_Indx pdl_plshade1_vtable_realdims_ind_ids[] = { 0, 1 };
275             static char *pdl_plshade1_vtable_indnames[] = { "nx","ny" };
276             pdl_transvtable pdl_plshade1_vtable = {
277             PDL_TRANS_DO_BROADCAST|PDL_TRANS_NO_PARALLEL, 0, pdl_plshade1_vtable_gentypes, 15, 15, NULL /*CORE21*/,
278             pdl_plshade1_vtable_realdims, pdl_plshade1_vtable_parnames,
279             pdl_plshade1_vtable_parflags, pdl_plshade1_vtable_partypes,
280             pdl_plshade1_vtable_realdims_starts, pdl_plshade1_vtable_realdims_ind_ids, 2,
281             2, pdl_plshade1_vtable_indnames,
282             NULL, pdl_plshade1_readdata, NULL,
283             pdl_plshade1_free,
284             sizeof(pdl_params_plshade1),"PDL::Graphics::PLplot::plshade1"
285             };
286              
287              
288 11           pdl_error pdl_run_plshade1(pdl *a,pdl *left,pdl *right,pdl *bottom,pdl *top,pdl *shade_min,pdl *shade_max,pdl *sh_cmap,pdl *sh_color,pdl *sh_width,pdl *min_color,pdl *min_width,pdl *max_color,pdl *max_width,pdl *rectangular,SV *defined,SV *pltr,SV *pltr_data) {
289 11           pdl_error PDL_err = {0, NULL, 0};
290 11 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
291 11           pdl_trans *__privtrans = PDL->create_trans(&pdl_plshade1_vtable);
292 11 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
293 11           pdl_params_plshade1 *__params = __privtrans->params;
294 11           __privtrans->pdls[0] = a;
295 11           __privtrans->pdls[1] = left;
296 11           __privtrans->pdls[2] = right;
297 11           __privtrans->pdls[3] = bottom;
298 11           __privtrans->pdls[4] = top;
299 11           __privtrans->pdls[5] = shade_min;
300 11           __privtrans->pdls[6] = shade_max;
301 11           __privtrans->pdls[7] = sh_cmap;
302 11           __privtrans->pdls[8] = sh_color;
303 11           __privtrans->pdls[9] = sh_width;
304 11           __privtrans->pdls[10] = min_color;
305 11           __privtrans->pdls[11] = min_width;
306 11           __privtrans->pdls[12] = max_color;
307 11           __privtrans->pdls[13] = max_width;
308 11           __privtrans->pdls[14] = rectangular;
309 11 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
310 11           (__params->defined) = newSVsv(defined); /* CType.get_copy */
311 11           (__params->pltr) = newSVsv(pltr); /* CType.get_copy */
312 11           (__params->pltr_data) = newSVsv(pltr_data); /* CType.get_copy */
313 11 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
314 11           return PDL_err;
315             }