@@ -10,7 +10,8 @@ use wit_bindgen_core::{
1010 wit_parser:: {
1111 abi:: { AbiVariant , Bindgen , Bitcast , Instruction , LiftLower , WasmType } ,
1212 Case , Docs , Enum , Flags , FlagsRepr , Function , FunctionKind , Int , InterfaceId , Record ,
13- Resolve , Result_ , SizeAlign , Tuple , Type , TypeDefKind , TypeId , Union , Variant , WorldId ,
13+ Resolve , Result_ , SizeAlign , Tuple , Type , TypeDef , TypeDefKind , TypeId , TypeOwner , Union ,
14+ Variant , WorldId ,
1415 } ,
1516 Files , InterfaceGenerator as _, Ns , WorldGenerator ,
1617} ;
@@ -53,6 +54,7 @@ pub struct TeaVmJava {
5354 needs_result : bool ,
5455 classes : HashMap < String , String > ,
5556 sizes : SizeAlign ,
57+ interface_names : HashMap < InterfaceId , String > ,
5658}
5759
5860impl TeaVmJava {
@@ -85,6 +87,7 @@ impl WorldGenerator for TeaVmJava {
8587 id : InterfaceId ,
8688 _files : & mut Files ,
8789 ) {
90+ self . interface_names . insert ( id, name. to_owned ( ) ) ;
8891 let mut gen = self . interface ( resolve, name) ;
8992 gen. types ( id) ;
9093
@@ -119,6 +122,7 @@ impl WorldGenerator for TeaVmJava {
119122 id : InterfaceId ,
120123 _files : & mut Files ,
121124 ) {
125+ self . interface_names . insert ( id, name. to_owned ( ) ) ;
122126 let mut gen = self . interface ( resolve, name) ;
123127 gen. types ( id) ;
124128
@@ -318,10 +322,18 @@ struct InterfaceGenerator<'a> {
318322}
319323
320324impl InterfaceGenerator < ' _ > {
321- fn qualifier ( & self , when : bool ) -> String {
325+ fn qualifier ( & self , when : bool , ty : & TypeDef ) -> String {
326+ if let TypeOwner :: Interface ( id) = & ty. owner {
327+ if let Some ( name) = self . gen . interface_names . get ( id) {
328+ if name != self . name {
329+ return format ! ( "{}." , name. to_upper_camel_case( ) ) ;
330+ }
331+ }
332+ }
333+
322334 if when {
323- let iface = self . name . to_upper_camel_case ( ) ;
324- format ! ( "{iface }." )
335+ let name = self . name . to_upper_camel_case ( ) ;
336+ format ! ( "{name }." )
325337 } else {
326338 String :: new ( )
327339 }
@@ -596,7 +608,7 @@ impl InterfaceGenerator<'_> {
596608 if let Some ( name) = & ty. name {
597609 format ! (
598610 "{}{}" ,
599- self . qualifier( qualifier) ,
611+ self . qualifier( qualifier, ty ) ,
600612 name. to_upper_camel_case( )
601613 )
602614 } else {
0 commit comments