File Coverage

third_party/modest/source/modest/render/tree.c
Criterion Covered Total %
statement 0 39 0.0
branch 0 20 0.0
condition n/a
subroutine n/a
pod n/a
total 0 59 0.0


line stmt bran cond sub pod time code
1             /*
2             Copyright (C) 2016-2017 Alexander Borisov
3            
4             This library is free software; you can redistribute it and/or
5             modify it under the terms of the GNU Lesser General Public
6             License as published by the Free Software Foundation; either
7             version 2.1 of the License, or (at your option) any later version.
8            
9             This library is distributed in the hope that it will be useful,
10             but WITHOUT ANY WARRANTY; without even the implied warranty of
11             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12             Lesser General Public License for more details.
13            
14             You should have received a copy of the GNU Lesser General Public
15             License along with this library; if not, write to the Free Software
16             Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17            
18             Author: lex.borisov@gmail.com (Alexander Borisov)
19             */
20              
21             #include "modest/render/tree.h"
22              
23 0           modest_render_tree_t * modest_render_tree_create(void)
24             {
25 0           return mycore_calloc(1, sizeof(modest_render_tree_t));
26             }
27              
28 0           mystatus_t modest_render_tree_init(modest_render_tree_t* render_tree)
29             {
30 0           render_tree->mc_nodes = mcobject_create();
31 0 0         if(render_tree->mc_nodes == NULL)
32 0           return MODEST_STATUS_ERROR_MEMORY_ALLOCATION;
33            
34 0           mystatus_t myhtml_status = mcobject_init(render_tree->mc_nodes, 1024, sizeof(modest_render_tree_node_t));
35 0 0         if(myhtml_status)
36 0           return MODEST_STATUS_ERROR;
37            
38 0           return MODEST_STATUS_OK;
39             }
40              
41 0           void modest_render_tree_clean_all(modest_render_tree_t* render_tree)
42             {
43 0           memset(render_tree, 0, sizeof(modest_render_tree_t));
44 0           }
45              
46 0           modest_render_tree_t * modest_render_tree_destroy(modest_render_tree_t* render_tree, bool self_destroy)
47             {
48 0 0         if(render_tree == NULL)
49 0           return NULL;
50            
51 0           render_tree->mc_nodes = mcobject_destroy(render_tree->mc_nodes, true);
52            
53 0 0         if(self_destroy) {
54 0           mycore_free(render_tree);
55 0           return NULL;
56             }
57            
58 0           return render_tree;
59             }
60              
61 0           void modest_render_tree_serialization(myhtml_tree_t* html_tree, modest_render_tree_t* tree,
62             modest_render_tree_node_t* scope_node, mycore_callback_serialize_f callback, void* context)
63             {
64 0           modest_render_tree_node_t* node = scope_node;
65 0           size_t depth = 0;
66            
67 0 0         while(node) {
68 0 0         for(size_t i = 0; i < depth; i++)
69 0           callback("\t", 1, context);
70            
71 0           modest_render_tree_node_serialization(html_tree, node, callback, context);
72 0           callback("\n", 1, context);
73            
74 0 0         if(node->child) {
75 0           depth++;
76 0           node = node->child;
77             }
78             else {
79 0 0         while(node != scope_node && node->next == NULL) {
    0          
80 0           depth--;
81 0           node = node->parent;
82             }
83            
84 0 0         if(node == scope_node)
85 0           break;
86            
87 0           node = node->next;
88             }
89             }
90            
91            
92 0           }
93              
94