forked from KDAB/cxx-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpassthrough_and_naming.rs
380 lines (380 loc) · 13 KB
/
passthrough_and_naming.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
#[cxx::bridge(namespace = "cxx_qt::multi_object")]
#[attrA]
#[attrB]
pub mod ffi {
const MAX: u16 = 65535;
enum Event {
MyEvent,
}
extern crate serde;
fn do_something() {
println!("I am a free function");
}
extern "C" {}
#[namespace = "namespace"]
extern "C" {}
#[namespace = "namespace"]
#[custom_attr = "test"]
extern "C" {}
unsafe extern "C++" {}
#[namespace = "namespace"]
unsafe extern "C++" {}
#[namespace = "namespace"]
#[custom_attr = "test"]
unsafe extern "C++" {}
macro_rules! macro1 {
() => {
0
};
}
macro macro2() {
0
}
mod m {}
static BIKE: Event = Event::MyEvent;
pub trait CustomTrait {
fn method();
}
pub trait SharableIterator = CustomTrait + Sync;
type Result<T> = std::result::Result<T, Event>;
union Foo<A, B> {
x: A,
y: B,
}
unsafe extern "C++" {
include ! (< QtCore / QStringListModel >);
}
unsafe extern "C++" {
include ! (< QtCore / QObject >);
include!("cxx-qt-lib/qt.h");
#[doc(hidden)]
#[namespace = "Qt"]
#[rust_name = "CxxQtConnectionType"]
type ConnectionType = cxx_qt_lib::ConnectionType;
include!("cxx-qt-lib/qmetaobjectconnection.h");
#[doc(hidden)]
#[namespace = "rust::cxxqtlib1"]
#[rust_name = "CxxQtQMetaObjectConnection"]
type QMetaObjectConnection = cxx_qt_lib::QMetaObjectConnection;
}
unsafe extern "C++" {
include!("cxx-qt-gen/multi_object.cxxqt.h");
}
unsafe extern "C++" {
#[doc = "The C++ type for the QObject "]
#[doc = "MyObjectRust"]
#[doc = "\n"]
#[doc = "Use this type when referring to the QObject as a pointer"]
#[doc = "\n"]
#[doc = "See the book for more information: <https://kdab.github.io/cxx-qt/book/qobject/generated-qobject.html>"]
type MyObject;
}
extern "Rust" {
type MyObjectRust;
}
extern "Rust" {
#[cxx_name = "getPropertyName"]
unsafe fn property_name<'a>(self: &'a MyObjectRust, cpp: &'a MyObject) -> &'a i32;
}
extern "Rust" {
#[cxx_name = "setPropertyName"]
fn set_property_name(self: &mut MyObjectRust, cpp: Pin<&mut MyObject>, value: i32);
}
unsafe extern "C++" {
#[doc = "Notify for the Q_PROPERTY"]
#[rust_name = "property_name_changed"]
fn propertyNameChanged(self: Pin<&mut MyObject>);
}
unsafe extern "C++" {
#[doc = "Connect the given function pointer to the signal "]
#[doc = "propertyNameChanged"]
#[doc = ", so that when the signal is emitted the function pointer is executed."]
#[must_use]
#[rust_name = "connect_property_name_changed"]
fn propertyNameChangedConnect(
self: Pin<&mut MyObject>,
func: fn(Pin<&mut MyObject>),
conn_type: CxxQtConnectionType,
) -> CxxQtQMetaObjectConnection;
}
extern "Rust" {
#[cxx_name = "invokableNameWrapper"]
fn invokable_name_wrapper(self: &mut MyObjectRust, cpp: Pin<&mut MyObject>);
}
unsafe extern "C++" {
#[rust_name = "ready"]
fn ready(self: Pin<&mut MyObject>);
}
unsafe extern "C++" {
#[doc = "Connect the given function pointer to the signal "]
#[doc = "ready"]
#[doc = ", so that when the signal is emitted the function pointer is executed."]
#[must_use]
#[rust_name = "connect_ready"]
fn readyConnect(
self: Pin<&mut MyObject>,
func: fn(Pin<&mut MyObject>),
conn_type: CxxQtConnectionType,
) -> CxxQtQMetaObjectConnection;
}
extern "Rust" {
#[cxx_name = "createRs"]
#[namespace = "cxx_qt::multi_object::cxx_qt_my_object"]
fn create_rs_my_object_rust() -> Box<MyObjectRust>;
}
unsafe extern "C++" {
#[cxx_name = "unsafeRust"]
#[doc(hidden)]
fn cxx_qt_ffi_rust(self: &MyObject) -> &MyObjectRust;
}
unsafe extern "C++" {
#[cxx_name = "unsafeRustMut"]
#[doc(hidden)]
fn cxx_qt_ffi_rust_mut(self: Pin<&mut MyObject>) -> Pin<&mut MyObjectRust>;
}
unsafe extern "C++" {
#[doc = "The C++ type for the QObject "]
#[doc = "SecondObjectRust"]
#[doc = "\n"]
#[doc = "Use this type when referring to the QObject as a pointer"]
#[doc = "\n"]
#[doc = "See the book for more information: <https://kdab.github.io/cxx-qt/book/qobject/generated-qobject.html>"]
type SecondObject;
}
extern "Rust" {
type SecondObjectRust;
}
extern "Rust" {
#[cxx_name = "getPropertyName"]
unsafe fn property_name<'a>(self: &'a SecondObjectRust, cpp: &'a SecondObject) -> &'a i32;
}
extern "Rust" {
#[cxx_name = "setPropertyName"]
fn set_property_name(self: &mut SecondObjectRust, cpp: Pin<&mut SecondObject>, value: i32);
}
unsafe extern "C++" {
#[doc = "Notify for the Q_PROPERTY"]
#[rust_name = "property_name_changed"]
fn propertyNameChanged(self: Pin<&mut SecondObject>);
}
unsafe extern "C++" {
#[doc = "Connect the given function pointer to the signal "]
#[doc = "propertyNameChanged"]
#[doc = ", so that when the signal is emitted the function pointer is executed."]
#[must_use]
#[rust_name = "connect_property_name_changed"]
fn propertyNameChangedConnect(
self: Pin<&mut SecondObject>,
func: fn(Pin<&mut SecondObject>),
conn_type: CxxQtConnectionType,
) -> CxxQtQMetaObjectConnection;
}
extern "Rust" {
#[cxx_name = "invokableNameWrapper"]
fn invokable_name_wrapper(self: &mut SecondObjectRust, cpp: Pin<&mut SecondObject>);
}
unsafe extern "C++" {
#[my_attribute]
#[rust_name = "ready"]
fn ready(self: Pin<&mut SecondObject>);
}
unsafe extern "C++" {
#[doc = "Connect the given function pointer to the signal "]
#[doc = "ready"]
#[doc = ", so that when the signal is emitted the function pointer is executed."]
#[must_use]
#[rust_name = "connect_ready"]
fn readyConnect(
self: Pin<&mut SecondObject>,
func: fn(Pin<&mut SecondObject>),
conn_type: CxxQtConnectionType,
) -> CxxQtQMetaObjectConnection;
}
extern "Rust" {
#[cxx_name = "createRs"]
#[namespace = "cxx_qt::multi_object::cxx_qt_second_object"]
fn create_rs_second_object_rust() -> Box<SecondObjectRust>;
}
unsafe extern "C++" {
#[cxx_name = "unsafeRust"]
#[doc(hidden)]
fn cxx_qt_ffi_rust(self: &SecondObject) -> &SecondObjectRust;
}
unsafe extern "C++" {
#[cxx_name = "unsafeRustMut"]
#[doc(hidden)]
fn cxx_qt_ffi_rust_mut(self: Pin<&mut SecondObject>) -> Pin<&mut SecondObjectRust>;
}
}
pub use self::cxx_qt_ffi::*;
#[doc = r" Internal CXX-Qt module, made public temporarily between API changes"]
pub mod cxx_qt_ffi {
use super::ffi::*;
use cxx_qt::CxxQtType;
use std::pin::Pin;
#[doc(hidden)]
type UniquePtr<T> = cxx::UniquePtr<T>;
use super::MyTrait;
impl MyTrait for MyObject {
fn my_func() -> String {
"Hello".to_owned()
}
}
type MyObjectRust = super::MyObjectRust;
impl MyObjectRust {
#[doc(hidden)]
pub fn property_name<'a>(&'a self, cpp: &'a MyObject) -> &'a i32 {
cpp.property_name()
}
}
impl MyObject {
#[doc = "Getter for the Q_PROPERTY "]
#[doc = "property_name"]
pub fn property_name(&self) -> &i32 {
&self.rust().property_name
}
}
impl MyObjectRust {
#[doc(hidden)]
pub fn set_property_name(&mut self, cpp: Pin<&mut MyObject>, value: i32) {
cpp.set_property_name(value);
}
}
impl MyObject {
#[doc = "Setter for the Q_PROPERTY "]
#[doc = "property_name"]
pub fn set_property_name(mut self: Pin<&mut Self>, value: i32) {
if self.rust().property_name == value {
return;
}
self.as_mut().rust_mut().property_name = value;
self.as_mut().property_name_changed();
}
}
impl MyObject {
#[doc = "Connect the given function pointer to the signal "]
#[doc = "propertyNameChanged"]
#[doc = ", so that when the signal is emitted the function pointer is executed."]
#[doc = "\n"]
#[doc = "Note that this method uses a AutoConnection connection type."]
#[must_use]
pub fn on_property_name_changed(
self: Pin<&mut MyObject>,
func: fn(Pin<&mut MyObject>),
) -> CxxQtQMetaObjectConnection {
self.connect_property_name_changed(func, CxxQtConnectionType::AutoConnection)
}
}
impl MyObjectRust {
#[doc(hidden)]
pub fn invokable_name_wrapper(self: &mut MyObjectRust, cpp: Pin<&mut MyObject>) {
cpp.invokable_name();
}
}
impl MyObject {
#[doc = "Connect the given function pointer to the signal "]
#[doc = "ready"]
#[doc = ", so that when the signal is emitted the function pointer is executed."]
#[doc = "\n"]
#[doc = "Note that this method uses a AutoConnection connection type."]
#[must_use]
pub fn on_ready(
self: Pin<&mut MyObject>,
func: fn(Pin<&mut MyObject>),
) -> CxxQtQMetaObjectConnection {
self.connect_ready(func, CxxQtConnectionType::AutoConnection)
}
}
impl cxx_qt::Locking for MyObject {}
#[doc = r" Generated CXX-Qt method which creates a boxed rust struct of a QObject"]
pub fn create_rs_my_object_rust() -> std::boxed::Box<MyObjectRust> {
core::default::Default::default()
}
impl cxx_qt::CxxQtType for MyObject {
type Rust = MyObjectRust;
fn rust(&self) -> &Self::Rust {
self.cxx_qt_ffi_rust()
}
fn rust_mut(self: core::pin::Pin<&mut Self>) -> Pin<&mut Self::Rust> {
self.cxx_qt_ffi_rust_mut()
}
}
type SecondObjectRust = super::SecondObjectRust;
impl SecondObjectRust {
#[doc(hidden)]
pub fn property_name<'a>(&'a self, cpp: &'a SecondObject) -> &'a i32 {
cpp.property_name()
}
}
impl SecondObject {
#[doc = "Getter for the Q_PROPERTY "]
#[doc = "property_name"]
pub fn property_name(&self) -> &i32 {
&self.rust().property_name
}
}
impl SecondObjectRust {
#[doc(hidden)]
pub fn set_property_name(&mut self, cpp: Pin<&mut SecondObject>, value: i32) {
cpp.set_property_name(value);
}
}
impl SecondObject {
#[doc = "Setter for the Q_PROPERTY "]
#[doc = "property_name"]
pub fn set_property_name(mut self: Pin<&mut Self>, value: i32) {
if self.rust().property_name == value {
return;
}
self.as_mut().rust_mut().property_name = value;
self.as_mut().property_name_changed();
}
}
impl SecondObject {
#[doc = "Connect the given function pointer to the signal "]
#[doc = "propertyNameChanged"]
#[doc = ", so that when the signal is emitted the function pointer is executed."]
#[doc = "\n"]
#[doc = "Note that this method uses a AutoConnection connection type."]
#[must_use]
pub fn on_property_name_changed(
self: Pin<&mut SecondObject>,
func: fn(Pin<&mut SecondObject>),
) -> CxxQtQMetaObjectConnection {
self.connect_property_name_changed(func, CxxQtConnectionType::AutoConnection)
}
}
impl SecondObjectRust {
#[doc(hidden)]
pub fn invokable_name_wrapper(self: &mut SecondObjectRust, cpp: Pin<&mut SecondObject>) {
cpp.invokable_name();
}
}
impl SecondObject {
#[doc = "Connect the given function pointer to the signal "]
#[doc = "ready"]
#[doc = ", so that when the signal is emitted the function pointer is executed."]
#[doc = "\n"]
#[doc = "Note that this method uses a AutoConnection connection type."]
#[must_use]
pub fn on_ready(
self: Pin<&mut SecondObject>,
func: fn(Pin<&mut SecondObject>),
) -> CxxQtQMetaObjectConnection {
self.connect_ready(func, CxxQtConnectionType::AutoConnection)
}
}
#[doc = r" Generated CXX-Qt method which creates a boxed rust struct of a QObject"]
pub fn create_rs_second_object_rust() -> std::boxed::Box<SecondObjectRust> {
core::default::Default::default()
}
impl cxx_qt::CxxQtType for SecondObject {
type Rust = SecondObjectRust;
fn rust(&self) -> &Self::Rust {
self.cxx_qt_ffi_rust()
}
fn rust_mut(self: core::pin::Pin<&mut Self>) -> Pin<&mut Self::Rust> {
self.cxx_qt_ffi_rust_mut()
}
}
}