3
3
//
4
4
// SPDX-License-Identifier: MIT OR Apache-2.0
5
5
6
+ use crate :: parser:: cxxqtdata:: ParsedCxxQtData ;
6
7
use crate :: {
7
8
parser:: {
8
9
externqobject:: ParsedExternQObject , require_attributes, signals:: ParsedSignal ,
9
10
CaseConversion ,
10
11
} ,
11
12
syntax:: { attribute:: attribute_get_path, expr:: expr_to_string} ,
12
13
} ;
14
+ use quote:: format_ident;
13
15
use syn:: { spanned:: Spanned , Error , ForeignItem , Ident , ItemForeignMod , Result , Token } ;
14
16
15
17
/// Representation of an extern "C++Qt" block
@@ -54,6 +56,9 @@ impl ParsedExternCxxQt {
54
56
..Default :: default ( )
55
57
} ;
56
58
59
+ let mut qobjects = vec ! [ ] ;
60
+ let mut signals = vec ! [ ] ;
61
+
57
62
// Parse any signals, other items are passed through
58
63
for item in foreign_mod. items . drain ( ..) {
59
64
match item {
@@ -74,7 +79,7 @@ impl ParsedExternCxxQt {
74
79
// extern "C++Qt" signals are always inherit = true
75
80
// as they always exist on an existing QObject
76
81
signal. inherit = true ;
77
- extern_cxx_block . signals . push ( signal) ;
82
+ signals. push ( signal) ;
78
83
} else {
79
84
extern_cxx_block
80
85
. passthrough_items
@@ -89,7 +94,7 @@ impl ParsedExternCxxQt {
89
94
let extern_ty =
90
95
ParsedExternQObject :: parse ( foreign_ty, module_ident, parent_namespace) ?;
91
96
// Pass through types separately for generation
92
- extern_cxx_block . qobjects . push ( extern_ty) ;
97
+ qobjects. push ( extern_ty) ;
93
98
} else {
94
99
return Err ( Error :: new (
95
100
foreign_ty. span ( ) ,
@@ -103,6 +108,16 @@ impl ParsedExternCxxQt {
103
108
}
104
109
}
105
110
111
+ let inline_self = qobjects. len ( ) == 1 ;
112
+ let inline_ident = qobjects
113
+ . last ( )
114
+ . map ( |obj| format_ident ! ( "{}" , obj. name. cxx_unqualified( ) ) ) ;
115
+
116
+ ParsedCxxQtData :: try_inline_self_types ( inline_self, & inline_ident, & mut signals) ?;
117
+
118
+ extern_cxx_block. qobjects . extend ( qobjects) ;
119
+ extern_cxx_block. signals . extend ( signals) ;
120
+
106
121
Ok ( extern_cxx_block)
107
122
}
108
123
}
0 commit comments