Skip to content

Commit cffa211

Browse files
committed
cxx-qt-gen: remove unused members list
1 parent 4896525 commit cffa211

File tree

4 files changed

+12
-55
lines changed

4 files changed

+12
-55
lines changed

cxx-qt-gen/src/gen_cpp.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,6 @@ struct CppSignal {
168168
}
169169
/// Describes a C++ property with header and source parts
170170
struct CppProperty {
171-
/// Any members that are required for the property
172-
header_members: Vec<String>,
173171
/// The header meta definition of the invokable
174172
header_meta: Vec<String>,
175173
/// The header public definition of the invokable
@@ -354,8 +352,6 @@ fn generate_properties_cpp(
354352

355353
// Build a basic C++ property with parts that are defined if the property is a pointer or not
356354
let mut cpp_property = CppProperty {
357-
// Members are defined later for only the pointer
358-
header_members: vec![],
359355
// Set the Q_PROPERTY for the C++ class
360356
header_meta: vec![format!("Q_PROPERTY({type_ident} {ident} READ {ident_getter} WRITE {ident_setter} NOTIFY {ident_changed})",
361357
ident = parameter.ident,
@@ -540,14 +536,12 @@ pub fn generate_qobject_cpp(obj: &QObject) -> Result<CppObject, TokenStream> {
540536

541537
// TODO: For now we proxy the gen_cpp code into what the writer phase expects
542538
// later this code will be moved into a generator phase
543-
let mut members: Vec<String> = vec![];
544539
let mut metaobjects: Vec<String> = vec![];
545540
let mut methods: Vec<CppFragmentPair> = vec![];
546541
let mut signals: Vec<String> = vec![];
547542
let mut slots: Vec<CppFragmentPair> = vec![];
548543

549544
for mut property in generate_properties_cpp(&obj.ident, &obj.properties)?.drain(..) {
550-
members.append(&mut property.header_members);
551545
metaobjects.append(&mut property.header_meta);
552546
methods.append(
553547
&mut property
@@ -627,7 +621,6 @@ pub fn generate_qobject_cpp(obj: &QObject) -> Result<CppObject, TokenStream> {
627621
methods,
628622
slots,
629623
signals,
630-
members,
631624
};
632625

633626
// Use our writer phase to convert to a string

cxx-qt-gen/src/generator/cpp/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,4 @@ pub struct GeneratedCppBlocks {
3131
pub slots: Vec<CppFragmentPair>,
3232
/// List of public Q_SIGNALS for the QObject
3333
pub signals: Vec<String>,
34-
/// List of private members for the QObject
35-
pub members: Vec<String>,
3634
}

cxx-qt-gen/src/writer/cpp/header.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ pub fn write_cpp_header(generated: &GeneratedCppBlocks) -> String {
7373
rust::Box<{rust_ident}> m_rustObj;
7474
std::shared_ptr<std::mutex> m_rustObjMutex;
7575
std::shared_ptr<rust::cxxqtlib1::CxxQtGuardedPointer<{ident}>> m_cxxQtThreadObj;
76-
77-
{members}
7876
}};
7977
8078
static_assert(std::is_base_of<QObject, {ident}>::value, "{ident} must inherit from QObject");
@@ -107,7 +105,6 @@ pub fn write_cpp_header(generated: &GeneratedCppBlocks) -> String {
107105
methods = create_block("public", &generated.methods.iter().map(pair_as_header).collect::<Vec<&str>>()),
108106
slots = create_block("public Q_SLOTS", &generated.slots.iter().map(pair_as_header).collect::<Vec<&str>>()),
109107
signals = create_block("Q_SIGNALS", &generated.signals.iter().map(AsRef::as_ref).collect::<Vec<&str>>()),
110-
members = generated.members.join("\n "),
111108
metatype = if generated.namespace.is_empty() {
112109
generated.ident.clone()
113110
} else {

cxx-qt-gen/src/writer/cpp/mod.rs

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ mod tests {
5151
int
5252
MyObject::count() const
5353
{
54-
return m_count;
54+
// getter
5555
}
5656
"#}
5757
.to_owned(),
@@ -62,7 +62,7 @@ mod tests {
6262
bool
6363
MyObject::toggle() const
6464
{
65-
return m_count;
65+
// getter
6666
}
6767
"#}
6868
.to_owned(),
@@ -97,11 +97,7 @@ mod tests {
9797
void
9898
MyObject::setCount(int count) const
9999
{
100-
if (m_count != count) {
101-
m_count = count;
102-
103-
Q_EMIT countChanged();
104-
}
100+
// setter
105101
}
106102
"#}
107103
.to_owned(),
@@ -112,11 +108,7 @@ mod tests {
112108
void
113109
MyObject::setToggle(bool toggle) const
114110
{
115-
if (m_toggle != toggle) {
116-
m_toggle = toggle;
117-
118-
Q_EMIT toggleChanged();
119-
}
111+
// setter
120112
}
121113
"#}
122114
.to_owned(),
@@ -126,7 +118,6 @@ mod tests {
126118
"void countChanged();".to_owned(),
127119
"void toggleChanged();".to_owned(),
128120
],
129-
members: vec!["int m_count;".to_owned(), "bool m_toggle;".to_owned()],
130121
}
131122
}
132123

@@ -190,9 +181,6 @@ mod tests {
190181
rust::Box<MyObjectRust> m_rustObj;
191182
std::shared_ptr<std::mutex> m_rustObjMutex;
192183
std::shared_ptr<rust::cxxqtlib1::CxxQtGuardedPointer<MyObject>> m_cxxQtThreadObj;
193-
194-
int m_count;
195-
bool m_toggle;
196184
};
197185
198186
static_assert(std::is_base_of<QObject, MyObject>::value, "MyObject must inherit from QObject");
@@ -259,9 +247,6 @@ mod tests {
259247
rust::Box<MyObjectRust> m_rustObj;
260248
std::shared_ptr<std::mutex> m_rustObjMutex;
261249
std::shared_ptr<rust::cxxqtlib1::CxxQtGuardedPointer<MyObject>> m_cxxQtThreadObj;
262-
263-
int m_count;
264-
bool m_toggle;
265250
};
266251
267252
static_assert(std::is_base_of<QObject, MyObject>::value, "MyObject must inherit from QObject");
@@ -318,13 +303,13 @@ mod tests {
318303
int
319304
MyObject::count() const
320305
{
321-
return m_count;
306+
// getter
322307
}
323308
324309
bool
325310
MyObject::toggle() const
326311
{
327-
return m_count;
312+
// getter
328313
}
329314
330315
void
@@ -342,21 +327,13 @@ mod tests {
342327
void
343328
MyObject::setCount(int count) const
344329
{
345-
if (m_count != count) {
346-
m_count = count;
347-
348-
Q_EMIT countChanged();
349-
}
330+
// setter
350331
}
351332
352333
void
353334
MyObject::setToggle(bool toggle) const
354335
{
355-
if (m_toggle != toggle) {
356-
m_toggle = toggle;
357-
358-
Q_EMIT toggleChanged();
359-
}
336+
// setter
360337
}
361338
362339
} // namespace cxx_qt::my_object
@@ -413,13 +390,13 @@ mod tests {
413390
int
414391
MyObject::count() const
415392
{
416-
return m_count;
393+
// getter
417394
}
418395
419396
bool
420397
MyObject::toggle() const
421398
{
422-
return m_count;
399+
// getter
423400
}
424401
425402
void
@@ -437,21 +414,13 @@ mod tests {
437414
void
438415
MyObject::setCount(int count) const
439416
{
440-
if (m_count != count) {
441-
m_count = count;
442-
443-
Q_EMIT countChanged();
444-
}
417+
// setter
445418
}
446419
447420
void
448421
MyObject::setToggle(bool toggle) const
449422
{
450-
if (m_toggle != toggle) {
451-
m_toggle = toggle;
452-
453-
Q_EMIT toggleChanged();
454-
}
423+
// setter
455424
}
456425
457426

0 commit comments

Comments
 (0)