Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make generated ffi portable, add 32bit support #13

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

gnunicorn
Copy link

This replaces several instance where we were using u64 or i64 as hard-coded instances for isize and usize with its dart counterparts of UintPtr and IntPtr. Thus rendering the generated dart file not only platform-compatible with the underlying target system, but also allowing us to the same generated dart file across any number of platforms. Prior to this for the few cases this was using usize-types, the generator would create a platform-specific mapping.

As a result, we do now support 32bit targets as well.

This replaces several instance where we were using u64 or i64 as hard-coded
instances for isize and usize with its dart counterparts of `UintPtr` and `IntPtr``.
Thus rendering the generated dart file not only platform-compatible with
the underlying target system, but also allowing us to the same generated
dart file across any number of platforms. Prior to this for the few cases
this was using usize-types, the generator would create a platform-specific
mapping.

As a result, we do now support 32bit targets as well.
Comment on lines +43 to +51
#[cfg(target_pointer_width = "32")]
type IPtr = i32;
#[cfg(target_pointer_width = "32")]
type UPtr = i32;
#[cfg(target_pointer_width = "64")]
type IPtr = i64;
#[cfg(target_pointer_width = "64")]
type UPtr = i64;

Choose a reason for hiding this comment

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

Great job.

Copy link

@bitfriend bitfriend left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@gnunicorn gnunicorn merged commit 0a2fd39 into main Jul 18, 2024
1 of 3 checks passed
@gnunicorn gnunicorn deleted the ben-add-32bit-support branch July 18, 2024 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants