summaryrefslogtreecommitdiff
path: root/core/bind
diff options
context:
space:
mode:
Diffstat (limited to 'core/bind')
-rw-r--r--core/bind/core_bind.cpp114
-rw-r--r--core/bind/core_bind.h37
2 files changed, 34 insertions, 117 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index e2774deb3c..ed0e7b1018 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -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) {
@@ -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) + "'.");
@@ -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();
@@ -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();
@@ -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() {
@@ -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));
@@ -914,12 +865,7 @@ void _OS::_bind_methods() {
BIND_ENUM_CONSTANT(SYSTEM_DIR_RINGTONES);
}
-_OS::_OS() {
-
- singleton = this;
-}
-
-///////////////////// GEOMETRY
+////// _Geometry //////
_Geometry *_Geometry::singleton = nullptr;
@@ -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) {
@@ -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;
@@ -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() {
@@ -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() {
@@ -2070,7 +2005,7 @@ void _Semaphore::_bind_methods() {
ClassDB::bind_method(D_METHOD("post"), &_Semaphore::post);
}
-///////////////
+////// _Mutex //////
void _Mutex::lock() {
@@ -2094,7 +2029,7 @@ void _Mutex::_bind_methods() {
ClassDB::bind_method(D_METHOD("unlock"), &_Mutex::unlock);
}
-///////////////
+////// _Thread //////
void _Thread::_start_func(void *ud) {
@@ -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 {
@@ -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) {
@@ -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);
@@ -2663,7 +2585,3 @@ Ref<JSONParseResult> _JSON::parse(const String &p_json) {
}
_JSON *_JSON::singleton = nullptr;
-
-_JSON::_JSON() {
- singleton = this;
-}
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index d5f44cdc44..44e573ccbe 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -69,7 +69,7 @@ public:
bool has_cached(const String &p_path);
bool exists(const String &p_path, const String &p_type_hint = "");
- _ResourceLoader();
+ _ResourceLoader() { singleton = this; }
};
VARIANT_ENUM_CAST(_ResourceLoader::ThreadLoadStatus);
@@ -98,7 +98,7 @@ public:
Error save(const String &p_path, const RES &p_resource, SaverFlags p_flags);
Vector<String> get_recognized_extensions(const RES &p_resource);
- _ResourceSaver();
+ _ResourceSaver() { singleton = this; }
};
VARIANT_ENUM_CAST(_ResourceSaver::SaverFlags);
@@ -245,7 +245,7 @@ public:
static _OS *get_singleton() { return singleton; }
- _OS();
+ _OS() { singleton = this; }
};
VARIANT_ENUM_CAST(_OS::VideoDriver);
@@ -327,7 +327,7 @@ public:
Dictionary make_atlas(const Vector<Size2> &p_rects);
- _Geometry();
+ _Geometry() { singleton = this; }
};
VARIANT_ENUM_CAST(_Geometry::PolyBooleanOperation);
@@ -335,10 +335,10 @@ VARIANT_ENUM_CAST(_Geometry::PolyJoinType);
VARIANT_ENUM_CAST(_Geometry::PolyEndType);
class _File : public Reference {
-
GDCLASS(_File, Reference);
- FileAccess *f;
- bool eswap;
+
+ FileAccess *f = nullptr;
+ bool eswap = false;
protected:
static void _bind_methods();
@@ -429,7 +429,7 @@ public:
uint64_t get_modified_time(const String &p_file) const;
- _File();
+ _File() {}
virtual ~_File();
};
@@ -538,10 +538,10 @@ class _Thread : public Reference {
protected:
Variant ret;
Variant userdata;
- volatile bool active;
- Object *target_instance;
+ volatile bool active = false;
+ Object *target_instance = nullptr;
StringName target_method;
- Thread *thread;
+ Thread *thread = nullptr;
static void _bind_methods();
static void _start_func(void *ud);
@@ -559,7 +559,7 @@ public:
bool is_active() const;
Variant wait_to_finish();
- _Thread();
+ _Thread() {}
~_Thread();
};
@@ -600,8 +600,8 @@ public:
bool is_class_enabled(StringName p_class) const;
- _ClassDB();
- ~_ClassDB();
+ _ClassDB() {}
+ ~_ClassDB() {}
};
class _Engine : public Object {
@@ -649,7 +649,7 @@ public:
void set_editor_hint(bool p_enabled);
bool is_editor_hint() const;
- _Engine();
+ _Engine() { singleton = this; }
};
class _JSON;
@@ -661,7 +661,7 @@ class JSONParseResult : public Reference {
Error error;
String error_string;
- int error_line;
+ int error_line = -1;
Variant result;
@@ -681,8 +681,7 @@ public:
void set_result(const Variant &p_result);
Variant get_result() const;
- JSONParseResult() :
- error_line(-1) {}
+ JSONParseResult() {}
};
class _JSON : public Object {
@@ -698,7 +697,7 @@ public:
String print(const Variant &p_value, const String &p_indent = "", bool p_sort_keys = false);
Ref<JSONParseResult> parse(const String &p_json);
- _JSON();
+ _JSON() { singleton = this; }
};
#endif // CORE_BIND_H