File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11//! Core: language-agnostic primitives for the Registry-based pipeline.
22//!
3- //! Public entry point: [`registry::Registry::from_source`] scans a
4- //! `prebindgen::Source` into a flat type table; [`registry::Registry::write_rust`]
3+ //! Public entry point: [`registry::Registry::from_items`] scans a stream
4+ //! of `(syn::Item, SourceLocation)` into a flat type table;
5+ //! [`registry::Registry::write_rust`]
56//! resolves every required type using the configured
67//! [`prebindgen_ext::PrebindgenExt`] and emits the bindings file. Kotlin
78//! emission for the JNI back-end lives in `crate::jni::JniExt::write_kotlin`.
Original file line number Diff line number Diff line change 1616use std:: collections:: { HashMap , HashSet } ;
1717use std:: fmt;
1818
19- use prebindgen:: { Source , SourceLocation } ;
19+ use prebindgen:: SourceLocation ;
2020use quote:: ToTokens ;
2121
2222use crate :: core:: niches:: Niches ;
@@ -233,12 +233,20 @@ impl From<crate::core::write::WriteError> for WriteRustError {
233233}
234234
235235impl Registry {
236- /// Construct a `Registry` by scanning a `prebindgen::Source`.
237- pub fn from_source ( source : & Source ) -> Result < Self , ScanError > {
236+ /// Construct a `Registry` by scanning a stream of source items.
237+ ///
238+ /// Callers feed any `(syn::Item, SourceLocation)` iterator — typically
239+ /// `source.items_all()`, `source.items_except_groups(...)`, or a
240+ /// hand-rolled filter chain — so item-level selection happens upstream
241+ /// of the registry rather than inside it.
242+ pub fn from_items < I > ( items : I ) -> Result < Self , ScanError >
243+ where
244+ I : IntoIterator < Item = ( syn:: Item , SourceLocation ) > ,
245+ {
238246 let mut registry = Registry :: default ( ) ;
239247
240248 // Phase 1 — index all items.
241- for ( item, loc) in source . items_all ( ) {
249+ for ( item, loc) in items {
242250 registry. index_item ( item, loc) ?;
243251 }
244252
Original file line number Diff line number Diff line change 11//! Registry-based universal converter pipeline for `#[prebindgen]` items.
22//!
33//! Pipeline:
4- //! 1. [`core::Registry::from_source`] scans a `prebindgen::Source`.
4+ //! 1. [`core::Registry::from_items`] scans a stream of
5+ //! `(syn::Item, SourceLocation)` (typically `source.items_all()`,
6+ //! with optional upstream filtering).
57//! 2. [`core::Registry::write_rust`] resolves every required type via
68//! a configured [`core::prebindgen_ext::PrebindgenExt`] and writes
79//! the generated Rust bindings file. Language-agnostic — any
Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ fn main() {
161161
162162 // ── Write Rust bindings ───────────────────────────────────────────
163163 let source = prebindgen:: Source :: new ( zenoh_flat:: PREBINDGEN_OUT_DIR ) ;
164- let mut registry = Registry :: from_source ( & source) . expect ( "scan failed" ) ;
164+ let mut registry = Registry :: from_items ( source. items_all ( ) ) . expect ( "scan failed" ) ;
165165 let rust_path = registry
166166 . write_rust ( & jni, "zenoh_flat_jni.rs" )
167167 . expect ( "write rust failed" ) ;
You can’t perform that action at this time.
0 commit comments