Skip to content

Commit

Permalink
Merge pull request #38697 from akien-mga/member-init-c++11
Browse files Browse the repository at this point in the history
Port member default initialization from constructor to declaration (C++11)
  • Loading branch information
akien-mga authored May 14, 2020
2 parents e7c9d81 + 1f6f364 commit 5f5f53e
Show file tree
Hide file tree
Showing 325 changed files with 1,708 additions and 3,499 deletions.
42 changes: 42 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,modernize-use-default-member-init'
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-default-member-init.IgnoreMacros
value: '1'
- key: modernize-use-default-member-init.UseAssignment
value: '1'
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...

114 changes: 16 additions & 98 deletions core/bind/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ static const unsigned int MONTH_DAYS_TABLE[2][12] = {
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
};

////// _ResourceLoader //////

_ResourceLoader *_ResourceLoader::singleton = nullptr;

Error _ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads) {
Expand Down Expand Up @@ -150,10 +152,7 @@ void _ResourceLoader::_bind_methods() {
BIND_ENUM_CONSTANT(THREAD_LOAD_LOADED);
}

_ResourceLoader::_ResourceLoader() {

singleton = this;
}
////// _ResourceSaver //////

Error _ResourceSaver::save(const String &p_path, const RES &p_resource, SaverFlags p_flags) {
ERR_FAIL_COND_V_MSG(p_resource.is_null(), ERR_INVALID_PARAMETER, "Can't save empty resource to path '" + String(p_path) + "'.");
Expand Down Expand Up @@ -189,10 +188,7 @@ void _ResourceSaver::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_REPLACE_SUBRESOURCE_PATHS);
}

_ResourceSaver::_ResourceSaver() {

singleton = this;
}
////// _OS //////

PackedStringArray _OS::get_connected_midi_inputs() {
return OS::get_singleton()->get_connected_midi_inputs();
Expand Down Expand Up @@ -319,50 +315,6 @@ bool _OS::has_feature(const String &p_feature) const {
return OS::get_singleton()->has_feature(p_feature);
}

/*
enum Weekday {
DAY_SUNDAY,
DAY_MONDAY,
DAY_TUESDAY,
DAY_WEDNESDAY,
DAY_THURSDAY,
DAY_FRIDAY,
DAY_SATURDAY
};
enum Month {
MONTH_JANUARY,
MONTH_FEBRUARY,
MONTH_MARCH,
MONTH_APRIL,
MONTH_MAY,
MONTH_JUNE,
MONTH_JULY,
MONTH_AUGUST,
MONTH_SEPTEMBER,
MONTH_OCTOBER,
MONTH_NOVEMBER,
MONTH_DECEMBER
};
*/
/*
struct Date {
int year;
Month month;
int day;
Weekday weekday;
bool dst;
};
struct Time {
int hour;
int min;
int sec;
};
*/

uint64_t _OS::get_static_memory_usage() const {

return OS::get_singleton()->get_static_memory_usage();
Expand Down Expand Up @@ -783,6 +735,7 @@ Vector<String> _OS::get_granted_permissions() const {
String _OS::get_unique_id() const {
return OS::get_singleton()->get_unique_id();
}

_OS *_OS::singleton = nullptr;

void _OS::_bind_methods() {
Expand Down Expand Up @@ -839,8 +792,6 @@ void _OS::_bind_methods() {

ClassDB::bind_method(D_METHOD("is_debug_build"), &_OS::is_debug_build);

//ClassDB::bind_method(D_METHOD("get_mouse_button_state"),&_OS::get_mouse_button_state);

ClassDB::bind_method(D_METHOD("dump_memory_to_file", "file"), &_OS::dump_memory_to_file);
ClassDB::bind_method(D_METHOD("dump_resources_to_file", "file"), &_OS::dump_resources_to_file);
ClassDB::bind_method(D_METHOD("print_resources_in_use", "short"), &_OS::print_resources_in_use, DEFVAL(false));
Expand Down Expand Up @@ -914,12 +865,7 @@ void _OS::_bind_methods() {
BIND_ENUM_CONSTANT(SYSTEM_DIR_RINGTONES);
}

_OS::_OS() {

singleton = this;
}

///////////////////// GEOMETRY
////// _Geometry //////

_Geometry *_Geometry::singleton = nullptr;

Expand Down Expand Up @@ -1296,11 +1242,7 @@ void _Geometry::_bind_methods() {
BIND_ENUM_CONSTANT(END_ROUND);
}

_Geometry::_Geometry() {
singleton = this;
}

///////////////////////// FILE
////// _File //////

Error _File::open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key) {

Expand Down Expand Up @@ -1736,19 +1678,12 @@ void _File::_bind_methods() {
BIND_ENUM_CONSTANT(COMPRESSION_GZIP);
}

_File::_File() {

f = nullptr;
eswap = false;
}

_File::~_File() {

if (f)
memdelete(f);
}

///////////////////////////////////////////////////////
////// _Directory //////

Error _Directory::open(const String &p_path) {
Error err;
Expand Down Expand Up @@ -1929,16 +1864,16 @@ void _Directory::_bind_methods() {
}

_Directory::_Directory() {

d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
}

_Directory::~_Directory() {

if (d)
memdelete(d);
}

////// _Marshalls //////

_Marshalls *_Marshalls::singleton = nullptr;

_Marshalls *_Marshalls::get_singleton() {
Expand Down Expand Up @@ -2046,7 +1981,7 @@ void _Marshalls::_bind_methods() {
ClassDB::bind_method(D_METHOD("base64_to_utf8", "base64_str"), &_Marshalls::base64_to_utf8);
};

////////////////
////// _Semaphore //////

void _Semaphore::wait() {

Expand All @@ -2070,7 +2005,7 @@ void _Semaphore::_bind_methods() {
ClassDB::bind_method(D_METHOD("post"), &_Semaphore::post);
}

///////////////
////// _Mutex //////

void _Mutex::lock() {

Expand All @@ -2094,7 +2029,7 @@ void _Mutex::_bind_methods() {
ClassDB::bind_method(D_METHOD("unlock"), &_Mutex::unlock);
}

///////////////
////// _Thread //////

void _Thread::_start_func(void *ud) {

Expand Down Expand Up @@ -2204,19 +2139,12 @@ void _Thread::_bind_methods() {
BIND_ENUM_CONSTANT(PRIORITY_NORMAL);
BIND_ENUM_CONSTANT(PRIORITY_HIGH);
}
_Thread::_Thread() {

active = false;
thread = nullptr;
target_instance = nullptr;
}

_Thread::~_Thread() {

ERR_FAIL_COND_MSG(active, "Reference to a Thread object was lost while the thread is still running...");
}

/////////////////////////////////////
////// _ClassDB //////

PackedStringArray _ClassDB::get_class_list() const {

Expand Down Expand Up @@ -2425,11 +2353,7 @@ void _ClassDB::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_class_enabled", "class"), &_ClassDB::is_class_enabled);
}

_ClassDB::_ClassDB() {
}
_ClassDB::~_ClassDB() {
}
///////////////////////////////
////// _Engine //////

void _Engine::set_iterations_per_second(int p_ips) {

Expand Down Expand Up @@ -2588,9 +2512,7 @@ void _Engine::_bind_methods() {

_Engine *_Engine::singleton = nullptr;

_Engine::_Engine() {
singleton = this;
}
////// _JSON //////

void JSONParseResult::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_error"), &JSONParseResult::get_error);
Expand Down Expand Up @@ -2663,7 +2585,3 @@ Ref<JSONParseResult> _JSON::parse(const String &p_json) {
}

_JSON *_JSON::singleton = nullptr;

_JSON::_JSON() {
singleton = this;
}
Loading

0 comments on commit 5f5f53e

Please sign in to comment.