Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ahayzen-kdab committed Oct 4, 2023
1 parent 39ab3c6 commit d7ff982
Show file tree
Hide file tree
Showing 19 changed files with 2,922 additions and 432 deletions.
10 changes: 8 additions & 2 deletions crates/cxx-qt-gen/src/generator/cpp/externcxxqt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ use syn::Result;
pub struct GeneratedCppExternCxxQtBlocks {
/// List of includes
pub includes: BTreeSet<String>,
/// List of forward declares before the class and include of the generated CXX header
pub forward_declares: Vec<String>,
/// List of methods
pub method: CppFragment,
/// Namespace of the method block
pub methods: Vec<CppFragment>,
/// List of source which is outside of the namespace
///
/// TODO: should these just be String as they are only source?
pub sources: Vec<CppFragment>,
/// Namespace of the method blocks
pub namespace: String,
}

Expand Down
24 changes: 12 additions & 12 deletions crates/cxx-qt-gen/src/generator/cpp/property/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,20 @@ mod tests {
};
assert_str_eq!(
header,
"::QMetaObject::Connection trivialPropertyChangedConnect(::rust::Fn<void(MyObject&)> func, ::Qt::ConnectionType type);"
"::QMetaObject::Connection trivialPropertyChangedConnect(::MyObjectCxxQtSignalHandlertrivialPropertyChanged closure, ::Qt::ConnectionType type);"
);
assert_str_eq!(
source,
indoc! {r#"
::QMetaObject::Connection
MyObject::trivialPropertyChangedConnect(::rust::Fn<void(MyObject&)> func, ::Qt::ConnectionType type)
MyObject::trivialPropertyChangedConnect(::MyObjectCxxQtSignalHandlertrivialPropertyChanged closure, ::Qt::ConnectionType type)
{
return ::QObject::connect(this,
&MyObject::trivialPropertyChanged,
this,
[&, func = ::std::move(func)]() {
[&, closure = ::std::move(closure)]() mutable {
const ::rust::cxxqtlib1::MaybeLockGuard<MyObject> guard(*this);
func(*this);
closure.template operator()<MyObject&>(*this);
},
type);
}
Expand All @@ -220,20 +220,20 @@ mod tests {
};
assert_str_eq!(
header,
"::QMetaObject::Connection opaquePropertyChangedConnect(::rust::Fn<void(MyObject&)> func, ::Qt::ConnectionType type);"
"::QMetaObject::Connection opaquePropertyChangedConnect(::MyObjectCxxQtSignalHandleropaquePropertyChanged closure, ::Qt::ConnectionType type);"
);
assert_str_eq!(
source,
indoc! {r#"
::QMetaObject::Connection
MyObject::opaquePropertyChangedConnect(::rust::Fn<void(MyObject&)> func, ::Qt::ConnectionType type)
MyObject::opaquePropertyChangedConnect(::MyObjectCxxQtSignalHandleropaquePropertyChanged closure, ::Qt::ConnectionType type)
{
return ::QObject::connect(this,
&MyObject::opaquePropertyChanged,
this,
[&, func = ::std::move(func)]() {
[&, closure = ::std::move(closure)]() mutable {
const ::rust::cxxqtlib1::MaybeLockGuard<MyObject> guard(*this);
func(*this);
closure.template operator()<MyObject&>(*this);
},
type);
}
Expand Down Expand Up @@ -354,20 +354,20 @@ mod tests {
};
assert_str_eq!(
header,
"::QMetaObject::Connection mappedPropertyChangedConnect(::rust::Fn<void(MyObject&)> func, ::Qt::ConnectionType type);"
"::QMetaObject::Connection mappedPropertyChangedConnect(::MyObjectCxxQtSignalHandlermappedPropertyChanged closure, ::Qt::ConnectionType type);"
);
assert_str_eq!(
source,
indoc! {r#"
::QMetaObject::Connection
MyObject::mappedPropertyChangedConnect(::rust::Fn<void(MyObject&)> func, ::Qt::ConnectionType type)
MyObject::mappedPropertyChangedConnect(::MyObjectCxxQtSignalHandlermappedPropertyChanged closure, ::Qt::ConnectionType type)
{
return ::QObject::connect(this,
&MyObject::mappedPropertyChanged,
this,
[&, func = ::std::move(func)]() {
[&, closure = ::std::move(closure)]() mutable {
const ::rust::cxxqtlib1::MaybeLockGuard<MyObject> guard(*this);
func(*this);
closure.template operator()<MyObject&>(*this);
},
type);
}
Expand Down
5 changes: 5 additions & 0 deletions crates/cxx-qt-gen/src/generator/cpp/qobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ pub struct GeneratedCppQObjectBlocks {
pub metaobjects: Vec<String>,
/// List of public methods for the QObject
pub methods: Vec<CppFragment>,
/// List of source which is outside of the QObject namespace
///
/// TODO: should these just be String as they are only source?
pub sources: Vec<CppFragment>,
/// List of private methods for the QObject
pub private_methods: Vec<CppFragment>,
/// List of includes
Expand All @@ -36,6 +40,7 @@ impl GeneratedCppQObjectBlocks {
self.forward_declares.append(&mut other.forward_declares);
self.metaobjects.append(&mut other.metaobjects);
self.methods.append(&mut other.methods);
self.sources.append(&mut other.sources);
self.private_methods.append(&mut other.private_methods);
self.includes.append(&mut other.includes);
self.base_classes.append(&mut other.base_classes);
Expand Down
Loading

0 comments on commit d7ff982

Please sign in to comment.