herb 0.8.3-x86_64-linux-musl → 0.8.4-x86_64-linux-musl
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/3.0/herb.so +0 -0
- data/lib/herb/3.1/herb.so +0 -0
- data/lib/herb/3.2/herb.so +0 -0
- data/lib/herb/3.3/herb.so +0 -0
- data/lib/herb/3.4/herb.so +0 -0
- data/lib/herb/engine/debug_visitor.rb +24 -1
- data/lib/herb/version.rb +1 -1
- data/sig/herb/engine/debug_visitor.rbs +5 -0
- data/src/analyze.c +27 -27
- data/src/ast_node.c +1 -1
- data/src/ast_nodes.c +157 -53
- data/src/errors.c +5 -5
- data/src/extract.c +2 -2
- data/src/herb.c +2 -2
- data/src/include/version.h +1 -1
- data/src/parser.c +6 -6
- data/src/parser_helpers.c +4 -4
- data/src/pretty_print.c +6 -6
- 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 +7 -3
- 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 +1 -1
data/src/parser.c
CHANGED
|
@@ -1142,7 +1142,7 @@ static void parser_parse_in_data_state(parser_T* parser, hb_array_T* children, h
|
|
|
1142
1142
|
static size_t find_matching_close_tag(hb_array_T* nodes, size_t start_idx, hb_string_T tag_name) {
|
|
1143
1143
|
int depth = 0;
|
|
1144
1144
|
|
|
1145
|
-
for (size_t i = start_idx + 1; i <
|
|
1145
|
+
for (size_t i = start_idx + 1; i < nodes->size; i++) {
|
|
1146
1146
|
AST_NODE_T* node = (AST_NODE_T*) hb_array_get(nodes, i);
|
|
1147
1147
|
if (node == NULL) { continue; }
|
|
1148
1148
|
|
|
@@ -1166,9 +1166,9 @@ static size_t find_matching_close_tag(hb_array_T* nodes, size_t start_idx, hb_st
|
|
|
1166
1166
|
static hb_array_T* parser_build_elements_from_tags(hb_array_T* nodes, hb_array_T* errors);
|
|
1167
1167
|
|
|
1168
1168
|
static hb_array_T* parser_build_elements_from_tags(hb_array_T* nodes, hb_array_T* errors) {
|
|
1169
|
-
hb_array_T* result = hb_array_init(
|
|
1169
|
+
hb_array_T* result = hb_array_init(nodes->size);
|
|
1170
1170
|
|
|
1171
|
-
for (size_t index = 0; index <
|
|
1171
|
+
for (size_t index = 0; index < nodes->size; index++) {
|
|
1172
1172
|
AST_NODE_T* node = (AST_NODE_T*) hb_array_get(nodes, index);
|
|
1173
1173
|
if (node == NULL) { continue; }
|
|
1174
1174
|
|
|
@@ -1179,7 +1179,7 @@ static hb_array_T* parser_build_elements_from_tags(hb_array_T* nodes, hb_array_T
|
|
|
1179
1179
|
size_t close_index = find_matching_close_tag(nodes, index, tag_name);
|
|
1180
1180
|
|
|
1181
1181
|
if (close_index == (size_t) -1) {
|
|
1182
|
-
if (
|
|
1182
|
+
if (open_tag->base.errors->size == 0) {
|
|
1183
1183
|
append_missing_closing_tag_error(
|
|
1184
1184
|
open_tag->tag_name,
|
|
1185
1185
|
open_tag->base.location.start,
|
|
@@ -1223,7 +1223,7 @@ static hb_array_T* parser_build_elements_from_tags(hb_array_T* nodes, hb_array_T
|
|
|
1223
1223
|
AST_HTML_CLOSE_TAG_NODE_T* close_tag = (AST_HTML_CLOSE_TAG_NODE_T*) node;
|
|
1224
1224
|
|
|
1225
1225
|
if (!is_void_element(hb_string(close_tag->tag_name->value))) {
|
|
1226
|
-
if (
|
|
1226
|
+
if (close_tag->base.errors->size == 0) {
|
|
1227
1227
|
append_missing_opening_tag_error(
|
|
1228
1228
|
close_tag->tag_name,
|
|
1229
1229
|
close_tag->base.location.start,
|
|
@@ -1297,7 +1297,7 @@ void herb_parser_deinit(parser_T* parser) {
|
|
|
1297
1297
|
}
|
|
1298
1298
|
|
|
1299
1299
|
void match_tags_in_node_array(hb_array_T* nodes, hb_array_T* errors) {
|
|
1300
|
-
if (nodes == NULL ||
|
|
1300
|
+
if (nodes == NULL || nodes->size == 0) { return; }
|
|
1301
1301
|
|
|
1302
1302
|
hb_array_T* processed = parser_build_elements_from_tags(nodes, errors);
|
|
1303
1303
|
|
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 (
|
|
22
|
+
if (parser->open_tags_stack->size == 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 (
|
|
31
|
+
if (parser->open_tags_stack->size == 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 =
|
|
45
|
+
size_t stack_size = parser->open_tags_stack->size;
|
|
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 (
|
|
194
|
+
if (parser->open_tags_stack->size > 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 (
|
|
116
|
+
if (array->size == 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",
|
|
127
|
+
sprintf(count, "%zu", array->size);
|
|
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 <
|
|
132
|
+
for (size_t i = 0; i < array->size; 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 ==
|
|
137
|
+
if (i == array->size - 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 !=
|
|
145
|
+
if (i != array->size - 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 != NULL &&
|
|
158
|
+
if (node->errors != NULL && node->errors->size > 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/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 <
|
|
27
|
+
for (size_t index = 0; index < document_node->children->size; 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 <
|
|
38
|
+
for (size_t index = 0; index < html_open_tag_node->children->size; 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 <
|
|
49
|
+
for (size_t index = 0; index < html_close_tag_node->children->size; 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 <
|
|
64
|
+
for (size_t index = 0; index < html_element_node->body->size; 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 <
|
|
79
|
+
for (size_t index = 0; index < html_attribute_value_node->children->size; 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 <
|
|
90
|
+
for (size_t index = 0; index < html_attribute_name_node->children->size; 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 <
|
|
114
|
+
for (size_t index = 0; index < html_comment_node->children->size; 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 <
|
|
125
|
+
for (size_t index = 0; index < html_doctype_node->children->size; 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 <
|
|
136
|
+
for (size_t index = 0; index < xml_declaration_node->children->size; 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 <
|
|
147
|
+
for (size_t index = 0; index < cdata_node->children->size; 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 <
|
|
158
|
+
for (size_t index = 0; index < erb_else_node->statements->size; 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 <
|
|
169
|
+
for (size_t index = 0; index < erb_if_node->statements->size; 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 <
|
|
188
|
+
for (size_t index = 0; index < erb_block_node->body->size; 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 <
|
|
203
|
+
for (size_t index = 0; index < erb_when_node->statements->size; 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 <
|
|
214
|
+
for (size_t index = 0; index < erb_case_node->children->size; 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 <
|
|
220
|
+
for (size_t index = 0; index < erb_case_node->conditions->size; 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 <
|
|
239
|
+
for (size_t index = 0; index < erb_case_match_node->children->size; 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 <
|
|
245
|
+
for (size_t index = 0; index < erb_case_match_node->conditions->size; 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 <
|
|
264
|
+
for (size_t index = 0; index < erb_while_node->statements->size; 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 <
|
|
279
|
+
for (size_t index = 0; index < erb_until_node->statements->size; 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 <
|
|
294
|
+
for (size_t index = 0; index < erb_for_node->statements->size; 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 <
|
|
309
|
+
for (size_t index = 0; index < erb_rescue_node->statements->size; 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 <
|
|
324
|
+
for (size_t index = 0; index < erb_ensure_node->statements->size; 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 <
|
|
335
|
+
for (size_t index = 0; index < erb_begin_node->statements->size; 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 <
|
|
362
|
+
for (size_t index = 0; index < erb_unless_node->statements->size; 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 <
|
|
381
|
+
for (size_t index = 0; index < erb_in_node->statements->size; 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 <
|
|
74
|
+
for (size_t i = 0; i < array->size; 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 <
|
|
84
|
+
for (size_t i = 0; i < array->size; 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 <
|
|
49
|
+
for (size_t i = 0; i < array->size; 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)
|
|
78
|
+
jobject javaList = (*env)->NewObject(env, arrayListClass, arrayListConstructor, (jint) array->size);
|
|
79
79
|
|
|
80
|
-
for (size_t i = 0; i <
|
|
80
|
+
for (size_t i = 0; i < array->size; 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 <
|
|
83
|
+
for (size_t i = 0; i < array->size; 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 <
|
|
81
|
+
for (size_t i = 0; i < array->size; 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 = (*errors_array).size;
|
|
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 = (*children_array).size;
|
|
114
114
|
let mut children = Vec::with_capacity(count);
|
|
115
115
|
|
|
116
116
|
for index in 0..count {
|
|
@@ -27,7 +27,11 @@
|
|
|
27
27
|
<%- when Herb::Template::NodeField -%>
|
|
28
28
|
<%= node.human %>-><%= field.name %> = <%= field.name %>;
|
|
29
29
|
<%- when Herb::Template::ArrayField -%>
|
|
30
|
-
<%=
|
|
30
|
+
if (<%= field.name %> == NULL) {
|
|
31
|
+
<%= node.human %>-><%= field.name %> = hb_array_init(8);
|
|
32
|
+
} else {
|
|
33
|
+
<%= node.human %>-><%= field.name %> = <%= field.name %>;
|
|
34
|
+
}
|
|
31
35
|
<%- when Herb::Template::BooleanField -%>
|
|
32
36
|
<%= node.human %>-><%= field.name %> = <%= field.name %>;
|
|
33
37
|
<%- when Herb::Template::ElementSourceField -%>
|
|
@@ -73,7 +77,7 @@ void ast_free_base_node(AST_NODE_T* node) {
|
|
|
73
77
|
if (node == NULL) { return; }
|
|
74
78
|
|
|
75
79
|
if (node->errors) {
|
|
76
|
-
for (size_t i = 0; i <
|
|
80
|
+
for (size_t i = 0; i < node->errors->size; i++) {
|
|
77
81
|
ERROR_T* child = hb_array_get(node->errors, i);
|
|
78
82
|
if (child != NULL) { error_free(child); }
|
|
79
83
|
}
|
|
@@ -99,7 +103,7 @@ static void ast_free_<%= node.human %>(<%= node.struct_type %>* <%= node.human %
|
|
|
99
103
|
ast_node_free((AST_NODE_T*) <%= node.human %>-><%= field.name %>);
|
|
100
104
|
<%- when Herb::Template::ArrayField -%>
|
|
101
105
|
if (<%= node.human %>-><%= field.name %> != NULL) {
|
|
102
|
-
for (size_t i = 0; i <
|
|
106
|
+
for (size_t i = 0; i < <%= node.human %>-><%= field.name %>->size; i++) {
|
|
103
107
|
AST_NODE_T* child = hb_array_get(<%= node.human %>-><%= field.name %>, i);
|
|
104
108
|
if (child) { ast_node_free(child); }
|
|
105
109
|
}
|
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 (
|
|
170
|
+
if (array->size == 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",
|
|
181
|
+
sprintf(count, "%zu", array->size);
|
|
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 <
|
|
186
|
+
for (size_t i = 0; i < array->size; 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 ==
|
|
191
|
+
if (i == array->size - 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 !=
|
|
199
|
+
if (i != array->size - 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 <
|
|
34
|
+
for (size_t index = 0; index < <%= node.human %>-><%= field.name %>->size; 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 <
|
|
69
|
+
for (size_t i = 0; i < array->size; 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 <
|
|
70
|
+
for (size_t i = 0; i < array->size; i++) {
|
|
71
71
|
AST_NODE_T* child_node = (AST_NODE_T*) hb_array_get(array, i);
|
|
72
72
|
|
|
73
73
|
if (child_node) {
|