| 1 |
|
| #include "EXTERN.h" |
| 2 |
|
| #include "perl.h" |
| 3 |
|
| #include "XSUB.h" |
| 4 |
|
| |
| 5 |
|
| # include "src/types.h" |
| 6 |
|
| # include "src/Identifiable.h" |
| 7 |
|
| # include "src/Listable.h" |
| 8 |
|
| # include "src/Writable.h" |
| 9 |
|
| # include "src/Node.h" |
| 10 |
|
| # include "src/Tree.h" |
| 11 |
|
| |
| 12 |
0 |
| Tree* create(const char * classname) { |
| 13 |
|
| Tree *self; |
| 14 |
0 |
| Newx(self,1,Tree); |
| 15 |
0 |
| initialize_tree(self); |
| 16 |
0 |
| return self; |
| 17 |
|
| } |
| 18 |
|
| |
| 19 |
0 |
| void initialize_tree(Tree* self){ |
| 20 |
0 |
| initialize_listable((Listable*)self); |
| 21 |
0 |
| self->is_unrooted = 0; |
| 22 |
0 |
| self->is_default = 0; |
| 23 |
0 |
| ((Identifiable*)self)->_type = _TREE_; |
| 24 |
0 |
| ((Identifiable*)self)->_container = _FOREST_; |
| 25 |
0 |
| ((Identifiable*)self)->_index = _TREE_IDX_; |
| 26 |
0 |
| } |
| 27 |
|
| |
| 28 |
0 |
| Tree* set_as_unrooted(Tree* self){ |
| 29 |
0 |
| self->is_unrooted = 1; |
| 30 |
0 |
| return self; |
| 31 |
|
| } |
| 32 |
|
| |
| 33 |
0 |
| Tree* set_as_default(Tree* self) { |
| 34 |
0 |
| self->is_default = 1; |
| 35 |
0 |
| return self; |
| 36 |
|
| } |
| 37 |
|
| |
| 38 |
0 |
| Tree* set_not_default(Tree* self) { |
| 39 |
0 |
| self->is_default = 0; |
| 40 |
0 |
| return self; |
| 41 |
|
| } |
| 42 |
|
| |
| 43 |
0 |
| int is_default(Tree* self) { |
| 44 |
0 |
| return self->is_default; |
| 45 |
|
| } |
| 46 |
|
| |
| 47 |
0 |
| Node* get_root(Tree* self) { |
| 48 |
0 |
| Listable* list = (Listable*)self; |
| 49 |
0 |
| SSize_t max = av_len(list->entities); |
| 50 |
|
| int i; |
| 51 |
0 |
▶ | for ( i = 0; i <= max; i++ ) { |
Branch: 1 branch
| Branch | True | False | Total |
| for ( i = 0; i <= max; i++ ) { |
0 |
0 |
0 |
|
| 52 |
0 |
▶ | if ( av_exists(list->entities,i) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( av_exists(list->entities,i) ) { |
0 |
0 |
0 |
|
| 53 |
0 |
| SV* sv = *(av_fetch(list->entities, i, 0)); |
| 54 |
0 |
| Node* node = (Node*)SvIV(SvRV(sv)); |
| 55 |
0 |
▶ | if ( node->parent == NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( node->parent == NULL ) { |
0 |
0 |
0 |
|
| 56 |
0 |
| return node; |
| 57 |
|
| } |
| 58 |
|
| } |
| 59 |
|
| } |
| 60 |
0 |
| return NULL; |
| 61 |
|
| } |
| 62 |
|
| |
| 63 |
0 |
| void destroy_tree(Tree* self) { |
| 64 |
0 |
| destroy_listable((Listable*)self); |
| 65 |
0 |
| } |
| 66 |
|
| MODULE = Bio::PhyloXS::Forest::Tree PACKAGE = Bio::PhyloXS::Forest::Tree |
| 67 |
|
| |
| 68 |
|
| PROTOTYPES: DISABLE |
| 69 |
|
| |
| 70 |
|
| |
| 71 |
|
| Tree * |
| 72 |
|
| create (classname) |
| 73 |
|
| const char * classname |
| 74 |
|
| |
| 75 |
|
| void |
| 76 |
|
| initialize_tree (self) |
| 77 |
|
| Tree * self |
| 78 |
|
| PREINIT: |
| 79 |
|
| I32* temp; |
| 80 |
|
| PPCODE: |
| 81 |
0 |
| temp = PL_markstack_ptr++; |
| 82 |
0 |
| initialize_tree(self); |
| 83 |
0 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
0 |
0 |
|
| 84 |
|
| /* truly void, because dXSARGS not invoked */ |
| 85 |
0 |
| PL_markstack_ptr = temp; |
| 86 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 87 |
|
| } |
| 88 |
|
| /* must have used dXSARGS; list context implied */ |
| 89 |
0 |
| return; /* assume stack size is correct */ |
| 90 |
|
| |
| 91 |
|
| Tree * |
| 92 |
|
| set_as_unrooted (self) |
| 93 |
|
| Tree * self |
| 94 |
|
| |
| 95 |
|
| Tree * |
| 96 |
|
| set_as_default (self) |
| 97 |
|
| Tree * self |
| 98 |
|
| |
| 99 |
|
| Tree * |
| 100 |
|
| set_not_default (self) |
| 101 |
|
| Tree * self |
| 102 |
|
| |
| 103 |
|
| int |
| 104 |
|
| is_default (self) |
| 105 |
|
| Tree * self |
| 106 |
|
| |
| 107 |
|
| Node * |
| 108 |
|
| get_root (self) |
| 109 |
|
| Tree * self |
| 110 |
|
| |
| 111 |
|
| void |
| 112 |
|
| destroy_tree (self) |
| 113 |
|
| Tree * self |
| 114 |
|
| PREINIT: |
| 115 |
|
| I32* temp; |
| 116 |
|
| PPCODE: |
| 117 |
0 |
| temp = PL_markstack_ptr++; |
| 118 |
0 |
| destroy_tree(self); |
| 119 |
0 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
0 |
0 |
|
| 120 |
|
| /* truly void, because dXSARGS not invoked */ |
| 121 |
0 |
| PL_markstack_ptr = temp; |
| 122 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 123 |
|
| } |
| 124 |
|
| /* must have used dXSARGS; list context implied */ |
| 125 |
0 |
| return; /* assume stack size is correct */ |
| 126 |
|
| |