diff options
Diffstat (limited to 'core')
62 files changed, 747 insertions, 426 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index ce08b3f754..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); @@ -180,8 +180,8 @@ int _OS::get_mouse_button_state() const { return OS::get_singleton()->get_mouse_button_state(); } -String _OS::get_unique_ID() const { - return OS::get_singleton()->get_unique_ID(); +String _OS::get_unique_id() const { + return OS::get_singleton()->get_unique_id(); } bool _OS::has_touchscreen_ui_hint() const { @@ -369,9 +369,9 @@ Error _OS::kill(int p_pid) { return OS::get_singleton()->kill(p_pid); } -int _OS::get_process_ID() const { +int _OS::get_process_id() const { - return OS::get_singleton()->get_process_ID(); + return OS::get_singleton()->get_process_id(); }; bool _OS::has_environment(const String &p_var) const { @@ -800,7 +800,7 @@ void _OS::print_all_textures_by_size() { img.fmt = fmt; img.path = E->get()->get_path(); img.vram = Image::get_image_data_size(img.size.width, img.size.height, Image::Format(img.fmt)); - img.id = E->get()->get_instance_ID(); + img.id = E->get()->get_instance_id(); total += img.vram; imgs.push_back(img); } @@ -1019,7 +1019,7 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("execute", "path", "arguments", "blocking", "output"), &_OS::execute, DEFVAL(Array())); ClassDB::bind_method(D_METHOD("kill", "pid"), &_OS::kill); ClassDB::bind_method(D_METHOD("shell_open", "uri"), &_OS::shell_open); - ClassDB::bind_method(D_METHOD("get_process_ID"), &_OS::get_process_ID); + ClassDB::bind_method(D_METHOD("get_process_id"), &_OS::get_process_id); ClassDB::bind_method(D_METHOD("get_environment", "environment"), &_OS::get_environment); ClassDB::bind_method(D_METHOD("has_environment", "environment"), &_OS::has_environment); @@ -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); @@ -1074,7 +1074,7 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_data_dir"), &_OS::get_data_dir); ClassDB::bind_method(D_METHOD("get_system_dir", "dir"), &_OS::get_system_dir); - ClassDB::bind_method(D_METHOD("get_unique_ID"), &_OS::get_unique_ID); + ClassDB::bind_method(D_METHOD("get_unique_id"), &_OS::get_unique_id); ClassDB::bind_method(D_METHOD("is_ok_left_and_cancel_right"), &_OS::is_ok_left_and_cancel_right); @@ -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); } @@ -2256,7 +2256,7 @@ String _Thread::get_id() const { if (!thread) return String(); - return itos(thread->get_ID()); + return itos(thread->get_id()); } bool _Thread::is_active() const { @@ -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/bind/core_bind.h b/core/bind/core_bind.h index ec4fd3f476..e18d663d85 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -175,7 +175,7 @@ public: Error kill(int p_pid); Error shell_open(String p_uri); - int get_process_ID() const; + int get_process_id() const; bool has_environment(const String &p_var) const; String get_environment(const String &p_var) const; @@ -204,7 +204,7 @@ public: bool is_debug_build() const; - String get_unique_ID() const; + String get_unique_id() const; String get_scancode_string(uint32_t p_code) const; bool is_scancode_unicode(uint32_t p_unicode) const; diff --git a/core/class_db.cpp b/core/class_db.cpp index 6b8c290a99..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) { @@ -937,6 +937,28 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia return false; } +int ClassDB::get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid) { + + ClassInfo *type = classes.getptr(p_class); + ClassInfo *check = type; + while (check) { + const PropertySetGet *psg = check->property_setget.getptr(p_property); + if (psg) { + + if (r_is_valid) + *r_is_valid = true; + + return psg->index; + } + + check = check->inherits_ptr; + } + if (r_is_valid) + *r_is_valid = false; + + return -1; +} + Variant::Type ClassDB::get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid) { ClassInfo *type = classes.getptr(p_class); @@ -1060,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); @@ -1084,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)) { @@ -1093,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 4f00a16e91..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 @@ -480,6 +474,7 @@ public: static bool set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid = NULL); static bool get_property(Object *p_object, const StringName &p_property, Variant &r_value); static bool has_property(const StringName &p_class, const StringName &p_property, bool p_no_inheritance = false); + static int get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL); static Variant::Type get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL); static StringName get_property_setter(StringName p_class, const StringName p_property); static StringName get_property_getter(StringName p_class, const StringName p_property); 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 1121c6d3e4..5622a03665 100644 --- a/core/func_ref.cpp +++ b/core/func_ref.cpp @@ -48,7 +48,7 @@ Variant FuncRef::call_func(const Variant **p_args, int p_argcount, Variant::Call void FuncRef::set_instance(Object *p_obj) { ERR_FAIL_NULL(p_obj); - id = p_obj->get_instance_ID(); + id = p_obj->get_instance_id(); } void FuncRef::set_function(const StringName &p_func) { @@ -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/global_constants.cpp b/core/global_constants.cpp index 18071d7748..9e745ecb98 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -67,8 +67,8 @@ static _GlobalConstant _global_constants[] = { BIND_GLOBAL_CONSTANT(KEY_TAB), BIND_GLOBAL_CONSTANT(KEY_BACKTAB), BIND_GLOBAL_CONSTANT(KEY_BACKSPACE), - BIND_GLOBAL_CONSTANT(KEY_RETURN), BIND_GLOBAL_CONSTANT(KEY_ENTER), + BIND_GLOBAL_CONSTANT(KEY_KP_ENTER), BIND_GLOBAL_CONSTANT(KEY_INSERT), BIND_GLOBAL_CONSTANT(KEY_DELETE), BIND_GLOBAL_CONSTANT(KEY_PAUSE), 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 24d0624e98..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); } @@ -219,11 +219,11 @@ void InputMap::load_default() { add_action("ui_accept"); key.instance(); - key->set_scancode(KEY_RETURN); + key->set_scancode(KEY_ENTER); action_add_event("ui_accept", key); key.instance(); - key->set_scancode(KEY_ENTER); + key->set_scancode(KEY_KP_ENTER); action_add_event("ui_accept", key); key.instance(); 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 a3d33593dd..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,9 @@ 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); } Error PacketPeerStream::_poll_buffer() const { @@ -146,13 +148,13 @@ Error PacketPeerStream::_poll_buffer() const { ERR_FAIL_COND_V(peer.is_null(), ERR_UNCONFIGURED); int read = 0; - Error err = peer->get_partial_data(&temp_buffer[0], ring_buffer.space_left(), read); + Error err = peer->get_partial_data(&input_buffer[0], ring_buffer.space_left(), read); if (err) return err; if (read == 0) return OK; - int w = ring_buffer.write(&temp_buffer[0], read); + int w = ring_buffer.write(&input_buffer[0], read); ERR_FAIL_COND_V(w != read, ERR_BUG); return OK; @@ -198,9 +200,9 @@ Error PacketPeerStream::get_packet(const uint8_t **r_buffer, int &r_buffer_size) ERR_FAIL_COND_V(remaining < (int)len, ERR_UNAVAILABLE); ring_buffer.read(lbuf, 4); //get rid of first 4 bytes - ring_buffer.read(&temp_buffer[0], len); // read packet + ring_buffer.read(&input_buffer[0], len); // read packet - *r_buffer = &temp_buffer[0]; + *r_buffer = &input_buffer[0]; r_buffer_size = len; return OK; } @@ -217,19 +219,19 @@ Error PacketPeerStream::put_packet(const uint8_t *p_buffer, int p_buffer_size) { return OK; ERR_FAIL_COND_V(p_buffer_size < 0, ERR_INVALID_PARAMETER); - ERR_FAIL_COND_V(p_buffer_size + 4 > temp_buffer.size(), ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(p_buffer_size + 4 > output_buffer.size(), ERR_INVALID_PARAMETER); - encode_uint32(p_buffer_size, &temp_buffer[0]); - uint8_t *dst = &temp_buffer[4]; + encode_uint32(p_buffer_size, &output_buffer[0]); + uint8_t *dst = &output_buffer[4]; for (int i = 0; i < p_buffer_size; i++) dst[i] = p_buffer[i]; - return peer->put_data(&temp_buffer[0], p_buffer_size + 4); + return peer->put_data(&output_buffer[0], p_buffer_size + 4); } int PacketPeerStream::get_max_packet_size() const { - return temp_buffer.size(); + return output_buffer.size(); } void PacketPeerStream::set_stream_peer(const Ref<StreamPeer> &p_peer) { @@ -249,7 +251,12 @@ void PacketPeerStream::set_input_buffer_max_size(int p_max_size) { ERR_EXPLAIN("Buffer in use, resizing would cause loss of data"); ERR_FAIL_COND(ring_buffer.data_left()); ring_buffer.resize(nearest_shift(p_max_size + 4)); - temp_buffer.resize(nearest_power_of_2(p_max_size + 4)); + input_buffer.resize(nearest_power_of_2(p_max_size + 4)); +} + +void PacketPeerStream::set_output_buffer_max_size(int p_max_size) { + + output_buffer.resize(nearest_power_of_2(p_max_size + 4)); } PacketPeerStream::PacketPeerStream() { @@ -257,5 +264,6 @@ PacketPeerStream::PacketPeerStream() { int rbsize = GLOBAL_GET("network/limits/packet_peer_stream/max_buffer_po2"); ring_buffer.resize(rbsize); - temp_buffer.resize(1 << rbsize); + input_buffer.resize(1 << rbsize); + output_buffer.resize(1 << rbsize); } diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h index 95806aa511..ed6b252d80 100644 --- a/core/io/packet_peer.h +++ b/core/io/packet_peer.h @@ -75,7 +75,8 @@ class PacketPeerStream : public PacketPeer { mutable Ref<StreamPeer> peer; mutable RingBuffer<uint8_t> ring_buffer; - mutable Vector<uint8_t> temp_buffer; + mutable Vector<uint8_t> input_buffer; + mutable Vector<uint8_t> output_buffer; Error _poll_buffer() const; @@ -92,6 +93,7 @@ public: void set_stream_peer(const Ref<StreamPeer> &p_peer); void set_input_buffer_max_size(int p_max_size); + void set_output_buffer_max_size(int p_max_size); PacketPeerStream(); }; 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_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 b59fecc196..b64f34d977 100644 --- a/core/math/matrix3.cpp +++ b/core/math/matrix3.cpp @@ -30,7 +30,7 @@ #include "matrix3.h" #include "math_funcs.h" #include "os/copymem.h" - +#include "print_string.h" #define cofac(row1, col1, row2, col2) \ (elements[row1][col1] * elements[row2][col2] - elements[row1][col2] * elements[row2][col1]) @@ -364,8 +364,16 @@ Vector3 Basis::get_euler() const { euler.y = Math::asin(elements[0][2]); if (euler.y < Math_PI * 0.5) { if (euler.y > -Math_PI * 0.5) { - euler.x = Math::atan2(-elements[1][2], elements[2][2]); - euler.z = Math::atan2(-elements[0][1], elements[0][0]); + //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) { + if (euler.y > 0.0) + euler.y = Math_PI - euler.y; + else + euler.y = -(Math_PI + euler.y); + } else { + euler.x = Math::atan2(-elements[1][2], elements[2][2]); + euler.z = Math::atan2(-elements[0][1], elements[0][0]); + } } else { real_t r = Math::atan2(elements[1][0], elements[1][1]); 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/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/message_queue.cpp b/core/message_queue.cpp index 93d0b0730a..564069d8bb 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -153,16 +153,16 @@ Error MessageQueue::push_notification(ObjectID p_id, int p_notification) { Error MessageQueue::push_call(Object *p_object, const StringName &p_method, VARIANT_ARG_DECLARE) { - return push_call(p_object->get_instance_ID(), p_method, VARIANT_ARG_PASS); + return push_call(p_object->get_instance_id(), p_method, VARIANT_ARG_PASS); } Error MessageQueue::push_notification(Object *p_object, int p_notification) { - return push_notification(p_object->get_instance_ID(), p_notification); + return push_notification(p_object->get_instance_id(), p_notification); } Error MessageQueue::push_set(Object *p_object, const StringName &p_prop, const Variant &p_value) { - return push_set(p_object->get_instance_ID(), p_prop, p_value); + return push_set(p_object->get_instance_id(), p_prop, p_value); } void MessageQueue::statistics() { 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/path_db.cpp b/core/node_path.cpp index d5c84a2457..ad2eae859d 100644 --- a/core/path_db.cpp +++ b/core/node_path.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* path_db.cpp */ +/* node_path.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "path_db.h" +#include "node_path.h" #include "print_string.h" diff --git a/core/path_db.h b/core/node_path.h index 1aed7535ca..31446ab9b4 100644 --- a/core/path_db.h +++ b/core/node_path.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* path_db.h */ +/* node_path.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,8 +27,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef PATH_DB_H -#define PATH_DB_H +#ifndef NODE_PATH_H +#define NODE_PATH_H #include "string_db.h" #include "ustring.h" diff --git a/core/object.cpp b/core/object.cpp index 316c624268..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 { @@ -599,7 +587,7 @@ Variant Object::_call_deferred_bind(const Variant **p_args, int p_argcount, Vari StringName method = *p_args[0]; - MessageQueue::get_singleton()->push_call(get_instance_ID(), method, &p_args[1], p_argcount - 1); + MessageQueue::get_singleton()->push_call(get_instance_id(), method, &p_args[1], p_argcount - 1); return Variant(); } @@ -1182,10 +1170,10 @@ Variant Object::_emit_signal(const Variant **p_args, int p_argcount, Variant::Ca return Variant(); } -void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount) { +Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount) { if (_block_signals) - return; //no emit, signals blocked + return ERR_CANT_AQUIRE_RESOURCE; //no emit, signals blocked Signal *s = signal_map.getptr(p_name); if (!s) { @@ -1194,11 +1182,11 @@ void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p //check in script if (!signal_is_valid && !script.is_null() && !Ref<Script>(script)->has_script_signal(p_name)) { ERR_EXPLAIN("Can't emit non-existing signal " + String("\"") + p_name + "\"."); - ERR_FAIL(); + ERR_FAIL_V(ERR_UNAVAILABLE); } #endif //not connected? just return - return; + return ERR_UNAVAILABLE; } List<_ObjectSignalDisconnectData> disconnect_data; @@ -1214,6 +1202,8 @@ void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p Vector<const Variant *> bind_mem; + Error err = OK; + for (int i = 0; i < ssize; i++) { const Connection &c = slot_map.getv(i).conn; @@ -1245,16 +1235,18 @@ void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p } if (c.flags & CONNECT_DEFERRED) { - MessageQueue::get_singleton()->push_call(target->get_instance_ID(), c.method, args, argc, true); + MessageQueue::get_singleton()->push_call(target->get_instance_id(), c.method, args, argc, true); } else { Variant::CallError ce; target->call(c.method, args, argc, ce); + if (ce.error != Variant::CallError::CALL_OK) { if (ce.error == Variant::CallError::CALL_ERROR_INVALID_METHOD && !ClassDB::class_exists(target->get_class_name())) { //most likely object is not initialized yet, do not throw error. } else { ERR_PRINTS("Error calling method from signal '" + String(p_name) + "': " + Variant::get_call_error_text(target, c.method, args, argc, ce)); + err = ERR_METHOD_NOT_FOUND; } } } @@ -1274,21 +1266,24 @@ void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p disconnect(dd.signal, dd.target, dd.method); disconnect_data.pop_front(); } + + return err; } -void Object::emit_signal(const StringName &p_name, VARIANT_ARG_DECLARE) { +Error Object::emit_signal(const StringName &p_name, VARIANT_ARG_DECLARE) { VARIANT_ARGPTRS; int argc = 0; for (int i = 0; i < VARIANT_ARG_MAX; i++) { + if (argptr[i]->get_type() == Variant::NIL) break; argc++; } - emit_signal(p_name, argptr, argc); + return emit_signal(p_name, argptr, argc); } void Object::_add_user_signal(const String &p_name, const Array &p_args) { @@ -1471,7 +1466,7 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str s = &signal_map[p_signal]; } - Signal::Target target(p_to_object->get_instance_ID(), p_to_method); + Signal::Target target(p_to_object->get_instance_id(), p_to_method); if (s->slot_map.has(target)) { ERR_EXPLAIN("Signal '" + p_signal + "'' already connected to given method '" + p_to_method + "' in that object."); ERR_FAIL_COND_V(s->slot_map.has(target), ERR_INVALID_PARAMETER); @@ -1509,7 +1504,7 @@ bool Object::is_connected(const StringName &p_signal, Object *p_to_object, const ERR_FAIL_COND_V(!s, false); } - Signal::Target target(p_to_object->get_instance_ID(), p_to_method); + Signal::Target target(p_to_object->get_instance_id(), p_to_method); return s->slot_map.has(target); //const Map<Signal::Target,Signal::Slot>::Element *E = s->slot_map.find(target); @@ -1529,7 +1524,7 @@ void Object::disconnect(const StringName &p_signal, Object *p_to_object, const S ERR_FAIL_COND(s->lock > 0); } - Signal::Target target(p_to_object->get_instance_ID(), p_to_method); + Signal::Target target(p_to_object->get_instance_id(), p_to_method); if (!s->slot_map.has(target)) { ERR_EXPLAIN("Disconnecting nonexistent signal '" + p_signal + "', slot: " + itos(target._id) + ":" + target.method); @@ -1656,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("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); @@ -1692,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); } { @@ -1703,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); @@ -1711,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); @@ -1731,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"; @@ -1929,7 +1924,7 @@ ObjectID ObjectDB::instance_counter = 1; HashMap<Object *, ObjectID, ObjectDB::ObjectPtrHash> ObjectDB::instance_checks; ObjectID ObjectDB::add_instance(Object *p_object) { - ERR_FAIL_COND_V(p_object->get_instance_ID() != 0, 0); + ERR_FAIL_COND_V(p_object->get_instance_id() != 0, 0); rw_lock->write_lock(); instances[++instance_counter] = p_object; @@ -1945,7 +1940,7 @@ void ObjectDB::remove_instance(Object *p_object) { rw_lock->write_lock(); - instances.erase(p_object->get_instance_ID()); + instances.erase(p_object->get_instance_id()); #ifdef DEBUG_ENABLED instance_checks.erase(p_object); #endif @@ -2008,7 +2003,7 @@ void ObjectDB::cleanup() { String node_name; if (instances[*K]->is_class("Node")) node_name = " - Node Name: " + String(instances[*K]->call("get_name")); - if (instances[*K]->is_class("Resoucre")) + if (instances[*K]->is_class("Resource")) node_name = " - Resource Name: " + String(instances[*K]->call("get_name")) + " Path: " + String(instances[*K]->call("get_path")); print_line("Leaked Instance: " + String(instances[*K]->get_class()) + ":" + itos(*K) + node_name); } diff --git a/core/object.h b/core/object.h index 148a73fbc4..551c3c31b9 100644 --- a/core/object.h +++ b/core/object.h @@ -105,6 +105,7 @@ enum PropertyUsageFlags { PROPERTY_USAGE_STORE_IF_NULL = 16384, PROPERTY_USAGE_ANIMATE_AS_TRIGGER = 32768, PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED = 65536, + PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE = 1 << 17, PROPERTY_USAGE_DEFAULT = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK, PROPERTY_USAGE_DEFAULT_INTL = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK | PROPERTY_USAGE_INTERNATIONALIZED, @@ -138,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; @@ -400,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; } }; @@ -533,7 +534,7 @@ public: bool _is_gpl_reversed() const { return false; } - _FORCE_INLINE_ ObjectID get_instance_ID() const { return _instance_ID; } + _FORCE_INLINE_ ObjectID get_instance_id() const { return _instance_ID; } // this is used for editors void add_change_receptor(Object *p_receptor); @@ -654,8 +655,8 @@ public: void set_script_and_instance(const RefPtr &p_script, ScriptInstance *p_instance); //some script languages can't control instance creation, so this function eases the process void add_user_signal(const MethodInfo &p_signal); - void emit_signal(const StringName &p_name, VARIANT_ARG_LIST); - void emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount); + Error emit_signal(const StringName &p_name, VARIANT_ARG_LIST); + Error emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount); void get_signal_list(List<MethodInfo> *p_signals) const; void get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const; void get_all_signal_connections(List<Connection> *p_connections) const; 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/keyboard.cpp b/core/os/keyboard.cpp index e154b1934d..9b3e376ea6 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -42,8 +42,8 @@ static const _KeyCodeText _keycodes[] = { {KEY_TAB ,"Tab"}, {KEY_BACKTAB ,"BackTab"}, {KEY_BACKSPACE ,"BackSpace"}, - {KEY_RETURN ,"Return"}, {KEY_ENTER ,"Enter"}, + {KEY_KP_ENTER ,"Kp Enter"}, {KEY_INSERT ,"Insert"}, {KEY_DELETE ,"Delete"}, {KEY_PAUSE ,"Pause"}, @@ -294,8 +294,8 @@ bool keycode_has_unicode(uint32_t p_keycode) { case KEY_TAB: case KEY_BACKTAB: case KEY_BACKSPACE: - case KEY_RETURN: case KEY_ENTER: + case KEY_KP_ENTER: case KEY_INSERT: case KEY_DELETE: case KEY_PAUSE: diff --git a/core/os/keyboard.h b/core/os/keyboard.h index c6985c887d..1ed93e3540 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -57,8 +57,8 @@ enum KeyList { KEY_TAB = SPKEY | 0x02, KEY_BACKTAB = SPKEY | 0x03, KEY_BACKSPACE = SPKEY | 0x04, - KEY_RETURN = SPKEY | 0x05, - KEY_ENTER = SPKEY | 0x06, + KEY_ENTER = SPKEY | 0x05, + KEY_KP_ENTER = SPKEY | 0x06, KEY_INSERT = SPKEY | 0x07, KEY_DELETE = SPKEY | 0x08, KEY_PAUSE = SPKEY | 0x09, 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.cpp b/core/os/os.cpp index 8e4c357195..3a06a3fa8f 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -129,7 +129,7 @@ String OS::get_executable_path() const { return _execpath; } -int OS::get_process_ID() const { +int OS::get_process_id() const { return -1; }; @@ -175,7 +175,7 @@ static void _OS_printres(Object *p_obj) { if (!res) return; - String str = itos(res->get_instance_ID()) + String(res->get_class()) + ":" + String(res->get_name()) + " - " + res->get_path(); + String str = itos(res->get_instance_id()) + String(res->get_class()) + ":" + String(res->get_name()) + " - " + res->get_path(); if (_OSPRF) _OSPRF->store_line(str); else @@ -412,7 +412,7 @@ void OS::make_rendering_thread() { void OS::swap_buffers() { } -String OS::get_unique_ID() const { +String OS::get_unique_id() const { ERR_FAIL_V(""); } diff --git a/core/os/os.h b/core/os/os.h index 703c6a6bcd..8e2257a0e4 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -197,7 +197,7 @@ public: virtual String get_executable_path() const; virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL) = 0; virtual Error kill(const ProcessID &p_pid) = 0; - virtual int get_process_ID() const; + virtual int get_process_id() const; virtual Error shell_open(String p_uri); virtual Error set_cwd(const String &p_cwd); @@ -370,7 +370,7 @@ public: virtual int get_processor_count() const; - virtual String get_unique_ID() const; + virtual String get_unique_id() const; virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); virtual bool native_video_is_playing() const; diff --git a/core/os/thread.cpp b/core/os/thread.cpp index 98f1968629..bd565334c3 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -30,16 +30,16 @@ #include "thread.h" Thread *(*Thread::create_func)(ThreadCreateCallback, void *, const Settings &) = NULL; -Thread::ID (*Thread::get_thread_ID_func)() = NULL; +Thread::ID (*Thread::get_thread_id_func)() = NULL; void (*Thread::wait_to_finish_func)(Thread *) = NULL; Error (*Thread::set_name_func)(const String &) = NULL; Thread::ID Thread::_main_thread_id = 0; -Thread::ID Thread::get_caller_ID() { +Thread::ID Thread::get_caller_id() { - if (get_thread_ID_func) - return get_thread_ID_func(); + if (get_thread_id_func) + return get_thread_id_func(); return 0; } diff --git a/core/os/thread.h b/core/os/thread.h index 3ad5d4bf2c..1103f67ff2 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -58,7 +58,7 @@ public: protected: static Thread *(*create_func)(ThreadCreateCallback p_callback, void *, const Settings &); - static ID (*get_thread_ID_func)(); + static ID (*get_thread_id_func)(); static void (*wait_to_finish_func)(Thread *); static Error (*set_name_func)(const String &); @@ -69,11 +69,11 @@ protected: Thread(); public: - virtual ID get_ID() const = 0; + virtual ID get_id() const = 0; static Error set_name(const String &p_name); - _FORCE_INLINE_ static ID get_main_ID() { return _main_thread_id; } ///< get the ID of the main thread - static ID get_caller_ID(); ///< get the ID of the caller function ID + _FORCE_INLINE_ static ID get_main_id() { return _main_thread_id; } ///< get the ID of the main thread + static ID get_caller_id(); ///< get the ID of the caller function ID static void wait_to_finish(Thread *p_thread); ///< waits until thread is finished, and deallocates it. static Thread *create(ThreadCreateCallback p_callback, void *p_user, const Settings &p_settings = Settings()); ///< Static function to create a thread, will call p_callback diff --git a/core/os/thread_dummy.h b/core/os/thread_dummy.h index 4155103bbf..64941a71f8 100644 --- a/core/os/thread_dummy.h +++ b/core/os/thread_dummy.h @@ -39,7 +39,7 @@ class ThreadDummy : public Thread { static Thread *create(ThreadCreateCallback p_callback, void *p_user, const Settings &p_settings = Settings()); public: - virtual ID get_ID() const { return 0; }; + virtual ID get_id() const { return 0; }; static void make_default(); }; 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 b31f78ec20..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); } @@ -925,10 +925,10 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("application/config/use_shared_user_dir", true); key.instance(); - key->set_scancode(KEY_RETURN); + key->set_scancode(KEY_ENTER); va.push_back(key); key.instance(); - key->set_scancode(KEY_ENTER); + key->set_scancode(KEY_KP_ENTER); va.push_back(key); key.instance(); key->set_scancode(KEY_SPACE); 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 060608eacb..e9629ee7c0 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -108,12 +108,12 @@ Variant WeakRef::get_ref() const { } void WeakRef::set_obj(Object *p_object) { - ref = p_object ? p_object->get_instance_ID() : 0; + ref = p_object ? p_object->get_instance_id() : 0; } void WeakRef::set_ref(const REF &p_ref) { - ref = p_ref.is_valid() ? p_ref->get_instance_ID() : 0; + ref = p_ref.is_valid() ? p_ref->get_instance_id() : 0; } WeakRef::WeakRef() { @@ -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 5625784396..a0b0fd24e1 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -32,6 +32,7 @@ #include "core_string_names.h" #include "io/resource_loader.h" #include "os/file_access.h" +#include "scene/main/node.h" //only so casting works #include "script_language.h" #include <stdio.h> @@ -227,12 +228,12 @@ RID Resource::get_rid() const { void Resource::register_owner(Object *p_owner) { - owners.insert(p_owner->get_instance_ID()); + owners.insert(p_owner->get_instance_id()); } void Resource::unregister_owner(Object *p_owner) { - owners.erase(p_owner->get_instance_ID()); + owners.erase(p_owner->get_instance_id()); } void Resource::notify_change_to_owners() { @@ -336,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 d19fe213f6..3628f2ecaf 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -95,7 +95,7 @@ static Object *_ScriptDebuggerRemote_find = NULL; static void _ScriptDebuggerRemote_debug_func(Object *p_obj) { if (_ScriptDebuggerRemote_find == p_obj) { - _ScriptDebuggerRemote_found_id = p_obj->get_instance_ID(); + _ScriptDebuggerRemote_found_id = p_obj->get_instance_id(); } } @@ -109,7 +109,7 @@ static ObjectID safe_get_instance_id(const Variant &p_v) { REF r = p_v; if (r.is_valid()) { - return r->get_instance_ID(); + return r->get_instance_id(); } else { _ScriptDebuggerRemote_found_id = 0; @@ -572,7 +572,7 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) { ObjectID id2; Object *obj = var; if (obj) { - id2 = obj->get_instance_ID(); + id2 = obj->get_instance_id(); } else { id2 = 0; } @@ -940,28 +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); - mutex = Mutex::create(); - locking = false; + packet_peer_stream->set_output_buffer_max_size(1024 * 1024 * 8); //8mb should be way more than enough 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; @@ -969,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 aeb1573840..4664049145 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -280,8 +280,23 @@ ScriptDebugger::ScriptDebugger() { bool PlaceHolderScriptInstance::set(const StringName &p_name, const Variant &p_value) { if (values.has(p_name)) { + Variant defval; + if (script->get_property_default_value(p_name, defval)) { + if (defval == p_value) { + values.erase(p_name); + return true; + } + } values[p_name] = p_value; return true; + } else { + Variant defval; + if (script->get_property_default_value(p_name, defval)) { + if (defval != p_value) { + values[p_name] = p_value; + } + return true; + } } return false; } @@ -291,12 +306,22 @@ bool PlaceHolderScriptInstance::get(const StringName &p_name, Variant &r_ret) co r_ret = values[p_name]; return true; } + + Variant defval; + if (script->get_property_default_value(p_name, defval)) { + r_ret = defval; + return true; + } return false; } void PlaceHolderScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const { for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { + PropertyInfo pinfo = E->get(); + if (!values.has(pinfo.name)) { + pinfo.usage |= PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE; + } p_properties->push_back(E->get()); } } @@ -336,6 +361,14 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c if (!new_values.has(E->key())) to_remove.push_back(E->key()); + + Variant defval; + if (script->get_property_default_value(E->key(), defval)) { + //remove because it's the same as the default value + if (defval == E->get()) { + to_remove.push_back(E->key()); + } + } } while (to_remove.size()) { @@ -351,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 b3ac9d274e..19b9f161b7 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -110,7 +110,7 @@ void UndoRedo::add_do_method(Object *p_object, const String &p_method, VARIANT_A ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; - do_op.object = p_object->get_instance_ID(); + do_op.object = p_object->get_instance_id(); if (p_object->cast_to<Resource>()) do_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); @@ -134,7 +134,7 @@ void UndoRedo::add_undo_method(Object *p_object, const String &p_method, VARIANT return; Operation undo_op; - undo_op.object = p_object->get_instance_ID(); + undo_op.object = p_object->get_instance_id(); if (p_object->cast_to<Resource>()) undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); @@ -151,7 +151,7 @@ void UndoRedo::add_do_property(Object *p_object, const String &p_property, const ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; - do_op.object = p_object->get_instance_ID(); + do_op.object = p_object->get_instance_id(); if (p_object->cast_to<Resource>()) do_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); @@ -170,7 +170,7 @@ void UndoRedo::add_undo_property(Object *p_object, const String &p_property, con return; Operation undo_op; - undo_op.object = p_object->get_instance_ID(); + undo_op.object = p_object->get_instance_id(); if (p_object->cast_to<Resource>()) undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); @@ -184,7 +184,7 @@ void UndoRedo::add_do_reference(Object *p_object) { ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; - do_op.object = p_object->get_instance_ID(); + do_op.object = p_object->get_instance_id(); if (p_object->cast_to<Resource>()) do_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); @@ -201,7 +201,7 @@ void UndoRedo::add_undo_reference(Object *p_object) { return; Operation undo_op; - undo_op.object = p_object->get_instance_ID(); + undo_op.object = p_object->get_instance_id(); if (p_object->cast_to<Resource>()) undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); @@ -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.cpp b/core/variant.cpp index 0807a33788..51c4b70bdc 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -1600,7 +1600,7 @@ Variant::operator String() const { }; }; #endif - return "[" + _get_obj().obj->get_class() + ":" + itos(_get_obj().obj->get_instance_ID()) + "]"; + return "[" + _get_obj().obj->get_class() + ":" + itos(_get_obj().obj->get_instance_id()) + "]"; } else return "[Object:null]"; diff --git a/core/variant.h b/core/variant.h index 661d31cf16..40de1a9bce 100644 --- a/core/variant.h +++ b/core/variant.h @@ -42,14 +42,13 @@ #include "io/ip_address.h" #include "math_2d.h" #include "matrix3.h" +#include "node_path.h" #include "os/power.h" -#include "path_db.h" #include "plane.h" #include "quat.h" #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) { } }; |