diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2021-06-04 18:03:15 +0200 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2021-06-11 18:48:42 +0200 |
commit | 04688b92fff1d6bbec9335b354f3751ddc473379 (patch) | |
tree | f4d61f5877c7183bf6ded23878839b2124f6ecd4 /modules | |
parent | fbb5a541ef30f41bb7814687e9cd9f11e991faa7 (diff) |
Rename Reference to RefCounted
Diffstat (limited to 'modules')
63 files changed, 203 insertions, 203 deletions
diff --git a/modules/csg/csg.h b/modules/csg/csg.h index 4bd79e15a9..c872860486 100644 --- a/modules/csg/csg.h +++ b/modules/csg/csg.h @@ -36,7 +36,7 @@ #include "core/math/transform_3d.h" #include "core/math/vector2.h" #include "core/math/vector3.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "core/templates/list.h" #include "core/templates/map.h" #include "core/templates/oa_hash_map.h" diff --git a/modules/fbx/data/fbx_bone.h b/modules/fbx/data/fbx_bone.h index efba147b89..83918ad1e2 100644 --- a/modules/fbx/data/fbx_bone.h +++ b/modules/fbx/data/fbx_bone.h @@ -38,7 +38,7 @@ struct PivotTransform; -struct FBXBone : public Reference { +struct FBXBone : public RefCounted { uint64_t parent_bone_id = 0; uint64_t bone_id = 0; diff --git a/modules/fbx/data/fbx_material.h b/modules/fbx/data/fbx_material.h index 23310b8e1d..5fd4d9212b 100644 --- a/modules/fbx/data/fbx_material.h +++ b/modules/fbx/data/fbx_material.h @@ -33,10 +33,10 @@ #include "tools/import_utils.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "core/string/ustring.h" -struct FBXMaterial : public Reference { +struct FBXMaterial : public RefCounted { String material_name = String(); bool warning_non_pbr_material = false; FBXDocParser::Material *material = nullptr; @@ -266,7 +266,7 @@ struct FBXMaterial : public Reference { /* storing the texture properties like color */ template <class T> - struct TexturePropertyMapping : Reference { + struct TexturePropertyMapping : RefCounted { StandardMaterial3D::TextureParam map_mode = StandardMaterial3D::TextureParam::TEXTURE_ALBEDO; const T property = T(); }; diff --git a/modules/fbx/data/fbx_mesh_data.h b/modules/fbx/data/fbx_mesh_data.h index c4eaa7d170..7486c5c59c 100644 --- a/modules/fbx/data/fbx_mesh_data.h +++ b/modules/fbx/data/fbx_mesh_data.h @@ -78,7 +78,7 @@ struct VertexData { }; // Caches mesh information and instantiates meshes for you using helper functions. -struct FBXMeshData : Reference { +struct FBXMeshData : RefCounted { struct MorphVertexData { // TODO we have only these?? /// Each element is a vertex. Not supposed to be void. diff --git a/modules/fbx/data/fbx_node.h b/modules/fbx/data/fbx_node.h index a6f62f3388..75461e397d 100644 --- a/modules/fbx/data/fbx_node.h +++ b/modules/fbx/data/fbx_node.h @@ -40,7 +40,7 @@ class Node3D; struct PivotTransform; -struct FBXNode : Reference, ModelAbstraction { +struct FBXNode : RefCounted, ModelAbstraction { uint64_t current_node_id = 0; String node_name = String(); Node3D *godot_node = nullptr; diff --git a/modules/fbx/data/fbx_skeleton.h b/modules/fbx/data/fbx_skeleton.h index df937cde49..b6103df949 100644 --- a/modules/fbx/data/fbx_skeleton.h +++ b/modules/fbx/data/fbx_skeleton.h @@ -35,14 +35,14 @@ #include "fbx_node.h" #include "model_abstraction.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "scene/3d/skeleton_3d.h" struct FBXNode; struct ImportState; struct FBXBone; -struct FBXSkeleton : Reference { +struct FBXSkeleton : RefCounted { Ref<FBXNode> fbx_node = Ref<FBXNode>(); Vector<Ref<FBXBone>> skeleton_bones = Vector<Ref<FBXBone>>(); Skeleton3D *skeleton = nullptr; diff --git a/modules/fbx/data/pivot_transform.h b/modules/fbx/data/pivot_transform.h index 29cf7a3d0e..099b268075 100644 --- a/modules/fbx/data/pivot_transform.h +++ b/modules/fbx/data/pivot_transform.h @@ -32,7 +32,7 @@ #define PIVOT_TRANSFORM_H #include "core/math/transform_3d.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "model_abstraction.h" @@ -55,7 +55,7 @@ enum TransformationComp { TransformationComp_MAXIMUM }; // Abstract away pivot data so its simpler to handle -struct PivotTransform : Reference, ModelAbstraction { +struct PivotTransform : RefCounted, ModelAbstraction { // at the end we want to keep geometric_ everything, post and pre rotation // these are used during animation data processing / keyframe ingestion the rest can be simplified down / out. Quaternion pre_rotation = Quaternion(); diff --git a/modules/gdnative/doc_classes/GDNative.xml b/modules/gdnative/doc_classes/GDNative.xml index 44d9e32ed8..4f1530598c 100644 --- a/modules/gdnative/doc_classes/GDNative.xml +++ b/modules/gdnative/doc_classes/GDNative.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GDNative" inherits="Reference" version="4.0"> +<class name="GDNative" inherits="RefCounted" version="4.0"> <brief_description> </brief_description> <description> diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h index a28c58ec0d..0cc6487ea4 100644 --- a/modules/gdnative/gdnative.h +++ b/modules/gdnative/gdnative.h @@ -138,8 +138,8 @@ struct GDNativeCallRegistry { Vector<StringName> get_native_call_types(); }; -class GDNative : public Reference { - GDCLASS(GDNative, Reference); +class GDNative : public RefCounted { + GDCLASS(GDNative, RefCounted); Ref<GDNativeLibrary> library; diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp index 24f50a94f5..cfb57137bb 100644 --- a/modules/gdnative/gdnative/variant.cpp +++ b/modules/gdnative/gdnative/variant.cpp @@ -30,7 +30,7 @@ #include "gdnative/variant.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "core/variant/variant.h" #ifdef __cplusplus @@ -200,17 +200,17 @@ void GDAPI godot_variant_new_signal(godot_variant *r_dest, const godot_signal *p void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj) { Variant *dest = (Variant *)r_dest; const Object *obj = (const Object *)p_obj; - const Reference *reference = Object::cast_to<Reference>(obj); + const RefCounted *ref_counted = Object::cast_to<RefCounted>(obj); REF ref; - if (reference) { - ref = REF(reference); + if (ref_counted) { + ref = REF(ref_counted); } if (!ref.is_null()) { memnew_placement_custom(dest, Variant, Variant(ref)); } else { #if defined(DEBUG_METHODS_ENABLED) - if (reference) { - ERR_PRINT("Reference object has 0 refcount in godot_variant_new_object - you lost it somewhere."); + if (ref_counted) { + ERR_PRINT("RefCounted object has 0 refcount in godot_variant_new_object - you lost it somewhere."); } #endif memnew_placement_custom(dest, Variant, Variant(obj)); diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 51e839f015..4ad8901f32 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -121,7 +121,7 @@ struct ClassAPI { String singleton_name; bool is_instantiable = false; // @Unclear - bool is_reference = false; + bool is_ref_counted = false; bool has_indexing = false; // For builtin types. String indexed_type; // For builtin types. bool is_keyed = false; // For builtin types. @@ -254,10 +254,10 @@ List<ClassAPI> generate_c_api_classes() { { List<StringName> inheriters; - ClassDB::get_inheriters_from_class("Reference", &inheriters); - bool is_reference = !!inheriters.find(class_name) || class_name == "Reference"; + ClassDB::get_inheriters_from_class("RefCounted", &inheriters); + bool is_ref_counted = !!inheriters.find(class_name) || class_name == "RefCounted"; // @Unclear - class_api.is_reference = !class_api.is_singleton && is_reference; + class_api.is_ref_counted = !class_api.is_singleton && is_ref_counted; } // constants @@ -509,10 +509,10 @@ List<ClassAPI> generate_c_builtin_api_types() { case Variant::PACKED_VECTOR2_ARRAY: case Variant::PACKED_VECTOR3_ARRAY: case Variant::PACKED_COLOR_ARRAY: - class_api.is_reference = true; + class_api.is_ref_counted = true; break; default: - class_api.is_reference = false; + class_api.is_ref_counted = false; break; } @@ -652,7 +652,7 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) { source.push_back(String("\t\t\"singleton\": ") + (api.is_singleton ? "true" : "false") + ",\n"); source.push_back("\t\t\"singleton_name\": \"" + api.singleton_name + "\",\n"); source.push_back(String("\t\t\"instantiable\": ") + (api.is_instantiable ? "true" : "false") + ",\n"); - source.push_back(String("\t\t\"is_reference\": ") + (api.is_reference ? "true" : "false") + ",\n"); + source.push_back(String("\t\t\"is_ref_counted\": ") + (api.is_ref_counted ? "true" : "false") + ",\n"); source.push_back("\t\t\"constants\": {\n"); for (List<ConstantAPI>::Element *e = api.constants.front(); e; e = e->next()) { @@ -794,7 +794,7 @@ static List<String> generate_c_builtin_api_json(const List<ClassAPI> &p_api) { append_indented(source, vformat(R"("name": "%s",)", class_api.class_name)); append_indented(source, vformat(R"("is_instantiable": %s,)", class_api.is_instantiable ? "true" : "false")); - append_indented(source, vformat(R"("is_reference": %s,)", class_api.is_reference ? "true" : "false")); + append_indented(source, vformat(R"("is_ref_counted": %s,)", class_api.is_ref_counted ? "true" : "false")); append_indented(source, vformat(R"("has_indexing": %s,)", class_api.has_indexing ? "true" : "false")); append_indented(source, vformat(R"("indexed_type": "%s",)", class_api.has_indexing && class_api.indexed_type == "Nil" ? "Variant" : class_api.indexed_type)); append_indented(source, vformat(R"("is_keyed": %s,)", class_api.is_keyed ? "true" : "false")); diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 3f705c7858..6c2d038654 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -505,7 +505,7 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Callable::Cal if (!(script_data->base_native_type == "")) { owner = ClassDB::instance(script_data->base_native_type); } else { - owner = memnew(Reference); + owner = memnew(RefCounted); } if (!owner) { @@ -513,7 +513,7 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Callable::Cal return Variant(); } - Reference *r = Object::cast_to<Reference>(owner); + RefCounted *r = Object::cast_to<RefCounted>(owner); if (r) { ref = REF(r); } diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index 56fc7273f2..1dabb1db63 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -94,7 +94,7 @@ Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::Cal Object *owner = nullptr; if (get_instance_base_type() == "") { - owner = memnew(Reference); + owner = memnew(RefCounted); } else { owner = ClassDB::instance(get_instance_base_type()); } @@ -104,7 +104,7 @@ Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::Cal return Variant(); } - Reference *r = Object::cast_to<Reference>(owner); + RefCounted *r = Object::cast_to<RefCounted>(owner); if (r) { ref = REF(r); } diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index fdbe557956..1aafaf9351 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -75,9 +75,9 @@ Variant GDScriptNativeClass::_new() { Object *o = instance(); ERR_FAIL_COND_V_MSG(!o, Variant(), "Class type: '" + String(name) + "' is not instantiable."); - Reference *ref = Object::cast_to<Reference>(o); - if (ref) { - return REF(ref); + RefCounted *rc = Object::cast_to<RefCounted>(o); + if (rc) { + return REF(rc); } else { return o; } @@ -98,11 +98,11 @@ void GDScript::_super_implicit_constructor(GDScript *p_script, GDScriptInstance p_script->implicit_initializer->call(p_instance, nullptr, 0, r_error); } -GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Callable::CallError &r_error) { +GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_is_ref_counted, Callable::CallError &r_error) { /* STEP 1, CREATE */ GDScriptInstance *instance = memnew(GDScriptInstance); - instance->base_ref = p_isref; + instance->base_ref_counted = p_is_ref_counted; instance->members.resize(member_indices.size()); instance->script = Ref<GDScript>(this); instance->owner = p_owner; @@ -172,11 +172,11 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr if (_baseptr->native.ptr()) { owner = _baseptr->native->instance(); } else { - owner = memnew(Reference); //by default, no base means use reference + owner = memnew(RefCounted); //by default, no base means use reference } ERR_FAIL_COND_V_MSG(!owner, Variant(), "Can't inherit from a virtual class."); - Reference *r = Object::cast_to<Reference>(owner); + RefCounted *r = Object::cast_to<RefCounted>(owner); if (r) { ref = REF(r); } @@ -353,7 +353,7 @@ ScriptInstance *GDScript::instance_create(Object *p_this) { } Callable::CallError unchecked_error; - return _create_instance(nullptr, 0, p_this, Object::cast_to<Reference>(p_this) != nullptr, unchecked_error); + return _create_instance(nullptr, 0, p_this, Object::cast_to<RefCounted>(p_this) != nullptr, unchecked_error); } PlaceHolderScriptInstance *GDScript::placeholder_instance_create(Object *p_this) { @@ -1576,7 +1576,7 @@ void GDScriptInstance::reload_members() { GDScriptInstance::GDScriptInstance() { owner = nullptr; - base_ref = false; + base_ref_counted = false; } GDScriptInstance::~GDScriptInstance() { @@ -2132,7 +2132,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b break; } } else { - *r_base_type = "Reference"; + *r_base_type = "RefCounted"; subclass = nullptr; } } diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index 8b1b859ca2..0584ced35e 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -39,8 +39,8 @@ #include "core/object/script_language.h" #include "gdscript_function.h" -class GDScriptNativeClass : public Reference { - GDCLASS(GDScriptNativeClass, Reference); +class GDScriptNativeClass : public RefCounted { + GDCLASS(GDScriptNativeClass, RefCounted); StringName name; @@ -132,7 +132,7 @@ class GDScript : public Script { SelfList<GDScriptFunctionState>::List pending_func_states; void _super_implicit_constructor(GDScript *p_script, GDScriptInstance *p_instance, Callable::CallError &r_error); - GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Callable::CallError &r_error); + GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_is_ref_counted, Callable::CallError &r_error); void _set_subclass_path(Ref<GDScript> &p_sc, const String &p_path); @@ -157,7 +157,7 @@ class GDScript : public Script { void _get_script_method_list(List<MethodInfo> *r_list, bool p_include_base) const; void _get_script_signal_list(List<MethodInfo> *r_list, bool p_include_base) const; - // This method will map the class name from "Reference" to "MyClass.InnerClass". + // This method will map the class name from "RefCounted" to "MyClass.InnerClass". static String _get_gdscript_reference_class_name(const GDScript *p_gdscript); protected: @@ -270,7 +270,7 @@ class GDScriptInstance : public ScriptInstance { Map<StringName, int> member_indices_cache; //used only for hot script reloading #endif Vector<Variant> members; - bool base_ref; + bool base_ref_counted; SelfList<GDScriptFunctionState>::List pending_func_states; diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index e901b74616..c3edc813d2 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -163,7 +163,7 @@ Error GDScriptAnalyzer::resolve_inheritance(GDScriptParser::ClassNode *p_class, if (!p_class->extends_used) { result.type_source = GDScriptParser::DataType::ANNOTATED_INFERRED; result.kind = GDScriptParser::DataType::NATIVE; - result.native_type = "Reference"; + result.native_type = "RefCounted"; } else { result.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT; diff --git a/modules/gdscript/gdscript_analyzer.h b/modules/gdscript/gdscript_analyzer.h index aabf407c76..8cd3fcf837 100644 --- a/modules/gdscript/gdscript_analyzer.h +++ b/modules/gdscript/gdscript_analyzer.h @@ -32,7 +32,7 @@ #define GDSCRIPT_ANALYZER_H #include "core/object/object.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "core/templates/set.h" #include "gdscript_cache.h" #include "gdscript_parser.h" diff --git a/modules/gdscript/gdscript_cache.h b/modules/gdscript/gdscript_cache.h index d1d2a2abbf..943638d29f 100644 --- a/modules/gdscript/gdscript_cache.h +++ b/modules/gdscript/gdscript_cache.h @@ -31,7 +31,7 @@ #ifndef GDSCRIPT_CACHE_H #define GDSCRIPT_CACHE_H -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "core/os/mutex.h" #include "core/templates/hash_map.h" #include "core/templates/set.h" @@ -40,7 +40,7 @@ class GDScriptAnalyzer; class GDScriptParser; -class GDScriptParserRef : public Reference { +class GDScriptParserRef : public RefCounted { public: enum Status { EMPTY, diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 49da4049bb..6d6b9e15af 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -2512,7 +2512,7 @@ Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptPa p_script->placeholders.erase(psi); //remove placeholder GDScriptInstance *instance = memnew(GDScriptInstance); - instance->base_ref = Object::cast_to<Reference>(E->get()); + instance->base_ref_counted = Object::cast_to<RefCounted>(E->get()); instance->members.resize(p_script->member_indices.size()); instance->script = Ref<GDScript>(p_script); instance->owner = E->get(); diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h index cd1704cb03..553c2ecc01 100644 --- a/modules/gdscript/gdscript_function.h +++ b/modules/gdscript/gdscript_function.h @@ -31,7 +31,7 @@ #ifndef GDSCRIPT_FUNCTION_H #define GDSCRIPT_FUNCTION_H -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "core/object/script_language.h" #include "core/os/thread.h" #include "core/string/string_name.h" @@ -597,8 +597,8 @@ public: ~GDScriptFunction(); }; -class GDScriptFunctionState : public Reference { - GDCLASS(GDScriptFunctionState, Reference); +class GDScriptFunctionState : public RefCounted { + GDCLASS(GDScriptFunctionState, RefCounted); friend class GDScriptFunction; GDScriptFunction *function = nullptr; GDScriptFunction::CallState state; diff --git a/modules/gdscript/gdscript_lambda_callable.h b/modules/gdscript/gdscript_lambda_callable.h index 357c845250..336778d549 100644 --- a/modules/gdscript/gdscript_lambda_callable.h +++ b/modules/gdscript/gdscript_lambda_callable.h @@ -31,7 +31,7 @@ #ifndef GDSCRIPT_LAMBDA_CALLABLE #define GDSCRIPT_LAMBDA_CALLABLE -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "core/templates/vector.h" #include "core/variant/callable.h" #include "core/variant/variant.h" diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index ee5e411cad..9e0b60a407 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -33,7 +33,7 @@ #include "core/io/multiplayer_api.h" #include "core/io/resource.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "core/object/script_language.h" #include "core/string/string_name.h" #include "core/string/ustring.h" diff --git a/modules/gdscript/language_server/gdscript_language_protocol.h b/modules/gdscript/language_server/gdscript_language_protocol.h index a5c5a233b1..969c38eab6 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.h +++ b/modules/gdscript/language_server/gdscript_language_protocol.h @@ -46,7 +46,7 @@ class GDScriptLanguageProtocol : public JSONRPC { GDCLASS(GDScriptLanguageProtocol, JSONRPC) private: - struct LSPeer : Reference { + struct LSPeer : RefCounted { Ref<StreamPeerTCP> connection; uint8_t req_buf[LSP_MAX_BUFFER_SIZE]; diff --git a/modules/gdscript/language_server/gdscript_text_document.h b/modules/gdscript/language_server/gdscript_text_document.h index 4696966e85..17f1d5d5e3 100644 --- a/modules/gdscript/language_server/gdscript_text_document.h +++ b/modules/gdscript/language_server/gdscript_text_document.h @@ -32,11 +32,11 @@ #define GDSCRIPT_TEXT_DOCUMENT_H #include "core/io/file_access.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "lsp.hpp" -class GDScriptTextDocument : public Reference { - GDCLASS(GDScriptTextDocument, Reference) +class GDScriptTextDocument : public RefCounted { + GDCLASS(GDScriptTextDocument, RefCounted) protected: static void _bind_methods(); diff --git a/modules/gdscript/language_server/gdscript_workspace.h b/modules/gdscript/language_server/gdscript_workspace.h index 27616a2989..8b166a873c 100644 --- a/modules/gdscript/language_server/gdscript_workspace.h +++ b/modules/gdscript/language_server/gdscript_workspace.h @@ -37,8 +37,8 @@ #include "gdscript_extend_parser.h" #include "lsp.hpp" -class GDScriptWorkspace : public Reference { - GDCLASS(GDScriptWorkspace, Reference); +class GDScriptWorkspace : public RefCounted { + GDCLASS(GDScriptWorkspace, RefCounted); private: void _get_owners(EditorFileSystemDirectory *efsd, String p_path, List<String> &owners); diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp index 47bcfeaefc..a7dcfdb22d 100644 --- a/modules/gdscript/language_server/lsp.hpp +++ b/modules/gdscript/language_server/lsp.hpp @@ -766,7 +766,7 @@ struct MarkupContent { // Use namespace instead of enumeration to follow the LSP specifications // lsp::EnumName::EnumValue is OK but lsp::EnumValue is not -// And here C++ compilers are unhappy with our enumeration name like Color, File, Reference etc. +// And here C++ compilers are unhappy with our enumeration name like Color, File, RefCounted etc. /** * The kind of a completion entry. */ @@ -788,7 +788,7 @@ static const int Keyword = 14; static const int Snippet = 15; static const int Color = 16; static const int File = 17; -static const int Reference = 18; +static const int RefCounted = 18; static const int Folder = 19; static const int EnumMember = 20; static const int Constant = 21; diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp index cda348f774..67bc927517 100644 --- a/modules/gdscript/tests/gdscript_test_runner.cpp +++ b/modules/gdscript/tests/gdscript_test_runner.cpp @@ -511,9 +511,9 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) { // Create object instance for test. Object *obj = ClassDB::instance(script->get_native()->get_name()); - Ref<Reference> obj_ref; - if (obj->is_reference()) { - obj_ref = Ref<Reference>(Object::cast_to<Reference>(obj)); + Ref<RefCounted> obj_ref; + if (obj->is_ref_counted()) { + obj_ref = Ref<RefCounted>(Object::cast_to<RefCounted>(obj)); } obj->set_script(script); GDScriptInstance *instance = static_cast<GDScriptInstance *>(obj->get_script_instance()); diff --git a/modules/gdscript/tests/gdscript_test_runner_suite.h b/modules/gdscript/tests/gdscript_test_runner_suite.h index 8fd77239cd..cf4e61f07d 100644 --- a/modules/gdscript/tests/gdscript_test_runner_suite.h +++ b/modules/gdscript/tests/gdscript_test_runner_suite.h @@ -51,7 +51,7 @@ TEST_SUITE("[Modules][GDScript]") { TEST_CASE("[Modules][GDScript] Load source code dynamically and run it") { Ref<GDScript> gdscript = memnew(GDScript); gdscript->set_source_code(R"( -extends Reference +extends RefCounted func _init(): set_meta("result", 42) @@ -64,9 +64,9 @@ func _init(): CHECK_MESSAGE(error == OK, "The script should parse successfully."); // Run the script by assigning it to a reference-counted object. - Ref<Reference> reference = memnew(Reference); - reference->set_script(gdscript); - CHECK_MESSAGE(int(reference->get_meta("result")) == 42, "The script should assign object metadata successfully."); + Ref<RefCounted> ref_counted = memnew(RefCounted); + ref_counted->set_script(gdscript); + CHECK_MESSAGE(int(ref_counted->get_meta("result")) == 42, "The script should assign object metadata successfully."); } } // namespace GDScriptTests diff --git a/modules/mbedtls/ssl_context_mbedtls.h b/modules/mbedtls/ssl_context_mbedtls.h index f8f9502caf..1b55a54a10 100644 --- a/modules/mbedtls/ssl_context_mbedtls.h +++ b/modules/mbedtls/ssl_context_mbedtls.h @@ -35,7 +35,7 @@ #include "core/io/file_access.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include <mbedtls/config.h> #include <mbedtls/ctr_drbg.h> @@ -46,7 +46,7 @@ class SSLContextMbedTLS; -class CookieContextMbedTLS : public Reference { +class CookieContextMbedTLS : public RefCounted { friend class SSLContextMbedTLS; protected: @@ -63,7 +63,7 @@ public: ~CookieContextMbedTLS(); }; -class SSLContextMbedTLS : public Reference { +class SSLContextMbedTLS : public RefCounted { protected: bool inited = false; diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 80333321c3..6fbefd88ac 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -863,13 +863,13 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { List<Ref<CSharpScript>> to_reload; // We need to keep reference instances alive during reloading - List<Ref<Reference>> ref_instances; + List<Ref<RefCounted>> rc_instances; for (Map<Object *, CSharpScriptBinding>::Element *E = script_bindings.front(); E; E = E->next()) { CSharpScriptBinding &script_binding = E->value(); - Reference *ref = Object::cast_to<Reference>(script_binding.owner); - if (ref) { - ref_instances.push_back(Ref<Reference>(ref)); + RefCounted *rc = Object::cast_to<RefCounted>(script_binding.owner); + if (rc) { + rc_instances.push_back(Ref<RefCounted>(rc)); } } @@ -892,9 +892,9 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { Object *obj = F->get(); script->pending_reload_instances.insert(obj->get_instance_id()); - Reference *ref = Object::cast_to<Reference>(obj); - if (ref) { - ref_instances.push_back(Ref<Reference>(ref)); + RefCounted *rc = Object::cast_to<RefCounted>(obj); + if (rc) { + rc_instances.push_back(Ref<RefCounted>(rc)); } } @@ -903,9 +903,9 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { Object *obj = F->get()->get_owner(); script->pending_reload_instances.insert(obj->get_instance_id()); - Reference *ref = Object::cast_to<Reference>(obj); - if (ref) { - ref_instances.push_back(Ref<Reference>(ref)); + RefCounted *rc = Object::cast_to<RefCounted>(obj); + if (rc) { + rc_instances.push_back(Ref<RefCounted>(rc)); } } #endif @@ -1438,16 +1438,16 @@ bool CSharpLanguage::setup_csharp_script_binding(CSharpScriptBinding &r_script_b r_script_binding.owner = p_object; // Tie managed to unmanaged - Reference *ref = Object::cast_to<Reference>(p_object); + RefCounted *rc = Object::cast_to<RefCounted>(p_object); - if (ref) { + if (rc) { // Unsafe refcount increment. The managed instance also counts as a reference. // This way if the unmanaged world has no references to our owner // but the managed instance is alive, the refcount will be 1 instead of 0. // See: godot_icall_Reference_Dtor(MonoObject *p_obj, Object *p_ptr) - ref->reference(); - CSharpLanguage::get_singleton()->post_unsafe_reference(ref); + rc->reference(); + CSharpLanguage::get_singleton()->post_unsafe_reference(rc); } return true; @@ -1511,10 +1511,10 @@ void CSharpLanguage::free_instance_binding_data(void *p_data) { } void CSharpLanguage::refcount_incremented_instance_binding(Object *p_object) { - Reference *ref_owner = Object::cast_to<Reference>(p_object); + RefCounted *rc_owner = Object::cast_to<RefCounted>(p_object); #ifdef DEBUG_ENABLED - CRASH_COND(!ref_owner); + CRASH_COND(!rc_owner); CRASH_COND(!p_object->has_script_instance_binding(get_language_index())); #endif @@ -1528,7 +1528,7 @@ void CSharpLanguage::refcount_incremented_instance_binding(Object *p_object) { return; } - if (ref_owner->reference_get_count() > 1 && gchandle.is_weak()) { // The managed side also holds a reference, hence 1 instead of 0 + if (rc_owner->reference_get_count() > 1 && gchandle.is_weak()) { // The managed side also holds a reference, hence 1 instead of 0 GD_MONO_SCOPE_THREAD_ATTACH; // The reference count was increased after the managed side was the only one referencing our owner. @@ -1548,10 +1548,10 @@ void CSharpLanguage::refcount_incremented_instance_binding(Object *p_object) { } bool CSharpLanguage::refcount_decremented_instance_binding(Object *p_object) { - Reference *ref_owner = Object::cast_to<Reference>(p_object); + RefCounted *rc_owner = Object::cast_to<RefCounted>(p_object); #ifdef DEBUG_ENABLED - CRASH_COND(!ref_owner); + CRASH_COND(!rc_owner); CRASH_COND(!p_object->has_script_instance_binding(get_language_index())); #endif @@ -1561,7 +1561,7 @@ bool CSharpLanguage::refcount_decremented_instance_binding(Object *p_object) { CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->get(); MonoGCHandleData &gchandle = script_binding.gchandle; - int refcount = ref_owner->reference_get_count(); + int refcount = rc_owner->reference_get_count(); if (!script_binding.inited) { return refcount == 0; @@ -1592,13 +1592,13 @@ bool CSharpLanguage::refcount_decremented_instance_binding(Object *p_object) { CSharpInstance *CSharpInstance::create_for_managed_type(Object *p_owner, CSharpScript *p_script, const MonoGCHandleData &p_gchandle) { CSharpInstance *instance = memnew(CSharpInstance(Ref<CSharpScript>(p_script))); - Reference *ref = Object::cast_to<Reference>(p_owner); + RefCounted *rc = Object::cast_to<RefCounted>(p_owner); - instance->base_ref = ref != nullptr; + instance->base_ref_counted = rc != nullptr; instance->owner = p_owner; instance->gchandle = p_gchandle; - if (instance->base_ref) { + if (instance->base_ref_counted) { instance->_reference_owner_unsafe(); } @@ -1900,7 +1900,7 @@ Variant CSharpInstance::call(const StringName &p_method, const Variant **p_args, bool CSharpInstance::_reference_owner_unsafe() { #ifdef DEBUG_ENABLED - CRASH_COND(!base_ref); + CRASH_COND(!base_ref_counted); CRASH_COND(owner == nullptr); CRASH_COND(unsafe_referenced); // already referenced #endif @@ -1911,7 +1911,7 @@ bool CSharpInstance::_reference_owner_unsafe() { // See: _unreference_owner_unsafe() // May not me referenced yet, so we must use init_ref() instead of reference() - if (static_cast<Reference *>(owner)->init_ref()) { + if (static_cast<RefCounted *>(owner)->init_ref()) { CSharpLanguage::get_singleton()->post_unsafe_reference(owner); unsafe_referenced = true; } @@ -1921,7 +1921,7 @@ bool CSharpInstance::_reference_owner_unsafe() { bool CSharpInstance::_unreference_owner_unsafe() { #ifdef DEBUG_ENABLED - CRASH_COND(!base_ref); + CRASH_COND(!base_ref_counted); CRASH_COND(owner == nullptr); #endif @@ -1938,7 +1938,7 @@ bool CSharpInstance::_unreference_owner_unsafe() { // Destroying the owner here means self destructing, so we defer the owner destruction to the caller. CSharpLanguage::get_singleton()->pre_unsafe_unreference(owner); - return static_cast<Reference *>(owner)->unreference(); + return static_cast<RefCounted *>(owner)->unreference(); } MonoObject *CSharpInstance::_internal_new_managed() { @@ -1970,7 +1970,7 @@ MonoObject *CSharpInstance::_internal_new_managed() { // Tie managed to unmanaged gchandle = MonoGCHandleData::new_strong_handle(mono_object); - if (base_ref) { + if (base_ref_counted) { _reference_owner_unsafe(); // Here, after assigning the gchandle (for the refcount_incremented callback) } @@ -1987,7 +1987,7 @@ void CSharpInstance::mono_object_disposed(MonoObject *p_obj) { disconnect_event_signals(); #ifdef DEBUG_ENABLED - CRASH_COND(base_ref); + CRASH_COND(base_ref_counted); CRASH_COND(gchandle.is_released()); #endif CSharpLanguage::get_singleton()->release_script_gchandle(p_obj, gchandle); @@ -1995,7 +1995,7 @@ void CSharpInstance::mono_object_disposed(MonoObject *p_obj) { void CSharpInstance::mono_object_disposed_baseref(MonoObject *p_obj, bool p_is_finalizer, bool &r_delete_owner, bool &r_remove_script_instance) { #ifdef DEBUG_ENABLED - CRASH_COND(!base_ref); + CRASH_COND(!base_ref_counted); CRASH_COND(gchandle.is_released()); #endif @@ -2056,13 +2056,13 @@ void CSharpInstance::disconnect_event_signals() { void CSharpInstance::refcount_incremented() { #ifdef DEBUG_ENABLED - CRASH_COND(!base_ref); + CRASH_COND(!base_ref_counted); CRASH_COND(owner == nullptr); #endif - Reference *ref_owner = Object::cast_to<Reference>(owner); + RefCounted *rc_owner = Object::cast_to<RefCounted>(owner); - if (ref_owner->reference_get_count() > 1 && gchandle.is_weak()) { // The managed side also holds a reference, hence 1 instead of 0 + if (rc_owner->reference_get_count() > 1 && gchandle.is_weak()) { // The managed side also holds a reference, hence 1 instead of 0 GD_MONO_SCOPE_THREAD_ATTACH; // The reference count was increased after the managed side was the only one referencing our owner. @@ -2078,13 +2078,13 @@ void CSharpInstance::refcount_incremented() { bool CSharpInstance::refcount_decremented() { #ifdef DEBUG_ENABLED - CRASH_COND(!base_ref); + CRASH_COND(!base_ref_counted); CRASH_COND(owner == nullptr); #endif - Reference *ref_owner = Object::cast_to<Reference>(owner); + RefCounted *rc_owner = Object::cast_to<RefCounted>(owner); - int refcount = ref_owner->reference_get_count(); + int refcount = rc_owner->reference_get_count(); if (refcount == 1 && !gchandle.is_weak()) { // The managed side also holds a reference, hence 1 instead of 0 GD_MONO_SCOPE_THREAD_ATTACH; @@ -2119,12 +2119,12 @@ void CSharpInstance::notification(int p_notification) { predelete_notified = true; - if (base_ref) { - // It's not safe to proceed if the owner derives Reference and the refcount reached 0. + if (base_ref_counted) { + // It's not safe to proceed if the owner derives RefCounted and the refcount reached 0. // At this point, Dispose() was already called (manually or from the finalizer) so // that's not a problem. The refcount wouldn't have reached 0 otherwise, since the // managed side references it and Dispose() needs to be called to release it. - // However, this means C# Reference scripts can't receive NOTIFICATION_PREDELETE, but + // However, this means C# RefCounted scripts can't receive NOTIFICATION_PREDELETE, but // this is likely the case with GDScript as well: https://github.com/godotengine/godot/issues/6784 return; } @@ -2250,15 +2250,15 @@ CSharpInstance::~CSharpInstance() { } // If not being called from the owner's destructor, and we still hold a reference to the owner - if (base_ref && !ref_dying && owner && unsafe_referenced) { + if (base_ref_counted && !ref_dying && owner && unsafe_referenced) { // The owner's script or script instance is being replaced (or removed) // Transfer ownership to an "instance binding" - Reference *ref_owner = static_cast<Reference *>(owner); + RefCounted *rc_owner = static_cast<RefCounted *>(owner); // We will unreference the owner before referencing it again, so we need to keep it alive - Ref<Reference> scope_keep_owner_alive(ref_owner); + Ref<RefCounted> scope_keep_owner_alive(rc_owner); (void)scope_keep_owner_alive; // Unreference the owner here, before the new "instance binding" references it. @@ -2283,7 +2283,7 @@ CSharpInstance::~CSharpInstance() { #ifdef DEBUG_ENABLED // The "instance binding" holds a reference so the refcount should be at least 2 before `scope_keep_owner_alive` goes out of scope - CRASH_COND(ref_owner->reference_get_count() <= 1); + CRASH_COND(rc_owner->reference_get_count() <= 1); #endif } @@ -2511,7 +2511,7 @@ bool CSharpScript::_update_exports() { #ifdef TOOLS_ENABLED if (is_editor) { // Need to check this here, before disposal - bool base_ref = Object::cast_to<Reference>(tmp_native) != nullptr; + bool base_ref_counted = Object::cast_to<RefCounted>(tmp_native) != nullptr; // Dispose the temporary managed instance @@ -2526,7 +2526,7 @@ bool CSharpScript::_update_exports() { GDMonoUtils::free_gchandle(tmp_pinned_gchandle); tmp_object = nullptr; - if (tmp_native && !base_ref) { + if (tmp_native && !base_ref_counted) { Node *node = Object::cast_to<Node>(tmp_native); if (node && node->is_inside_tree()) { ERR_PRINT("Temporary instance was added to the scene tree."); @@ -3077,7 +3077,7 @@ StringName CSharpScript::get_instance_base_type() const { } } -CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Callable::CallError &r_error) { +CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_is_ref_counted, Callable::CallError &r_error) { GD_MONO_ASSERT_THREAD_ATTACHED; /* STEP 1, CREATE */ @@ -3093,10 +3093,10 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg ERR_FAIL_V_MSG(nullptr, "Constructor not found."); } - Ref<Reference> ref; - if (p_isref) { + Ref<RefCounted> ref; + if (p_is_ref_counted) { // Hold it alive. Important if we have to dispose a script instance binding before creating the CSharpInstance. - ref = Ref<Reference>(static_cast<Reference *>(p_owner)); + ref = Ref<RefCounted>(static_cast<RefCounted *>(p_owner)); } // If the object had a script instance binding, dispose it before adding the CSharpInstance @@ -3122,7 +3122,7 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg } CSharpInstance *instance = memnew(CSharpInstance(Ref<CSharpScript>(this))); - instance->base_ref = p_isref; + instance->base_ref_counted = p_is_ref_counted; instance->owner = p_owner; instance->owner->set_script_instance(instance); @@ -3147,7 +3147,7 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg // Tie managed to unmanaged instance->gchandle = MonoGCHandleData::new_strong_handle(mono_object); - if (instance->base_ref) { + if (instance->base_ref_counted) { instance->_reference_owner_unsafe(); // Here, after assigning the gchandle (for the refcount_incremented callback) } @@ -3182,7 +3182,7 @@ Variant CSharpScript::_new(const Variant **p_args, int p_argcount, Callable::Cal Object *owner = ClassDB::instance(NATIVE_GDMONOCLASS_NAME(native)); REF ref; - Reference *r = Object::cast_to<Reference>(owner); + RefCounted *r = Object::cast_to<RefCounted>(owner); if (r) { ref = REF(r); } @@ -3223,7 +3223,7 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) { GD_MONO_SCOPE_THREAD_ATTACH; Callable::CallError unchecked_error; - return _create_instance(nullptr, 0, p_this, Object::cast_to<Reference>(p_this) != nullptr, unchecked_error); + return _create_instance(nullptr, 0, p_this, Object::cast_to<RefCounted>(p_this) != nullptr, unchecked_error); } PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_this) { diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index b389e900f4..c347a902ed 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -170,7 +170,7 @@ private: static int _try_get_member_export_hint(IMonoClassMember *p_member, ManagedType p_type, Variant::Type p_variant_type, bool p_allow_generics, PropertyHint &r_hint, String &r_hint_string); #endif - CSharpInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Callable::CallError &r_error); + CSharpInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_is_ref_counted, Callable::CallError &r_error); Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error); // Do not use unless you know what you are doing @@ -251,7 +251,7 @@ class CSharpInstance : public ScriptInstance { friend class CSharpLanguage; Object *owner = nullptr; - bool base_ref = false; + bool base_ref_counted = false; bool ref_dying = false; bool unsafe_referenced = false; bool predelete_notified = false; diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs index 51055dc9b9..27737c3da0 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs @@ -7,7 +7,7 @@ using Path = System.IO.Path; namespace GodotTools.Build { [Serializable] - public sealed class BuildInfo : Reference // TODO Remove Reference once we have proper serialization + public sealed class BuildInfo : RefCounted // TODO Remove RefCounted once we have proper serialization { public string Solution { get; } public string[] Targets { get; } diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs index 1a1639aac7..c380707587 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs @@ -11,7 +11,7 @@ namespace GodotTools.Build public class BuildOutputView : VBoxContainer, ISerializationListener { [Serializable] - private class BuildIssue : Reference // TODO Remove Reference once we have proper serialization + private class BuildIssue : RefCounted // TODO Remove RefCounted once we have proper serialization { public bool Warning { get; set; } public string File { get; set; } diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index adf19cfb8c..b6bff58610 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -1260,7 +1260,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str CRASH_COND(itype.cname != name_cache.type_Object); CRASH_COND(!itype.is_instantiable); CRASH_COND(itype.api_type != ClassDB::API_CORE); - CRASH_COND(itype.is_reference); + CRASH_COND(itype.is_ref_counted); CRASH_COND(itype.is_singleton); } @@ -2284,8 +2284,8 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte } if (return_type->is_object_type) { - ptrcall_return_type = return_type->is_reference ? "Ref<Reference>" : return_type->c_type; - initialization = return_type->is_reference ? "" : " = nullptr"; + ptrcall_return_type = return_type->is_ref_counted ? "Ref<RefCounted>" : return_type->c_type; + initialization = return_type->is_ref_counted ? "" : " = nullptr"; } else { ptrcall_return_type = return_type->c_type; } @@ -2600,12 +2600,12 @@ bool BindingsGenerator::_populate_object_type_interfaces() { itype.base_name = ClassDB::get_parent_class(type_cname); itype.is_singleton = Engine::get_singleton()->has_singleton(itype.proxy_name); itype.is_instantiable = class_info->creation_func && !itype.is_singleton; - itype.is_reference = ClassDB::is_parent_class(type_cname, name_cache.type_Reference); - itype.memory_own = itype.is_reference; + itype.is_ref_counted = ClassDB::is_parent_class(type_cname, name_cache.type_RefCounted); + itype.memory_own = itype.is_ref_counted; itype.c_out = "\treturn "; itype.c_out += C_METHOD_UNMANAGED_GET_MANAGED; - itype.c_out += itype.is_reference ? "(%1.ptr());\n" : "(%1);\n"; + itype.c_out += itype.is_ref_counted ? "(%1.ptr());\n" : "(%1);\n"; itype.cs_in = itype.is_singleton ? BINDINGS_PTR_FIELD : "Object." CS_SMETHOD_GETINSTANCE "(%0)"; @@ -2741,7 +2741,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { imethod.return_type.cname = return_info.class_name; bool bad_reference_hint = !imethod.is_virtual && return_info.hint != PROPERTY_HINT_RESOURCE_TYPE && - ClassDB::is_parent_class(return_info.class_name, name_cache.type_Reference); + ClassDB::is_parent_class(return_info.class_name, name_cache.type_RefCounted); ERR_FAIL_COND_V_MSG(bad_reference_hint, false, String() + "Return type is reference but hint is not '" _STR(PROPERTY_HINT_RESOURCE_TYPE) "'." + " Are you returning a reference type by pointer? Method: '" + itype.name + "." + imethod.name + "'."); diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index 876046176b..48c0e02723 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -216,7 +216,7 @@ class BindingsGenerator { bool is_enum = false; bool is_object_type = false; bool is_singleton = false; - bool is_reference = false; + bool is_ref_counted = false; /** * Used only by Object-derived types. @@ -228,7 +228,7 @@ class BindingsGenerator { /** * Used only by Object-derived types. * Determines if the C# class owns the native handle and must free it somehow when disposed. - * e.g.: Reference types must notify when the C# instance is disposed, for proper refcounting. + * e.g.: RefCounted types must notify when the C# instance is disposed, for proper refcounting. */ bool memory_own = false; @@ -295,7 +295,7 @@ class BindingsGenerator { * VarArg (fictitious type to represent variable arguments): Array * float: double (because ptrcall only supports double) * int: int64_t (because ptrcall only supports int64_t and uint64_t) - * Reference types override this for the type of the return variable: Ref<Reference> + * RefCounted types override this for the type of the return variable: Ref<RefCounted> */ String c_type; @@ -534,7 +534,7 @@ class BindingsGenerator { StringName type_Variant = StaticCString::create("Variant"); StringName type_VarArg = StaticCString::create("VarArg"); StringName type_Object = StaticCString::create("Object"); - StringName type_Reference = StaticCString::create("Reference"); + StringName type_RefCounted = StaticCString::create("RefCounted"); StringName type_RID = StaticCString::create("RID"); StringName type_String = StaticCString::create("String"); StringName type_StringName = StaticCString::create("StringName"); @@ -623,7 +623,7 @@ class BindingsGenerator { } inline String get_unique_sig(const TypeInterface &p_type) { - if (p_type.is_reference) { + if (p_type.is_ref_counted) { return "Ref"; } else if (p_type.is_object_type) { return "Obj"; diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp index 34a96eba17..c1b50b9951 100644 --- a/modules/mono/glue/base_object_glue.cpp +++ b/modules/mono/glue/base_object_glue.cpp @@ -31,7 +31,7 @@ #ifdef MONO_GLUE_ENABLED #include "core/object/class_db.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "core/string/string_name.h" #include "../csharp_script.h" @@ -81,13 +81,13 @@ void godot_icall_Object_Disposed(MonoObject *p_obj, Object *p_ptr) { void godot_icall_Reference_Disposed(MonoObject *p_obj, Object *p_ptr, MonoBoolean p_is_finalizer) { #ifdef DEBUG_ENABLED CRASH_COND(p_ptr == nullptr); - // This is only called with Reference derived classes - CRASH_COND(!Object::cast_to<Reference>(p_ptr)); + // This is only called with RefCounted derived classes + CRASH_COND(!Object::cast_to<RefCounted>(p_ptr)); #endif - Reference *ref = static_cast<Reference *>(p_ptr); + RefCounted *rc = static_cast<RefCounted *>(p_ptr); - if (ref->get_script_instance()) { + if (rc->get_script_instance()) { CSharpInstance *cs_instance = CAST_CSHARP_INSTANCE(ref->get_script_instance()); if (cs_instance) { if (!cs_instance->is_destructing_script_instance()) { @@ -97,9 +97,9 @@ void godot_icall_Reference_Disposed(MonoObject *p_obj, Object *p_ptr, MonoBoolea cs_instance->mono_object_disposed_baseref(p_obj, p_is_finalizer, delete_owner, remove_script_instance); if (delete_owner) { - memdelete(ref); + memdelete(rc); } else if (remove_script_instance) { - ref->set_script_instance(nullptr); + rc->set_script_instance(nullptr); } } return; @@ -145,10 +145,10 @@ MonoObject *godot_icall_Object_weakref(Object *p_ptr) { } Ref<WeakRef> wref; - Reference *ref = Object::cast_to<Reference>(p_ptr); + RefCounted *rc = Object::cast_to<RefCounted>(p_ptr); - if (ref) { - REF r = ref; + if (rc) { + REF r = rc; if (!r.is_valid()) { return nullptr; } diff --git a/modules/mono/glue/glue_header.h b/modules/mono/glue/glue_header.h index 3db52d7c30..eed3bd2167 100644 --- a/modules/mono/glue/glue_header.h +++ b/modules/mono/glue/glue_header.h @@ -61,7 +61,7 @@ void godot_register_glue_header_icalls() { #include "core/config/engine.h" #include "core/object/class_db.h" #include "core/object/method_bind.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "core/string/node_path.h" #include "core/string/ustring.h" #include "core/typedefs.h" diff --git a/modules/mono/mono_gc_handle.h b/modules/mono/mono_gc_handle.h index f435aab3dd..d0e51d159f 100644 --- a/modules/mono/mono_gc_handle.h +++ b/modules/mono/mono_gc_handle.h @@ -33,7 +33,7 @@ #include <mono/jit/jit.h> -#include "core/object/reference.h" +#include "core/object/ref_counted.h" namespace gdmono { @@ -79,8 +79,8 @@ struct MonoGCHandleData { static MonoGCHandleData new_weak_handle(MonoObject *p_object); }; -class MonoGCHandleRef : public Reference { - GDCLASS(MonoGCHandleRef, Reference); +class MonoGCHandleRef : public RefCounted { + GDCLASS(MonoGCHandleRef, RefCounted); MonoGCHandleData data; diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp index fa93c6533a..65fb23b128 100644 --- a/modules/mono/mono_gd/gd_mono_internals.cpp +++ b/modules/mono/mono_gd/gd_mono_internals.cpp @@ -51,7 +51,7 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) { // All mono objects created from the managed world (e.g.: 'new Player()') // need to have a CSharpScript in order for their methods to be callable from the unmanaged side - Reference *ref = Object::cast_to<Reference>(unmanaged); + RefCounted *rc = Object::cast_to<RefCounted>(unmanaged); GDMonoClass *klass = GDMonoUtils::get_object_class(managed); @@ -73,18 +73,18 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) { script_binding.inited = true; script_binding.type_name = NATIVE_GDMONOCLASS_NAME(klass); script_binding.wrapper_class = klass; - script_binding.gchandle = ref ? MonoGCHandleData::new_weak_handle(managed) : MonoGCHandleData::new_strong_handle(managed); + script_binding.gchandle = rc ? MonoGCHandleData::new_weak_handle(managed) : MonoGCHandleData::new_strong_handle(managed); script_binding.owner = unmanaged; - if (ref) { + if (rc) { // Unsafe refcount increment. The managed instance also counts as a reference. // This way if the unmanaged world has no references to our owner // but the managed instance is alive, the refcount will be 1 instead of 0. // See: godot_icall_Reference_Dtor(MonoObject *p_obj, Object *p_ptr) // May not me referenced yet, so we must use init_ref() instead of reference() - if (ref->init_ref()) { - CSharpLanguage::get_singleton()->post_unsafe_reference(ref); + if (rc->init_ref()) { + CSharpLanguage::get_singleton()->post_unsafe_reference(rc); } } @@ -99,7 +99,7 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) { return; } - MonoGCHandleData gchandle = ref ? MonoGCHandleData::new_weak_handle(managed) : MonoGCHandleData::new_strong_handle(managed); + MonoGCHandleData gchandle = rc ? MonoGCHandleData::new_weak_handle(managed) : MonoGCHandleData::new_strong_handle(managed); Ref<CSharpScript> script = CSharpScript::create_for_managed_type(klass, native); diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp index c8f80e7777..9f2977bfa2 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.cpp +++ b/modules/mono/mono_gd/gd_mono_marshal.cpp @@ -1136,8 +1136,8 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type if (CACHED_CLASS(GodotObject)->is_assignable_from(type_class)) { Object *ptr = unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_obj)); if (ptr != nullptr) { - Reference *ref = Object::cast_to<Reference>(ptr); - return ref ? Variant(Ref<Reference>(ref)) : Variant(ptr); + RefCounted *rc = Object::cast_to<RefCounted>(ptr); + return rc ? Variant(Ref<RefCounted>(rc)) : Variant(ptr); } return Variant(); } diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp index 52bdc6ff01..cf2859c319 100644 --- a/modules/mono/mono_gd/gd_mono_utils.cpp +++ b/modules/mono/mono_gd/gd_mono_utils.cpp @@ -36,7 +36,7 @@ #include "core/debugger/engine_debugger.h" #include "core/debugger/script_debugger.h" #include "core/io/dir_access.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "core/os/mutex.h" #include "core/os/os.h" @@ -108,15 +108,15 @@ MonoObject *unmanaged_get_managed(Object *unmanaged) { gchandle = MonoGCHandleData::new_strong_handle(mono_object); // Tie managed to unmanaged - Reference *ref = Object::cast_to<Reference>(unmanaged); + RefCounted *rc = Object::cast_to<RefCounted>(unmanaged); - if (ref) { + if (rc) { // Unsafe refcount increment. The managed instance also counts as a reference. // This way if the unmanaged world has no references to our owner // but the managed instance is alive, the refcount will be 1 instead of 0. // See: godot_icall_Reference_Dtor(MonoObject *p_obj, Object *p_ptr) - ref->reference(); - CSharpLanguage::get_singleton()->post_unsafe_reference(ref); + rc->reference(); + CSharpLanguage::get_singleton()->post_unsafe_reference(rc); } return mono_object; diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h index 9e024418e1..773501e93d 100644 --- a/modules/mono/mono_gd/gd_mono_utils.h +++ b/modules/mono/mono_gd/gd_mono_utils.h @@ -41,7 +41,7 @@ #endif #include "core/object/class_db.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #define UNHANDLED_EXCEPTION(m_exc) \ if (unlikely(m_exc != nullptr)) { \ diff --git a/modules/mono/signal_awaiter_utils.h b/modules/mono/signal_awaiter_utils.h index 4c77f8cfed..e12ea45b3f 100644 --- a/modules/mono/signal_awaiter_utils.h +++ b/modules/mono/signal_awaiter_utils.h @@ -31,7 +31,7 @@ #ifndef SIGNAL_AWAITER_UTILS_H #define SIGNAL_AWAITER_UTILS_H -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "csharp_script.h" #include "mono_gc_handle.h" diff --git a/modules/opensimplex/noise_texture.h b/modules/opensimplex/noise_texture.h index 20a53bb58b..6237b6460d 100644 --- a/modules/opensimplex/noise_texture.h +++ b/modules/opensimplex/noise_texture.h @@ -34,7 +34,7 @@ #include "open_simplex_noise.h" #include "core/io/image.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "editor/editor_node.h" #include "editor/editor_plugin.h" #include "editor/property_editor.h" diff --git a/modules/opensimplex/open_simplex_noise.h b/modules/opensimplex/open_simplex_noise.h index bb50c523d2..dcf922a8bf 100644 --- a/modules/opensimplex/open_simplex_noise.h +++ b/modules/opensimplex/open_simplex_noise.h @@ -32,7 +32,7 @@ #define OPEN_SIMPLEX_NOISE_H #include "core/io/image.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "scene/resources/texture.h" #include "thirdparty/misc/open-simplex-noise.h" diff --git a/modules/pvr/image_compress_pvrtc.cpp b/modules/pvr/image_compress_pvrtc.cpp index 6cb9837f49..4d0430fa92 100644 --- a/modules/pvr/image_compress_pvrtc.cpp +++ b/modules/pvr/image_compress_pvrtc.cpp @@ -31,7 +31,7 @@ #include "image_compress_pvrtc.h" #include "core/io/image.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include <PvrTcEncoder.h> #include <RgbaBitmap.h> diff --git a/modules/raycast/raycast_occlusion_cull.h b/modules/raycast/raycast_occlusion_cull.h index d9ca57cf24..85710a790c 100644 --- a/modules/raycast/raycast_occlusion_cull.h +++ b/modules/raycast/raycast_occlusion_cull.h @@ -34,7 +34,7 @@ #include "core/io/image.h" #include "core/math/camera_matrix.h" #include "core/object/object.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "core/templates/local_vector.h" #include "core/templates/rid_owner.h" #include "scene/resources/mesh.h" diff --git a/modules/regex/doc_classes/RegEx.xml b/modules/regex/doc_classes/RegEx.xml index b21f5d1e7a..7f5a0dfecb 100644 --- a/modules/regex/doc_classes/RegEx.xml +++ b/modules/regex/doc_classes/RegEx.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RegEx" inherits="Reference" version="4.0"> +<class name="RegEx" inherits="RefCounted" version="4.0"> <brief_description> Class for searching text for patterns using regular expressions. </brief_description> diff --git a/modules/regex/doc_classes/RegExMatch.xml b/modules/regex/doc_classes/RegExMatch.xml index a45de60aef..cfe00f83ee 100644 --- a/modules/regex/doc_classes/RegExMatch.xml +++ b/modules/regex/doc_classes/RegExMatch.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RegExMatch" inherits="Reference" version="4.0"> +<class name="RegExMatch" inherits="RefCounted" version="4.0"> <brief_description> Contains the results of a [RegEx] search. </brief_description> diff --git a/modules/regex/regex.h b/modules/regex/regex.h index f5773042fb..68fe2bc6e0 100644 --- a/modules/regex/regex.h +++ b/modules/regex/regex.h @@ -31,15 +31,15 @@ #ifndef REGEX_H #define REGEX_H -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "core/string/ustring.h" #include "core/templates/map.h" #include "core/templates/vector.h" #include "core/variant/array.h" #include "core/variant/dictionary.h" -class RegExMatch : public Reference { - GDCLASS(RegExMatch, Reference); +class RegExMatch : public RefCounted { + GDCLASS(RegExMatch, RefCounted); struct Range { int start = 0; @@ -68,8 +68,8 @@ public: int get_end(const Variant &p_name) const; }; -class RegEx : public Reference { - GDCLASS(RegEx, Reference); +class RegEx : public RefCounted { + GDCLASS(RegEx, RefCounted); void *general_ctx; void *code = nullptr; diff --git a/modules/upnp/doc_classes/UPNP.xml b/modules/upnp/doc_classes/UPNP.xml index 785c8dad50..09a2c8a88c 100644 --- a/modules/upnp/doc_classes/UPNP.xml +++ b/modules/upnp/doc_classes/UPNP.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="UPNP" inherits="Reference" version="4.0"> +<class name="UPNP" inherits="RefCounted" version="4.0"> <brief_description> UPNP network functions. </brief_description> diff --git a/modules/upnp/doc_classes/UPNPDevice.xml b/modules/upnp/doc_classes/UPNPDevice.xml index f3b96bb89d..f7b5386d86 100644 --- a/modules/upnp/doc_classes/UPNPDevice.xml +++ b/modules/upnp/doc_classes/UPNPDevice.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="UPNPDevice" inherits="Reference" version="4.0"> +<class name="UPNPDevice" inherits="RefCounted" version="4.0"> <brief_description> UPNP device. </brief_description> diff --git a/modules/upnp/upnp.h b/modules/upnp/upnp.h index a0cca96bc8..b961a9667f 100644 --- a/modules/upnp/upnp.h +++ b/modules/upnp/upnp.h @@ -31,14 +31,14 @@ #ifndef GODOT_UPNP_H #define GODOT_UPNP_H -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "upnp_device.h" #include <miniupnpc/miniupnpc.h> -class UPNP : public Reference { - GDCLASS(UPNP, Reference); +class UPNP : public RefCounted { + GDCLASS(UPNP, RefCounted); private: String discover_multicast_if = ""; diff --git a/modules/upnp/upnp_device.h b/modules/upnp/upnp_device.h index 126e761a56..0a66c36ab9 100644 --- a/modules/upnp/upnp_device.h +++ b/modules/upnp/upnp_device.h @@ -31,10 +31,10 @@ #ifndef GODOT_UPNP_DEVICE_H #define GODOT_UPNP_DEVICE_H -#include "core/object/reference.h" +#include "core/object/ref_counted.h" -class UPNPDevice : public Reference { - GDCLASS(UPNPDevice, Reference); +class UPNPDevice : public RefCounted { + GDCLASS(UPNPDevice, RefCounted); public: enum IGDStatus { diff --git a/modules/visual_script/doc_classes/VisualScriptFunctionState.xml b/modules/visual_script/doc_classes/VisualScriptFunctionState.xml index 68083614a6..f5bf195bbf 100644 --- a/modules/visual_script/doc_classes/VisualScriptFunctionState.xml +++ b/modules/visual_script/doc_classes/VisualScriptFunctionState.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptFunctionState" inherits="Reference" version="4.0"> +<class name="VisualScriptFunctionState" inherits="RefCounted" version="4.0"> <brief_description> </brief_description> <description> diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index 3c4a26a2a3..438ec99a56 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -449,8 +449,8 @@ public: ~VisualScriptInstance(); }; -class VisualScriptFunctionState : public Reference { - GDCLASS(VisualScriptFunctionState, Reference); +class VisualScriptFunctionState : public RefCounted { + GDCLASS(VisualScriptFunctionState, RefCounted); friend class VisualScriptInstance; ObjectID instance_id; diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index df34ec22ce..a3133f126d 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -33,7 +33,7 @@ #include "core/io/marshalls.h" #include "core/math/math_funcs.h" #include "core/object/class_db.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "core/os/os.h" #include "core/variant/variant_parser.h" diff --git a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml index 3b53892a3d..62e524825d 100644 --- a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml +++ b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="WebRTCPeerConnection" inherits="Reference" version="4.0"> +<class name="WebRTCPeerConnection" inherits="RefCounted" version="4.0"> <brief_description> Interface to a WebRTC peer connection. </brief_description> diff --git a/modules/webrtc/webrtc_multiplayer.h b/modules/webrtc/webrtc_multiplayer.h index 6b4ae6fcc8..2ddb98f656 100644 --- a/modules/webrtc/webrtc_multiplayer.h +++ b/modules/webrtc/webrtc_multiplayer.h @@ -48,7 +48,7 @@ private: CH_RESERVED_MAX = 3 }; - class ConnectedPeer : public Reference { + class ConnectedPeer : public RefCounted { public: Ref<WebRTCPeerConnection> connection; List<Ref<WebRTCDataChannel>> channels; diff --git a/modules/webrtc/webrtc_peer_connection.h b/modules/webrtc/webrtc_peer_connection.h index ae75864489..fcfb9ae9ae 100644 --- a/modules/webrtc/webrtc_peer_connection.h +++ b/modules/webrtc/webrtc_peer_connection.h @@ -34,8 +34,8 @@ #include "core/io/packet_peer.h" #include "modules/webrtc/webrtc_data_channel.h" -class WebRTCPeerConnection : public Reference { - GDCLASS(WebRTCPeerConnection, Reference); +class WebRTCPeerConnection : public RefCounted { + GDCLASS(WebRTCPeerConnection, RefCounted); public: enum ConnectionState { diff --git a/modules/websocket/emws_server.h b/modules/websocket/emws_server.h index e7285ccb86..d36e3a3557 100644 --- a/modules/websocket/emws_server.h +++ b/modules/websocket/emws_server.h @@ -33,7 +33,7 @@ #ifdef JAVASCRIPT_ENABLED -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "emws_peer.h" #include "websocket_server.h" diff --git a/modules/websocket/websocket_server.h b/modules/websocket/websocket_server.h index 10da51fce5..bc5e591e7b 100644 --- a/modules/websocket/websocket_server.h +++ b/modules/websocket/websocket_server.h @@ -32,7 +32,7 @@ #define WEBSOCKET_H #include "core/crypto/crypto.h" -#include "core/object/reference.h" +#include "core/object/ref_counted.h" #include "websocket_multiplayer_peer.h" #include "websocket_peer.h" diff --git a/modules/websocket/wsl_server.h b/modules/websocket/wsl_server.h index c2cf9df58b..39177a16a8 100644 --- a/modules/websocket/wsl_server.h +++ b/modules/websocket/wsl_server.h @@ -46,7 +46,7 @@ class WSLServer : public WebSocketServer { GDCIIMPL(WSLServer, WebSocketServer); private: - class PendingPeer : public Reference { + class PendingPeer : public RefCounted { private: bool _parse_request(const Vector<String> p_protocols); |