Port member initialization from constructor to declaration (C++11)

Using `clang-tidy`'s `modernize-use-default-member-init` check and
manual review of the changes, and some extra manual changes that
`clang-tidy` failed to do.

Also went manually through all of `core` to find occurrences that
`clang-tidy` couldn't handle, especially all initializations done
in a constructor without using initializer lists.
This commit is contained in:
Rémi Verschelde 2020-05-12 17:01:17 +02:00
parent e7c9d81876
commit 1f6f364a56
325 changed files with 1689 additions and 3480 deletions

View file

@ -326,17 +326,13 @@ public:
};
struct CSharpScriptBinding {
bool inited;
bool inited = false;
StringName type_name;
GDMonoClass *wrapper_class;
GDMonoClass *wrapper_class = nullptr;
MonoGCHandleData gchandle;
Object *owner;
Object *owner = nullptr;
CSharpScriptBinding() :
inited(false),
wrapper_class(nullptr),
owner(nullptr) {
}
CSharpScriptBinding() {}
};
class ManagedCallableMiddleman : public Object {

View file

@ -85,16 +85,12 @@ class BindingsGenerator {
struct TypeReference {
StringName cname;
bool is_enum;
bool is_enum = false;
TypeReference() :
is_enum(false) {
}
TypeReference() {}
TypeReference(const StringName &p_cname) :
cname(p_cname),
is_enum(false) {
}
cname(p_cname) {}
};
struct ArgumentInterface {
@ -107,7 +103,7 @@ class BindingsGenerator {
TypeReference type;
String name;
DefaultParamMode def_param_mode;
DefaultParamMode def_param_mode = CONSTANT;
/**
* Determines the expression for the parameter default value.
@ -116,9 +112,7 @@ class BindingsGenerator {
*/
String default_argument;
ArgumentInterface() {
def_param_mode = CONSTANT;
}
ArgumentInterface() {}
};
struct MethodInterface {
@ -138,19 +132,19 @@ class BindingsGenerator {
/**
* Determines if the method has a variable number of arguments (VarArg)
*/
bool is_vararg;
bool is_vararg = false;
/**
* Virtual methods ("virtual" as defined by the Godot API) are methods that by default do nothing,
* but can be overridden by the user to add custom functionality.
* e.g.: _ready, _process, etc.
*/
bool is_virtual;
bool is_virtual = false;
/**
* Determines if the call should fallback to Godot's object.Call(string, params) in C#.
*/
bool requires_object_call;
bool requires_object_call = false;
/**
* Determines if the method visibility is 'internal' (visible only to files in the same assembly).
@ -158,27 +152,20 @@ class BindingsGenerator {
* but are required by properties as getters or setters.
* Methods that are not meant to be exposed are those that begin with underscore and are not virtual.
*/
bool is_internal;
bool is_internal = false;
List<ArgumentInterface> arguments;
const DocData::MethodDoc *method_doc;
const DocData::MethodDoc *method_doc = nullptr;
bool is_deprecated;
bool is_deprecated = false;
String deprecation_message;
void add_argument(const ArgumentInterface &argument) {
arguments.push_back(argument);
}
MethodInterface() {
is_vararg = false;
is_virtual = false;
requires_object_call = false;
is_internal = false;
method_doc = nullptr;
is_deprecated = false;
}
MethodInterface() {}
};
struct SignalInterface {
@ -192,19 +179,16 @@ class BindingsGenerator {
List<ArgumentInterface> arguments;
const DocData::MethodDoc *method_doc;
const DocData::MethodDoc *method_doc = nullptr;
bool is_deprecated;
bool is_deprecated = false;
String deprecation_message;
void add_argument(const ArgumentInterface &argument) {
arguments.push_back(argument);
}
SignalInterface() {
method_doc = nullptr;
is_deprecated = false;
}
SignalInterface() {}
};
struct TypeInterface {
@ -225,26 +209,26 @@ class BindingsGenerator {
*/
String proxy_name;
ClassDB::APIType api_type;
ClassDB::APIType api_type = ClassDB::API_NONE;
bool is_enum;
bool is_object_type;
bool is_singleton;
bool is_reference;
bool is_enum = false;
bool is_object_type = false;
bool is_singleton = false;
bool is_reference = false;
/**
* Used only by Object-derived types.
* Determines if this type is not abstract (incomplete).
* e.g.: CanvasItem cannot be instantiated.
*/
bool is_instantiable;
bool is_instantiable = false;
/**
* Used only by Object-derived types.
* Determines if the C# class owns the native handle and must free it somehow when disposed.
* e.g.: Reference types must notify when the C# instance is disposed, for proper refcounting.
*/
bool memory_own;
bool memory_own = false;
/**
* This must be set to true for any struct bigger than 32-bits. Those cannot be passed/returned by value
@ -252,7 +236,7 @@ class BindingsGenerator {
* In this case, [c_out] and [cs_out] must have a different format, explained below.
* The Mono IL interpreter icall trampolines don't support passing structs bigger than 32-bits by value (at least not on WASM).
*/
bool ret_as_byref_arg;
bool ret_as_byref_arg = false;
// !! The comments of the following fields make reference to other fields via square brackets, e.g.: [field_name]
// !! When renaming those fields, make sure to rename their references in the comments
@ -279,7 +263,7 @@ class BindingsGenerator {
* Formatting elements:
* %0 or %s: name of the parameter
*/
String c_arg_in;
String c_arg_in = "%s";
/**
* One or more statements that determine how a variable of this type is returned from a function.
@ -362,7 +346,7 @@ class BindingsGenerator {
*/
String im_type_out;
const DocData::ClassDoc *class_doc;
const DocData::ClassDoc *class_doc = nullptr;
List<ConstantInterface> constants;
List<EnumInterface> enums;
@ -482,24 +466,7 @@ class BindingsGenerator {
r_enum_itype.class_doc = &EditorHelp::get_doc_data()->class_list[r_enum_itype.proxy_name];
}
TypeInterface() {
api_type = ClassDB::API_NONE;
is_enum = false;
is_object_type = false;
is_singleton = false;
is_reference = false;
is_instantiable = false;
memory_own = false;
ret_as_byref_arg = false;
c_arg_in = "%s";
class_doc = nullptr;
}
TypeInterface() {}
};
struct InternalCall {
@ -532,8 +499,8 @@ class BindingsGenerator {
}
};
bool log_print_enabled;
bool initialized;
bool log_print_enabled = true;
bool initialized = false;
OrderedHashMap<StringName, TypeInterface> obj_types;
@ -697,9 +664,7 @@ public:
static void handle_cmdline_args(const List<String> &p_cmdline_args);
BindingsGenerator() :
log_print_enabled(true),
initialized(false) {
BindingsGenerator() {
_initialize();
}
};

View file

@ -47,8 +47,8 @@ enum class GCHandleType : char {
// Manual release of the GC handle must be done when using this struct
struct MonoGCHandleData {
uint32_t handle;
gdmono::GCHandleType type;
uint32_t handle = 0;
gdmono::GCHandleType type = gdmono::GCHandleType::NIL;
_FORCE_INLINE_ bool is_released() const { return !handle; }
_FORCE_INLINE_ bool is_weak() const { return type == gdmono::GCHandleType::WEAK_HANDLE; }
@ -68,10 +68,7 @@ struct MonoGCHandleData {
MonoGCHandleData(const MonoGCHandleData &) = default;
MonoGCHandleData() :
handle(0),
type(gdmono::GCHandleType::NIL) {
}
MonoGCHandleData() {}
MonoGCHandleData(uint32_t p_handle, gdmono::GCHandleType p_type) :
handle(p_handle),

View file

@ -48,9 +48,9 @@ enum Type {
};
struct Version {
uint64_t godot_api_hash;
uint32_t bindings_version;
uint32_t cs_glue_version;
uint64_t godot_api_hash = 0;
uint32_t bindings_version = 0;
uint32_t cs_glue_version = 0;
bool operator==(const Version &p_other) const {
return godot_api_hash == p_other.godot_api_hash &&
@ -58,11 +58,7 @@ struct Version {
cs_glue_version == p_other.cs_glue_version;
}
Version() :
godot_api_hash(0),
bindings_version(0),
cs_glue_version(0) {
}
Version() {}
Version(uint64_t p_godot_api_hash,
uint32_t p_bindings_version,
@ -87,13 +83,10 @@ public:
};
struct LoadedApiAssembly {
GDMonoAssembly *assembly;
bool out_of_sync;
GDMonoAssembly *assembly = nullptr;
bool out_of_sync = false;
LoadedApiAssembly() :
assembly(nullptr),
out_of_sync(false) {
}
LoadedApiAssembly() {}
};
private:

View file

@ -490,18 +490,7 @@ GDMonoAssembly *GDMonoAssembly::load_from(const String &p_name, const String &p_
return loaded_asm;
}
GDMonoAssembly::GDMonoAssembly(const String &p_name, MonoImage *p_image, MonoAssembly *p_assembly) :
name(p_name),
image(p_image),
assembly(p_assembly),
#ifdef GD_MONO_HOT_RELOAD
modified_time(0),
#endif
gdobject_class_cache_updated(false) {
}
GDMonoAssembly::~GDMonoAssembly() {
if (image)
unload();
}

View file

@ -73,10 +73,10 @@ class GDMonoAssembly {
MonoAssembly *assembly;
#ifdef GD_MONO_HOT_RELOAD
uint64_t modified_time;
uint64_t modified_time = 0;
#endif
bool gdobject_class_cache_updated;
bool gdobject_class_cache_updated = false;
Map<StringName, GDMonoClass *> gdobject_class_cache;
HashMap<ClassKey, GDMonoClass *, ClassKey::Hasher> cached_classes;
@ -125,7 +125,11 @@ public:
static GDMonoAssembly *load(const String &p_name, MonoAssemblyName *p_aname, bool p_refonly, const Vector<String> &p_search_dirs);
static GDMonoAssembly *load_from(const String &p_name, const String &p_path, bool p_refonly);
GDMonoAssembly(const String &p_name, MonoImage *p_image, MonoAssembly *p_assembly);
GDMonoAssembly(const String &p_name, MonoImage *p_image, MonoAssembly *p_assembly) :
name(p_name),
image(p_image),
assembly(p_assembly) {
}
~GDMonoAssembly();
};

View file

@ -50,7 +50,7 @@ struct GDMonoMethodThunk {
typedef void(GD_MONO_STDCALL *M)(ParamTypes... p_args, MonoException **);
M mono_method_thunk;
M mono_method_thunk = nullptr;
public:
_FORCE_INLINE_ void invoke(ParamTypes... p_args, MonoException **r_exc) {
@ -81,9 +81,7 @@ public:
mono_method_thunk = (M)mono_method_get_unmanaged_thunk(p_mono_method->get_mono_ptr());
}
GDMonoMethodThunk() :
mono_method_thunk(nullptr) {
}
GDMonoMethodThunk() {}
explicit GDMonoMethodThunk(GDMonoMethod *p_mono_method) {
set_from_method(p_mono_method);
@ -95,7 +93,7 @@ struct GDMonoMethodThunkR {
typedef R(GD_MONO_STDCALL *M)(ParamTypes... p_args, MonoException **);
M mono_method_thunk;
M mono_method_thunk = nullptr;
public:
_FORCE_INLINE_ R invoke(ParamTypes... p_args, MonoException **r_exc) {
@ -127,9 +125,7 @@ public:
mono_method_thunk = (M)mono_method_get_unmanaged_thunk(p_mono_method->get_mono_ptr());
}
GDMonoMethodThunkR() :
mono_method_thunk(nullptr) {
}
GDMonoMethodThunkR() {}
explicit GDMonoMethodThunkR(GDMonoMethod *p_mono_method) {
#ifdef DEBUG_ENABLED
@ -248,7 +244,7 @@ struct VariadicInvokeMonoMethodR<1, R, P1> {
template <class... ParamTypes>
struct GDMonoMethodThunk {
GDMonoMethod *mono_method;
GDMonoMethod *mono_method = nullptr;
public:
_FORCE_INLINE_ void invoke(ParamTypes... p_args, MonoException **r_exc) {
@ -277,9 +273,7 @@ public:
mono_method = p_mono_method;
}
GDMonoMethodThunk() :
mono_method(nullptr) {
}
GDMonoMethodThunk() {}
explicit GDMonoMethodThunk(GDMonoMethod *p_mono_method) {
set_from_method(p_mono_method);
@ -289,7 +283,7 @@ public:
template <class R, class... ParamTypes>
struct GDMonoMethodThunkR {
GDMonoMethod *mono_method;
GDMonoMethod *mono_method = nullptr;
public:
_FORCE_INLINE_ R invoke(ParamTypes... p_args, MonoException **r_exc) {
@ -318,9 +312,7 @@ public:
mono_method = p_mono_method;
}
GDMonoMethodThunkR() :
mono_method(nullptr) {
}
GDMonoMethodThunkR() {}
explicit GDMonoMethodThunkR(GDMonoMethod *p_mono_method) {
set_from_method(p_mono_method);

View file

@ -664,8 +664,7 @@ GDMonoClass *make_generic_dictionary_type(MonoReflectionType *p_key_reftype, Mon
} // namespace Marshal
ScopeThreadAttach::ScopeThreadAttach() :
mono_thread(nullptr) {
ScopeThreadAttach::ScopeThreadAttach() {
if (likely(GDMono::get_singleton()->is_runtime_initialized()) && unlikely(!mono_domain_get())) {
mono_thread = GDMonoUtils::attach_current_thread();
}

View file

@ -155,7 +155,7 @@ struct ScopeThreadAttach {
~ScopeThreadAttach();
private:
MonoThread *mono_thread;
MonoThread *mono_thread = nullptr;
};
StringName get_native_godot_class_name(GDMonoClass *p_class);

View file

@ -36,18 +36,15 @@
#include "gd_mono_header.h"
struct ManagedType {
int type_encoding;
GDMonoClass *type_class;
int type_encoding = 0;
GDMonoClass *type_class = nullptr;
static ManagedType from_class(GDMonoClass *p_class);
static ManagedType from_class(MonoClass *p_mono_class);
static ManagedType from_type(MonoType *p_mono_type);
static ManagedType from_reftype(MonoReflectionType *p_mono_reftype);
ManagedType() :
type_encoding(0),
type_class(nullptr) {
}
ManagedType() {}
ManagedType(int p_type_encoding, GDMonoClass *p_type_class) :
type_encoding(p_type_encoding),