@@ -47,6 +47,18 @@ void rb_js_abi_host_string_free(rb_js_abi_host_string_t *ret) {
4747 ret -> ptr = NULL ;
4848 ret -> len = 0 ;
4949}
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+ }
5062void rb_js_abi_host_raw_integer_free (rb_js_abi_host_raw_integer_t * ptr ) {
5163 switch ((int32_t ) ptr -> tag ) {
5264 case 1 : {
@@ -63,11 +75,27 @@ void rb_js_abi_host_list_js_abi_value_free(rb_js_abi_host_list_js_abi_value_t *p
6375 free (ptr -> ptr );
6476 }
6577}
66- __attribute__((import_module ("rb-js-abi-host" ), import_name ("eval-js: func(code: string) -> handle<js-abi-value>" )))
67- int32_t __wasm_import_rb_js_abi_host_eval_js (int32_t , int32_t );
68- rb_js_abi_host_js_abi_value_t rb_js_abi_host_eval_js (rb_js_abi_host_string_t * code ) {
69- int32_t ret = __wasm_import_rb_js_abi_host_eval_js ((int32_t ) (* code ).ptr , (int32_t ) (* code ).len );
70- return (rb_js_abi_host_js_abi_value_t ){ ret };
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 ;
7199}
72100__attribute__((import_module ("rb-js-abi-host" ), import_name ("is-js: func(value: handle<js-abi-value>) -> bool" )))
73101int32_t __wasm_import_rb_js_abi_host_is_js (int32_t );
@@ -182,11 +210,27 @@ bool rb_js_abi_host_js_value_strictly_equal(rb_js_abi_host_js_abi_value_t lhs, r
182210 int32_t ret = __wasm_import_rb_js_abi_host_js_value_strictly_equal ((lhs ).idx , (rhs ).idx );
183211 return ret ;
184212}
185- __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>>) -> handle<js-abi-value>" )))
186- int32_t __wasm_import_rb_js_abi_host_reflect_apply (int32_t , int32_t , int32_t , int32_t );
187- 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 ) {
188- int32_t ret = __wasm_import_rb_js_abi_host_reflect_apply ((target ).idx , (this_argument ).idx , (int32_t ) (* arguments ).ptr , (int32_t ) (* arguments ).len );
189- return (rb_js_abi_host_js_abi_value_t ){ ret };
213+ __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>) }" )))
214+ void __wasm_import_rb_js_abi_host_reflect_apply (int32_t , int32_t , int32_t , int32_t , int32_t );
215+ 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 ) {
216+
217+ __attribute__((aligned (4 )))
218+ uint8_t ret_area [8 ];
219+ int32_t ptr = (int32_t ) & ret_area ;
220+ __wasm_import_rb_js_abi_host_reflect_apply ((target ).idx , (this_argument ).idx , (int32_t ) (* arguments ).ptr , (int32_t ) (* arguments ).len , ptr );
221+ rb_js_abi_host_js_abi_result_t variant ;
222+ variant .tag = (int32_t ) (* ((uint8_t * ) (ptr + 0 )));
223+ switch ((int32_t ) variant .tag ) {
224+ case 0 : {
225+ variant .val .success = (rb_js_abi_host_js_abi_value_t ){ * ((int32_t * ) (ptr + 4 )) };
226+ break ;
227+ }
228+ case 1 : {
229+ variant .val .failure = (rb_js_abi_host_js_abi_value_t ){ * ((int32_t * ) (ptr + 4 )) };
230+ break ;
231+ }
232+ }
233+ * ret0 = variant ;
190234}
191235__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>" )))
192236int32_t __wasm_import_rb_js_abi_host_reflect_construct (int32_t , int32_t , int32_t );
0 commit comments