|
| 1 | +#include <stdlib.h> |
| 2 | +#include <rb-js-abi-host.h> |
| 3 | + |
| 4 | +__attribute__((weak, export_name("canonical_abi_realloc"))) |
| 5 | +void *canonical_abi_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__((weak, export_name("canonical_abi_free"))) |
| 18 | +void canonical_abi_free( |
| 19 | +void *ptr, |
| 20 | +size_t size, |
| 21 | +size_t align |
| 22 | +) { |
| 23 | + free(ptr); |
| 24 | +} |
| 25 | + |
| 26 | +__attribute__((import_module("canonical_abi"), import_name("resource_drop_js-abi-value"))) |
| 27 | +void __resource_js_abi_value_drop(uint32_t idx); |
| 28 | + |
| 29 | +void rb_js_abi_host_js_abi_value_free(rb_js_abi_host_js_abi_value_t *ptr) { |
| 30 | + __resource_js_abi_value_drop(ptr->idx); |
| 31 | +} |
| 32 | + |
| 33 | +__attribute__((import_module("canonical_abi"), import_name("resource_clone_js-abi-value"))) |
| 34 | +uint32_t __resource_js_abi_value_clone(uint32_t idx); |
| 35 | + |
| 36 | +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) { |
| 37 | + return (rb_js_abi_host_js_abi_value_t){__resource_js_abi_value_clone(ptr->idx)}; |
| 38 | +} |
| 39 | +#include <string.h> |
| 40 | + |
| 41 | +void rb_js_abi_host_string_set(rb_js_abi_host_string_t *ret, const char *s) { |
| 42 | + ret->ptr = (char*) s; |
| 43 | + ret->len = strlen(s); |
| 44 | +} |
| 45 | + |
| 46 | +void rb_js_abi_host_string_dup(rb_js_abi_host_string_t *ret, const char *s) { |
| 47 | + ret->len = strlen(s); |
| 48 | + ret->ptr = canonical_abi_realloc(NULL, 0, 1, ret->len); |
| 49 | + memcpy(ret->ptr, s, ret->len); |
| 50 | +} |
| 51 | + |
| 52 | +void rb_js_abi_host_string_free(rb_js_abi_host_string_t *ret) { |
| 53 | + canonical_abi_free(ret->ptr, ret->len, 1); |
| 54 | + ret->ptr = NULL; |
| 55 | + ret->len = 0; |
| 56 | +} |
| 57 | +void rb_js_abi_host_list_js_abi_value_free(rb_js_abi_host_list_js_abi_value_t *ptr) { |
| 58 | + for (size_t i = 0; i < ptr->len; i++) { |
| 59 | + rb_js_abi_host_js_abi_value_free(&ptr->ptr[i]); |
| 60 | + } |
| 61 | + canonical_abi_free(ptr->ptr, ptr->len * 4, 4); |
| 62 | +} |
| 63 | +static int64_t RET_AREA[2]; |
| 64 | +__attribute__((import_module("rb-js-abi-host"), import_name("eval-js"))) |
| 65 | +int32_t __wasm_import_rb_js_abi_host_eval_js(int32_t, int32_t); |
| 66 | +rb_js_abi_host_js_abi_value_t rb_js_abi_host_eval_js(rb_js_abi_host_string_t *code) { |
| 67 | + int32_t ret = __wasm_import_rb_js_abi_host_eval_js((int32_t) (*code).ptr, (int32_t) (*code).len); |
| 68 | + return (rb_js_abi_host_js_abi_value_t){ ret }; |
| 69 | +} |
| 70 | +__attribute__((import_module("rb-js-abi-host"), import_name("is-js"))) |
| 71 | +int32_t __wasm_import_rb_js_abi_host_is_js(int32_t); |
| 72 | +bool rb_js_abi_host_is_js(rb_js_abi_host_js_abi_value_t value) { |
| 73 | + int32_t ret = __wasm_import_rb_js_abi_host_is_js((value).idx); |
| 74 | + return ret; |
| 75 | +} |
| 76 | +__attribute__((import_module("rb-js-abi-host"), import_name("instance-of"))) |
| 77 | +int32_t __wasm_import_rb_js_abi_host_instance_of(int32_t, int32_t); |
| 78 | +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) { |
| 79 | + int32_t ret = __wasm_import_rb_js_abi_host_instance_of((value).idx, (klass).idx); |
| 80 | + return ret; |
| 81 | +} |
| 82 | +__attribute__((import_module("rb-js-abi-host"), import_name("global-this"))) |
| 83 | +int32_t __wasm_import_rb_js_abi_host_global_this(void); |
| 84 | +rb_js_abi_host_js_abi_value_t rb_js_abi_host_global_this(void) { |
| 85 | + int32_t ret = __wasm_import_rb_js_abi_host_global_this(); |
| 86 | + return (rb_js_abi_host_js_abi_value_t){ ret }; |
| 87 | +} |
| 88 | +__attribute__((import_module("rb-js-abi-host"), import_name("int-to-js-number"))) |
| 89 | +int32_t __wasm_import_rb_js_abi_host_int_to_js_number(int32_t); |
| 90 | +rb_js_abi_host_js_abi_value_t rb_js_abi_host_int_to_js_number(int32_t value) { |
| 91 | + int32_t ret = __wasm_import_rb_js_abi_host_int_to_js_number(value); |
| 92 | + return (rb_js_abi_host_js_abi_value_t){ ret }; |
| 93 | +} |
| 94 | +__attribute__((import_module("rb-js-abi-host"), import_name("string-to-js-string"))) |
| 95 | +int32_t __wasm_import_rb_js_abi_host_string_to_js_string(int32_t, int32_t); |
| 96 | +rb_js_abi_host_js_abi_value_t rb_js_abi_host_string_to_js_string(rb_js_abi_host_string_t *value) { |
| 97 | + int32_t ret = __wasm_import_rb_js_abi_host_string_to_js_string((int32_t) (*value).ptr, (int32_t) (*value).len); |
| 98 | + return (rb_js_abi_host_js_abi_value_t){ ret }; |
| 99 | +} |
| 100 | +__attribute__((import_module("rb-js-abi-host"), import_name("bool-to-js-bool"))) |
| 101 | +int32_t __wasm_import_rb_js_abi_host_bool_to_js_bool(int32_t); |
| 102 | +rb_js_abi_host_js_abi_value_t rb_js_abi_host_bool_to_js_bool(bool value) { |
| 103 | + int32_t variant; |
| 104 | + switch ((int32_t) value) { |
| 105 | + case 0: { |
| 106 | + variant = 0; |
| 107 | + break; |
| 108 | + } |
| 109 | + case 1: { |
| 110 | + variant = 1; |
| 111 | + break; |
| 112 | + } |
| 113 | + } |
| 114 | + int32_t ret = __wasm_import_rb_js_abi_host_bool_to_js_bool(variant); |
| 115 | + return (rb_js_abi_host_js_abi_value_t){ ret }; |
| 116 | +} |
| 117 | +__attribute__((import_module("rb-js-abi-host"), import_name("proc-to-js-function"))) |
| 118 | +int32_t __wasm_import_rb_js_abi_host_proc_to_js_function(int32_t); |
| 119 | +rb_js_abi_host_js_abi_value_t rb_js_abi_host_proc_to_js_function(uint32_t value) { |
| 120 | + int32_t ret = __wasm_import_rb_js_abi_host_proc_to_js_function((int32_t) (value)); |
| 121 | + return (rb_js_abi_host_js_abi_value_t){ ret }; |
| 122 | +} |
| 123 | +__attribute__((import_module("rb-js-abi-host"), import_name("rb-object-to-js-rb-value"))) |
| 124 | +int32_t __wasm_import_rb_js_abi_host_rb_object_to_js_rb_value(int32_t); |
| 125 | +rb_js_abi_host_js_abi_value_t rb_js_abi_host_rb_object_to_js_rb_value(uint32_t raw_rb_abi_value) { |
| 126 | + int32_t ret = __wasm_import_rb_js_abi_host_rb_object_to_js_rb_value((int32_t) (raw_rb_abi_value)); |
| 127 | + return (rb_js_abi_host_js_abi_value_t){ ret }; |
| 128 | +} |
| 129 | +__attribute__((import_module("rb-js-abi-host"), import_name("js-value-to-string"))) |
| 130 | +void __wasm_import_rb_js_abi_host_js_value_to_string(int32_t, int32_t); |
| 131 | +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) { |
| 132 | + int32_t ptr = (int32_t) &RET_AREA; |
| 133 | + __wasm_import_rb_js_abi_host_js_value_to_string((value).idx, ptr); |
| 134 | + *ret0 = (rb_js_abi_host_string_t) { (char*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 8))) }; |
| 135 | +} |
| 136 | +__attribute__((import_module("rb-js-abi-host"), import_name("export-js-value-to-host"))) |
| 137 | +void __wasm_import_rb_js_abi_host_export_js_value_to_host(int32_t); |
| 138 | +void rb_js_abi_host_export_js_value_to_host(rb_js_abi_host_js_abi_value_t value) { |
| 139 | + __wasm_import_rb_js_abi_host_export_js_value_to_host((value).idx); |
| 140 | +} |
| 141 | +__attribute__((import_module("rb-js-abi-host"), import_name("import-js-value-from-host"))) |
| 142 | +int32_t __wasm_import_rb_js_abi_host_import_js_value_from_host(void); |
| 143 | +rb_js_abi_host_js_abi_value_t rb_js_abi_host_import_js_value_from_host(void) { |
| 144 | + int32_t ret = __wasm_import_rb_js_abi_host_import_js_value_from_host(); |
| 145 | + return (rb_js_abi_host_js_abi_value_t){ ret }; |
| 146 | +} |
| 147 | +__attribute__((import_module("rb-js-abi-host"), import_name("js-value-typeof"))) |
| 148 | +void __wasm_import_rb_js_abi_host_js_value_typeof(int32_t, int32_t); |
| 149 | +void rb_js_abi_host_js_value_typeof(rb_js_abi_host_js_abi_value_t value, rb_js_abi_host_string_t *ret0) { |
| 150 | + int32_t ptr = (int32_t) &RET_AREA; |
| 151 | + __wasm_import_rb_js_abi_host_js_value_typeof((value).idx, ptr); |
| 152 | + *ret0 = (rb_js_abi_host_string_t) { (char*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 8))) }; |
| 153 | +} |
| 154 | +__attribute__((import_module("rb-js-abi-host"), import_name("js-value-equal"))) |
| 155 | +int32_t __wasm_import_rb_js_abi_host_js_value_equal(int32_t, int32_t); |
| 156 | +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) { |
| 157 | + int32_t ret = __wasm_import_rb_js_abi_host_js_value_equal((lhs).idx, (rhs).idx); |
| 158 | + return ret; |
| 159 | +} |
| 160 | +__attribute__((import_module("rb-js-abi-host"), import_name("js-value-strictly-equal"))) |
| 161 | +int32_t __wasm_import_rb_js_abi_host_js_value_strictly_equal(int32_t, int32_t); |
| 162 | +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) { |
| 163 | + int32_t ret = __wasm_import_rb_js_abi_host_js_value_strictly_equal((lhs).idx, (rhs).idx); |
| 164 | + return ret; |
| 165 | +} |
| 166 | +__attribute__((import_module("rb-js-abi-host"), import_name("reflect-apply"))) |
| 167 | +int32_t __wasm_import_rb_js_abi_host_reflect_apply(int32_t, int32_t, int32_t, int32_t); |
| 168 | +rb_js_abi_host_js_abi_value_t 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) { |
| 169 | + int32_t ret = __wasm_import_rb_js_abi_host_reflect_apply((target).idx, (this_argument).idx, (int32_t) (*arguments).ptr, (int32_t) (*arguments).len); |
| 170 | + return (rb_js_abi_host_js_abi_value_t){ ret }; |
| 171 | +} |
| 172 | +__attribute__((import_module("rb-js-abi-host"), import_name("reflect-construct"))) |
| 173 | +int32_t __wasm_import_rb_js_abi_host_reflect_construct(int32_t, int32_t, int32_t); |
| 174 | +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) { |
| 175 | + int32_t ret = __wasm_import_rb_js_abi_host_reflect_construct((target).idx, (int32_t) (*arguments).ptr, (int32_t) (*arguments).len); |
| 176 | + return (rb_js_abi_host_js_abi_value_t){ ret }; |
| 177 | +} |
| 178 | +__attribute__((import_module("rb-js-abi-host"), import_name("reflect-delete-property"))) |
| 179 | +int32_t __wasm_import_rb_js_abi_host_reflect_delete_property(int32_t, int32_t, int32_t); |
| 180 | +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) { |
| 181 | + int32_t ret = __wasm_import_rb_js_abi_host_reflect_delete_property((target).idx, (int32_t) (*property_key).ptr, (int32_t) (*property_key).len); |
| 182 | + return ret; |
| 183 | +} |
| 184 | +__attribute__((import_module("rb-js-abi-host"), import_name("reflect-get"))) |
| 185 | +int32_t __wasm_import_rb_js_abi_host_reflect_get(int32_t, int32_t, int32_t); |
| 186 | +rb_js_abi_host_js_abi_value_t rb_js_abi_host_reflect_get(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_string_t *property_key) { |
| 187 | + int32_t ret = __wasm_import_rb_js_abi_host_reflect_get((target).idx, (int32_t) (*property_key).ptr, (int32_t) (*property_key).len); |
| 188 | + return (rb_js_abi_host_js_abi_value_t){ ret }; |
| 189 | +} |
| 190 | +__attribute__((import_module("rb-js-abi-host"), import_name("reflect-get-own-property-descriptor"))) |
| 191 | +int32_t __wasm_import_rb_js_abi_host_reflect_get_own_property_descriptor(int32_t, int32_t, int32_t); |
| 192 | +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) { |
| 193 | + 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); |
| 194 | + return (rb_js_abi_host_js_abi_value_t){ ret }; |
| 195 | +} |
| 196 | +__attribute__((import_module("rb-js-abi-host"), import_name("reflect-get-prototype-of"))) |
| 197 | +int32_t __wasm_import_rb_js_abi_host_reflect_get_prototype_of(int32_t); |
| 198 | +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) { |
| 199 | + int32_t ret = __wasm_import_rb_js_abi_host_reflect_get_prototype_of((target).idx); |
| 200 | + return (rb_js_abi_host_js_abi_value_t){ ret }; |
| 201 | +} |
| 202 | +__attribute__((import_module("rb-js-abi-host"), import_name("reflect-has"))) |
| 203 | +int32_t __wasm_import_rb_js_abi_host_reflect_has(int32_t, int32_t, int32_t); |
| 204 | +bool rb_js_abi_host_reflect_has(rb_js_abi_host_js_abi_value_t target, rb_js_abi_host_string_t *property_key) { |
| 205 | + int32_t ret = __wasm_import_rb_js_abi_host_reflect_has((target).idx, (int32_t) (*property_key).ptr, (int32_t) (*property_key).len); |
| 206 | + return ret; |
| 207 | +} |
| 208 | +__attribute__((import_module("rb-js-abi-host"), import_name("reflect-is-extensible"))) |
| 209 | +int32_t __wasm_import_rb_js_abi_host_reflect_is_extensible(int32_t); |
| 210 | +bool rb_js_abi_host_reflect_is_extensible(rb_js_abi_host_js_abi_value_t target) { |
| 211 | + int32_t ret = __wasm_import_rb_js_abi_host_reflect_is_extensible((target).idx); |
| 212 | + return ret; |
| 213 | +} |
| 214 | +__attribute__((import_module("rb-js-abi-host"), import_name("reflect-own-keys"))) |
| 215 | +void __wasm_import_rb_js_abi_host_reflect_own_keys(int32_t, int32_t); |
| 216 | +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) { |
| 217 | + int32_t ptr = (int32_t) &RET_AREA; |
| 218 | + __wasm_import_rb_js_abi_host_reflect_own_keys((target).idx, ptr); |
| 219 | + *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 + 8))) }; |
| 220 | +} |
| 221 | +__attribute__((import_module("rb-js-abi-host"), import_name("reflect-prevent-extensions"))) |
| 222 | +int32_t __wasm_import_rb_js_abi_host_reflect_prevent_extensions(int32_t); |
| 223 | +bool rb_js_abi_host_reflect_prevent_extensions(rb_js_abi_host_js_abi_value_t target) { |
| 224 | + int32_t ret = __wasm_import_rb_js_abi_host_reflect_prevent_extensions((target).idx); |
| 225 | + return ret; |
| 226 | +} |
| 227 | +__attribute__((import_module("rb-js-abi-host"), import_name("reflect-set"))) |
| 228 | +int32_t __wasm_import_rb_js_abi_host_reflect_set(int32_t, int32_t, int32_t, int32_t); |
| 229 | +bool 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) { |
| 230 | + int32_t ret = __wasm_import_rb_js_abi_host_reflect_set((target).idx, (int32_t) (*property_key).ptr, (int32_t) (*property_key).len, (value).idx); |
| 231 | + return ret; |
| 232 | +} |
| 233 | +__attribute__((import_module("rb-js-abi-host"), import_name("reflect-set-prototype-of"))) |
| 234 | +int32_t __wasm_import_rb_js_abi_host_reflect_set_prototype_of(int32_t, int32_t); |
| 235 | +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) { |
| 236 | + int32_t ret = __wasm_import_rb_js_abi_host_reflect_set_prototype_of((target).idx, (prototype).idx); |
| 237 | + return ret; |
| 238 | +} |
0 commit comments