| 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 "mycss/declaration/entry.h" |
|
22
|
|
|
|
|
|
|
#include "mycss/declaration/entry_destroy_resources.h" |
|
23
|
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
mycss_declaration_entry_t * mycss_declaration_entry_create(mycss_declaration_t* declaration, mystatus_t* status) |
|
25
|
|
|
|
|
|
|
{ |
|
26
|
0
|
|
|
|
|
|
mycss_declaration_entry_t *dec_entry = mcobject_malloc(declaration->mcobject_entries, status); |
|
27
|
0
|
|
|
|
|
|
memset(dec_entry, 0, sizeof(mycss_declaration_entry_t)); |
|
28
|
0
|
|
|
|
|
|
return dec_entry; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
void mycss_declaration_entry_clean(mycss_declaration_entry_t* entry) |
|
32
|
|
|
|
|
|
|
{ |
|
33
|
0
|
|
|
|
|
|
entry->value = NULL; |
|
34
|
0
|
|
|
|
|
|
entry->value_type = 0; |
|
35
|
0
|
|
|
|
|
|
entry->is_important = false; |
|
36
|
0
|
|
|
|
|
|
entry->type = MyCSS_PROPERTY_TYPE_UNDEF; |
|
37
|
0
|
|
|
|
|
|
entry->flags = MyCSS_DECLARATION_FLAGS_UNDEF; |
|
38
|
0
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
void mycss_declaration_entry_clean_all(mycss_declaration_entry_t* dec_entry) |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
0
|
|
|
|
|
|
memset(dec_entry, 0, sizeof(mycss_declaration_entry_t)); |
|
43
|
0
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
mycss_declaration_entry_t * mycss_declaration_entry_destroy(mycss_declaration_t* declaration, mycss_declaration_entry_t* decl_entry, bool self_destroy) |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
0
|
0
|
|
|
|
|
if(decl_entry == NULL) |
|
48
|
0
|
|
|
|
|
|
return NULL; |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return mycss_declaration_entry_destroy_map_by_type[ decl_entry->type ](declaration, decl_entry, self_destroy); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
void mycss_declaration_entry_append_to_current(mycss_declaration_t* declaration, mycss_declaration_entry_t* dec_entry) |
|
54
|
|
|
|
|
|
|
{ |
|
55
|
0
|
0
|
|
|
|
|
if(declaration->entry_last) { |
|
56
|
0
|
|
|
|
|
|
declaration->entry_last->next = dec_entry; |
|
57
|
0
|
|
|
|
|
|
dec_entry->prev = declaration->entry_last; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
else { |
|
60
|
0
|
|
|
|
|
|
(*declaration->entry) = dec_entry; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
declaration->entry_last = dec_entry; |
|
64
|
0
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
mycss_declaration_entry_t * mycss_declaration_entry_clone(mycss_declaration_t* declaration, mycss_declaration_entry_t* dec_entry, bool with_value) |
|
67
|
|
|
|
|
|
|
{ |
|
68
|
0
|
|
|
|
|
|
mycss_declaration_entry_t *new_decl = mycss_declaration_entry_create(declaration, NULL); |
|
69
|
0
|
|
|
|
|
|
memcpy(new_decl, dec_entry, sizeof(mycss_declaration_entry_t)); |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
if(with_value && dec_entry->value) { |
|
|
|
0
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
new_decl->value = mycss_values_clone(declaration->ref_entry, dec_entry->value); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return new_decl; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
void mycss_declaration_entry_remove(mycss_declaration_t* declaration, mycss_declaration_entry_t* dec_entry) |
|
79
|
|
|
|
|
|
|
{ |
|
80
|
0
|
0
|
|
|
|
|
if(dec_entry->next) { |
|
81
|
0
|
|
|
|
|
|
dec_entry->next->prev = dec_entry->prev; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
if(dec_entry->prev) { |
|
85
|
0
|
|
|
|
|
|
dec_entry->prev->next = dec_entry->next; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
dec_entry->next = NULL; |
|
89
|
0
|
|
|
|
|
|
dec_entry->prev = NULL; |
|
90
|
0
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
mycss_declaration_entry_t * mycss_declaration_entry_delete(mycss_declaration_t* declaration, mycss_declaration_entry_t* dec_entry) |
|
93
|
|
|
|
|
|
|
{ |
|
94
|
0
|
|
|
|
|
|
mycss_declaration_entry_remove(declaration, dec_entry); |
|
95
|
0
|
|
|
|
|
|
mycss_declaration_entry_destroy(declaration, dec_entry, true); |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
return NULL; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
mycss_declaration_entry_t * mycss_declaration_entry(mycss_declaration_t* declaration) |
|
101
|
|
|
|
|
|
|
{ |
|
102
|
0
|
|
|
|
|
|
return declaration->entry_last; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
mycss_declaration_entry_t * mycss_declaration_entry_last(mycss_declaration_t* declaration) |
|
106
|
|
|
|
|
|
|
{ |
|
107
|
0
|
|
|
|
|
|
return declaration->entry_last; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
void mycss_declaration_entry_type_set(mycss_declaration_entry_t* dec_entry, mycss_property_type_t type) |
|
111
|
|
|
|
|
|
|
{ |
|
112
|
0
|
|
|
|
|
|
dec_entry->type = type; |
|
113
|
0
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
void mycss_declaration_entry_important_set(mycss_declaration_entry_t* dec_entry, bool is_important) |
|
116
|
|
|
|
|
|
|
{ |
|
117
|
0
|
|
|
|
|
|
dec_entry->is_important = is_important; |
|
118
|
0
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|