File Coverage

pp-plmap.c
Criterion Covered Total %
statement 39 40 97.5
branch 32 58 55.1
condition n/a
subroutine n/a
pod n/a
total 71 98 72.4


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-plmap.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_plmap {
55             #line 56 "pp-plmap.c"
56             SV *mapform;
57             char *type;
58             } pdl_params_plmap;
59              
60              
61             #line 1857 "lib/PDL/PP.pm"
62             pdl_error pdl_plmap_readdata(pdl_trans *__privtrans) {
63             pdl_error PDL_err = {0, NULL, 0};
64             #line 65 "pp-plmap.c"
65 4           pdl_params_plmap *__params = __privtrans->params; (void)__params;
66 4 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in plmap:" "broadcast.incs NULL");
67             /* broadcastloop declarations */
68             int __brcloopval;
69             register PDL_Indx __tind0,__tind1; /* counters along dim */
70 4           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
71             /* dims here are how many steps along those dims */
72 4           register PDL_Indx __tinc0_minlong = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
73 4           register PDL_Indx __tinc0_maxlong = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
74 4           register PDL_Indx __tinc0_minlat = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0);
75 4           register PDL_Indx __tinc0_maxlat = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,0);
76 4           register PDL_Indx __tinc1_minlong = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
77 4           register PDL_Indx __tinc1_maxlong = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
78 4           register PDL_Indx __tinc1_minlat = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1);
79 4           register PDL_Indx __tinc1_maxlat = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,1);
80             #define PDL_BROADCASTLOOP_START_plmap_readdata PDL_BROADCASTLOOP_START( \
81             readdata, \
82             __privtrans->broadcast, \
83             __privtrans->vtable, \
84             minlong_datap += __offsp[0]; \
85             maxlong_datap += __offsp[1]; \
86             minlat_datap += __offsp[2]; \
87             maxlat_datap += __offsp[3]; \
88             , \
89             ( ,minlong_datap += __tinc1_minlong - __tinc0_minlong * __tdims0 \
90             ,maxlong_datap += __tinc1_maxlong - __tinc0_maxlong * __tdims0 \
91             ,minlat_datap += __tinc1_minlat - __tinc0_minlat * __tdims0 \
92             ,maxlat_datap += __tinc1_maxlat - __tinc0_maxlat * __tdims0 \
93             ), \
94             ( ,minlong_datap += __tinc0_minlong \
95             ,maxlong_datap += __tinc0_maxlong \
96             ,minlat_datap += __tinc0_minlat \
97             ,maxlat_datap += __tinc0_maxlat \
98             ) \
99             )
100             #define PDL_BROADCASTLOOP_END_plmap_readdata PDL_BROADCASTLOOP_END( \
101             __privtrans->broadcast, \
102             minlong_datap -= __tinc1_minlong * __tdims1 + __offsp[0]; \
103             maxlong_datap -= __tinc1_maxlong * __tdims1 + __offsp[1]; \
104             minlat_datap -= __tinc1_minlat * __tdims1 + __offsp[2]; \
105             maxlat_datap -= __tinc1_maxlat * __tdims1 + __offsp[3]; \
106             )
107             #ifndef PDL_DECLARE_PARAMS_plmap_1
108             #define PDL_DECLARE_PARAMS_plmap_1(PDL_TYPE_OP,PDL_PPSYM_OP) \
109             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, minlong, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
110             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, maxlong, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \
111             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, minlat, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP) \
112             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, maxlat, (__privtrans->pdls[3]), 1, PDL_PPSYM_OP)
113             #endif
114             #define PDL_IF_BAD(t,f) f
115 4 50         switch (__privtrans->__datatype) { /* Start generic switch */
116 4           case PDL_D: {
117 4 50         PDL_DECLARE_PARAMS_plmap_1(PDL_Double,D)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
118 16 50         PDL_BROADCASTLOOP_START_plmap_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
119             int use_xform;
120 4           mapform_callback_set(__params->mapform,
121             "plmap: mapform must be either 0 or a subroutine pointer");
122              
123 4           use_xform = SvTRUE (__params->mapform);
124 4           plmap (use_xform ? mapform_callback : NULL,
125 8 100         __params->type, (minlong_datap)[0], (maxlong_datap)[0], (minlat_datap)[0], (maxlat_datap)[0]);}PDL_BROADCASTLOOP_END_plmap_readdata
    50          
    50          
126 4           } break;
127 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in plmap: unhandled datatype(%d), only handles (D)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
128             }
129             #undef PDL_IF_BAD
130 4           return PDL_err;
131             }
132              
133              
134             #line 1857 "lib/PDL/PP.pm"
135             pdl_error pdl_plmap_free(pdl_trans *__privtrans, char destroy) {
136             pdl_error PDL_err = {0, NULL, 0};
137             #line 138 "pp-plmap.c"
138 4           pdl_params_plmap *__params = __privtrans->params; (void)__params;
139 4 50         PDL_FREE_CODE(__privtrans, destroy, SvREFCNT_dec(__params->mapform); /* CType.get_free */
140             free(__params->type); /* CType.get_free */
141 4           , ) return PDL_err;
142             }
143              
144             static pdl_datatypes pdl_plmap_vtable_gentypes[] = { PDL_D, -1 };
145             static PDL_Indx pdl_plmap_vtable_realdims[] = { 0, 0, 0, 0 };
146             static char *pdl_plmap_vtable_parnames[] = { "minlong","maxlong","minlat","maxlat" };
147             static short pdl_plmap_vtable_parflags[] = {
148             0,
149             0,
150             0,
151             0
152             };
153             static pdl_datatypes pdl_plmap_vtable_partypes[] = { -1, -1, -1, -1 };
154             static PDL_Indx pdl_plmap_vtable_realdims_starts[] = { 0, 0, 0, 0 };
155             static PDL_Indx pdl_plmap_vtable_realdims_ind_ids[] = { 0 };
156             static char *pdl_plmap_vtable_indnames[] = { "" };
157             pdl_transvtable pdl_plmap_vtable = {
158             PDL_TRANS_DO_BROADCAST|PDL_TRANS_NO_PARALLEL, 0, pdl_plmap_vtable_gentypes, 4, 4, NULL /*CORE21*/,
159             pdl_plmap_vtable_realdims, pdl_plmap_vtable_parnames,
160             pdl_plmap_vtable_parflags, pdl_plmap_vtable_partypes,
161             pdl_plmap_vtable_realdims_starts, pdl_plmap_vtable_realdims_ind_ids, 0,
162             0, pdl_plmap_vtable_indnames,
163             NULL, pdl_plmap_readdata, NULL,
164             pdl_plmap_free,
165             sizeof(pdl_params_plmap),"PDL::Graphics::PLplot::plmap"
166             };
167              
168              
169 4           pdl_error pdl_run_plmap(pdl *minlong,pdl *maxlong,pdl *minlat,pdl *maxlat,SV *mapform,char *type) {
170 4           pdl_error PDL_err = {0, NULL, 0};
171 4 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
172 4           pdl_trans *__privtrans = PDL->create_trans(&pdl_plmap_vtable);
173 4 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
174 4           pdl_params_plmap *__params = __privtrans->params;
175 4           __privtrans->pdls[0] = minlong;
176 4           __privtrans->pdls[1] = maxlong;
177 4           __privtrans->pdls[2] = minlat;
178 4           __privtrans->pdls[3] = maxlat;
179 4 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
180 4           (__params->mapform) = newSVsv(mapform); /* CType.get_copy */
181 4           (__params->type) = malloc(strlen(type)+1); strcpy(__params->type,type); /* CType.get_copy */
182 4 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
183 4           return PDL_err;
184             }