File Coverage

pp-plParseOpts.c
Criterion Covered Total %
statement 42 44 95.4
branch 31 52 59.6
condition n/a
subroutine n/a
pod n/a
total 73 96 76.0


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-plParseOpts.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_plParseOpts {
41             #line 42 "pp-plParseOpts.c"
42             SV *argv;
43             int mode;
44             } pdl_params_plParseOpts;
45              
46              
47             #line 1857 "lib/PDL/PP.pm"
48             pdl_error pdl_plParseOpts_readdata(pdl_trans *__privtrans) {
49             pdl_error PDL_err = {0, NULL, 0};
50             #line 51 "pp-plParseOpts.c"
51 30           pdl_params_plParseOpts *__params = __privtrans->params; (void)__params;
52 30 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in plParseOpts:" "broadcast.incs NULL");
53             /* broadcastloop declarations */
54             int __brcloopval;
55             register PDL_Indx __tind0,__tind1; /* counters along dim */
56 30           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
57             /* dims here are how many steps along those dims */
58 30           register PDL_Indx __tinc0_retval = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
59 30           register PDL_Indx __tinc1_retval = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
60             #define PDL_BROADCASTLOOP_START_plParseOpts_readdata PDL_BROADCASTLOOP_START( \
61             readdata, \
62             __privtrans->broadcast, \
63             __privtrans->vtable, \
64             retval_datap += __offsp[0]; \
65             , \
66             ( ,retval_datap += __tinc1_retval - __tinc0_retval * __tdims0 \
67             ), \
68             ( ,retval_datap += __tinc0_retval \
69             ) \
70             )
71             #define PDL_BROADCASTLOOP_END_plParseOpts_readdata PDL_BROADCASTLOOP_END( \
72             __privtrans->broadcast, \
73             retval_datap -= __tinc1_retval * __tdims1 + __offsp[0]; \
74             )
75             #ifndef PDL_DECLARE_PARAMS_plParseOpts_1
76             #define PDL_DECLARE_PARAMS_plParseOpts_1(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_retval,PDL_PPSYM_PARAM_retval) \
77             PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_retval, retval, (__privtrans->pdls[0]), 1, PDL_PPSYM_PARAM_retval)
78             #endif
79             #define PDL_IF_BAD(t,f) f
80 30 50         switch (__privtrans->__datatype) { /* Start generic switch */
81 30           case PDL_D: {
82 30 50         PDL_DECLARE_PARAMS_plParseOpts_1(PDL_Double,D,PDL_Long,L)
    50          
    50          
83 120 50         PDL_BROADCASTLOOP_START_plParseOpts_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
84 30           SV* sv = __params->argv;
85             SV* dummy;
86             AV* arr;
87             int argc, newargc, i, retval;
88             char** args;
89              
90 30 50         if ( !(SvROK (sv) && SvTYPE (SvRV (sv)) == SVt_PVAV)) {
    50          
91 0           barf("plParseOpts requires an array ref");
92             }
93              
94 30           arr = (AV*) SvRV (sv);
95 30           newargc = argc = av_len (arr) + 1;
96 30 50         if (argc > 0) {
97 30           Newx(args, argc, char *);
98 30 50         if(args == NULL) return PDL->make_error(PDL_EUSERERROR, "Error in plParseOpts:" "Failed to allocate memory in plParseOpts");
99              
100 183 100         for (i = 0; i < argc; i++) {
101             STRLEN len;
102 153           args[i] = SvPV (* av_fetch (arr, i, 0), len);
103             }
104              
105 30           (retval_datap)[0] = c_plparseopts (&newargc, (PLCHAR_NC_MATRIX)args, __params->mode);
106              
107 33 100         for (i = 0; i < newargc; i++)
108 3           av_push (arr, newSVpv (args[i], 0));
109              
110 183 100         for (i = 0; i < argc; i++)
111 153           dummy = av_shift (arr); /* assign to dummy to suppress compile warning */
112              
113 30           Safefree (args);
114             }
115 30 50         }PDL_BROADCASTLOOP_END_plParseOpts_readdata
    50          
116 30           } break;
117 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in plParseOpts: unhandled datatype(%d), only handles (D)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
118             }
119             #undef PDL_IF_BAD
120 30           return PDL_err;
121             }
122              
123              
124             #line 1857 "lib/PDL/PP.pm"
125             pdl_error pdl_plParseOpts_free(pdl_trans *__privtrans, char destroy) {
126             pdl_error PDL_err = {0, NULL, 0};
127             #line 128 "pp-plParseOpts.c"
128 30           pdl_params_plParseOpts *__params = __privtrans->params; (void)__params;
129 30 50         PDL_FREE_CODE(__privtrans, destroy, SvREFCNT_dec(__params->argv); /* CType.get_free */
130 30           , ) return PDL_err;
131             }
132              
133             static pdl_datatypes pdl_plParseOpts_vtable_gentypes[] = { PDL_D, -1 };
134             static PDL_Indx pdl_plParseOpts_vtable_realdims[] = { 0 };
135             static char *pdl_plParseOpts_vtable_parnames[] = { "retval" };
136             static short pdl_plParseOpts_vtable_parflags[] = {
137             PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISTYPED|PDL_PARAM_ISWRITE
138             };
139             static pdl_datatypes pdl_plParseOpts_vtable_partypes[] = { PDL_L };
140             static PDL_Indx pdl_plParseOpts_vtable_realdims_starts[] = { 0 };
141             static PDL_Indx pdl_plParseOpts_vtable_realdims_ind_ids[] = { 0 };
142             static char *pdl_plParseOpts_vtable_indnames[] = { "" };
143             pdl_transvtable pdl_plParseOpts_vtable = {
144             PDL_TRANS_DO_BROADCAST|PDL_TRANS_NO_PARALLEL, 0, pdl_plParseOpts_vtable_gentypes, 0, 1, NULL /*CORE21*/,
145             pdl_plParseOpts_vtable_realdims, pdl_plParseOpts_vtable_parnames,
146             pdl_plParseOpts_vtable_parflags, pdl_plParseOpts_vtable_partypes,
147             pdl_plParseOpts_vtable_realdims_starts, pdl_plParseOpts_vtable_realdims_ind_ids, 0,
148             0, pdl_plParseOpts_vtable_indnames,
149             NULL, pdl_plParseOpts_readdata, NULL,
150             pdl_plParseOpts_free,
151             sizeof(pdl_params_plParseOpts),"PDL::Graphics::PLplot::plParseOpts"
152             };
153              
154              
155 30           pdl_error pdl_run_plParseOpts(pdl *retval,SV *argv,int mode) {
156 30           pdl_error PDL_err = {0, NULL, 0};
157 30 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
158 30           pdl_trans *__privtrans = PDL->create_trans(&pdl_plParseOpts_vtable);
159 30 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
160 30           pdl_params_plParseOpts *__params = __privtrans->params;
161 30           __privtrans->pdls[0] = retval;
162 30 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
163 30           (__params->argv) = newSVsv(argv); /* CType.get_copy */
164 30           (__params->mode) = (mode); /* CType.get_copy */
165 30 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
166 30           return PDL_err;
167             }