summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp56
-rw-r--r--core/class_db.cpp25
-rw-r--r--core/class_db.h26
-rw-r--r--core/compressed_translation.cpp2
-rw-r--r--core/core_string_names.cpp29
-rw-r--r--core/core_string_names.h2
-rw-r--r--core/func_ref.cpp2
-rw-r--r--core/hash_map.h6
-rw-r--r--core/image.cpp12
-rw-r--r--core/input_map.cpp8
-rw-r--r--core/io/config_file.cpp6
-rw-r--r--core/io/file_access_pack.cpp7
-rw-r--r--core/io/http_client.cpp10
-rw-r--r--core/io/packet_peer.cpp10
-rw-r--r--core/io/packet_peer_udp.cpp4
-rw-r--r--core/io/resource_format_binary.cpp6
-rw-r--r--core/io/resource_format_binary.h8
-rw-r--r--core/io/resource_import.h6
-rw-r--r--core/io/resource_loader.cpp2
-rw-r--r--core/io/stream_peer.cpp6
-rw-r--r--core/io/stream_peer_ssl.cpp4
-rw-r--r--core/io/tcp_server.cpp2
-rw-r--r--core/make_binders.py24
-rw-r--r--core/math/bsp_tree.cpp11
-rw-r--r--core/math/math_2d.h30
-rw-r--r--core/math/matrix3.cpp86
-rw-r--r--core/math/matrix3.h9
-rw-r--r--core/math/plane.h17
-rw-r--r--core/math/quat.cpp55
-rw-r--r--core/math/quat.h11
-rw-r--r--core/math/rect3.h6
-rw-r--r--core/math/transform.cpp7
-rw-r--r--core/method_bind.cpp34
-rw-r--r--core/method_bind.h19
-rw-r--r--core/object.cpp150
-rw-r--r--core/object.h26
-rw-r--r--core/os/input.cpp4
-rw-r--r--core/os/input_event.cpp6
-rw-r--r--core/os/main_loop.cpp2
-rw-r--r--core/os/os.h3
-rw-r--r--core/packed_data_container.cpp2
-rw-r--r--core/pair.h6
-rw-r--r--core/project_settings.cpp2
-rw-r--r--core/project_settings.h28
-rw-r--r--core/reference.cpp2
-rw-r--r--core/reference.h18
-rw-r--r--core/resource.cpp4
-rw-r--r--core/script_debugger_remote.cpp38
-rw-r--r--core/script_language.cpp9
-rw-r--r--core/translation.cpp16
-rw-r--r--core/type_info.h203
-rw-r--r--core/undo_redo.cpp4
-rw-r--r--core/variant.h10
-rw-r--r--core/variant_call.cpp6
54 files changed, 726 insertions, 361 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 3e289eeaf3..273ef78669 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -112,8 +112,8 @@ bool _ResourceLoader::has(const String &p_path) {
void _ResourceLoader::_bind_methods() {
- ClassDB::bind_method(D_METHOD("load_interactive:ResourceInteractiveLoader", "path", "type_hint"), &_ResourceLoader::load_interactive, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("load:Resource", "path", "type_hint", "p_no_cache"), &_ResourceLoader::load, DEFVAL(""), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("load_interactive", "path", "type_hint"), &_ResourceLoader::load_interactive, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("load", "path", "type_hint", "p_no_cache"), &_ResourceLoader::load, DEFVAL(""), DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_recognized_extensions_for_type", "type"), &_ResourceLoader::get_recognized_extensions_for_type);
ClassDB::bind_method(D_METHOD("set_abort_on_missing_resources", "abort"), &_ResourceLoader::set_abort_on_missing_resources);
ClassDB::bind_method(D_METHOD("get_dependencies", "path"), &_ResourceLoader::get_dependencies);
@@ -148,8 +148,8 @@ _ResourceSaver *_ResourceSaver::singleton = NULL;
void _ResourceSaver::_bind_methods() {
- ClassDB::bind_method(D_METHOD("save", "path", "resource:Resource", "flags"), &_ResourceSaver::save, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_recognized_extensions", "type:Resource"), &_ResourceSaver::get_recognized_extensions);
+ ClassDB::bind_method(D_METHOD("save", "path", "resource", "flags"), &_ResourceSaver::save, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_recognized_extensions", "type"), &_ResourceSaver::get_recognized_extensions);
BIND_CONSTANT(FLAG_RELATIVE_PATHS);
BIND_CONSTANT(FLAG_BUNDLE_RESOURCES);
@@ -1038,7 +1038,7 @@ void _OS::_bind_methods() {
&_OS::get_unix_time_from_datetime);
ClassDB::bind_method(D_METHOD("get_system_time_secs"), &_OS::get_system_time_secs);
- ClassDB::bind_method(D_METHOD("set_icon", "icon:Image"), &_OS::set_icon);
+ ClassDB::bind_method(D_METHOD("set_icon", "icon"), &_OS::set_icon);
ClassDB::bind_method(D_METHOD("get_exit_code"), &_OS::get_exit_code);
ClassDB::bind_method(D_METHOD("set_exit_code", "code"), &_OS::set_exit_code);
@@ -1750,7 +1750,7 @@ void _File::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_sha256", "path"), &_File::get_sha256);
ClassDB::bind_method(D_METHOD("get_endian_swap"), &_File::get_endian_swap);
ClassDB::bind_method(D_METHOD("set_endian_swap", "enable"), &_File::set_endian_swap);
- ClassDB::bind_method(D_METHOD("get_error:Error"), &_File::get_error);
+ ClassDB::bind_method(D_METHOD("get_error"), &_File::get_error);
ClassDB::bind_method(D_METHOD("get_var"), &_File::get_var);
ClassDB::bind_method(D_METHOD("get_csv_line", "delim"), &_File::get_csv_line, DEFVAL(","));
@@ -1954,7 +1954,7 @@ Error _Directory::remove(String p_name) {
void _Directory::_bind_methods() {
- ClassDB::bind_method(D_METHOD("open:Error", "path"), &_Directory::open);
+ ClassDB::bind_method(D_METHOD("open", "path"), &_Directory::open);
ClassDB::bind_method(D_METHOD("list_dir_begin", "skip_navigational", "skip_hidden"), &_Directory::list_dir_begin, DEFVAL(false), DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_next"), &_Directory::get_next);
ClassDB::bind_method(D_METHOD("current_is_dir"), &_Directory::current_is_dir);
@@ -1962,17 +1962,17 @@ void _Directory::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_drive_count"), &_Directory::get_drive_count);
ClassDB::bind_method(D_METHOD("get_drive", "idx"), &_Directory::get_drive);
ClassDB::bind_method(D_METHOD("get_current_drive"), &_Directory::get_current_drive);
- ClassDB::bind_method(D_METHOD("change_dir:Error", "todir"), &_Directory::change_dir);
+ ClassDB::bind_method(D_METHOD("change_dir", "todir"), &_Directory::change_dir);
ClassDB::bind_method(D_METHOD("get_current_dir"), &_Directory::get_current_dir);
- ClassDB::bind_method(D_METHOD("make_dir:Error", "path"), &_Directory::make_dir);
- ClassDB::bind_method(D_METHOD("make_dir_recursive:Error", "path"), &_Directory::make_dir_recursive);
+ ClassDB::bind_method(D_METHOD("make_dir", "path"), &_Directory::make_dir);
+ ClassDB::bind_method(D_METHOD("make_dir_recursive", "path"), &_Directory::make_dir_recursive);
ClassDB::bind_method(D_METHOD("file_exists", "path"), &_Directory::file_exists);
ClassDB::bind_method(D_METHOD("dir_exists", "path"), &_Directory::dir_exists);
//ClassDB::bind_method(D_METHOD("get_modified_time","file"),&_Directory::get_modified_time);
ClassDB::bind_method(D_METHOD("get_space_left"), &_Directory::get_space_left);
- ClassDB::bind_method(D_METHOD("copy:Error", "from", "to"), &_Directory::copy);
- ClassDB::bind_method(D_METHOD("rename:Error", "from", "to"), &_Directory::rename);
- ClassDB::bind_method(D_METHOD("remove:Error", "path"), &_Directory::remove);
+ ClassDB::bind_method(D_METHOD("copy", "from", "to"), &_Directory::copy);
+ ClassDB::bind_method(D_METHOD("rename", "from", "to"), &_Directory::rename);
+ ClassDB::bind_method(D_METHOD("remove", "path"), &_Directory::remove);
}
_Directory::_Directory() {
@@ -2109,14 +2109,14 @@ String _Marshalls::base64_to_utf8(const String &p_str) {
void _Marshalls::_bind_methods() {
- ClassDB::bind_method(D_METHOD("variant_to_base64:String", "variant"), &_Marshalls::variant_to_base64);
- ClassDB::bind_method(D_METHOD("base64_to_variant:Variant", "base64_str"), &_Marshalls::base64_to_variant);
+ ClassDB::bind_method(D_METHOD("variant_to_base64", "variant"), &_Marshalls::variant_to_base64);
+ ClassDB::bind_method(D_METHOD("base64_to_variant", "base64_str"), &_Marshalls::base64_to_variant);
- ClassDB::bind_method(D_METHOD("raw_to_base64:String", "array"), &_Marshalls::raw_to_base64);
- ClassDB::bind_method(D_METHOD("base64_to_raw:PoolByteArray", "base64_str"), &_Marshalls::base64_to_raw);
+ ClassDB::bind_method(D_METHOD("raw_to_base64", "array"), &_Marshalls::raw_to_base64);
+ ClassDB::bind_method(D_METHOD("base64_to_raw", "base64_str"), &_Marshalls::base64_to_raw);
- ClassDB::bind_method(D_METHOD("utf8_to_base64:String", "utf8_str"), &_Marshalls::utf8_to_base64);
- ClassDB::bind_method(D_METHOD("base64_to_utf8:String", "base64_str"), &_Marshalls::base64_to_utf8);
+ ClassDB::bind_method(D_METHOD("utf8_to_base64", "utf8_str"), &_Marshalls::utf8_to_base64);
+ ClassDB::bind_method(D_METHOD("base64_to_utf8", "base64_str"), &_Marshalls::base64_to_utf8);
};
////////////////
@@ -2133,8 +2133,8 @@ Error _Semaphore::post() {
void _Semaphore::_bind_methods() {
- ClassDB::bind_method(D_METHOD("wait:Error"), &_Semaphore::wait);
- ClassDB::bind_method(D_METHOD("post:Error"), &_Semaphore::post);
+ ClassDB::bind_method(D_METHOD("wait"), &_Semaphore::wait);
+ ClassDB::bind_method(D_METHOD("post"), &_Semaphore::post);
}
_Semaphore::_Semaphore() {
@@ -2167,7 +2167,7 @@ void _Mutex::unlock() {
void _Mutex::_bind_methods() {
ClassDB::bind_method(D_METHOD("lock"), &_Mutex::lock);
- ClassDB::bind_method(D_METHOD("try_lock:Error"), &_Mutex::try_lock);
+ ClassDB::bind_method(D_METHOD("try_lock"), &_Mutex::try_lock);
ClassDB::bind_method(D_METHOD("unlock"), &_Mutex::unlock);
}
@@ -2280,10 +2280,10 @@ Variant _Thread::wait_to_finish() {
void _Thread::_bind_methods() {
- ClassDB::bind_method(D_METHOD("start:Error", "instance", "method", "userdata", "priority"), &_Thread::start, DEFVAL(Variant()), DEFVAL(PRIORITY_NORMAL));
+ ClassDB::bind_method(D_METHOD("start", "instance", "method", "userdata", "priority"), &_Thread::start, DEFVAL(Variant()), DEFVAL(PRIORITY_NORMAL));
ClassDB::bind_method(D_METHOD("get_id"), &_Thread::get_id);
ClassDB::bind_method(D_METHOD("is_active"), &_Thread::is_active);
- ClassDB::bind_method(D_METHOD("wait_to_finish:Variant"), &_Thread::wait_to_finish);
+ ClassDB::bind_method(D_METHOD("wait_to_finish"), &_Thread::wait_to_finish);
BIND_CONSTANT(PRIORITY_LOW);
BIND_CONSTANT(PRIORITY_NORMAL);
@@ -2483,15 +2483,15 @@ void _ClassDB::_bind_methods() {
ClassDB::bind_method(D_METHOD("class_exists", "class"), &_ClassDB::class_exists);
ClassDB::bind_method(D_METHOD("is_parent_class", "class", "inherits"), &_ClassDB::is_parent_class);
ClassDB::bind_method(D_METHOD("can_instance", "class"), &_ClassDB::can_instance);
- ClassDB::bind_method(D_METHOD("instance:Variant", "class"), &_ClassDB::instance);
+ ClassDB::bind_method(D_METHOD("instance", "class"), &_ClassDB::instance);
ClassDB::bind_method(D_METHOD("class_has_signal", "class", "signal"), &_ClassDB::has_signal);
ClassDB::bind_method(D_METHOD("class_get_signal", "class", "signal"), &_ClassDB::get_signal);
ClassDB::bind_method(D_METHOD("class_get_signal_list", "class", "no_inheritance"), &_ClassDB::get_signal_list, DEFVAL(false));
ClassDB::bind_method(D_METHOD("class_get_property_list", "class", "no_inheritance"), &_ClassDB::get_property_list, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("class_get_property:Variant", "object", "property"), &_ClassDB::get_property);
- ClassDB::bind_method(D_METHOD("class_set_property:Error", "object", "property", "value"), &_ClassDB::set_property);
+ ClassDB::bind_method(D_METHOD("class_get_property", "object", "property"), &_ClassDB::get_property);
+ ClassDB::bind_method(D_METHOD("class_set_property", "object", "property", "value"), &_ClassDB::set_property);
ClassDB::bind_method(D_METHOD("class_has_method", "class", "method", "no_inheritance"), &_ClassDB::has_method, DEFVAL(false));
@@ -2583,7 +2583,7 @@ void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_frames_drawn"), &_Engine::get_frames_drawn);
ClassDB::bind_method(D_METHOD("get_frames_per_second"), &_Engine::get_frames_per_second);
- ClassDB::bind_method(D_METHOD("get_main_loop:MainLoop"), &_Engine::get_main_loop);
+ ClassDB::bind_method(D_METHOD("get_main_loop"), &_Engine::get_main_loop);
ClassDB::bind_method(D_METHOD("get_version_info"), &_Engine::get_version_info);
diff --git a/core/class_db.cpp b/core/class_db.cpp
index 24d71f86b0..0503f7c6fc 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -46,9 +46,9 @@
#ifdef DEBUG_METHODS_ENABLED
-ParamDef::ParamDef(const Variant &p_variant) {
- used = true;
- val = p_variant;
+ParamDef::ParamDef(const Variant &p_variant)
+ : used(true),
+ val(p_variant) {
}
MethodDefinition D_METHOD(const char *p_name) {
@@ -1082,12 +1082,6 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const c
StringName mdname = StaticCString::create(method_name);
#endif
- StringName rettype;
- if (mdname.operator String().find(":") != -1) {
- rettype = mdname.operator String().get_slice(":", 1);
- mdname = mdname.operator String().get_slice(":", 0);
- }
-
OBJTYPE_WLOCK;
ERR_FAIL_COND_V(!p_bind, NULL);
p_bind->set_name(mdname);
@@ -1106,7 +1100,7 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const c
if (!type) {
ERR_PRINTS("Couldn't bind method '" + mdname + "' for instance: " + instance_type);
memdelete(p_bind);
- ERR_FAIL_COND_V(!type, NULL);
+ ERR_FAIL_V(NULL);
}
if (type->method_map.has(mdname)) {
@@ -1115,11 +1109,20 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const c
ERR_EXPLAIN("Method already bound: " + instance_type + "::" + mdname);
ERR_FAIL_V(NULL);
}
+
#ifdef DEBUG_METHODS_ENABLED
+
+ if (method_name.args.size() > p_bind->get_argument_count()) {
+ memdelete(p_bind);
+ ERR_EXPLAIN("Method definition provides more arguments than the method actually has: " + instance_type + "::" + mdname);
+ ERR_FAIL_V(NULL);
+ }
+
p_bind->set_argument_names(method_name.args);
- p_bind->set_return_type(rettype);
+
type->method_order.push_back(mdname);
#endif
+
type->method_map[mdname] = p_bind;
Vector<Variant> defvals;
diff --git a/core/class_db.h b/core/class_db.h
index 02eac0dbbc..f73e082c52 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -45,12 +45,11 @@ struct ParamHint {
String hint_text;
Variant default_val;
- ParamHint(const String &p_name = "", PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_text = "", Variant p_default_val = Variant()) {
-
- name = p_name;
- hint = p_hint;
- hint_text = p_hint_text;
- default_val = p_default_val;
+ ParamHint(const String &p_name = "", PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_text = "", Variant p_default_val = Variant())
+ : name(p_name),
+ hint(p_hint),
+ hint_text(p_hint_text),
+ default_val(p_default_val) {
}
};
@@ -73,8 +72,10 @@ struct MethodDefinition {
StringName name;
Vector<StringName> args;
MethodDefinition() {}
- MethodDefinition(const char *p_name) { name = p_name; }
- MethodDefinition(const StringName &p_name) { name = p_name; }
+ MethodDefinition(const char *p_name)
+ : name(p_name) {}
+ MethodDefinition(const StringName &p_name)
+ : name(p_name) {}
};
MethodDefinition D_METHOD(const char *p_name);
@@ -436,12 +437,6 @@ public:
MethodBind *bind = create_vararg_method_bind(p_method, p_info);
ERR_FAIL_COND_V(!bind, NULL);
- String rettype;
- if (p_name.operator String().find(":") != -1) {
- rettype = p_name.operator String().get_slice(":", 1);
- p_name = p_name.operator String().get_slice(":", 0);
- }
-
bind->set_name(p_name);
bind->set_default_arguments(p_default_args);
@@ -461,8 +456,7 @@ public:
}
type->method_map[p_name] = bind;
#ifdef DEBUG_METHODS_ENABLED
- if (!rettype.empty())
- bind->set_return_type(rettype);
+ bind->set_return_type("Variant");
type->method_order.push_back(p_name);
#endif
diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp
index 9bdd960424..172249c5d7 100644
--- a/core/compressed_translation.cpp
+++ b/core/compressed_translation.cpp
@@ -306,7 +306,7 @@ void PHashTranslation::_get_property_list(List<PropertyInfo> *p_list) const {
}
void PHashTranslation::_bind_methods() {
- ClassDB::bind_method(D_METHOD("generate", "from:Translation"), &PHashTranslation::generate);
+ ClassDB::bind_method(D_METHOD("generate", "from"), &PHashTranslation::generate);
}
PHashTranslation::PHashTranslation() {
diff --git a/core/core_string_names.cpp b/core/core_string_names.cpp
index 2adc15447a..2f5a684373 100644
--- a/core/core_string_names.cpp
+++ b/core/core_string_names.cpp
@@ -31,21 +31,20 @@
CoreStringNames *CoreStringNames::singleton = NULL;
-CoreStringNames::CoreStringNames() {
-
- _free = StaticCString::create("free");
- changed = StaticCString::create("changed");
- _meta = StaticCString::create("__meta__");
- _script = StaticCString::create("script");
- script_changed = StaticCString::create("script_changed");
- ___pdcdata = StaticCString::create("___pdcdata");
- __getvar = StaticCString::create("__getvar");
- _iter_init = StaticCString::create("_iter_init");
- _iter_next = StaticCString::create("_iter_next");
- _iter_get = StaticCString::create("_iter_get");
- get_rid = StaticCString::create("get_rid");
- _custom_features = StaticCString::create("_custom_features");
+CoreStringNames::CoreStringNames()
+ : _free(StaticCString::create("free")),
+ changed(StaticCString::create("changed")),
+ _meta(StaticCString::create("__meta__")),
+ _script(StaticCString::create("script")),
+ script_changed(StaticCString::create("script_changed")),
+ ___pdcdata(StaticCString::create("___pdcdata")),
+ __getvar(StaticCString::create("__getvar")),
+ _iter_init(StaticCString::create("_iter_init")),
+ _iter_next(StaticCString::create("_iter_next")),
+ _iter_get(StaticCString::create("_iter_get")),
+ get_rid(StaticCString::create("get_rid")),
#ifdef TOOLS_ENABLED
- _sections_unfolded = StaticCString::create("_sections_unfolded");
+ _sections_unfolded(StaticCString::create("_sections_unfolded")),
#endif
+ _custom_features(StaticCString::create("_custom_features")) {
}
diff --git a/core/core_string_names.h b/core/core_string_names.h
index 501185f5b7..40f76aa9c0 100644
--- a/core/core_string_names.h
+++ b/core/core_string_names.h
@@ -61,10 +61,10 @@ public:
StringName _iter_next;
StringName _iter_get;
StringName get_rid;
- StringName _custom_features;
#ifdef TOOLS_ENABLED
StringName _sections_unfolded;
#endif
+ StringName _custom_features;
};
#endif // SCENE_STRING_NAMES_H
diff --git a/core/func_ref.cpp b/core/func_ref.cpp
index 2d74efd822..5622a03665 100644
--- a/core/func_ref.cpp
+++ b/core/func_ref.cpp
@@ -61,7 +61,7 @@ void FuncRef::_bind_methods() {
MethodInfo mi;
mi.name = "call_func";
Vector<Variant> defargs;
- ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call_func:Variant", &FuncRef::call_func, mi, defargs);
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call_func", &FuncRef::call_func, mi, defargs);
}
ClassDB::bind_method(D_METHOD("set_instance", "instance"), &FuncRef::set_instance);
diff --git a/core/hash_map.h b/core/hash_map.h
index 45e7b82d24..2d7249e2fc 100644
--- a/core/hash_map.h
+++ b/core/hash_map.h
@@ -96,9 +96,9 @@ public:
TData data;
Pair() {}
- Pair(const TKey &p_key, const TData &p_data) {
- key = p_key;
- data = p_data;
+ Pair(const TKey &p_key, const TData &p_data)
+ : key(p_key),
+ data(p_data) {
}
};
diff --git a/core/image.cpp b/core/image.cpp
index 50dc9c109d..2db9cb1571 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -2254,16 +2254,16 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("srgb_to_linear"), &Image::srgb_to_linear);
ClassDB::bind_method(D_METHOD("normalmap_to_xy"), &Image::normalmap_to_xy);
- ClassDB::bind_method(D_METHOD("blit_rect", "src:Image", "src_rect", "dst"), &Image::blit_rect);
- ClassDB::bind_method(D_METHOD("blit_rect_mask", "src:Image", "mask:Image", "src_rect", "dst"), &Image::blit_rect_mask);
- ClassDB::bind_method(D_METHOD("blend_rect", "src:Image", "src_rect", "dst"), &Image::blend_rect);
- ClassDB::bind_method(D_METHOD("blend_rect_mask", "src:Image", "mask:Image", "src_rect", "dst"), &Image::blend_rect_mask);
+ ClassDB::bind_method(D_METHOD("blit_rect", "src", "src_rect", "dst"), &Image::blit_rect);
+ ClassDB::bind_method(D_METHOD("blit_rect_mask", "src", "mask", "src_rect", "dst"), &Image::blit_rect_mask);
+ ClassDB::bind_method(D_METHOD("blend_rect", "src", "src_rect", "dst"), &Image::blend_rect);
+ ClassDB::bind_method(D_METHOD("blend_rect_mask", "src", "mask", "src_rect", "dst"), &Image::blend_rect_mask);
ClassDB::bind_method(D_METHOD("fill", "color"), &Image::fill);
ClassDB::bind_method(D_METHOD("get_used_rect"), &Image::get_used_rect);
- ClassDB::bind_method(D_METHOD("get_rect:Image", "rect"), &Image::get_rect);
+ ClassDB::bind_method(D_METHOD("get_rect", "rect"), &Image::get_rect);
- ClassDB::bind_method(D_METHOD("copy_from", "src:Image"), &Image::copy_internals_from);
+ ClassDB::bind_method(D_METHOD("copy_from", "src"), &Image::copy_internals_from);
ClassDB::bind_method(D_METHOD("_set_data", "data"), &Image::_set_data);
ClassDB::bind_method(D_METHOD("_get_data"), &Image::_get_data);
diff --git a/core/input_map.cpp b/core/input_map.cpp
index 85e627f352..8435882325 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -41,11 +41,11 @@ void InputMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_action", "action"), &InputMap::add_action);
ClassDB::bind_method(D_METHOD("erase_action", "action"), &InputMap::erase_action);
- ClassDB::bind_method(D_METHOD("action_add_event", "action", "event:InputEvent"), &InputMap::action_add_event);
- ClassDB::bind_method(D_METHOD("action_has_event", "action", "event:InputEvent"), &InputMap::action_has_event);
- ClassDB::bind_method(D_METHOD("action_erase_event", "action", "event:InputEvent"), &InputMap::action_erase_event);
+ ClassDB::bind_method(D_METHOD("action_add_event", "action", "event"), &InputMap::action_add_event);
+ ClassDB::bind_method(D_METHOD("action_has_event", "action", "event"), &InputMap::action_has_event);
+ ClassDB::bind_method(D_METHOD("action_erase_event", "action", "event"), &InputMap::action_erase_event);
ClassDB::bind_method(D_METHOD("get_action_list", "action"), &InputMap::_get_action_list);
- ClassDB::bind_method(D_METHOD("event_is_action", "event:InputEvent", "action"), &InputMap::event_is_action);
+ ClassDB::bind_method(D_METHOD("event_is_action", "event", "action"), &InputMap::event_is_action);
ClassDB::bind_method(D_METHOD("load_from_globals"), &InputMap::load_from_globals);
}
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp
index 4067899068..edd090adf2 100644
--- a/core/io/config_file.cpp
+++ b/core/io/config_file.cpp
@@ -205,7 +205,7 @@ Error ConfigFile::load(const String &p_path) {
void ConfigFile::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_value", "section", "key", "value"), &ConfigFile::set_value);
- ClassDB::bind_method(D_METHOD("get_value:Variant", "section", "key", "default"), &ConfigFile::get_value, DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("get_value", "section", "key", "default"), &ConfigFile::get_value, DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("has_section", "section"), &ConfigFile::has_section);
ClassDB::bind_method(D_METHOD("has_section_key", "section", "key"), &ConfigFile::has_section_key);
@@ -215,8 +215,8 @@ void ConfigFile::_bind_methods() {
ClassDB::bind_method(D_METHOD("erase_section", "section"), &ConfigFile::erase_section);
- ClassDB::bind_method(D_METHOD("load:Error", "path"), &ConfigFile::load);
- ClassDB::bind_method(D_METHOD("save:Error", "path"), &ConfigFile::save);
+ ClassDB::bind_method(D_METHOD("load", "path"), &ConfigFile::load);
+ ClassDB::bind_method(D_METHOD("save", "path"), &ConfigFile::save);
}
ConfigFile::ConfigFile() {
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index 79aa39521f..c3bcfc840b 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -308,10 +308,9 @@ bool FileAccessPack::file_exists(const String &p_name) {
return false;
}
-FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file) {
-
- pf = p_file;
- f = FileAccess::open(pf.pack, FileAccess::READ);
+FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file)
+ : pf(p_file),
+ f(FileAccess::open(pf.pack, FileAccess::READ)) {
if (!f) {
ERR_EXPLAIN("Can't open pack-referenced file: " + String(pf.pack));
ERR_FAIL_COND(!f);
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 0c84a5213f..4d5b88cfa1 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -624,9 +624,9 @@ Error HTTPClient::_get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received
void HTTPClient::_bind_methods() {
- ClassDB::bind_method(D_METHOD("connect_to_host:Error", "host", "port", "use_ssl", "verify_host"), &HTTPClient::connect_to_host, DEFVAL(false), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("set_connection", "connection:StreamPeer"), &HTTPClient::set_connection);
- ClassDB::bind_method(D_METHOD("get_connection:StreamPeer"), &HTTPClient::get_connection);
+ ClassDB::bind_method(D_METHOD("connect_to_host", "host", "port", "use_ssl", "verify_host"), &HTTPClient::connect_to_host, DEFVAL(false), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("set_connection", "connection"), &HTTPClient::set_connection);
+ ClassDB::bind_method(D_METHOD("get_connection"), &HTTPClient::get_connection);
ClassDB::bind_method(D_METHOD("request_raw", "method", "url", "headers", "body"), &HTTPClient::request_raw);
ClassDB::bind_method(D_METHOD("request", "method", "url", "headers", "body"), &HTTPClient::request, DEFVAL(String()));
ClassDB::bind_method(D_METHOD("send_body_text", "body"), &HTTPClient::send_body_text);
@@ -646,9 +646,9 @@ void HTTPClient::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_blocking_mode_enabled"), &HTTPClient::is_blocking_mode_enabled);
ClassDB::bind_method(D_METHOD("get_status"), &HTTPClient::get_status);
- ClassDB::bind_method(D_METHOD("poll:Error"), &HTTPClient::poll);
+ ClassDB::bind_method(D_METHOD("poll"), &HTTPClient::poll);
- ClassDB::bind_method(D_METHOD("query_string_from_dict:String", "fields"), &HTTPClient::query_string_from_dict);
+ ClassDB::bind_method(D_METHOD("query_string_from_dict", "fields"), &HTTPClient::query_string_from_dict);
BIND_CONSTANT(METHOD_GET);
BIND_CONSTANT(METHOD_HEAD);
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 40082cc481..c028d7d197 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -120,11 +120,11 @@ Error PacketPeer::_get_packet_error() const {
void PacketPeer::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_var:Variant"), &PacketPeer::_bnd_get_var);
- ClassDB::bind_method(D_METHOD("put_var", "var:Variant"), &PacketPeer::put_var);
+ ClassDB::bind_method(D_METHOD("get_var"), &PacketPeer::_bnd_get_var);
+ ClassDB::bind_method(D_METHOD("put_var", "var"), &PacketPeer::put_var);
ClassDB::bind_method(D_METHOD("get_packet"), &PacketPeer::_get_packet);
- ClassDB::bind_method(D_METHOD("put_packet:Error", "buffer"), &PacketPeer::_put_packet);
- ClassDB::bind_method(D_METHOD("get_packet_error:Error"), &PacketPeer::_get_packet_error);
+ ClassDB::bind_method(D_METHOD("put_packet", "buffer"), &PacketPeer::_put_packet);
+ ClassDB::bind_method(D_METHOD("get_packet_error"), &PacketPeer::_get_packet_error);
ClassDB::bind_method(D_METHOD("get_available_packet_count"), &PacketPeer::get_available_packet_count);
};
@@ -138,7 +138,7 @@ void PacketPeerStream::_set_stream_peer(REF p_peer) {
void PacketPeerStream::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_stream_peer", "peer:StreamPeer"), &PacketPeerStream::_set_stream_peer);
+ ClassDB::bind_method(D_METHOD("set_stream_peer", "peer"), &PacketPeerStream::_set_stream_peer);
ClassDB::bind_method(D_METHOD("set_input_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_input_buffer_max_size);
ClassDB::bind_method(D_METHOD("set_output_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_output_buffer_max_size);
}
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
index 8bc3241cc5..d1729819a8 100644
--- a/core/io/packet_peer_udp.cpp
+++ b/core/io/packet_peer_udp.cpp
@@ -59,9 +59,9 @@ Error PacketPeerUDP::_set_dest_address(const String &p_address, int p_port) {
void PacketPeerUDP::_bind_methods() {
- ClassDB::bind_method(D_METHOD("listen:Error", "port", "bind_address", "recv_buf_size"), &PacketPeerUDP::listen, DEFVAL("*"), DEFVAL(65536));
+ ClassDB::bind_method(D_METHOD("listen", "port", "bind_address", "recv_buf_size"), &PacketPeerUDP::listen, DEFVAL("*"), DEFVAL(65536));
ClassDB::bind_method(D_METHOD("close"), &PacketPeerUDP::close);
- ClassDB::bind_method(D_METHOD("wait:Error"), &PacketPeerUDP::wait);
+ ClassDB::bind_method(D_METHOD("wait"), &PacketPeerUDP::wait);
ClassDB::bind_method(D_METHOD("is_listening"), &PacketPeerUDP::is_listening);
ClassDB::bind_method(D_METHOD("get_packet_ip"), &PacketPeerUDP::_get_packet_ip);
//ClassDB::bind_method(D_METHOD("get_packet_address"),&PacketPeerUDP::_get_packet_address);
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 9aa16ed7e7..fd8928b8a0 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -717,7 +717,7 @@ Error ResourceInteractiveLoaderBinary::poll() {
if (!r) {
error = ERR_FILE_CORRUPT;
memdelete(obj); //bye
- ERR_EXPLAIN(local_path + ":Resoucre type in resource field not a resource, type is: " + obj->get_class());
+ ERR_EXPLAIN(local_path + ":Resource type in resource field not a resource, type is: " + obj->get_class());
ERR_FAIL_COND_V(!r, ERR_FILE_CORRUPT);
}
@@ -901,7 +901,7 @@ void ResourceInteractiveLoaderBinary::open(FileAccess *p_f) {
uint32_t ext_resources_size = f->get_32();
for (uint32_t i = 0; i < ext_resources_size; i++) {
- ExtResoucre er;
+ ExtResource er;
er.type = get_unicode_string();
er.path = get_unicode_string();
external_resources.push_back(er);
@@ -926,7 +926,7 @@ void ResourceInteractiveLoaderBinary::open(FileAccess *p_f) {
for (uint32_t i = 0; i < int_resources_size; i++) {
- IntResoucre ir;
+ IntResource ir;
ir.path = get_unicode_string();
ir.offset = f->get_64();
internal_resources.push_back(ir);
diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h
index 5da5a0fc37..1c66344e3e 100644
--- a/core/io/resource_format_binary.h
+++ b/core/io/resource_format_binary.h
@@ -56,19 +56,19 @@ class ResourceInteractiveLoaderBinary : public ResourceInteractiveLoader {
StringName _get_string();
- struct ExtResoucre {
+ struct ExtResource {
String path;
String type;
};
- Vector<ExtResoucre> external_resources;
+ Vector<ExtResource> external_resources;
- struct IntResoucre {
+ struct IntResource {
String path;
uint64_t offset;
};
- Vector<IntResoucre> internal_resources;
+ Vector<IntResource> internal_resources;
String get_unicode_string();
void _advance_padding(uint32_t p_len);
diff --git a/core/io/resource_import.h b/core/io/resource_import.h
index 9d2a5180dc..d3f98cbc07 100644
--- a/core/io/resource_import.h
+++ b/core/io/resource_import.h
@@ -85,9 +85,9 @@ public:
PropertyInfo option;
Variant default_value;
- ImportOption(const PropertyInfo &p_info, const Variant &p_default) {
- option = p_info;
- default_value = p_default;
+ ImportOption(const PropertyInfo &p_info, const Variant &p_default)
+ : option(p_info),
+ default_value(p_default) {
}
ImportOption() {}
};
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 9b89fa3399..5347cd6ee1 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -84,7 +84,7 @@ void ResourceLoader::get_recognized_extensions_for_type(const String &p_type, Li
void ResourceInteractiveLoader::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_resource:Resource"), &ResourceInteractiveLoader::get_resource);
+ ClassDB::bind_method(D_METHOD("get_resource"), &ResourceInteractiveLoader::get_resource);
ClassDB::bind_method(D_METHOD("poll"), &ResourceInteractiveLoader::poll);
ClassDB::bind_method(D_METHOD("wait"), &ResourceInteractiveLoader::wait);
ClassDB::bind_method(D_METHOD("get_stage"), &ResourceInteractiveLoader::get_stage);
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index 0dbcb3cf56..fdad7c7bdf 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -385,7 +385,7 @@ void StreamPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("put_float", "val"), &StreamPeer::put_float);
ClassDB::bind_method(D_METHOD("put_double", "val"), &StreamPeer::put_double);
ClassDB::bind_method(D_METHOD("put_utf8_string", "val"), &StreamPeer::put_utf8_string);
- ClassDB::bind_method(D_METHOD("put_var", "val:Variant"), &StreamPeer::put_var);
+ ClassDB::bind_method(D_METHOD("put_var", "val"), &StreamPeer::put_var);
ClassDB::bind_method(D_METHOD("get_8"), &StreamPeer::get_8);
ClassDB::bind_method(D_METHOD("get_u8"), &StreamPeer::get_u8);
@@ -399,7 +399,7 @@ void StreamPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_double"), &StreamPeer::get_double);
ClassDB::bind_method(D_METHOD("get_string", "bytes"), &StreamPeer::get_string);
ClassDB::bind_method(D_METHOD("get_utf8_string", "bytes"), &StreamPeer::get_utf8_string);
- ClassDB::bind_method(D_METHOD("get_var:Variant"), &StreamPeer::get_var);
+ ClassDB::bind_method(D_METHOD("get_var"), &StreamPeer::get_var);
}
////////////////////////////////
@@ -412,7 +412,7 @@ void StreamPeerBuffer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_data_array", "data"), &StreamPeerBuffer::set_data_array);
ClassDB::bind_method(D_METHOD("get_data_array"), &StreamPeerBuffer::get_data_array);
ClassDB::bind_method(D_METHOD("clear"), &StreamPeerBuffer::clear);
- ClassDB::bind_method(D_METHOD("duplicate:StreamPeerBuffer"), &StreamPeerBuffer::duplicate);
+ ClassDB::bind_method(D_METHOD("duplicate"), &StreamPeerBuffer::duplicate);
}
Error StreamPeerBuffer::put_data(const uint8_t *p_data, int p_bytes) {
diff --git a/core/io/stream_peer_ssl.cpp b/core/io/stream_peer_ssl.cpp
index 57cffd073a..ef3c264375 100644
--- a/core/io/stream_peer_ssl.cpp
+++ b/core/io/stream_peer_ssl.cpp
@@ -51,8 +51,8 @@ bool StreamPeerSSL::is_available() {
void StreamPeerSSL::_bind_methods() {
- ClassDB::bind_method(D_METHOD("accept_stream:Error", "stream:StreamPeer"), &StreamPeerSSL::accept_stream);
- ClassDB::bind_method(D_METHOD("connect_to_stream:Error", "stream:StreamPeer", "validate_certs", "for_hostname"), &StreamPeerSSL::connect_to_stream, DEFVAL(false), DEFVAL(String()));
+ ClassDB::bind_method(D_METHOD("accept_stream", "stream"), &StreamPeerSSL::accept_stream);
+ ClassDB::bind_method(D_METHOD("connect_to_stream", "stream", "validate_certs", "for_hostname"), &StreamPeerSSL::connect_to_stream, DEFVAL(false), DEFVAL(String()));
ClassDB::bind_method(D_METHOD("get_status"), &StreamPeerSSL::get_status);
ClassDB::bind_method(D_METHOD("disconnect_from_stream"), &StreamPeerSSL::disconnect_from_stream);
BIND_CONSTANT(STATUS_DISCONNECTED);
diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp
index 4c891188ee..29a80ecc19 100644
--- a/core/io/tcp_server.cpp
+++ b/core/io/tcp_server.cpp
@@ -49,7 +49,7 @@ void TCP_Server::_bind_methods() {
ClassDB::bind_method(D_METHOD("listen", "port", "bind_address"), &TCP_Server::listen, DEFVAL("*"));
ClassDB::bind_method(D_METHOD("is_connection_available"), &TCP_Server::is_connection_available);
- ClassDB::bind_method(D_METHOD("take_connection:StreamPeerTCP"), &TCP_Server::take_connection);
+ ClassDB::bind_method(D_METHOD("take_connection"), &TCP_Server::take_connection);
ClassDB::bind_method(D_METHOD("stop"), &TCP_Server::stop);
}
diff --git a/core/make_binders.py b/core/make_binders.py
index 74b5e9fda3..a5cdb78443 100644
--- a/core/make_binders.py
+++ b/core/make_binders.py
@@ -11,11 +11,18 @@ public:
#ifdef DEBUG_METHODS_ENABLED
virtual Variant::Type _gen_argument_type(int p_arg) const { return _get_argument_type(p_arg); }
Variant::Type _get_argument_type(int p_argument) const {
- $ifret if (p_argument==-1) return Variant::get_type_for<R>();$
- $arg if (p_argument==(@-1)) return Variant::get_type_for<P@>();
+ $ifret if (p_argument==-1) return (Variant::Type)GetTypeInfo<R>::VARIANT_TYPE;$
+ $arg if (p_argument==(@-1)) return (Variant::Type)GetTypeInfo<P@>::VARIANT_TYPE;
$
return Variant::NIL;
}
+ virtual StringName _gen_argument_type_name(int p_arg) const { return _gen_argument_type_hint(p_arg); }
+ StringName _gen_argument_type_hint(int p_argument) const {
+ $ifret if (p_argument==-1) return GetTypeInfo<R>::get_class_name();$
+ $arg if (p_argument==(@-1)) return GetTypeInfo<P@>::get_class_name();
+ $
+ return StringName();
+ }
#endif
virtual String get_instance_class() const {
return T::get_class_static();
@@ -91,11 +98,20 @@ public:
virtual Variant::Type _gen_argument_type(int p_arg) const { return _get_argument_type(p_arg); }
Variant::Type _get_argument_type(int p_argument) const {
- $ifret if (p_argument==-1) return Variant::get_type_for<R>();$
- $arg if (p_argument==(@-1)) return Variant::get_type_for<P@>();
+ $ifret if (p_argument==-1) return (Variant::Type)GetTypeInfo<R>::VARIANT_TYPE;$
+ $arg if (p_argument==(@-1)) return (Variant::Type)GetTypeInfo<P@>::VARIANT_TYPE;
$
return Variant::NIL;
}
+
+ virtual StringName _gen_argument_type_name(int p_arg) const { return _gen_argument_type_hint(p_arg); }
+
+ StringName _gen_argument_type_hint(int p_argument) const {
+ $ifret if (p_argument==-1) return GetTypeInfo<R>::get_class_name();$
+ $arg if (p_argument==(@-1)) return GetTypeInfo<P@>::get_class_name();
+ $
+ return StringName();
+ }
#endif
virtual String get_instance_class() const {
return type_name;
diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp
index 327a6017c3..e22bc2b05e 100644
--- a/core/math/bsp_tree.cpp
+++ b/core/math/bsp_tree.cpp
@@ -577,12 +577,11 @@ BSP_Tree::BSP_Tree(const PoolVector<Face3> &p_faces, real_t p_error_radius) {
error_radius = p_error_radius;
}
-BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3 &p_aabb, real_t p_error_radius) {
-
- nodes = p_nodes;
- planes = p_planes;
- aabb = p_aabb;
- error_radius = p_error_radius;
+BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3 &p_aabb, real_t p_error_radius)
+ : nodes(p_nodes),
+ planes(p_planes),
+ aabb(p_aabb),
+ error_radius(p_error_radius) {
}
BSP_Tree::~BSP_Tree() {
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index 780bb532d7..b679371e03 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -378,13 +378,13 @@ struct Rect2 {
operator String() const { return String(position) + ", " + String(size); }
Rect2() {}
- Rect2(real_t p_x, real_t p_y, real_t p_width, real_t p_height) {
- position = Point2(p_x, p_y);
- size = Size2(p_width, p_height);
+ Rect2(real_t p_x, real_t p_y, real_t p_width, real_t p_height)
+ : position(Point2(p_x, p_y)),
+ size(Size2(p_width, p_height)) {
}
- Rect2(const Point2 &p_pos, const Size2 &p_size) {
- position = p_pos;
- size = p_size;
+ Rect2(const Point2 &p_pos, const Size2 &p_size)
+ : position(p_pos),
+ size(p_size) {
}
};
@@ -571,18 +571,18 @@ struct Rect2i {
operator String() const { return String(position) + ", " + String(size); }
operator Rect2() const { return Rect2(position, size); }
- Rect2i(const Rect2 &p_r2) {
- position = p_r2.position;
- size = p_r2.size;
+ Rect2i(const Rect2 &p_r2)
+ : position(p_r2.position),
+ size(p_r2.size) {
}
Rect2i() {}
- Rect2i(int p_x, int p_y, int p_width, int p_height) {
- position = Point2(p_x, p_y);
- size = Size2(p_width, p_height);
+ Rect2i(int p_x, int p_y, int p_width, int p_height)
+ : position(Point2(p_x, p_y)),
+ size(Size2(p_width, p_height)) {
}
- Rect2i(const Point2 &p_pos, const Size2 &p_size) {
- position = p_pos;
- size = p_size;
+ Rect2i(const Point2 &p_pos, const Size2 &p_size)
+ : position(p_pos),
+ size(p_size) {
}
};
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index b64f34d977..f2f6ff93cf 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -338,7 +338,7 @@ void Basis::set_rotation_axis_angle(const Vector3 &p_axis, real_t p_angle) {
rotate(p_axis, p_angle);
}
-// get_euler returns a vector containing the Euler angles in the format
+// get_euler_xyz returns a vector containing the Euler angles in the format
// (a1,a2,a3), where a3 is the angle of the first rotation, and a1 is the last
// (following the convention they are commonly defined in the literature).
//
@@ -348,7 +348,7 @@ void Basis::set_rotation_axis_angle(const Vector3 &p_axis, real_t p_angle) {
// And thus, assuming the matrix is a rotation matrix, this function returns
// the angles in the decomposition R = X(a1).Y(a2).Z(a3) where Z(a) rotates
// around the z-axis by a and so on.
-Vector3 Basis::get_euler() const {
+Vector3 Basis::get_euler_xyz() const {
// Euler angles in XYZ convention.
// See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
@@ -366,6 +366,9 @@ Vector3 Basis::get_euler() const {
if (euler.y > -Math_PI * 0.5) {
//if rotation is Y-only, return a proper -pi,pi range like in x or z for the same case.
if (elements[1][0] == 0.0 && elements[0][1] == 0.0 && elements[0][0] < 0.0) {
+ euler.x = 0;
+ euler.z = 0;
+
if (euler.y > 0.0)
euler.y = Math_PI - euler.y;
else
@@ -389,10 +392,11 @@ Vector3 Basis::get_euler() const {
return euler;
}
-// set_euler expects a vector containing the Euler angles in the format
-// (c,b,a), where a is the angle of the first rotation, and c is the last.
+// set_euler_xyz expects a vector containing the Euler angles in the format
+// (ax,ay,az), where ax is the angle of rotation around x axis,
+// and similar for other axes.
// The current implementation uses XYZ convention (Z is the first rotation).
-void Basis::set_euler(const Vector3 &p_euler) {
+void Basis::set_euler_xyz(const Vector3 &p_euler) {
real_t c, s;
@@ -412,6 +416,78 @@ void Basis::set_euler(const Vector3 &p_euler) {
*this = xmat * (ymat * zmat);
}
+// get_euler_yxz returns a vector containing the Euler angles in the YXZ convention,
+// as in first-Z, then-X, last-Y. The angles for X, Y, and Z rotations are returned
+// as the x, y, and z components of a Vector3 respectively.
+Vector3 Basis::get_euler_yxz() const {
+
+ // Euler angles in YXZ convention.
+ // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
+ //
+ // rot = cy*cz+sy*sx*sz cz*sy*sx-cy*sz cx*sy
+ // cx*sz cx*cz -sx
+ // cy*sx*sz-cz*sy cy*cz*sx+sy*sz cy*cx
+
+ Vector3 euler;
+#ifdef MATH_CHECKS
+ ERR_FAIL_COND_V(is_rotation() == false, euler);
+#endif
+ real_t m12 = elements[1][2];
+
+ if (m12 < 1) {
+ if (m12 > -1) {
+ if (elements[1][0] == 0 && elements[0][1] == 0 && elements[2][2] < 0) { // use pure x rotation
+ real_t x = asin(-m12);
+ euler.y = 0;
+ euler.z = 0;
+
+ if (x > 0.0)
+ euler.x = Math_PI - x;
+ else
+ euler.x = -(Math_PI + x);
+ } else {
+ euler.x = asin(-m12);
+ euler.y = atan2(elements[0][2], elements[2][2]);
+ euler.z = atan2(elements[1][0], elements[1][1]);
+ }
+ } else { // m12 == -1
+ euler.x = Math_PI * 0.5;
+ euler.y = -atan2(-elements[0][1], elements[0][0]);
+ euler.z = 0;
+ }
+ } else { // m12 == 1
+ euler.x = -Math_PI * 0.5;
+ euler.y = -atan2(-elements[0][1], elements[0][0]);
+ euler.z = 0;
+ }
+
+ return euler;
+}
+
+// set_euler_yxz expects a vector containing the Euler angles in the format
+// (ax,ay,az), where ax is the angle of rotation around x axis,
+// and similar for other axes.
+// The current implementation uses YXZ convention (Z is the first rotation).
+void Basis::set_euler_yxz(const Vector3 &p_euler) {
+
+ real_t c, s;
+
+ c = Math::cos(p_euler.x);
+ s = Math::sin(p_euler.x);
+ Basis xmat(1.0, 0.0, 0.0, 0.0, c, -s, 0.0, s, c);
+
+ c = Math::cos(p_euler.y);
+ s = Math::sin(p_euler.y);
+ Basis ymat(c, 0.0, s, 0.0, 1.0, 0.0, -s, 0.0, c);
+
+ c = Math::cos(p_euler.z);
+ s = Math::sin(p_euler.z);
+ Basis zmat(c, -s, 0.0, s, c, 0.0, 0.0, 0.0, 1.0);
+
+ //optimizer will optimize away all this anyway
+ *this = ymat * xmat * zmat;
+}
+
bool Basis::is_equal_approx(const Basis &a, const Basis &b) const {
for (int i = 0; i < 3; i++) {
diff --git a/core/math/matrix3.h b/core/math/matrix3.h
index 8897c692f7..74e6564578 100644
--- a/core/math/matrix3.h
+++ b/core/math/matrix3.h
@@ -84,8 +84,13 @@ public:
void set_rotation_euler(const Vector3 &p_euler);
void set_rotation_axis_angle(const Vector3 &p_axis, real_t p_angle);
- Vector3 get_euler() const;
- void set_euler(const Vector3 &p_euler);
+ Vector3 get_euler_xyz() const;
+ void set_euler_xyz(const Vector3 &p_euler);
+ Vector3 get_euler_yxz() const;
+ void set_euler_yxz(const Vector3 &p_euler);
+
+ Vector3 get_euler() const { return get_euler_yxz(); };
+ void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); };
void get_axis_angle(Vector3 &r_axis, real_t &r_angle) const;
void set_axis_angle(const Vector3 &p_axis, real_t p_phi);
diff --git a/core/math/plane.h b/core/math/plane.h
index 5a048674e4..92ebcd8024 100644
--- a/core/math/plane.h
+++ b/core/math/plane.h
@@ -75,7 +75,8 @@ public:
_FORCE_INLINE_ Plane() { d = 0; }
_FORCE_INLINE_ Plane(real_t p_a, real_t p_b, real_t p_c, real_t p_d)
- : normal(p_a, p_b, p_c), d(p_d){};
+ : normal(p_a, p_b, p_c),
+ d(p_d){};
_FORCE_INLINE_ Plane(const Vector3 &p_normal, real_t p_d);
_FORCE_INLINE_ Plane(const Vector3 &p_point, const Vector3 &p_normal);
@@ -99,16 +100,14 @@ bool Plane::has_point(const Vector3 &p_point, real_t _epsilon) const {
return (dist <= _epsilon);
}
-Plane::Plane(const Vector3 &p_normal, real_t p_d) {
-
- normal = p_normal;
- d = p_d;
+Plane::Plane(const Vector3 &p_normal, real_t p_d)
+ : normal(p_normal),
+ d(p_d) {
}
-Plane::Plane(const Vector3 &p_point, const Vector3 &p_normal) {
-
- normal = p_normal;
- d = p_normal.dot(p_point);
+Plane::Plane(const Vector3 &p_point, const Vector3 &p_normal)
+ : normal(p_normal),
+ d(p_normal.dot(p_point)) {
}
Plane::Plane(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_point3, ClockDirection p_dir) {
diff --git a/core/math/quat.cpp b/core/math/quat.cpp
index 0bea97c2e8..5984cdf657 100644
--- a/core/math/quat.cpp
+++ b/core/math/quat.cpp
@@ -31,10 +31,11 @@
#include "matrix3.h"
#include "print_string.h"
-// set_euler expects a vector containing the Euler angles in the format
-// (c,b,a), where a is the angle of the first rotation, and c is the last.
-// The current implementation uses XYZ convention (Z is the first rotation).
-void Quat::set_euler(const Vector3 &p_euler) {
+// set_euler_xyz expects a vector containing the Euler angles in the format
+// (ax,ay,az), where ax is the angle of rotation around x axis,
+// and similar for other axes.
+// This implementation uses XYZ convention (Z is the first rotation).
+void Quat::set_euler_xyz(const Vector3 &p_euler) {
real_t half_a1 = p_euler.x * 0.5;
real_t half_a2 = p_euler.y * 0.5;
real_t half_a3 = p_euler.z * 0.5;
@@ -56,12 +57,48 @@ void Quat::set_euler(const Vector3 &p_euler) {
-sin_a1 * sin_a2 * sin_a3 + cos_a1 * cos_a2 * cos_a3);
}
-// get_euler returns a vector containing the Euler angles in the format
-// (a1,a2,a3), where a3 is the angle of the first rotation, and a1 is the last.
-// The current implementation uses XYZ convention (Z is the first rotation).
-Vector3 Quat::get_euler() const {
+// get_euler_xyz returns a vector containing the Euler angles in the format
+// (ax,ay,az), where ax is the angle of rotation around x axis,
+// and similar for other axes.
+// This implementation uses XYZ convention (Z is the first rotation).
+Vector3 Quat::get_euler_xyz() const {
Basis m(*this);
- return m.get_euler();
+ return m.get_euler_xyz();
+}
+
+// set_euler_yxz expects a vector containing the Euler angles in the format
+// (ax,ay,az), where ax is the angle of rotation around x axis,
+// and similar for other axes.
+// This implementation uses YXZ convention (Z is the first rotation).
+void Quat::set_euler_yxz(const Vector3 &p_euler) {
+ real_t half_a1 = p_euler.y * 0.5;
+ real_t half_a2 = p_euler.x * 0.5;
+ real_t half_a3 = p_euler.z * 0.5;
+
+ // R = Y(a1).X(a2).Z(a3) convention for Euler angles.
+ // Conversion to quaternion as listed in https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19770024290.pdf (page A-6)
+ // a3 is the angle of the first rotation, following the notation in this reference.
+
+ real_t cos_a1 = Math::cos(half_a1);
+ real_t sin_a1 = Math::sin(half_a1);
+ real_t cos_a2 = Math::cos(half_a2);
+ real_t sin_a2 = Math::sin(half_a2);
+ real_t cos_a3 = Math::cos(half_a3);
+ real_t sin_a3 = Math::sin(half_a3);
+
+ set(sin_a1 * cos_a2 * sin_a3 + cos_a1 * sin_a2 * cos_a3,
+ sin_a1 * cos_a2 * cos_a3 - cos_a1 * sin_a2 * sin_a3,
+ -sin_a1 * sin_a2 * cos_a3 + cos_a1 * sin_a2 * sin_a3,
+ sin_a1 * sin_a2 * sin_a3 + cos_a1 * cos_a2 * cos_a3);
+}
+
+// get_euler_yxz returns a vector containing the Euler angles in the format
+// (ax,ay,az), where ax is the angle of rotation around x axis,
+// and similar for other axes.
+// This implementation uses YXZ convention (Z is the first rotation).
+Vector3 Quat::get_euler_yxz() const {
+ Basis m(*this);
+ return m.get_euler_yxz();
}
void Quat::operator*=(const Quat &q) {
diff --git a/core/math/quat.h b/core/math/quat.h
index f22275b457..0e378eb4e4 100644
--- a/core/math/quat.h
+++ b/core/math/quat.h
@@ -51,8 +51,15 @@ public:
bool is_normalized() const;
Quat inverse() const;
_FORCE_INLINE_ real_t dot(const Quat &q) const;
- void set_euler(const Vector3 &p_euler);
- Vector3 get_euler() const;
+
+ void set_euler_xyz(const Vector3 &p_euler);
+ Vector3 get_euler_xyz() const;
+ void set_euler_yxz(const Vector3 &p_euler);
+ Vector3 get_euler_yxz() const;
+
+ void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); };
+ Vector3 get_euler() const { return get_euler_yxz(); };
+
Quat slerp(const Quat &q, const real_t &t) const;
Quat slerpni(const Quat &q, const real_t &t) const;
Quat cubic_slerp(const Quat &q, const Quat &prep, const Quat &postq, const real_t &t) const;
diff --git a/core/math/rect3.h b/core/math/rect3.h
index b7c94ad9f7..e5d7462009 100644
--- a/core/math/rect3.h
+++ b/core/math/rect3.h
@@ -101,9 +101,9 @@ public:
operator String() const;
_FORCE_INLINE_ Rect3() {}
- inline Rect3(const Vector3 &p_pos, const Vector3 &p_size) {
- position = p_pos;
- size = p_size;
+ inline Rect3(const Vector3 &p_pos, const Vector3 &p_size)
+ : position(p_pos),
+ size(p_size) {
}
};
diff --git a/core/math/transform.cpp b/core/math/transform.cpp
index 7a50214596..3a86fbfc6c 100644
--- a/core/math/transform.cpp
+++ b/core/math/transform.cpp
@@ -208,8 +208,7 @@ Transform::operator String() const {
return basis.operator String() + " - " + origin.operator String();
}
-Transform::Transform(const Basis &p_basis, const Vector3 &p_origin) {
-
- basis = p_basis;
- origin = p_origin;
+Transform::Transform(const Basis &p_basis, const Vector3 &p_origin)
+ : basis(p_basis),
+ origin(p_origin) {
}
diff --git a/core/method_bind.cpp b/core/method_bind.cpp
index 51c0e72bc7..6792b62703 100644
--- a/core/method_bind.cpp
+++ b/core/method_bind.cpp
@@ -38,12 +38,16 @@ PropertyInfo MethodBind::get_argument_info(int p_argument) const {
if (p_argument >= 0) {
- String name = (p_argument < arg_names.size()) ? String(arg_names[p_argument]) : String("arg" + itos(p_argument));
+ String name = p_argument < arg_names.size() ? String(arg_names[p_argument]) : String("arg" + itos(p_argument));
PropertyInfo pi(get_argument_type(p_argument), name);
- if ((pi.type == Variant::OBJECT) && name.find(":") != -1) {
- pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
- pi.hint_string = name.get_slicec(':', 1);
- pi.name = name.get_slicec(':', 0);
+
+ if (!is_vararg() && pi.type == Variant::OBJECT) {
+ StringName type_hint = arg_type_hints[p_argument];
+
+ if (type_hint != StringName()) {
+ pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
+ pi.hint_string = type_hint.operator String();
+ }
}
return pi;
@@ -87,6 +91,16 @@ Vector<StringName> MethodBind::get_argument_names() const {
return arg_names;
}
+void MethodBind::set_argument_type_hints(const Vector<StringName> &p_type_hints) {
+
+ arg_type_hints = p_type_hints;
+}
+
+Vector<StringName> MethodBind::get_argument_type_hints() const {
+
+ return arg_type_hints;
+}
+
#endif
void MethodBind::set_default_arguments(const Vector<Variant> &p_defargs) {
@@ -98,11 +112,19 @@ void MethodBind::set_default_arguments(const Vector<Variant> &p_defargs) {
void MethodBind::_generate_argument_types(int p_count) {
set_argument_count(p_count);
+
Variant::Type *argt = memnew_arr(Variant::Type, p_count + 1);
- argt[0] = _gen_argument_type(-1);
+
+ arg_type_hints.resize(p_count);
+
+ argt[0] = _gen_argument_type(-1); // return type
+ set_return_type(_gen_argument_type_hint(-1));
+
for (int i = 0; i < p_count; i++) {
argt[i + 1] = _gen_argument_type(i);
+ arg_type_hints[i] = _gen_argument_type_hint(i);
}
+
set_argument_types(argt);
}
diff --git a/core/method_bind.h b/core/method_bind.h
index dbc9cca082..3b4ff96a19 100644
--- a/core/method_bind.h
+++ b/core/method_bind.h
@@ -44,6 +44,8 @@
#define DEBUG_METHODS_ENABLED
#endif
+#include "type_info.h"
+
enum MethodFlags {
METHOD_FLAG_NORMAL = 1,
@@ -87,12 +89,10 @@ struct VariantCaster<const T &> {
#define _VC(m_idx) \
(VariantCaster<P##m_idx>::cast((m_idx - 1) >= p_arg_count ? get_default_argument(m_idx - 1) : *p_args[m_idx - 1]))
-//SIMPLE_NUMERIC_TYPE is used to avoid a warning on Variant::get_type_for
-
#ifdef PTRCALL_ENABLED
#define VARIANT_ENUM_CAST(m_enum) \
- SIMPLE_NUMERIC_TYPE(m_enum); \
+ MAKE_ENUM_TYPE_INFO(m_enum) \
template <> \
struct VariantCaster<m_enum> { \
\
@@ -113,7 +113,7 @@ struct VariantCaster<const T &> {
#else
#define VARIANT_ENUM_CAST(m_enum) \
- SIMPLE_NUMERIC_TYPE(m_enum); \
+ MAKE_ENUM_TYPE_INFO(m_enum) \
template <> \
struct VariantCaster<m_enum> { \
\
@@ -165,6 +165,7 @@ class MethodBind {
int argument_count;
#ifdef DEBUG_METHODS_ENABLED
Vector<StringName> arg_names;
+ Vector<StringName> arg_type_hints;
Variant::Type *argument_types;
StringName ret_type;
#endif
@@ -176,6 +177,7 @@ protected:
void _set_returns(bool p_returns);
#ifdef DEBUG_METHODS_ENABLED
virtual Variant::Type _gen_argument_type(int p_arg) const = 0;
+ virtual StringName _gen_argument_type_hint(int p_arg) const = 0;
void _generate_argument_types(int p_count);
void set_argument_types(Variant::Type *p_types) { argument_types = p_types; }
#endif
@@ -220,6 +222,9 @@ public:
void set_argument_names(const Vector<StringName> &p_names);
Vector<StringName> get_argument_names() const;
+
+ void set_argument_type_hints(const Vector<StringName> &p_type_hints);
+ Vector<StringName> get_argument_type_hints() const;
#endif
void set_hint_flags(uint32_t p_hint) { hint_flags = p_hint; }
uint32_t get_hint_flags() const { return hint_flags | (is_const() ? METHOD_FLAG_CONST : 0) | (is_vararg() ? METHOD_FLAG_VARARG : 0); }
@@ -282,11 +287,17 @@ public:
return Variant::NIL;
}
+ virtual StringName _gen_argument_type_hint(int p_arg) const {
+
+ return "Variant";
+ }
+
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Variant::CallError &r_error) {
T *instance = static_cast<T *>(p_object);
return (instance->*call_method)(p_args, p_arg_count, r_error);
}
+
void set_method_info(const MethodInfo &p_info) {
set_argument_count(p_info.arguments.size());
diff --git a/core/object.cpp b/core/object.cpp
index de75257ede..62b2b5d545 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -122,10 +122,9 @@ MethodInfo::operator Dictionary() const {
return d;
}
-MethodInfo::MethodInfo() {
-
- id = 0;
- flags = METHOD_FLAG_NORMAL;
+MethodInfo::MethodInfo()
+ : flags(METHOD_FLAG_NORMAL),
+ id(0) {
}
MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) {
@@ -161,125 +160,114 @@ MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) {
return mi;
}
-MethodInfo::MethodInfo(const String &p_name) {
-
- id = 0;
- name = p_name;
- flags = METHOD_FLAG_NORMAL;
+MethodInfo::MethodInfo(const String &p_name)
+ : name(p_name),
+ flags(METHOD_FLAG_NORMAL),
+ id(0) {
}
-MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1) {
-
- id = 0;
- name = p_name;
+MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1)
+ : name(p_name),
+ flags(METHOD_FLAG_NORMAL),
+ id(0) {
arguments.push_back(p_param1);
- flags = METHOD_FLAG_NORMAL;
}
-MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) {
-
- id = 0;
- name = p_name;
+MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2)
+ : name(p_name),
+ flags(METHOD_FLAG_NORMAL),
+ id(0) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
- flags = METHOD_FLAG_NORMAL;
}
-MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) {
-
- id = 0;
- name = p_name;
+MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3)
+ : name(p_name),
+ flags(METHOD_FLAG_NORMAL),
+ id(0) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
- flags = METHOD_FLAG_NORMAL;
}
-MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) {
-
- id = 0;
- name = p_name;
+MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4)
+ : name(p_name),
+ flags(METHOD_FLAG_NORMAL),
+ id(0) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
arguments.push_back(p_param4);
- flags = METHOD_FLAG_NORMAL;
}
-MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) {
- id = 0;
- name = p_name;
+MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5)
+ : name(p_name),
+ flags(METHOD_FLAG_NORMAL),
+ id(0) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
arguments.push_back(p_param4);
arguments.push_back(p_param5);
- flags = METHOD_FLAG_NORMAL;
}
-MethodInfo::MethodInfo(Variant::Type ret) {
-
- id = 0;
- flags = METHOD_FLAG_NORMAL;
+MethodInfo::MethodInfo(Variant::Type ret)
+ : flags(METHOD_FLAG_NORMAL),
+ id(0) {
return_val.type = ret;
}
-MethodInfo::MethodInfo(Variant::Type ret, const String &p_name) {
-
- id = 0;
- name = p_name;
- flags = METHOD_FLAG_NORMAL;
+MethodInfo::MethodInfo(Variant::Type ret, const String &p_name)
+ : name(p_name),
+ flags(METHOD_FLAG_NORMAL),
+ id(0) {
return_val.type = ret;
}
-MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1) {
-
- id = 0;
- name = p_name;
- arguments.push_back(p_param1);
- flags = METHOD_FLAG_NORMAL;
+MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1)
+ : name(p_name),
+ flags(METHOD_FLAG_NORMAL),
+ id(0) {
return_val.type = ret;
+ arguments.push_back(p_param1);
}
-MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) {
-
- id = 0;
- name = p_name;
+MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2)
+ : name(p_name),
+ flags(METHOD_FLAG_NORMAL),
+ id(0) {
+ return_val.type = ret;
arguments.push_back(p_param1);
arguments.push_back(p_param2);
- flags = METHOD_FLAG_NORMAL;
- return_val.type = ret;
}
-MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) {
-
- id = 0;
- name = p_name;
+MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3)
+ : name(p_name),
+ flags(METHOD_FLAG_NORMAL),
+ id(0) {
+ return_val.type = ret;
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
- flags = METHOD_FLAG_NORMAL;
- return_val.type = ret;
}
-MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) {
-
- id = 0;
- name = p_name;
+MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4)
+ : name(p_name),
+ flags(METHOD_FLAG_NORMAL),
+ id(0) {
+ return_val.type = ret;
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
arguments.push_back(p_param4);
- flags = METHOD_FLAG_NORMAL;
- return_val.type = ret;
}
-MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) {
- id = 0;
- name = p_name;
+MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5)
+ : name(p_name),
+ flags(METHOD_FLAG_NORMAL),
+ id(0) {
+ return_val.type = ret;
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
arguments.push_back(p_param4);
arguments.push_back(p_param5);
- flags = METHOD_FLAG_NORMAL;
- return_val.type = ret;
}
Object::Connection::operator Variant() const {
@@ -1663,17 +1651,17 @@ void Object::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_class"), &Object::get_class);
ClassDB::bind_method(D_METHOD("is_class", "type"), &Object::is_class);
ClassDB::bind_method(D_METHOD("set", "property", "value"), &Object::_set_bind);
- ClassDB::bind_method(D_METHOD("get:Variant", "property"), &Object::_get_bind);
+ ClassDB::bind_method(D_METHOD("get", "property"), &Object::_get_bind);
ClassDB::bind_method(D_METHOD("get_property_list"), &Object::_get_property_list_bind);
ClassDB::bind_method(D_METHOD("get_method_list"), &Object::_get_method_list_bind);
ClassDB::bind_method(D_METHOD("notification", "what", "reversed"), &Object::notification, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_instance_id"), &Object::get_instance_id);
- ClassDB::bind_method(D_METHOD("set_script", "script:Script"), &Object::set_script);
- ClassDB::bind_method(D_METHOD("get_script:Script"), &Object::get_script);
+ ClassDB::bind_method(D_METHOD("set_script", "script"), &Object::set_script);
+ ClassDB::bind_method(D_METHOD("get_script"), &Object::get_script);
ClassDB::bind_method(D_METHOD("set_meta", "name", "value"), &Object::set_meta);
- ClassDB::bind_method(D_METHOD("get_meta:Variant", "name", "value"), &Object::get_meta);
+ ClassDB::bind_method(D_METHOD("get_meta", "name"), &Object::get_meta);
ClassDB::bind_method(D_METHOD("has_meta", "name"), &Object::has_meta);
ClassDB::bind_method(D_METHOD("get_meta_list"), &Object::_get_meta_list_bind);
@@ -1699,7 +1687,7 @@ void Object::_bind_methods() {
mi.name = "call";
mi.arguments.push_back(PropertyInfo(Variant::STRING, "method"));
- ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call:Variant", &Object::_call_bind, mi);
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call", &Object::_call_bind, mi);
}
{
@@ -1710,7 +1698,7 @@ void Object::_bind_methods() {
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call_deferred", &Object::_call_deferred_bind, mi);
}
- ClassDB::bind_method(D_METHOD("callv:Variant", "method", "arg_array"), &Object::callv);
+ ClassDB::bind_method(D_METHOD("callv", "method", "arg_array"), &Object::callv);
ClassDB::bind_method(D_METHOD("has_method", "method"), &Object::has_method);
@@ -1718,9 +1706,9 @@ void Object::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_signal_connection_list", "signal"), &Object::_get_signal_connection_list);
ClassDB::bind_method(D_METHOD("get_incoming_connections"), &Object::_get_incoming_connections);
- ClassDB::bind_method(D_METHOD("connect", "signal", "target:Object", "method", "binds", "flags"), &Object::connect, DEFVAL(Array()), DEFVAL(0));
- ClassDB::bind_method(D_METHOD("disconnect", "signal", "target:Object", "method"), &Object::disconnect);
- ClassDB::bind_method(D_METHOD("is_connected", "signal", "target:Object", "method"), &Object::is_connected);
+ ClassDB::bind_method(D_METHOD("connect", "signal", "target", "method", "binds", "flags"), &Object::connect, DEFVAL(Array()), DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("disconnect", "signal", "target", "method"), &Object::disconnect);
+ ClassDB::bind_method(D_METHOD("is_connected", "signal", "target", "method"), &Object::is_connected);
ClassDB::bind_method(D_METHOD("set_block_signals", "enable"), &Object::set_block_signals);
ClassDB::bind_method(D_METHOD("is_blocking_signals"), &Object::is_blocking_signals);
@@ -1738,7 +1726,7 @@ void Object::_bind_methods() {
ADD_SIGNAL(MethodInfo("script_changed"));
BIND_VMETHOD(MethodInfo("_notification", PropertyInfo(Variant::INT, "what")));
- BIND_VMETHOD(MethodInfo("_set", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value")));
+ BIND_VMETHOD(MethodInfo("_set:bool", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value")));
#ifdef TOOLS_ENABLED
MethodInfo miget("_get", PropertyInfo(Variant::STRING, "property"));
miget.return_val.name = "Variant";
diff --git a/core/object.h b/core/object.h
index f0147080b4..551c3c31b9 100644
--- a/core/object.h
+++ b/core/object.h
@@ -139,17 +139,17 @@ struct PropertyInfo {
static PropertyInfo from_dict(const Dictionary &p_dict);
- PropertyInfo() {
- type = Variant::NIL;
- hint = PROPERTY_HINT_NONE;
- usage = PROPERTY_USAGE_DEFAULT;
+ PropertyInfo()
+ : type(Variant::NIL),
+ hint(PROPERTY_HINT_NONE),
+ usage(PROPERTY_USAGE_DEFAULT) {
}
- PropertyInfo(Variant::Type p_type, const String p_name, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = "", uint32_t p_usage = PROPERTY_USAGE_DEFAULT) {
- type = p_type;
- name = p_name;
- hint = p_hint;
- hint_string = p_hint_string;
- usage = p_usage;
+ PropertyInfo(Variant::Type p_type, const String p_name, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = "", uint32_t p_usage = PROPERTY_USAGE_DEFAULT)
+ : type(p_type),
+ name(p_name),
+ hint(p_hint),
+ hint_string(p_hint_string),
+ usage(p_usage) {
}
bool operator<(const PropertyInfo &p_info) const {
return name < p_info.name;
@@ -401,9 +401,9 @@ private:
_FORCE_INLINE_ bool operator<(const Target &p_target) const { return (_id == p_target._id) ? (method < p_target.method) : (_id < p_target._id); }
- Target(const ObjectID &p_id, const StringName &p_method) {
- _id = p_id;
- method = p_method;
+ Target(const ObjectID &p_id, const StringName &p_method)
+ : _id(p_id),
+ method(p_method) {
}
Target() { _id = 0; }
};
diff --git a/core/os/input.cpp b/core/os/input.cpp
index a90a552d1d..c7b32b939a 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -83,8 +83,8 @@ void Input::_bind_methods() {
ClassDB::bind_method(D_METHOD("warp_mouse_pos", "to"), &Input::warp_mouse_pos);
ClassDB::bind_method(D_METHOD("action_press", "action"), &Input::action_press);
ClassDB::bind_method(D_METHOD("action_release", "action"), &Input::action_release);
- ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor", "image:Texture", "hotspot"), &Input::set_custom_mouse_cursor, DEFVAL(Vector2()));
- ClassDB::bind_method(D_METHOD("parse_input_event", "event:InputEvent"), &Input::parse_input_event);
+ ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor", "image", "hotspot"), &Input::set_custom_mouse_cursor, DEFVAL(Vector2()));
+ ClassDB::bind_method(D_METHOD("parse_input_event", "event"), &Input::parse_input_event);
BIND_CONSTANT(MOUSE_MODE_VISIBLE);
BIND_CONSTANT(MOUSE_MODE_HIDDEN);
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 0a07b6b2b7..fe0e2c2524 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -134,12 +134,12 @@ void InputEvent::_bind_methods() {
ClassDB::bind_method(D_METHOD("as_text"), &InputEvent::as_text);
- ClassDB::bind_method(D_METHOD("action_match", "event:InputEvent"), &InputEvent::action_match);
- ClassDB::bind_method(D_METHOD("shortcut_match", "event:InputEvent"), &InputEvent::shortcut_match);
+ ClassDB::bind_method(D_METHOD("action_match", "event"), &InputEvent::action_match);
+ ClassDB::bind_method(D_METHOD("shortcut_match", "event"), &InputEvent::shortcut_match);
ClassDB::bind_method(D_METHOD("is_action_type"), &InputEvent::is_action_type);
- ClassDB::bind_method(D_METHOD("xformed_by:InputEvent", "xform", "local_ofs"), &InputEvent::xformed_by, DEFVAL(Vector2()));
+ ClassDB::bind_method(D_METHOD("xformed_by", "xform", "local_ofs"), &InputEvent::xformed_by, DEFVAL(Vector2()));
ADD_PROPERTY(PropertyInfo(Variant::INT, "device"), "set_device", "get_device");
}
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 93658c07c2..248f5537c6 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -32,7 +32,7 @@
void MainLoop::_bind_methods() {
- ClassDB::bind_method(D_METHOD("input_event", "ev:InputEvent"), &MainLoop::input_event);
+ ClassDB::bind_method(D_METHOD("input_event", "ev"), &MainLoop::input_event);
ClassDB::bind_method(D_METHOD("input_text", "text"), &MainLoop::input_text);
ClassDB::bind_method(D_METHOD("init"), &MainLoop::init);
ClassDB::bind_method(D_METHOD("iteration", "delta"), &MainLoop::iteration);
diff --git a/core/os/os.h b/core/os/os.h
index 8e2257a0e4..4d64e4a9f0 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -63,6 +63,8 @@ class OS {
void *_stack_bottom;
public:
+ typedef void (*ImeCallback)(void *p_inp, String p_text, Point2 p_selection);
+
enum RenderThreadMode {
RENDER_THREAD_UNSAFE,
@@ -183,6 +185,7 @@ public:
virtual bool get_borderless_window() { return 0; }
virtual void set_ime_position(const Point2 &p_pos) {}
+ virtual void set_ime_intermediate_text_callback(ImeCallback p_callback, void *p_inp) {}
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle) { return ERR_UNAVAILABLE; }
virtual Error close_dynamic_library(void *p_library_handle) { return ERR_UNAVAILABLE; }
diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp
index 0565d0d3f5..eb4aeb758a 100644
--- a/core/packed_data_container.cpp
+++ b/core/packed_data_container.cpp
@@ -368,7 +368,7 @@ void PackedDataContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("_iter_init"), &PackedDataContainer::_iter_init);
ClassDB::bind_method(D_METHOD("_iter_get"), &PackedDataContainer::_iter_get);
ClassDB::bind_method(D_METHOD("_iter_next"), &PackedDataContainer::_iter_next);
- ClassDB::bind_method(D_METHOD("pack:Error", "value"), &PackedDataContainer::pack);
+ ClassDB::bind_method(D_METHOD("pack", "value"), &PackedDataContainer::pack);
ClassDB::bind_method(D_METHOD("size"), &PackedDataContainer::size);
ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "__data__"), "_set_data", "_get_data");
diff --git a/core/pair.h b/core/pair.h
index 761caf7791..d4b1897537 100644
--- a/core/pair.h
+++ b/core/pair.h
@@ -37,9 +37,9 @@ struct Pair {
S second;
Pair() {}
- Pair(F p_first, S p_second) {
- first = p_first;
- second = p_second;
+ Pair(F p_first, S p_second)
+ : first(p_first),
+ second(p_second) {
}
};
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index f6e0d2e991..4a1b35ea4a 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -900,7 +900,7 @@ void ProjectSettings::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_singleton", "name"), &ProjectSettings::get_singleton_object);
ClassDB::bind_method(D_METHOD("load_resource_pack", "pack"), &ProjectSettings::_load_resource_pack);
ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &ProjectSettings::property_can_revert);
- ClassDB::bind_method(D_METHOD("property_get_revert:Variant", "name"), &ProjectSettings::property_get_revert);
+ ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &ProjectSettings::property_get_revert);
ClassDB::bind_method(D_METHOD("save_custom", "file"), &ProjectSettings::_save_custom_bnd);
}
diff --git a/core/project_settings.h b/core/project_settings.h
index c58ac3ca49..c64bb393d1 100644
--- a/core/project_settings.h
+++ b/core/project_settings.h
@@ -48,9 +48,9 @@ public:
struct Singleton {
StringName name;
Object *ptr;
- Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL) {
- name = p_name;
- ptr = p_ptr;
+ Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL)
+ : name(p_name),
+ ptr(p_ptr) {
}
};
enum {
@@ -66,18 +66,18 @@ protected:
Variant initial;
bool hide_from_editor;
bool overrided;
- VariantContainer() {
- order = 0;
- hide_from_editor = false;
- persist = false;
- overrided = false;
+ VariantContainer()
+ : order(0),
+ persist(false),
+ hide_from_editor(false),
+ overrided(false) {
}
- VariantContainer(const Variant &p_variant, int p_order, bool p_persist = false) {
- variant = p_variant;
- order = p_order;
- hide_from_editor = false;
- persist = p_persist;
- overrided = false;
+ VariantContainer(const Variant &p_variant, int p_order, bool p_persist = false)
+ : order(p_order),
+ persist(p_persist),
+ variant(p_variant),
+ hide_from_editor(false),
+ overrided(false) {
}
};
diff --git a/core/reference.cpp b/core/reference.cpp
index 066dc8059e..e9629ee7c0 100644
--- a/core/reference.cpp
+++ b/core/reference.cpp
@@ -122,7 +122,7 @@ WeakRef::WeakRef() {
void WeakRef::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_ref:Object"), &WeakRef::get_ref);
+ ClassDB::bind_method(D_METHOD("get_ref"), &WeakRef::get_ref);
}
#if 0
diff --git a/core/reference.h b/core/reference.h
index 90f2791f4b..7f48f8323e 100644
--- a/core/reference.h
+++ b/core/reference.h
@@ -374,5 +374,23 @@ struct PtrToArg<const RefPtr &> {
}
};
+template <class T>
+struct GetTypeInfo<Ref<T> > {
+ enum { VARIANT_TYPE = Variant::OBJECT };
+
+ static inline StringName get_class_name() {
+ return T::get_class_static();
+ }
+};
+
+template <class T>
+struct GetTypeInfo<const Ref<T> &> {
+ enum { VARIANT_TYPE = Variant::OBJECT };
+
+ static inline StringName get_class_name() {
+ return T::get_class_static();
+ }
+};
+
#endif
#endif // REFERENCE_H
diff --git a/core/resource.cpp b/core/resource.cpp
index 9bce343cba..a0b0fd24e1 100644
--- a/core/resource.cpp
+++ b/core/resource.cpp
@@ -337,10 +337,10 @@ void Resource::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rid"), &Resource::get_rid);
ClassDB::bind_method(D_METHOD("set_local_to_scene", "enable"), &Resource::set_local_to_scene);
ClassDB::bind_method(D_METHOD("is_local_to_scene"), &Resource::is_local_to_scene);
- ClassDB::bind_method(D_METHOD("get_local_scene:Node"), &Resource::get_local_scene);
+ ClassDB::bind_method(D_METHOD("get_local_scene"), &Resource::get_local_scene);
ClassDB::bind_method(D_METHOD("setup_local_to_scene"), &Resource::setup_local_to_scene);
- ClassDB::bind_method(D_METHOD("duplicate:Resource", "subresources"), &Resource::duplicate, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("duplicate", "subresources"), &Resource::duplicate, DEFVAL(false));
ADD_SIGNAL(MethodInfo("changed"));
ADD_GROUP("Resource", "resource_");
ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "resource_local_to_scene"), "set_local_to_scene", "is_local_to_scene");
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 6f12338f66..3628f2ecaf 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -940,29 +940,32 @@ void ScriptDebuggerRemote::profiling_set_frame_times(float p_frame_time, float p
ScriptDebuggerRemote::ResourceUsageFunc ScriptDebuggerRemote::resource_usage_func = NULL;
-ScriptDebuggerRemote::ScriptDebuggerRemote() {
+ScriptDebuggerRemote::ScriptDebuggerRemote()
+ : profiling(false),
+ max_frame_functions(16),
+ skip_profile_frame(false),
+ reload_all_scripts(false),
+ tcp_client(StreamPeerTCP::create_ref()),
+ packet_peer_stream(Ref<PacketPeerStream>(memnew(PacketPeerStream))),
+ last_perf_time(0),
+ performance(ProjectSettings::get_singleton()->get_singleton_object("Performance")),
+ requested_quit(false),
+ mutex(Mutex::create()),
+ max_cps(GLOBAL_GET("network/limits/debugger_stdout/max_chars_per_second")),
+ char_count(0),
+ last_msec(0),
+ msec_count(0),
+ locking(false),
+ poll_every(0),
+ request_scene_tree(NULL),
+ live_edit_funcs(NULL) {
- tcp_client = StreamPeerTCP::create_ref();
- packet_peer_stream = Ref<PacketPeerStream>(memnew(PacketPeerStream));
packet_peer_stream->set_stream_peer(tcp_client);
packet_peer_stream->set_output_buffer_max_size(1024 * 1024 * 8); //8mb should be way more than enough
- mutex = Mutex::create();
- locking = false;
phl.printfunc = _print_handler;
phl.userdata = this;
add_print_handler(&phl);
- requested_quit = false;
- performance = ProjectSettings::get_singleton()->get_singleton_object("Performance");
- last_perf_time = 0;
- poll_every = 0;
- request_scene_tree = NULL;
- live_edit_funcs = NULL;
- max_cps = GLOBAL_GET("network/limits/debugger_stdout/max_chars_per_second");
- char_count = 0;
- msec_count = 0;
- last_msec = 0;
- skip_profile_frame = false;
eh.errfunc = _err_handler;
eh.userdata = this;
@@ -970,9 +973,6 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() {
profile_info.resize(CLAMP(int(ProjectSettings::get_singleton()->get("debug/settings/profiler/max_functions")), 128, 65535));
profile_info_ptrs.resize(profile_info.size());
- profiling = false;
- max_frame_functions = 16;
- reload_all_scripts = false;
}
ScriptDebuggerRemote::~ScriptDebuggerRemote() {
diff --git a/core/script_language.cpp b/core/script_language.cpp
index bb99e0abae..4664049145 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -384,11 +384,10 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c
//change notify
}
-PlaceHolderScriptInstance::PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script, Object *p_owner) {
-
- language = p_language;
- script = p_script;
- owner = p_owner;
+PlaceHolderScriptInstance::PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script, Object *p_owner)
+ : owner(p_owner),
+ language(p_language),
+ script(p_script) {
}
PlaceHolderScriptInstance::~PlaceHolderScriptInstance() {
diff --git a/core/translation.cpp b/core/translation.cpp
index 50694e4a2d..c38d5d8b4d 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -923,9 +923,8 @@ void Translation::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "locale"), "set_locale", "get_locale");
}
-Translation::Translation() {
-
- locale = "en";
+Translation::Translation()
+ : locale("en") {
}
///////////////////////////////////////////////
@@ -1125,8 +1124,8 @@ void TranslationServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("translate", "message"), &TranslationServer::translate);
- ClassDB::bind_method(D_METHOD("add_translation", "translation:Translation"), &TranslationServer::add_translation);
- ClassDB::bind_method(D_METHOD("remove_translation", "translation:Translation"), &TranslationServer::remove_translation);
+ ClassDB::bind_method(D_METHOD("add_translation", "translation"), &TranslationServer::add_translation);
+ ClassDB::bind_method(D_METHOD("remove_translation", "translation"), &TranslationServer::remove_translation);
ClassDB::bind_method(D_METHOD("clear"), &TranslationServer::clear);
}
@@ -1144,9 +1143,8 @@ void TranslationServer::load_translations() {
}
}
-TranslationServer::TranslationServer() {
-
+TranslationServer::TranslationServer()
+ : locale("en"),
+ enabled(true) {
singleton = this;
- locale = "en";
- enabled = true;
}
diff --git a/core/type_info.h b/core/type_info.h
new file mode 100644
index 0000000000..10912fd074
--- /dev/null
+++ b/core/type_info.h
@@ -0,0 +1,203 @@
+#ifndef GET_TYPE_INFO_H
+#define GET_TYPE_INFO_H
+
+template <bool C, typename T = void>
+struct EnableIf {
+
+ typedef T type;
+};
+
+template <typename T>
+struct EnableIf<false, T> {
+};
+
+template <typename, typename>
+struct TypesAreSame {
+
+ static bool const value = false;
+};
+
+template <typename A>
+struct TypesAreSame<A, A> {
+
+ static bool const value = true;
+};
+
+template <typename B, typename D>
+struct TypeInherits {
+
+ static D *get_d();
+
+ static char (&test(B *))[1];
+ static char (&test(...))[2];
+
+ static bool const value = sizeof(test(get_d())) == sizeof(char) &&
+ !TypesAreSame<B volatile const, void volatile const>::value;
+};
+
+template <class T, typename = void>
+struct GetTypeInfo {
+ enum { VARIANT_TYPE = Variant::NIL };
+
+ static inline StringName get_class_name() {
+ ERR_PRINT("Fallback type info. Bug!");
+ return ""; // Not "Nil", this is an error
+ }
+};
+
+#define MAKE_TYPE_INFO(m_type, m_var_type) \
+ template <> \
+ struct GetTypeInfo<m_type> { \
+ enum { VARIANT_TYPE = m_var_type }; \
+ static inline StringName get_class_name() { \
+ return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \
+ } \
+ }; \
+ template <> \
+ struct GetTypeInfo<const m_type &> { \
+ enum { VARIANT_TYPE = m_var_type }; \
+ static inline StringName get_class_name() { \
+ return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \
+ } \
+ };
+
+MAKE_TYPE_INFO(bool, Variant::BOOL)
+MAKE_TYPE_INFO(uint8_t, Variant::INT)
+MAKE_TYPE_INFO(int8_t, Variant::INT)
+MAKE_TYPE_INFO(uint16_t, Variant::INT)
+MAKE_TYPE_INFO(int16_t, Variant::INT)
+MAKE_TYPE_INFO(uint32_t, Variant::INT)
+MAKE_TYPE_INFO(int32_t, Variant::INT)
+MAKE_TYPE_INFO(int64_t, Variant::INT)
+MAKE_TYPE_INFO(uint64_t, Variant::INT)
+MAKE_TYPE_INFO(float, Variant::REAL)
+MAKE_TYPE_INFO(double, Variant::REAL)
+
+MAKE_TYPE_INFO(String, Variant::STRING)
+MAKE_TYPE_INFO(Vector2, Variant::VECTOR2)
+MAKE_TYPE_INFO(Rect2, Variant::RECT2)
+MAKE_TYPE_INFO(Vector3, Variant::VECTOR3)
+MAKE_TYPE_INFO(Transform2D, Variant::TRANSFORM2D)
+MAKE_TYPE_INFO(Plane, Variant::PLANE)
+MAKE_TYPE_INFO(Quat, Variant::QUAT)
+MAKE_TYPE_INFO(Rect3, Variant::RECT3)
+MAKE_TYPE_INFO(Basis, Variant::BASIS)
+MAKE_TYPE_INFO(Transform, Variant::TRANSFORM)
+MAKE_TYPE_INFO(Color, Variant::COLOR)
+MAKE_TYPE_INFO(NodePath, Variant::NODE_PATH)
+MAKE_TYPE_INFO(RID, Variant::_RID)
+MAKE_TYPE_INFO(Dictionary, Variant::DICTIONARY)
+MAKE_TYPE_INFO(Array, Variant::ARRAY)
+MAKE_TYPE_INFO(PoolByteArray, Variant::POOL_BYTE_ARRAY)
+MAKE_TYPE_INFO(PoolIntArray, Variant::POOL_INT_ARRAY)
+MAKE_TYPE_INFO(PoolRealArray, Variant::POOL_REAL_ARRAY)
+MAKE_TYPE_INFO(PoolStringArray, Variant::POOL_STRING_ARRAY)
+MAKE_TYPE_INFO(PoolVector2Array, Variant::POOL_VECTOR2_ARRAY)
+MAKE_TYPE_INFO(PoolVector3Array, Variant::POOL_VECTOR3_ARRAY)
+MAKE_TYPE_INFO(PoolColorArray, Variant::POOL_COLOR_ARRAY)
+
+MAKE_TYPE_INFO(StringName, Variant::STRING)
+MAKE_TYPE_INFO(IP_Address, Variant::STRING)
+
+class BSP_Tree;
+MAKE_TYPE_INFO(BSP_Tree, Variant::DICTIONARY)
+
+#define MAKE_TYPE_INFO_WITH_NAME(m_type, m_var_type, m_class_name) \
+ template <> \
+ struct GetTypeInfo<m_type> { \
+ enum { VARIANT_TYPE = m_var_type }; \
+ static inline StringName get_class_name() { \
+ return m_class_name; \
+ } \
+ }; \
+ template <> \
+ struct GetTypeInfo<const m_type &> { \
+ enum { VARIANT_TYPE = m_var_type }; \
+ static inline StringName get_class_name() { \
+ return m_class_name; \
+ } \
+ };
+
+MAKE_TYPE_INFO_WITH_NAME(RefPtr, Variant::OBJECT, "Reference")
+MAKE_TYPE_INFO_WITH_NAME(Variant, Variant::NIL, "Variant")
+
+#define MAKE_TEMPLATE_TYPE_INFO(m_template, m_type, m_var_type) \
+ template <> \
+ struct GetTypeInfo<m_template<m_type> > { \
+ enum { VARIANT_TYPE = m_var_type }; \
+ static inline StringName get_class_name() { \
+ return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \
+ } \
+ }; \
+ template <> \
+ struct GetTypeInfo<const m_template<m_type> &> { \
+ enum { VARIANT_TYPE = m_var_type }; \
+ static inline StringName get_class_name() { \
+ return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \
+ } \
+ };
+
+MAKE_TEMPLATE_TYPE_INFO(Vector, uint8_t, Variant::POOL_BYTE_ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, int, Variant::POOL_INT_ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, float, Variant::POOL_REAL_ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, String, Variant::POOL_STRING_ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, Vector2, Variant::POOL_VECTOR2_ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, Vector3, Variant::POOL_VECTOR3_ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, Color, Variant::POOL_COLOR_ARRAY)
+
+MAKE_TEMPLATE_TYPE_INFO(Vector, Variant, Variant::ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, RID, Variant::ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, Plane, Variant::ARRAY)
+
+MAKE_TEMPLATE_TYPE_INFO(PoolVector, Plane, Variant::ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(PoolVector, Face3, Variant::POOL_VECTOR3_ARRAY)
+
+#define MAKE_ENUM_TYPE_INFO(m_enum) \
+ template <> \
+ struct GetTypeInfo<m_enum> { \
+ enum { VARIANT_TYPE = Variant::INT }; \
+ static inline StringName get_class_name() { \
+ return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \
+ } \
+ }; \
+ template <> \
+ struct GetTypeInfo<m_enum const> { \
+ enum { VARIANT_TYPE = Variant::INT }; \
+ static inline StringName get_class_name() { \
+ return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \
+ } \
+ }; \
+ template <> \
+ struct GetTypeInfo<m_enum &> { \
+ enum { VARIANT_TYPE = Variant::INT }; \
+ static inline StringName get_class_name() { \
+ return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \
+ } \
+ }; \
+ template <> \
+ struct GetTypeInfo<const m_enum &> { \
+ enum { VARIANT_TYPE = Variant::INT }; \
+ static inline StringName get_class_name() { \
+ return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \
+ } \
+ };
+
+template <typename T>
+struct GetTypeInfo<T *, typename EnableIf<TypeInherits<Object, T>::value>::type> {
+ enum { VARIANT_TYPE = Variant::OBJECT };
+
+ static inline StringName get_class_name() {
+ return T::get_class_static();
+ }
+};
+
+template <typename T>
+struct GetTypeInfo<const T *, typename EnableIf<TypeInherits<Object, T>::value>::type> {
+ enum { VARIANT_TYPE = Variant::OBJECT };
+
+ static inline StringName get_class_name() {
+ return T::get_class_static();
+ }
+};
+
+#endif // GET_TYPE_INFO_H
diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp
index 637fcd91d4..19b9f161b7 100644
--- a/core/undo_redo.cpp
+++ b/core/undo_redo.cpp
@@ -496,8 +496,8 @@ void UndoRedo::_bind_methods() {
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "add_undo_method", &UndoRedo::_add_undo_method, mi);
}
- ClassDB::bind_method(D_METHOD("add_do_property", "object", "property", "value:Variant"), &UndoRedo::add_do_property);
- ClassDB::bind_method(D_METHOD("add_undo_property", "object", "property", "value:Variant"), &UndoRedo::add_undo_property);
+ ClassDB::bind_method(D_METHOD("add_do_property", "object", "property", "value"), &UndoRedo::add_do_property);
+ ClassDB::bind_method(D_METHOD("add_undo_property", "object", "property", "value"), &UndoRedo::add_undo_property);
ClassDB::bind_method(D_METHOD("add_do_reference", "object"), &UndoRedo::add_do_reference);
ClassDB::bind_method(D_METHOD("add_undo_reference", "object"), &UndoRedo::add_undo_reference);
ClassDB::bind_method(D_METHOD("clear_history"), &UndoRedo::clear_history);
diff --git a/core/variant.h b/core/variant.h
index 95782d9619..40de1a9bce 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -49,7 +49,6 @@
#include "rect3.h"
#include "ref_ptr.h"
#include "rid.h"
-#include "simple_type.h"
#include "transform.h"
#include "ustring.h"
#include "vector3.h"
@@ -154,15 +153,6 @@ public:
static bool can_convert(Type p_type_from, Type p_type_to);
static bool can_convert_strict(Type p_type_from, Type p_type_to);
- template <class T>
- static Type get_type_for() {
-
- GetSimpleType<T> t;
- Variant v(t.type);
- Type r = v.get_type();
- return r;
- }
-
bool is_ref() const;
_FORCE_INLINE_ bool is_num() const { return type == INT || type == REAL; };
_FORCE_INLINE_ bool is_array() const { return type >= ARRAY; };
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 4a806aec6c..aabc2546bc 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -130,9 +130,9 @@ struct _VariantCall {
StringName name;
Variant::Type type;
Arg() { type = Variant::NIL; }
- Arg(Variant::Type p_type, const StringName &p_name) {
- name = p_name;
- type = p_type;
+ Arg(Variant::Type p_type, const StringName &p_name)
+ : name(p_name),
+ type(p_type) {
}
};