Skip to content

Commit 691c7a0

Browse files
Add casting for QQmlEngine and reexport qobject
1 parent 5978a23 commit 691c7a0

File tree

15 files changed

+69
-62
lines changed

15 files changed

+69
-62
lines changed

crates/cxx-qt-gen/src/generator/rust/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ fn add_qobject_import(qobjects: &[ParsedQObject]) -> GeneratedRustFragment {
107107
extern "C++" {
108108
#[doc(hidden)]
109109
#[namespace=""]
110-
type QObject = cxx_qt::qobject::QObject;
110+
type QObject = cxx_qt::QObject;
111111
}
112112
}],
113113
cxx_qt_mod_contents: vec![],

crates/cxx-qt-gen/src/generator/rust/qobject.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ impl GeneratedRustFragment {
7171
.map(|name| type_names.lookup(name))
7272
.transpose()?
7373
.cloned()
74-
.unwrap_or(
75-
Name::new(format_ident!("QObject")).with_module(parse_quote! {::cxx_qt::qobject}),
76-
);
74+
.unwrap_or(Name::new(format_ident!("QObject")).with_module(parse_quote! {::cxx_qt}));
7775

7876
let base_unqualified = base.rust_unqualified();
7977
let base_qualified = base.rust_qualified();

crates/cxx-qt-gen/test_outputs/cfgs.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ mod ffi {
481481
extern "C++" {
482482
#[doc(hidden)]
483483
#[namespace = ""]
484-
type QObject = cxx_qt::qobject::QObject;
484+
type QObject = cxx_qt::QObject;
485485
}
486486
}
487487
#[cfg(not(enabled))]
@@ -632,11 +632,11 @@ cxx_qt::static_assertions::assert_eq_size!(
632632
cxx_qt::signalhandler::CxxQtSignalHandler<QObjectEnabledCxxQtSignalClosuresignal_enabled>,
633633
[usize; 2]
634634
);
635-
impl ::cxx_qt::Upcast<::cxx_qt::qobject::QObject> for ffi::QObjectEnabled {
636-
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::qobject::QObject {
635+
impl ::cxx_qt::Upcast<::cxx_qt::QObject> for ffi::QObjectEnabled {
636+
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::QObject {
637637
ffi::cxx_qt_ffi_QObjectEnabled_upcastPtr(this)
638638
}
639-
unsafe fn from_base_ptr(base: *const ::cxx_qt::qobject::QObject) -> *const Self {
639+
unsafe fn from_base_ptr(base: *const ::cxx_qt::QObject) -> *const Self {
640640
ffi::cxx_qt_ffi_QObjectEnabled_downcastPtr(base)
641641
}
642642
}
@@ -811,11 +811,11 @@ cxx_qt::static_assertions::assert_eq_size!(
811811
cxx_qt::signalhandler::CxxQtSignalHandler<QObjectDisabledCxxQtSignalClosuresignal_enabled>,
812812
[usize; 2]
813813
);
814-
impl ::cxx_qt::Upcast<::cxx_qt::qobject::QObject> for ffi::QObjectDisabled {
815-
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::qobject::QObject {
814+
impl ::cxx_qt::Upcast<::cxx_qt::QObject> for ffi::QObjectDisabled {
815+
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::QObject {
816816
ffi::cxx_qt_ffi_QObjectDisabled_upcastPtr(this)
817817
}
818-
unsafe fn from_base_ptr(base: *const ::cxx_qt::qobject::QObject) -> *const Self {
818+
unsafe fn from_base_ptr(base: *const ::cxx_qt::QObject) -> *const Self {
819819
ffi::cxx_qt_ffi_QObjectDisabled_downcastPtr(base)
820820
}
821821
}

crates/cxx-qt-gen/test_outputs/invokables.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ mod ffi {
266266
extern "C++" {
267267
#[doc(hidden)]
268268
#[namespace = ""]
269-
type QObject = cxx_qt::qobject::QObject;
269+
type QObject = cxx_qt::QObject;
270270
}
271271
}
272272
impl cxx_qt::Threading for ffi::MyObject {
@@ -321,11 +321,11 @@ impl cxx_qt::Threading for ffi::MyObject {
321321
pub struct MyObjectCxxQtThreadQueuedFn {
322322
inner: std::boxed::Box<dyn FnOnce(core::pin::Pin<&mut ffi::MyObject>) + Send>,
323323
}
324-
impl ::cxx_qt::Upcast<::cxx_qt::qobject::QObject> for ffi::MyObject {
325-
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::qobject::QObject {
324+
impl ::cxx_qt::Upcast<::cxx_qt::QObject> for ffi::MyObject {
325+
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::QObject {
326326
ffi::cxx_qt_ffi_MyObject_upcastPtr(this)
327327
}
328-
unsafe fn from_base_ptr(base: *const ::cxx_qt::qobject::QObject) -> *const Self {
328+
unsafe fn from_base_ptr(base: *const ::cxx_qt::QObject) -> *const Self {
329329
ffi::cxx_qt_ffi_MyObject_downcastPtr(base)
330330
}
331331
}

crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ pub mod ffi {
473473
extern "C++" {
474474
#[doc(hidden)]
475475
#[namespace = ""]
476-
type QObject = cxx_qt::qobject::QObject;
476+
type QObject = cxx_qt::QObject;
477477
}
478478
}
479479
impl ffi::MyObject {
@@ -796,11 +796,11 @@ cxx_qt::static_assertions::assert_eq_size!(
796796
cxx_qt::signalhandler::CxxQtSignalHandler<SecondObjectCxxQtSignalClosureready>,
797797
[usize; 2]
798798
);
799-
impl ::cxx_qt::Upcast<::cxx_qt::qobject::QObject> for ffi::SecondObject {
800-
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::qobject::QObject {
799+
impl ::cxx_qt::Upcast<::cxx_qt::QObject> for ffi::SecondObject {
800+
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::QObject {
801801
ffi::cxx_qt_ffi_SecondObject_upcastPtr(this)
802802
}
803-
unsafe fn from_base_ptr(base: *const ::cxx_qt::qobject::QObject) -> *const Self {
803+
unsafe fn from_base_ptr(base: *const ::cxx_qt::QObject) -> *const Self {
804804
ffi::cxx_qt_ffi_SecondObject_downcastPtr(base)
805805
}
806806
}
@@ -824,11 +824,11 @@ impl ::cxx_qt::CxxQtType for ffi::SecondObject {
824824
ffi::cxx_qt_ffi_SecondObject_unsafeRustMut(self)
825825
}
826826
}
827-
impl ::cxx_qt::Upcast<::cxx_qt::qobject::QObject> for ffi::MyRustName {
828-
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::qobject::QObject {
827+
impl ::cxx_qt::Upcast<::cxx_qt::QObject> for ffi::MyRustName {
828+
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::QObject {
829829
ffi::cxx_qt_ffi_MyCxxName_upcastPtr(this)
830830
}
831-
unsafe fn from_base_ptr(base: *const ::cxx_qt::qobject::QObject) -> *const Self {
831+
unsafe fn from_base_ptr(base: *const ::cxx_qt::QObject) -> *const Self {
832832
ffi::cxx_qt_ffi_MyCxxName_downcastPtr(base)
833833
}
834834
}

crates/cxx-qt-gen/test_outputs/properties.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ mod ffi {
419419
extern "C++" {
420420
#[doc(hidden)]
421421
#[namespace = ""]
422-
type QObject = cxx_qt::qobject::QObject;
422+
type QObject = cxx_qt::QObject;
423423
}
424424
}
425425
impl ffi::MyObject {
@@ -1052,11 +1052,11 @@ cxx_qt::static_assertions::assert_eq_size!(
10521052
cxx_qt::signalhandler::CxxQtSignalHandler<MyObjectCxxQtSignalClosuremy_on_changed>,
10531053
[usize; 2]
10541054
);
1055-
impl ::cxx_qt::Upcast<::cxx_qt::qobject::QObject> for ffi::MyObject {
1056-
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::qobject::QObject {
1055+
impl ::cxx_qt::Upcast<::cxx_qt::QObject> for ffi::MyObject {
1056+
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::QObject {
10571057
ffi::cxx_qt_ffi_MyObject_upcastPtr(this)
10581058
}
1059-
unsafe fn from_base_ptr(base: *const ::cxx_qt::qobject::QObject) -> *const Self {
1059+
unsafe fn from_base_ptr(base: *const ::cxx_qt::QObject) -> *const Self {
10601060
ffi::cxx_qt_ffi_MyObject_downcastPtr(base)
10611061
}
10621062
}

crates/cxx-qt-gen/test_outputs/qenum.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@ mod ffi {
166166
extern "C++" {
167167
#[doc(hidden)]
168168
#[namespace = ""]
169-
type QObject = cxx_qt::qobject::QObject;
169+
type QObject = cxx_qt::QObject;
170170
}
171171
}
172-
impl ::cxx_qt::Upcast<::cxx_qt::qobject::QObject> for ffi::MyObject {
173-
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::qobject::QObject {
172+
impl ::cxx_qt::Upcast<::cxx_qt::QObject> for ffi::MyObject {
173+
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::QObject {
174174
ffi::cxx_qt_ffi_MyObject_upcastPtr(this)
175175
}
176-
unsafe fn from_base_ptr(base: *const ::cxx_qt::qobject::QObject) -> *const Self {
176+
unsafe fn from_base_ptr(base: *const ::cxx_qt::QObject) -> *const Self {
177177
ffi::cxx_qt_ffi_MyObject_downcastPtr(base)
178178
}
179179
}
@@ -197,11 +197,11 @@ impl ::cxx_qt::CxxQtType for ffi::MyObject {
197197
ffi::cxx_qt_ffi_MyObject_unsafeRustMut(self)
198198
}
199199
}
200-
impl ::cxx_qt::Upcast<::cxx_qt::qobject::QObject> for ffi::MyRenamedObject {
201-
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::qobject::QObject {
200+
impl ::cxx_qt::Upcast<::cxx_qt::QObject> for ffi::MyRenamedObject {
201+
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::QObject {
202202
ffi::cxx_qt_ffi_CxxName_upcastPtr(this)
203203
}
204-
unsafe fn from_base_ptr(base: *const ::cxx_qt::qobject::QObject) -> *const Self {
204+
unsafe fn from_base_ptr(base: *const ::cxx_qt::QObject) -> *const Self {
205205
ffi::cxx_qt_ffi_CxxName_downcastPtr(base)
206206
}
207207
}

crates/cxx-qt-gen/test_outputs/signals.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ mod ffi {
214214
extern "C++" {
215215
#[doc(hidden)]
216216
#[namespace = ""]
217-
type QObject = cxx_qt::qobject::QObject;
217+
type QObject = cxx_qt::QObject;
218218
}
219219
}
220220
impl ffi::MyObject {
@@ -443,11 +443,11 @@ cxx_qt::static_assertions::assert_eq_size!(
443443
cxx_qt::signalhandler::CxxQtSignalHandler<MyObjectCxxQtSignalClosurenewData>,
444444
[usize; 2]
445445
);
446-
impl ::cxx_qt::Upcast<::cxx_qt::qobject::QObject> for ffi::MyObject {
447-
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::qobject::QObject {
446+
impl ::cxx_qt::Upcast<::cxx_qt::QObject> for ffi::MyObject {
447+
unsafe fn upcast_ptr(this: *const Self) -> *const ::cxx_qt::QObject {
448448
ffi::cxx_qt_ffi_MyObject_upcastPtr(this)
449449
}
450-
unsafe fn from_base_ptr(base: *const ::cxx_qt::qobject::QObject) -> *const Self {
450+
unsafe fn from_base_ptr(base: *const ::cxx_qt::QObject) -> *const Self {
451451
ffi::cxx_qt_ffi_MyObject_downcastPtr(base)
452452
}
453453
}

crates/cxx-qt-lib/include/qml/qqmlapplicationengine.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ namespace cxxqtlib1 {
2222
::std::unique_ptr<QQmlApplicationEngine>
2323
qqmlapplicationengineNew();
2424

25-
QQmlEngine&
26-
qqmlapplicationengineAsQQmlEngine(QQmlApplicationEngine&);
27-
2825
}
2926
}
3027

crates/cxx-qt-lib/src/qml/qqmlapplicationengine.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,5 @@ qqmlapplicationengineNew()
1616
return ::std::make_unique<QQmlApplicationEngine>();
1717
}
1818

19-
QQmlEngine&
20-
qqmlapplicationengineAsQQmlEngine(QQmlApplicationEngine& engine)
21-
{
22-
return static_cast<QQmlEngine&>(engine);
23-
}
24-
2519
}
2620
}

0 commit comments

Comments
 (0)