File Coverage

pp-plAlloc2dGrid.c
Criterion Covered Total %
statement 39 40 97.5
branch 30 48 62.5
condition n/a
subroutine n/a
pod n/a
total 69 88 78.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-plAlloc2dGrid.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             #line 1846 "lib/PDL/PP.pm"
40             typedef struct pdl_params_plAlloc2dGrid {
41             #line 42 "pp-plAlloc2dGrid.c"
42             PLcGrid2Ptr__OUT *grid;
43             } pdl_params_plAlloc2dGrid;
44              
45              
46             #line 1857 "lib/PDL/PP.pm"
47             pdl_error pdl_plAlloc2dGrid_readdata(pdl_trans *__privtrans) {
48             pdl_error PDL_err = {0, NULL, 0};
49             #line 50 "pp-plAlloc2dGrid.c"
50 9           pdl_params_plAlloc2dGrid *__params = __privtrans->params; (void)__params;
51 9 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in plAlloc2dGrid:" "broadcast.incs NULL");
52             /* broadcastloop declarations */
53             int __brcloopval;
54             register PDL_Indx __tind0,__tind1; /* counters along dim */
55 9           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
56             /* dims here are how many steps along those dims */
57 9           register PDL_Indx __tinc0_xg = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
58 9           register PDL_Indx __tinc0_yg = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
59 9           register PDL_Indx __tinc1_xg = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
60 9           register PDL_Indx __tinc1_yg = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
61             #define PDL_BROADCASTLOOP_START_plAlloc2dGrid_readdata PDL_BROADCASTLOOP_START( \
62             readdata, \
63             __privtrans->broadcast, \
64             __privtrans->vtable, \
65             xg_datap += __offsp[0]; \
66             yg_datap += __offsp[1]; \
67             , \
68             ( ,xg_datap += __tinc1_xg - __tinc0_xg * __tdims0 \
69             ,yg_datap += __tinc1_yg - __tinc0_yg * __tdims0 \
70             ), \
71             ( ,xg_datap += __tinc0_xg \
72             ,yg_datap += __tinc0_yg \
73             ) \
74             )
75             #define PDL_BROADCASTLOOP_END_plAlloc2dGrid_readdata PDL_BROADCASTLOOP_END( \
76             __privtrans->broadcast, \
77             xg_datap -= __tinc1_xg * __tdims1 + __offsp[0]; \
78             yg_datap -= __tinc1_yg * __tdims1 + __offsp[1]; \
79             )
80 9           register PDL_Indx __inc_xg_nx = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_xg_nx;register PDL_Indx __inc_xg_ny = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,1)]; (void)__inc_xg_ny;
81 9           register PDL_Indx __inc_yg_nx = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_yg_nx;register PDL_Indx __inc_yg_ny = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,1)]; (void)__inc_yg_ny;
82             #ifndef PDL_DECLARE_PARAMS_plAlloc2dGrid_1
83             #define PDL_DECLARE_PARAMS_plAlloc2dGrid_1(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_xg,PDL_PPSYM_PARAM_xg,PDL_TYPE_PARAM_yg,PDL_PPSYM_PARAM_yg) \
84             PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_xg, xg, (__privtrans->pdls[0]), 1, PDL_PPSYM_PARAM_xg) \
85             PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_yg, yg, (__privtrans->pdls[1]), 1, PDL_PPSYM_PARAM_yg)
86             #endif
87             #define PDL_IF_BAD(t,f) f
88 9 50         switch (__privtrans->__datatype) { /* Start generic switch */
89 9           case PDL_D: {
90 9 100         PDL_DECLARE_PARAMS_plAlloc2dGrid_1(PDL_Double,D,PDL_Double,D,PDL_Double,D)
    50          
    50          
    100          
    50          
    50          
91 36 50         PDL_BROADCASTLOOP_START_plAlloc2dGrid_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
92 9           int i, j, nx = __privtrans->ind_sizes[0], ny = __privtrans->ind_sizes[1];
93 9           PLcGrid2 *grid = (PLcGrid2*) malloc(sizeof(PLcGrid2));
94 9 50         if (!grid) return PDL->make_error(PDL_EUSERERROR, "Error in plAlloc2dGrid:" "Failed to allocate memory for grid");
95 9           plAlloc2dGrid(&(grid->xg), nx, ny);
96 9           plAlloc2dGrid(&(grid->yg), nx, ny);
97 264 100         for (i = 0; i < nx; i++)
98 9625 100         for (j = 0; j < ny; j++) {
99 9370           grid->xg[i][j] = (xg_datap)[0+(__inc_xg_nx*(i))+(__inc_xg_ny*(j))];
100 9370           grid->yg[i][j] = (yg_datap)[0+(__inc_yg_nx*(i))+(__inc_yg_ny*(j))];
101             }
102 9           grid->nx = nx;
103 9           grid->ny = ny;
104 18 50         (*(__params->grid)) = grid;}PDL_BROADCASTLOOP_END_plAlloc2dGrid_readdata
    50          
105 9           } break;
106 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in plAlloc2dGrid: unhandled datatype(%d), only handles (D)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
107             }
108             #undef PDL_IF_BAD
109 9           return PDL_err;
110             }
111              
112             static pdl_datatypes pdl_plAlloc2dGrid_vtable_gentypes[] = { PDL_D, -1 };
113             static PDL_Indx pdl_plAlloc2dGrid_vtable_realdims[] = { 2, 2 };
114             static char *pdl_plAlloc2dGrid_vtable_parnames[] = { "xg","yg" };
115             static short pdl_plAlloc2dGrid_vtable_parflags[] = {
116             PDL_PARAM_ISTYPED,
117             PDL_PARAM_ISTYPED
118             };
119             static pdl_datatypes pdl_plAlloc2dGrid_vtable_partypes[] = { PDL_D, PDL_D };
120             static PDL_Indx pdl_plAlloc2dGrid_vtable_realdims_starts[] = { 0, 2 };
121             static PDL_Indx pdl_plAlloc2dGrid_vtable_realdims_ind_ids[] = { 0, 1, 0, 1 };
122             static char *pdl_plAlloc2dGrid_vtable_indnames[] = { "nx","ny" };
123             pdl_transvtable pdl_plAlloc2dGrid_vtable = {
124             PDL_TRANS_DO_BROADCAST|PDL_TRANS_NO_PARALLEL|PDL_TRANS_OUTPUT_OTHERPAR, 0, pdl_plAlloc2dGrid_vtable_gentypes, 2, 2, NULL /*CORE21*/,
125             pdl_plAlloc2dGrid_vtable_realdims, pdl_plAlloc2dGrid_vtable_parnames,
126             pdl_plAlloc2dGrid_vtable_parflags, pdl_plAlloc2dGrid_vtable_partypes,
127             pdl_plAlloc2dGrid_vtable_realdims_starts, pdl_plAlloc2dGrid_vtable_realdims_ind_ids, 4,
128             2, pdl_plAlloc2dGrid_vtable_indnames,
129             NULL, pdl_plAlloc2dGrid_readdata, NULL,
130             NULL,
131             sizeof(pdl_params_plAlloc2dGrid),"PDL::Graphics::PLplot::plAlloc2dGrid"
132             };
133              
134              
135 9           pdl_error pdl_run_plAlloc2dGrid(pdl *xg,pdl *yg,PLcGrid2Ptr__OUT *grid) {
136 9           pdl_error PDL_err = {0, NULL, 0};
137 9 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
138 9           pdl_trans *__privtrans = PDL->create_trans(&pdl_plAlloc2dGrid_vtable);
139 9 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
140 9           pdl_params_plAlloc2dGrid *__params = __privtrans->params;
141 9           __privtrans->pdls[0] = xg;
142 9           __privtrans->pdls[1] = yg;
143 9 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
144 9           (__params->grid) = (grid); /* CType.get_copy */
145 9 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
146 9           return PDL_err;
147             }