From b1fcc9e6bf77e98a7798fc8a4b40c3f2e814f701 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 6 Nov 2022 17:45:05 -0800 Subject: Fix bug when passing ABI Types as integers --- src/bun.js/api/ffi.zig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/bun.js/api/ffi.zig b/src/bun.js/api/ffi.zig index 0fe736258..dd5de1da7 100644 --- a/src/bun.js/api/ffi.zig +++ b/src/bun.js/api/ffi.zig @@ -522,9 +522,9 @@ pub const FFI = struct { } if (val.isAnyInt()) { - const int = val.toInt32(); + const int = val.to(i32); switch (int) { - 0...14 => { + 0...ABIType.max => { abi_types.appendAssumeCapacity(@intToEnum(ABIType, int)); continue; }, @@ -561,7 +561,7 @@ pub const FFI = struct { if (ret_value.isAnyInt()) { const int = ret_value.toInt32(); switch (int) { - 0...14 => { + 0...ABIType.max => { return_type = @intToEnum(ABIType, int); break :brk; }, @@ -1330,6 +1330,8 @@ pub const FFI = struct { function = 17, + pub const max = @enumToInt(ABIType.function); + /// Types that we can directly pass through as an `int64_t` pub fn needsACastInC(this: ABIType) bool { return switch (this) { -- cgit v1.2.3