@herb-tools/node 0.8.1 → 0.8.2
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/dist/herb-node.esm.js +1 -1
- package/extension/error_helpers.cpp +1 -1
- package/extension/error_helpers.h +1 -1
- package/extension/libherb/analyze.c +5 -5
- package/extension/libherb/analyze_missing_end.c +1 -1
- package/extension/libherb/analyze_transform.c +1 -1
- package/extension/libherb/ast_nodes.c +1 -1
- package/extension/libherb/ast_nodes.h +1 -1
- package/extension/libherb/ast_pretty_print.c +1 -1
- package/extension/libherb/ast_pretty_print.h +1 -1
- package/extension/libherb/errors.c +1 -1
- package/extension/libherb/errors.h +1 -1
- package/extension/libherb/include/ast_nodes.h +1 -1
- package/extension/libherb/include/ast_pretty_print.h +1 -1
- package/extension/libherb/include/errors.h +1 -1
- package/extension/libherb/include/util/hb_buffer.h +3 -0
- package/extension/libherb/include/version.h +1 -1
- package/extension/libherb/parser.c +2 -2
- package/extension/libherb/parser_match_tags.c +1 -1
- package/extension/libherb/util/hb_buffer.c +18 -1
- package/extension/libherb/util/hb_buffer.h +3 -0
- package/extension/libherb/version.h +1 -1
- package/extension/libherb/visitor.c +1 -1
- package/extension/nodes.cpp +1 -1
- package/extension/nodes.h +1 -1
- package/package.json +2 -2
package/dist/herb-node.esm.js
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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/javascript/packages/node/extension/error_helpers.cpp.erb
|
|
3
3
|
|
|
4
4
|
#include <node_api.h>
|
|
5
5
|
#include "error_helpers.h"
|
|
@@ -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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/javascript/packages/node/extension/error_helpers.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_EXTENSION_ERRORS_H
|
|
5
5
|
#define HERB_EXTENSION_ERRORS_H
|
|
@@ -288,7 +288,7 @@ static AST_NODE_T* create_control_node(
|
|
|
288
288
|
if (end_node) {
|
|
289
289
|
end_position = end_node->base.location.end;
|
|
290
290
|
} else if (children && hb_array_size(children) > 0) {
|
|
291
|
-
AST_NODE_T* last_child =
|
|
291
|
+
AST_NODE_T* last_child = hb_array_last(children);
|
|
292
292
|
end_position = last_child->location.end;
|
|
293
293
|
} else if (subsequent) {
|
|
294
294
|
end_position = subsequent->location.end;
|
|
@@ -695,10 +695,10 @@ static size_t process_control_structure(
|
|
|
695
695
|
} else if (else_clause) {
|
|
696
696
|
end_position = else_clause->base.location.end;
|
|
697
697
|
} else if (hb_array_size(when_conditions) > 0) {
|
|
698
|
-
AST_NODE_T* last_when =
|
|
698
|
+
AST_NODE_T* last_when = hb_array_last(when_conditions);
|
|
699
699
|
end_position = last_when->location.end;
|
|
700
700
|
} else if (hb_array_size(in_conditions) > 0) {
|
|
701
|
-
AST_NODE_T* last_in =
|
|
701
|
+
AST_NODE_T* last_in = hb_array_last(in_conditions);
|
|
702
702
|
end_position = last_in->location.end;
|
|
703
703
|
}
|
|
704
704
|
|
|
@@ -955,7 +955,7 @@ static size_t process_control_structure(
|
|
|
955
955
|
if (end_node) {
|
|
956
956
|
end_position = end_node->base.location.end;
|
|
957
957
|
} else if (children && hb_array_size(children) > 0) {
|
|
958
|
-
AST_NODE_T* last_child =
|
|
958
|
+
AST_NODE_T* last_child = hb_array_last(children);
|
|
959
959
|
end_position = last_child->location.end;
|
|
960
960
|
}
|
|
961
961
|
|
|
@@ -1139,7 +1139,7 @@ static size_t process_block_children(
|
|
|
1139
1139
|
hb_array_T* temp_array = hb_array_init(1);
|
|
1140
1140
|
size_t new_index = process_control_structure(node, array, index, temp_array, context, child_type);
|
|
1141
1141
|
|
|
1142
|
-
if (hb_array_size(temp_array) > 0) { hb_array_append(children_array,
|
|
1142
|
+
if (hb_array_size(temp_array) > 0) { hb_array_append(children_array, hb_array_first(temp_array)); }
|
|
1143
1143
|
|
|
1144
1144
|
hb_array_free(&temp_array);
|
|
1145
1145
|
|
|
@@ -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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/src/analyze_missing_end.c.erb
|
|
3
3
|
|
|
4
4
|
#include "include/analyze_helpers.h"
|
|
5
5
|
#include "include/errors.h"
|
|
@@ -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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/src/analyze_transform.c.erb
|
|
3
3
|
|
|
4
4
|
#include "include/analyze.h"
|
|
5
5
|
#include "include/visitor.h"
|
|
@@ -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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/src/ast_nodes.c.erb
|
|
3
3
|
|
|
4
4
|
#include <stdio.h>
|
|
5
5
|
#include <stdbool.h>
|
|
@@ -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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/src/include/ast_nodes.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_AST_NODES_H
|
|
5
5
|
#define HERB_AST_NODES_H
|
|
@@ -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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/src/ast_pretty_print.c.erb
|
|
3
3
|
|
|
4
4
|
#include "include/ast_node.h"
|
|
5
5
|
#include "include/ast_nodes.h"
|
|
@@ -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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/src/include/ast_pretty_print.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_AST_PRETTY_PRINT_H
|
|
5
5
|
#define HERB_AST_PRETTY_PRINT_H
|
|
@@ -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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/src/errors.c.erb
|
|
3
3
|
|
|
4
4
|
#include "include/errors.h"
|
|
5
5
|
#include "include/location.h"
|
|
@@ -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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/src/include/errors.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_ERRORS_H
|
|
5
5
|
#define HERB_ERRORS_H
|
|
@@ -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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/src/include/ast_nodes.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_AST_NODES_H
|
|
5
5
|
#define HERB_AST_NODES_H
|
|
@@ -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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/src/include/ast_pretty_print.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_AST_PRETTY_PRINT_H
|
|
5
5
|
#define HERB_AST_PRETTY_PRINT_H
|
|
@@ -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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/src/include/errors.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_ERRORS_H
|
|
5
5
|
#define HERB_ERRORS_H
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
#ifndef HERB_BUFFER_H
|
|
2
2
|
#define HERB_BUFFER_H
|
|
3
3
|
|
|
4
|
+
#include "hb_arena.h"
|
|
4
5
|
#include "hb_string.h"
|
|
5
6
|
|
|
6
7
|
#include <stdbool.h>
|
|
7
8
|
#include <stdlib.h>
|
|
8
9
|
|
|
9
10
|
typedef struct HB_BUFFER_STRUCT {
|
|
11
|
+
hb_arena_T* allocator;
|
|
10
12
|
char* value;
|
|
11
13
|
size_t length;
|
|
12
14
|
size_t capacity;
|
|
13
15
|
} hb_buffer_T;
|
|
14
16
|
|
|
15
17
|
bool hb_buffer_init(hb_buffer_T* buffer, size_t capacity);
|
|
18
|
+
bool hb_buffer_init_arena(hb_buffer_T* buffer, hb_arena_T* allocator, size_t capacity);
|
|
16
19
|
|
|
17
20
|
void hb_buffer_append(hb_buffer_T* buffer, const char* text);
|
|
18
21
|
void hb_buffer_append_with_length(hb_buffer_T* buffer, const char* text, size_t length);
|
|
@@ -315,8 +315,8 @@ static AST_HTML_ATTRIBUTE_NAME_NODE_T* parser_parse_html_attribute_name(parser_T
|
|
|
315
315
|
position_T node_end = { 0 };
|
|
316
316
|
|
|
317
317
|
if (children->size > 0) {
|
|
318
|
-
AST_NODE_T* first_child =
|
|
319
|
-
AST_NODE_T* last_child =
|
|
318
|
+
AST_NODE_T* first_child = hb_array_first(children);
|
|
319
|
+
AST_NODE_T* last_child = hb_array_last(children);
|
|
320
320
|
|
|
321
321
|
node_start = first_child->location.start;
|
|
322
322
|
node_end = last_child->location.end;
|
|
@@ -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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/src/parser_match_tags.c.erb
|
|
3
3
|
|
|
4
4
|
#include "include/parser.h"
|
|
5
5
|
#include "include/ast_nodes.h"
|
|
@@ -22,8 +22,14 @@ static bool hb_buffer_resize(hb_buffer_T* buffer, const size_t new_capacity) {
|
|
|
22
22
|
fprintf(stderr, "Error: Buffer capacity would overflow system limits.\n");
|
|
23
23
|
exit(1);
|
|
24
24
|
}
|
|
25
|
+
char* new_value = NULL;
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
if (buffer->allocator == NULL) {
|
|
28
|
+
new_value = realloc(buffer->value, new_capacity + 1);
|
|
29
|
+
} else {
|
|
30
|
+
new_value = hb_arena_alloc(buffer->allocator, new_capacity + 1);
|
|
31
|
+
memcpy(new_value, buffer->value, buffer->capacity + 1);
|
|
32
|
+
}
|
|
27
33
|
|
|
28
34
|
if (unlikely(new_value == NULL)) {
|
|
29
35
|
fprintf(stderr, "Error: Failed to resize buffer to %zu.\n", new_capacity);
|
|
@@ -61,6 +67,7 @@ static bool hb_buffer_expand_if_needed(hb_buffer_T* buffer, const size_t require
|
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
bool hb_buffer_init(hb_buffer_T* buffer, const size_t capacity) {
|
|
70
|
+
buffer->allocator = NULL;
|
|
64
71
|
buffer->capacity = capacity;
|
|
65
72
|
buffer->length = 0;
|
|
66
73
|
buffer->value = malloc(sizeof(char) * (buffer->capacity + 1));
|
|
@@ -76,6 +83,16 @@ bool hb_buffer_init(hb_buffer_T* buffer, const size_t capacity) {
|
|
|
76
83
|
return true;
|
|
77
84
|
}
|
|
78
85
|
|
|
86
|
+
bool hb_buffer_init_arena(hb_buffer_T* buffer, hb_arena_T* allocator, size_t capacity) {
|
|
87
|
+
buffer->allocator = allocator;
|
|
88
|
+
buffer->capacity = capacity;
|
|
89
|
+
buffer->length = 0;
|
|
90
|
+
buffer->value = hb_arena_alloc(allocator, sizeof(char) * (buffer->capacity + 1));
|
|
91
|
+
buffer->value[0] = '\0';
|
|
92
|
+
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
|
|
79
96
|
char* hb_buffer_value(const hb_buffer_T* buffer) {
|
|
80
97
|
return buffer->value;
|
|
81
98
|
}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
#ifndef HERB_BUFFER_H
|
|
2
2
|
#define HERB_BUFFER_H
|
|
3
3
|
|
|
4
|
+
#include "hb_arena.h"
|
|
4
5
|
#include "hb_string.h"
|
|
5
6
|
|
|
6
7
|
#include <stdbool.h>
|
|
7
8
|
#include <stdlib.h>
|
|
8
9
|
|
|
9
10
|
typedef struct HB_BUFFER_STRUCT {
|
|
11
|
+
hb_arena_T* allocator;
|
|
10
12
|
char* value;
|
|
11
13
|
size_t length;
|
|
12
14
|
size_t capacity;
|
|
13
15
|
} hb_buffer_T;
|
|
14
16
|
|
|
15
17
|
bool hb_buffer_init(hb_buffer_T* buffer, size_t capacity);
|
|
18
|
+
bool hb_buffer_init_arena(hb_buffer_T* buffer, hb_arena_T* allocator, size_t capacity);
|
|
16
19
|
|
|
17
20
|
void hb_buffer_append(hb_buffer_T* buffer, const char* text);
|
|
18
21
|
void hb_buffer_append_with_length(hb_buffer_T* buffer, const char* text, size_t length);
|
|
@@ -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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/src/visitor.c.erb
|
|
3
3
|
|
|
4
4
|
#include <stdio.h>
|
|
5
5
|
|
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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/javascript/packages/node/extension/nodes.cpp.erb
|
|
3
3
|
|
|
4
4
|
#include <node_api.h>
|
|
5
5
|
#include "error_helpers.h"
|
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.8.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.2/templates/javascript/packages/node/extension/nodes.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_EXTENSION_NODES_H
|
|
5
5
|
#define HERB_EXTENSION_NODES_H
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herb-tools/node",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Native Node.js addon for HTML-aware ERB parsing using Herb.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"host": "https://github.com/marcoroth/herb/releases/download/"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@herb-tools/core": "0.8.
|
|
51
|
+
"@herb-tools/core": "0.8.2",
|
|
52
52
|
"@mapbox/node-pre-gyp": "^2.0.0",
|
|
53
53
|
"node-addon-api": "^8.5.0",
|
|
54
54
|
"node-pre-gyp-github": "^2.0.0"
|