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

fix: Fix optional bools in JNI structs #283

Merged
merged 2 commits into from
Nov 5, 2024
Merged

Conversation

mrousavy
Copy link
Owner

@mrousavy mrousavy commented Nov 5, 2024

Fixes an error where structs that contain optional bools where not properly converted from Java to C++.

interface SomeStruct {
  someBool?: boolean
}

The reason this failed is because a Java boolean is not the same as a C++ boolean in JNI. It is an unsigned char, whereas a C++ boolean is a bool.
This cannot be implicitly converted, so we have to wrap booleans with static_cast<bool>(value) in order for it to work. This is what this PR now does.

And it adds the code to the example so it doesn't break in the future anymore.

Copy link

vercel bot commented Nov 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
nitro-docs ⬜️ Skipped (Inspect) Nov 5, 2024 10:08am

@mrousavy mrousavy merged commit 7dabb67 into main Nov 5, 2024
13 of 15 checks passed
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.

Run Build failed on Android: error: no matching constructor for initialization of <<Object>>
1 participant