Matlab.xs

filter: Statementstmt 65.5% 38 / 58 Branchbran 55.8% 19 / 34 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 61.9% 57 / 92 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« extra_matio.c ↑ Summary convert_matvar_pdl.c »
1  
2 #line 453 "lib/PDL/PP.pm"
3 /*
4 * THIS FILE WAS GENERATED BY PDL::PP from matlab.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_IO_Matlab
21 extern Core* PDL; /* Structure hold core C functions */
22 #line 23 "Matlab.xs"
23  
24 #include <stdio.h>
25 #include <stdlib.h>
26 #ifdef DISTRO_MATIO
27 #include "matio-1.5.30/src/matio.h"
28 #else
29 #include <matio.h>
30 #endif
31 //#include "matio-1.5.30/src/matio_private.h"
32 //#include "matio-1.5.30/src/mat5.h"
33 //#include "matio-1.5.30/src/mat4.h"
34 //#include "matio-1.5.30/src/mat73.h"
35 //#include "mat_var_print.c"
36 #include "extra_matio.c"
37 #include "convert_matvar_pdl.c"
38  
39 #line 449 "lib/PDL/PP.pm"
40 #include "pdlperl.h"
41 #line 42 "Matlab.xs"
42  
43 Core* PDL = NULL; /* Structure hold core C functions */
44  
45 MODULE = PDL::IO::Matlab PACKAGE = PDL PREFIX=pdl_run_
46  
47 PROTOTYPES: DISABLE
48  
49  
50 MODULE = PDL::IO::Matlab PACKAGE = PDL::IO::Matlab
51  
52  
53  
54 MODULE = PDL::IO::Matlab PACKAGE = PDL::IO::Matlab
55  
56 mat_t *
57 _mat_open_read( filename )
58 char * filename
59 CODE:
60 4 RETVAL = Mat_Open(filename,MAT_ACC_RDONLY);
61 OUTPUT:
62 RETVAL
63  
64 mat_t *
65 _mat_open_read_write( filename )
66 char * filename
67 CODE:
68 0 RETVAL = Mat_Open(filename,MAT_ACC_RDWR);
69 OUTPUT:
70 RETVAL
71  
72 int
73 _mat_close( handle )
74 mat_t * handle
75 CODE:
76 /* always returns 0 */
77 7 RETVAL = Mat_Close(handle);
78 OUTPUT:
79 RETVAL
80  
81 int
82 _have_hdf5()
83 CODE:
84 #if defined(HAVE_HDF5) && HAVE_HDF5 && defined(MAT73) && MAT73
85 RETVAL = 1;
86 #else
87 1 ▶ RETVAL = 0;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = 0; 0 1 1
88 #endif
89 OUTPUT:
90 RETVAL
91  
92  
93 MODULE = PDL::IO::Matlab PACKAGE = PDL PREFIX=pdl_run_
94  
95  
96 MODULE = PDL::IO::Matlab PACKAGE = PDL::IO::Matlab
97  
98  
99 mat_t *
100 _mat_create_ver( matname, hdr_str, mat_file_ver_in, header_flag)
101 char * matname
102 char * hdr_str
103 int mat_file_ver_in
104 int header_flag
105 CODE:
106 /* following should be written w/o conditionals ! */
107 enum mat_ft mat_file_ver;
108 3 switch (mat_file_ver_in)
109 {
110 #if defined(MAT73) && MAT73
111 case 0:
112 {
113 mat_file_ver = MAT_FT_MAT73;
114 break;
115 }
116 #endif
117 3 case 1:
118 {
119 3 mat_file_ver = MAT_FT_MAT5;
120 3 break;
121 }
122 0 case 2:
123 {
124 0 barf("PDL::IO::Matlab::open Writing in format version MAT4 not supported.");
125 }
126 0 default:
127 0 barf("PDL::IO::Matlab::open unknown file format.");
128 }
129 3 ▶ if (header_flag)
Branch: 1 branch
BranchTrueFalseTotal
if (header_flag) 0 3 3
130 0 RETVAL = Mat_CreateVer(matname, hdr_str, mat_file_ver);
131 3 else RETVAL = Mat_CreateVer(matname, (void *) NULL, mat_file_ver);
132 OUTPUT:
133 RETVAL
134  
135 MODULE = PDL::IO::Matlab PACKAGE = PDL PREFIX=pdl_run_
136  
137  
138 MODULE = PDL::IO::Matlab PACKAGE = PDL::IO::Matlab
139  
140  
141  
142 int
143 _mat_get_version(matfp)
144 mat_t * matfp
145 CODE:
146 enum mat_ft mat_file_ver;
147 int retval;
148 5 mat_file_ver = Mat_GetVersion(matfp);
149 /* fprintf(stderr, "in C vers %d", mat_file_ver); */
150 /* This could be done much more easily ! */
151 5 switch (mat_file_ver)
152 {
153 0 case MAT_FT_MAT73:
154 {
155 0 retval= 0;
156 0 break;
157 }
158 5 case MAT_FT_MAT5:
159 {
160 5 retval= 1;
161 5 break;
162 }
163 0 case MAT_FT_MAT4:
164 {
165 0 retval= 2;
166 0 break;
167 }
168 0 default:
169 {
170 0 barf("PDL::IO::Matlab::get_version returned unknown version.");
171 }
172 }
173 5 ▶ RETVAL = retval;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = retval; 4 1 5
174 OUTPUT:
175 RETVAL
176  
177 MODULE = PDL::IO::Matlab PACKAGE = PDL PREFIX=pdl_run_
178  
179  
180 MODULE = PDL::IO::Matlab PACKAGE = PDL::IO::Matlab
181  
182  
183  
184 void
185 _read_data_all (mat, matvar)
186 mat_t * mat
187 matvar_t * matvar
188 CODE:
189 0 Mat_VarReadDataAll(mat,matvar);
190  
191 void
192 get_library_version()
193 INIT:
194 int major,minor,release;
195  
196 PPCODE:
197 1 Mat_GetLibraryVersion(&major, &minor, &release);
198 1 ▶ XPUSHs(sv_2mortal(newSVnv(major)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVnv(major))); 0 1 1
199 1 ▶ XPUSHs(sv_2mortal(newSVnv(minor)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVnv(minor))); 0 1 1
200 1 ▶ XPUSHs(sv_2mortal(newSVnv(release)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVnv(release))); 0 1 1
201  
202 int
203 _mat_rewind(mat)
204 mat_t * mat
205 CODE:
206 1 RETVAL = Mat_Rewind(mat);
207 1 ▶if (RETVAL == -1) barf("PDL::IO::Matlab::rewind Bad filehandle");
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL == -1) barf("PDL::IO::Matlab::rewind Bad filehandle"); 0 1 1
208 OUTPUT:
209 RETVAL
210  
211 char *
212 _mat_get_header(mat)
213 mat_t * mat
214 CODE:
215 1 RETVAL = (char *)Mat_GetHeader(mat);
216 OUTPUT:
217 RETVAL
218  
219 char *
220 _mat_get_filename(mat)
221 mat_t * mat
222 CODE:
223 0 RETVAL = (char *)Mat_GetFilename(mat);
224 OUTPUT:
225 RETVAL
226  
227  
228 MODULE = PDL::IO::Matlab PACKAGE = PDL PREFIX=pdl_run_
229  
230  
231 MODULE = PDL::IO::Matlab PACKAGE = PDL::IO::Matlab
232  
233  
234  
235 void
236 _extra_matio_print_all_var_info (matfp,printdata)
237 mat_t * matfp
238 int printdata
239 CODE:
240 0 extra_matio_print_all_var_info(matfp,printdata);
241  
242 void
243 _convert_next_matvar_to_pdl(matfp,onedr)
244 mat_t * matfp
245 int onedr
246 PPCODE:
247 pdl * retpdl;
248 matvar_t * matvar;
249 25 retpdl = convert_next_matvar_to_pdl(matfp, &matvar, onedr);
250 25 SV * s = sv_newmortal();
251 25 SV * p = sv_newmortal();
252 25 ▶if (retpdl != NULL) PDL->SetSV_PDL(p,retpdl);
Branch: 1 branch
BranchTrueFalseTotal
if (retpdl != NULL) PDL->SetSV_PDL(p,retpdl); 21 4 25
253 25 ▶if (matvar != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (matvar != NULL) { 21 4 25
254 21 sv_setpv(s, matvar->name);
255 21 Mat_VarFree(matvar);
256 }
257 25 ▶XPUSHs(p);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(p); 0 25 25
258 25 ▶XPUSHs(s);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(s); 0 25 25
259  
260 int
261 _write_pdl_to_matlab_file (mat, ndarray, varname, oned, compress)
262 mat_t * mat
263 pdl * ndarray
264 char * varname
265 int oned
266 int compress
267 CODE:
268 9 RETVAL = write_pdl_to_matlab_file (mat, ndarray, varname, oned, compress);
269 OUTPUT:
270 RETVAL
271  
272  
273  
274 MODULE = PDL::IO::Matlab PACKAGE = PDL PREFIX=pdl_run_
275  
276  
277  
278 #line 483 "lib/PDL/PP.pm"
279 BOOT:
280 /* Get pointer to structure of core shared C routines */
281 /* make sure PDL::Core is loaded */
282 #line 283 "Matlab.xs"
283 1 perl_require_pv ("PDL/Core.pm"); /* make sure PDL::Core is loaded */
284 #ifndef aTHX_
285 #define aTHX_
286 #endif
287 1 ▶ if (SvTRUE (ERRSV)) Perl_croak(aTHX_ "%s",SvPV_nolen (ERRSV));
Branch: 3 branches
BranchTrueFalseTotal
if (SvTRUE (ERRSV)) Perl_croak(aTHX_ "%s",SvPV_nolen (ERRSV)); 1 0 1
if (SvTRUE (ERRSV)) Perl_croak(aTHX_ "%s",SvPV_nolen (ERRSV)); 0 1 1
if (SvTRUE (ERRSV)) Perl_croak(aTHX_ "%s",SvPV_nolen (ERRSV)); 0 0 0
288 1 SV* CoreSV = perl_get_sv("PDL::SHARE",FALSE); /* var with core structure */
289 1 ▶ if (!CoreSV)
Branch: 1 branch
BranchTrueFalseTotal
if (!CoreSV) 0 1 1
290 0 Perl_croak(aTHX_ "We require the PDL::Core module, which was not found");
291 1 ▶ if (!(PDL = INT2PTR(Core*,SvIV( CoreSV )))) /* Core* value */
Branch: 1 branch
BranchTrueFalseTotal
if (!(PDL = INT2PTR(Core*,SvIV( CoreSV )))) /* Core* value */ 0 1 1
292 0 Perl_croak(aTHX_ "Got NULL pointer for PDL");
293 1 ▶ if (PDL->Version != PDL_CORE_VERSION)
Branch: 1 branch
BranchTrueFalseTotal
if (PDL->Version != PDL_CORE_VERSION) 0 1 1
294 0 Perl_croak(aTHX_ "[PDL->Version: %ld PDL_CORE_VERSION: %ld XS_VERSION: %s] PDL::IO::Matlab needs to be recompiled against the newly installed PDL", (long int)PDL->Version, (long int)PDL_CORE_VERSION, XS_VERSION);
« extra_matio.c ↑ Summary convert_matvar_pdl.c »