@@ -15,6 +15,13 @@ pub struct Manifest {
1515 pub dependencies : BTreeMap < String , Vec < String > > ,
1616 #[ serde( skip) ]
1717 pub ext_wrappers : BTreeMap < String , Vec < String > > ,
18+ /// Short re-export path -> canonical path. Types live at
19+ /// `engage_il2cpp::<ns>::<module>::<Type>` but the generated `<ns>` module
20+ /// re-exports them one level up (the `pub use <module>::{Type}` lines in
21+ /// app.rs etc), so code usually imports the short `engage_il2cpp::<ns>::<Type>`.
22+ /// This maps that short form back so the scanner recognizes it.
23+ #[ serde( skip) ]
24+ pub reexports : BTreeMap < String , String > ,
1825}
1926
2027const SCHEMA_VERSION : u32 = 1 ;
@@ -37,6 +44,8 @@ impl Manifest {
3744 m. ext_wrappers = load_ext_wrappers ( bindings_root) . unwrap_or_default ( ) ;
3845 }
3946
47+ m. reexports = build_reexports ( & m. paths ) ;
48+
4049 Ok ( m)
4150 }
4251
@@ -70,6 +79,41 @@ impl Manifest {
7079 }
7180}
7281
82+ /// Invert the namespace-root re-exports: for each canonical
83+ /// `engage_il2cpp::<ns>::<module>::<Type>`, the `<ns>` module re-exports it as
84+ /// `engage_il2cpp::<ns>::<Type>`, so drop the module segment (second to last) to
85+ /// get the short form code actually imports. A real `pub use` at one level can't
86+ /// name two types the same way, so if two canonicals ever collapse to the same
87+ /// short form we drop it rather than guess.
88+ fn build_reexports ( paths : & BTreeMap < String , String > ) -> BTreeMap < String , String > {
89+ let mut grouped: BTreeMap < String , Vec < & String > > = BTreeMap :: new ( ) ;
90+
91+ for canonical in paths. keys ( ) {
92+ let segs: Vec < & str > = canonical. split ( "::" ) . collect ( ) ;
93+
94+ // Need at least crate::ns::module::Type for there to be a module to drop.
95+ if segs. len ( ) < 4 {
96+ continue ;
97+ }
98+
99+ let mut short_segs = segs. clone ( ) ;
100+ short_segs. remove ( segs. len ( ) - 2 ) ;
101+ let short = short_segs. join ( "::" ) ;
102+
103+ if short != * canonical {
104+ grouped. entry ( short) . or_default ( ) . push ( canonical) ;
105+ }
106+ }
107+
108+ grouped
109+ . into_iter ( )
110+ . filter_map ( |( short, canonicals) | match canonicals. as_slice ( ) {
111+ [ only] => Some ( ( short, ( * only) . clone ( ) ) ) ,
112+ _ => None ,
113+ } )
114+ . collect ( )
115+ }
116+
73117fn load_ext_wrappers ( bindings_root : & Path ) -> Option < BTreeMap < String , Vec < String > > > {
74118 let ext_path = bindings_root. join ( "src" ) . join ( "ext.rs" ) ;
75119 let text = std:: fs:: read_to_string ( & ext_path) . ok ( ) ?;
0 commit comments