src/Exceptions.h

filter: Statementstmt 0.0% 0 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 12 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« lib/Bio/PhyloXS/Util/Exceptions.c ↑ Summary blib/lib/Bio/PhyloXS/NeXML/Writable.pm »
1 #ifndef EXCEPTIONS_H
2 #define EXCEPTIONS_H
3  
4 typedef struct {
5 char * message;
6 char * class_name;
7 } Exceptions;
8  
9 //SV* except( char * name, char * message );
10 //char* error(SV* self);
11  
12 0 SV* except(char* name, char* message) {
13 char class_name[80];
14 0 strcpy(class_name, "Bio::Phylo::Util::Exceptions::");
15 0 strcat(class_name, name);
16
17 Exceptions* exception;
18 SV* obj;
19 SV* obj_ref;
20  
21 0 Newx(exception, 1, Exceptions);
22 0 exception->message = savepv(message);
23  
24 0 obj = newSViv((IV)exception);
25 0 obj_ref = newRV_noinc(obj);
26 0 sv_bless(obj_ref, gv_stashpv(class_name, GV_ADD));
27 0 SvREADONLY_on(obj);
28  
29 0 return obj_ref;
30 }
31  
32 0 char* error(SV* self) {
33 0 return ((Exceptions*)SvIV(SvRV(self)))->message;
34 }
35  
36 #endif
« lib/Bio/PhyloXS/Util/Exceptions.c ↑ Summary blib/lib/Bio/PhyloXS/NeXML/Writable.pm »