Skip to content

Commit a2b967d

Browse files
usiemsmrbean-bremen
authored andcommitted
initialize members with list-initializers
as far as is possible (bit-field list-initializers are a C++20 feature)
1 parent 14c1de6 commit a2b967d

File tree

2 files changed

+36
-61
lines changed

2 files changed

+36
-61
lines changed

generator/abstractmetalang.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,10 +1201,6 @@ static bool functions_contains(const AbstractMetaFunctionList &l, const Abstract
12011201
return false;
12021202
}
12031203

1204-
AbstractMetaField::AbstractMetaField() : m_getter(0), m_setter(0), m_class(0)
1205-
{
1206-
}
1207-
12081204
AbstractMetaField::~AbstractMetaField()
12091205
{
12101206
delete m_setter;

generator/abstractmetalang.h

Lines changed: 36 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class AbstractMetaClassList : public QList<AbstractMetaClass *>
7979
class AbstractMetaAttributes
8080
{
8181
public:
82-
AbstractMetaAttributes() : m_attributes(0) { };
82+
AbstractMetaAttributes() = default;
8383

8484
enum Attribute {
8585
None = 0x00000000,
@@ -180,11 +180,6 @@ class AbstractMetaType
180180
};
181181

182182
AbstractMetaType() :
183-
m_type_entry(0),
184-
m_array_element_count(0),
185-
m_array_element_type(0),
186-
m_original_template_type(0),
187-
m_pattern(InvalidPattern),
188183
m_constant(false),
189184
m_reference(false),
190185
m_cpp_instantiation(true),
@@ -294,16 +289,16 @@ class AbstractMetaType
294289
const AbstractMetaType *originalTemplateType() const { return m_original_template_type; }
295290

296291
private:
297-
const TypeEntry *m_type_entry;
292+
const TypeEntry *m_type_entry{};
298293
QList <AbstractMetaType *> m_instantiations;
299294
QString m_package;
300295
QString m_original_type_description;
301296

302-
int m_array_element_count;
303-
AbstractMetaType *m_array_element_type;
304-
const AbstractMetaType *m_original_template_type;
297+
int m_array_element_count{};
298+
AbstractMetaType *m_array_element_type{};
299+
const AbstractMetaType *m_original_template_type{};
305300

306-
TypeUsagePattern m_pattern;
301+
TypeUsagePattern m_pattern{InvalidPattern};
307302
uint m_constant : 1;
308303
uint m_reference : 1;
309304
uint m_cpp_instantiation : 1;
@@ -314,7 +309,7 @@ class AbstractMetaType
314309
class AbstractMetaVariable
315310
{
316311
public:
317-
AbstractMetaVariable() : m_type(0) { }
312+
AbstractMetaVariable() = default;
318313

319314
AbstractMetaType *type() const { return m_type; }
320315
void setType(AbstractMetaType *type) { m_type = type; }
@@ -324,15 +319,15 @@ class AbstractMetaVariable
324319

325320
private:
326321
QString m_name;
327-
AbstractMetaType *m_type;
322+
AbstractMetaType *m_type{};
328323
};
329324

330325

331326

332327
class AbstractMetaArgument : public AbstractMetaVariable
333328
{
334329
public:
335-
AbstractMetaArgument() : m_argument_index(0) { };
330+
AbstractMetaArgument() = default;
336331

337332
QString defaultValueExpression() const { return m_expression; }
338333
void setDefaultValueExpression(const QString &expr) { m_expression = expr; }
@@ -357,14 +352,14 @@ class AbstractMetaArgument : public AbstractMetaVariable
357352

358353
QString m_expression;
359354
QString m_original_expression;
360-
int m_argument_index;
355+
int m_argument_index{};
361356
};
362357

363358

364359
class AbstractMetaField : public AbstractMetaVariable, public AbstractMetaAttributes
365360
{
366361
public:
367-
AbstractMetaField();
362+
AbstractMetaField() = default;
368363
~AbstractMetaField();
369364

370365
const AbstractMetaClass *enclosingClass() const { return m_class; }
@@ -378,9 +373,9 @@ class AbstractMetaField : public AbstractMetaVariable, public AbstractMetaAttrib
378373
AbstractMetaField *copy() const;
379374

380375
private:
381-
mutable AbstractMetaFunction *m_getter;
382-
mutable AbstractMetaFunction *m_setter;
383-
const AbstractMetaClass *m_class;
376+
mutable AbstractMetaFunction *m_getter{};
377+
mutable AbstractMetaFunction *m_setter{};
378+
const AbstractMetaClass *m_class{};
384379
};
385380

386381

@@ -413,14 +408,7 @@ class AbstractMetaFunction : public AbstractMetaAttributes
413408
NotEqual = 0x00001000
414409
};
415410

416-
AbstractMetaFunction()
417-
: m_function_type(NormalFunction),
418-
m_type(0),
419-
m_class(0),
420-
m_implementing_class(0),
421-
m_declaring_class(0),
422-
m_interface_class(0),
423-
m_property_spec(0),
411+
AbstractMetaFunction() :
424412
m_constant(false),
425413
m_invalid(false)
426414
{
@@ -552,13 +540,13 @@ class AbstractMetaFunction : public AbstractMetaAttributes
552540
mutable QString m_cached_minimal_signature;
553541
mutable QString m_cached_modified_name;
554542

555-
FunctionType m_function_type;
556-
AbstractMetaType *m_type;
557-
const AbstractMetaClass *m_class;
558-
const AbstractMetaClass *m_implementing_class;
559-
const AbstractMetaClass *m_declaring_class;
560-
const AbstractMetaClass *m_interface_class;
561-
QPropertySpec *m_property_spec;
543+
FunctionType m_function_type{NormalFunction};
544+
AbstractMetaType *m_type{};
545+
const AbstractMetaClass *m_class{};
546+
const AbstractMetaClass *m_implementing_class{};
547+
const AbstractMetaClass *m_declaring_class{};
548+
const AbstractMetaClass *m_interface_class{};
549+
QPropertySpec *m_property_spec{};
562550
AbstractMetaArgumentList m_arguments;
563551
QString m_exception;
564552
uint m_constant : 1;
@@ -569,10 +557,7 @@ class AbstractMetaFunction : public AbstractMetaAttributes
569557
class AbstractMetaEnumValue
570558
{
571559
public:
572-
AbstractMetaEnumValue()
573-
: m_value_set(false), m_value(0)
574-
{
575-
}
560+
AbstractMetaEnumValue() = default;
576561

577562
int value() const { return m_value; }
578563
void setValue(int value) { m_value_set = true; m_value = value; }
@@ -589,8 +574,8 @@ class AbstractMetaEnumValue
589574
QString m_name;
590575
QString m_string_value;
591576

592-
bool m_value_set;
593-
int m_value;
577+
bool m_value_set{};
578+
int m_value{};
594579
};
595580

596581

@@ -603,7 +588,7 @@ class AbstractMetaEnumValueList : public QList<AbstractMetaEnumValue *>
603588
class AbstractMetaEnum : public AbstractMetaAttributes
604589
{
605590
public:
606-
AbstractMetaEnum() : m_type_entry(0), m_class(0), m_has_qenums_declaration(false) {}
591+
AbstractMetaEnum() : m_has_qenums_declaration(false) {}
607592

608593
AbstractMetaEnumValueList values() const { return m_enum_values; }
609594
void addEnumValue(AbstractMetaEnumValue *enumValue) { m_enum_values << enumValue; }
@@ -625,8 +610,8 @@ class AbstractMetaEnum : public AbstractMetaAttributes
625610

626611
private:
627612
AbstractMetaEnumValueList m_enum_values;
628-
EnumTypeEntry *m_type_entry;
629-
AbstractMetaClass *m_class;
613+
EnumTypeEntry *m_type_entry{};
614+
AbstractMetaClass *m_class{};
630615

631616
uint m_has_qenums_declaration : 1;
632617
uint m_reserved : 31;
@@ -680,12 +665,6 @@ class AbstractMetaClass : public AbstractMetaAttributes
680665
m_has_equals_operator(false),
681666
m_has_clone_operator(false),
682667
m_is_type_alias(false),
683-
m_enclosing_class(0),
684-
m_base_class(0),
685-
m_template_base_class(0),
686-
m_extracted_interface(0),
687-
m_primary_interface_implementor(0),
688-
m_type_entry(0),
689668
m_qDebug_stream_function(0)
690669
{
691670
}
@@ -865,16 +844,16 @@ class AbstractMetaClass : public AbstractMetaAttributes
865844
uint m_reserved : 18;
866845
QString m_destructor_exception;
867846

868-
const AbstractMetaClass *m_enclosing_class;
869-
AbstractMetaClass *m_base_class;
847+
const AbstractMetaClass *m_enclosing_class{};
848+
AbstractMetaClass *m_base_class{};
870849
QList<AbstractMetaClass*> m_super_classes;
871-
const AbstractMetaClass *m_template_base_class;
850+
const AbstractMetaClass *m_template_base_class{};
872851
AbstractMetaFunctionList m_functions;
873852
AbstractMetaFieldList m_fields;
874853
AbstractMetaEnumList m_enums;
875854
AbstractMetaClassList m_interfaces;
876-
AbstractMetaClass *m_extracted_interface;
877-
AbstractMetaClass *m_primary_interface_implementor;
855+
AbstractMetaClass *m_extracted_interface{};
856+
AbstractMetaClass *m_primary_interface_implementor{};
878857
QList<QPropertySpec *> m_property_specs;
879858
AbstractMetaFunctionList m_equals_functions;
880859
AbstractMetaFunctionList m_nequals_functions;
@@ -886,7 +865,7 @@ class AbstractMetaClass : public AbstractMetaAttributes
886865

887866
QStringList m_base_class_names;
888867
QList<TypeEntry *> m_template_args;
889-
ComplexTypeEntry *m_type_entry;
868+
ComplexTypeEntry *m_type_entry{};
890869
FunctionModelItem m_qDebug_stream_function;
891870
};
892871

@@ -924,8 +903,8 @@ class QPropertySpec {
924903
QString m_write;
925904
QString m_designable;
926905
QString m_reset;
927-
const TypeEntry *m_type;
928-
int m_index;
906+
const TypeEntry *m_type{};
907+
int m_index{-1};
929908
};
930909

931910
inline AbstractMetaFunctionList AbstractMetaClass::allVirtualFunctions() const

0 commit comments

Comments
 (0)