Skip to content

Commit 8618301

Browse files
Separate parsing RustQt blocks, like we do with C++Qt
- Refactor parsing steps to be more readable - Refactor tests to be better separated
1 parent a2695b9 commit 8618301

File tree

13 files changed

+445
-433
lines changed

13 files changed

+445
-433
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ use std::{
4343
};
4444

4545
use cxx_qt_gen::{
46-
parse_qt_file, qualify_self_types, write_cpp, write_rust, CppFragment, CxxQtItem,
47-
GeneratedCppBlocks, GeneratedOpt, GeneratedRustBlocks, Parser,
46+
parse_qt_file, self_inlining::qualify_self_types, write_cpp, write_rust, CppFragment,
47+
CxxQtItem, GeneratedCppBlocks, GeneratedOpt, GeneratedRustBlocks, Parser,
4848
};
4949

5050
// TODO: we need to eventually support having multiple modules defined in a single file. This

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ impl GeneratedRustBlocks {
104104
fn add_qobject_import(cxx_qt_data: &ParsedCxxQtData) -> Option<GeneratedRustFragment> {
105105
let includes = cxx_qt_data
106106
.qobjects()
107+
.iter()
107108
.any(|obj| obj.has_qobject_macro && obj.base_class.is_none());
108109
if includes
109110
|| cxx_qt_data

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ impl<'a> Structures<'a> {
8080
pub fn new(cxxqtdata: &'a ParsedCxxQtData) -> Result<Self> {
8181
let mut qobjects: Vec<_> = cxxqtdata
8282
.qobjects()
83+
.into_iter()
8384
.map(StructuredQObject::from_qobject)
8485
.collect();
8586

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
mod generator;
1212
mod naming;
1313
mod parser;
14-
mod preprocessor;
14+
mod shorthand;
1515
mod syntax;
1616
mod writer;
1717

@@ -21,7 +21,7 @@ pub use generator::{
2121
GeneratedOpt,
2222
};
2323
pub use parser::Parser;
24-
pub use preprocessor::self_inlining::qualify_self_types;
24+
pub use shorthand::self_inlining;
2525
pub use syntax::{parse_qt_file, CxxQtFile, CxxQtItem};
2626
pub use writer::{cpp::write_cpp, rust::write_rust};
2727

@@ -88,6 +88,7 @@ mod tests {
8888
$(assert!($parse_fn(syn::parse_quote! $input).is_err());)*
8989
}
9090
}
91+
use crate::self_inlining::qualify_self_types;
9192
pub(crate) use assert_parse_errors;
9293

9394
/// Helper for formating C++ code

0 commit comments

Comments
 (0)