Skip to content

Conversation

@RunDevelopment
Copy link
Contributor

@RunDevelopment RunDevelopment commented Oct 24, 2024

Fixes #2822

This adds WASM ABI support for i128 and u128. Both are split into 2 u64 and passed as such in the ABI.

The following types can now be used in argument and return positions: i128, u128, Option<i128>, and Option<u128>. Return positions can also use Result<i128, E> and Result<u128, E>.

It's important to note that Result<Option<i128>, E> is not supported. This is because the WasmAbi trait supports at most 4 primitives, but Result<Option<i128>, E> would require 5 primitives (2 for i128, 1 for the option tag, 1 for the result tag, and 1 for the error variant value). Future Result<Option<T>, E> ABI optimizations (either combining the result and option tag into one primitive, or raising the number of supported primitives to 5) will make Result<Option<i128>, E> possible, but this should be a separate PR IMO.


Related to #4201.

@daxpedda
Copy link
Member

daxpedda commented Nov 9, 2024

Converting to draft until #4246 is resolved.

@daxpedda daxpedda marked this pull request as draft November 9, 2024 20:30
@RunDevelopment
Copy link
Contributor Author

Converting to draft until #4246 is resolved.

Either that, or I just use BigInt(value) everywhere for now. If we decide to bigint literals in #4246 later, I can just make another PR to change it later. Grepping for BigInt( isn't hard.

@daxpedda
Copy link
Member

Converting to draft until #4246 is resolved.

Either that, or I just use BigInt(value) everywhere for now. If we decide to bigint literals in #4246 later, I can just make another PR to change it later. Grepping for BigInt( isn't hard.

Yep, please go ahead and just use the constructor!

Copy link
Member

@daxpedda daxpedda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

Just some nits and a changelog entry missing.

@RunDevelopment RunDevelopment marked this pull request as ready for review November 11, 2024 12:13
Copy link
Member

@daxpedda daxpedda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@daxpedda daxpedda merged commit df9893b into wasm-bindgen:main Nov 11, 2024
41 checks passed
@RunDevelopment RunDevelopment deleted the int128 branch November 11, 2024 14:19
TylerJang27 pushed a commit to TylerJang27/wasm-bindgen that referenced this pull request Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants