generate jni-wrapping code from Rust#473
Draft
milyin wants to merge 26 commits into
Draft
Conversation
BFS from each required-but-unresolved type through struct fields, enum variants, generic args, and impl Fn args, surfacing transitively unresolved entries that propagate_required cannot reach (because subs edges don't exist past an unresolved parent). Without this, a missing declaration in build.rs for a type only referenced as a field of another unresolved struct went unreported. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
.method() is a namespace declaration — every #[prebindgen] fn must be assigned to a typed handle, data class, enum, or kotlin_package. There is no third "orphan" bucket, so JNIOrphaned was always emitted empty and the duplicate declared_function_names helper just repeated the PrebindgenExt::declared_functions trait method. - delete write_jni_orphaned, jni_orphaned_class_name, the stale generated JNIOrphaned.kt file - rename render_jni_orphaned_source -> render_jni_package_source, drop the now-redundant include_only_promoted / wrap_in_object / declared / class_name params - drop declared_function_names; render_jni_native_source now takes &HashSet<syn::Ident> from declared_functions() directly Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Replace the five scattered self.qualify_emitted_type() calls (build_input_fn, build_output_fn, opaque_handle_input, build_handle_destructor_items, option_input) with a single AST visitor pass applied once at write time. The previous design qualified only at specific emit sites — each new emit site had to remember the call. emit_into_dispatcher missed it, so the impl-Into dispatcher body emitted bare KeyExpr/ZKeyExpr references that failed to resolve in the binding crate's scope. Architecture: - New PrebindgenExt::post_process_item(item: &mut syn::Item) trait hook (default no-op), invoked by write_rust on every emitted item. - JniExt implements it via qualify_item, which runs QualifyEmittedTypes — a syn::visit_mut::VisitMut that walks the full AST (signatures, generic args, type ascriptions in let bindings, *mut/*const in cast expressions) and prefixes every bare single-segment Type::Path matching a registered source-module name with source_module. - option_input no longer takes &JniExt; the body uses the bare t1 token and the post-emit visitor qualifies it later. Also fixes the pre-existing TypeEntry field-name drift in final_invariant_reports_unresolved_field_of_unresolved_struct. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Use https://github.com/milyin/prebindgen utility to make JNI code from simple flat rust zenoh wrapping library