herb 0.9.7-arm-linux-gnu → 0.10.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/README.md +1 -0
- data/ext/herb/extconf.rb +1 -0
- data/ext/herb/extension.c +108 -0
- data/herb.gemspec +1 -1
- 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/action_view/render_analyzer.rb +1057 -0
- data/lib/herb/ast/erb_render_node.rb +155 -0
- data/lib/herb/bootstrap.rb +0 -1
- data/lib/herb/cli.rb +253 -19
- data/lib/herb/colors.rb +18 -0
- data/lib/herb/configuration.rb +49 -13
- data/lib/herb/defaults.yml +3 -0
- data/lib/herb/dev/runner.rb +445 -0
- data/lib/herb/dev/server.rb +207 -0
- data/lib/herb/dev/server_entry.rb +128 -0
- data/lib/herb/diff_operation.rb +34 -0
- data/lib/herb/diff_result.rb +59 -0
- data/lib/herb/engine/compiler.rb +56 -3
- data/lib/herb/engine/validators/render_validator.rb +92 -0
- data/lib/herb/engine.rb +58 -4
- data/lib/herb/html/util.rb +16 -0
- data/lib/herb/project.rb +1 -6
- data/lib/herb/version.rb +1 -1
- data/lib/herb.rb +41 -5
- data/sig/herb/action_view/render_analyzer.rbs +122 -0
- data/sig/herb/ast/erb_render_node.rbs +29 -0
- data/sig/herb/colors.rbs +12 -0
- data/sig/herb/configuration.rbs +20 -1
- data/sig/herb/dev/runner.rbs +59 -0
- data/sig/herb/dev/server.rbs +50 -0
- data/sig/herb/dev/server_entry.rbs +51 -0
- data/sig/herb/diff_operation.rbs +34 -0
- data/sig/herb/diff_result.rbs +34 -0
- data/sig/herb/engine/compiler.rbs +6 -0
- data/sig/herb/engine/validators/render_validator.rbs +21 -0
- data/sig/herb/engine.rbs +15 -0
- data/sig/herb/html/util.rbs +13 -0
- data/sig/herb.rbs +12 -2
- data/sig/herb_c_extension.rbs +1 -1
- data/sig/vendor/did_you_mean.rbs +6 -0
- data/sig/vendor/parallel.rbs +4 -0
- data/src/analyze/action_view/attribute_extraction_helpers.c +3 -2
- data/src/diff/herb_diff.c +137 -0
- data/src/diff/herb_diff_attributes.c +207 -0
- data/src/diff/herb_diff_children.c +518 -0
- data/src/diff/herb_diff_helpers.c +114 -0
- data/src/diff/herb_diff_nodes.c +707 -0
- data/src/diff/herb_hash.c +42 -0
- data/src/diff/herb_hash_index_map.c +47 -0
- data/src/diff/herb_hash_map.c +104 -0
- data/src/diff/herb_hash_tree.c +680 -0
- data/src/include/diff/herb_diff.h +118 -0
- data/src/include/diff/herb_hash.h +25 -0
- data/src/include/diff/herb_hash_index_map.h +32 -0
- data/src/include/diff/herb_hash_map.h +30 -0
- data/src/include/herb.h +1 -0
- data/src/include/version.h +1 -1
- data/templates/javascript/packages/core/src/config.ts.erb +43 -0
- data/templates/rust/src/ast/nodes.rs.erb +1 -1
- data/templates/rust/src/config.rs.erb +50 -0
- data/templates/src/diff/herb_diff_helpers.c.erb +38 -0
- data/templates/src/diff/herb_diff_nodes.c.erb +224 -0
- data/templates/src/diff/herb_hash_tree.c.erb +147 -0
- data/templates/template.rb +4 -4
- metadata +40 -4
- data/lib/herb/3.0/herb.so +0 -0
- data/lib/herb/3.1/herb.so +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#include "../include/diff/herb_hash.h"
|
|
2
|
+
|
|
3
|
+
herb_hash_T herb_hash_byte(herb_hash_T hash, const uint8_t byte) {
|
|
4
|
+
hash ^= (herb_hash_T) byte;
|
|
5
|
+
hash *= HERB_HASH_FNV_PRIME;
|
|
6
|
+
|
|
7
|
+
return hash;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
herb_hash_T herb_hash_bytes(herb_hash_T hash, const void* data, const size_t length) {
|
|
11
|
+
const uint8_t* bytes = (const uint8_t*) data;
|
|
12
|
+
|
|
13
|
+
for (size_t index = 0; index < length; index++) {
|
|
14
|
+
hash = herb_hash_byte(hash, bytes[index]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return hash;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
herb_hash_T herb_hash_uint32(herb_hash_T hash, const uint32_t value) {
|
|
21
|
+
return herb_hash_bytes(hash, &value, sizeof(value));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
herb_hash_T herb_hash_uint64(herb_hash_T hash, const uint64_t value) {
|
|
25
|
+
return herb_hash_bytes(hash, &value, sizeof(value));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
herb_hash_T herb_hash_bool(herb_hash_T hash, const bool value) {
|
|
29
|
+
const uint8_t byte = value ? 1 : 0;
|
|
30
|
+
|
|
31
|
+
return herb_hash_byte(hash, byte);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
herb_hash_T herb_hash_string(herb_hash_T hash, const hb_string_T string) {
|
|
35
|
+
hash = herb_hash_uint64(hash, (uint64_t) string.length);
|
|
36
|
+
|
|
37
|
+
return herb_hash_bytes(hash, string.data, string.length);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
herb_hash_T herb_hash_combine(herb_hash_T hash, const herb_hash_T other) {
|
|
41
|
+
return herb_hash_uint64(hash, other);
|
|
42
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#include "../include/diff/herb_hash_index_map.h"
|
|
2
|
+
|
|
3
|
+
#include <string.h>
|
|
4
|
+
|
|
5
|
+
bool herb_hash_index_map_init(herb_hash_index_map_T* map, size_t count, hb_allocator_T* allocator) {
|
|
6
|
+
map->capacity = count < 4 ? 8 : count * 3;
|
|
7
|
+
size_t alloc_size = map->capacity * sizeof(herb_hash_index_entry_T);
|
|
8
|
+
map->entries = (herb_hash_index_entry_T*) hb_allocator_alloc(allocator, alloc_size);
|
|
9
|
+
|
|
10
|
+
if (map->entries == NULL) { return false; }
|
|
11
|
+
|
|
12
|
+
memset(map->entries, 0, alloc_size);
|
|
13
|
+
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
void herb_hash_index_map_insert(herb_hash_index_map_T* map, herb_hash_T key, size_t value) {
|
|
18
|
+
size_t slot = (size_t) (key % map->capacity);
|
|
19
|
+
|
|
20
|
+
while (map->entries[slot].occupied) {
|
|
21
|
+
slot = (slot + 1) % map->capacity;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
map->entries[slot].key = key;
|
|
25
|
+
map->entries[slot].value = value;
|
|
26
|
+
map->entries[slot].occupied = true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
bool herb_hash_index_map_find_unmatched(
|
|
30
|
+
const herb_hash_index_map_T* map,
|
|
31
|
+
herb_hash_T key,
|
|
32
|
+
const bool* matched,
|
|
33
|
+
size_t* out_value
|
|
34
|
+
) {
|
|
35
|
+
size_t slot = (size_t) (key % map->capacity);
|
|
36
|
+
|
|
37
|
+
while (map->entries[slot].occupied) {
|
|
38
|
+
if (map->entries[slot].key == key && !matched[map->entries[slot].value]) {
|
|
39
|
+
*out_value = map->entries[slot].value;
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
slot = (slot + 1) % map->capacity;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#include "../include/diff/herb_hash_map.h"
|
|
2
|
+
|
|
3
|
+
#include <string.h>
|
|
4
|
+
|
|
5
|
+
static size_t hash_pointer(const AST_NODE_T* node, const size_t capacity) {
|
|
6
|
+
uintptr_t pointer_value = (uintptr_t) node;
|
|
7
|
+
|
|
8
|
+
pointer_value = ((pointer_value >> 16) ^ pointer_value) * 0x45d9f3b;
|
|
9
|
+
pointer_value = ((pointer_value >> 16) ^ pointer_value) * 0x45d9f3b;
|
|
10
|
+
pointer_value = (pointer_value >> 16) ^ pointer_value;
|
|
11
|
+
|
|
12
|
+
return (size_t) (pointer_value % capacity);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static bool herb_hash_map_grow(herb_hash_map_T* map) {
|
|
16
|
+
const size_t new_capacity = map->capacity * 2;
|
|
17
|
+
const size_t alloc_size = new_capacity * sizeof(herb_hash_map_entry_T);
|
|
18
|
+
|
|
19
|
+
herb_hash_map_entry_T* new_entries = (herb_hash_map_entry_T*) hb_allocator_alloc(map->allocator, alloc_size);
|
|
20
|
+
|
|
21
|
+
if (new_entries == NULL) { return false; }
|
|
22
|
+
|
|
23
|
+
memset(new_entries, 0, alloc_size);
|
|
24
|
+
|
|
25
|
+
for (size_t index = 0; index < map->capacity; index++) {
|
|
26
|
+
if (!map->entries[index].occupied) { continue; }
|
|
27
|
+
|
|
28
|
+
size_t slot = hash_pointer(map->entries[index].node, new_capacity);
|
|
29
|
+
|
|
30
|
+
while (new_entries[slot].occupied) {
|
|
31
|
+
slot = (slot + 1) % new_capacity;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
new_entries[slot] = map->entries[index];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
map->entries = new_entries;
|
|
38
|
+
map->capacity = new_capacity;
|
|
39
|
+
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
bool herb_hash_map_init(herb_hash_map_T* map, const size_t initial_capacity, hb_allocator_T* allocator) {
|
|
44
|
+
const size_t alloc_size = initial_capacity * sizeof(herb_hash_map_entry_T);
|
|
45
|
+
|
|
46
|
+
map->entries = (herb_hash_map_entry_T*) hb_allocator_alloc(allocator, alloc_size);
|
|
47
|
+
|
|
48
|
+
if (map->entries == NULL) { return false; }
|
|
49
|
+
|
|
50
|
+
memset(map->entries, 0, alloc_size);
|
|
51
|
+
map->capacity = initial_capacity;
|
|
52
|
+
map->size = 0;
|
|
53
|
+
map->allocator = allocator;
|
|
54
|
+
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void herb_hash_map_set(herb_hash_map_T* map, const AST_NODE_T* node, const herb_hash_T hash) {
|
|
59
|
+
if (map->size * 4 >= map->capacity * 3) { herb_hash_map_grow(map); }
|
|
60
|
+
|
|
61
|
+
size_t slot = hash_pointer(node, map->capacity);
|
|
62
|
+
|
|
63
|
+
while (map->entries[slot].occupied) {
|
|
64
|
+
if (map->entries[slot].node == node) {
|
|
65
|
+
map->entries[slot].hash = hash;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
slot = (slot + 1) % map->capacity;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
map->entries[slot].node = node;
|
|
73
|
+
map->entries[slot].hash = hash;
|
|
74
|
+
map->entries[slot].occupied = true;
|
|
75
|
+
map->size++;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
herb_hash_T herb_hash_map_get(const herb_hash_map_T* map, const AST_NODE_T* node) {
|
|
79
|
+
if (node == NULL || map->size == 0) { return HERB_HASH_INIT; }
|
|
80
|
+
|
|
81
|
+
size_t slot = hash_pointer(node, map->capacity);
|
|
82
|
+
|
|
83
|
+
while (map->entries[slot].occupied) {
|
|
84
|
+
if (map->entries[slot].node == node) { return map->entries[slot].hash; }
|
|
85
|
+
|
|
86
|
+
slot = (slot + 1) % map->capacity;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return HERB_HASH_INIT;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
bool herb_hash_map_has(const herb_hash_map_T* map, const AST_NODE_T* node) {
|
|
93
|
+
if (node == NULL || map->size == 0) { return false; }
|
|
94
|
+
|
|
95
|
+
size_t slot = hash_pointer(node, map->capacity);
|
|
96
|
+
|
|
97
|
+
while (map->entries[slot].occupied) {
|
|
98
|
+
if (map->entries[slot].node == node) { return true; }
|
|
99
|
+
|
|
100
|
+
slot = (slot + 1) % map->capacity;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return false;
|
|
104
|
+
}
|