Skip to content

Commit 22f1e0a

Browse files
Rename raw-integer variant field f64 to as-float
`f64` is now a keyword in WIT
1 parent 730f157 commit 22f1e0a

File tree

11 files changed

+21
-21
lines changed

11 files changed

+21
-21
lines changed

packages/gems/js/ext/js/bindgen/ext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ void ruby_js_js_runtime_js_value_to_integer(ruby_js_js_runtime_borrow_js_abi_val
331331
variant.tag = (int32_t) *((uint8_t*) (ptr + 0));
332332
switch ((int32_t) variant.tag) {
333333
case 0: {
334-
variant.val.float_ = *((double*) (ptr + 8));
334+
variant.val.as_float = *((double*) (ptr + 8));
335335
break;
336336
}
337337
case 1: {

packages/gems/js/ext/js/bindgen/ext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ typedef struct ruby_js_js_runtime_js_abi_result_t {
3535
typedef struct ruby_js_js_runtime_raw_integer_t {
3636
uint8_t tag;
3737
union {
38-
double float_;
38+
double as_float;
3939
ext_string_t bignum;
4040
} val;
4141
} ruby_js_js_runtime_raw_integer_t;
4242

43-
#define RUBY_JS_JS_RUNTIME_RAW_INTEGER_FLOAT 0
43+
#define RUBY_JS_JS_RUNTIME_RAW_INTEGER_AS_FLOAT 0
4444
#define RUBY_JS_JS_RUNTIME_RAW_INTEGER_BIGNUM 1
4545

4646
typedef struct ruby_js_js_runtime_list_borrow_js_abi_value_t {
Binary file not shown.

packages/gems/js/ext/js/bindgen/legacy/rb-js-abi-host.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void rb_js_abi_host_js_value_to_string(rb_js_abi_host_js_abi_value_t value, rb_j
161161
__wasm_import_rb_js_abi_host_js_value_to_string((value).idx, ptr);
162162
*ret0 = (rb_js_abi_host_string_t) { (char*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) };
163163
}
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) }")))
164+
__attribute__((import_module("rb-js-abi-host"), import_name("js-value-to-integer: func(value: handle<js-abi-value>) -> variant { as-float(float64), bignum(string) }")))
165165
void __wasm_import_rb_js_abi_host_js_value_to_integer(int32_t, int32_t);
166166
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) {
167167

@@ -173,7 +173,7 @@ void rb_js_abi_host_js_value_to_integer(rb_js_abi_host_js_abi_value_t value, rb_
173173
variant.tag = (int32_t) (*((uint8_t*) (ptr + 0)));
174174
switch ((int32_t) variant.tag) {
175175
case 0: {
176-
variant.val.f64 = *((double*) (ptr + 8));
176+
variant.val.as_float = *((double*) (ptr + 8));
177177
break;
178178
}
179179
case 1: {

packages/gems/js/ext/js/bindgen/legacy/rb-js-abi-host.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ extern "C"
3535
typedef struct {
3636
uint8_t tag;
3737
union {
38-
double f64;
38+
double as_float;
3939
rb_js_abi_host_string_t bignum;
4040
} val;
4141
} rb_js_abi_host_raw_integer_t;
42-
#define RB_JS_ABI_HOST_RAW_INTEGER_F64 0
42+
#define RB_JS_ABI_HOST_RAW_INTEGER_AS_FLOAT 0
4343
#define RB_JS_ABI_HOST_RAW_INTEGER_BIGNUM 1
4444
void rb_js_abi_host_raw_integer_free(rb_js_abi_host_raw_integer_t *ptr);
4545
typedef struct {

packages/gems/js/ext/js/bindgen/legacy/rb-js-abi-host.wit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ rb-object-to-js-rb-value: func(raw-rb-abi-value: u32) -> js-abi-value
1919
js-value-to-string: func(value: js-abi-value) -> string
2020

2121
variant raw-integer {
22-
f64(float64),
22+
as-float(float64),
2323
bignum(string),
2424
}
2525

packages/gems/js/ext/js/js-core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ static VALUE _rb_js_obj_to_i(VALUE obj) {
376376
rb_js_abi_host_raw_integer_t ret;
377377
rb_js_abi_host_js_value_to_integer(p->abi, &ret);
378378
VALUE result;
379-
if (ret.tag == RB_JS_ABI_HOST_RAW_INTEGER_F64) {
380-
result = rb_dbl2big(ret.val.f64);
379+
if (ret.tag == RB_JS_ABI_HOST_RAW_INTEGER_AS_FLOAT) {
380+
result = rb_dbl2big(ret.val.as_float);
381381
} else {
382382
result = rb_cstr2inum((const char *)ret.val.bignum.ptr, 10);
383383
}
@@ -406,8 +406,8 @@ static VALUE _rb_js_obj_to_f(VALUE obj) {
406406
rb_js_abi_host_raw_integer_t ret;
407407
VALUE result;
408408
rb_js_abi_host_js_value_to_integer(p->abi, &ret);
409-
if (ret.tag == RB_JS_ABI_HOST_RAW_INTEGER_F64) {
410-
result = rb_float_new(ret.val.f64);
409+
if (ret.tag == RB_JS_ABI_HOST_RAW_INTEGER_AS_FLOAT) {
410+
result = rb_float_new(ret.val.as_float);
411411
} else {
412412
result = DBL2NUM(rb_cstr_to_dbl((const char *)ret.val.bignum.ptr, FALSE));
413413
}

packages/gems/js/wit/js-runtime.wit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface js-runtime {
2323
js-value-to-string: func(value: borrow<js-abi-value>) -> string;
2424

2525
variant raw-integer {
26-
float(float64),
26+
as-float(float64),
2727
bignum(string),
2828
}
2929

packages/npm-packages/ruby-wasm-wasi/src/bindgen/rb-js-abi-host.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ export interface JsAbiResultFailure {
77
tag: "failure",
88
val: JsAbiValue,
99
}
10-
export type RawInteger = RawIntegerF64 | RawIntegerBignum;
11-
export interface RawIntegerF64 {
12-
tag: "f64",
10+
export type RawInteger = RawIntegerAsFloat | RawIntegerBignum;
11+
export interface RawIntegerAsFloat {
12+
tag: "as-float",
1313
val: number,
1414
}
1515
export interface RawIntegerBignum {

packages/npm-packages/ruby-wasm-wasi/src/bindgen/rb-js-abi-host.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ export function addRbJsAbiHostToImports(imports, obj, get_export) {
7575
data_view(memory).setInt32(arg1 + 4, len0, true);
7676
data_view(memory).setInt32(arg1 + 0, ptr0, true);
7777
};
78-
imports["rb-js-abi-host"]["js-value-to-integer: func(value: handle<js-abi-value>) -> variant { f64(float64), bignum(string) }"] = function(arg0, arg1) {
78+
imports["rb-js-abi-host"]["js-value-to-integer: func(value: handle<js-abi-value>) -> variant { as-float(float64), bignum(string) }"] = function(arg0, arg1) {
7979
const memory = get_export("memory");
8080
const realloc = get_export("cabi_realloc");
8181
const ret0 = obj.jsValueToInteger(resources0.get(arg0));
8282
const variant1 = ret0;
8383
switch (variant1.tag) {
84-
case "f64": {
84+
case "as-float": {
8585
const e = variant1.val;
8686
data_view(memory).setInt8(arg1 + 0, 0, true);
8787
data_view(memory).setFloat64(arg1 + 8, +e, true);

0 commit comments

Comments
 (0)