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/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
|
0
|
|
|
|
|
if(modest->mnode_obj == NULL) |
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
|
0
|
|
|
|
|
if(mcstatus) |
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
|
0
|
|
|
|
|
if(mcstatus) |
47
|
0
|
|
|
|
|
|
return MODEST_STATUS_ERROR_MNODE_NODE_ADD; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
/* Modest stylesheet */ |
51
|
0
|
|
|
|
|
|
modest->mstylesheet_obj = mcobject_async_create(); |
52
|
0
|
0
|
|
|
|
|
if(modest->mstylesheet_obj == NULL) |
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
|
0
|
|
|
|
|
if(mcstatus) |
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
|
0
|
|
|
|
|
if(mcstatus) |
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
|
0
|
|
|
|
|
if(modest->mstyle_type_obj == NULL) |
68
|
0
|
|
|
|
|
|
return MODEST_STATUS_ERROR_STYLE_TYPE_CREATE; |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
if((status = mchar_async_init(modest->mstyle_type_obj, 12, (4096 * 5)))) |
71
|
0
|
|
|
|
|
|
return status; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
modest->mstyle_type_node_id = mchar_async_node_add(modest->mstyle_type_obj, &status); |
74
|
0
|
0
|
|
|
|
|
if(status) |
75
|
0
|
|
|
|
|
|
return status; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
/* for raw declaration style */ |
78
|
0
|
|
|
|
|
|
modest->mraw_style_declaration_obj = mcobject_create(); |
79
|
0
|
0
|
|
|
|
|
if(modest->mraw_style_declaration_obj == NULL) |
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
|
0
|
|
|
|
|
if(myhtml_status) |
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
|
0
|
|
|
|
|
if(modest->style_avl_tree == NULL) |
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
|
0
|
|
|
|
|
if(myhtml_status) |
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
|
0
|
|
|
|
|
if(modest == NULL) |
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
|
0
|
|
|
|
|
if(self_destroy) { |
116
|
0
|
|
|
|
|
|
mycore_free(modest); |
117
|
0
|
|
|
|
|
|
return NULL; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
return modest; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|