lib/Bio/PhyloXS/Matrices/TypeSafeData.xs

filter: Statementstmt 0.0% 0 / 80 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 94 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« lib/Bio/PhyloXS/Matrices/Matrix.xs ↑ Summary lib/Bio/PhyloXS/Mediators/TaxaMediator.xs »
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4  
5 # include "src/TypeSafeData.h"
6 # include "src/Listable.h"
7 # include "src/Datatype.h"
8 # include "src/types.h"
9  
10 0 TypeSafeData* create(const char * classname) {
11 TypeSafeData *self;
12 0 Newx(self,1,TypeSafeData);
13 0 initialize_typesafedata(self);
14 0 return self;
15 }
16  
17 0 void initialize_typesafedata(TypeSafeData* self){
18 0 initialize_listable((Listable*)self);
19  
20 // create datatype object
21 0 Newx(self->datatype,1,Datatype);
22 0 initialize_writable((Writable*)self->datatype);
23 0 self->datatype->missing = '?';
24 0 self->datatype->gap = '-';
25 0 self->datatype->datatype = 0;
26 0 ((Identifiable*)self->datatype)->_type = _DATATYPE_;
27 0 ((Identifiable*)self->datatype)->_container = _NONE_;
28 0 ((Identifiable*)self->datatype)->_index = _DATATYPE_IDX_;
29 0 }
30  
31 0 TypeSafeData* set_type(TypeSafeData* self, char* type) {
32 0 ▶ if ( tolower(type[0]) == 'd' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( tolower(type[0]) == 'd' ) { 0 0 0
33 0 self->datatype->datatype = _DNA_;
34 }
35 0 ▶ else if ( tolower(type[0]) == 'r' ) {
Branch: 1 branch
BranchTrueFalseTotal
else if ( tolower(type[0]) == 'r' ) { 0 0 0
36 0 self->datatype->datatype = _RNA_;
37 }
38 0 ▶ else if ( tolower(type[0]) == 'p' ) {
Branch: 1 branch
BranchTrueFalseTotal
else if ( tolower(type[0]) == 'p' ) { 0 0 0
39 0 self->datatype->datatype = _PROTEIN_;
40 }
41 0 ▶ else if ( tolower(type[0]) == 's' ) {
Branch: 1 branch
BranchTrueFalseTotal
else if ( tolower(type[0]) == 's' ) { 0 0 0
42 0 self->datatype->datatype = _STANDARD_;
43 }
44 0 ▶ else if ( tolower(type[0]) == 'c' ) {
Branch: 1 branch
BranchTrueFalseTotal
else if ( tolower(type[0]) == 'c' ) { 0 0 0
45 0 self->datatype->datatype = _CONTINUOUS_;
46 }
47 else {
48 0 warn("Unsupported data type");
49 }
50 0 return self;
51 }
52  
53 0 char get_missing(TypeSafeData* self) {
54 0 return self->datatype->missing;
55 }
56  
57 0 TypeSafeData* set_missing(TypeSafeData* self, char missing) {
58 0 self->datatype->missing = missing;
59 0 return self;
60 }
61  
62 0 char get_gap(TypeSafeData* self) {
63 0 return self->datatype->gap;
64 }
65  
66 0 TypeSafeData* set_gap(TypeSafeData* self, char gap) {
67 0 self->datatype->gap = gap;
68 0 return self;
69 }
70  
71 0 char* get_type(TypeSafeData* self) {
72 char* retval;
73 0 switch(self->datatype->datatype) {
74 0 case _DNA_:
75 0 retval = "dna";
76 0 break;
77 0 case _RNA_:
78 0 retval = "rna";
79 0 break;
80 0 case _PROTEIN_:
81 0 retval = "protein";
82 0 break;
83 0 case _STANDARD_:
84 0 retval = "protein";
85 0 break;
86 0 case _CONTINUOUS_:
87 0 retval = "continuous";
88 0 break;
89 0 default:
90 0 warn("Datatype undefined");
91 0 break;
92 }
93 0 return retval;
94 }
95  
96 0 Datatype* get_type_object(TypeSafeData* self) {
97 0 return self->datatype;
98 }
99  
100 0 TypeSafeData* set_type_object(TypeSafeData* self, Datatype* type) {
101 0 self->datatype = type;
102 0 return self;
103 }
104  
105 0 void destroy_typesafedata(TypeSafeData* self) {
106 0 destroy_listable((Listable*)self);
107 0 Safefree(self->datatype);
108 0 }
109 MODULE = Bio::PhyloXS::Matrices::TypeSafeData PACKAGE = Bio::PhyloXS::Matrices::TypeSafeData
110  
111 PROTOTYPES: DISABLE
112  
113  
114 TypeSafeData *
115 create (classname)
116 const char * classname
117  
118 void
119 initialize_typesafedata (self)
120 TypeSafeData * self
121 PREINIT:
122 I32* temp;
123 PPCODE:
124 0 temp = PL_markstack_ptr++;
125 0 initialize_typesafedata(self);
126 0 ▶ if (PL_markstack_ptr != temp) {
Branch: 1 branch
BranchTrueFalseTotal
if (PL_markstack_ptr != temp) { 0 0 0
127 /* truly void, because dXSARGS not invoked */
128 0 PL_markstack_ptr = temp;
129 0 XSRETURN_EMPTY; /* return empty stack */
130 }
131 /* must have used dXSARGS; list context implied */
132 0 return; /* assume stack size is correct */
133  
134 TypeSafeData *
135 set_type (self, type)
136 TypeSafeData * self
137 char * type
138  
139 char
140 get_missing (self)
141 TypeSafeData * self
142  
143 TypeSafeData *
144 set_missing (self, missing)
145 TypeSafeData * self
146 char missing
147  
148 char
149 get_gap (self)
150 TypeSafeData * self
151  
152 TypeSafeData *
153 set_gap (self, gap)
154 TypeSafeData * self
155 char gap
156  
157 char *
158 get_type (self)
159 TypeSafeData * self
160  
161 Datatype *
162 get_type_object (self)
163 TypeSafeData * self
164  
165 TypeSafeData *
166 set_type_object (self, type)
167 TypeSafeData * self
168 Datatype * type
169  
170 void
171 destroy_typesafedata (self)
172 TypeSafeData * self
173 PREINIT:
174 I32* temp;
175 PPCODE:
176 0 temp = PL_markstack_ptr++;
177 0 destroy_typesafedata(self);
178 0 ▶ if (PL_markstack_ptr != temp) {
Branch: 1 branch
BranchTrueFalseTotal
if (PL_markstack_ptr != temp) { 0 0 0
179 /* truly void, because dXSARGS not invoked */
180 0 PL_markstack_ptr = temp;
181 0 XSRETURN_EMPTY; /* return empty stack */
182 }
183 /* must have used dXSARGS; list context implied */
184 0 return; /* assume stack size is correct */
185  
« lib/Bio/PhyloXS/Matrices/Matrix.xs ↑ Summary lib/Bio/PhyloXS/Mediators/TaxaMediator.xs »