Skip to content

Commit 82299c6

Browse files
committed
cxx-qt-gen: remove generated qobject module and use bridge mod instead
Related to #559
1 parent 0414d25 commit 82299c6

File tree

28 files changed

+58
-205
lines changed

28 files changed

+58
-205
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
- `rust_mut` is now safe to call
3434
- `#[qproperty]` is now defined as an attribute on the qobject rather than the field
3535
- QObject struct is now split between the bridge and implementation outside via a type alias
36+
- `qobject` module is no longer generated
3637

3738
### Fixed
3839

book/src/concepts/nested_objects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Rust Qt objects can be nested as properties or parameters of each other.
1111

1212
A nested object is referred to by using a pointer to its QObject representation.
1313

14-
First define a type with an extern block for your bridge, this should point to the `qobject::T` of the QObject and the `cxx_name` should match the QObject name.
14+
First define a type within an extern block for your bridge as normal.
1515

1616
```rust,ignore,noplayground
1717
{{#include ../../../examples/qml_features/rust/src/nested_qobjects.rs:book_extern_block}}

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

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,6 @@ pub fn write_rust(generated: &GeneratedRustBlocks) -> TokenStream {
121121
})
122122
}
123123

124-
// Create the qobject block for the type alias
125-
cxx_qt_mod_contents.push(
126-
syn::parse2(quote! {
127-
/// Generated CXX-Qt module containing type alias to the C++ types of the QObjects
128-
pub mod qobject {
129-
#(#qobject_types)*
130-
}
131-
})
132-
.expect("Could not build qobject block"),
133-
);
134-
135124
// Inject the CXX blocks
136125
if let Some((_, items)) = &mut cxx_mod.content {
137126
items.extend(cxx_mod_contents.into_iter());
@@ -385,17 +374,6 @@ mod tests {
385374
self.cxx_qt_ffi_rust_mut()
386375
}
387376
}
388-
389-
/// Generated CXX-Qt module containing type alias to the C++ types of the QObjects
390-
pub mod qobject {
391-
#[doc = "The C++ type for the QObject "]
392-
#[doc = "MyObject"]
393-
#[doc = "\n"]
394-
#[doc = "Use this type when referring to the QObject as a pointer"]
395-
#[doc = "\n"]
396-
#[doc = "See the book for more information: <https://kdab.github.io/cxx-qt/book/qobject/generated-qobject.html>"]
397-
pub type MyObject = super::MyObject;
398-
}
399377
}
400378
}
401379
.into_token_stream()
@@ -516,24 +494,6 @@ mod tests {
516494
self.cxx_qt_ffi_rust_mut()
517495
}
518496
}
519-
520-
/// Generated CXX-Qt module containing type alias to the C++ types of the QObjects
521-
pub mod qobject {
522-
#[doc = "The C++ type for the QObject "]
523-
#[doc = "FirstObject"]
524-
#[doc = "\n"]
525-
#[doc = "Use this type when referring to the QObject as a pointer"]
526-
#[doc = "\n"]
527-
#[doc = "See the book for more information: <https://kdab.github.io/cxx-qt/book/qobject/generated-qobject.html>"]
528-
pub type FirstObject = super::FirstObject;
529-
#[doc = "The C++ type for the QObject "]
530-
#[doc = "SecondObject"]
531-
#[doc = "\n"]
532-
#[doc = "Use this type when referring to the QObject as a pointer"]
533-
#[doc = "\n"]
534-
#[doc = "See the book for more information: <https://kdab.github.io/cxx-qt/book/qobject/generated-qobject.html>"]
535-
pub type SecondObject = super::SecondObject;
536-
}
537497
}
538498
}
539499
.into_token_stream()

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,4 @@ pub mod cxx_qt_inheritance {
118118
self.cxx_qt_ffi_rust_mut()
119119
}
120120
}
121-
#[doc = r" Generated CXX-Qt module containing type alias to the C++ types of the QObjects"]
122-
pub mod qobject {
123-
#[doc = "The C++ type for the QObject "]
124-
#[doc = "MyObject"]
125-
#[doc = "\n"]
126-
#[doc = "Use this type when referring to the QObject as a pointer"]
127-
#[doc = "\n"]
128-
#[doc = "See the book for more information: <https://kdab.github.io/cxx-qt/book/qobject/generated-qobject.html>"]
129-
pub type MyObject = super::MyObject;
130-
}
131121
}

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,4 @@ pub mod cxx_qt_ffi {
328328
self.cxx_qt_ffi_rust_mut()
329329
}
330330
}
331-
#[doc = r" Generated CXX-Qt module containing type alias to the C++ types of the QObjects"]
332-
pub mod qobject {
333-
#[doc = "The C++ type for the QObject "]
334-
#[doc = "MyObject"]
335-
#[doc = "\n"]
336-
#[doc = "Use this type when referring to the QObject as a pointer"]
337-
#[doc = "\n"]
338-
#[doc = "See the book for more information: <https://kdab.github.io/cxx-qt/book/qobject/generated-qobject.html>"]
339-
pub type MyObject = super::MyObject;
340-
}
341331
}

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -377,21 +377,4 @@ pub mod cxx_qt_ffi {
377377
self.cxx_qt_ffi_rust_mut()
378378
}
379379
}
380-
#[doc = r" Generated CXX-Qt module containing type alias to the C++ types of the QObjects"]
381-
pub mod qobject {
382-
#[doc = "The C++ type for the QObject "]
383-
#[doc = "MyObject"]
384-
#[doc = "\n"]
385-
#[doc = "Use this type when referring to the QObject as a pointer"]
386-
#[doc = "\n"]
387-
#[doc = "See the book for more information: <https://kdab.github.io/cxx-qt/book/qobject/generated-qobject.html>"]
388-
pub type MyObject = super::MyObject;
389-
#[doc = "The C++ type for the QObject "]
390-
#[doc = "SecondObject"]
391-
#[doc = "\n"]
392-
#[doc = "Use this type when referring to the QObject as a pointer"]
393-
#[doc = "\n"]
394-
#[doc = "See the book for more information: <https://kdab.github.io/cxx-qt/book/qobject/generated-qobject.html>"]
395-
pub type SecondObject = super::SecondObject;
396-
}
397380
}

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,4 @@ pub mod cxx_qt_ffi {
210210
self.cxx_qt_ffi_rust_mut()
211211
}
212212
}
213-
#[doc = r" Generated CXX-Qt module containing type alias to the C++ types of the QObjects"]
214-
pub mod qobject {
215-
#[doc = "The C++ type for the QObject "]
216-
#[doc = "MyObject"]
217-
#[doc = "\n"]
218-
#[doc = "Use this type when referring to the QObject as a pointer"]
219-
#[doc = "\n"]
220-
#[doc = "See the book for more information: <https://kdab.github.io/cxx-qt/book/qobject/generated-qobject.html>"]
221-
pub type MyObject = super::MyObject;
222-
}
223213
}

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,4 @@ pub mod cxx_qt_ffi {
208208
self.cxx_qt_ffi_rust_mut()
209209
}
210210
}
211-
#[doc = r" Generated CXX-Qt module containing type alias to the C++ types of the QObjects"]
212-
pub mod qobject {
213-
#[doc = "The C++ type for the QObject "]
214-
#[doc = "MyObject"]
215-
#[doc = "\n"]
216-
#[doc = "Use this type when referring to the QObject as a pointer"]
217-
#[doc = "\n"]
218-
#[doc = "See the book for more information: <https://kdab.github.io/cxx-qt/book/qobject/generated-qobject.html>"]
219-
pub type MyObject = super::MyObject;
220-
}
221211
}

crates/cxx-qt-macro/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use cxx_qt_gen::{write_rust, GeneratedRustBlocks, Parser};
1818
///
1919
/// ```rust
2020
/// #[cxx_qt::bridge(namespace = "cxx_qt::my_object")]
21-
/// mod ffi {
21+
/// mod qobject {
2222
/// unsafe extern "RustQt" {
2323
/// #[cxx_qt::qobject]
2424
/// # // Note that we can't use properties as this confuses the linker on Windows
@@ -32,9 +32,7 @@ use cxx_qt_gen::{write_rust, GeneratedRustBlocks, Parser};
3232
/// #[derive(Default)]
3333
/// pub struct MyObjectRust;
3434
///
35-
/// # // TODO: this will change to qobject::MyObject once
36-
/// # // https://github.com/KDAB/cxx-qt/issues/559 is done
37-
/// impl ffi::MyObject {
35+
/// impl qobject::MyObject {
3836
/// fn invokable(&self, a: i32, b: i32) -> i32 {
3937
/// a + b
4038
/// }

crates/cxx-qt/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub trait Threading: Locking + Sized {
9292
/// # Minimal Example
9393
/// ```
9494
/// #[cxx_qt::bridge]
95-
/// mod ffi {
95+
/// mod qobject {
9696
/// extern "RustQt" {
9797
/// #[cxx_qt::qobject]
9898
/// type MyStruct = super::MyStructRust;

0 commit comments

Comments
 (0)