herb 0.8.10-arm-linux-gnu → 0.9.0-arm-linux-gnu
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/Makefile +11 -3
- data/README.md +64 -34
- data/Rakefile +48 -40
- data/config.yml +317 -34
- data/ext/herb/error_helpers.c +367 -140
- data/ext/herb/error_helpers.h +1 -0
- data/ext/herb/extconf.rb +67 -28
- data/ext/herb/extension.c +317 -51
- data/ext/herb/extension.h +1 -0
- data/ext/herb/extension_helpers.c +23 -14
- data/ext/herb/extension_helpers.h +2 -2
- data/ext/herb/nodes.c +537 -270
- data/ext/herb/nodes.h +1 -0
- data/herb.gemspec +3 -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/4.0/herb.so +0 -0
- data/lib/herb/ast/helpers.rb +3 -3
- data/lib/herb/ast/node.rb +15 -2
- data/lib/herb/ast/nodes.rb +1132 -157
- data/lib/herb/bootstrap.rb +87 -0
- data/lib/herb/cli.rb +341 -31
- data/lib/herb/configuration.rb +248 -0
- data/lib/herb/defaults.yml +32 -0
- data/lib/herb/engine/compiler.rb +78 -11
- data/lib/herb/engine/debug_visitor.rb +13 -3
- data/lib/herb/engine/error_formatter.rb +13 -9
- data/lib/herb/engine/parser_error_overlay.rb +10 -6
- data/lib/herb/engine/validator.rb +8 -3
- data/lib/herb/engine/validators/nesting_validator.rb +2 -2
- data/lib/herb/engine.rb +82 -35
- data/lib/herb/errors.rb +563 -88
- data/lib/herb/lex_result.rb +1 -0
- data/lib/herb/location.rb +7 -3
- data/lib/herb/parse_result.rb +12 -2
- data/lib/herb/parser_options.rb +57 -0
- data/lib/herb/position.rb +1 -0
- data/lib/herb/prism_inspect.rb +116 -0
- data/lib/herb/project.rb +923 -331
- data/lib/herb/range.rb +1 -0
- data/lib/herb/token.rb +7 -1
- data/lib/herb/version.rb +1 -1
- data/lib/herb/visitor.rb +37 -2
- data/lib/herb/warnings.rb +6 -1
- data/lib/herb.rb +35 -3
- data/sig/herb/ast/helpers.rbs +2 -2
- data/sig/herb/ast/node.rbs +12 -2
- data/sig/herb/ast/nodes.rbs +641 -128
- data/sig/herb/bootstrap.rbs +31 -0
- data/sig/herb/configuration.rbs +89 -0
- data/sig/herb/engine/compiler.rbs +9 -1
- data/sig/herb/engine/debug_visitor.rbs +2 -0
- data/sig/herb/engine/validator.rbs +5 -1
- data/sig/herb/engine.rbs +17 -3
- data/sig/herb/errors.rbs +258 -63
- data/sig/herb/location.rbs +4 -0
- data/sig/herb/parse_result.rbs +4 -2
- data/sig/herb/parser_options.rbs +42 -0
- data/sig/herb/position.rbs +1 -0
- data/sig/herb/prism_inspect.rbs +28 -0
- data/sig/herb/range.rbs +1 -0
- data/sig/herb/token.rbs +6 -0
- data/sig/herb/visitor.rbs +25 -4
- data/sig/herb/warnings.rbs +6 -1
- data/sig/herb.rbs +14 -0
- data/sig/herb_c_extension.rbs +5 -2
- data/sig/serialized_ast_errors.rbs +54 -6
- data/sig/serialized_ast_nodes.rbs +60 -6
- data/src/analyze/action_view/attribute_extraction_helpers.c +290 -0
- data/src/analyze/action_view/content_tag.c +70 -0
- data/src/analyze/action_view/link_to.c +143 -0
- data/src/analyze/action_view/registry.c +60 -0
- data/src/analyze/action_view/tag.c +64 -0
- data/src/analyze/action_view/tag_helper_node_builders.c +305 -0
- data/src/analyze/action_view/tag_helpers.c +748 -0
- data/src/analyze/action_view/turbo_frame_tag.c +88 -0
- data/src/analyze/analyze.c +882 -0
- data/src/{analyzed_ruby.c → analyze/analyzed_ruby.c} +13 -11
- data/src/analyze/builders.c +343 -0
- data/src/analyze/conditional_elements.c +594 -0
- data/src/analyze/conditional_open_tags.c +640 -0
- data/src/analyze/control_type.c +250 -0
- data/src/{analyze_helpers.c → analyze/helpers.c} +48 -23
- data/src/analyze/invalid_structures.c +193 -0
- data/src/{analyze_missing_end.c → analyze/missing_end.c} +33 -22
- data/src/analyze/parse_errors.c +84 -0
- data/src/analyze/prism_annotate.c +397 -0
- data/src/{analyze_transform.c → analyze/transform.c} +17 -3
- data/src/ast_node.c +17 -7
- data/src/ast_nodes.c +662 -387
- data/src/ast_pretty_print.c +190 -6
- data/src/errors.c +1076 -520
- data/src/extract.c +145 -49
- data/src/herb.c +52 -34
- data/src/html_util.c +241 -12
- data/src/include/analyze/action_view/attribute_extraction_helpers.h +36 -0
- data/src/include/analyze/action_view/tag_helper_handler.h +41 -0
- data/src/include/analyze/action_view/tag_helper_node_builders.h +70 -0
- data/src/include/analyze/action_view/tag_helpers.h +38 -0
- data/src/include/{analyze.h → analyze/analyze.h} +14 -4
- data/src/include/{analyzed_ruby.h → analyze/analyzed_ruby.h} +3 -3
- data/src/include/analyze/builders.h +27 -0
- data/src/include/analyze/conditional_elements.h +9 -0
- data/src/include/analyze/conditional_open_tags.h +9 -0
- data/src/include/analyze/control_type.h +14 -0
- data/src/include/{analyze_helpers.h → analyze/helpers.h} +4 -2
- data/src/include/analyze/invalid_structures.h +11 -0
- data/src/include/analyze/prism_annotate.h +16 -0
- data/src/include/ast_node.h +11 -5
- data/src/include/ast_nodes.h +117 -38
- data/src/include/ast_pretty_print.h +5 -0
- data/src/include/element_source.h +3 -8
- data/src/include/errors.h +148 -55
- data/src/include/extract.h +21 -5
- data/src/include/herb.h +18 -6
- data/src/include/herb_prism_node.h +13 -0
- data/src/include/html_util.h +7 -2
- data/src/include/io.h +3 -1
- data/src/include/lex_helpers.h +29 -0
- data/src/include/lexer.h +1 -1
- data/src/include/lexer_peek_helpers.h +87 -13
- data/src/include/lexer_struct.h +2 -0
- data/src/include/location.h +2 -1
- data/src/include/parser.h +27 -2
- data/src/include/parser_helpers.h +19 -3
- data/src/include/pretty_print.h +10 -5
- data/src/include/prism_context.h +45 -0
- data/src/include/prism_helpers.h +10 -7
- data/src/include/prism_serialized.h +12 -0
- data/src/include/token.h +16 -4
- data/src/include/token_struct.h +10 -3
- data/src/include/utf8.h +2 -1
- data/src/include/util/hb_allocator.h +78 -0
- data/src/include/util/hb_arena.h +6 -1
- data/src/include/util/hb_arena_debug.h +12 -1
- data/src/include/util/hb_array.h +7 -3
- data/src/include/util/hb_buffer.h +6 -4
- data/src/include/util/hb_foreach.h +79 -0
- data/src/include/util/hb_narray.h +8 -4
- data/src/include/util/hb_string.h +56 -9
- data/src/include/util.h +6 -3
- data/src/include/version.h +1 -1
- data/src/io.c +3 -2
- data/src/lexer.c +42 -30
- data/src/lexer_peek_helpers.c +12 -74
- data/src/location.c +2 -2
- data/src/main.c +53 -28
- data/src/parser.c +783 -247
- data/src/parser_helpers.c +110 -23
- data/src/parser_match_tags.c +109 -48
- data/src/pretty_print.c +29 -24
- data/src/prism_helpers.c +30 -27
- data/src/ruby_parser.c +2 -0
- data/src/token.c +151 -66
- data/src/token_matchers.c +0 -1
- data/src/utf8.c +7 -6
- data/src/util/hb_allocator.c +341 -0
- data/src/util/hb_arena.c +81 -56
- data/src/util/hb_arena_debug.c +32 -17
- data/src/util/hb_array.c +30 -15
- data/src/util/hb_buffer.c +17 -21
- data/src/util/hb_narray.c +22 -7
- data/src/util/hb_string.c +49 -35
- data/src/util.c +21 -11
- data/src/visitor.c +47 -0
- data/templates/ext/herb/error_helpers.c.erb +24 -11
- data/templates/ext/herb/error_helpers.h.erb +1 -0
- data/templates/ext/herb/nodes.c.erb +50 -16
- data/templates/ext/herb/nodes.h.erb +1 -0
- data/templates/java/error_helpers.c.erb +1 -1
- data/templates/java/nodes.c.erb +30 -8
- data/templates/java/org/herb/ast/Errors.java.erb +24 -1
- data/templates/java/org/herb/ast/Nodes.java.erb +80 -21
- data/templates/javascript/packages/core/src/errors.ts.erb +16 -3
- data/templates/javascript/packages/core/src/node-type-guards.ts.erb +3 -1
- data/templates/javascript/packages/core/src/nodes.ts.erb +109 -32
- data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +13 -4
- data/templates/javascript/packages/node/extension/nodes.cpp.erb +43 -4
- data/templates/lib/herb/ast/nodes.rb.erb +88 -31
- data/templates/lib/herb/errors.rb.erb +15 -3
- data/templates/lib/herb/visitor.rb.erb +2 -2
- data/templates/rust/src/ast/nodes.rs.erb +97 -44
- data/templates/rust/src/errors.rs.erb +2 -1
- data/templates/rust/src/nodes.rs.erb +167 -15
- data/templates/rust/src/union_types.rs.erb +60 -0
- data/templates/rust/src/visitor.rs.erb +81 -0
- data/templates/src/{analyze_missing_end.c.erb → analyze/missing_end.c.erb} +9 -6
- data/templates/src/{analyze_transform.c.erb → analyze/transform.c.erb} +2 -2
- data/templates/src/ast_nodes.c.erb +34 -26
- data/templates/src/ast_pretty_print.c.erb +24 -5
- data/templates/src/errors.c.erb +60 -54
- data/templates/src/include/ast_nodes.h.erb +6 -2
- data/templates/src/include/ast_pretty_print.h.erb +5 -0
- data/templates/src/include/errors.h.erb +15 -11
- data/templates/src/include/util/hb_foreach.h.erb +20 -0
- data/templates/src/parser_match_tags.c.erb +10 -4
- data/templates/src/visitor.c.erb +2 -2
- data/templates/template.rb +204 -29
- data/templates/wasm/error_helpers.cpp.erb +9 -5
- data/templates/wasm/nodes.cpp.erb +41 -4
- metadata +57 -16
- data/src/analyze.c +0 -1608
- data/src/element_source.c +0 -12
- data/src/include/util/hb_system.h +0 -9
- data/src/util/hb_system.c +0 -30
data/ext/herb/nodes.c
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// be modified manually. See /home/runner/work/herb/herb/templates/ext/herb/nodes.c.erb
|
|
3
3
|
|
|
4
4
|
#include <ruby.h>
|
|
5
|
+
#include <ruby/encoding.h>
|
|
5
6
|
|
|
6
7
|
#include "error_helpers.h"
|
|
7
8
|
#include "extension_helpers.h"
|
|
@@ -14,31 +15,129 @@
|
|
|
14
15
|
VALUE rb_node_from_c_struct(AST_NODE_T* node);
|
|
15
16
|
static VALUE rb_nodes_array_from_c_array(hb_array_T* array);
|
|
16
17
|
|
|
18
|
+
static VALUE mAST;
|
|
19
|
+
static VALUE cNode;
|
|
20
|
+
static VALUE cDocumentNode;
|
|
21
|
+
static VALUE cLiteralNode;
|
|
22
|
+
static VALUE cHTMLOpenTagNode;
|
|
23
|
+
static VALUE cHTMLConditionalOpenTagNode;
|
|
24
|
+
static VALUE cHTMLCloseTagNode;
|
|
25
|
+
static VALUE cHTMLOmittedCloseTagNode;
|
|
26
|
+
static VALUE cHTMLVirtualCloseTagNode;
|
|
27
|
+
static VALUE cHTMLElementNode;
|
|
28
|
+
static VALUE cHTMLConditionalElementNode;
|
|
29
|
+
static VALUE cHTMLAttributeValueNode;
|
|
30
|
+
static VALUE cHTMLAttributeNameNode;
|
|
31
|
+
static VALUE cHTMLAttributeNode;
|
|
32
|
+
static VALUE cRubyLiteralNode;
|
|
33
|
+
static VALUE cRubyHTMLAttributesSplatNode;
|
|
34
|
+
static VALUE cERBOpenTagNode;
|
|
35
|
+
static VALUE cHTMLTextNode;
|
|
36
|
+
static VALUE cHTMLCommentNode;
|
|
37
|
+
static VALUE cHTMLDoctypeNode;
|
|
38
|
+
static VALUE cXMLDeclarationNode;
|
|
39
|
+
static VALUE cCDATANode;
|
|
40
|
+
static VALUE cWhitespaceNode;
|
|
41
|
+
static VALUE cERBContentNode;
|
|
42
|
+
static VALUE cERBEndNode;
|
|
43
|
+
static VALUE cERBElseNode;
|
|
44
|
+
static VALUE cERBIfNode;
|
|
45
|
+
static VALUE cERBBlockNode;
|
|
46
|
+
static VALUE cERBWhenNode;
|
|
47
|
+
static VALUE cERBCaseNode;
|
|
48
|
+
static VALUE cERBCaseMatchNode;
|
|
49
|
+
static VALUE cERBWhileNode;
|
|
50
|
+
static VALUE cERBUntilNode;
|
|
51
|
+
static VALUE cERBForNode;
|
|
52
|
+
static VALUE cERBRescueNode;
|
|
53
|
+
static VALUE cERBEnsureNode;
|
|
54
|
+
static VALUE cERBBeginNode;
|
|
55
|
+
static VALUE cERBUnlessNode;
|
|
56
|
+
static VALUE cERBYieldNode;
|
|
57
|
+
static VALUE cERBInNode;
|
|
58
|
+
|
|
59
|
+
void rb_init_node_classes(void) {
|
|
60
|
+
mAST = rb_define_module_under(mHerb, "AST");
|
|
61
|
+
cNode = rb_define_class_under(mAST, "Node", rb_cObject);
|
|
62
|
+
cDocumentNode = rb_define_class_under(mAST, "DocumentNode", cNode);
|
|
63
|
+
cLiteralNode = rb_define_class_under(mAST, "LiteralNode", cNode);
|
|
64
|
+
cHTMLOpenTagNode = rb_define_class_under(mAST, "HTMLOpenTagNode", cNode);
|
|
65
|
+
cHTMLConditionalOpenTagNode = rb_define_class_under(mAST, "HTMLConditionalOpenTagNode", cNode);
|
|
66
|
+
cHTMLCloseTagNode = rb_define_class_under(mAST, "HTMLCloseTagNode", cNode);
|
|
67
|
+
cHTMLOmittedCloseTagNode = rb_define_class_under(mAST, "HTMLOmittedCloseTagNode", cNode);
|
|
68
|
+
cHTMLVirtualCloseTagNode = rb_define_class_under(mAST, "HTMLVirtualCloseTagNode", cNode);
|
|
69
|
+
cHTMLElementNode = rb_define_class_under(mAST, "HTMLElementNode", cNode);
|
|
70
|
+
cHTMLConditionalElementNode = rb_define_class_under(mAST, "HTMLConditionalElementNode", cNode);
|
|
71
|
+
cHTMLAttributeValueNode = rb_define_class_under(mAST, "HTMLAttributeValueNode", cNode);
|
|
72
|
+
cHTMLAttributeNameNode = rb_define_class_under(mAST, "HTMLAttributeNameNode", cNode);
|
|
73
|
+
cHTMLAttributeNode = rb_define_class_under(mAST, "HTMLAttributeNode", cNode);
|
|
74
|
+
cRubyLiteralNode = rb_define_class_under(mAST, "RubyLiteralNode", cNode);
|
|
75
|
+
cRubyHTMLAttributesSplatNode = rb_define_class_under(mAST, "RubyHTMLAttributesSplatNode", cNode);
|
|
76
|
+
cERBOpenTagNode = rb_define_class_under(mAST, "ERBOpenTagNode", cNode);
|
|
77
|
+
cHTMLTextNode = rb_define_class_under(mAST, "HTMLTextNode", cNode);
|
|
78
|
+
cHTMLCommentNode = rb_define_class_under(mAST, "HTMLCommentNode", cNode);
|
|
79
|
+
cHTMLDoctypeNode = rb_define_class_under(mAST, "HTMLDoctypeNode", cNode);
|
|
80
|
+
cXMLDeclarationNode = rb_define_class_under(mAST, "XMLDeclarationNode", cNode);
|
|
81
|
+
cCDATANode = rb_define_class_under(mAST, "CDATANode", cNode);
|
|
82
|
+
cWhitespaceNode = rb_define_class_under(mAST, "WhitespaceNode", cNode);
|
|
83
|
+
cERBContentNode = rb_define_class_under(mAST, "ERBContentNode", cNode);
|
|
84
|
+
cERBEndNode = rb_define_class_under(mAST, "ERBEndNode", cNode);
|
|
85
|
+
cERBElseNode = rb_define_class_under(mAST, "ERBElseNode", cNode);
|
|
86
|
+
cERBIfNode = rb_define_class_under(mAST, "ERBIfNode", cNode);
|
|
87
|
+
cERBBlockNode = rb_define_class_under(mAST, "ERBBlockNode", cNode);
|
|
88
|
+
cERBWhenNode = rb_define_class_under(mAST, "ERBWhenNode", cNode);
|
|
89
|
+
cERBCaseNode = rb_define_class_under(mAST, "ERBCaseNode", cNode);
|
|
90
|
+
cERBCaseMatchNode = rb_define_class_under(mAST, "ERBCaseMatchNode", cNode);
|
|
91
|
+
cERBWhileNode = rb_define_class_under(mAST, "ERBWhileNode", cNode);
|
|
92
|
+
cERBUntilNode = rb_define_class_under(mAST, "ERBUntilNode", cNode);
|
|
93
|
+
cERBForNode = rb_define_class_under(mAST, "ERBForNode", cNode);
|
|
94
|
+
cERBRescueNode = rb_define_class_under(mAST, "ERBRescueNode", cNode);
|
|
95
|
+
cERBEnsureNode = rb_define_class_under(mAST, "ERBEnsureNode", cNode);
|
|
96
|
+
cERBBeginNode = rb_define_class_under(mAST, "ERBBeginNode", cNode);
|
|
97
|
+
cERBUnlessNode = rb_define_class_under(mAST, "ERBUnlessNode", cNode);
|
|
98
|
+
cERBYieldNode = rb_define_class_under(mAST, "ERBYieldNode", cNode);
|
|
99
|
+
cERBInNode = rb_define_class_under(mAST, "ERBInNode", cNode);
|
|
100
|
+
}
|
|
101
|
+
|
|
17
102
|
static VALUE rb_document_node_from_c_struct(AST_DOCUMENT_NODE_T* document_node) {
|
|
18
103
|
if (document_node == NULL) { return Qnil; }
|
|
19
104
|
|
|
20
105
|
AST_NODE_T* node = &document_node->base;
|
|
21
106
|
|
|
22
|
-
VALUE
|
|
23
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
24
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
25
|
-
VALUE DocumentNode = rb_define_class_under(AST, "DocumentNode", Node);
|
|
26
|
-
|
|
27
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
28
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
107
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
29
108
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
30
109
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
31
110
|
|
|
32
111
|
VALUE document_node_children = rb_nodes_array_from_c_array(document_node->children);
|
|
112
|
+
/* prism_context is internal parser state, not exposed to Ruby */
|
|
113
|
+
VALUE document_node_prism_context = Qnil;
|
|
114
|
+
VALUE document_node_prism_node;
|
|
115
|
+
if (document_node->prism_node.node != NULL && document_node->prism_node.parser != NULL) {
|
|
116
|
+
pm_buffer_t pm_buffer = { 0 };
|
|
117
|
+
pm_serialize(document_node->prism_node.parser, document_node->prism_node.node, &pm_buffer);
|
|
118
|
+
|
|
119
|
+
if (pm_buffer.length > 0) {
|
|
120
|
+
document_node_prism_node = rb_str_new(pm_buffer.value, pm_buffer.length);
|
|
121
|
+
rb_enc_associate(document_node_prism_node, rb_ascii8bit_encoding());
|
|
122
|
+
OBJ_FREEZE(document_node_prism_node);
|
|
123
|
+
} else {
|
|
124
|
+
document_node_prism_node = Qnil;
|
|
125
|
+
}
|
|
126
|
+
pm_buffer_free(&pm_buffer);
|
|
127
|
+
} else {
|
|
128
|
+
document_node_prism_node = Qnil;
|
|
129
|
+
}
|
|
33
130
|
|
|
34
|
-
VALUE args[
|
|
131
|
+
VALUE args[6] = {
|
|
35
132
|
type,
|
|
36
133
|
location,
|
|
37
134
|
errors,
|
|
38
|
-
document_node_children
|
|
135
|
+
document_node_children,
|
|
136
|
+
document_node_prism_context,
|
|
137
|
+
document_node_prism_node
|
|
39
138
|
};
|
|
40
139
|
|
|
41
|
-
return rb_class_new_instance(
|
|
140
|
+
return rb_class_new_instance(6, args, cDocumentNode);
|
|
42
141
|
};
|
|
43
142
|
|
|
44
143
|
static VALUE rb_literal_node_from_c_struct(AST_LITERAL_NODE_T* literal_node) {
|
|
@@ -46,17 +145,11 @@ static VALUE rb_literal_node_from_c_struct(AST_LITERAL_NODE_T* literal_node) {
|
|
|
46
145
|
|
|
47
146
|
AST_NODE_T* node = &literal_node->base;
|
|
48
147
|
|
|
49
|
-
VALUE
|
|
50
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
51
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
52
|
-
VALUE LiteralNode = rb_define_class_under(AST, "LiteralNode", Node);
|
|
53
|
-
|
|
54
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
55
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
148
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
56
149
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
57
150
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
58
151
|
|
|
59
|
-
VALUE literal_node_content =
|
|
152
|
+
VALUE literal_node_content = rb_string_from_hb_string(literal_node->content);
|
|
60
153
|
|
|
61
154
|
VALUE args[4] = {
|
|
62
155
|
type,
|
|
@@ -65,7 +158,7 @@ static VALUE rb_literal_node_from_c_struct(AST_LITERAL_NODE_T* literal_node) {
|
|
|
65
158
|
literal_node_content
|
|
66
159
|
};
|
|
67
160
|
|
|
68
|
-
return rb_class_new_instance(4, args,
|
|
161
|
+
return rb_class_new_instance(4, args, cLiteralNode);
|
|
69
162
|
};
|
|
70
163
|
|
|
71
164
|
static VALUE rb_html_open_tag_node_from_c_struct(AST_HTML_OPEN_TAG_NODE_T* html_open_tag_node) {
|
|
@@ -73,13 +166,7 @@ static VALUE rb_html_open_tag_node_from_c_struct(AST_HTML_OPEN_TAG_NODE_T* html_
|
|
|
73
166
|
|
|
74
167
|
AST_NODE_T* node = &html_open_tag_node->base;
|
|
75
168
|
|
|
76
|
-
VALUE
|
|
77
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
78
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
79
|
-
VALUE HTMLOpenTagNode = rb_define_class_under(AST, "HTMLOpenTagNode", Node);
|
|
80
|
-
|
|
81
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
82
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
169
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
83
170
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
84
171
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
85
172
|
|
|
@@ -100,7 +187,32 @@ static VALUE rb_html_open_tag_node_from_c_struct(AST_HTML_OPEN_TAG_NODE_T* html_
|
|
|
100
187
|
html_open_tag_node_is_void
|
|
101
188
|
};
|
|
102
189
|
|
|
103
|
-
return rb_class_new_instance(8, args,
|
|
190
|
+
return rb_class_new_instance(8, args, cHTMLOpenTagNode);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
static VALUE rb_html_conditional_open_tag_node_from_c_struct(AST_HTML_CONDITIONAL_OPEN_TAG_NODE_T* html_conditional_open_tag_node) {
|
|
194
|
+
if (html_conditional_open_tag_node == NULL) { return Qnil; }
|
|
195
|
+
|
|
196
|
+
AST_NODE_T* node = &html_conditional_open_tag_node->base;
|
|
197
|
+
|
|
198
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
199
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
|
200
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
201
|
+
|
|
202
|
+
VALUE html_conditional_open_tag_node_conditional = rb_node_from_c_struct((AST_NODE_T*) html_conditional_open_tag_node->conditional);
|
|
203
|
+
VALUE html_conditional_open_tag_node_tag_name = rb_token_from_c_struct(html_conditional_open_tag_node->tag_name);
|
|
204
|
+
VALUE html_conditional_open_tag_node_is_void = (html_conditional_open_tag_node->is_void) ? Qtrue : Qfalse;
|
|
205
|
+
|
|
206
|
+
VALUE args[6] = {
|
|
207
|
+
type,
|
|
208
|
+
location,
|
|
209
|
+
errors,
|
|
210
|
+
html_conditional_open_tag_node_conditional,
|
|
211
|
+
html_conditional_open_tag_node_tag_name,
|
|
212
|
+
html_conditional_open_tag_node_is_void
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
return rb_class_new_instance(6, args, cHTMLConditionalOpenTagNode);
|
|
104
216
|
};
|
|
105
217
|
|
|
106
218
|
static VALUE rb_html_close_tag_node_from_c_struct(AST_HTML_CLOSE_TAG_NODE_T* html_close_tag_node) {
|
|
@@ -108,13 +220,7 @@ static VALUE rb_html_close_tag_node_from_c_struct(AST_HTML_CLOSE_TAG_NODE_T* htm
|
|
|
108
220
|
|
|
109
221
|
AST_NODE_T* node = &html_close_tag_node->base;
|
|
110
222
|
|
|
111
|
-
VALUE
|
|
112
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
113
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
114
|
-
VALUE HTMLCloseTagNode = rb_define_class_under(AST, "HTMLCloseTagNode", Node);
|
|
115
|
-
|
|
116
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
117
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
223
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
118
224
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
119
225
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
120
226
|
|
|
@@ -133,7 +239,49 @@ static VALUE rb_html_close_tag_node_from_c_struct(AST_HTML_CLOSE_TAG_NODE_T* htm
|
|
|
133
239
|
html_close_tag_node_tag_closing
|
|
134
240
|
};
|
|
135
241
|
|
|
136
|
-
return rb_class_new_instance(7, args,
|
|
242
|
+
return rb_class_new_instance(7, args, cHTMLCloseTagNode);
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
static VALUE rb_html_omitted_close_tag_node_from_c_struct(AST_HTML_OMITTED_CLOSE_TAG_NODE_T* html_omitted_close_tag_node) {
|
|
246
|
+
if (html_omitted_close_tag_node == NULL) { return Qnil; }
|
|
247
|
+
|
|
248
|
+
AST_NODE_T* node = &html_omitted_close_tag_node->base;
|
|
249
|
+
|
|
250
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
251
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
|
252
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
253
|
+
|
|
254
|
+
VALUE html_omitted_close_tag_node_tag_name = rb_token_from_c_struct(html_omitted_close_tag_node->tag_name);
|
|
255
|
+
|
|
256
|
+
VALUE args[4] = {
|
|
257
|
+
type,
|
|
258
|
+
location,
|
|
259
|
+
errors,
|
|
260
|
+
html_omitted_close_tag_node_tag_name
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
return rb_class_new_instance(4, args, cHTMLOmittedCloseTagNode);
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
static VALUE rb_html_virtual_close_tag_node_from_c_struct(AST_HTML_VIRTUAL_CLOSE_TAG_NODE_T* html_virtual_close_tag_node) {
|
|
267
|
+
if (html_virtual_close_tag_node == NULL) { return Qnil; }
|
|
268
|
+
|
|
269
|
+
AST_NODE_T* node = &html_virtual_close_tag_node->base;
|
|
270
|
+
|
|
271
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
272
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
|
273
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
274
|
+
|
|
275
|
+
VALUE html_virtual_close_tag_node_tag_name = rb_token_from_c_struct(html_virtual_close_tag_node->tag_name);
|
|
276
|
+
|
|
277
|
+
VALUE args[4] = {
|
|
278
|
+
type,
|
|
279
|
+
location,
|
|
280
|
+
errors,
|
|
281
|
+
html_virtual_close_tag_node_tag_name
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
return rb_class_new_instance(4, args, cHTMLVirtualCloseTagNode);
|
|
137
285
|
};
|
|
138
286
|
|
|
139
287
|
static VALUE rb_html_element_node_from_c_struct(AST_HTML_ELEMENT_NODE_T* html_element_node) {
|
|
@@ -141,13 +289,7 @@ static VALUE rb_html_element_node_from_c_struct(AST_HTML_ELEMENT_NODE_T* html_el
|
|
|
141
289
|
|
|
142
290
|
AST_NODE_T* node = &html_element_node->base;
|
|
143
291
|
|
|
144
|
-
VALUE
|
|
145
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
146
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
147
|
-
VALUE HTMLElementNode = rb_define_class_under(AST, "HTMLElementNode", Node);
|
|
148
|
-
|
|
149
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
150
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
292
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
151
293
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
152
294
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
153
295
|
|
|
@@ -156,11 +298,7 @@ static VALUE rb_html_element_node_from_c_struct(AST_HTML_ELEMENT_NODE_T* html_el
|
|
|
156
298
|
VALUE html_element_node_body = rb_nodes_array_from_c_array(html_element_node->body);
|
|
157
299
|
VALUE html_element_node_close_tag = rb_node_from_c_struct((AST_NODE_T*) html_element_node->close_tag);
|
|
158
300
|
VALUE html_element_node_is_void = (html_element_node->is_void) ? Qtrue : Qfalse;
|
|
159
|
-
VALUE
|
|
160
|
-
{
|
|
161
|
-
hb_string_T element_source_string = element_source_to_string(html_element_node->source);
|
|
162
|
-
html_element_node_source = rb_utf8_str_new(element_source_string.data, element_source_string.length);
|
|
163
|
-
}
|
|
301
|
+
VALUE html_element_node_element_source = rb_string_from_hb_string(html_element_node->element_source);
|
|
164
302
|
|
|
165
303
|
VALUE args[9] = {
|
|
166
304
|
type,
|
|
@@ -171,10 +309,45 @@ static VALUE rb_html_element_node_from_c_struct(AST_HTML_ELEMENT_NODE_T* html_el
|
|
|
171
309
|
html_element_node_body,
|
|
172
310
|
html_element_node_close_tag,
|
|
173
311
|
html_element_node_is_void,
|
|
174
|
-
|
|
312
|
+
html_element_node_element_source
|
|
175
313
|
};
|
|
176
314
|
|
|
177
|
-
return rb_class_new_instance(9, args,
|
|
315
|
+
return rb_class_new_instance(9, args, cHTMLElementNode);
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
static VALUE rb_html_conditional_element_node_from_c_struct(AST_HTML_CONDITIONAL_ELEMENT_NODE_T* html_conditional_element_node) {
|
|
319
|
+
if (html_conditional_element_node == NULL) { return Qnil; }
|
|
320
|
+
|
|
321
|
+
AST_NODE_T* node = &html_conditional_element_node->base;
|
|
322
|
+
|
|
323
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
324
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
|
325
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
326
|
+
|
|
327
|
+
VALUE html_conditional_element_node_condition = rb_string_from_hb_string(html_conditional_element_node->condition);
|
|
328
|
+
VALUE html_conditional_element_node_open_conditional = rb_node_from_c_struct((AST_NODE_T*) html_conditional_element_node->open_conditional);
|
|
329
|
+
VALUE html_conditional_element_node_open_tag = rb_node_from_c_struct((AST_NODE_T*) html_conditional_element_node->open_tag);
|
|
330
|
+
VALUE html_conditional_element_node_body = rb_nodes_array_from_c_array(html_conditional_element_node->body);
|
|
331
|
+
VALUE html_conditional_element_node_close_tag = rb_node_from_c_struct((AST_NODE_T*) html_conditional_element_node->close_tag);
|
|
332
|
+
VALUE html_conditional_element_node_close_conditional = rb_node_from_c_struct((AST_NODE_T*) html_conditional_element_node->close_conditional);
|
|
333
|
+
VALUE html_conditional_element_node_tag_name = rb_token_from_c_struct(html_conditional_element_node->tag_name);
|
|
334
|
+
VALUE html_conditional_element_node_element_source = rb_string_from_hb_string(html_conditional_element_node->element_source);
|
|
335
|
+
|
|
336
|
+
VALUE args[11] = {
|
|
337
|
+
type,
|
|
338
|
+
location,
|
|
339
|
+
errors,
|
|
340
|
+
html_conditional_element_node_condition,
|
|
341
|
+
html_conditional_element_node_open_conditional,
|
|
342
|
+
html_conditional_element_node_open_tag,
|
|
343
|
+
html_conditional_element_node_body,
|
|
344
|
+
html_conditional_element_node_close_tag,
|
|
345
|
+
html_conditional_element_node_close_conditional,
|
|
346
|
+
html_conditional_element_node_tag_name,
|
|
347
|
+
html_conditional_element_node_element_source
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
return rb_class_new_instance(11, args, cHTMLConditionalElementNode);
|
|
178
351
|
};
|
|
179
352
|
|
|
180
353
|
static VALUE rb_html_attribute_value_node_from_c_struct(AST_HTML_ATTRIBUTE_VALUE_NODE_T* html_attribute_value_node) {
|
|
@@ -182,13 +355,7 @@ static VALUE rb_html_attribute_value_node_from_c_struct(AST_HTML_ATTRIBUTE_VALUE
|
|
|
182
355
|
|
|
183
356
|
AST_NODE_T* node = &html_attribute_value_node->base;
|
|
184
357
|
|
|
185
|
-
VALUE
|
|
186
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
187
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
188
|
-
VALUE HTMLAttributeValueNode = rb_define_class_under(AST, "HTMLAttributeValueNode", Node);
|
|
189
|
-
|
|
190
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
191
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
358
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
192
359
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
193
360
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
194
361
|
|
|
@@ -207,7 +374,7 @@ static VALUE rb_html_attribute_value_node_from_c_struct(AST_HTML_ATTRIBUTE_VALUE
|
|
|
207
374
|
html_attribute_value_node_quoted
|
|
208
375
|
};
|
|
209
376
|
|
|
210
|
-
return rb_class_new_instance(7, args,
|
|
377
|
+
return rb_class_new_instance(7, args, cHTMLAttributeValueNode);
|
|
211
378
|
};
|
|
212
379
|
|
|
213
380
|
static VALUE rb_html_attribute_name_node_from_c_struct(AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node) {
|
|
@@ -215,13 +382,7 @@ static VALUE rb_html_attribute_name_node_from_c_struct(AST_HTML_ATTRIBUTE_NAME_N
|
|
|
215
382
|
|
|
216
383
|
AST_NODE_T* node = &html_attribute_name_node->base;
|
|
217
384
|
|
|
218
|
-
VALUE
|
|
219
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
220
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
221
|
-
VALUE HTMLAttributeNameNode = rb_define_class_under(AST, "HTMLAttributeNameNode", Node);
|
|
222
|
-
|
|
223
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
224
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
385
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
225
386
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
226
387
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
227
388
|
|
|
@@ -234,7 +395,7 @@ static VALUE rb_html_attribute_name_node_from_c_struct(AST_HTML_ATTRIBUTE_NAME_N
|
|
|
234
395
|
html_attribute_name_node_children
|
|
235
396
|
};
|
|
236
397
|
|
|
237
|
-
return rb_class_new_instance(4, args,
|
|
398
|
+
return rb_class_new_instance(4, args, cHTMLAttributeNameNode);
|
|
238
399
|
};
|
|
239
400
|
|
|
240
401
|
static VALUE rb_html_attribute_node_from_c_struct(AST_HTML_ATTRIBUTE_NODE_T* html_attribute_node) {
|
|
@@ -242,13 +403,7 @@ static VALUE rb_html_attribute_node_from_c_struct(AST_HTML_ATTRIBUTE_NODE_T* htm
|
|
|
242
403
|
|
|
243
404
|
AST_NODE_T* node = &html_attribute_node->base;
|
|
244
405
|
|
|
245
|
-
VALUE
|
|
246
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
247
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
248
|
-
VALUE HTMLAttributeNode = rb_define_class_under(AST, "HTMLAttributeNode", Node);
|
|
249
|
-
|
|
250
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
251
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
406
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
252
407
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
253
408
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
254
409
|
|
|
@@ -265,7 +420,80 @@ static VALUE rb_html_attribute_node_from_c_struct(AST_HTML_ATTRIBUTE_NODE_T* htm
|
|
|
265
420
|
html_attribute_node_value
|
|
266
421
|
};
|
|
267
422
|
|
|
268
|
-
return rb_class_new_instance(6, args,
|
|
423
|
+
return rb_class_new_instance(6, args, cHTMLAttributeNode);
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
static VALUE rb_ruby_literal_node_from_c_struct(AST_RUBY_LITERAL_NODE_T* ruby_literal_node) {
|
|
427
|
+
if (ruby_literal_node == NULL) { return Qnil; }
|
|
428
|
+
|
|
429
|
+
AST_NODE_T* node = &ruby_literal_node->base;
|
|
430
|
+
|
|
431
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
432
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
|
433
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
434
|
+
|
|
435
|
+
VALUE ruby_literal_node_content = rb_string_from_hb_string(ruby_literal_node->content);
|
|
436
|
+
|
|
437
|
+
VALUE args[4] = {
|
|
438
|
+
type,
|
|
439
|
+
location,
|
|
440
|
+
errors,
|
|
441
|
+
ruby_literal_node_content
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
return rb_class_new_instance(4, args, cRubyLiteralNode);
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
static VALUE rb_ruby_html_attributes_splat_node_from_c_struct(AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE_T* ruby_html_attributes_splat_node) {
|
|
448
|
+
if (ruby_html_attributes_splat_node == NULL) { return Qnil; }
|
|
449
|
+
|
|
450
|
+
AST_NODE_T* node = &ruby_html_attributes_splat_node->base;
|
|
451
|
+
|
|
452
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
453
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
|
454
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
455
|
+
|
|
456
|
+
VALUE ruby_html_attributes_splat_node_content = rb_string_from_hb_string(ruby_html_attributes_splat_node->content);
|
|
457
|
+
VALUE ruby_html_attributes_splat_node_prefix = rb_string_from_hb_string(ruby_html_attributes_splat_node->prefix);
|
|
458
|
+
|
|
459
|
+
VALUE args[5] = {
|
|
460
|
+
type,
|
|
461
|
+
location,
|
|
462
|
+
errors,
|
|
463
|
+
ruby_html_attributes_splat_node_content,
|
|
464
|
+
ruby_html_attributes_splat_node_prefix
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
return rb_class_new_instance(5, args, cRubyHTMLAttributesSplatNode);
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
static VALUE rb_erb_open_tag_node_from_c_struct(AST_ERB_OPEN_TAG_NODE_T* erb_open_tag_node) {
|
|
471
|
+
if (erb_open_tag_node == NULL) { return Qnil; }
|
|
472
|
+
|
|
473
|
+
AST_NODE_T* node = &erb_open_tag_node->base;
|
|
474
|
+
|
|
475
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
476
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
|
477
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
478
|
+
|
|
479
|
+
VALUE erb_open_tag_node_tag_opening = rb_token_from_c_struct(erb_open_tag_node->tag_opening);
|
|
480
|
+
VALUE erb_open_tag_node_content = rb_token_from_c_struct(erb_open_tag_node->content);
|
|
481
|
+
VALUE erb_open_tag_node_tag_closing = rb_token_from_c_struct(erb_open_tag_node->tag_closing);
|
|
482
|
+
VALUE erb_open_tag_node_tag_name = rb_token_from_c_struct(erb_open_tag_node->tag_name);
|
|
483
|
+
VALUE erb_open_tag_node_children = rb_nodes_array_from_c_array(erb_open_tag_node->children);
|
|
484
|
+
|
|
485
|
+
VALUE args[8] = {
|
|
486
|
+
type,
|
|
487
|
+
location,
|
|
488
|
+
errors,
|
|
489
|
+
erb_open_tag_node_tag_opening,
|
|
490
|
+
erb_open_tag_node_content,
|
|
491
|
+
erb_open_tag_node_tag_closing,
|
|
492
|
+
erb_open_tag_node_tag_name,
|
|
493
|
+
erb_open_tag_node_children
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
return rb_class_new_instance(8, args, cERBOpenTagNode);
|
|
269
497
|
};
|
|
270
498
|
|
|
271
499
|
static VALUE rb_html_text_node_from_c_struct(AST_HTML_TEXT_NODE_T* html_text_node) {
|
|
@@ -273,17 +501,11 @@ static VALUE rb_html_text_node_from_c_struct(AST_HTML_TEXT_NODE_T* html_text_nod
|
|
|
273
501
|
|
|
274
502
|
AST_NODE_T* node = &html_text_node->base;
|
|
275
503
|
|
|
276
|
-
VALUE
|
|
277
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
278
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
279
|
-
VALUE HTMLTextNode = rb_define_class_under(AST, "HTMLTextNode", Node);
|
|
280
|
-
|
|
281
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
282
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
504
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
283
505
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
284
506
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
285
507
|
|
|
286
|
-
VALUE html_text_node_content =
|
|
508
|
+
VALUE html_text_node_content = rb_string_from_hb_string(html_text_node->content);
|
|
287
509
|
|
|
288
510
|
VALUE args[4] = {
|
|
289
511
|
type,
|
|
@@ -292,7 +514,7 @@ static VALUE rb_html_text_node_from_c_struct(AST_HTML_TEXT_NODE_T* html_text_nod
|
|
|
292
514
|
html_text_node_content
|
|
293
515
|
};
|
|
294
516
|
|
|
295
|
-
return rb_class_new_instance(4, args,
|
|
517
|
+
return rb_class_new_instance(4, args, cHTMLTextNode);
|
|
296
518
|
};
|
|
297
519
|
|
|
298
520
|
static VALUE rb_html_comment_node_from_c_struct(AST_HTML_COMMENT_NODE_T* html_comment_node) {
|
|
@@ -300,13 +522,7 @@ static VALUE rb_html_comment_node_from_c_struct(AST_HTML_COMMENT_NODE_T* html_co
|
|
|
300
522
|
|
|
301
523
|
AST_NODE_T* node = &html_comment_node->base;
|
|
302
524
|
|
|
303
|
-
VALUE
|
|
304
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
305
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
306
|
-
VALUE HTMLCommentNode = rb_define_class_under(AST, "HTMLCommentNode", Node);
|
|
307
|
-
|
|
308
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
309
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
525
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
310
526
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
311
527
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
312
528
|
|
|
@@ -323,7 +539,7 @@ static VALUE rb_html_comment_node_from_c_struct(AST_HTML_COMMENT_NODE_T* html_co
|
|
|
323
539
|
html_comment_node_comment_end
|
|
324
540
|
};
|
|
325
541
|
|
|
326
|
-
return rb_class_new_instance(6, args,
|
|
542
|
+
return rb_class_new_instance(6, args, cHTMLCommentNode);
|
|
327
543
|
};
|
|
328
544
|
|
|
329
545
|
static VALUE rb_html_doctype_node_from_c_struct(AST_HTML_DOCTYPE_NODE_T* html_doctype_node) {
|
|
@@ -331,13 +547,7 @@ static VALUE rb_html_doctype_node_from_c_struct(AST_HTML_DOCTYPE_NODE_T* html_do
|
|
|
331
547
|
|
|
332
548
|
AST_NODE_T* node = &html_doctype_node->base;
|
|
333
549
|
|
|
334
|
-
VALUE
|
|
335
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
336
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
337
|
-
VALUE HTMLDoctypeNode = rb_define_class_under(AST, "HTMLDoctypeNode", Node);
|
|
338
|
-
|
|
339
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
340
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
550
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
341
551
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
342
552
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
343
553
|
|
|
@@ -354,7 +564,7 @@ static VALUE rb_html_doctype_node_from_c_struct(AST_HTML_DOCTYPE_NODE_T* html_do
|
|
|
354
564
|
html_doctype_node_tag_closing
|
|
355
565
|
};
|
|
356
566
|
|
|
357
|
-
return rb_class_new_instance(6, args,
|
|
567
|
+
return rb_class_new_instance(6, args, cHTMLDoctypeNode);
|
|
358
568
|
};
|
|
359
569
|
|
|
360
570
|
static VALUE rb_xml_declaration_node_from_c_struct(AST_XML_DECLARATION_NODE_T* xml_declaration_node) {
|
|
@@ -362,13 +572,7 @@ static VALUE rb_xml_declaration_node_from_c_struct(AST_XML_DECLARATION_NODE_T* x
|
|
|
362
572
|
|
|
363
573
|
AST_NODE_T* node = &xml_declaration_node->base;
|
|
364
574
|
|
|
365
|
-
VALUE
|
|
366
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
367
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
368
|
-
VALUE XMLDeclarationNode = rb_define_class_under(AST, "XMLDeclarationNode", Node);
|
|
369
|
-
|
|
370
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
371
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
575
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
372
576
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
373
577
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
374
578
|
|
|
@@ -385,7 +589,7 @@ static VALUE rb_xml_declaration_node_from_c_struct(AST_XML_DECLARATION_NODE_T* x
|
|
|
385
589
|
xml_declaration_node_tag_closing
|
|
386
590
|
};
|
|
387
591
|
|
|
388
|
-
return rb_class_new_instance(6, args,
|
|
592
|
+
return rb_class_new_instance(6, args, cXMLDeclarationNode);
|
|
389
593
|
};
|
|
390
594
|
|
|
391
595
|
static VALUE rb_cdata_node_from_c_struct(AST_CDATA_NODE_T* cdata_node) {
|
|
@@ -393,13 +597,7 @@ static VALUE rb_cdata_node_from_c_struct(AST_CDATA_NODE_T* cdata_node) {
|
|
|
393
597
|
|
|
394
598
|
AST_NODE_T* node = &cdata_node->base;
|
|
395
599
|
|
|
396
|
-
VALUE
|
|
397
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
398
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
399
|
-
VALUE CDATANode = rb_define_class_under(AST, "CDATANode", Node);
|
|
400
|
-
|
|
401
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
402
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
600
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
403
601
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
404
602
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
405
603
|
|
|
@@ -416,7 +614,7 @@ static VALUE rb_cdata_node_from_c_struct(AST_CDATA_NODE_T* cdata_node) {
|
|
|
416
614
|
cdata_node_tag_closing
|
|
417
615
|
};
|
|
418
616
|
|
|
419
|
-
return rb_class_new_instance(6, args,
|
|
617
|
+
return rb_class_new_instance(6, args, cCDATANode);
|
|
420
618
|
};
|
|
421
619
|
|
|
422
620
|
static VALUE rb_whitespace_node_from_c_struct(AST_WHITESPACE_NODE_T* whitespace_node) {
|
|
@@ -424,13 +622,7 @@ static VALUE rb_whitespace_node_from_c_struct(AST_WHITESPACE_NODE_T* whitespace_
|
|
|
424
622
|
|
|
425
623
|
AST_NODE_T* node = &whitespace_node->base;
|
|
426
624
|
|
|
427
|
-
VALUE
|
|
428
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
429
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
430
|
-
VALUE WhitespaceNode = rb_define_class_under(AST, "WhitespaceNode", Node);
|
|
431
|
-
|
|
432
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
433
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
625
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
434
626
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
435
627
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
436
628
|
|
|
@@ -443,7 +635,7 @@ static VALUE rb_whitespace_node_from_c_struct(AST_WHITESPACE_NODE_T* whitespace_
|
|
|
443
635
|
whitespace_node_value
|
|
444
636
|
};
|
|
445
637
|
|
|
446
|
-
return rb_class_new_instance(4, args,
|
|
638
|
+
return rb_class_new_instance(4, args, cWhitespaceNode);
|
|
447
639
|
};
|
|
448
640
|
|
|
449
641
|
static VALUE rb_erb_content_node_from_c_struct(AST_ERB_CONTENT_NODE_T* erb_content_node) {
|
|
@@ -451,25 +643,35 @@ static VALUE rb_erb_content_node_from_c_struct(AST_ERB_CONTENT_NODE_T* erb_conte
|
|
|
451
643
|
|
|
452
644
|
AST_NODE_T* node = &erb_content_node->base;
|
|
453
645
|
|
|
454
|
-
VALUE
|
|
455
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
456
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
457
|
-
VALUE ERBContentNode = rb_define_class_under(AST, "ERBContentNode", Node);
|
|
458
|
-
|
|
459
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
460
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
646
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
461
647
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
462
648
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
463
649
|
|
|
464
650
|
VALUE erb_content_node_tag_opening = rb_token_from_c_struct(erb_content_node->tag_opening);
|
|
465
651
|
VALUE erb_content_node_content = rb_token_from_c_struct(erb_content_node->content);
|
|
466
652
|
VALUE erb_content_node_tag_closing = rb_token_from_c_struct(erb_content_node->tag_closing);
|
|
467
|
-
/*
|
|
653
|
+
/* analyzed_ruby is internal parser state, not exposed to Ruby */
|
|
468
654
|
VALUE erb_content_node_analyzed_ruby = Qnil;
|
|
469
655
|
VALUE erb_content_node_parsed = (erb_content_node->parsed) ? Qtrue : Qfalse;
|
|
470
656
|
VALUE erb_content_node_valid = (erb_content_node->valid) ? Qtrue : Qfalse;
|
|
657
|
+
VALUE erb_content_node_prism_node;
|
|
658
|
+
if (erb_content_node->prism_node.node != NULL && erb_content_node->prism_node.parser != NULL) {
|
|
659
|
+
pm_buffer_t pm_buffer = { 0 };
|
|
660
|
+
pm_serialize(erb_content_node->prism_node.parser, erb_content_node->prism_node.node, &pm_buffer);
|
|
661
|
+
|
|
662
|
+
if (pm_buffer.length > 0) {
|
|
663
|
+
erb_content_node_prism_node = rb_str_new(pm_buffer.value, pm_buffer.length);
|
|
664
|
+
rb_enc_associate(erb_content_node_prism_node, rb_ascii8bit_encoding());
|
|
665
|
+
OBJ_FREEZE(erb_content_node_prism_node);
|
|
666
|
+
} else {
|
|
667
|
+
erb_content_node_prism_node = Qnil;
|
|
668
|
+
}
|
|
669
|
+
pm_buffer_free(&pm_buffer);
|
|
670
|
+
} else {
|
|
671
|
+
erb_content_node_prism_node = Qnil;
|
|
672
|
+
}
|
|
471
673
|
|
|
472
|
-
VALUE args[
|
|
674
|
+
VALUE args[10] = {
|
|
473
675
|
type,
|
|
474
676
|
location,
|
|
475
677
|
errors,
|
|
@@ -478,10 +680,11 @@ static VALUE rb_erb_content_node_from_c_struct(AST_ERB_CONTENT_NODE_T* erb_conte
|
|
|
478
680
|
erb_content_node_tag_closing,
|
|
479
681
|
erb_content_node_analyzed_ruby,
|
|
480
682
|
erb_content_node_parsed,
|
|
481
|
-
erb_content_node_valid
|
|
683
|
+
erb_content_node_valid,
|
|
684
|
+
erb_content_node_prism_node
|
|
482
685
|
};
|
|
483
686
|
|
|
484
|
-
return rb_class_new_instance(
|
|
687
|
+
return rb_class_new_instance(10, args, cERBContentNode);
|
|
485
688
|
};
|
|
486
689
|
|
|
487
690
|
static VALUE rb_erb_end_node_from_c_struct(AST_ERB_END_NODE_T* erb_end_node) {
|
|
@@ -489,13 +692,7 @@ static VALUE rb_erb_end_node_from_c_struct(AST_ERB_END_NODE_T* erb_end_node) {
|
|
|
489
692
|
|
|
490
693
|
AST_NODE_T* node = &erb_end_node->base;
|
|
491
694
|
|
|
492
|
-
VALUE
|
|
493
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
494
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
495
|
-
VALUE ERBEndNode = rb_define_class_under(AST, "ERBEndNode", Node);
|
|
496
|
-
|
|
497
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
498
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
695
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
499
696
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
500
697
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
501
698
|
|
|
@@ -512,7 +709,7 @@ static VALUE rb_erb_end_node_from_c_struct(AST_ERB_END_NODE_T* erb_end_node) {
|
|
|
512
709
|
erb_end_node_tag_closing
|
|
513
710
|
};
|
|
514
711
|
|
|
515
|
-
return rb_class_new_instance(6, args,
|
|
712
|
+
return rb_class_new_instance(6, args, cERBEndNode);
|
|
516
713
|
};
|
|
517
714
|
|
|
518
715
|
static VALUE rb_erb_else_node_from_c_struct(AST_ERB_ELSE_NODE_T* erb_else_node) {
|
|
@@ -520,13 +717,7 @@ static VALUE rb_erb_else_node_from_c_struct(AST_ERB_ELSE_NODE_T* erb_else_node)
|
|
|
520
717
|
|
|
521
718
|
AST_NODE_T* node = &erb_else_node->base;
|
|
522
719
|
|
|
523
|
-
VALUE
|
|
524
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
525
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
526
|
-
VALUE ERBElseNode = rb_define_class_under(AST, "ERBElseNode", Node);
|
|
527
|
-
|
|
528
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
529
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
720
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
530
721
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
531
722
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
532
723
|
|
|
@@ -545,7 +736,7 @@ static VALUE rb_erb_else_node_from_c_struct(AST_ERB_ELSE_NODE_T* erb_else_node)
|
|
|
545
736
|
erb_else_node_statements
|
|
546
737
|
};
|
|
547
738
|
|
|
548
|
-
return rb_class_new_instance(7, args,
|
|
739
|
+
return rb_class_new_instance(7, args, cERBElseNode);
|
|
549
740
|
};
|
|
550
741
|
|
|
551
742
|
static VALUE rb_erb_if_node_from_c_struct(AST_ERB_IF_NODE_T* erb_if_node) {
|
|
@@ -553,13 +744,7 @@ static VALUE rb_erb_if_node_from_c_struct(AST_ERB_IF_NODE_T* erb_if_node) {
|
|
|
553
744
|
|
|
554
745
|
AST_NODE_T* node = &erb_if_node->base;
|
|
555
746
|
|
|
556
|
-
VALUE
|
|
557
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
558
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
559
|
-
VALUE ERBIfNode = rb_define_class_under(AST, "ERBIfNode", Node);
|
|
560
|
-
|
|
561
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
562
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
747
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
563
748
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
564
749
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
565
750
|
|
|
@@ -567,11 +752,27 @@ static VALUE rb_erb_if_node_from_c_struct(AST_ERB_IF_NODE_T* erb_if_node) {
|
|
|
567
752
|
VALUE erb_if_node_content = rb_token_from_c_struct(erb_if_node->content);
|
|
568
753
|
VALUE erb_if_node_tag_closing = rb_token_from_c_struct(erb_if_node->tag_closing);
|
|
569
754
|
VALUE erb_if_node_then_keyword = (erb_if_node->then_keyword != NULL) ? rb_location_from_c_struct(*erb_if_node->then_keyword) : Qnil;
|
|
755
|
+
VALUE erb_if_node_prism_node;
|
|
756
|
+
if (erb_if_node->prism_node.node != NULL && erb_if_node->prism_node.parser != NULL) {
|
|
757
|
+
pm_buffer_t pm_buffer = { 0 };
|
|
758
|
+
pm_serialize(erb_if_node->prism_node.parser, erb_if_node->prism_node.node, &pm_buffer);
|
|
759
|
+
|
|
760
|
+
if (pm_buffer.length > 0) {
|
|
761
|
+
erb_if_node_prism_node = rb_str_new(pm_buffer.value, pm_buffer.length);
|
|
762
|
+
rb_enc_associate(erb_if_node_prism_node, rb_ascii8bit_encoding());
|
|
763
|
+
OBJ_FREEZE(erb_if_node_prism_node);
|
|
764
|
+
} else {
|
|
765
|
+
erb_if_node_prism_node = Qnil;
|
|
766
|
+
}
|
|
767
|
+
pm_buffer_free(&pm_buffer);
|
|
768
|
+
} else {
|
|
769
|
+
erb_if_node_prism_node = Qnil;
|
|
770
|
+
}
|
|
570
771
|
VALUE erb_if_node_statements = rb_nodes_array_from_c_array(erb_if_node->statements);
|
|
571
772
|
VALUE erb_if_node_subsequent = rb_node_from_c_struct((AST_NODE_T*) erb_if_node->subsequent);
|
|
572
773
|
VALUE erb_if_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_if_node->end_node);
|
|
573
774
|
|
|
574
|
-
VALUE args[
|
|
775
|
+
VALUE args[11] = {
|
|
575
776
|
type,
|
|
576
777
|
location,
|
|
577
778
|
errors,
|
|
@@ -579,12 +780,13 @@ static VALUE rb_erb_if_node_from_c_struct(AST_ERB_IF_NODE_T* erb_if_node) {
|
|
|
579
780
|
erb_if_node_content,
|
|
580
781
|
erb_if_node_tag_closing,
|
|
581
782
|
erb_if_node_then_keyword,
|
|
783
|
+
erb_if_node_prism_node,
|
|
582
784
|
erb_if_node_statements,
|
|
583
785
|
erb_if_node_subsequent,
|
|
584
786
|
erb_if_node_end_node
|
|
585
787
|
};
|
|
586
788
|
|
|
587
|
-
return rb_class_new_instance(
|
|
789
|
+
return rb_class_new_instance(11, args, cERBIfNode);
|
|
588
790
|
};
|
|
589
791
|
|
|
590
792
|
static VALUE rb_erb_block_node_from_c_struct(AST_ERB_BLOCK_NODE_T* erb_block_node) {
|
|
@@ -592,34 +794,45 @@ static VALUE rb_erb_block_node_from_c_struct(AST_ERB_BLOCK_NODE_T* erb_block_nod
|
|
|
592
794
|
|
|
593
795
|
AST_NODE_T* node = &erb_block_node->base;
|
|
594
796
|
|
|
595
|
-
VALUE
|
|
596
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
597
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
598
|
-
VALUE ERBBlockNode = rb_define_class_under(AST, "ERBBlockNode", Node);
|
|
599
|
-
|
|
600
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
601
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
797
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
602
798
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
603
799
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
604
800
|
|
|
605
801
|
VALUE erb_block_node_tag_opening = rb_token_from_c_struct(erb_block_node->tag_opening);
|
|
606
802
|
VALUE erb_block_node_content = rb_token_from_c_struct(erb_block_node->content);
|
|
607
803
|
VALUE erb_block_node_tag_closing = rb_token_from_c_struct(erb_block_node->tag_closing);
|
|
804
|
+
VALUE erb_block_node_prism_node;
|
|
805
|
+
if (erb_block_node->prism_node.node != NULL && erb_block_node->prism_node.parser != NULL) {
|
|
806
|
+
pm_buffer_t pm_buffer = { 0 };
|
|
807
|
+
pm_serialize(erb_block_node->prism_node.parser, erb_block_node->prism_node.node, &pm_buffer);
|
|
808
|
+
|
|
809
|
+
if (pm_buffer.length > 0) {
|
|
810
|
+
erb_block_node_prism_node = rb_str_new(pm_buffer.value, pm_buffer.length);
|
|
811
|
+
rb_enc_associate(erb_block_node_prism_node, rb_ascii8bit_encoding());
|
|
812
|
+
OBJ_FREEZE(erb_block_node_prism_node);
|
|
813
|
+
} else {
|
|
814
|
+
erb_block_node_prism_node = Qnil;
|
|
815
|
+
}
|
|
816
|
+
pm_buffer_free(&pm_buffer);
|
|
817
|
+
} else {
|
|
818
|
+
erb_block_node_prism_node = Qnil;
|
|
819
|
+
}
|
|
608
820
|
VALUE erb_block_node_body = rb_nodes_array_from_c_array(erb_block_node->body);
|
|
609
821
|
VALUE erb_block_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_block_node->end_node);
|
|
610
822
|
|
|
611
|
-
VALUE args[
|
|
823
|
+
VALUE args[9] = {
|
|
612
824
|
type,
|
|
613
825
|
location,
|
|
614
826
|
errors,
|
|
615
827
|
erb_block_node_tag_opening,
|
|
616
828
|
erb_block_node_content,
|
|
617
829
|
erb_block_node_tag_closing,
|
|
830
|
+
erb_block_node_prism_node,
|
|
618
831
|
erb_block_node_body,
|
|
619
832
|
erb_block_node_end_node
|
|
620
833
|
};
|
|
621
834
|
|
|
622
|
-
return rb_class_new_instance(
|
|
835
|
+
return rb_class_new_instance(9, args, cERBBlockNode);
|
|
623
836
|
};
|
|
624
837
|
|
|
625
838
|
static VALUE rb_erb_when_node_from_c_struct(AST_ERB_WHEN_NODE_T* erb_when_node) {
|
|
@@ -627,13 +840,7 @@ static VALUE rb_erb_when_node_from_c_struct(AST_ERB_WHEN_NODE_T* erb_when_node)
|
|
|
627
840
|
|
|
628
841
|
AST_NODE_T* node = &erb_when_node->base;
|
|
629
842
|
|
|
630
|
-
VALUE
|
|
631
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
632
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
633
|
-
VALUE ERBWhenNode = rb_define_class_under(AST, "ERBWhenNode", Node);
|
|
634
|
-
|
|
635
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
636
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
843
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
637
844
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
638
845
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
639
846
|
|
|
@@ -654,7 +861,7 @@ static VALUE rb_erb_when_node_from_c_struct(AST_ERB_WHEN_NODE_T* erb_when_node)
|
|
|
654
861
|
erb_when_node_statements
|
|
655
862
|
};
|
|
656
863
|
|
|
657
|
-
return rb_class_new_instance(8, args,
|
|
864
|
+
return rb_class_new_instance(8, args, cERBWhenNode);
|
|
658
865
|
};
|
|
659
866
|
|
|
660
867
|
static VALUE rb_erb_case_node_from_c_struct(AST_ERB_CASE_NODE_T* erb_case_node) {
|
|
@@ -662,13 +869,7 @@ static VALUE rb_erb_case_node_from_c_struct(AST_ERB_CASE_NODE_T* erb_case_node)
|
|
|
662
869
|
|
|
663
870
|
AST_NODE_T* node = &erb_case_node->base;
|
|
664
871
|
|
|
665
|
-
VALUE
|
|
666
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
667
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
668
|
-
VALUE ERBCaseNode = rb_define_class_under(AST, "ERBCaseNode", Node);
|
|
669
|
-
|
|
670
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
671
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
872
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
672
873
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
673
874
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
674
875
|
|
|
@@ -676,11 +877,27 @@ static VALUE rb_erb_case_node_from_c_struct(AST_ERB_CASE_NODE_T* erb_case_node)
|
|
|
676
877
|
VALUE erb_case_node_content = rb_token_from_c_struct(erb_case_node->content);
|
|
677
878
|
VALUE erb_case_node_tag_closing = rb_token_from_c_struct(erb_case_node->tag_closing);
|
|
678
879
|
VALUE erb_case_node_children = rb_nodes_array_from_c_array(erb_case_node->children);
|
|
880
|
+
VALUE erb_case_node_prism_node;
|
|
881
|
+
if (erb_case_node->prism_node.node != NULL && erb_case_node->prism_node.parser != NULL) {
|
|
882
|
+
pm_buffer_t pm_buffer = { 0 };
|
|
883
|
+
pm_serialize(erb_case_node->prism_node.parser, erb_case_node->prism_node.node, &pm_buffer);
|
|
884
|
+
|
|
885
|
+
if (pm_buffer.length > 0) {
|
|
886
|
+
erb_case_node_prism_node = rb_str_new(pm_buffer.value, pm_buffer.length);
|
|
887
|
+
rb_enc_associate(erb_case_node_prism_node, rb_ascii8bit_encoding());
|
|
888
|
+
OBJ_FREEZE(erb_case_node_prism_node);
|
|
889
|
+
} else {
|
|
890
|
+
erb_case_node_prism_node = Qnil;
|
|
891
|
+
}
|
|
892
|
+
pm_buffer_free(&pm_buffer);
|
|
893
|
+
} else {
|
|
894
|
+
erb_case_node_prism_node = Qnil;
|
|
895
|
+
}
|
|
679
896
|
VALUE erb_case_node_conditions = rb_nodes_array_from_c_array(erb_case_node->conditions);
|
|
680
897
|
VALUE erb_case_node_else_clause = rb_node_from_c_struct((AST_NODE_T*) erb_case_node->else_clause);
|
|
681
898
|
VALUE erb_case_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_case_node->end_node);
|
|
682
899
|
|
|
683
|
-
VALUE args[
|
|
900
|
+
VALUE args[11] = {
|
|
684
901
|
type,
|
|
685
902
|
location,
|
|
686
903
|
errors,
|
|
@@ -688,12 +905,13 @@ static VALUE rb_erb_case_node_from_c_struct(AST_ERB_CASE_NODE_T* erb_case_node)
|
|
|
688
905
|
erb_case_node_content,
|
|
689
906
|
erb_case_node_tag_closing,
|
|
690
907
|
erb_case_node_children,
|
|
908
|
+
erb_case_node_prism_node,
|
|
691
909
|
erb_case_node_conditions,
|
|
692
910
|
erb_case_node_else_clause,
|
|
693
911
|
erb_case_node_end_node
|
|
694
912
|
};
|
|
695
913
|
|
|
696
|
-
return rb_class_new_instance(
|
|
914
|
+
return rb_class_new_instance(11, args, cERBCaseNode);
|
|
697
915
|
};
|
|
698
916
|
|
|
699
917
|
static VALUE rb_erb_case_match_node_from_c_struct(AST_ERB_CASE_MATCH_NODE_T* erb_case_match_node) {
|
|
@@ -701,13 +919,7 @@ static VALUE rb_erb_case_match_node_from_c_struct(AST_ERB_CASE_MATCH_NODE_T* erb
|
|
|
701
919
|
|
|
702
920
|
AST_NODE_T* node = &erb_case_match_node->base;
|
|
703
921
|
|
|
704
|
-
VALUE
|
|
705
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
706
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
707
|
-
VALUE ERBCaseMatchNode = rb_define_class_under(AST, "ERBCaseMatchNode", Node);
|
|
708
|
-
|
|
709
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
710
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
922
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
711
923
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
712
924
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
713
925
|
|
|
@@ -715,11 +927,27 @@ static VALUE rb_erb_case_match_node_from_c_struct(AST_ERB_CASE_MATCH_NODE_T* erb
|
|
|
715
927
|
VALUE erb_case_match_node_content = rb_token_from_c_struct(erb_case_match_node->content);
|
|
716
928
|
VALUE erb_case_match_node_tag_closing = rb_token_from_c_struct(erb_case_match_node->tag_closing);
|
|
717
929
|
VALUE erb_case_match_node_children = rb_nodes_array_from_c_array(erb_case_match_node->children);
|
|
930
|
+
VALUE erb_case_match_node_prism_node;
|
|
931
|
+
if (erb_case_match_node->prism_node.node != NULL && erb_case_match_node->prism_node.parser != NULL) {
|
|
932
|
+
pm_buffer_t pm_buffer = { 0 };
|
|
933
|
+
pm_serialize(erb_case_match_node->prism_node.parser, erb_case_match_node->prism_node.node, &pm_buffer);
|
|
934
|
+
|
|
935
|
+
if (pm_buffer.length > 0) {
|
|
936
|
+
erb_case_match_node_prism_node = rb_str_new(pm_buffer.value, pm_buffer.length);
|
|
937
|
+
rb_enc_associate(erb_case_match_node_prism_node, rb_ascii8bit_encoding());
|
|
938
|
+
OBJ_FREEZE(erb_case_match_node_prism_node);
|
|
939
|
+
} else {
|
|
940
|
+
erb_case_match_node_prism_node = Qnil;
|
|
941
|
+
}
|
|
942
|
+
pm_buffer_free(&pm_buffer);
|
|
943
|
+
} else {
|
|
944
|
+
erb_case_match_node_prism_node = Qnil;
|
|
945
|
+
}
|
|
718
946
|
VALUE erb_case_match_node_conditions = rb_nodes_array_from_c_array(erb_case_match_node->conditions);
|
|
719
947
|
VALUE erb_case_match_node_else_clause = rb_node_from_c_struct((AST_NODE_T*) erb_case_match_node->else_clause);
|
|
720
948
|
VALUE erb_case_match_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_case_match_node->end_node);
|
|
721
949
|
|
|
722
|
-
VALUE args[
|
|
950
|
+
VALUE args[11] = {
|
|
723
951
|
type,
|
|
724
952
|
location,
|
|
725
953
|
errors,
|
|
@@ -727,12 +955,13 @@ static VALUE rb_erb_case_match_node_from_c_struct(AST_ERB_CASE_MATCH_NODE_T* erb
|
|
|
727
955
|
erb_case_match_node_content,
|
|
728
956
|
erb_case_match_node_tag_closing,
|
|
729
957
|
erb_case_match_node_children,
|
|
958
|
+
erb_case_match_node_prism_node,
|
|
730
959
|
erb_case_match_node_conditions,
|
|
731
960
|
erb_case_match_node_else_clause,
|
|
732
961
|
erb_case_match_node_end_node
|
|
733
962
|
};
|
|
734
963
|
|
|
735
|
-
return rb_class_new_instance(
|
|
964
|
+
return rb_class_new_instance(11, args, cERBCaseMatchNode);
|
|
736
965
|
};
|
|
737
966
|
|
|
738
967
|
static VALUE rb_erb_while_node_from_c_struct(AST_ERB_WHILE_NODE_T* erb_while_node) {
|
|
@@ -740,34 +969,45 @@ static VALUE rb_erb_while_node_from_c_struct(AST_ERB_WHILE_NODE_T* erb_while_nod
|
|
|
740
969
|
|
|
741
970
|
AST_NODE_T* node = &erb_while_node->base;
|
|
742
971
|
|
|
743
|
-
VALUE
|
|
744
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
745
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
746
|
-
VALUE ERBWhileNode = rb_define_class_under(AST, "ERBWhileNode", Node);
|
|
747
|
-
|
|
748
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
749
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
972
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
750
973
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
751
974
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
752
975
|
|
|
753
976
|
VALUE erb_while_node_tag_opening = rb_token_from_c_struct(erb_while_node->tag_opening);
|
|
754
977
|
VALUE erb_while_node_content = rb_token_from_c_struct(erb_while_node->content);
|
|
755
978
|
VALUE erb_while_node_tag_closing = rb_token_from_c_struct(erb_while_node->tag_closing);
|
|
979
|
+
VALUE erb_while_node_prism_node;
|
|
980
|
+
if (erb_while_node->prism_node.node != NULL && erb_while_node->prism_node.parser != NULL) {
|
|
981
|
+
pm_buffer_t pm_buffer = { 0 };
|
|
982
|
+
pm_serialize(erb_while_node->prism_node.parser, erb_while_node->prism_node.node, &pm_buffer);
|
|
983
|
+
|
|
984
|
+
if (pm_buffer.length > 0) {
|
|
985
|
+
erb_while_node_prism_node = rb_str_new(pm_buffer.value, pm_buffer.length);
|
|
986
|
+
rb_enc_associate(erb_while_node_prism_node, rb_ascii8bit_encoding());
|
|
987
|
+
OBJ_FREEZE(erb_while_node_prism_node);
|
|
988
|
+
} else {
|
|
989
|
+
erb_while_node_prism_node = Qnil;
|
|
990
|
+
}
|
|
991
|
+
pm_buffer_free(&pm_buffer);
|
|
992
|
+
} else {
|
|
993
|
+
erb_while_node_prism_node = Qnil;
|
|
994
|
+
}
|
|
756
995
|
VALUE erb_while_node_statements = rb_nodes_array_from_c_array(erb_while_node->statements);
|
|
757
996
|
VALUE erb_while_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_while_node->end_node);
|
|
758
997
|
|
|
759
|
-
VALUE args[
|
|
998
|
+
VALUE args[9] = {
|
|
760
999
|
type,
|
|
761
1000
|
location,
|
|
762
1001
|
errors,
|
|
763
1002
|
erb_while_node_tag_opening,
|
|
764
1003
|
erb_while_node_content,
|
|
765
1004
|
erb_while_node_tag_closing,
|
|
1005
|
+
erb_while_node_prism_node,
|
|
766
1006
|
erb_while_node_statements,
|
|
767
1007
|
erb_while_node_end_node
|
|
768
1008
|
};
|
|
769
1009
|
|
|
770
|
-
return rb_class_new_instance(
|
|
1010
|
+
return rb_class_new_instance(9, args, cERBWhileNode);
|
|
771
1011
|
};
|
|
772
1012
|
|
|
773
1013
|
static VALUE rb_erb_until_node_from_c_struct(AST_ERB_UNTIL_NODE_T* erb_until_node) {
|
|
@@ -775,34 +1015,45 @@ static VALUE rb_erb_until_node_from_c_struct(AST_ERB_UNTIL_NODE_T* erb_until_nod
|
|
|
775
1015
|
|
|
776
1016
|
AST_NODE_T* node = &erb_until_node->base;
|
|
777
1017
|
|
|
778
|
-
VALUE
|
|
779
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
780
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
781
|
-
VALUE ERBUntilNode = rb_define_class_under(AST, "ERBUntilNode", Node);
|
|
782
|
-
|
|
783
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
784
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
1018
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
785
1019
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
786
1020
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
787
1021
|
|
|
788
1022
|
VALUE erb_until_node_tag_opening = rb_token_from_c_struct(erb_until_node->tag_opening);
|
|
789
1023
|
VALUE erb_until_node_content = rb_token_from_c_struct(erb_until_node->content);
|
|
790
1024
|
VALUE erb_until_node_tag_closing = rb_token_from_c_struct(erb_until_node->tag_closing);
|
|
1025
|
+
VALUE erb_until_node_prism_node;
|
|
1026
|
+
if (erb_until_node->prism_node.node != NULL && erb_until_node->prism_node.parser != NULL) {
|
|
1027
|
+
pm_buffer_t pm_buffer = { 0 };
|
|
1028
|
+
pm_serialize(erb_until_node->prism_node.parser, erb_until_node->prism_node.node, &pm_buffer);
|
|
1029
|
+
|
|
1030
|
+
if (pm_buffer.length > 0) {
|
|
1031
|
+
erb_until_node_prism_node = rb_str_new(pm_buffer.value, pm_buffer.length);
|
|
1032
|
+
rb_enc_associate(erb_until_node_prism_node, rb_ascii8bit_encoding());
|
|
1033
|
+
OBJ_FREEZE(erb_until_node_prism_node);
|
|
1034
|
+
} else {
|
|
1035
|
+
erb_until_node_prism_node = Qnil;
|
|
1036
|
+
}
|
|
1037
|
+
pm_buffer_free(&pm_buffer);
|
|
1038
|
+
} else {
|
|
1039
|
+
erb_until_node_prism_node = Qnil;
|
|
1040
|
+
}
|
|
791
1041
|
VALUE erb_until_node_statements = rb_nodes_array_from_c_array(erb_until_node->statements);
|
|
792
1042
|
VALUE erb_until_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_until_node->end_node);
|
|
793
1043
|
|
|
794
|
-
VALUE args[
|
|
1044
|
+
VALUE args[9] = {
|
|
795
1045
|
type,
|
|
796
1046
|
location,
|
|
797
1047
|
errors,
|
|
798
1048
|
erb_until_node_tag_opening,
|
|
799
1049
|
erb_until_node_content,
|
|
800
1050
|
erb_until_node_tag_closing,
|
|
1051
|
+
erb_until_node_prism_node,
|
|
801
1052
|
erb_until_node_statements,
|
|
802
1053
|
erb_until_node_end_node
|
|
803
1054
|
};
|
|
804
1055
|
|
|
805
|
-
return rb_class_new_instance(
|
|
1056
|
+
return rb_class_new_instance(9, args, cERBUntilNode);
|
|
806
1057
|
};
|
|
807
1058
|
|
|
808
1059
|
static VALUE rb_erb_for_node_from_c_struct(AST_ERB_FOR_NODE_T* erb_for_node) {
|
|
@@ -810,34 +1061,45 @@ static VALUE rb_erb_for_node_from_c_struct(AST_ERB_FOR_NODE_T* erb_for_node) {
|
|
|
810
1061
|
|
|
811
1062
|
AST_NODE_T* node = &erb_for_node->base;
|
|
812
1063
|
|
|
813
|
-
VALUE
|
|
814
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
815
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
816
|
-
VALUE ERBForNode = rb_define_class_under(AST, "ERBForNode", Node);
|
|
817
|
-
|
|
818
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
819
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
1064
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
820
1065
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
821
1066
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
822
1067
|
|
|
823
1068
|
VALUE erb_for_node_tag_opening = rb_token_from_c_struct(erb_for_node->tag_opening);
|
|
824
1069
|
VALUE erb_for_node_content = rb_token_from_c_struct(erb_for_node->content);
|
|
825
1070
|
VALUE erb_for_node_tag_closing = rb_token_from_c_struct(erb_for_node->tag_closing);
|
|
1071
|
+
VALUE erb_for_node_prism_node;
|
|
1072
|
+
if (erb_for_node->prism_node.node != NULL && erb_for_node->prism_node.parser != NULL) {
|
|
1073
|
+
pm_buffer_t pm_buffer = { 0 };
|
|
1074
|
+
pm_serialize(erb_for_node->prism_node.parser, erb_for_node->prism_node.node, &pm_buffer);
|
|
1075
|
+
|
|
1076
|
+
if (pm_buffer.length > 0) {
|
|
1077
|
+
erb_for_node_prism_node = rb_str_new(pm_buffer.value, pm_buffer.length);
|
|
1078
|
+
rb_enc_associate(erb_for_node_prism_node, rb_ascii8bit_encoding());
|
|
1079
|
+
OBJ_FREEZE(erb_for_node_prism_node);
|
|
1080
|
+
} else {
|
|
1081
|
+
erb_for_node_prism_node = Qnil;
|
|
1082
|
+
}
|
|
1083
|
+
pm_buffer_free(&pm_buffer);
|
|
1084
|
+
} else {
|
|
1085
|
+
erb_for_node_prism_node = Qnil;
|
|
1086
|
+
}
|
|
826
1087
|
VALUE erb_for_node_statements = rb_nodes_array_from_c_array(erb_for_node->statements);
|
|
827
1088
|
VALUE erb_for_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_for_node->end_node);
|
|
828
1089
|
|
|
829
|
-
VALUE args[
|
|
1090
|
+
VALUE args[9] = {
|
|
830
1091
|
type,
|
|
831
1092
|
location,
|
|
832
1093
|
errors,
|
|
833
1094
|
erb_for_node_tag_opening,
|
|
834
1095
|
erb_for_node_content,
|
|
835
1096
|
erb_for_node_tag_closing,
|
|
1097
|
+
erb_for_node_prism_node,
|
|
836
1098
|
erb_for_node_statements,
|
|
837
1099
|
erb_for_node_end_node
|
|
838
1100
|
};
|
|
839
1101
|
|
|
840
|
-
return rb_class_new_instance(
|
|
1102
|
+
return rb_class_new_instance(9, args, cERBForNode);
|
|
841
1103
|
};
|
|
842
1104
|
|
|
843
1105
|
static VALUE rb_erb_rescue_node_from_c_struct(AST_ERB_RESCUE_NODE_T* erb_rescue_node) {
|
|
@@ -845,13 +1107,7 @@ static VALUE rb_erb_rescue_node_from_c_struct(AST_ERB_RESCUE_NODE_T* erb_rescue_
|
|
|
845
1107
|
|
|
846
1108
|
AST_NODE_T* node = &erb_rescue_node->base;
|
|
847
1109
|
|
|
848
|
-
VALUE
|
|
849
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
850
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
851
|
-
VALUE ERBRescueNode = rb_define_class_under(AST, "ERBRescueNode", Node);
|
|
852
|
-
|
|
853
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
854
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
1110
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
855
1111
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
856
1112
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
857
1113
|
|
|
@@ -872,7 +1128,7 @@ static VALUE rb_erb_rescue_node_from_c_struct(AST_ERB_RESCUE_NODE_T* erb_rescue_
|
|
|
872
1128
|
erb_rescue_node_subsequent
|
|
873
1129
|
};
|
|
874
1130
|
|
|
875
|
-
return rb_class_new_instance(8, args,
|
|
1131
|
+
return rb_class_new_instance(8, args, cERBRescueNode);
|
|
876
1132
|
};
|
|
877
1133
|
|
|
878
1134
|
static VALUE rb_erb_ensure_node_from_c_struct(AST_ERB_ENSURE_NODE_T* erb_ensure_node) {
|
|
@@ -880,13 +1136,7 @@ static VALUE rb_erb_ensure_node_from_c_struct(AST_ERB_ENSURE_NODE_T* erb_ensure_
|
|
|
880
1136
|
|
|
881
1137
|
AST_NODE_T* node = &erb_ensure_node->base;
|
|
882
1138
|
|
|
883
|
-
VALUE
|
|
884
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
885
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
886
|
-
VALUE ERBEnsureNode = rb_define_class_under(AST, "ERBEnsureNode", Node);
|
|
887
|
-
|
|
888
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
889
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
1139
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
890
1140
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
891
1141
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
892
1142
|
|
|
@@ -905,7 +1155,7 @@ static VALUE rb_erb_ensure_node_from_c_struct(AST_ERB_ENSURE_NODE_T* erb_ensure_
|
|
|
905
1155
|
erb_ensure_node_statements
|
|
906
1156
|
};
|
|
907
1157
|
|
|
908
|
-
return rb_class_new_instance(7, args,
|
|
1158
|
+
return rb_class_new_instance(7, args, cERBEnsureNode);
|
|
909
1159
|
};
|
|
910
1160
|
|
|
911
1161
|
static VALUE rb_erb_begin_node_from_c_struct(AST_ERB_BEGIN_NODE_T* erb_begin_node) {
|
|
@@ -913,32 +1163,43 @@ static VALUE rb_erb_begin_node_from_c_struct(AST_ERB_BEGIN_NODE_T* erb_begin_nod
|
|
|
913
1163
|
|
|
914
1164
|
AST_NODE_T* node = &erb_begin_node->base;
|
|
915
1165
|
|
|
916
|
-
VALUE
|
|
917
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
918
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
919
|
-
VALUE ERBBeginNode = rb_define_class_under(AST, "ERBBeginNode", Node);
|
|
920
|
-
|
|
921
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
922
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
1166
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
923
1167
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
924
1168
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
925
1169
|
|
|
926
1170
|
VALUE erb_begin_node_tag_opening = rb_token_from_c_struct(erb_begin_node->tag_opening);
|
|
927
1171
|
VALUE erb_begin_node_content = rb_token_from_c_struct(erb_begin_node->content);
|
|
928
1172
|
VALUE erb_begin_node_tag_closing = rb_token_from_c_struct(erb_begin_node->tag_closing);
|
|
1173
|
+
VALUE erb_begin_node_prism_node;
|
|
1174
|
+
if (erb_begin_node->prism_node.node != NULL && erb_begin_node->prism_node.parser != NULL) {
|
|
1175
|
+
pm_buffer_t pm_buffer = { 0 };
|
|
1176
|
+
pm_serialize(erb_begin_node->prism_node.parser, erb_begin_node->prism_node.node, &pm_buffer);
|
|
1177
|
+
|
|
1178
|
+
if (pm_buffer.length > 0) {
|
|
1179
|
+
erb_begin_node_prism_node = rb_str_new(pm_buffer.value, pm_buffer.length);
|
|
1180
|
+
rb_enc_associate(erb_begin_node_prism_node, rb_ascii8bit_encoding());
|
|
1181
|
+
OBJ_FREEZE(erb_begin_node_prism_node);
|
|
1182
|
+
} else {
|
|
1183
|
+
erb_begin_node_prism_node = Qnil;
|
|
1184
|
+
}
|
|
1185
|
+
pm_buffer_free(&pm_buffer);
|
|
1186
|
+
} else {
|
|
1187
|
+
erb_begin_node_prism_node = Qnil;
|
|
1188
|
+
}
|
|
929
1189
|
VALUE erb_begin_node_statements = rb_nodes_array_from_c_array(erb_begin_node->statements);
|
|
930
1190
|
VALUE erb_begin_node_rescue_clause = rb_node_from_c_struct((AST_NODE_T*) erb_begin_node->rescue_clause);
|
|
931
1191
|
VALUE erb_begin_node_else_clause = rb_node_from_c_struct((AST_NODE_T*) erb_begin_node->else_clause);
|
|
932
1192
|
VALUE erb_begin_node_ensure_clause = rb_node_from_c_struct((AST_NODE_T*) erb_begin_node->ensure_clause);
|
|
933
1193
|
VALUE erb_begin_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_begin_node->end_node);
|
|
934
1194
|
|
|
935
|
-
VALUE args[
|
|
1195
|
+
VALUE args[12] = {
|
|
936
1196
|
type,
|
|
937
1197
|
location,
|
|
938
1198
|
errors,
|
|
939
1199
|
erb_begin_node_tag_opening,
|
|
940
1200
|
erb_begin_node_content,
|
|
941
1201
|
erb_begin_node_tag_closing,
|
|
1202
|
+
erb_begin_node_prism_node,
|
|
942
1203
|
erb_begin_node_statements,
|
|
943
1204
|
erb_begin_node_rescue_clause,
|
|
944
1205
|
erb_begin_node_else_clause,
|
|
@@ -946,7 +1207,7 @@ static VALUE rb_erb_begin_node_from_c_struct(AST_ERB_BEGIN_NODE_T* erb_begin_nod
|
|
|
946
1207
|
erb_begin_node_end_node
|
|
947
1208
|
};
|
|
948
1209
|
|
|
949
|
-
return rb_class_new_instance(
|
|
1210
|
+
return rb_class_new_instance(12, args, cERBBeginNode);
|
|
950
1211
|
};
|
|
951
1212
|
|
|
952
1213
|
static VALUE rb_erb_unless_node_from_c_struct(AST_ERB_UNLESS_NODE_T* erb_unless_node) {
|
|
@@ -954,13 +1215,7 @@ static VALUE rb_erb_unless_node_from_c_struct(AST_ERB_UNLESS_NODE_T* erb_unless_
|
|
|
954
1215
|
|
|
955
1216
|
AST_NODE_T* node = &erb_unless_node->base;
|
|
956
1217
|
|
|
957
|
-
VALUE
|
|
958
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
959
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
960
|
-
VALUE ERBUnlessNode = rb_define_class_under(AST, "ERBUnlessNode", Node);
|
|
961
|
-
|
|
962
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
963
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
1218
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
964
1219
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
965
1220
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
966
1221
|
|
|
@@ -968,11 +1223,27 @@ static VALUE rb_erb_unless_node_from_c_struct(AST_ERB_UNLESS_NODE_T* erb_unless_
|
|
|
968
1223
|
VALUE erb_unless_node_content = rb_token_from_c_struct(erb_unless_node->content);
|
|
969
1224
|
VALUE erb_unless_node_tag_closing = rb_token_from_c_struct(erb_unless_node->tag_closing);
|
|
970
1225
|
VALUE erb_unless_node_then_keyword = (erb_unless_node->then_keyword != NULL) ? rb_location_from_c_struct(*erb_unless_node->then_keyword) : Qnil;
|
|
1226
|
+
VALUE erb_unless_node_prism_node;
|
|
1227
|
+
if (erb_unless_node->prism_node.node != NULL && erb_unless_node->prism_node.parser != NULL) {
|
|
1228
|
+
pm_buffer_t pm_buffer = { 0 };
|
|
1229
|
+
pm_serialize(erb_unless_node->prism_node.parser, erb_unless_node->prism_node.node, &pm_buffer);
|
|
1230
|
+
|
|
1231
|
+
if (pm_buffer.length > 0) {
|
|
1232
|
+
erb_unless_node_prism_node = rb_str_new(pm_buffer.value, pm_buffer.length);
|
|
1233
|
+
rb_enc_associate(erb_unless_node_prism_node, rb_ascii8bit_encoding());
|
|
1234
|
+
OBJ_FREEZE(erb_unless_node_prism_node);
|
|
1235
|
+
} else {
|
|
1236
|
+
erb_unless_node_prism_node = Qnil;
|
|
1237
|
+
}
|
|
1238
|
+
pm_buffer_free(&pm_buffer);
|
|
1239
|
+
} else {
|
|
1240
|
+
erb_unless_node_prism_node = Qnil;
|
|
1241
|
+
}
|
|
971
1242
|
VALUE erb_unless_node_statements = rb_nodes_array_from_c_array(erb_unless_node->statements);
|
|
972
1243
|
VALUE erb_unless_node_else_clause = rb_node_from_c_struct((AST_NODE_T*) erb_unless_node->else_clause);
|
|
973
1244
|
VALUE erb_unless_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_unless_node->end_node);
|
|
974
1245
|
|
|
975
|
-
VALUE args[
|
|
1246
|
+
VALUE args[11] = {
|
|
976
1247
|
type,
|
|
977
1248
|
location,
|
|
978
1249
|
errors,
|
|
@@ -980,12 +1251,13 @@ static VALUE rb_erb_unless_node_from_c_struct(AST_ERB_UNLESS_NODE_T* erb_unless_
|
|
|
980
1251
|
erb_unless_node_content,
|
|
981
1252
|
erb_unless_node_tag_closing,
|
|
982
1253
|
erb_unless_node_then_keyword,
|
|
1254
|
+
erb_unless_node_prism_node,
|
|
983
1255
|
erb_unless_node_statements,
|
|
984
1256
|
erb_unless_node_else_clause,
|
|
985
1257
|
erb_unless_node_end_node
|
|
986
1258
|
};
|
|
987
1259
|
|
|
988
|
-
return rb_class_new_instance(
|
|
1260
|
+
return rb_class_new_instance(11, args, cERBUnlessNode);
|
|
989
1261
|
};
|
|
990
1262
|
|
|
991
1263
|
static VALUE rb_erb_yield_node_from_c_struct(AST_ERB_YIELD_NODE_T* erb_yield_node) {
|
|
@@ -993,13 +1265,7 @@ static VALUE rb_erb_yield_node_from_c_struct(AST_ERB_YIELD_NODE_T* erb_yield_nod
|
|
|
993
1265
|
|
|
994
1266
|
AST_NODE_T* node = &erb_yield_node->base;
|
|
995
1267
|
|
|
996
|
-
VALUE
|
|
997
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
998
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
999
|
-
VALUE ERBYieldNode = rb_define_class_under(AST, "ERBYieldNode", Node);
|
|
1000
|
-
|
|
1001
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
1002
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
1268
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
1003
1269
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
1004
1270
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
1005
1271
|
|
|
@@ -1016,7 +1282,7 @@ static VALUE rb_erb_yield_node_from_c_struct(AST_ERB_YIELD_NODE_T* erb_yield_nod
|
|
|
1016
1282
|
erb_yield_node_tag_closing
|
|
1017
1283
|
};
|
|
1018
1284
|
|
|
1019
|
-
return rb_class_new_instance(6, args,
|
|
1285
|
+
return rb_class_new_instance(6, args, cERBYieldNode);
|
|
1020
1286
|
};
|
|
1021
1287
|
|
|
1022
1288
|
static VALUE rb_erb_in_node_from_c_struct(AST_ERB_IN_NODE_T* erb_in_node) {
|
|
@@ -1024,13 +1290,7 @@ static VALUE rb_erb_in_node_from_c_struct(AST_ERB_IN_NODE_T* erb_in_node) {
|
|
|
1024
1290
|
|
|
1025
1291
|
AST_NODE_T* node = &erb_in_node->base;
|
|
1026
1292
|
|
|
1027
|
-
VALUE
|
|
1028
|
-
VALUE AST = rb_define_module_under(Herb, "AST");
|
|
1029
|
-
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
|
1030
|
-
VALUE ERBInNode = rb_define_class_under(AST, "ERBInNode", Node);
|
|
1031
|
-
|
|
1032
|
-
hb_string_T node_type = ast_node_type_to_string(node);
|
|
1033
|
-
VALUE type = rb_utf8_str_new(node_type.data, node_type.length);
|
|
1293
|
+
VALUE type = rb_string_from_hb_string(ast_node_type_to_string(node));
|
|
1034
1294
|
VALUE location = rb_location_from_c_struct(node->location);
|
|
1035
1295
|
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
|
1036
1296
|
|
|
@@ -1051,7 +1311,7 @@ static VALUE rb_erb_in_node_from_c_struct(AST_ERB_IN_NODE_T* erb_in_node) {
|
|
|
1051
1311
|
erb_in_node_statements
|
|
1052
1312
|
};
|
|
1053
1313
|
|
|
1054
|
-
return rb_class_new_instance(8, args,
|
|
1314
|
+
return rb_class_new_instance(8, args, cERBInNode);
|
|
1055
1315
|
};
|
|
1056
1316
|
|
|
1057
1317
|
|
|
@@ -1062,11 +1322,18 @@ VALUE rb_node_from_c_struct(AST_NODE_T* node) {
|
|
|
1062
1322
|
case AST_DOCUMENT_NODE: return rb_document_node_from_c_struct((AST_DOCUMENT_NODE_T*) node); break;
|
|
1063
1323
|
case AST_LITERAL_NODE: return rb_literal_node_from_c_struct((AST_LITERAL_NODE_T*) node); break;
|
|
1064
1324
|
case AST_HTML_OPEN_TAG_NODE: return rb_html_open_tag_node_from_c_struct((AST_HTML_OPEN_TAG_NODE_T*) node); break;
|
|
1325
|
+
case AST_HTML_CONDITIONAL_OPEN_TAG_NODE: return rb_html_conditional_open_tag_node_from_c_struct((AST_HTML_CONDITIONAL_OPEN_TAG_NODE_T*) node); break;
|
|
1065
1326
|
case AST_HTML_CLOSE_TAG_NODE: return rb_html_close_tag_node_from_c_struct((AST_HTML_CLOSE_TAG_NODE_T*) node); break;
|
|
1327
|
+
case AST_HTML_OMITTED_CLOSE_TAG_NODE: return rb_html_omitted_close_tag_node_from_c_struct((AST_HTML_OMITTED_CLOSE_TAG_NODE_T*) node); break;
|
|
1328
|
+
case AST_HTML_VIRTUAL_CLOSE_TAG_NODE: return rb_html_virtual_close_tag_node_from_c_struct((AST_HTML_VIRTUAL_CLOSE_TAG_NODE_T*) node); break;
|
|
1066
1329
|
case AST_HTML_ELEMENT_NODE: return rb_html_element_node_from_c_struct((AST_HTML_ELEMENT_NODE_T*) node); break;
|
|
1330
|
+
case AST_HTML_CONDITIONAL_ELEMENT_NODE: return rb_html_conditional_element_node_from_c_struct((AST_HTML_CONDITIONAL_ELEMENT_NODE_T*) node); break;
|
|
1067
1331
|
case AST_HTML_ATTRIBUTE_VALUE_NODE: return rb_html_attribute_value_node_from_c_struct((AST_HTML_ATTRIBUTE_VALUE_NODE_T*) node); break;
|
|
1068
1332
|
case AST_HTML_ATTRIBUTE_NAME_NODE: return rb_html_attribute_name_node_from_c_struct((AST_HTML_ATTRIBUTE_NAME_NODE_T*) node); break;
|
|
1069
1333
|
case AST_HTML_ATTRIBUTE_NODE: return rb_html_attribute_node_from_c_struct((AST_HTML_ATTRIBUTE_NODE_T*) node); break;
|
|
1334
|
+
case AST_RUBY_LITERAL_NODE: return rb_ruby_literal_node_from_c_struct((AST_RUBY_LITERAL_NODE_T*) node); break;
|
|
1335
|
+
case AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE: return rb_ruby_html_attributes_splat_node_from_c_struct((AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE_T*) node); break;
|
|
1336
|
+
case AST_ERB_OPEN_TAG_NODE: return rb_erb_open_tag_node_from_c_struct((AST_ERB_OPEN_TAG_NODE_T*) node); break;
|
|
1070
1337
|
case AST_HTML_TEXT_NODE: return rb_html_text_node_from_c_struct((AST_HTML_TEXT_NODE_T*) node); break;
|
|
1071
1338
|
case AST_HTML_COMMENT_NODE: return rb_html_comment_node_from_c_struct((AST_HTML_COMMENT_NODE_T*) node); break;
|
|
1072
1339
|
case AST_HTML_DOCTYPE_NODE: return rb_html_doctype_node_from_c_struct((AST_HTML_DOCTYPE_NODE_T*) node); break;
|