js 0.0.1 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/js/bindgen/.clang-format +2 -0
- data/ext/js/bindgen/rb-js-abi-host.c +342 -0
- data/ext/js/bindgen/rb-js-abi-host.h +82 -0
- data/ext/js/bindgen/rb-js-abi-host.wit +47 -0
- data/ext/js/depend +10 -0
- data/ext/js/extconf.rb +3 -0
- data/ext/js/js-core.c +577 -0
- data/ext/witapi/bindgen/.clang-format +2 -0
- data/ext/witapi/bindgen/rb-abi-guest.c +222 -0
- data/ext/witapi/bindgen/rb-abi-guest.h +77 -0
- data/ext/witapi/bindgen/rb-abi-guest.wit +25 -0
- data/ext/witapi/depend +11 -0
- data/ext/witapi/extconf.rb +3 -0
- data/ext/witapi/witapi-core.c +325 -0
- data/js.gemspec +26 -16
- data/lib/js/array.rb +9 -0
- data/lib/js/hash.rb +8 -0
- data/lib/js/nil_class.rb +6 -0
- data/lib/js/require_remote/evaluator.rb +15 -0
- data/lib/js/require_remote/url_resolver.rb +45 -0
- data/lib/js/require_remote.rb +85 -0
- data/lib/js/version.rb +2 -2
- data/lib/js.rb +238 -3
- metadata +39 -22
- data/.gitignore +0 -17
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/README.md +0 -35
- data/Rakefile +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c8db8331e9b5af21a79ef8c5f7136ac86f2dd5960805fb666e7b29a76ab5a8df
|
4
|
+
data.tar.gz: 90393c06028f76007dd4e6f186d75e5556abf619a631a34934c93e2425455a21
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f091babf60c93c329efd3ccc3ffc798312551a93deeef2bea3a01fc98d70b4b9ef739f1c2c02e4d0d29eb8544b541ae29ab2b3b3239044e2e66290f8838bea35
|
7
|
+
data.tar.gz: 67bfb90975cc2ae66b6e713eb64fb5f7521599059779e17ffaa741a39b636366dc24a6dfb97c17ae082eaee3f50e2f99a07f66ef0b0061c827a5820a09f31b72
|
@@ -0,0 +1,342 @@
|
|
1
|
+
#include <stdlib.h>
|
2
|
+
#include <rb-js-abi-host.h>
|
3
|
+
|
4
|
+
__attribute__((weak, export_name("cabi_realloc")))
|
5
|
+
void *cabi_realloc(
|
6
|
+
void *ptr,
|
7
|
+
size_t orig_size,
|
8
|
+
size_t org_align,
|
9
|
+
size_t new_size
|
10
|
+
) {
|
11
|
+
void *ret = realloc(ptr, new_size);
|
12
|
+
if (!ret)
|
13
|
+
abort();
|
14
|
+
return ret;
|
15
|
+
}
|
16
|
+
|
17
|
+
__attribute__((import_module("canonical_abi"), import_name("resource_drop_js-abi-value")))
|
18
|
+
void __resource_js_abi_value_drop(uint32_t idx);
|
19
|
+
|
20
|
+
void rb_js_abi_host_js_abi_value_free(rb_js_abi_host_js_abi_value_t *ptr) {
|
21
|
+
__resource_js_abi_value_drop(ptr->idx);
|
22
|
+
}
|
23
|
+
|
24
|
+
__attribute__((import_module("canonical_abi"), import_name("resource_clone_js-abi-value")))
|
25
|
+
uint32_t __resource_js_abi_value_clone(uint32_t idx);
|
26
|
+
|
27
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_js_abi_value_clone(rb_js_abi_host_js_abi_value_t *ptr) {
|
28
|
+
return (rb_js_abi_host_js_abi_value_t){__resource_js_abi_value_clone(ptr->idx)};
|
29
|
+
}
|
30
|
+
#include <string.h>
|
31
|
+
|
32
|
+
void rb_js_abi_host_string_set(rb_js_abi_host_string_t *ret, const char *s) {
|
33
|
+
ret->ptr = (char*) s;
|
34
|
+
ret->len = strlen(s);
|
35
|
+
}
|
36
|
+
|
37
|
+
void rb_js_abi_host_string_dup(rb_js_abi_host_string_t *ret, const char *s) {
|
38
|
+
ret->len = strlen(s);
|
39
|
+
ret->ptr = cabi_realloc(NULL, 0, 1, ret->len);
|
40
|
+
memcpy(ret->ptr, s, ret->len);
|
41
|
+
}
|
42
|
+
|
43
|
+
void rb_js_abi_host_string_free(rb_js_abi_host_string_t *ret) {
|
44
|
+
if (ret->len > 0) {
|
45
|
+
free(ret->ptr);
|
46
|
+
}
|
47
|
+
ret->ptr = NULL;
|
48
|
+
ret->len = 0;
|
49
|
+
}
|
50
|
+
void rb_js_abi_host_js_abi_result_free(rb_js_abi_host_js_abi_result_t *ptr) {
|
51
|
+
switch ((int32_t) ptr->tag) {
|
52
|
+
case 0: {
|
53
|
+
rb_js_abi_host_js_abi_value_free(&ptr->val.success);
|
54
|
+
break;
|
55
|
+
}
|
56
|
+
case 1: {
|
57
|
+
rb_js_abi_host_js_abi_value_free(&ptr->val.failure);
|
58
|
+
break;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
void rb_js_abi_host_raw_integer_free(rb_js_abi_host_raw_integer_t *ptr) {
|
63
|
+
switch ((int32_t) ptr->tag) {
|
64
|
+
case 1: {
|
65
|
+
rb_js_abi_host_string_free(&ptr->val.bignum);
|
66
|
+
break;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
void rb_js_abi_host_list_js_abi_value_free(rb_js_abi_host_list_js_abi_value_t *ptr) {
|
71
|
+
for (size_t i = 0; i < ptr->len; i++) {
|
72
|
+
rb_js_abi_host_js_abi_value_free(&ptr->ptr[i]);
|
73
|
+
}
|
74
|
+
if (ptr->len > 0) {
|
75
|
+
free(ptr->ptr);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("eval-js: func(code: string) -> variant { success(handle<js-abi-value>), failure(handle<js-abi-value>) }")))
|
79
|
+
void __wasm_import_rb_js_abi_host_eval_js(int32_t, int32_t, int32_t);
|
80
|
+
void rb_js_abi_host_eval_js(rb_js_abi_host_string_t *code, rb_js_abi_host_js_abi_result_t *ret0) {
|
81
|
+
|
82
|
+
__attribute__((aligned(4)))
|
83
|
+
uint8_t ret_area[8];
|
84
|
+
int32_t ptr = (int32_t) &ret_area;
|
85
|
+
__wasm_import_rb_js_abi_host_eval_js((int32_t) (*code).ptr, (int32_t) (*code).len, ptr);
|
86
|
+
rb_js_abi_host_js_abi_result_t variant;
|
87
|
+
variant.tag = (int32_t) (*((uint8_t*) (ptr + 0)));
|
88
|
+
switch ((int32_t) variant.tag) {
|
89
|
+
case 0: {
|
90
|
+
variant.val.success = (rb_js_abi_host_js_abi_value_t){ *((int32_t*) (ptr + 4)) };
|
91
|
+
break;
|
92
|
+
}
|
93
|
+
case 1: {
|
94
|
+
variant.val.failure = (rb_js_abi_host_js_abi_value_t){ *((int32_t*) (ptr + 4)) };
|
95
|
+
break;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
*ret0 = variant;
|
99
|
+
}
|
100
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("is-js: func(value: handle<js-abi-value>) -> bool")))
|
101
|
+
int32_t __wasm_import_rb_js_abi_host_is_js(int32_t);
|
102
|
+
bool rb_js_abi_host_is_js(rb_js_abi_host_js_abi_value_t value) {
|
103
|
+
int32_t ret = __wasm_import_rb_js_abi_host_is_js((value).idx);
|
104
|
+
return ret;
|
105
|
+
}
|
106
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("instance-of: func(value: handle<js-abi-value>, klass: handle<js-abi-value>) -> bool")))
|
107
|
+
int32_t __wasm_import_rb_js_abi_host_instance_of(int32_t, int32_t);
|
108
|
+
bool rb_js_abi_host_instance_of(rb_js_abi_host_js_abi_value_t value, rb_js_abi_host_js_abi_value_t klass) {
|
109
|
+
int32_t ret = __wasm_import_rb_js_abi_host_instance_of((value).idx, (klass).idx);
|
110
|
+
return ret;
|
111
|
+
}
|
112
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("global-this: func() -> handle<js-abi-value>")))
|
113
|
+
int32_t __wasm_import_rb_js_abi_host_global_this(void);
|
114
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_global_this(void) {
|
115
|
+
int32_t ret = __wasm_import_rb_js_abi_host_global_this();
|
116
|
+
return (rb_js_abi_host_js_abi_value_t){ ret };
|
117
|
+
}
|
118
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("int-to-js-number: func(value: s32) -> handle<js-abi-value>")))
|
119
|
+
int32_t __wasm_import_rb_js_abi_host_int_to_js_number(int32_t);
|
120
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_int_to_js_number(int32_t value) {
|
121
|
+
int32_t ret = __wasm_import_rb_js_abi_host_int_to_js_number(value);
|
122
|
+
return (rb_js_abi_host_js_abi_value_t){ ret };
|
123
|
+
}
|
124
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("float-to-js-number: func(value: float64) -> handle<js-abi-value>")))
|
125
|
+
int32_t __wasm_import_rb_js_abi_host_float_to_js_number(double);
|
126
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_float_to_js_number(double value) {
|
127
|
+
int32_t ret = __wasm_import_rb_js_abi_host_float_to_js_number(value);
|
128
|
+
return (rb_js_abi_host_js_abi_value_t){ ret };
|
129
|
+
}
|
130
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("string-to-js-string: func(value: string) -> handle<js-abi-value>")))
|
131
|
+
int32_t __wasm_import_rb_js_abi_host_string_to_js_string(int32_t, int32_t);
|
132
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_string_to_js_string(rb_js_abi_host_string_t *value) {
|
133
|
+
int32_t ret = __wasm_import_rb_js_abi_host_string_to_js_string((int32_t) (*value).ptr, (int32_t) (*value).len);
|
134
|
+
return (rb_js_abi_host_js_abi_value_t){ ret };
|
135
|
+
}
|
136
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("bool-to-js-bool: func(value: bool) -> handle<js-abi-value>")))
|
137
|
+
int32_t __wasm_import_rb_js_abi_host_bool_to_js_bool(int32_t);
|
138
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_bool_to_js_bool(bool value) {
|
139
|
+
int32_t ret = __wasm_import_rb_js_abi_host_bool_to_js_bool(value);
|
140
|
+
return (rb_js_abi_host_js_abi_value_t){ ret };
|
141
|
+
}
|
142
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("proc-to-js-function: func(value: u32) -> handle<js-abi-value>")))
|
143
|
+
int32_t __wasm_import_rb_js_abi_host_proc_to_js_function(int32_t);
|
144
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_proc_to_js_function(uint32_t value) {
|
145
|
+
int32_t ret = __wasm_import_rb_js_abi_host_proc_to_js_function((int32_t) (value));
|
146
|
+
return (rb_js_abi_host_js_abi_value_t){ ret };
|
147
|
+
}
|
148
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("rb-object-to-js-rb-value: func(raw-rb-abi-value: u32) -> handle<js-abi-value>")))
|
149
|
+
int32_t __wasm_import_rb_js_abi_host_rb_object_to_js_rb_value(int32_t);
|
150
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_rb_object_to_js_rb_value(uint32_t raw_rb_abi_value) {
|
151
|
+
int32_t ret = __wasm_import_rb_js_abi_host_rb_object_to_js_rb_value((int32_t) (raw_rb_abi_value));
|
152
|
+
return (rb_js_abi_host_js_abi_value_t){ ret };
|
153
|
+
}
|
154
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("js-value-to-string: func(value: handle<js-abi-value>) -> string")))
|
155
|
+
void __wasm_import_rb_js_abi_host_js_value_to_string(int32_t, int32_t);
|
156
|
+
void rb_js_abi_host_js_value_to_string(rb_js_abi_host_js_abi_value_t value, rb_js_abi_host_string_t *ret0) {
|
157
|
+
|
158
|
+
__attribute__((aligned(4)))
|
159
|
+
uint8_t ret_area[8];
|
160
|
+
int32_t ptr = (int32_t) &ret_area;
|
161
|
+
__wasm_import_rb_js_abi_host_js_value_to_string((value).idx, ptr);
|
162
|
+
*ret0 = (rb_js_abi_host_string_t) { (char*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) };
|
163
|
+
}
|
164
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("js-value-to-integer: func(value: handle<js-abi-value>) -> variant { f64(float64), bignum(string) }")))
|
165
|
+
void __wasm_import_rb_js_abi_host_js_value_to_integer(int32_t, int32_t);
|
166
|
+
void rb_js_abi_host_js_value_to_integer(rb_js_abi_host_js_abi_value_t value, rb_js_abi_host_raw_integer_t *ret0) {
|
167
|
+
|
168
|
+
__attribute__((aligned(8)))
|
169
|
+
uint8_t ret_area[16];
|
170
|
+
int32_t ptr = (int32_t) &ret_area;
|
171
|
+
__wasm_import_rb_js_abi_host_js_value_to_integer((value).idx, ptr);
|
172
|
+
rb_js_abi_host_raw_integer_t variant;
|
173
|
+
variant.tag = (int32_t) (*((uint8_t*) (ptr + 0)));
|
174
|
+
switch ((int32_t) variant.tag) {
|
175
|
+
case 0: {
|
176
|
+
variant.val.f64 = *((double*) (ptr + 8));
|
177
|
+
break;
|
178
|
+
}
|
179
|
+
case 1: {
|
180
|
+
variant.val.bignum = (rb_js_abi_host_string_t) { (char*)(*((int32_t*) (ptr + 8))), (size_t)(*((int32_t*) (ptr + 12))) };
|
181
|
+
break;
|
182
|
+
}
|
183
|
+
}
|
184
|
+
*ret0 = variant;
|
185
|
+
}
|
186
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("export-js-value-to-host: func(value: handle<js-abi-value>) -> ()")))
|
187
|
+
void __wasm_import_rb_js_abi_host_export_js_value_to_host(int32_t);
|
188
|
+
void rb_js_abi_host_export_js_value_to_host(rb_js_abi_host_js_abi_value_t value) {
|
189
|
+
__wasm_import_rb_js_abi_host_export_js_value_to_host((value).idx);
|
190
|
+
}
|
191
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("import-js-value-from-host: func() -> handle<js-abi-value>")))
|
192
|
+
int32_t __wasm_import_rb_js_abi_host_import_js_value_from_host(void);
|
193
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_import_js_value_from_host(void) {
|
194
|
+
int32_t ret = __wasm_import_rb_js_abi_host_import_js_value_from_host();
|
195
|
+
return (rb_js_abi_host_js_abi_value_t){ ret };
|
196
|
+
}
|
197
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("js-value-typeof: func(value: handle<js-abi-value>) -> string")))
|
198
|
+
void __wasm_import_rb_js_abi_host_js_value_typeof(int32_t, int32_t);
|
199
|
+
void rb_js_abi_host_js_value_typeof(rb_js_abi_host_js_abi_value_t value, rb_js_abi_host_string_t *ret0) {
|
200
|
+
|
201
|
+
__attribute__((aligned(4)))
|
202
|
+
uint8_t ret_area[8];
|
203
|
+
int32_t ptr = (int32_t) &ret_area;
|
204
|
+
__wasm_import_rb_js_abi_host_js_value_typeof((value).idx, ptr);
|
205
|
+
*ret0 = (rb_js_abi_host_string_t) { (char*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) };
|
206
|
+
}
|
207
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("js-value-equal: func(lhs: handle<js-abi-value>, rhs: handle<js-abi-value>) -> bool")))
|
208
|
+
int32_t __wasm_import_rb_js_abi_host_js_value_equal(int32_t, int32_t);
|
209
|
+
bool rb_js_abi_host_js_value_equal(rb_js_abi_host_js_abi_value_t lhs, rb_js_abi_host_js_abi_value_t rhs) {
|
210
|
+
int32_t ret = __wasm_import_rb_js_abi_host_js_value_equal((lhs).idx, (rhs).idx);
|
211
|
+
return ret;
|
212
|
+
}
|
213
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("js-value-strictly-equal: func(lhs: handle<js-abi-value>, rhs: handle<js-abi-value>) -> bool")))
|
214
|
+
int32_t __wasm_import_rb_js_abi_host_js_value_strictly_equal(int32_t, int32_t);
|
215
|
+
bool rb_js_abi_host_js_value_strictly_equal(rb_js_abi_host_js_abi_value_t lhs, rb_js_abi_host_js_abi_value_t rhs) {
|
216
|
+
int32_t ret = __wasm_import_rb_js_abi_host_js_value_strictly_equal((lhs).idx, (rhs).idx);
|
217
|
+
return ret;
|
218
|
+
}
|
219
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("reflect-apply: func(target: handle<js-abi-value>, this-argument: handle<js-abi-value>, arguments: list<handle<js-abi-value>>) -> variant { success(handle<js-abi-value>), failure(handle<js-abi-value>) }")))
|
220
|
+
void __wasm_import_rb_js_abi_host_reflect_apply(int32_t, int32_t, int32_t, int32_t, int32_t);
|
221
|
+
void rb_js_abi_host_reflect_apply(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_js_abi_value_t this_argument, rb_js_abi_host_list_js_abi_value_t *arguments, rb_js_abi_host_js_abi_result_t *ret0) {
|
222
|
+
|
223
|
+
__attribute__((aligned(4)))
|
224
|
+
uint8_t ret_area[8];
|
225
|
+
int32_t ptr = (int32_t) &ret_area;
|
226
|
+
__wasm_import_rb_js_abi_host_reflect_apply((target).idx, (this_argument).idx, (int32_t) (*arguments).ptr, (int32_t) (*arguments).len, ptr);
|
227
|
+
rb_js_abi_host_js_abi_result_t variant;
|
228
|
+
variant.tag = (int32_t) (*((uint8_t*) (ptr + 0)));
|
229
|
+
switch ((int32_t) variant.tag) {
|
230
|
+
case 0: {
|
231
|
+
variant.val.success = (rb_js_abi_host_js_abi_value_t){ *((int32_t*) (ptr + 4)) };
|
232
|
+
break;
|
233
|
+
}
|
234
|
+
case 1: {
|
235
|
+
variant.val.failure = (rb_js_abi_host_js_abi_value_t){ *((int32_t*) (ptr + 4)) };
|
236
|
+
break;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
*ret0 = variant;
|
240
|
+
}
|
241
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("reflect-construct: func(target: handle<js-abi-value>, arguments: list<handle<js-abi-value>>) -> handle<js-abi-value>")))
|
242
|
+
int32_t __wasm_import_rb_js_abi_host_reflect_construct(int32_t, int32_t, int32_t);
|
243
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_reflect_construct(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_list_js_abi_value_t *arguments) {
|
244
|
+
int32_t ret = __wasm_import_rb_js_abi_host_reflect_construct((target).idx, (int32_t) (*arguments).ptr, (int32_t) (*arguments).len);
|
245
|
+
return (rb_js_abi_host_js_abi_value_t){ ret };
|
246
|
+
}
|
247
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("reflect-delete-property: func(target: handle<js-abi-value>, property-key: string) -> bool")))
|
248
|
+
int32_t __wasm_import_rb_js_abi_host_reflect_delete_property(int32_t, int32_t, int32_t);
|
249
|
+
bool rb_js_abi_host_reflect_delete_property(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_string_t *property_key) {
|
250
|
+
int32_t ret = __wasm_import_rb_js_abi_host_reflect_delete_property((target).idx, (int32_t) (*property_key).ptr, (int32_t) (*property_key).len);
|
251
|
+
return ret;
|
252
|
+
}
|
253
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("reflect-get: func(target: handle<js-abi-value>, property-key: string) -> variant { success(handle<js-abi-value>), failure(handle<js-abi-value>) }")))
|
254
|
+
void __wasm_import_rb_js_abi_host_reflect_get(int32_t, int32_t, int32_t, int32_t);
|
255
|
+
void rb_js_abi_host_reflect_get(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_string_t *property_key, rb_js_abi_host_js_abi_result_t *ret0) {
|
256
|
+
|
257
|
+
__attribute__((aligned(4)))
|
258
|
+
uint8_t ret_area[8];
|
259
|
+
int32_t ptr = (int32_t) &ret_area;
|
260
|
+
__wasm_import_rb_js_abi_host_reflect_get((target).idx, (int32_t) (*property_key).ptr, (int32_t) (*property_key).len, ptr);
|
261
|
+
rb_js_abi_host_js_abi_result_t variant;
|
262
|
+
variant.tag = (int32_t) (*((uint8_t*) (ptr + 0)));
|
263
|
+
switch ((int32_t) variant.tag) {
|
264
|
+
case 0: {
|
265
|
+
variant.val.success = (rb_js_abi_host_js_abi_value_t){ *((int32_t*) (ptr + 4)) };
|
266
|
+
break;
|
267
|
+
}
|
268
|
+
case 1: {
|
269
|
+
variant.val.failure = (rb_js_abi_host_js_abi_value_t){ *((int32_t*) (ptr + 4)) };
|
270
|
+
break;
|
271
|
+
}
|
272
|
+
}
|
273
|
+
*ret0 = variant;
|
274
|
+
}
|
275
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("reflect-get-own-property-descriptor: func(target: handle<js-abi-value>, property-key: string) -> handle<js-abi-value>")))
|
276
|
+
int32_t __wasm_import_rb_js_abi_host_reflect_get_own_property_descriptor(int32_t, int32_t, int32_t);
|
277
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_reflect_get_own_property_descriptor(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_string_t *property_key) {
|
278
|
+
int32_t ret = __wasm_import_rb_js_abi_host_reflect_get_own_property_descriptor((target).idx, (int32_t) (*property_key).ptr, (int32_t) (*property_key).len);
|
279
|
+
return (rb_js_abi_host_js_abi_value_t){ ret };
|
280
|
+
}
|
281
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("reflect-get-prototype-of: func(target: handle<js-abi-value>) -> handle<js-abi-value>")))
|
282
|
+
int32_t __wasm_import_rb_js_abi_host_reflect_get_prototype_of(int32_t);
|
283
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_reflect_get_prototype_of(rb_js_abi_host_js_abi_value_t target) {
|
284
|
+
int32_t ret = __wasm_import_rb_js_abi_host_reflect_get_prototype_of((target).idx);
|
285
|
+
return (rb_js_abi_host_js_abi_value_t){ ret };
|
286
|
+
}
|
287
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("reflect-has: func(target: handle<js-abi-value>, property-key: string) -> bool")))
|
288
|
+
int32_t __wasm_import_rb_js_abi_host_reflect_has(int32_t, int32_t, int32_t);
|
289
|
+
bool rb_js_abi_host_reflect_has(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_string_t *property_key) {
|
290
|
+
int32_t ret = __wasm_import_rb_js_abi_host_reflect_has((target).idx, (int32_t) (*property_key).ptr, (int32_t) (*property_key).len);
|
291
|
+
return ret;
|
292
|
+
}
|
293
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("reflect-is-extensible: func(target: handle<js-abi-value>) -> bool")))
|
294
|
+
int32_t __wasm_import_rb_js_abi_host_reflect_is_extensible(int32_t);
|
295
|
+
bool rb_js_abi_host_reflect_is_extensible(rb_js_abi_host_js_abi_value_t target) {
|
296
|
+
int32_t ret = __wasm_import_rb_js_abi_host_reflect_is_extensible((target).idx);
|
297
|
+
return ret;
|
298
|
+
}
|
299
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("reflect-own-keys: func(target: handle<js-abi-value>) -> list<handle<js-abi-value>>")))
|
300
|
+
void __wasm_import_rb_js_abi_host_reflect_own_keys(int32_t, int32_t);
|
301
|
+
void rb_js_abi_host_reflect_own_keys(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_list_js_abi_value_t *ret0) {
|
302
|
+
|
303
|
+
__attribute__((aligned(4)))
|
304
|
+
uint8_t ret_area[8];
|
305
|
+
int32_t ptr = (int32_t) &ret_area;
|
306
|
+
__wasm_import_rb_js_abi_host_reflect_own_keys((target).idx, ptr);
|
307
|
+
*ret0 = (rb_js_abi_host_list_js_abi_value_t) { (rb_js_abi_host_js_abi_value_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) };
|
308
|
+
}
|
309
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("reflect-prevent-extensions: func(target: handle<js-abi-value>) -> bool")))
|
310
|
+
int32_t __wasm_import_rb_js_abi_host_reflect_prevent_extensions(int32_t);
|
311
|
+
bool rb_js_abi_host_reflect_prevent_extensions(rb_js_abi_host_js_abi_value_t target) {
|
312
|
+
int32_t ret = __wasm_import_rb_js_abi_host_reflect_prevent_extensions((target).idx);
|
313
|
+
return ret;
|
314
|
+
}
|
315
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("reflect-set: func(target: handle<js-abi-value>, property-key: string, value: handle<js-abi-value>) -> variant { success(handle<js-abi-value>), failure(handle<js-abi-value>) }")))
|
316
|
+
void __wasm_import_rb_js_abi_host_reflect_set(int32_t, int32_t, int32_t, int32_t, int32_t);
|
317
|
+
void rb_js_abi_host_reflect_set(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_string_t *property_key, rb_js_abi_host_js_abi_value_t value, rb_js_abi_host_js_abi_result_t *ret0) {
|
318
|
+
|
319
|
+
__attribute__((aligned(4)))
|
320
|
+
uint8_t ret_area[8];
|
321
|
+
int32_t ptr = (int32_t) &ret_area;
|
322
|
+
__wasm_import_rb_js_abi_host_reflect_set((target).idx, (int32_t) (*property_key).ptr, (int32_t) (*property_key).len, (value).idx, ptr);
|
323
|
+
rb_js_abi_host_js_abi_result_t variant;
|
324
|
+
variant.tag = (int32_t) (*((uint8_t*) (ptr + 0)));
|
325
|
+
switch ((int32_t) variant.tag) {
|
326
|
+
case 0: {
|
327
|
+
variant.val.success = (rb_js_abi_host_js_abi_value_t){ *((int32_t*) (ptr + 4)) };
|
328
|
+
break;
|
329
|
+
}
|
330
|
+
case 1: {
|
331
|
+
variant.val.failure = (rb_js_abi_host_js_abi_value_t){ *((int32_t*) (ptr + 4)) };
|
332
|
+
break;
|
333
|
+
}
|
334
|
+
}
|
335
|
+
*ret0 = variant;
|
336
|
+
}
|
337
|
+
__attribute__((import_module("rb-js-abi-host"), import_name("reflect-set-prototype-of: func(target: handle<js-abi-value>, prototype: handle<js-abi-value>) -> bool")))
|
338
|
+
int32_t __wasm_import_rb_js_abi_host_reflect_set_prototype_of(int32_t, int32_t);
|
339
|
+
bool rb_js_abi_host_reflect_set_prototype_of(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_js_abi_value_t prototype) {
|
340
|
+
int32_t ret = __wasm_import_rb_js_abi_host_reflect_set_prototype_of((target).idx, (prototype).idx);
|
341
|
+
return ret;
|
342
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#ifndef __BINDINGS_RB_JS_ABI_HOST_H
|
2
|
+
#define __BINDINGS_RB_JS_ABI_HOST_H
|
3
|
+
#ifdef __cplusplus
|
4
|
+
extern "C"
|
5
|
+
{
|
6
|
+
#endif
|
7
|
+
|
8
|
+
#include <stdint.h>
|
9
|
+
#include <stdbool.h>
|
10
|
+
|
11
|
+
typedef struct {
|
12
|
+
uint32_t idx;
|
13
|
+
} rb_js_abi_host_js_abi_value_t;
|
14
|
+
void rb_js_abi_host_js_abi_value_free(rb_js_abi_host_js_abi_value_t *ptr);
|
15
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_js_abi_value_clone(rb_js_abi_host_js_abi_value_t *ptr);
|
16
|
+
|
17
|
+
typedef struct {
|
18
|
+
char *ptr;
|
19
|
+
size_t len;
|
20
|
+
} rb_js_abi_host_string_t;
|
21
|
+
|
22
|
+
void rb_js_abi_host_string_set(rb_js_abi_host_string_t *ret, const char *s);
|
23
|
+
void rb_js_abi_host_string_dup(rb_js_abi_host_string_t *ret, const char *s);
|
24
|
+
void rb_js_abi_host_string_free(rb_js_abi_host_string_t *ret);
|
25
|
+
typedef struct {
|
26
|
+
uint8_t tag;
|
27
|
+
union {
|
28
|
+
rb_js_abi_host_js_abi_value_t success;
|
29
|
+
rb_js_abi_host_js_abi_value_t failure;
|
30
|
+
} val;
|
31
|
+
} rb_js_abi_host_js_abi_result_t;
|
32
|
+
#define RB_JS_ABI_HOST_JS_ABI_RESULT_SUCCESS 0
|
33
|
+
#define RB_JS_ABI_HOST_JS_ABI_RESULT_FAILURE 1
|
34
|
+
void rb_js_abi_host_js_abi_result_free(rb_js_abi_host_js_abi_result_t *ptr);
|
35
|
+
typedef struct {
|
36
|
+
uint8_t tag;
|
37
|
+
union {
|
38
|
+
double f64;
|
39
|
+
rb_js_abi_host_string_t bignum;
|
40
|
+
} val;
|
41
|
+
} rb_js_abi_host_raw_integer_t;
|
42
|
+
#define RB_JS_ABI_HOST_RAW_INTEGER_F64 0
|
43
|
+
#define RB_JS_ABI_HOST_RAW_INTEGER_BIGNUM 1
|
44
|
+
void rb_js_abi_host_raw_integer_free(rb_js_abi_host_raw_integer_t *ptr);
|
45
|
+
typedef struct {
|
46
|
+
rb_js_abi_host_js_abi_value_t *ptr;
|
47
|
+
size_t len;
|
48
|
+
} rb_js_abi_host_list_js_abi_value_t;
|
49
|
+
void rb_js_abi_host_list_js_abi_value_free(rb_js_abi_host_list_js_abi_value_t *ptr);
|
50
|
+
void rb_js_abi_host_eval_js(rb_js_abi_host_string_t *code, rb_js_abi_host_js_abi_result_t *ret0);
|
51
|
+
bool rb_js_abi_host_is_js(rb_js_abi_host_js_abi_value_t value);
|
52
|
+
bool rb_js_abi_host_instance_of(rb_js_abi_host_js_abi_value_t value, rb_js_abi_host_js_abi_value_t klass);
|
53
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_global_this(void);
|
54
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_int_to_js_number(int32_t value);
|
55
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_float_to_js_number(double value);
|
56
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_string_to_js_string(rb_js_abi_host_string_t *value);
|
57
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_bool_to_js_bool(bool value);
|
58
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_proc_to_js_function(uint32_t value);
|
59
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_rb_object_to_js_rb_value(uint32_t raw_rb_abi_value);
|
60
|
+
void rb_js_abi_host_js_value_to_string(rb_js_abi_host_js_abi_value_t value, rb_js_abi_host_string_t *ret0);
|
61
|
+
void rb_js_abi_host_js_value_to_integer(rb_js_abi_host_js_abi_value_t value, rb_js_abi_host_raw_integer_t *ret0);
|
62
|
+
void rb_js_abi_host_export_js_value_to_host(rb_js_abi_host_js_abi_value_t value);
|
63
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_import_js_value_from_host(void);
|
64
|
+
void rb_js_abi_host_js_value_typeof(rb_js_abi_host_js_abi_value_t value, rb_js_abi_host_string_t *ret0);
|
65
|
+
bool rb_js_abi_host_js_value_equal(rb_js_abi_host_js_abi_value_t lhs, rb_js_abi_host_js_abi_value_t rhs);
|
66
|
+
bool rb_js_abi_host_js_value_strictly_equal(rb_js_abi_host_js_abi_value_t lhs, rb_js_abi_host_js_abi_value_t rhs);
|
67
|
+
void rb_js_abi_host_reflect_apply(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_js_abi_value_t this_argument, rb_js_abi_host_list_js_abi_value_t *arguments, rb_js_abi_host_js_abi_result_t *ret0);
|
68
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_reflect_construct(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_list_js_abi_value_t *arguments);
|
69
|
+
bool rb_js_abi_host_reflect_delete_property(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_string_t *property_key);
|
70
|
+
void rb_js_abi_host_reflect_get(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_string_t *property_key, rb_js_abi_host_js_abi_result_t *ret0);
|
71
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_reflect_get_own_property_descriptor(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_string_t *property_key);
|
72
|
+
rb_js_abi_host_js_abi_value_t rb_js_abi_host_reflect_get_prototype_of(rb_js_abi_host_js_abi_value_t target);
|
73
|
+
bool rb_js_abi_host_reflect_has(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_string_t *property_key);
|
74
|
+
bool rb_js_abi_host_reflect_is_extensible(rb_js_abi_host_js_abi_value_t target);
|
75
|
+
void rb_js_abi_host_reflect_own_keys(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_list_js_abi_value_t *ret0);
|
76
|
+
bool rb_js_abi_host_reflect_prevent_extensions(rb_js_abi_host_js_abi_value_t target);
|
77
|
+
void rb_js_abi_host_reflect_set(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_string_t *property_key, rb_js_abi_host_js_abi_value_t value, rb_js_abi_host_js_abi_result_t *ret0);
|
78
|
+
bool rb_js_abi_host_reflect_set_prototype_of(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_js_abi_value_t prototype);
|
79
|
+
#ifdef __cplusplus
|
80
|
+
}
|
81
|
+
#endif
|
82
|
+
#endif
|
@@ -0,0 +1,47 @@
|
|
1
|
+
resource js-abi-value
|
2
|
+
|
3
|
+
variant js-abi-result {
|
4
|
+
success(js-abi-value),
|
5
|
+
failure(js-abi-value),
|
6
|
+
}
|
7
|
+
|
8
|
+
eval-js: func(code: string) -> js-abi-result
|
9
|
+
is-js: func(value: js-abi-value) -> bool
|
10
|
+
instance-of: func(value: js-abi-value, klass: js-abi-value) -> bool
|
11
|
+
global-this: func() -> js-abi-value
|
12
|
+
int-to-js-number: func(value: s32) -> js-abi-value
|
13
|
+
float-to-js-number: func(value: float64) -> js-abi-value
|
14
|
+
string-to-js-string: func(value: string) -> js-abi-value
|
15
|
+
bool-to-js-bool: func(value: bool) -> js-abi-value
|
16
|
+
proc-to-js-function: func(value: u32) -> js-abi-value
|
17
|
+
rb-object-to-js-rb-value: func(raw-rb-abi-value: u32) -> js-abi-value
|
18
|
+
|
19
|
+
js-value-to-string: func(value: js-abi-value) -> string
|
20
|
+
|
21
|
+
variant raw-integer {
|
22
|
+
f64(float64),
|
23
|
+
bignum(string),
|
24
|
+
}
|
25
|
+
|
26
|
+
js-value-to-integer: func(value: js-abi-value) -> raw-integer
|
27
|
+
|
28
|
+
export-js-value-to-host: func(value: js-abi-value)
|
29
|
+
import-js-value-from-host: func() -> js-abi-value
|
30
|
+
|
31
|
+
js-value-typeof: func(value: js-abi-value) -> string
|
32
|
+
|
33
|
+
js-value-equal: func(lhs: js-abi-value, rhs: js-abi-value) -> bool
|
34
|
+
js-value-strictly-equal: func(lhs: js-abi-value, rhs: js-abi-value) -> bool
|
35
|
+
|
36
|
+
reflect-apply: func(target: js-abi-value, this-argument: js-abi-value, arguments: list<js-abi-value>) -> js-abi-result
|
37
|
+
reflect-construct: func(target: js-abi-value, arguments: list<js-abi-value>) -> js-abi-value
|
38
|
+
reflect-delete-property: func(target: js-abi-value, property-key: string) -> bool
|
39
|
+
reflect-get: func(target: js-abi-value, property-key: string) -> js-abi-result
|
40
|
+
reflect-get-own-property-descriptor: func(target: js-abi-value, property-key: string) -> js-abi-value
|
41
|
+
reflect-get-prototype-of: func(target: js-abi-value) -> js-abi-value
|
42
|
+
reflect-has: func(target: js-abi-value, property-key: string) -> bool
|
43
|
+
reflect-is-extensible: func(target: js-abi-value) -> bool
|
44
|
+
reflect-own-keys: func(target: js-abi-value) -> list<js-abi-value>
|
45
|
+
reflect-prevent-extensions: func(target: js-abi-value) -> bool
|
46
|
+
reflect-set: func(target: js-abi-value, property-key: string, value: js-abi-value) -> js-abi-result
|
47
|
+
reflect-set-prototype-of: func(target: js-abi-value, prototype: js-abi-value) -> bool
|
data/ext/js/depend
ADDED
data/ext/js/extconf.rb
ADDED