Skip to content

Commit

Permalink
cxx-qt-gen: remove unused others from parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ahayzen-kdab authored and Be-ing committed Aug 24, 2023
1 parent 2730139 commit 746fb7a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
5 changes: 1 addition & 4 deletions crates/cxx-qt-gen/src/generator/rust/qobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ impl GeneratedRustQObject {
// Create the base object
let qobject_idents = QObjectName::from(qobject);
let namespace_idents = NamespaceName::from(qobject);
let mut generated = GeneratedRustQObject {
cxx_mod_contents: vec![],
cxx_qt_mod_contents: qobject.others.clone(),
};
let mut generated = GeneratedRustQObject::default();

generated.append(&mut generate_qobject_definitions(
&qobject_idents,
Expand Down
8 changes: 2 additions & 6 deletions crates/cxx-qt-gen/src/parser/cxxqtdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,8 @@ impl ParsedCxxQtData {
// If we are a trait then process it otherwise add to others
if imp.trait_.is_some() {
qobject.parse_trait_impl(imp)?;
} else {
qobject.others.push(Item::Impl(imp));
return Ok(None);
}

return Ok(None);
}
}
}
Expand Down Expand Up @@ -490,8 +487,7 @@ mod tests {
}
};
let result = cxx_qt_data.parse_cxx_qt_item(item).unwrap();
assert!(result.is_none());
assert_eq!(cxx_qt_data.qobjects[&qobject_ident()].others.len(), 1);
assert!(result.is_some());
}

#[test]
Expand Down
6 changes: 1 addition & 5 deletions crates/cxx-qt-gen/src/parser/qobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
path::path_compare_str,
},
};
use syn::{Attribute, Error, Ident, Item, ItemImpl, Meta, Result};
use syn::{Attribute, Error, Ident, ItemImpl, Meta, Result};

/// Metadata for registering QML element
#[derive(Clone, Debug, Default, Eq, PartialEq)]
Expand Down Expand Up @@ -57,9 +57,6 @@ pub struct ParsedQObject {
pub locking: bool,
/// Whether threading has been enabled for this QObject
pub threading: bool,
/// Items that we don't need to generate anything for CXX or C++
/// eg impls on the Rust object or Default implementations
pub others: Vec<Item>,
}

impl TryFrom<&ForeignTypeIdentAlias> for ParsedQObject {
Expand Down Expand Up @@ -100,7 +97,6 @@ impl TryFrom<&ForeignTypeIdentAlias> for ParsedQObject {
qml_metadata,
locking: true,
threading: false,
others: vec![],
})
}
}
Expand Down

0 comments on commit 746fb7a

Please sign in to comment.