Skip to content

[jni] Add deep conversion utils#3161

Open
imshubham22apr-gif wants to merge 1 commit intodart-lang:mainfrom
imshubham22apr-gif:jni-deep-conversion-utils
Open

[jni] Add deep conversion utils#3161
imshubham22apr-gif wants to merge 1 commit intodart-lang:mainfrom
imshubham22apr-gif:jni-deep-conversion-utils

Conversation

@imshubham22apr-gif
Copy link

Summary

This PR adds deep conversion utilities for package:jni, following the established pattern in package:objective_c. These utilities simplify the process of converting between Dart collections/primitive types and their JNI counterparts.

Changes

  • Recursive Converters: Added toJObject and toDartObject which handle nested List, Set, and Map structures.
  • Array Extensions: New extension methods on Dart List for direct conversion to JNI primitive arrays (e.g., toJIntArray, toJDoubleArray).
  • Object Array Support: Added toJObjectArray for converting typed lists of JObject.
  • Unit Tests: Comprehensive tests added in test/converter_test.dart to verify deep conversion of basic types, nested collections, and arrays.

Related Issues

Fixes #3143

PR Checklist

  • Reviewed the contributor guide.
  • Added new tests to check the changes.
  • PR solves the mentioned issue.

@liamappelbe
Copy link
Contributor

@imshubham22apr-gif Thanks for the contribution. Just FYI #3143 is a follow up TODO for #3093, which hasn't landed yet. So I won't be able to review this PR until that one lands. Hopefully that will be sometime next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[jni] Add deep conversion utils

2 participants