third_party/modest/source/modest/modest.c

filter: Statementstmt 0.0% 0 / 57 Branchbran 0.0% 0 / 30 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 87 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« third_party/modest/source/modest/layer/layer.c ↑ Summary third_party/modest/source/modest/node/node.c »
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/modest.h"
22 #include "modest/style/sheet.h"
23 #include "modest/style/raw.h"
24 #include "modest/node/node.h"
25  
26 0 modest_t * modest_create(void)
27 {
28 0 return (modest_t*)mycore_calloc(1, sizeof(modest_t));
29 }
30  
31 0 mystatus_t modest_init(modest_t* modest)
32 {
33 mystatus_t status;
34
35 /* Modest nodes */
36 0 modest->mnode_obj = mcobject_async_create();
37 0 ▶ if(modest->mnode_obj == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(modest->mnode_obj == NULL) 0 0 0
38 0 return MODEST_STATUS_ERROR_MNODE_CREATE;
39
40 0 mcobject_async_status_t mcstatus = mcobject_async_init(modest->mnode_obj, 128, 1024, sizeof(modest_node_t));
41 0 ▶ if(mcstatus)
Branch: 1 branch
BranchTrueFalseTotal
if(mcstatus) 0 0 0
42 0 return MODEST_STATUS_ERROR_MNODE_INIT;
43
44 /* base object node for all modest node objects */
45 0 modest->mnode_node_id = mcobject_async_node_add(modest->mnode_obj, &mcstatus);
46 0 ▶ if(mcstatus)
Branch: 1 branch
BranchTrueFalseTotal
if(mcstatus) 0 0 0
47 0 return MODEST_STATUS_ERROR_MNODE_NODE_ADD;
48
49
50 /* Modest stylesheet */
51 0 modest->mstylesheet_obj = mcobject_async_create();
52 0 ▶ if(modest->mstylesheet_obj == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(modest->mstylesheet_obj == NULL) 0 0 0
53 0 return MODEST_STATUS_ERROR_STYLESHEET_CREATE;
54
55 0 mcstatus = mcobject_async_init(modest->mstylesheet_obj, 128, 1024, sizeof(modest_style_sheet_t));
56 0 ▶ if(mcstatus)
Branch: 1 branch
BranchTrueFalseTotal
if(mcstatus) 0 0 0
57 0 return MODEST_STATUS_ERROR_STYLESHEET_INIT;
58
59 /* base object node for all modest stylesheet objects */
60 0 modest->mstylesheet_node_id = mcobject_async_node_add(modest->mstylesheet_obj, &mcstatus);
61 0 ▶ if(mcstatus)
Branch: 1 branch
BranchTrueFalseTotal
if(mcstatus) 0 0 0
62 0 return MODEST_STATUS_ERROR_STYLESHEET_NODE_ADD;
63
64
65 /* Modest style type */
66 0 modest->mstyle_type_obj = mchar_async_create();
67 0 ▶ if(modest->mstyle_type_obj == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(modest->mstyle_type_obj == NULL) 0 0 0
68 0 return MODEST_STATUS_ERROR_STYLE_TYPE_CREATE;
69
70 0 ▶ if((status = mchar_async_init(modest->mstyle_type_obj, 12, (4096 * 5))))
Branch: 1 branch
BranchTrueFalseTotal
if((status = mchar_async_init(modest->mstyle_type_obj, 12, (4096 * 5)))) 0 0 0
71 0 return status;
72
73 0 modest->mstyle_type_node_id = mchar_async_node_add(modest->mstyle_type_obj, &status);
74 0 ▶ if(status)
Branch: 1 branch
BranchTrueFalseTotal
if(status) 0 0 0
75 0 return status;
76
77 /* for raw declaration style */
78 0 modest->mraw_style_declaration_obj = mcobject_create();
79 0 ▶ if(modest->mraw_style_declaration_obj == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(modest->mraw_style_declaration_obj == NULL) 0 0 0
80 0 return MODEST_STATUS_ERROR_STYLE_DECLARATION_CREATE;
81
82 0 mystatus_t myhtml_status = mcobject_init(modest->mraw_style_declaration_obj, 256, sizeof(modest_style_raw_declaration_t));
83 0 ▶ if(myhtml_status)
Branch: 1 branch
BranchTrueFalseTotal
if(myhtml_status) 0 0 0
84 0 return MODEST_STATUS_ERROR_STYLE_DECLARATION_INIT;
85
86
87 /* styles tree */
88 0 modest->style_avl_tree = mycore_utils_avl_tree_create();
89 0 ▶ if(modest->style_avl_tree == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(modest->style_avl_tree == NULL) 0 0 0
90 0 return MODEST_STATUS_ERROR_AVL_TREE_CREATE;
91
92 0 myhtml_status = mycore_utils_avl_tree_init(modest->style_avl_tree);
93 0 ▶ if(myhtml_status)
Branch: 1 branch
BranchTrueFalseTotal
if(myhtml_status) 0 0 0
94 0 return MODEST_STATUS_ERROR_AVL_TREE_INIT;
95
96 0 return MODEST_STATUS_OK;
97 }
98  
99 0 void modest_clean(modest_t* modest)
100 {
101 0 mcobject_async_clean(modest->mnode_obj);
102 0 mcobject_async_clean(modest->mstylesheet_obj);
103 0 mycore_utils_avl_tree_clean(modest->style_avl_tree);
104 0 }
105  
106 0 modest_t * modest_destroy(modest_t* modest, bool self_destroy)
107 {
108 0 ▶ if(modest == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if(modest == NULL) 0 0 0
109 0 return NULL;
110
111 0 modest->mnode_obj = mcobject_async_destroy(modest->mnode_obj, true);
112 0 modest->mstylesheet_obj = mcobject_async_destroy(modest->mstylesheet_obj, true);
113 0 modest->style_avl_tree = mycore_utils_avl_tree_destroy(modest->style_avl_tree, true);
114
115 0 ▶ if(self_destroy) {
Branch: 1 branch
BranchTrueFalseTotal
if(self_destroy) { 0 0 0
116 0 mycore_free(modest);
117 0 return NULL;
118 }
119
120 0 return modest;
121 }
122  
123  
« third_party/modest/source/modest/layer/layer.c ↑ Summary third_party/modest/source/modest/node/node.c »