summaryrefslogtreecommitdiff
path: root/modules/gdnative
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-12 17:01:17 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 10:01:56 +0200
commit1f6f364a56319eabd02c050746fe7df3f55ffee3 (patch)
tree8bebdce946466ce8e9476ccd46c9dba62c323938 /modules/gdnative
parente7c9d818766a119089873e4941e4865fb36883ec (diff)
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.
Diffstat (limited to 'modules/gdnative')
-rw-r--r--modules/gdnative/nativescript/nativescript.h24
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp5
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.h10
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.cpp17
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.h42
5 files changed, 34 insertions, 64 deletions
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index 7e7598e06c..d24b247e59 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -43,6 +43,7 @@
#include "scene/main/node.h"
#include "modules/gdnative/gdnative.h"
+
#include <nativescript/godot_nativescript.h>
struct NativeScriptDesc {
@@ -54,6 +55,7 @@ struct NativeScriptDesc {
uint16_t rpc_method_id;
String documentation;
};
+
struct Property {
godot_property_set_func setter;
godot_property_get_func getter;
@@ -69,9 +71,9 @@ struct NativeScriptDesc {
String documentation;
};
- uint16_t rpc_count;
+ uint16_t rpc_count = 0;
Map<StringName, Method> methods;
- uint16_t rset_count;
+ uint16_t rset_count = 0;
OrderedHashMap<StringName, Property> properties;
Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals
StringName base;
@@ -82,20 +84,11 @@ struct NativeScriptDesc {
String documentation;
- const void *type_tag;
+ const void *type_tag = nullptr;
bool is_tool;
- inline NativeScriptDesc() :
- rpc_count(0),
- methods(),
- rset_count(0),
- properties(),
- signals_(),
- base(),
- base_native_type(),
- documentation(),
- type_tag(nullptr) {
+ inline NativeScriptDesc() {
zeromem(&create_func, sizeof(godot_instance_create_func));
zeromem(&destroy_func, sizeof(godot_instance_destroy_func));
}
@@ -396,14 +389,13 @@ inline NativeScriptDesc *NativeScript::get_script_desc() const {
class NativeReloadNode : public Node {
GDCLASS(NativeReloadNode, Node);
- bool unloaded;
+ bool unloaded = false;
public:
static void _bind_methods();
void _notification(int p_what);
- NativeReloadNode() :
- unloaded(false) {}
+ NativeReloadNode() {}
};
class ResourceFormatLoaderNativeScript : public ResourceFormatLoader {
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp
index 6b303c8716..9b00d654d1 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_script.cpp
@@ -550,11 +550,6 @@ MultiplayerAPI::RPCMode PluginScript::get_rset_mode(const StringName &p_variable
}
PluginScript::PluginScript() :
- _data(nullptr),
- _desc(nullptr),
- _language(nullptr),
- _tool(false),
- _valid(false),
_script_list(this) {
}
diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h
index 70b9ca980b..287f42bf7b 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.h
+++ b/modules/gdnative/pluginscript/pluginscript_script.h
@@ -45,11 +45,11 @@ class PluginScript : public Script {
friend class PluginScriptLanguage;
private:
- godot_pluginscript_script_data *_data;
- const godot_pluginscript_script_desc *_desc;
- PluginScriptLanguage *_language;
- bool _tool;
- bool _valid;
+ godot_pluginscript_script_data *_data = nullptr;
+ const godot_pluginscript_script_desc *_desc = nullptr;
+ PluginScriptLanguage *_language = nullptr;
+ bool _tool = false;
+ bool _valid = false;
Ref<Script> _ref_base_parent;
StringName _native_parent;
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
index f7d87595af..a2ff376e31 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
@@ -202,22 +202,7 @@ void VideoStreamPlaybackGDNative::update_texture() {
// ctor and dtor
VideoStreamPlaybackGDNative::VideoStreamPlaybackGDNative() :
- texture(Ref<ImageTexture>(memnew(ImageTexture))),
- playing(false),
- paused(false),
- mix_udata(nullptr),
- mix_callback(nullptr),
- num_channels(-1),
- time(0),
- seek_backward(false),
- mix_rate(0),
- delay_compensation(0),
- pcm(nullptr),
- pcm_write_idx(0),
- samples_decoded(0),
- file(nullptr),
- interface(nullptr),
- data_struct(nullptr) {}
+ texture(Ref<ImageTexture>(memnew(ImageTexture))) {}
VideoStreamPlaybackGDNative::~VideoStreamPlaybackGDNative() {
cleanup();
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h
index 092e10a0f5..f1bae22801 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.h
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.h
@@ -37,13 +37,11 @@
#include "scene/resources/video_stream.h"
struct VideoDecoderGDNative {
- const godot_videodecoder_interface_gdnative *interface;
- String plugin_name;
+ const godot_videodecoder_interface_gdnative *interface = nullptr;
+ String plugin_name = "none";
Vector<String> supported_extensions;
- VideoDecoderGDNative() :
- interface(nullptr),
- plugin_name("none") {}
+ VideoDecoderGDNative() {}
VideoDecoderGDNative(const godot_videodecoder_interface_gdnative *p_interface) :
interface(p_interface),
@@ -111,23 +109,23 @@ class VideoStreamPlaybackGDNative : public VideoStreamPlayback {
GDCLASS(VideoStreamPlaybackGDNative, VideoStreamPlayback);
Ref<ImageTexture> texture;
- bool playing;
- bool paused;
+ bool playing = false;
+ bool paused = false;
Vector2 texture_size;
- void *mix_udata;
- AudioMixCallback mix_callback;
+ void *mix_udata = nullptr;
+ AudioMixCallback mix_callback = nullptr;
- int num_channels;
- float time;
- bool seek_backward;
- int mix_rate;
- double delay_compensation;
+ int num_channels = -1;
+ float time = 0;
+ bool seek_backward = false;
+ int mix_rate = 0;
+ double delay_compensation = 0;
- float *pcm;
- int pcm_write_idx;
- int samples_decoded;
+ float *pcm = nullptr;
+ int pcm_write_idx = 0;
+ int samples_decoded = 0;
void cleanup();
void update_texture();
@@ -135,10 +133,10 @@ class VideoStreamPlaybackGDNative : public VideoStreamPlayback {
protected:
String file_name;
- FileAccess *file;
+ FileAccess *file = nullptr;
- const godot_videodecoder_interface_gdnative *interface;
- void *data_struct;
+ const godot_videodecoder_interface_gdnative *interface = nullptr;
+ void *data_struct = nullptr;
public:
VideoStreamPlaybackGDNative();
@@ -181,7 +179,7 @@ class VideoStreamGDNative : public VideoStream {
GDCLASS(VideoStreamGDNative, VideoStream);
String file;
- int audio_track;
+ int audio_track = 0;
protected:
static void
@@ -194,7 +192,7 @@ public:
virtual void set_audio_track(int p_track);
virtual Ref<VideoStreamPlayback> instance_playback();
- VideoStreamGDNative() { audio_track = 0; }
+ VideoStreamGDNative() {}
};
class ResourceFormatLoaderVideoStreamGDNative : public ResourceFormatLoader {