herb 0.8.6 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/herb/error_helpers.c +1 -1
- data/ext/herb/extension_helpers.c +1 -1
- data/ext/herb/nodes.c +2 -2
- data/lib/herb/version.rb +1 -1
- data/src/analyze.c +27 -27
- data/src/ast_node.c +1 -1
- data/src/ast_nodes.c +53 -157
- data/src/errors.c +5 -5
- data/src/extract.c +2 -2
- data/src/herb.c +2 -2
- data/src/include/util/hb_narray.h +1 -0
- data/src/include/version.h +1 -1
- data/src/parser.c +9 -9
- data/src/parser_helpers.c +4 -4
- data/src/pretty_print.c +6 -6
- data/src/util/hb_array.c +1 -0
- data/src/util/hb_narray.c +6 -0
- data/src/visitor.c +26 -26
- data/templates/ext/herb/error_helpers.c.erb +1 -1
- data/templates/ext/herb/nodes.c.erb +1 -1
- data/templates/java/error_helpers.c.erb +1 -1
- data/templates/java/nodes.c.erb +2 -2
- data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +1 -1
- data/templates/javascript/packages/node/extension/nodes.cpp.erb +1 -1
- data/templates/rust/src/ast/nodes.rs.erb +2 -2
- data/templates/src/ast_nodes.c.erb +3 -7
- data/templates/src/errors.c.erb +5 -5
- data/templates/src/visitor.c.erb +1 -1
- data/templates/wasm/error_helpers.cpp.erb +1 -1
- data/templates/wasm/nodes.cpp.erb +1 -1
- metadata +2 -2
data/src/parser.c
CHANGED
|
@@ -314,7 +314,7 @@ static AST_HTML_ATTRIBUTE_NAME_NODE_T* parser_parse_html_attribute_name(parser_T
|
|
|
314
314
|
position_T node_start = { 0 };
|
|
315
315
|
position_T node_end = { 0 };
|
|
316
316
|
|
|
317
|
-
if (children
|
|
317
|
+
if (hb_array_size(children) > 0) {
|
|
318
318
|
AST_NODE_T* first_child = hb_array_first(children);
|
|
319
319
|
AST_NODE_T* last_child = hb_array_last(children);
|
|
320
320
|
|
|
@@ -1144,7 +1144,7 @@ static void parser_parse_in_data_state(parser_T* parser, hb_array_T* children, h
|
|
|
1144
1144
|
static size_t find_matching_close_tag(hb_array_T* nodes, size_t start_idx, hb_string_T tag_name) {
|
|
1145
1145
|
int depth = 0;
|
|
1146
1146
|
|
|
1147
|
-
for (size_t i = start_idx + 1; i < nodes
|
|
1147
|
+
for (size_t i = start_idx + 1; i < hb_array_size(nodes); i++) {
|
|
1148
1148
|
AST_NODE_T* node = (AST_NODE_T*) hb_array_get(nodes, i);
|
|
1149
1149
|
if (node == NULL) { continue; }
|
|
1150
1150
|
|
|
@@ -1168,9 +1168,9 @@ static size_t find_matching_close_tag(hb_array_T* nodes, size_t start_idx, hb_st
|
|
|
1168
1168
|
static hb_array_T* parser_build_elements_from_tags(hb_array_T* nodes, hb_array_T* errors);
|
|
1169
1169
|
|
|
1170
1170
|
static hb_array_T* parser_build_elements_from_tags(hb_array_T* nodes, hb_array_T* errors) {
|
|
1171
|
-
hb_array_T* result = hb_array_init(nodes
|
|
1171
|
+
hb_array_T* result = hb_array_init(hb_array_size(nodes));
|
|
1172
1172
|
|
|
1173
|
-
for (size_t index = 0; index < nodes
|
|
1173
|
+
for (size_t index = 0; index < hb_array_size(nodes); index++) {
|
|
1174
1174
|
AST_NODE_T* node = (AST_NODE_T*) hb_array_get(nodes, index);
|
|
1175
1175
|
if (node == NULL) { continue; }
|
|
1176
1176
|
|
|
@@ -1181,7 +1181,7 @@ static hb_array_T* parser_build_elements_from_tags(hb_array_T* nodes, hb_array_T
|
|
|
1181
1181
|
size_t close_index = find_matching_close_tag(nodes, index, tag_name);
|
|
1182
1182
|
|
|
1183
1183
|
if (close_index == (size_t) -1) {
|
|
1184
|
-
if (open_tag->base.errors
|
|
1184
|
+
if (hb_array_size(open_tag->base.errors) == 0) {
|
|
1185
1185
|
append_missing_closing_tag_error(
|
|
1186
1186
|
open_tag->tag_name,
|
|
1187
1187
|
open_tag->base.location.start,
|
|
@@ -1225,7 +1225,7 @@ static hb_array_T* parser_build_elements_from_tags(hb_array_T* nodes, hb_array_T
|
|
|
1225
1225
|
AST_HTML_CLOSE_TAG_NODE_T* close_tag = (AST_HTML_CLOSE_TAG_NODE_T*) node;
|
|
1226
1226
|
|
|
1227
1227
|
if (!is_void_element(hb_string(close_tag->tag_name->value))) {
|
|
1228
|
-
if (close_tag->base.errors
|
|
1228
|
+
if (hb_array_size(close_tag->base.errors) == 0) {
|
|
1229
1229
|
append_missing_opening_tag_error(
|
|
1230
1230
|
close_tag->tag_name,
|
|
1231
1231
|
close_tag->base.location.start,
|
|
@@ -1299,19 +1299,19 @@ void herb_parser_deinit(parser_T* parser) {
|
|
|
1299
1299
|
}
|
|
1300
1300
|
|
|
1301
1301
|
void match_tags_in_node_array(hb_array_T* nodes, hb_array_T* errors) {
|
|
1302
|
-
if (nodes == NULL || nodes
|
|
1302
|
+
if (nodes == NULL || hb_array_size(nodes) == 0) { return; }
|
|
1303
1303
|
|
|
1304
1304
|
hb_array_T* processed = parser_build_elements_from_tags(nodes, errors);
|
|
1305
1305
|
|
|
1306
1306
|
nodes->size = 0;
|
|
1307
1307
|
|
|
1308
|
-
for (size_t i = 0; i < processed
|
|
1308
|
+
for (size_t i = 0; i < hb_array_size(processed); i++) {
|
|
1309
1309
|
hb_array_append(nodes, hb_array_get(processed, i));
|
|
1310
1310
|
}
|
|
1311
1311
|
|
|
1312
1312
|
hb_array_free(&processed);
|
|
1313
1313
|
|
|
1314
|
-
for (size_t i = 0; i < nodes
|
|
1314
|
+
for (size_t i = 0; i < hb_array_size(nodes); i++) {
|
|
1315
1315
|
AST_NODE_T* node = (AST_NODE_T*) hb_array_get(nodes, i);
|
|
1316
1316
|
if (node == NULL) { continue; }
|
|
1317
1317
|
|
data/src/parser_helpers.c
CHANGED
|
@@ -19,7 +19,7 @@ void parser_push_open_tag(const parser_T* parser, token_T* tag_name) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
bool parser_check_matching_tag(const parser_T* parser, hb_string_T tag_name) {
|
|
22
|
-
if (parser->open_tags_stack
|
|
22
|
+
if (hb_array_size(parser->open_tags_stack) == 0) { return false; }
|
|
23
23
|
|
|
24
24
|
token_T* top_token = hb_array_last(parser->open_tags_stack);
|
|
25
25
|
if (top_token == NULL || top_token->value == NULL) { return false; };
|
|
@@ -28,7 +28,7 @@ bool parser_check_matching_tag(const parser_T* parser, hb_string_T tag_name) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
token_T* parser_pop_open_tag(const parser_T* parser) {
|
|
31
|
-
if (parser->open_tags_stack
|
|
31
|
+
if (hb_array_size(parser->open_tags_stack) == 0) { return NULL; }
|
|
32
32
|
|
|
33
33
|
return hb_array_pop(parser->open_tags_stack);
|
|
34
34
|
}
|
|
@@ -42,7 +42,7 @@ token_T* parser_pop_open_tag(const parser_T* parser) {
|
|
|
42
42
|
bool parser_in_svg_context(const parser_T* parser) {
|
|
43
43
|
if (!parser || !parser->open_tags_stack) { return false; }
|
|
44
44
|
|
|
45
|
-
size_t stack_size = parser->open_tags_stack
|
|
45
|
+
size_t stack_size = hb_array_size(parser->open_tags_stack);
|
|
46
46
|
|
|
47
47
|
for (size_t i = 0; i < stack_size; i++) {
|
|
48
48
|
token_T* tag = (token_T*) hb_array_get(parser->open_tags_stack, i);
|
|
@@ -191,7 +191,7 @@ void parser_handle_mismatched_tags(
|
|
|
191
191
|
const AST_HTML_CLOSE_TAG_NODE_T* close_tag,
|
|
192
192
|
hb_array_T* errors
|
|
193
193
|
) {
|
|
194
|
-
if (parser->open_tags_stack
|
|
194
|
+
if (hb_array_size(parser->open_tags_stack) > 0) {
|
|
195
195
|
token_T* expected_tag = hb_array_last(parser->open_tags_stack);
|
|
196
196
|
token_T* actual_tag = close_tag->tag_name;
|
|
197
197
|
|
data/src/pretty_print.c
CHANGED
|
@@ -113,7 +113,7 @@ void pretty_print_array(
|
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
if (array
|
|
116
|
+
if (hb_array_size(array) == 0) {
|
|
117
117
|
pretty_print_property(name, hb_string("[]"), indent, relative_indent, last_property, buffer);
|
|
118
118
|
|
|
119
119
|
return;
|
|
@@ -124,17 +124,17 @@ void pretty_print_array(
|
|
|
124
124
|
hb_buffer_append(buffer, "(");
|
|
125
125
|
|
|
126
126
|
char count[16];
|
|
127
|
-
sprintf(count, "%zu", array
|
|
127
|
+
sprintf(count, "%zu", hb_array_size(array));
|
|
128
128
|
hb_buffer_append(buffer, count);
|
|
129
129
|
hb_buffer_append(buffer, ")\n");
|
|
130
130
|
|
|
131
131
|
if (indent < 20) {
|
|
132
|
-
for (size_t i = 0; i < array
|
|
132
|
+
for (size_t i = 0; i < hb_array_size(array); i++) {
|
|
133
133
|
AST_NODE_T* child = hb_array_get(array, i);
|
|
134
134
|
pretty_print_indent(buffer, indent);
|
|
135
135
|
pretty_print_indent(buffer, relative_indent + 1);
|
|
136
136
|
|
|
137
|
-
if (i == array
|
|
137
|
+
if (i == hb_array_size(array) - 1) {
|
|
138
138
|
hb_buffer_append(buffer, "└── ");
|
|
139
139
|
} else {
|
|
140
140
|
hb_buffer_append(buffer, "├── ");
|
|
@@ -142,7 +142,7 @@ void pretty_print_array(
|
|
|
142
142
|
|
|
143
143
|
ast_pretty_print_node(child, indent + 1, relative_indent + 1, buffer);
|
|
144
144
|
|
|
145
|
-
if (i != array
|
|
145
|
+
if (i != hb_array_size(array) - 1) { pretty_print_newline(indent + 1, relative_indent, buffer); }
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
hb_buffer_append(buffer, "\n");
|
|
@@ -155,7 +155,7 @@ void pretty_print_errors(
|
|
|
155
155
|
const bool last_property,
|
|
156
156
|
hb_buffer_T* buffer
|
|
157
157
|
) {
|
|
158
|
-
if (node->errors
|
|
158
|
+
if (hb_array_size(node->errors) > 0) {
|
|
159
159
|
error_pretty_print_array("errors", node->errors, indent, relative_indent, last_property, buffer);
|
|
160
160
|
hb_buffer_append(buffer, "\n");
|
|
161
161
|
}
|
data/src/util/hb_array.c
CHANGED
data/src/util/hb_narray.c
CHANGED
data/src/visitor.c
CHANGED
|
@@ -24,7 +24,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
24
24
|
const AST_DOCUMENT_NODE_T* document_node = ((const AST_DOCUMENT_NODE_T *) node);
|
|
25
25
|
|
|
26
26
|
if (document_node->children != NULL) {
|
|
27
|
-
for (size_t index = 0; index < document_node->children
|
|
27
|
+
for (size_t index = 0; index < hb_array_size(document_node->children); index++) {
|
|
28
28
|
herb_visit_node(hb_array_get(document_node->children, index), visitor, data);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -35,7 +35,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
35
35
|
const AST_HTML_OPEN_TAG_NODE_T* html_open_tag_node = ((const AST_HTML_OPEN_TAG_NODE_T *) node);
|
|
36
36
|
|
|
37
37
|
if (html_open_tag_node->children != NULL) {
|
|
38
|
-
for (size_t index = 0; index < html_open_tag_node->children
|
|
38
|
+
for (size_t index = 0; index < hb_array_size(html_open_tag_node->children); index++) {
|
|
39
39
|
herb_visit_node(hb_array_get(html_open_tag_node->children, index), visitor, data);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -46,7 +46,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
46
46
|
const AST_HTML_CLOSE_TAG_NODE_T* html_close_tag_node = ((const AST_HTML_CLOSE_TAG_NODE_T *) node);
|
|
47
47
|
|
|
48
48
|
if (html_close_tag_node->children != NULL) {
|
|
49
|
-
for (size_t index = 0; index < html_close_tag_node->children
|
|
49
|
+
for (size_t index = 0; index < hb_array_size(html_close_tag_node->children); index++) {
|
|
50
50
|
herb_visit_node(hb_array_get(html_close_tag_node->children, index), visitor, data);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -61,7 +61,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
if (html_element_node->body != NULL) {
|
|
64
|
-
for (size_t index = 0; index < html_element_node->body
|
|
64
|
+
for (size_t index = 0; index < hb_array_size(html_element_node->body); index++) {
|
|
65
65
|
herb_visit_node(hb_array_get(html_element_node->body, index), visitor, data);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -76,7 +76,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
76
76
|
const AST_HTML_ATTRIBUTE_VALUE_NODE_T* html_attribute_value_node = ((const AST_HTML_ATTRIBUTE_VALUE_NODE_T *) node);
|
|
77
77
|
|
|
78
78
|
if (html_attribute_value_node->children != NULL) {
|
|
79
|
-
for (size_t index = 0; index < html_attribute_value_node->children
|
|
79
|
+
for (size_t index = 0; index < hb_array_size(html_attribute_value_node->children); index++) {
|
|
80
80
|
herb_visit_node(hb_array_get(html_attribute_value_node->children, index), visitor, data);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -87,7 +87,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
87
87
|
const AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node = ((const AST_HTML_ATTRIBUTE_NAME_NODE_T *) node);
|
|
88
88
|
|
|
89
89
|
if (html_attribute_name_node->children != NULL) {
|
|
90
|
-
for (size_t index = 0; index < html_attribute_name_node->children
|
|
90
|
+
for (size_t index = 0; index < hb_array_size(html_attribute_name_node->children); index++) {
|
|
91
91
|
herb_visit_node(hb_array_get(html_attribute_name_node->children, index), visitor, data);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -111,7 +111,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
111
111
|
const AST_HTML_COMMENT_NODE_T* html_comment_node = ((const AST_HTML_COMMENT_NODE_T *) node);
|
|
112
112
|
|
|
113
113
|
if (html_comment_node->children != NULL) {
|
|
114
|
-
for (size_t index = 0; index < html_comment_node->children
|
|
114
|
+
for (size_t index = 0; index < hb_array_size(html_comment_node->children); index++) {
|
|
115
115
|
herb_visit_node(hb_array_get(html_comment_node->children, index), visitor, data);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
@@ -122,7 +122,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
122
122
|
const AST_HTML_DOCTYPE_NODE_T* html_doctype_node = ((const AST_HTML_DOCTYPE_NODE_T *) node);
|
|
123
123
|
|
|
124
124
|
if (html_doctype_node->children != NULL) {
|
|
125
|
-
for (size_t index = 0; index < html_doctype_node->children
|
|
125
|
+
for (size_t index = 0; index < hb_array_size(html_doctype_node->children); index++) {
|
|
126
126
|
herb_visit_node(hb_array_get(html_doctype_node->children, index), visitor, data);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -133,7 +133,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
133
133
|
const AST_XML_DECLARATION_NODE_T* xml_declaration_node = ((const AST_XML_DECLARATION_NODE_T *) node);
|
|
134
134
|
|
|
135
135
|
if (xml_declaration_node->children != NULL) {
|
|
136
|
-
for (size_t index = 0; index < xml_declaration_node->children
|
|
136
|
+
for (size_t index = 0; index < hb_array_size(xml_declaration_node->children); index++) {
|
|
137
137
|
herb_visit_node(hb_array_get(xml_declaration_node->children, index), visitor, data);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -144,7 +144,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
144
144
|
const AST_CDATA_NODE_T* cdata_node = ((const AST_CDATA_NODE_T *) node);
|
|
145
145
|
|
|
146
146
|
if (cdata_node->children != NULL) {
|
|
147
|
-
for (size_t index = 0; index < cdata_node->children
|
|
147
|
+
for (size_t index = 0; index < hb_array_size(cdata_node->children); index++) {
|
|
148
148
|
herb_visit_node(hb_array_get(cdata_node->children, index), visitor, data);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -155,7 +155,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
155
155
|
const AST_ERB_ELSE_NODE_T* erb_else_node = ((const AST_ERB_ELSE_NODE_T *) node);
|
|
156
156
|
|
|
157
157
|
if (erb_else_node->statements != NULL) {
|
|
158
|
-
for (size_t index = 0; index < erb_else_node->statements
|
|
158
|
+
for (size_t index = 0; index < hb_array_size(erb_else_node->statements); index++) {
|
|
159
159
|
herb_visit_node(hb_array_get(erb_else_node->statements, index), visitor, data);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
@@ -166,7 +166,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
166
166
|
const AST_ERB_IF_NODE_T* erb_if_node = ((const AST_ERB_IF_NODE_T *) node);
|
|
167
167
|
|
|
168
168
|
if (erb_if_node->statements != NULL) {
|
|
169
|
-
for (size_t index = 0; index < erb_if_node->statements
|
|
169
|
+
for (size_t index = 0; index < hb_array_size(erb_if_node->statements); index++) {
|
|
170
170
|
herb_visit_node(hb_array_get(erb_if_node->statements, index), visitor, data);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -185,7 +185,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
185
185
|
const AST_ERB_BLOCK_NODE_T* erb_block_node = ((const AST_ERB_BLOCK_NODE_T *) node);
|
|
186
186
|
|
|
187
187
|
if (erb_block_node->body != NULL) {
|
|
188
|
-
for (size_t index = 0; index < erb_block_node->body
|
|
188
|
+
for (size_t index = 0; index < hb_array_size(erb_block_node->body); index++) {
|
|
189
189
|
herb_visit_node(hb_array_get(erb_block_node->body, index), visitor, data);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
@@ -200,7 +200,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
200
200
|
const AST_ERB_WHEN_NODE_T* erb_when_node = ((const AST_ERB_WHEN_NODE_T *) node);
|
|
201
201
|
|
|
202
202
|
if (erb_when_node->statements != NULL) {
|
|
203
|
-
for (size_t index = 0; index < erb_when_node->statements
|
|
203
|
+
for (size_t index = 0; index < hb_array_size(erb_when_node->statements); index++) {
|
|
204
204
|
herb_visit_node(hb_array_get(erb_when_node->statements, index), visitor, data);
|
|
205
205
|
}
|
|
206
206
|
}
|
|
@@ -211,13 +211,13 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
211
211
|
const AST_ERB_CASE_NODE_T* erb_case_node = ((const AST_ERB_CASE_NODE_T *) node);
|
|
212
212
|
|
|
213
213
|
if (erb_case_node->children != NULL) {
|
|
214
|
-
for (size_t index = 0; index < erb_case_node->children
|
|
214
|
+
for (size_t index = 0; index < hb_array_size(erb_case_node->children); index++) {
|
|
215
215
|
herb_visit_node(hb_array_get(erb_case_node->children, index), visitor, data);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
if (erb_case_node->conditions != NULL) {
|
|
220
|
-
for (size_t index = 0; index < erb_case_node->conditions
|
|
220
|
+
for (size_t index = 0; index < hb_array_size(erb_case_node->conditions); index++) {
|
|
221
221
|
herb_visit_node(hb_array_get(erb_case_node->conditions, index), visitor, data);
|
|
222
222
|
}
|
|
223
223
|
}
|
|
@@ -236,13 +236,13 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
236
236
|
const AST_ERB_CASE_MATCH_NODE_T* erb_case_match_node = ((const AST_ERB_CASE_MATCH_NODE_T *) node);
|
|
237
237
|
|
|
238
238
|
if (erb_case_match_node->children != NULL) {
|
|
239
|
-
for (size_t index = 0; index < erb_case_match_node->children
|
|
239
|
+
for (size_t index = 0; index < hb_array_size(erb_case_match_node->children); index++) {
|
|
240
240
|
herb_visit_node(hb_array_get(erb_case_match_node->children, index), visitor, data);
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
if (erb_case_match_node->conditions != NULL) {
|
|
245
|
-
for (size_t index = 0; index < erb_case_match_node->conditions
|
|
245
|
+
for (size_t index = 0; index < hb_array_size(erb_case_match_node->conditions); index++) {
|
|
246
246
|
herb_visit_node(hb_array_get(erb_case_match_node->conditions, index), visitor, data);
|
|
247
247
|
}
|
|
248
248
|
}
|
|
@@ -261,7 +261,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
261
261
|
const AST_ERB_WHILE_NODE_T* erb_while_node = ((const AST_ERB_WHILE_NODE_T *) node);
|
|
262
262
|
|
|
263
263
|
if (erb_while_node->statements != NULL) {
|
|
264
|
-
for (size_t index = 0; index < erb_while_node->statements
|
|
264
|
+
for (size_t index = 0; index < hb_array_size(erb_while_node->statements); index++) {
|
|
265
265
|
herb_visit_node(hb_array_get(erb_while_node->statements, index), visitor, data);
|
|
266
266
|
}
|
|
267
267
|
}
|
|
@@ -276,7 +276,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
276
276
|
const AST_ERB_UNTIL_NODE_T* erb_until_node = ((const AST_ERB_UNTIL_NODE_T *) node);
|
|
277
277
|
|
|
278
278
|
if (erb_until_node->statements != NULL) {
|
|
279
|
-
for (size_t index = 0; index < erb_until_node->statements
|
|
279
|
+
for (size_t index = 0; index < hb_array_size(erb_until_node->statements); index++) {
|
|
280
280
|
herb_visit_node(hb_array_get(erb_until_node->statements, index), visitor, data);
|
|
281
281
|
}
|
|
282
282
|
}
|
|
@@ -291,7 +291,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
291
291
|
const AST_ERB_FOR_NODE_T* erb_for_node = ((const AST_ERB_FOR_NODE_T *) node);
|
|
292
292
|
|
|
293
293
|
if (erb_for_node->statements != NULL) {
|
|
294
|
-
for (size_t index = 0; index < erb_for_node->statements
|
|
294
|
+
for (size_t index = 0; index < hb_array_size(erb_for_node->statements); index++) {
|
|
295
295
|
herb_visit_node(hb_array_get(erb_for_node->statements, index), visitor, data);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
@@ -306,7 +306,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
306
306
|
const AST_ERB_RESCUE_NODE_T* erb_rescue_node = ((const AST_ERB_RESCUE_NODE_T *) node);
|
|
307
307
|
|
|
308
308
|
if (erb_rescue_node->statements != NULL) {
|
|
309
|
-
for (size_t index = 0; index < erb_rescue_node->statements
|
|
309
|
+
for (size_t index = 0; index < hb_array_size(erb_rescue_node->statements); index++) {
|
|
310
310
|
herb_visit_node(hb_array_get(erb_rescue_node->statements, index), visitor, data);
|
|
311
311
|
}
|
|
312
312
|
}
|
|
@@ -321,7 +321,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
321
321
|
const AST_ERB_ENSURE_NODE_T* erb_ensure_node = ((const AST_ERB_ENSURE_NODE_T *) node);
|
|
322
322
|
|
|
323
323
|
if (erb_ensure_node->statements != NULL) {
|
|
324
|
-
for (size_t index = 0; index < erb_ensure_node->statements
|
|
324
|
+
for (size_t index = 0; index < hb_array_size(erb_ensure_node->statements); index++) {
|
|
325
325
|
herb_visit_node(hb_array_get(erb_ensure_node->statements, index), visitor, data);
|
|
326
326
|
}
|
|
327
327
|
}
|
|
@@ -332,7 +332,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
332
332
|
const AST_ERB_BEGIN_NODE_T* erb_begin_node = ((const AST_ERB_BEGIN_NODE_T *) node);
|
|
333
333
|
|
|
334
334
|
if (erb_begin_node->statements != NULL) {
|
|
335
|
-
for (size_t index = 0; index < erb_begin_node->statements
|
|
335
|
+
for (size_t index = 0; index < hb_array_size(erb_begin_node->statements); index++) {
|
|
336
336
|
herb_visit_node(hb_array_get(erb_begin_node->statements, index), visitor, data);
|
|
337
337
|
}
|
|
338
338
|
}
|
|
@@ -359,7 +359,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
359
359
|
const AST_ERB_UNLESS_NODE_T* erb_unless_node = ((const AST_ERB_UNLESS_NODE_T *) node);
|
|
360
360
|
|
|
361
361
|
if (erb_unless_node->statements != NULL) {
|
|
362
|
-
for (size_t index = 0; index < erb_unless_node->statements
|
|
362
|
+
for (size_t index = 0; index < hb_array_size(erb_unless_node->statements); index++) {
|
|
363
363
|
herb_visit_node(hb_array_get(erb_unless_node->statements, index), visitor, data);
|
|
364
364
|
}
|
|
365
365
|
}
|
|
@@ -378,7 +378,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
378
378
|
const AST_ERB_IN_NODE_T* erb_in_node = ((const AST_ERB_IN_NODE_T *) node);
|
|
379
379
|
|
|
380
380
|
if (erb_in_node->statements != NULL) {
|
|
381
|
-
for (size_t index = 0; index < erb_in_node->statements
|
|
381
|
+
for (size_t index = 0; index < hb_array_size(erb_in_node->statements); index++) {
|
|
382
382
|
herb_visit_node(hb_array_get(erb_in_node->statements, index), visitor, data);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
@@ -71,7 +71,7 @@ VALUE rb_errors_array_from_c_array(hb_array_T* array) {
|
|
|
71
71
|
VALUE rb_array = rb_ary_new();
|
|
72
72
|
|
|
73
73
|
if (array) {
|
|
74
|
-
for (size_t i = 0; i < array
|
|
74
|
+
for (size_t i = 0; i < hb_array_size(array); i++) {
|
|
75
75
|
ERROR_T* child_node = (ERROR_T*) hb_array_get(array, i);
|
|
76
76
|
|
|
77
77
|
if (child_node) {
|
|
@@ -81,7 +81,7 @@ static VALUE rb_nodes_array_from_c_array(hb_array_T* array) {
|
|
|
81
81
|
VALUE rb_array = rb_ary_new();
|
|
82
82
|
|
|
83
83
|
if (array) {
|
|
84
|
-
for (size_t i = 0; i < array
|
|
84
|
+
for (size_t i = 0; i < hb_array_size(array); i++) {
|
|
85
85
|
AST_NODE_T* child_node = (AST_NODE_T*) hb_array_get(array, i);
|
|
86
86
|
|
|
87
87
|
if (child_node) {
|
|
@@ -46,7 +46,7 @@ jobject ErrorsArrayFromCArray(JNIEnv* env, hb_array_T* array) {
|
|
|
46
46
|
jobject javaList = (*env)->NewObject(env, arrayListClass, arrayListConstructor, 0);
|
|
47
47
|
|
|
48
48
|
if (array) {
|
|
49
|
-
for (size_t i = 0; i < array
|
|
49
|
+
for (size_t i = 0; i < hb_array_size(array); i++) {
|
|
50
50
|
ERROR_T* error = (ERROR_T*) hb_array_get(array, i);
|
|
51
51
|
|
|
52
52
|
if (error) {
|
data/templates/java/nodes.c.erb
CHANGED
|
@@ -75,9 +75,9 @@ jobject NodesArrayFromCArray(JNIEnv* env, hb_array_T* array) {
|
|
|
75
75
|
return (*env)->NewObject(env, arrayListClass, arrayListConstructor, 0);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
jobject javaList = (*env)->NewObject(env, arrayListClass, arrayListConstructor, (jint) array
|
|
78
|
+
jobject javaList = (*env)->NewObject(env, arrayListClass, arrayListConstructor, (jint) hb_array_size(array));
|
|
79
79
|
|
|
80
|
-
for (size_t i = 0; i < array
|
|
80
|
+
for (size_t i = 0; i < hb_array_size(array); i++) {
|
|
81
81
|
AST_NODE_T* child_node = (AST_NODE_T*) hb_array_get(array, i);
|
|
82
82
|
|
|
83
83
|
if (child_node) {
|
|
@@ -80,7 +80,7 @@ napi_value ErrorsArrayFromCArray(napi_env env, hb_array_T* array) {
|
|
|
80
80
|
napi_create_array(env, &result);
|
|
81
81
|
|
|
82
82
|
if (array) {
|
|
83
|
-
for (size_t i = 0; i < array
|
|
83
|
+
for (size_t i = 0; i < hb_array_size(array); i++) {
|
|
84
84
|
ERROR_T* error = (ERROR_T*) hb_array_get(array, i);
|
|
85
85
|
if (error) {
|
|
86
86
|
napi_value js_error = ErrorFromCStruct(env, error);
|
|
@@ -78,7 +78,7 @@ napi_value NodesArrayFromCArray(napi_env env, hb_array_T* array) {
|
|
|
78
78
|
napi_create_array(env, &result);
|
|
79
79
|
|
|
80
80
|
if (array) {
|
|
81
|
-
for (size_t i = 0; i < array
|
|
81
|
+
for (size_t i = 0; i < hb_array_size(array); i++) {
|
|
82
82
|
AST_NODE_T* child_node = (AST_NODE_T*) hb_array_get(array, i);
|
|
83
83
|
if (child_node) {
|
|
84
84
|
napi_value js_child = NodeFromCStruct(env, child_node);
|
|
@@ -51,7 +51,7 @@ unsafe fn convert_errors(errors_array: *mut hb_array_T) -> Vec<AnyError> {
|
|
|
51
51
|
return Vec::new();
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
let count = (
|
|
54
|
+
let count = hb_array_size(errors_array);
|
|
55
55
|
let mut errors = Vec::with_capacity(count);
|
|
56
56
|
|
|
57
57
|
for index in 0..count {
|
|
@@ -110,7 +110,7 @@ unsafe fn convert_children(children_array: *mut hb_array_T) -> Vec<AnyNode> {
|
|
|
110
110
|
return Vec::new();
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
let count = (
|
|
113
|
+
let count = hb_array_size(children_array);
|
|
114
114
|
let mut children = Vec::with_capacity(count);
|
|
115
115
|
|
|
116
116
|
for index in 0..count {
|
|
@@ -27,11 +27,7 @@
|
|
|
27
27
|
<%- when Herb::Template::NodeField -%>
|
|
28
28
|
<%= node.human %>-><%= field.name %> = <%= field.name %>;
|
|
29
29
|
<%- when Herb::Template::ArrayField -%>
|
|
30
|
-
|
|
31
|
-
<%= node.human %>-><%= field.name %> = hb_array_init(8);
|
|
32
|
-
} else {
|
|
33
|
-
<%= node.human %>-><%= field.name %> = <%= field.name %>;
|
|
34
|
-
}
|
|
30
|
+
<%= node.human %>-><%= field.name %> = <%= field.name %>;
|
|
35
31
|
<%- when Herb::Template::BooleanField -%>
|
|
36
32
|
<%= node.human %>-><%= field.name %> = <%= field.name %>;
|
|
37
33
|
<%- when Herb::Template::ElementSourceField -%>
|
|
@@ -77,7 +73,7 @@ void ast_free_base_node(AST_NODE_T* node) {
|
|
|
77
73
|
if (node == NULL) { return; }
|
|
78
74
|
|
|
79
75
|
if (node->errors) {
|
|
80
|
-
for (size_t i = 0; i < node->errors
|
|
76
|
+
for (size_t i = 0; i < hb_array_size(node->errors); i++) {
|
|
81
77
|
ERROR_T* child = hb_array_get(node->errors, i);
|
|
82
78
|
if (child != NULL) { error_free(child); }
|
|
83
79
|
}
|
|
@@ -103,7 +99,7 @@ static void ast_free_<%= node.human %>(<%= node.struct_type %>* <%= node.human %
|
|
|
103
99
|
ast_node_free((AST_NODE_T*) <%= node.human %>-><%= field.name %>);
|
|
104
100
|
<%- when Herb::Template::ArrayField -%>
|
|
105
101
|
if (<%= node.human %>-><%= field.name %> != NULL) {
|
|
106
|
-
for (size_t i = 0; i < <%= node.human %>-><%= field.name
|
|
102
|
+
for (size_t i = 0; i < hb_array_size(<%= node.human %>-><%= field.name %>); i++) {
|
|
107
103
|
AST_NODE_T* child = hb_array_get(<%= node.human %>-><%= field.name %>, i);
|
|
108
104
|
if (child) { ast_node_free(child); }
|
|
109
105
|
}
|
data/templates/src/errors.c.erb
CHANGED
|
@@ -167,7 +167,7 @@ void error_pretty_print_array(
|
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
if (array
|
|
170
|
+
if (hb_array_size(array) == 0) {
|
|
171
171
|
pretty_print_property(hb_string(name), hb_string("[]"), indent, relative_indent, last_property, buffer);
|
|
172
172
|
|
|
173
173
|
return;
|
|
@@ -178,17 +178,17 @@ void error_pretty_print_array(
|
|
|
178
178
|
hb_buffer_append(buffer, "(");
|
|
179
179
|
|
|
180
180
|
char count[16];
|
|
181
|
-
sprintf(count, "%zu", array
|
|
181
|
+
sprintf(count, "%zu", hb_array_size(array));
|
|
182
182
|
hb_buffer_append(buffer, count);
|
|
183
183
|
hb_buffer_append(buffer, ")\n");
|
|
184
184
|
|
|
185
185
|
if (indent < 20) {
|
|
186
|
-
for (size_t i = 0; i < array
|
|
186
|
+
for (size_t i = 0; i < hb_array_size(array); i++) {
|
|
187
187
|
ERROR_T* child = hb_array_get(array, i);
|
|
188
188
|
pretty_print_indent(buffer, indent);
|
|
189
189
|
pretty_print_indent(buffer, relative_indent + 1);
|
|
190
190
|
|
|
191
|
-
if (i == array
|
|
191
|
+
if (i == hb_array_size(array) - 1) {
|
|
192
192
|
hb_buffer_append(buffer, "└── ");
|
|
193
193
|
} else {
|
|
194
194
|
hb_buffer_append(buffer, "├── ");
|
|
@@ -196,7 +196,7 @@ void error_pretty_print_array(
|
|
|
196
196
|
|
|
197
197
|
error_pretty_print(child, indent + 1, relative_indent + 1, buffer);
|
|
198
198
|
|
|
199
|
-
if (i != array
|
|
199
|
+
if (i != hb_array_size(array) - 1) { pretty_print_newline(indent + 1, relative_indent, buffer); }
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
}
|
data/templates/src/visitor.c.erb
CHANGED
|
@@ -31,7 +31,7 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
31
31
|
|
|
32
32
|
<%- when Herb::Template::ArrayField -%>
|
|
33
33
|
if (<%= node.human %>-><%= field.name %> != NULL) {
|
|
34
|
-
for (size_t index = 0; index < <%= node.human %>-><%= field.name
|
|
34
|
+
for (size_t index = 0; index < hb_array_size(<%= node.human %>-><%= field.name %>); index++) {
|
|
35
35
|
herb_visit_node(hb_array_get(<%= node.human %>-><%= field.name %>, index), visitor, data);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -66,7 +66,7 @@ val ErrorsArrayFromCArray(hb_array_T* array) {
|
|
|
66
66
|
val result = Array.new_();
|
|
67
67
|
|
|
68
68
|
if (array) {
|
|
69
|
-
for (size_t i = 0; i < array
|
|
69
|
+
for (size_t i = 0; i < hb_array_size(array); i++) {
|
|
70
70
|
ERROR_T* error = (ERROR_T*)hb_array_get(array, i);
|
|
71
71
|
if (error) {
|
|
72
72
|
result.call<void>("push", ErrorFromCStruct(error));
|
|
@@ -67,7 +67,7 @@ val NodesArrayFromCArray(hb_array_T* array) {
|
|
|
67
67
|
|
|
68
68
|
val jsArray = val::array();
|
|
69
69
|
|
|
70
|
-
for (size_t i = 0; i < array
|
|
70
|
+
for (size_t i = 0; i < hb_array_size(array); i++) {
|
|
71
71
|
AST_NODE_T* child_node = (AST_NODE_T*) hb_array_get(array, i);
|
|
72
72
|
|
|
73
73
|
if (child_node) {
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: herb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marco Roth
|
|
@@ -323,7 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
323
323
|
- !ruby/object:Gem::Version
|
|
324
324
|
version: '0'
|
|
325
325
|
requirements: []
|
|
326
|
-
rubygems_version:
|
|
326
|
+
rubygems_version: 4.0.3
|
|
327
327
|
specification_version: 4
|
|
328
328
|
summary: Powerful and seamless HTML-aware ERB parsing and tooling.
|
|
329
329
|
test_files: []
|