Added unsigned integer support (u8, u16, u32, u64) in rs_post.#658
Draft
tanu15-png wants to merge 1 commit intometacall:developfrom
Draft
Added unsigned integer support (u8, u16, u32, u64) in rs_post.#658tanu15-png wants to merge 1 commit intometacall:developfrom
tanu15-png wants to merge 1 commit intometacall:developfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for u8, u16, u32, and u64 in the rs_port. Since MetaCall does not provide native unsigned integer types, all unsigned integers are mapped to METACALL_LONG, which corresponds to i64, the largest integer type available in MetaCall. The design decisions are as follows:
METACALL_LONG is used for all unsigned types to ensure a consistent and safe internal representation.
Incoming values are converted to i64 first and then range-checked before casting to the target unsigned type.
Negative values are rejected to prevent invalid unsigned conversions.
Overflow beyond the target type’s maximum value is explicitly checked and rejected.
Although smaller types like u8 and u16 could fit into METACALL_SHORT or METACALL_INT, using METACALL_LONG avoids cross-language inconsistencies and simplifies conversion logic.
For u64, full support is limited because METACALL_LONG maps to i64, meaning values above i64::MAX cannot be represented.
for example:
Python integers are received as METACALL_LONG regardless of their size.
Using METACALL_LONG ensures compatibility with Python’s integer model.
Mapping unsigned rust types (u8, u16, u32) to METACALL_LONG avoids mismatches when values originate from Python.