@herb-tools/node 0.7.5 → 0.8.0
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.
- package/binding.gyp +8 -4
- package/dist/herb-node.esm.js +6 -6
- package/dist/herb-node.esm.js.map +1 -1
- package/extension/error_helpers.cpp +67 -9
- package/extension/error_helpers.h +4 -2
- package/extension/extension_helpers.cpp +12 -5
- package/extension/extension_helpers.h +4 -2
- package/extension/herb.cpp +10 -42
- package/extension/libherb/analyze.c +420 -171
- package/extension/libherb/analyze.h +10 -2
- package/extension/libherb/analyze_helpers.c +5 -0
- package/extension/libherb/analyze_helpers.h +3 -0
- package/extension/libherb/analyze_missing_end.c +147 -0
- package/extension/libherb/analyze_transform.c +196 -0
- package/extension/libherb/analyzed_ruby.c +23 -2
- package/extension/libherb/analyzed_ruby.h +4 -2
- package/extension/libherb/ast_node.c +5 -5
- package/extension/libherb/ast_node.h +2 -2
- package/extension/libherb/ast_nodes.c +180 -180
- package/extension/libherb/ast_nodes.h +68 -67
- package/extension/libherb/ast_pretty_print.c +233 -233
- package/extension/libherb/ast_pretty_print.h +3 -3
- package/extension/libherb/element_source.c +7 -6
- package/extension/libherb/element_source.h +3 -1
- package/extension/libherb/errors.c +247 -127
- package/extension/libherb/errors.h +31 -15
- package/extension/libherb/extract.c +92 -34
- package/extension/libherb/extract.h +4 -4
- package/extension/libherb/herb.c +37 -49
- package/extension/libherb/herb.h +6 -7
- package/extension/libherb/html_util.c +34 -96
- package/extension/libherb/html_util.h +4 -5
- package/extension/libherb/include/analyze.h +10 -2
- package/extension/libherb/include/analyze_helpers.h +3 -0
- package/extension/libherb/include/analyzed_ruby.h +4 -2
- package/extension/libherb/include/ast_node.h +2 -2
- package/extension/libherb/include/ast_nodes.h +68 -67
- package/extension/libherb/include/ast_pretty_print.h +3 -3
- package/extension/libherb/include/element_source.h +3 -1
- package/extension/libherb/include/errors.h +31 -15
- package/extension/libherb/include/extract.h +4 -4
- package/extension/libherb/include/herb.h +6 -7
- package/extension/libherb/include/html_util.h +4 -5
- package/extension/libherb/include/lexer.h +1 -3
- package/extension/libherb/include/lexer_peek_helpers.h +14 -14
- package/extension/libherb/include/lexer_struct.h +3 -2
- package/extension/libherb/include/macros.h +4 -0
- package/extension/libherb/include/parser.h +12 -6
- package/extension/libherb/include/parser_helpers.h +25 -15
- package/extension/libherb/include/pretty_print.h +38 -28
- package/extension/libherb/include/token.h +5 -8
- package/extension/libherb/include/utf8.h +3 -2
- package/extension/libherb/include/util/hb_arena.h +31 -0
- package/extension/libherb/include/util/hb_arena_debug.h +8 -0
- package/extension/libherb/include/util/hb_array.h +33 -0
- package/extension/libherb/include/util/hb_buffer.h +34 -0
- package/extension/libherb/include/util/hb_string.h +29 -0
- package/extension/libherb/include/util/hb_system.h +9 -0
- package/extension/libherb/include/util.h +3 -14
- package/extension/libherb/include/version.h +1 -1
- package/extension/libherb/include/visitor.h +1 -1
- package/extension/libherb/io.c +7 -4
- package/extension/libherb/lexer.c +61 -88
- package/extension/libherb/lexer.h +1 -3
- package/extension/libherb/lexer_peek_helpers.c +35 -37
- package/extension/libherb/lexer_peek_helpers.h +14 -14
- package/extension/libherb/lexer_struct.h +3 -2
- package/extension/libherb/macros.h +4 -0
- package/extension/libherb/main.c +19 -23
- package/extension/libherb/parser.c +282 -201
- package/extension/libherb/parser.h +12 -6
- package/extension/libherb/parser_helpers.c +46 -40
- package/extension/libherb/parser_helpers.h +25 -15
- package/extension/libherb/parser_match_tags.c +316 -0
- package/extension/libherb/pretty_print.c +82 -106
- package/extension/libherb/pretty_print.h +38 -28
- package/extension/libherb/token.c +18 -65
- package/extension/libherb/token.h +5 -8
- package/extension/libherb/utf8.c +4 -4
- package/extension/libherb/utf8.h +3 -2
- package/extension/libherb/util/hb_arena.c +179 -0
- package/extension/libherb/util/hb_arena.h +31 -0
- package/extension/libherb/util/hb_arena_debug.c +237 -0
- package/extension/libherb/util/hb_arena_debug.h +8 -0
- package/extension/libherb/{array.c → util/hb_array.c} +26 -27
- package/extension/libherb/util/hb_array.h +33 -0
- package/extension/libherb/util/hb_buffer.c +203 -0
- package/extension/libherb/util/hb_buffer.h +34 -0
- package/extension/libherb/util/hb_string.c +85 -0
- package/extension/libherb/util/hb_string.h +29 -0
- package/extension/libherb/util/hb_system.c +30 -0
- package/extension/libherb/util/hb_system.h +9 -0
- package/extension/libherb/util.c +29 -99
- package/extension/libherb/util.h +3 -14
- package/extension/libherb/version.h +1 -1
- package/extension/libherb/visitor.c +55 -55
- package/extension/libherb/visitor.h +1 -1
- package/extension/nodes.cpp +40 -40
- package/extension/nodes.h +2 -2
- package/extension/prism/include/prism/ast.h +31 -1
- package/extension/prism/include/prism/diagnostic.h +1 -0
- package/extension/prism/include/prism/version.h +3 -3
- package/extension/prism/src/diagnostic.c +3 -1
- package/extension/prism/src/prism.c +130 -71
- package/extension/prism/src/util/pm_string.c +6 -8
- package/package.json +3 -3
- package/extension/libherb/array.h +0 -33
- package/extension/libherb/buffer.c +0 -241
- package/extension/libherb/buffer.h +0 -39
- package/extension/libherb/include/array.h +0 -33
- package/extension/libherb/include/buffer.h +0 -39
- package/extension/libherb/include/json.h +0 -28
- package/extension/libherb/include/memory.h +0 -12
- package/extension/libherb/json.c +0 -205
- package/extension/libherb/json.h +0 -28
- package/extension/libherb/memory.c +0 -53
- package/extension/libherb/memory.h +0 -12
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.0/templates/src/visitor.c.erb
|
|
3
3
|
|
|
4
4
|
#include <stdio.h>
|
|
5
5
|
|
|
6
|
-
#include "include/array.h"
|
|
7
|
-
#include "include/visitor.h"
|
|
8
6
|
#include "include/ast_node.h"
|
|
9
7
|
#include "include/ast_nodes.h"
|
|
8
|
+
#include "include/util/hb_array.h"
|
|
9
|
+
#include "include/visitor.h"
|
|
10
10
|
|
|
11
11
|
void herb_visit_node(const AST_NODE_T* node, bool (*visitor)(const AST_NODE_T*, void*), void* data) {
|
|
12
12
|
if (visitor(node, data) && node != NULL) {
|
|
@@ -24,8 +24,8 @@ 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 <
|
|
28
|
-
herb_visit_node(
|
|
27
|
+
for (size_t index = 0; index < hb_array_size(document_node->children); index++) {
|
|
28
|
+
herb_visit_node(hb_array_get(document_node->children, index), visitor, data);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -35,8 +35,8 @@ 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 <
|
|
39
|
-
herb_visit_node(
|
|
38
|
+
for (size_t index = 0; index < hb_array_size(html_open_tag_node->children); index++) {
|
|
39
|
+
herb_visit_node(hb_array_get(html_open_tag_node->children, index), visitor, data);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -46,8 +46,8 @@ 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 <
|
|
50
|
-
herb_visit_node(
|
|
49
|
+
for (size_t index = 0; index < hb_array_size(html_close_tag_node->children); index++) {
|
|
50
|
+
herb_visit_node(hb_array_get(html_close_tag_node->children, index), visitor, data);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -61,8 +61,8 @@ 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 <
|
|
65
|
-
herb_visit_node(
|
|
64
|
+
for (size_t index = 0; index < hb_array_size(html_element_node->body); index++) {
|
|
65
|
+
herb_visit_node(hb_array_get(html_element_node->body, index), visitor, data);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -76,8 +76,8 @@ 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 <
|
|
80
|
-
herb_visit_node(
|
|
79
|
+
for (size_t index = 0; index < hb_array_size(html_attribute_value_node->children); index++) {
|
|
80
|
+
herb_visit_node(hb_array_get(html_attribute_value_node->children, index), visitor, data);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -87,8 +87,8 @@ 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 <
|
|
91
|
-
herb_visit_node(
|
|
90
|
+
for (size_t index = 0; index < hb_array_size(html_attribute_name_node->children); index++) {
|
|
91
|
+
herb_visit_node(hb_array_get(html_attribute_name_node->children, index), visitor, data);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -111,8 +111,8 @@ 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 <
|
|
115
|
-
herb_visit_node(
|
|
114
|
+
for (size_t index = 0; index < hb_array_size(html_comment_node->children); index++) {
|
|
115
|
+
herb_visit_node(hb_array_get(html_comment_node->children, index), visitor, data);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
@@ -122,8 +122,8 @@ 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 <
|
|
126
|
-
herb_visit_node(
|
|
125
|
+
for (size_t index = 0; index < hb_array_size(html_doctype_node->children); index++) {
|
|
126
|
+
herb_visit_node(hb_array_get(html_doctype_node->children, index), visitor, data);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -133,8 +133,8 @@ 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 <
|
|
137
|
-
herb_visit_node(
|
|
136
|
+
for (size_t index = 0; index < hb_array_size(xml_declaration_node->children); index++) {
|
|
137
|
+
herb_visit_node(hb_array_get(xml_declaration_node->children, index), visitor, data);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
@@ -144,8 +144,8 @@ 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 <
|
|
148
|
-
herb_visit_node(
|
|
147
|
+
for (size_t index = 0; index < hb_array_size(cdata_node->children); index++) {
|
|
148
|
+
herb_visit_node(hb_array_get(cdata_node->children, index), visitor, data);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -155,8 +155,8 @@ 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 <
|
|
159
|
-
herb_visit_node(
|
|
158
|
+
for (size_t index = 0; index < hb_array_size(erb_else_node->statements); index++) {
|
|
159
|
+
herb_visit_node(hb_array_get(erb_else_node->statements, index), visitor, data);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
@@ -166,8 +166,8 @@ 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 <
|
|
170
|
-
herb_visit_node(
|
|
169
|
+
for (size_t index = 0; index < hb_array_size(erb_if_node->statements); index++) {
|
|
170
|
+
herb_visit_node(hb_array_get(erb_if_node->statements, index), visitor, data);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
@@ -185,8 +185,8 @@ 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 <
|
|
189
|
-
herb_visit_node(
|
|
188
|
+
for (size_t index = 0; index < hb_array_size(erb_block_node->body); index++) {
|
|
189
|
+
herb_visit_node(hb_array_get(erb_block_node->body, index), visitor, data);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
|
|
@@ -200,8 +200,8 @@ 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 <
|
|
204
|
-
herb_visit_node(
|
|
203
|
+
for (size_t index = 0; index < hb_array_size(erb_when_node->statements); index++) {
|
|
204
|
+
herb_visit_node(hb_array_get(erb_when_node->statements, index), visitor, data);
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
|
|
@@ -211,14 +211,14 @@ 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 <
|
|
215
|
-
herb_visit_node(
|
|
214
|
+
for (size_t index = 0; index < hb_array_size(erb_case_node->children); index++) {
|
|
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 <
|
|
221
|
-
herb_visit_node(
|
|
220
|
+
for (size_t index = 0; index < hb_array_size(erb_case_node->conditions); index++) {
|
|
221
|
+
herb_visit_node(hb_array_get(erb_case_node->conditions, index), visitor, data);
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
|
|
@@ -236,14 +236,14 @@ 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 <
|
|
240
|
-
herb_visit_node(
|
|
239
|
+
for (size_t index = 0; index < hb_array_size(erb_case_match_node->children); index++) {
|
|
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 <
|
|
246
|
-
herb_visit_node(
|
|
245
|
+
for (size_t index = 0; index < hb_array_size(erb_case_match_node->conditions); index++) {
|
|
246
|
+
herb_visit_node(hb_array_get(erb_case_match_node->conditions, index), visitor, data);
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
|
|
@@ -261,8 +261,8 @@ 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 <
|
|
265
|
-
herb_visit_node(
|
|
264
|
+
for (size_t index = 0; index < hb_array_size(erb_while_node->statements); index++) {
|
|
265
|
+
herb_visit_node(hb_array_get(erb_while_node->statements, index), visitor, data);
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
268
|
|
|
@@ -276,8 +276,8 @@ 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 <
|
|
280
|
-
herb_visit_node(
|
|
279
|
+
for (size_t index = 0; index < hb_array_size(erb_until_node->statements); index++) {
|
|
280
|
+
herb_visit_node(hb_array_get(erb_until_node->statements, index), visitor, data);
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
|
|
@@ -291,8 +291,8 @@ 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 <
|
|
295
|
-
herb_visit_node(
|
|
294
|
+
for (size_t index = 0; index < hb_array_size(erb_for_node->statements); index++) {
|
|
295
|
+
herb_visit_node(hb_array_get(erb_for_node->statements, index), visitor, data);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
|
|
@@ -306,8 +306,8 @@ 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 <
|
|
310
|
-
herb_visit_node(
|
|
309
|
+
for (size_t index = 0; index < hb_array_size(erb_rescue_node->statements); index++) {
|
|
310
|
+
herb_visit_node(hb_array_get(erb_rescue_node->statements, index), visitor, data);
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
|
|
@@ -321,8 +321,8 @@ 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 <
|
|
325
|
-
herb_visit_node(
|
|
324
|
+
for (size_t index = 0; index < hb_array_size(erb_ensure_node->statements); index++) {
|
|
325
|
+
herb_visit_node(hb_array_get(erb_ensure_node->statements, index), visitor, data);
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
|
|
@@ -332,8 +332,8 @@ 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 <
|
|
336
|
-
herb_visit_node(
|
|
335
|
+
for (size_t index = 0; index < hb_array_size(erb_begin_node->statements); index++) {
|
|
336
|
+
herb_visit_node(hb_array_get(erb_begin_node->statements, index), visitor, data);
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
|
|
@@ -359,8 +359,8 @@ 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 <
|
|
363
|
-
herb_visit_node(
|
|
362
|
+
for (size_t index = 0; index < hb_array_size(erb_unless_node->statements); index++) {
|
|
363
|
+
herb_visit_node(hb_array_get(erb_unless_node->statements, index), visitor, data);
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
|
|
@@ -378,8 +378,8 @@ 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 <
|
|
382
|
-
herb_visit_node(
|
|
381
|
+
for (size_t index = 0; index < hb_array_size(erb_in_node->statements); index++) {
|
|
382
|
+
herb_visit_node(hb_array_get(erb_in_node->statements, index), visitor, data);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#ifndef HERB_VISITOR_H
|
|
2
2
|
#define HERB_VISITOR_H
|
|
3
3
|
|
|
4
|
-
#include "array.h"
|
|
5
4
|
#include "ast_node.h"
|
|
6
5
|
#include "ast_nodes.h"
|
|
6
|
+
#include "util/hb_array.h"
|
|
7
7
|
|
|
8
8
|
void herb_visit_node(const AST_NODE_T* node, bool (*visitor)(const AST_NODE_T*, void*), void* data);
|
|
9
9
|
void herb_visit_child_nodes(const AST_NODE_T* node, bool (*visitor)(const AST_NODE_T* node, void* data), void* data);
|
package/extension/nodes.cpp
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.0/templates/javascript/packages/node/extension/nodes.cpp.erb
|
|
3
3
|
|
|
4
4
|
#include <node_api.h>
|
|
5
5
|
#include "error_helpers.h"
|
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
#include "nodes.h"
|
|
8
8
|
|
|
9
9
|
extern "C" {
|
|
10
|
-
#include "../extension/libherb/include/herb.h"
|
|
11
|
-
#include "../extension/libherb/include/token.h"
|
|
12
|
-
#include "../extension/libherb/include/array.h"
|
|
13
10
|
#include "../extension/libherb/include/ast_node.h"
|
|
14
11
|
#include "../extension/libherb/include/ast_nodes.h"
|
|
12
|
+
#include "../extension/libherb/include/herb.h"
|
|
13
|
+
#include "../extension/libherb/include/token.h"
|
|
14
|
+
#include "../extension/libherb/include/util/hb_array.h"
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
napi_value NodeFromCStruct(napi_env env, AST_NODE_T* node);
|
|
18
|
-
napi_value NodesArrayFromCArray(napi_env env,
|
|
18
|
+
napi_value NodesArrayFromCArray(napi_env env, hb_array_T* array);
|
|
19
19
|
|
|
20
20
|
napi_value document_nodeNodeFromCStruct(napi_env env, AST_DOCUMENT_NODE_T* document_node) {
|
|
21
21
|
if (!document_node) {
|
|
@@ -27,7 +27,7 @@ napi_value document_nodeNodeFromCStruct(napi_env env, AST_DOCUMENT_NODE_T* docum
|
|
|
27
27
|
napi_value result;
|
|
28
28
|
napi_create_object(env, &result);
|
|
29
29
|
|
|
30
|
-
napi_value type =
|
|
30
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&document_node->base));
|
|
31
31
|
napi_set_named_property(env, result, "type", type);
|
|
32
32
|
|
|
33
33
|
napi_value location = CreateLocation(env, document_node->base.location);
|
|
@@ -52,7 +52,7 @@ napi_value literal_nodeNodeFromCStruct(napi_env env, AST_LITERAL_NODE_T* literal
|
|
|
52
52
|
napi_value result;
|
|
53
53
|
napi_create_object(env, &result);
|
|
54
54
|
|
|
55
|
-
napi_value type =
|
|
55
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&literal_node->base));
|
|
56
56
|
napi_set_named_property(env, result, "type", type);
|
|
57
57
|
|
|
58
58
|
napi_value location = CreateLocation(env, literal_node->base.location);
|
|
@@ -77,7 +77,7 @@ napi_value html_open_tag_nodeNodeFromCStruct(napi_env env, AST_HTML_OPEN_TAG_NOD
|
|
|
77
77
|
napi_value result;
|
|
78
78
|
napi_create_object(env, &result);
|
|
79
79
|
|
|
80
|
-
napi_value type =
|
|
80
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&html_open_tag_node->base));
|
|
81
81
|
napi_set_named_property(env, result, "type", type);
|
|
82
82
|
|
|
83
83
|
napi_value location = CreateLocation(env, html_open_tag_node->base.location);
|
|
@@ -115,7 +115,7 @@ napi_value html_close_tag_nodeNodeFromCStruct(napi_env env, AST_HTML_CLOSE_TAG_N
|
|
|
115
115
|
napi_value result;
|
|
116
116
|
napi_create_object(env, &result);
|
|
117
117
|
|
|
118
|
-
napi_value type =
|
|
118
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&html_close_tag_node->base));
|
|
119
119
|
napi_set_named_property(env, result, "type", type);
|
|
120
120
|
|
|
121
121
|
napi_value location = CreateLocation(env, html_close_tag_node->base.location);
|
|
@@ -149,7 +149,7 @@ napi_value html_element_nodeNodeFromCStruct(napi_env env, AST_HTML_ELEMENT_NODE_
|
|
|
149
149
|
napi_value result;
|
|
150
150
|
napi_create_object(env, &result);
|
|
151
151
|
|
|
152
|
-
napi_value type =
|
|
152
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&html_element_node->base));
|
|
153
153
|
napi_set_named_property(env, result, "type", type);
|
|
154
154
|
|
|
155
155
|
napi_value location = CreateLocation(env, html_element_node->base.location);
|
|
@@ -174,7 +174,7 @@ napi_value html_element_nodeNodeFromCStruct(napi_env env, AST_HTML_ELEMENT_NODE_
|
|
|
174
174
|
napi_get_boolean(env, html_element_node->is_void, &is_void);
|
|
175
175
|
napi_set_named_property(env, result, "is_void", is_void);
|
|
176
176
|
|
|
177
|
-
napi_value source =
|
|
177
|
+
napi_value source = CreateStringFromHbString(env, element_source_to_string(html_element_node->source));
|
|
178
178
|
napi_set_named_property(env, result, "source", source);
|
|
179
179
|
|
|
180
180
|
|
|
@@ -190,7 +190,7 @@ napi_value html_attribute_value_nodeNodeFromCStruct(napi_env env, AST_HTML_ATTRI
|
|
|
190
190
|
napi_value result;
|
|
191
191
|
napi_create_object(env, &result);
|
|
192
192
|
|
|
193
|
-
napi_value type =
|
|
193
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&html_attribute_value_node->base));
|
|
194
194
|
napi_set_named_property(env, result, "type", type);
|
|
195
195
|
|
|
196
196
|
napi_value location = CreateLocation(env, html_attribute_value_node->base.location);
|
|
@@ -225,7 +225,7 @@ napi_value html_attribute_name_nodeNodeFromCStruct(napi_env env, AST_HTML_ATTRIB
|
|
|
225
225
|
napi_value result;
|
|
226
226
|
napi_create_object(env, &result);
|
|
227
227
|
|
|
228
|
-
napi_value type =
|
|
228
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&html_attribute_name_node->base));
|
|
229
229
|
napi_set_named_property(env, result, "type", type);
|
|
230
230
|
|
|
231
231
|
napi_value location = CreateLocation(env, html_attribute_name_node->base.location);
|
|
@@ -250,7 +250,7 @@ napi_value html_attribute_nodeNodeFromCStruct(napi_env env, AST_HTML_ATTRIBUTE_N
|
|
|
250
250
|
napi_value result;
|
|
251
251
|
napi_create_object(env, &result);
|
|
252
252
|
|
|
253
|
-
napi_value type =
|
|
253
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&html_attribute_node->base));
|
|
254
254
|
napi_set_named_property(env, result, "type", type);
|
|
255
255
|
|
|
256
256
|
napi_value location = CreateLocation(env, html_attribute_node->base.location);
|
|
@@ -281,7 +281,7 @@ napi_value html_text_nodeNodeFromCStruct(napi_env env, AST_HTML_TEXT_NODE_T* htm
|
|
|
281
281
|
napi_value result;
|
|
282
282
|
napi_create_object(env, &result);
|
|
283
283
|
|
|
284
|
-
napi_value type =
|
|
284
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&html_text_node->base));
|
|
285
285
|
napi_set_named_property(env, result, "type", type);
|
|
286
286
|
|
|
287
287
|
napi_value location = CreateLocation(env, html_text_node->base.location);
|
|
@@ -306,7 +306,7 @@ napi_value html_comment_nodeNodeFromCStruct(napi_env env, AST_HTML_COMMENT_NODE_
|
|
|
306
306
|
napi_value result;
|
|
307
307
|
napi_create_object(env, &result);
|
|
308
308
|
|
|
309
|
-
napi_value type =
|
|
309
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&html_comment_node->base));
|
|
310
310
|
napi_set_named_property(env, result, "type", type);
|
|
311
311
|
|
|
312
312
|
napi_value location = CreateLocation(env, html_comment_node->base.location);
|
|
@@ -337,7 +337,7 @@ napi_value html_doctype_nodeNodeFromCStruct(napi_env env, AST_HTML_DOCTYPE_NODE_
|
|
|
337
337
|
napi_value result;
|
|
338
338
|
napi_create_object(env, &result);
|
|
339
339
|
|
|
340
|
-
napi_value type =
|
|
340
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&html_doctype_node->base));
|
|
341
341
|
napi_set_named_property(env, result, "type", type);
|
|
342
342
|
|
|
343
343
|
napi_value location = CreateLocation(env, html_doctype_node->base.location);
|
|
@@ -368,7 +368,7 @@ napi_value xml_declaration_nodeNodeFromCStruct(napi_env env, AST_XML_DECLARATION
|
|
|
368
368
|
napi_value result;
|
|
369
369
|
napi_create_object(env, &result);
|
|
370
370
|
|
|
371
|
-
napi_value type =
|
|
371
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&xml_declaration_node->base));
|
|
372
372
|
napi_set_named_property(env, result, "type", type);
|
|
373
373
|
|
|
374
374
|
napi_value location = CreateLocation(env, xml_declaration_node->base.location);
|
|
@@ -399,7 +399,7 @@ napi_value cdata_nodeNodeFromCStruct(napi_env env, AST_CDATA_NODE_T* cdata_node)
|
|
|
399
399
|
napi_value result;
|
|
400
400
|
napi_create_object(env, &result);
|
|
401
401
|
|
|
402
|
-
napi_value type =
|
|
402
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&cdata_node->base));
|
|
403
403
|
napi_set_named_property(env, result, "type", type);
|
|
404
404
|
|
|
405
405
|
napi_value location = CreateLocation(env, cdata_node->base.location);
|
|
@@ -430,7 +430,7 @@ napi_value whitespace_nodeNodeFromCStruct(napi_env env, AST_WHITESPACE_NODE_T* w
|
|
|
430
430
|
napi_value result;
|
|
431
431
|
napi_create_object(env, &result);
|
|
432
432
|
|
|
433
|
-
napi_value type =
|
|
433
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&whitespace_node->base));
|
|
434
434
|
napi_set_named_property(env, result, "type", type);
|
|
435
435
|
|
|
436
436
|
napi_value location = CreateLocation(env, whitespace_node->base.location);
|
|
@@ -455,7 +455,7 @@ napi_value erb_content_nodeNodeFromCStruct(napi_env env, AST_ERB_CONTENT_NODE_T*
|
|
|
455
455
|
napi_value result;
|
|
456
456
|
napi_create_object(env, &result);
|
|
457
457
|
|
|
458
|
-
napi_value type =
|
|
458
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_content_node->base));
|
|
459
459
|
napi_set_named_property(env, result, "type", type);
|
|
460
460
|
|
|
461
461
|
napi_value location = CreateLocation(env, erb_content_node->base.location);
|
|
@@ -498,7 +498,7 @@ napi_value erb_end_nodeNodeFromCStruct(napi_env env, AST_ERB_END_NODE_T* erb_end
|
|
|
498
498
|
napi_value result;
|
|
499
499
|
napi_create_object(env, &result);
|
|
500
500
|
|
|
501
|
-
napi_value type =
|
|
501
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_end_node->base));
|
|
502
502
|
napi_set_named_property(env, result, "type", type);
|
|
503
503
|
|
|
504
504
|
napi_value location = CreateLocation(env, erb_end_node->base.location);
|
|
@@ -529,7 +529,7 @@ napi_value erb_else_nodeNodeFromCStruct(napi_env env, AST_ERB_ELSE_NODE_T* erb_e
|
|
|
529
529
|
napi_value result;
|
|
530
530
|
napi_create_object(env, &result);
|
|
531
531
|
|
|
532
|
-
napi_value type =
|
|
532
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_else_node->base));
|
|
533
533
|
napi_set_named_property(env, result, "type", type);
|
|
534
534
|
|
|
535
535
|
napi_value location = CreateLocation(env, erb_else_node->base.location);
|
|
@@ -563,7 +563,7 @@ napi_value erb_if_nodeNodeFromCStruct(napi_env env, AST_ERB_IF_NODE_T* erb_if_no
|
|
|
563
563
|
napi_value result;
|
|
564
564
|
napi_create_object(env, &result);
|
|
565
565
|
|
|
566
|
-
napi_value type =
|
|
566
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_if_node->base));
|
|
567
567
|
napi_set_named_property(env, result, "type", type);
|
|
568
568
|
|
|
569
569
|
napi_value location = CreateLocation(env, erb_if_node->base.location);
|
|
@@ -603,7 +603,7 @@ napi_value erb_block_nodeNodeFromCStruct(napi_env env, AST_ERB_BLOCK_NODE_T* erb
|
|
|
603
603
|
napi_value result;
|
|
604
604
|
napi_create_object(env, &result);
|
|
605
605
|
|
|
606
|
-
napi_value type =
|
|
606
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_block_node->base));
|
|
607
607
|
napi_set_named_property(env, result, "type", type);
|
|
608
608
|
|
|
609
609
|
napi_value location = CreateLocation(env, erb_block_node->base.location);
|
|
@@ -640,7 +640,7 @@ napi_value erb_when_nodeNodeFromCStruct(napi_env env, AST_ERB_WHEN_NODE_T* erb_w
|
|
|
640
640
|
napi_value result;
|
|
641
641
|
napi_create_object(env, &result);
|
|
642
642
|
|
|
643
|
-
napi_value type =
|
|
643
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_when_node->base));
|
|
644
644
|
napi_set_named_property(env, result, "type", type);
|
|
645
645
|
|
|
646
646
|
napi_value location = CreateLocation(env, erb_when_node->base.location);
|
|
@@ -674,7 +674,7 @@ napi_value erb_case_nodeNodeFromCStruct(napi_env env, AST_ERB_CASE_NODE_T* erb_c
|
|
|
674
674
|
napi_value result;
|
|
675
675
|
napi_create_object(env, &result);
|
|
676
676
|
|
|
677
|
-
napi_value type =
|
|
677
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_case_node->base));
|
|
678
678
|
napi_set_named_property(env, result, "type", type);
|
|
679
679
|
|
|
680
680
|
napi_value location = CreateLocation(env, erb_case_node->base.location);
|
|
@@ -717,7 +717,7 @@ napi_value erb_case_match_nodeNodeFromCStruct(napi_env env, AST_ERB_CASE_MATCH_N
|
|
|
717
717
|
napi_value result;
|
|
718
718
|
napi_create_object(env, &result);
|
|
719
719
|
|
|
720
|
-
napi_value type =
|
|
720
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_case_match_node->base));
|
|
721
721
|
napi_set_named_property(env, result, "type", type);
|
|
722
722
|
|
|
723
723
|
napi_value location = CreateLocation(env, erb_case_match_node->base.location);
|
|
@@ -760,7 +760,7 @@ napi_value erb_while_nodeNodeFromCStruct(napi_env env, AST_ERB_WHILE_NODE_T* erb
|
|
|
760
760
|
napi_value result;
|
|
761
761
|
napi_create_object(env, &result);
|
|
762
762
|
|
|
763
|
-
napi_value type =
|
|
763
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_while_node->base));
|
|
764
764
|
napi_set_named_property(env, result, "type", type);
|
|
765
765
|
|
|
766
766
|
napi_value location = CreateLocation(env, erb_while_node->base.location);
|
|
@@ -797,7 +797,7 @@ napi_value erb_until_nodeNodeFromCStruct(napi_env env, AST_ERB_UNTIL_NODE_T* erb
|
|
|
797
797
|
napi_value result;
|
|
798
798
|
napi_create_object(env, &result);
|
|
799
799
|
|
|
800
|
-
napi_value type =
|
|
800
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_until_node->base));
|
|
801
801
|
napi_set_named_property(env, result, "type", type);
|
|
802
802
|
|
|
803
803
|
napi_value location = CreateLocation(env, erb_until_node->base.location);
|
|
@@ -834,7 +834,7 @@ napi_value erb_for_nodeNodeFromCStruct(napi_env env, AST_ERB_FOR_NODE_T* erb_for
|
|
|
834
834
|
napi_value result;
|
|
835
835
|
napi_create_object(env, &result);
|
|
836
836
|
|
|
837
|
-
napi_value type =
|
|
837
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_for_node->base));
|
|
838
838
|
napi_set_named_property(env, result, "type", type);
|
|
839
839
|
|
|
840
840
|
napi_value location = CreateLocation(env, erb_for_node->base.location);
|
|
@@ -871,7 +871,7 @@ napi_value erb_rescue_nodeNodeFromCStruct(napi_env env, AST_ERB_RESCUE_NODE_T* e
|
|
|
871
871
|
napi_value result;
|
|
872
872
|
napi_create_object(env, &result);
|
|
873
873
|
|
|
874
|
-
napi_value type =
|
|
874
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_rescue_node->base));
|
|
875
875
|
napi_set_named_property(env, result, "type", type);
|
|
876
876
|
|
|
877
877
|
napi_value location = CreateLocation(env, erb_rescue_node->base.location);
|
|
@@ -908,7 +908,7 @@ napi_value erb_ensure_nodeNodeFromCStruct(napi_env env, AST_ERB_ENSURE_NODE_T* e
|
|
|
908
908
|
napi_value result;
|
|
909
909
|
napi_create_object(env, &result);
|
|
910
910
|
|
|
911
|
-
napi_value type =
|
|
911
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_ensure_node->base));
|
|
912
912
|
napi_set_named_property(env, result, "type", type);
|
|
913
913
|
|
|
914
914
|
napi_value location = CreateLocation(env, erb_ensure_node->base.location);
|
|
@@ -942,7 +942,7 @@ napi_value erb_begin_nodeNodeFromCStruct(napi_env env, AST_ERB_BEGIN_NODE_T* erb
|
|
|
942
942
|
napi_value result;
|
|
943
943
|
napi_create_object(env, &result);
|
|
944
944
|
|
|
945
|
-
napi_value type =
|
|
945
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_begin_node->base));
|
|
946
946
|
napi_set_named_property(env, result, "type", type);
|
|
947
947
|
|
|
948
948
|
napi_value location = CreateLocation(env, erb_begin_node->base.location);
|
|
@@ -988,7 +988,7 @@ napi_value erb_unless_nodeNodeFromCStruct(napi_env env, AST_ERB_UNLESS_NODE_T* e
|
|
|
988
988
|
napi_value result;
|
|
989
989
|
napi_create_object(env, &result);
|
|
990
990
|
|
|
991
|
-
napi_value type =
|
|
991
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_unless_node->base));
|
|
992
992
|
napi_set_named_property(env, result, "type", type);
|
|
993
993
|
|
|
994
994
|
napi_value location = CreateLocation(env, erb_unless_node->base.location);
|
|
@@ -1028,7 +1028,7 @@ napi_value erb_yield_nodeNodeFromCStruct(napi_env env, AST_ERB_YIELD_NODE_T* erb
|
|
|
1028
1028
|
napi_value result;
|
|
1029
1029
|
napi_create_object(env, &result);
|
|
1030
1030
|
|
|
1031
|
-
napi_value type =
|
|
1031
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_yield_node->base));
|
|
1032
1032
|
napi_set_named_property(env, result, "type", type);
|
|
1033
1033
|
|
|
1034
1034
|
napi_value location = CreateLocation(env, erb_yield_node->base.location);
|
|
@@ -1059,7 +1059,7 @@ napi_value erb_in_nodeNodeFromCStruct(napi_env env, AST_ERB_IN_NODE_T* erb_in_no
|
|
|
1059
1059
|
napi_value result;
|
|
1060
1060
|
napi_create_object(env, &result);
|
|
1061
1061
|
|
|
1062
|
-
napi_value type =
|
|
1062
|
+
napi_value type = CreateStringFromHbString(env, ast_node_type_to_string(&erb_in_node->base));
|
|
1063
1063
|
napi_set_named_property(env, result, "type", type);
|
|
1064
1064
|
|
|
1065
1065
|
napi_value location = CreateLocation(env, erb_in_node->base.location);
|
|
@@ -1084,13 +1084,13 @@ napi_value erb_in_nodeNodeFromCStruct(napi_env env, AST_ERB_IN_NODE_T* erb_in_no
|
|
|
1084
1084
|
return result;
|
|
1085
1085
|
}
|
|
1086
1086
|
|
|
1087
|
-
napi_value NodesArrayFromCArray(napi_env env,
|
|
1087
|
+
napi_value NodesArrayFromCArray(napi_env env, hb_array_T* array) {
|
|
1088
1088
|
napi_value result;
|
|
1089
1089
|
napi_create_array(env, &result);
|
|
1090
1090
|
|
|
1091
1091
|
if (array) {
|
|
1092
|
-
for (size_t i = 0; i <
|
|
1093
|
-
AST_NODE_T* child_node = (AST_NODE_T*)
|
|
1092
|
+
for (size_t i = 0; i < hb_array_size(array); i++) {
|
|
1093
|
+
AST_NODE_T* child_node = (AST_NODE_T*) hb_array_get(array, i);
|
|
1094
1094
|
if (child_node) {
|
|
1095
1095
|
napi_value js_child = NodeFromCStruct(env, child_node);
|
|
1096
1096
|
napi_set_element(env, result, i, js_child);
|
package/extension/nodes.h
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.0/templates/javascript/packages/node/extension/nodes.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_EXTENSION_NODES_H
|
|
5
5
|
#define HERB_EXTENSION_NODES_H
|
|
@@ -11,7 +11,7 @@ extern "C" {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
napi_value NodeFromCStruct(napi_env env, AST_NODE_T* node);
|
|
14
|
-
napi_value NodesArrayFromCArray(napi_env env,
|
|
14
|
+
napi_value NodesArrayFromCArray(napi_env env, hb_array_T* array);
|
|
15
15
|
|
|
16
16
|
napi_value document_nodeNodeFromCStruct(napi_env env, AST_DOCUMENT_NODE_T* document_node);
|
|
17
17
|
napi_value literal_nodeNodeFromCStruct(napi_env env, AST_LITERAL_NODE_T* literal_node);
|