diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 912c89a9d22..85fdcaee125 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -1850,12 +1850,12 @@ bool _ClassDB::is_parent_class(const StringName &p_class, const StringName &p_in return ClassDB::is_parent_class(p_class, p_inherits); } -bool _ClassDB::can_instance(const StringName &p_class) const { - return ClassDB::can_instance(p_class); +bool _ClassDB::can_instantiate(const StringName &p_class) const { + return ClassDB::can_instantiate(p_class); } -Variant _ClassDB::instance(const StringName &p_class) const { - Object *obj = ClassDB::instance(p_class); +Variant _ClassDB::instantiate(const StringName &p_class) const { + Object *obj = ClassDB::instantiate(p_class); if (!obj) { return Variant(); } @@ -1984,8 +1984,8 @@ void _ClassDB::_bind_methods() { ClassDB::bind_method(D_METHOD("get_parent_class", "class"), &_ClassDB::get_parent_class); 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", "class"), &_ClassDB::instance); + ClassDB::bind_method(D_METHOD("can_instantiate", "class"), &_ClassDB::can_instantiate); + ClassDB::bind_method(D_METHOD("instantiate", "class"), &_ClassDB::instantiate); 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); diff --git a/core/core_bind.h b/core/core_bind.h index 74b6a5b26fe..c01a149f586 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -585,8 +585,8 @@ public: StringName get_parent_class(const StringName &p_class) const; bool class_exists(const StringName &p_class) const; bool is_parent_class(const StringName &p_class, const StringName &p_inherits) const; - bool can_instance(const StringName &p_class) const; - Variant instance(const StringName &p_class) const; + bool can_instantiate(const StringName &p_class) const; + Variant instantiate(const StringName &p_class) const; bool has_signal(StringName p_class, StringName p_signal) const; Dictionary get_signal(StringName p_class, StringName p_signal) const; diff --git a/core/debugger/remote_debugger_peer.cpp b/core/debugger/remote_debugger_peer.cpp index 39113eda14f..ea5e32203ca 100644 --- a/core/debugger/remote_debugger_peer.cpp +++ b/core/debugger/remote_debugger_peer.cpp @@ -84,7 +84,7 @@ RemoteDebuggerPeerTCP::RemoteDebuggerPeerTCP(Ref p_tcp) { thread.start(_thread_func, this); #endif } else { - tcp_client.instance(); + tcp_client.instantiate(); } } diff --git a/core/input/input.cpp b/core/input/input.cpp index 6e98b596d73..be536aa7301 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -500,7 +500,7 @@ void Input::_parse_input_event_impl(const Ref &p_event, bool p_is_em if (event_dispatch_function && emulate_touch_from_mouse && !p_is_emulated && mb->get_button_index() == 1) { Ref touch_event; - touch_event.instance(); + touch_event.instantiate(); touch_event->set_pressed(mb->is_pressed()); touch_event->set_position(mb->get_position()); event_dispatch_function(touch_event); @@ -517,7 +517,7 @@ void Input::_parse_input_event_impl(const Ref &p_event, bool p_is_em if (event_dispatch_function && emulate_touch_from_mouse && !p_is_emulated && mm->get_button_mask() & 1) { Ref drag_event; - drag_event.instance(); + drag_event.instantiate(); drag_event->set_position(mm->get_position()); drag_event->set_relative(mm->get_relative()); @@ -555,7 +555,7 @@ void Input::_parse_input_event_impl(const Ref &p_event, bool p_is_em if (translate) { Ref button_event; - button_event.instance(); + button_event.instantiate(); button_event->set_device(InputEvent::DEVICE_ID_TOUCH_MOUSE); button_event->set_position(st->get_position()); @@ -582,7 +582,7 @@ void Input::_parse_input_event_impl(const Ref &p_event, bool p_is_em if (emulate_mouse_from_touch && sd->get_index() == mouse_from_touch_index) { Ref motion_event; - motion_event.instance(); + motion_event.instantiate(); motion_event->set_device(InputEvent::DEVICE_ID_TOUCH_MOUSE); motion_event->set_position(sd->get_position()); @@ -787,7 +787,7 @@ void Input::ensure_touch_mouse_raised() { mouse_from_touch_index = -1; Ref button_event; - button_event.instance(); + button_event.instantiate(); button_event->set_device(InputEvent::DEVICE_ID_TOUCH_MOUSE); button_event->set_position(mouse_pos); @@ -821,7 +821,7 @@ void Input::set_default_cursor_shape(CursorShape p_shape) { // The default shape is set in Viewport::_gui_input_event. To instantly // see the shape in the viewport we need to trigger a mouse motion event. Ref mm; - mm.instance(); + mm.instantiate(); mm->set_position(mouse_pos); mm->set_global_position(mouse_pos); parse_input_event(mm); @@ -1031,7 +1031,7 @@ void Input::joy_hat(int p_device, int p_val) { void Input::_button_event(int p_device, int p_index, bool p_pressed) { Ref ievent; - ievent.instance(); + ievent.instantiate(); ievent->set_device(p_device); ievent->set_button_index(p_index); ievent->set_pressed(p_pressed); @@ -1041,7 +1041,7 @@ void Input::_button_event(int p_device, int p_index, bool p_pressed) { void Input::_axis_event(int p_device, int p_axis, float p_value) { Ref ievent; - ievent.instance(); + ievent.instantiate(); ievent->set_device(p_device); ievent->set_axis(p_axis); ievent->set_axis_value(p_value); diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 72fb409b631..14762f955c3 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -375,7 +375,7 @@ String InputEventKey::to_string() { Ref InputEventKey::create_reference(uint32_t p_keycode) { Ref ie; - ie.instance(); + ie.instantiate(); ie->set_keycode(p_keycode & KEY_CODE_MASK); ie->set_unicode(p_keycode & KEY_CODE_MASK); @@ -545,7 +545,7 @@ Ref InputEventMouseButton::xformed_by(const Transform2D &p_xform, co Vector2 l = p_xform.xform(get_position() + p_local_ofs); Ref mb; - mb.instance(); + mb.instantiate(); mb->set_device(get_device()); mb->set_window_id(get_window_id()); @@ -731,7 +731,7 @@ Ref InputEventMouseMotion::xformed_by(const Transform2D &p_xform, co Vector2 s = p_xform.basis_xform(get_speed()); Ref mm; - mm.instance(); + mm.instantiate(); mm->set_device(get_device()); mm->set_window_id(get_window_id()); @@ -1048,7 +1048,7 @@ String InputEventJoypadButton::to_string() { Ref InputEventJoypadButton::create_reference(int p_btn_index) { Ref ie; - ie.instance(); + ie.instantiate(); ie->set_button_index(p_btn_index); return ie; @@ -1097,7 +1097,7 @@ bool InputEventScreenTouch::is_pressed() const { Ref InputEventScreenTouch::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { Ref st; - st.instance(); + st.instantiate(); st->set_device(get_device()); st->set_window_id(get_window_id()); st->set_index(index); @@ -1170,7 +1170,7 @@ Vector2 InputEventScreenDrag::get_speed() const { Ref InputEventScreenDrag::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { Ref sd; - sd.instance(); + sd.instantiate(); sd->set_device(get_device()); sd->set_window_id(get_window_id()); @@ -1325,7 +1325,7 @@ real_t InputEventMagnifyGesture::get_factor() const { Ref InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { Ref ev; - ev.instance(); + ev.instantiate(); ev->set_device(get_device()); ev->set_window_id(get_window_id()); @@ -1365,7 +1365,7 @@ Vector2 InputEventPanGesture::get_delta() const { Ref InputEventPanGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { Ref ev; - ev.instance(); + ev.instantiate(); ev->set_device(get_device()); ev->set_window_id(get_window_id()); diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index 63a8f9c5b60..9ee3876c2f1 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -210,7 +210,7 @@ FileAccessNetworkClient *FileAccessNetworkClient::singleton = nullptr; FileAccessNetworkClient::FileAccessNetworkClient() { singleton = this; - client.instance(); + client.instantiate(); } FileAccessNetworkClient::~FileAccessNetworkClient() { diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 449ebaa6ee1..78f04e57d30 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -730,7 +730,7 @@ int HTTPClient::get_read_chunk_size() const { } HTTPClient::HTTPClient() { - tcp_connection.instance(); + tcp_connection.instantiate(); } HTTPClient::~HTTPClient() {} diff --git a/core/io/image.cpp b/core/io/image.cpp index 9cd0ea7b5dd..25d9eab3fe3 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -1945,7 +1945,7 @@ Error Image::generate_mipmap_roughness(RoughnessChannel p_roughness_channel, con memcpy(wr.ptr(), ptr, size); wr = uint8_t*(); Ref im; - im.instance(); + im.instantiate(); im->create(w, h, false, format, imgdata); im->save_png("res://mipmap_" + itos(i) + ".png"); } @@ -3280,7 +3280,7 @@ Ref Image::rgbe_to_srgb() { ERR_FAIL_COND_V(format != FORMAT_RGBE9995, Ref()); Ref new_image; - new_image.instance(); + new_image.instantiate(); new_image->create(width, height, false, Image::FORMAT_RGB8); for (int row = 0; row < height; row++) { @@ -3310,7 +3310,7 @@ Ref Image::get_image_from_mipmap(int p_mipamp) const { } Ref image; - image.instance(); + image.instantiate(); image->width = w; image->height = h; image->format = format; @@ -3627,7 +3627,7 @@ Image::Image(const uint8_t *p_mem_png_jpg, int p_len) { Ref Image::duplicate(bool p_subresources) const { Ref copy; - copy.instance(); + copy.instantiate(); copy->_copy_internals_from(*this); return copy; } diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index 7de038e6fe5..b45e9d26b1b 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -163,7 +163,7 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String &p_origin } Ref image; - image.instance(); + image.instantiate(); Error err = ImageLoader::loader[idx]->load_image(image, f, false, 1.0); diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index c447e11ee76..f342db2dad0 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -547,7 +547,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int r_variant = (Object *)nullptr; } else { Ref obj_as_id; - obj_as_id.instance(); + obj_as_id.instantiate(); obj_as_id->set_object_id(val); r_variant = obj_as_id; @@ -565,7 +565,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int if (str == String()) { r_variant = (Object *)nullptr; } else { - Object *obj = ClassDB::instance(str); + Object *obj = ClassDB::instantiate(str); ERR_FAIL_COND_V(!obj, ERR_UNAVAILABLE); ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA); diff --git a/core/io/resource.cpp b/core/io/resource.cpp index b970e85c992..efa622d976a 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -164,7 +164,7 @@ Ref Resource::duplicate_for_local_scene(Node *p_for_scene, Map plist; get_property_list(&plist); - Ref r = Object::cast_to(ClassDB::instance(get_class())); + Ref r = Object::cast_to(ClassDB::instantiate(get_class())); ERR_FAIL_COND_V(r.is_null(), Ref()); r->local_scene = p_for_scene; @@ -224,7 +224,7 @@ Ref Resource::duplicate(bool p_subresources) const { List plist; get_property_list(&plist); - Ref r = (Resource *)ClassDB::instance(get_class()); + Ref r = (Resource *)ClassDB::instantiate(get_class()); ERR_FAIL_COND_V(r.is_null(), Ref()); for (List::Element *E = plist.front(); E; E = E->next()) { diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index f83ba305142..0e9815245f8 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -704,7 +704,7 @@ Error ResourceLoaderBinary::load() { if (res.is_null()) { //did not replace - Object *obj = ClassDB::instance(t); + Object *obj = ClassDB::instantiate(t); if (!obj) { error = ERR_FILE_CORRUPT; ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, local_path + ":Resource of unrecognized type in file: " + t + "."); diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 1700766cbf6..c5dfe1f2b05 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -1045,7 +1045,7 @@ bool ResourceLoader::add_custom_resource_format_loader(String script_path) { bool valid_type = ClassDB::is_parent_class(ibt, "ResourceFormatLoader"); ERR_FAIL_COND_V_MSG(!valid_type, false, "Script does not inherit a CustomResourceLoader: " + script_path + "."); - Object *obj = ClassDB::instance(ibt); + Object *obj = ClassDB::instantiate(ibt); ERR_FAIL_COND_V_MSG(obj == nullptr, false, "Cannot instance script as custom resource loader, expected 'ResourceFormatLoader' inheritance, got: " + String(ibt) + "."); diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 389a4fdbbd3..80cb85fba3d 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -210,7 +210,7 @@ bool ResourceSaver::add_custom_resource_format_saver(String script_path) { bool valid_type = ClassDB::is_parent_class(ibt, "ResourceFormatSaver"); ERR_FAIL_COND_V_MSG(!valid_type, false, "Script does not inherit a CustomResourceSaver: " + script_path + "."); - Object *obj = ClassDB::instance(ibt); + Object *obj = ClassDB::instantiate(ibt); ERR_FAIL_COND_V_MSG(obj == nullptr, false, "Cannot instance script as custom resource saver, expected 'ResourceFormatSaver' inheritance, got: " + String(ibt) + "."); diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp index ee5e9eca0c3..27f8d4e88fa 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -512,7 +512,7 @@ void StreamPeerBuffer::clear() { Ref StreamPeerBuffer::duplicate() const { Ref spb; - spb.instance(); + spb.instantiate(); spb->data = data; return spb; } diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index 5bf874ccae1..df36587662c 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -516,7 +516,7 @@ void ClassDB::instance_get_native_extension_data(ObjectNativeExtension **r_exten } } -Object *ClassDB::instance(const StringName &p_class) { +Object *ClassDB::instantiate(const StringName &p_class) { ClassInfo *ti; { OBJTYPE_RLOCK; @@ -544,7 +544,7 @@ Object *ClassDB::instance(const StringName &p_class) { return ti->creation_func(); } -bool ClassDB::can_instance(const StringName &p_class) { +bool ClassDB::can_instantiate(const StringName &p_class) { OBJTYPE_RLOCK; ClassInfo *ti = classes.getptr(p_class); @@ -1522,8 +1522,8 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con if (Engine::get_singleton()->has_singleton(p_class)) { c = Engine::get_singleton()->get_singleton_object(p_class); cleanup_c = false; - } else if (ClassDB::can_instance(p_class)) { - c = ClassDB::instance(p_class); + } else if (ClassDB::can_instantiate(p_class)) { + c = ClassDB::instantiate(p_class); cleanup_c = true; } diff --git a/core/object/class_db.h b/core/object/class_db.h index 4355c9b0eaa..a4af535149c 100644 --- a/core/object/class_db.h +++ b/core/object/class_db.h @@ -230,8 +230,8 @@ public: static StringName get_compatibility_remapped_class(const StringName &p_class); static bool class_exists(const StringName &p_class); static bool is_parent_class(const StringName &p_class, const StringName &p_inherits); - static bool can_instance(const StringName &p_class); - static Object *instance(const StringName &p_class); + static bool can_instantiate(const StringName &p_class); + static Object *instantiate(const StringName &p_class); static void instance_get_native_extension_data(ObjectNativeExtension **r_extension, void **r_extension_instance); static APIType get_api_type(const StringName &p_class); diff --git a/core/object/object.cpp b/core/object/object.cpp index 799e63a512d..bad40f14d97 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -871,7 +871,7 @@ void Object::set_script(const Variant &p_script) { Ref