File Coverage

pp-plshades.c
Criterion Covered Total %
statement 72 74 97.3
branch 56 102 54.9
condition n/a
subroutine n/a
pod n/a
total 128 176 72.7


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-plshades.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_plshades {
55             #line 56 "pp-plshades.c"
56             SV *defined;
57             SV *pltr;
58             SV *pltr_data;
59             } pdl_params_plshades;
60              
61              
62             #line 1857 "lib/PDL/PP.pm"
63             pdl_error pdl_plshades_readdata(pdl_trans *__privtrans) {
64             pdl_error PDL_err = {0, NULL, 0};
65             #line 66 "pp-plshades.c"
66 9           pdl_params_plshades *__params = __privtrans->params; (void)__params;
67 9 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in plshades:" "broadcast.incs NULL");
68             /* broadcastloop declarations */
69             int __brcloopval;
70             register PDL_Indx __tind0,__tind1; /* counters along dim */
71 9           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
72             /* dims here are how many steps along those dims */
73 9           register PDL_Indx __tinc0_z = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
74 9           register PDL_Indx __tinc0_xmin = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
75 9           register PDL_Indx __tinc0_xmax = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0);
76 9           register PDL_Indx __tinc0_ymin = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,0);
77 9           register PDL_Indx __tinc0_ymax = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,4,0);
78 9           register PDL_Indx __tinc0_clevel = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,5,0);
79 9           register PDL_Indx __tinc0_fill_width = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,6,0);
80 9           register PDL_Indx __tinc0_cont_color = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,7,0);
81 9           register PDL_Indx __tinc0_cont_width = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,8,0);
82 9           register PDL_Indx __tinc0_rectangular = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,9,0);
83 9           register PDL_Indx __tinc1_z = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
84 9           register PDL_Indx __tinc1_xmin = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
85 9           register PDL_Indx __tinc1_xmax = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1);
86 9           register PDL_Indx __tinc1_ymin = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,1);
87 9           register PDL_Indx __tinc1_ymax = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,4,1);
88 9           register PDL_Indx __tinc1_clevel = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,5,1);
89 9           register PDL_Indx __tinc1_fill_width = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,6,1);
90 9           register PDL_Indx __tinc1_cont_color = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,7,1);
91 9           register PDL_Indx __tinc1_cont_width = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,8,1);
92 9           register PDL_Indx __tinc1_rectangular = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,9,1);
93             #define PDL_BROADCASTLOOP_START_plshades_readdata PDL_BROADCASTLOOP_START( \
94             readdata, \
95             __privtrans->broadcast, \
96             __privtrans->vtable, \
97             z_datap += __offsp[0]; \
98             xmin_datap += __offsp[1]; \
99             xmax_datap += __offsp[2]; \
100             ymin_datap += __offsp[3]; \
101             ymax_datap += __offsp[4]; \
102             clevel_datap += __offsp[5]; \
103             fill_width_datap += __offsp[6]; \
104             cont_color_datap += __offsp[7]; \
105             cont_width_datap += __offsp[8]; \
106             rectangular_datap += __offsp[9]; \
107             , \
108             ( ,z_datap += __tinc1_z - __tinc0_z * __tdims0 \
109             ,xmin_datap += __tinc1_xmin - __tinc0_xmin * __tdims0 \
110             ,xmax_datap += __tinc1_xmax - __tinc0_xmax * __tdims0 \
111             ,ymin_datap += __tinc1_ymin - __tinc0_ymin * __tdims0 \
112             ,ymax_datap += __tinc1_ymax - __tinc0_ymax * __tdims0 \
113             ,clevel_datap += __tinc1_clevel - __tinc0_clevel * __tdims0 \
114             ,fill_width_datap += __tinc1_fill_width - __tinc0_fill_width * __tdims0 \
115             ,cont_color_datap += __tinc1_cont_color - __tinc0_cont_color * __tdims0 \
116             ,cont_width_datap += __tinc1_cont_width - __tinc0_cont_width * __tdims0 \
117             ,rectangular_datap += __tinc1_rectangular - __tinc0_rectangular * __tdims0 \
118             ), \
119             ( ,z_datap += __tinc0_z \
120             ,xmin_datap += __tinc0_xmin \
121             ,xmax_datap += __tinc0_xmax \
122             ,ymin_datap += __tinc0_ymin \
123             ,ymax_datap += __tinc0_ymax \
124             ,clevel_datap += __tinc0_clevel \
125             ,fill_width_datap += __tinc0_fill_width \
126             ,cont_color_datap += __tinc0_cont_color \
127             ,cont_width_datap += __tinc0_cont_width \
128             ,rectangular_datap += __tinc0_rectangular \
129             ) \
130             )
131             #define PDL_BROADCASTLOOP_END_plshades_readdata PDL_BROADCASTLOOP_END( \
132             __privtrans->broadcast, \
133             z_datap -= __tinc1_z * __tdims1 + __offsp[0]; \
134             xmin_datap -= __tinc1_xmin * __tdims1 + __offsp[1]; \
135             xmax_datap -= __tinc1_xmax * __tdims1 + __offsp[2]; \
136             ymin_datap -= __tinc1_ymin * __tdims1 + __offsp[3]; \
137             ymax_datap -= __tinc1_ymax * __tdims1 + __offsp[4]; \
138             clevel_datap -= __tinc1_clevel * __tdims1 + __offsp[5]; \
139             fill_width_datap -= __tinc1_fill_width * __tdims1 + __offsp[6]; \
140             cont_color_datap -= __tinc1_cont_color * __tdims1 + __offsp[7]; \
141             cont_width_datap -= __tinc1_cont_width * __tdims1 + __offsp[8]; \
142             rectangular_datap -= __tinc1_rectangular * __tdims1 + __offsp[9]; \
143             )
144 9           register PDL_Indx __inc_clevel_l = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,5,0)]; (void)__inc_clevel_l;
145 9           register PDL_Indx __inc_z_x = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_z_x;register PDL_Indx __inc_z_y = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,1)]; (void)__inc_z_y;
146             #ifndef PDL_DECLARE_PARAMS_plshades_1
147             #define PDL_DECLARE_PARAMS_plshades_1(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_fill_width,PDL_PPSYM_PARAM_fill_width,PDL_TYPE_PARAM_cont_color,PDL_PPSYM_PARAM_cont_color,PDL_TYPE_PARAM_cont_width,PDL_PPSYM_PARAM_cont_width,PDL_TYPE_PARAM_rectangular,PDL_PPSYM_PARAM_rectangular) \
148             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, z, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
149             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, xmin, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \
150             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, xmax, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP) \
151             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, ymin, (__privtrans->pdls[3]), 1, PDL_PPSYM_OP) \
152             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, ymax, (__privtrans->pdls[4]), 1, PDL_PPSYM_OP) \
153             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, clevel, (__privtrans->pdls[5]), 1, PDL_PPSYM_OP) \
154             PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_fill_width, fill_width, (__privtrans->pdls[6]), 1, PDL_PPSYM_PARAM_fill_width) \
155             PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_cont_color, cont_color, (__privtrans->pdls[7]), 1, PDL_PPSYM_PARAM_cont_color) \
156             PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_cont_width, cont_width, (__privtrans->pdls[8]), 1, PDL_PPSYM_PARAM_cont_width) \
157             PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_rectangular, rectangular, (__privtrans->pdls[9]), 1, PDL_PPSYM_PARAM_rectangular)
158             #endif
159             #define PDL_IF_BAD(t,f) f
160 9 50         switch (__privtrans->__datatype) { /* Start generic switch */
161 9           case PDL_D: {
162 9 50         PDL_DECLARE_PARAMS_plshades_1(PDL_Double,D,PDL_Long,L,PDL_Long,L,PDL_Long,L,PDL_Long,L)
    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          
163 36 50         PDL_BROADCASTLOOP_START_plshades_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
164 9           int nx = __privtrans->ind_sizes[1];
165 9           int ny = __privtrans->ind_sizes[2];
166 9           int nlvl = __privtrans->ind_sizes[0];
167             int i, j;
168             PLFLT **z;
169             void (*pltrcb) ();
170             PLPointer pltrdt;
171              
172 9           plAlloc2dGrid (&z, nx, ny);
173              
174 249 100         for (i = 0; i < nx; i++)
175 6860 100         for (j = 0; j < ny; j++)
176 6620           z[i][j] = (PLFLT) (z_datap)[0+(__inc_z_x*(i))+(__inc_z_y*(j))];
177              
178 9           defined_callback_set(__params->defined,
179             "plshades: defined must be either 0 or a subroutine pointer");
180              
181 9           pltr_callback_set(__params->pltr,
182             "plshades: pltr must be either 0 or a subroutine pointer");
183              
184 9           pltrcb = get_standard_pltrcb (__params->pltr);
185 9 50         if (pltrcb != pltr_callback)
186 9 100         pltrdt = PLPTR_RECEIVE_SV(__params->pltr_data);
187             else
188 0           pltrdt = __params->pltr_data;
189              
190 9 50         c_plshades ((const PLFLT **)z, nx, ny,
191 9           SvTRUE (__params->defined) ? defined_callback : NULL,
192             (xmin_datap)[0], (xmax_datap)[0], (ymin_datap)[0], (ymax_datap)[0],
193 9           clevel_datap, nlvl, (fill_width_datap)[0], (cont_color_datap)[0], (cont_width_datap)[0],
194             plfill, (rectangular_datap)[0], pltrcb, pltrdt);
195              
196 18 50         plFree2dGrid(z, nx, ny);}PDL_BROADCASTLOOP_END_plshades_readdata
    50          
197 9           } break;
198 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in plshades: unhandled datatype(%d), only handles (D)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
199             }
200             #undef PDL_IF_BAD
201 9           return PDL_err;
202             }
203              
204              
205             #line 1857 "lib/PDL/PP.pm"
206             pdl_error pdl_plshades_free(pdl_trans *__privtrans, char destroy) {
207             pdl_error PDL_err = {0, NULL, 0};
208             #line 209 "pp-plshades.c"
209 9           pdl_params_plshades *__params = __privtrans->params; (void)__params;
210 9 50         PDL_FREE_CODE(__privtrans, destroy, SvREFCNT_dec(__params->defined); /* CType.get_free */
211             SvREFCNT_dec(__params->pltr); /* CType.get_free */
212             SvREFCNT_dec(__params->pltr_data); /* CType.get_free */
213 9           , ) return PDL_err;
214             }
215              
216             static pdl_datatypes pdl_plshades_vtable_gentypes[] = { PDL_D, -1 };
217             static PDL_Indx pdl_plshades_vtable_realdims[] = { 2, 0, 0, 0, 0, 1, 0, 0, 0, 0 };
218             static char *pdl_plshades_vtable_parnames[] = { "z","xmin","xmax","ymin","ymax","clevel","fill_width","cont_color","cont_width","rectangular" };
219             static short pdl_plshades_vtable_parflags[] = {
220             0,
221             0,
222             0,
223             0,
224             0,
225             PDL_PARAM_ISPHYS,
226             PDL_PARAM_ISTYPED,
227             PDL_PARAM_ISTYPED,
228             PDL_PARAM_ISTYPED,
229             PDL_PARAM_ISTYPED
230             };
231             static pdl_datatypes pdl_plshades_vtable_partypes[] = { -1, -1, -1, -1, -1, -1, PDL_L, PDL_L, PDL_L, PDL_L };
232             static PDL_Indx pdl_plshades_vtable_realdims_starts[] = { 0, 2, 2, 2, 2, 2, 3, 3, 3, 3 };
233             static PDL_Indx pdl_plshades_vtable_realdims_ind_ids[] = { 1, 2, 0 };
234             static char *pdl_plshades_vtable_indnames[] = { "l","x","y" };
235             pdl_transvtable pdl_plshades_vtable = {
236             PDL_TRANS_DO_BROADCAST|PDL_TRANS_NO_PARALLEL, 0, pdl_plshades_vtable_gentypes, 10, 10, NULL /*CORE21*/,
237             pdl_plshades_vtable_realdims, pdl_plshades_vtable_parnames,
238             pdl_plshades_vtable_parflags, pdl_plshades_vtable_partypes,
239             pdl_plshades_vtable_realdims_starts, pdl_plshades_vtable_realdims_ind_ids, 3,
240             3, pdl_plshades_vtable_indnames,
241             NULL, pdl_plshades_readdata, NULL,
242             pdl_plshades_free,
243             sizeof(pdl_params_plshades),"PDL::Graphics::PLplot::plshades"
244             };
245              
246              
247 9           pdl_error pdl_run_plshades(pdl *z,pdl *xmin,pdl *xmax,pdl *ymin,pdl *ymax,pdl *clevel,pdl *fill_width,pdl *cont_color,pdl *cont_width,pdl *rectangular,SV *defined,SV *pltr,SV *pltr_data) {
248 9           pdl_error PDL_err = {0, NULL, 0};
249 9 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
250 9           pdl_trans *__privtrans = PDL->create_trans(&pdl_plshades_vtable);
251 9 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
252 9           pdl_params_plshades *__params = __privtrans->params;
253 9           __privtrans->pdls[0] = z;
254 9           __privtrans->pdls[1] = xmin;
255 9           __privtrans->pdls[2] = xmax;
256 9           __privtrans->pdls[3] = ymin;
257 9           __privtrans->pdls[4] = ymax;
258 9           __privtrans->pdls[5] = clevel;
259 9           __privtrans->pdls[6] = fill_width;
260 9           __privtrans->pdls[7] = cont_color;
261 9           __privtrans->pdls[8] = cont_width;
262 9           __privtrans->pdls[9] = rectangular;
263 9 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
264 9           (__params->defined) = newSVsv(defined); /* CType.get_copy */
265 9           (__params->pltr) = newSVsv(pltr); /* CType.get_copy */
266 9           (__params->pltr_data) = newSVsv(pltr_data); /* CType.get_copy */
267 9 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
268 9           return PDL_err;
269             }