@@ -10,13 +10,15 @@ pub struct Gen<'a> {
1010 pub min_enum : bool ,
1111 pub min_inherit : bool ,
1212 pub min_xaml : bool ,
13+ pub windows_extern : bool ,
1314}
1415
1516impl Gen < ' _ > {
1617 pub ( crate ) fn namespace ( & self , namespace : & str ) -> TokenStream {
1718 if self . flatten || namespace == self . namespace {
1819 quote ! { }
1920 } else {
21+ let is_external = namespace. starts_with ( "Windows." ) && !self . namespace . starts_with ( "Windows" ) ;
2022 let mut relative = self . namespace . split ( '.' ) . peekable ( ) ;
2123 let mut namespace = namespace. split ( '.' ) . peekable ( ) ;
2224
@@ -30,8 +32,13 @@ impl Gen<'_> {
3032
3133 let mut tokens = TokenStream :: new ( ) ;
3234
33- for _ in 0 ..relative. count ( ) {
34- tokens. push_str ( "super::" ) ;
35+ if is_external {
36+ tokens. push_str ( "::windows::" ) ;
37+ namespace. next ( ) ;
38+ } else {
39+ for _ in 0 ..relative. count ( ) {
40+ tokens. push_str ( "super::" ) ;
41+ }
3542 }
3643
3744 for namespace in namespace {
@@ -49,7 +56,11 @@ impl Gen<'_> {
4956 } else {
5057 let mut tokens = format ! ( "'{}'" , to_feature( self . namespace) ) ;
5158
52- for features in & cfg. features ( self . namespace ) {
59+ let mut features = cfg. features ( self . namespace ) ;
60+ if self . windows_extern {
61+ features = features. into_iter ( ) . filter ( |f| !f. starts_with ( "Windows." ) ) . collect ( ) ;
62+ }
63+ for features in features {
5364 tokens. push_str ( & format ! ( ", '{}'" , to_feature( features) ) ) ;
5465 }
5566
@@ -72,7 +83,11 @@ impl Gen<'_> {
7283 }
7384 } ;
7485
75- let features = & cfg. features ( self . namespace ) ;
86+ let mut features = cfg. features ( self . namespace ) ;
87+ if self . windows_extern {
88+ features = features. into_iter ( ) . filter ( |f| !f. starts_with ( "Windows." ) ) . collect ( ) ;
89+ }
90+
7691 let features = match features. len ( ) {
7792 0 => quote ! { } ,
7893 1 => {
@@ -90,10 +105,13 @@ impl Gen<'_> {
90105 }
91106
92107 pub ( crate ) fn not_cfg ( & self , cfg : & Cfg ) -> TokenStream {
93- let features = & cfg. features ( self . namespace ) ;
108+ let mut features = cfg. features ( self . namespace ) ;
94109 if !self . cfg || features. is_empty ( ) {
95110 quote ! { }
96111 } else {
112+ if self . windows_extern {
113+ features = features. into_iter ( ) . filter ( |f| !f. starts_with ( "Windows." ) ) . collect ( ) ;
114+ }
97115 match features. len ( ) {
98116 0 => quote ! { } ,
99117 1 => {
0 commit comments