Rename Reference to RefCounted

This commit is contained in:
Pedro J. Estébanez 2021-06-04 18:03:15 +02:00
parent fbb5a541ef
commit 04688b92ff
270 changed files with 926 additions and 926 deletions

View file

@ -232,9 +232,9 @@ Engine::Singleton::Singleton(const StringName &p_name, Object *p_ptr) :
name(p_name), name(p_name),
ptr(p_ptr) { ptr(p_ptr) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
Reference *ref = Object::cast_to<Reference>(p_ptr); RefCounted *rc = Object::cast_to<RefCounted>(p_ptr);
if (ref && !ref->is_referenced()) { if (rc && !rc->is_referenced()) {
WARN_PRINT("You must use Ref<> to ensure the lifetime of a Reference object intended to be used as a singleton."); WARN_PRINT("You must use Ref<> to ensure the lifetime of a RefCounted object intended to be used as a singleton.");
} }
#endif #endif
} }

View file

@ -2074,7 +2074,7 @@ Variant _ClassDB::instance(const StringName &p_class) const {
return Variant(); return Variant();
} }
Reference *r = Object::cast_to<Reference>(obj); RefCounted *r = Object::cast_to<RefCounted>(obj);
if (r) { if (r) {
return REF(r); return REF(r);
} else { } else {

View file

@ -353,8 +353,8 @@ public:
_Geometry3D() { singleton = this; } _Geometry3D() { singleton = this; }
}; };
class _File : public Reference { class _File : public RefCounted {
GDCLASS(_File, Reference); GDCLASS(_File, RefCounted);
FileAccess *f = nullptr; FileAccess *f = nullptr;
bool big_endian = false; bool big_endian = false;
@ -455,8 +455,8 @@ public:
VARIANT_ENUM_CAST(_File::ModeFlags); VARIANT_ENUM_CAST(_File::ModeFlags);
VARIANT_ENUM_CAST(_File::CompressionMode); VARIANT_ENUM_CAST(_File::CompressionMode);
class _Directory : public Reference { class _Directory : public RefCounted {
GDCLASS(_Directory, Reference); GDCLASS(_Directory, RefCounted);
DirAccess *d; DirAccess *d;
bool dir_open = false; bool dir_open = false;
@ -525,8 +525,8 @@ public:
~_Marshalls() { singleton = nullptr; } ~_Marshalls() { singleton = nullptr; }
}; };
class _Mutex : public Reference { class _Mutex : public RefCounted {
GDCLASS(_Mutex, Reference); GDCLASS(_Mutex, RefCounted);
Mutex mutex; Mutex mutex;
static void _bind_methods(); static void _bind_methods();
@ -537,8 +537,8 @@ public:
void unlock(); void unlock();
}; };
class _Semaphore : public Reference { class _Semaphore : public RefCounted {
GDCLASS(_Semaphore, Reference); GDCLASS(_Semaphore, RefCounted);
Semaphore semaphore; Semaphore semaphore;
static void _bind_methods(); static void _bind_methods();
@ -549,8 +549,8 @@ public:
void post(); void post();
}; };
class _Thread : public Reference { class _Thread : public RefCounted {
GDCLASS(_Thread, Reference); GDCLASS(_Thread, RefCounted);
protected: protected:
Variant ret; Variant ret;
@ -666,8 +666,8 @@ public:
class _JSON; class _JSON;
class JSONParseResult : public Reference { class JSONParseResult : public RefCounted {
GDCLASS(JSONParseResult, Reference); GDCLASS(JSONParseResult, RefCounted);
friend class _JSON; friend class _JSON;

View file

@ -32,10 +32,10 @@
#define AES_CONTEXT_H #define AES_CONTEXT_H
#include "core/crypto/crypto_core.h" #include "core/crypto/crypto_core.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
class AESContext : public Reference { class AESContext : public RefCounted {
GDCLASS(AESContext, Reference); GDCLASS(AESContext, RefCounted);
public: public:
enum Mode { enum Mode {

View file

@ -35,7 +35,7 @@
#include "core/io/resource.h" #include "core/io/resource.h"
#include "core/io/resource_loader.h" #include "core/io/resource_loader.h"
#include "core/io/resource_saver.h" #include "core/io/resource_saver.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
class CryptoKey : public Resource { class CryptoKey : public Resource {
GDCLASS(CryptoKey, Resource); GDCLASS(CryptoKey, Resource);
@ -67,8 +67,8 @@ public:
virtual Error save(String p_path) = 0; virtual Error save(String p_path) = 0;
}; };
class HMACContext : public Reference { class HMACContext : public RefCounted {
GDCLASS(HMACContext, Reference); GDCLASS(HMACContext, RefCounted);
protected: protected:
static void _bind_methods(); static void _bind_methods();
@ -84,8 +84,8 @@ public:
HMACContext() {} HMACContext() {}
}; };
class Crypto : public Reference { class Crypto : public RefCounted {
GDCLASS(Crypto, Reference); GDCLASS(Crypto, RefCounted);
protected: protected:
static void _bind_methods(); static void _bind_methods();

View file

@ -31,7 +31,7 @@
#ifndef CRYPTO_CORE_H #ifndef CRYPTO_CORE_H
#define CRYPTO_CORE_H #define CRYPTO_CORE_H
#include "core/object/reference.h" #include "core/object/ref_counted.h"
class CryptoCore { class CryptoCore {
public: public:

View file

@ -31,10 +31,10 @@
#ifndef HASHING_CONTEXT_H #ifndef HASHING_CONTEXT_H
#define HASHING_CONTEXT_H #define HASHING_CONTEXT_H
#include "core/object/reference.h" #include "core/object/ref_counted.h"
class HashingContext : public Reference { class HashingContext : public RefCounted {
GDCLASS(HashingContext, Reference); GDCLASS(HashingContext, RefCounted);
public: public:
enum HashType { enum HashType {

View file

@ -32,12 +32,12 @@
#define REMOTE_DEBUGGER_PEER_H #define REMOTE_DEBUGGER_PEER_H
#include "core/io/stream_peer_tcp.h" #include "core/io/stream_peer_tcp.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
#include "core/os/mutex.h" #include "core/os/mutex.h"
#include "core/os/thread.h" #include "core/os/thread.h"
#include "core/string/ustring.h" #include "core/string/ustring.h"
class RemoteDebuggerPeer : public Reference { class RemoteDebuggerPeer : public RefCounted {
protected: protected:
int max_queued_messages = 4096; int max_queued_messages = 4096;

View file

@ -32,12 +32,12 @@
#define CONFIG_FILE_H #define CONFIG_FILE_H
#include "core/io/file_access.h" #include "core/io/file_access.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
#include "core/templates/ordered_hash_map.h" #include "core/templates/ordered_hash_map.h"
#include "core/variant/variant_parser.h" #include "core/variant/variant_parser.h"
class ConfigFile : public Reference { class ConfigFile : public RefCounted {
GDCLASS(ConfigFile, Reference); GDCLASS(ConfigFile, RefCounted);
OrderedHashMap<String, OrderedHashMap<String, Variant>> values; OrderedHashMap<String, OrderedHashMap<String, Variant>> values;

View file

@ -34,8 +34,8 @@
#include "core/io/net_socket.h" #include "core/io/net_socket.h"
#include "core/io/packet_peer_dtls.h" #include "core/io/packet_peer_dtls.h"
class DTLSServer : public Reference { class DTLSServer : public RefCounted {
GDCLASS(DTLSServer, Reference); GDCLASS(DTLSServer, RefCounted);
protected: protected:
static DTLSServer *(*_create)(); static DTLSServer *(*_create)();

View file

@ -34,10 +34,10 @@
#include "core/io/ip.h" #include "core/io/ip.h"
#include "core/io/stream_peer.h" #include "core/io/stream_peer.h"
#include "core/io/stream_peer_tcp.h" #include "core/io/stream_peer_tcp.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
class HTTPClient : public Reference { class HTTPClient : public RefCounted {
GDCLASS(HTTPClient, Reference); GDCLASS(HTTPClient, RefCounted);
public: public:
enum ResponseCode { enum ResponseCode {

View file

@ -31,7 +31,7 @@
#ifndef JSON_H #ifndef JSON_H
#define JSON_H #define JSON_H
#include "core/object/reference.h" #include "core/object/ref_counted.h"
#include "core/variant/variant.h" #include "core/variant/variant.h"
class JSON { class JSON {
enum TokenType { enum TokenType {
@ -74,8 +74,8 @@ public:
static Error parse(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line); static Error parse(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line);
}; };
class JSONParser : public Reference { class JSONParser : public RefCounted {
GDCLASS(JSONParser, Reference); GDCLASS(JSONParser, RefCounted);
Variant data; Variant data;
String string; String string;

View file

@ -30,7 +30,7 @@
#include "marshalls.h" #include "marshalls.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
#include "core/os/keyboard.h" #include "core/os/keyboard.h"
#include "core/string/print_string.h" #include "core/string/print_string.h"
@ -489,8 +489,8 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
obj->set(str, value); obj->set(str, value);
} }
if (Object::cast_to<Reference>(obj)) { if (Object::cast_to<RefCounted>(obj)) {
REF ref = REF(Object::cast_to<Reference>(obj)); REF ref = REF(Object::cast_to<RefCounted>(obj));
r_variant = ref; r_variant = ref;
} else { } else {
r_variant = obj; r_variant = obj;

View file

@ -31,7 +31,7 @@
#ifndef MARSHALLS_H #ifndef MARSHALLS_H
#define MARSHALLS_H #define MARSHALLS_H
#include "core/object/reference.h" #include "core/object/ref_counted.h"
#include "core/typedefs.h" #include "core/typedefs.h"
#include "core/variant/variant.h" #include "core/variant/variant.h"
@ -165,8 +165,8 @@ static inline double decode_double(const uint8_t *p_arr) {
return md.d; return md.d;
} }
class EncodedObjectAsID : public Reference { class EncodedObjectAsID : public RefCounted {
GDCLASS(EncodedObjectAsID, Reference); GDCLASS(EncodedObjectAsID, RefCounted);
ObjectID id; ObjectID id;

View file

@ -32,10 +32,10 @@
#define MULTIPLAYER_API_H #define MULTIPLAYER_API_H
#include "core/io/networked_multiplayer_peer.h" #include "core/io/networked_multiplayer_peer.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
class MultiplayerAPI : public Reference { class MultiplayerAPI : public RefCounted {
GDCLASS(MultiplayerAPI, Reference); GDCLASS(MultiplayerAPI, RefCounted);
public: public:
enum RPCMode { enum RPCMode {

View file

@ -32,9 +32,9 @@
#define NET_SOCKET_H #define NET_SOCKET_H
#include "core/io/ip.h" #include "core/io/ip.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
class NetSocket : public Reference { class NetSocket : public RefCounted {
protected: protected:
static NetSocket *(*_create)(); static NetSocket *(*_create)();

View file

@ -80,8 +80,8 @@ public:
PackedDataContainer() {} PackedDataContainer() {}
}; };
class PackedDataContainerRef : public Reference { class PackedDataContainerRef : public RefCounted {
GDCLASS(PackedDataContainerRef, Reference); GDCLASS(PackedDataContainerRef, RefCounted);
friend class PackedDataContainer; friend class PackedDataContainer;
uint32_t offset = 0; uint32_t offset = 0;

View file

@ -35,8 +35,8 @@
#include "core/object/class_db.h" #include "core/object/class_db.h"
#include "core/templates/ring_buffer.h" #include "core/templates/ring_buffer.h"
class PacketPeer : public Reference { class PacketPeer : public RefCounted {
GDCLASS(PacketPeer, Reference); GDCLASS(PacketPeer, RefCounted);
Variant _bnd_get_var(bool p_allow_objects = false); Variant _bnd_get_var(bool p_allow_objects = false);

View file

@ -31,12 +31,12 @@
#ifndef PCK_PACKER_H #ifndef PCK_PACKER_H
#define PCK_PACKER_H #define PCK_PACKER_H
#include "core/object/reference.h" #include "core/object/ref_counted.h"
class FileAccess; class FileAccess;
class PCKPacker : public Reference { class PCKPacker : public RefCounted {
GDCLASS(PCKPacker, Reference); GDCLASS(PCKPacker, RefCounted);
FileAccess *file = nullptr; FileAccess *file = nullptr;
int alignment = 0; int alignment = 0;

View file

@ -32,7 +32,7 @@
#define RESOURCE_H #define RESOURCE_H
#include "core/object/class_db.h" #include "core/object/class_db.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
#include "core/templates/safe_refcount.h" #include "core/templates/safe_refcount.h"
#include "core/templates/self_list.h" #include "core/templates/self_list.h"
@ -43,8 +43,8 @@ public:
\ \
private: private:
class Resource : public Reference { class Resource : public RefCounted {
GDCLASS(Resource, Reference); GDCLASS(Resource, RefCounted);
OBJ_CATEGORY("Resources"); OBJ_CATEGORY("Resources");
public: public:

View file

@ -93,8 +93,8 @@ public:
ResourceFormatImporter(); ResourceFormatImporter();
}; };
class ResourceImporter : public Reference { class ResourceImporter : public RefCounted {
GDCLASS(ResourceImporter, Reference); GDCLASS(ResourceImporter, RefCounted);
public: public:
virtual String get_importer_name() const = 0; virtual String get_importer_name() const = 0;

View file

@ -35,8 +35,8 @@
#include "core/os/semaphore.h" #include "core/os/semaphore.h"
#include "core/os/thread.h" #include "core/os/thread.h"
class ResourceFormatLoader : public Reference { class ResourceFormatLoader : public RefCounted {
GDCLASS(ResourceFormatLoader, Reference); GDCLASS(ResourceFormatLoader, RefCounted);
public: public:
enum CacheMode { enum CacheMode {

View file

@ -33,8 +33,8 @@
#include "core/io/resource.h" #include "core/io/resource.h"
class ResourceFormatSaver : public Reference { class ResourceFormatSaver : public RefCounted {
GDCLASS(ResourceFormatSaver, Reference); GDCLASS(ResourceFormatSaver, RefCounted);
protected: protected:
static void _bind_methods(); static void _bind_methods();

View file

@ -31,10 +31,10 @@
#ifndef STREAM_PEER_H #ifndef STREAM_PEER_H
#define STREAM_PEER_H #define STREAM_PEER_H
#include "core/object/reference.h" #include "core/object/ref_counted.h"
class StreamPeer : public Reference { class StreamPeer : public RefCounted {
GDCLASS(StreamPeer, Reference); GDCLASS(StreamPeer, RefCounted);
OBJ_CATEGORY("Networking"); OBJ_CATEGORY("Networking");
protected: protected:

View file

@ -36,8 +36,8 @@
#include "core/io/stream_peer.h" #include "core/io/stream_peer.h"
#include "core/io/stream_peer_tcp.h" #include "core/io/stream_peer_tcp.h"
class TCPServer : public Reference { class TCPServer : public RefCounted {
GDCLASS(TCPServer, Reference); GDCLASS(TCPServer, RefCounted);
protected: protected:
enum { enum {

View file

@ -34,8 +34,8 @@
#include "core/io/net_socket.h" #include "core/io/net_socket.h"
#include "core/io/packet_peer_udp.h" #include "core/io/packet_peer_udp.h"
class UDPServer : public Reference { class UDPServer : public RefCounted {
GDCLASS(UDPServer, Reference); GDCLASS(UDPServer, RefCounted);
protected: protected:
enum { enum {

View file

@ -32,7 +32,7 @@
#define XML_PARSER_H #define XML_PARSER_H
#include "core/io/file_access.h" #include "core/io/file_access.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
#include "core/string/ustring.h" #include "core/string/ustring.h"
#include "core/templates/vector.h" #include "core/templates/vector.h"
@ -40,8 +40,8 @@
Based on irrXML (see their zlib license). Added mainly for compatibility with their Collada loader. Based on irrXML (see their zlib license). Added mainly for compatibility with their Collada loader.
*/ */
class XMLParser : public Reference { class XMLParser : public RefCounted {
GDCLASS(XMLParser, Reference); GDCLASS(XMLParser, RefCounted);
public: public:
//! Enumeration of all supported source text file formats //! Enumeration of all supported source text file formats

View file

@ -31,7 +31,7 @@
#ifndef A_STAR_H #ifndef A_STAR_H
#define A_STAR_H #define A_STAR_H
#include "core/object/reference.h" #include "core/object/ref_counted.h"
#include "core/templates/oa_hash_map.h" #include "core/templates/oa_hash_map.h"
/** /**
@ -40,8 +40,8 @@
@author Juan Linietsky <reduzio@gmail.com> @author Juan Linietsky <reduzio@gmail.com>
*/ */
class AStar : public Reference { class AStar : public RefCounted {
GDCLASS(AStar, Reference); GDCLASS(AStar, RefCounted);
friend class AStar2D; friend class AStar2D;
struct Point { struct Point {
@ -157,8 +157,8 @@ public:
~AStar(); ~AStar();
}; };
class AStar2D : public Reference { class AStar2D : public RefCounted {
GDCLASS(AStar2D, Reference); GDCLASS(AStar2D, RefCounted);
AStar astar; AStar astar;
bool _solve(AStar::Point *begin_point, AStar::Point *end_point); bool _solve(AStar::Point *begin_point, AStar::Point *end_point);

View file

@ -33,7 +33,7 @@
#include "core/io/marshalls.h" #include "core/io/marshalls.h"
#include "core/math/math_funcs.h" #include "core/math/math_funcs.h"
#include "core/object/class_db.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/os/os.h"
#include "core/variant/variant_parser.h" #include "core/variant/variant_parser.h"

View file

@ -31,10 +31,10 @@
#ifndef EXPRESSION_H #ifndef EXPRESSION_H
#define EXPRESSION_H #define EXPRESSION_H
#include "core/object/reference.h" #include "core/object/ref_counted.h"
class Expression : public Reference { class Expression : public RefCounted {
GDCLASS(Expression, Reference); GDCLASS(Expression, RefCounted);
private: private:
struct Input { struct Input {

View file

@ -32,10 +32,10 @@
#define RANDOM_NUMBER_GENERATOR_H #define RANDOM_NUMBER_GENERATOR_H
#include "core/math/random_pcg.h" #include "core/math/random_pcg.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
class RandomNumberGenerator : public Reference { class RandomNumberGenerator : public RefCounted {
GDCLASS(RandomNumberGenerator, Reference); GDCLASS(RandomNumberGenerator, RefCounted);
protected: protected:
RandomPCG randbase; RandomPCG randbase;

View file

@ -32,10 +32,10 @@
#define TRIANGLE_MESH_H #define TRIANGLE_MESH_H
#include "core/math/face3.h" #include "core/math/face3.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
class TriangleMesh : public Reference { class TriangleMesh : public RefCounted {
GDCLASS(TriangleMesh, Reference); GDCLASS(TriangleMesh, RefCounted);
struct Triangle { struct Triangle {
Vector3 normal; Vector3 normal;

View file

@ -769,7 +769,7 @@ Variant Object::call(const StringName &p_method, const Variant **p_args, int p_a
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
return Variant(); return Variant();
} }
if (Object::cast_to<Reference>(this)) { if (Object::cast_to<RefCounted>(this)) {
r_error.argument = 0; r_error.argument = 0;
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
ERR_FAIL_V_MSG(Variant(), "Can't 'free' a reference."); ERR_FAIL_V_MSG(Variant(), "Can't 'free' a reference.");
@ -1900,7 +1900,7 @@ ObjectID ObjectDB::add_instance(Object *p_object) {
object_slots = (ObjectSlot *)memrealloc(object_slots, sizeof(ObjectSlot) * new_slot_max); object_slots = (ObjectSlot *)memrealloc(object_slots, sizeof(ObjectSlot) * new_slot_max);
for (uint32_t i = slot_max; i < new_slot_max; i++) { for (uint32_t i = slot_max; i < new_slot_max; i++) {
object_slots[i].object = nullptr; object_slots[i].object = nullptr;
object_slots[i].is_reference = false; object_slots[i].is_ref_counted = false;
object_slots[i].next_free = i; object_slots[i].next_free = i;
object_slots[i].validator = 0; object_slots[i].validator = 0;
} }
@ -1913,7 +1913,7 @@ ObjectID ObjectDB::add_instance(Object *p_object) {
ERR_FAIL_COND_V(object_slots[slot].object != nullptr, ObjectID()); ERR_FAIL_COND_V(object_slots[slot].object != nullptr, ObjectID());
} }
object_slots[slot].object = p_object; object_slots[slot].object = p_object;
object_slots[slot].is_reference = p_object->is_reference(); object_slots[slot].is_ref_counted = p_object->is_ref_counted();
validator_counter = (validator_counter + 1) & OBJECTDB_VALIDATOR_MASK; validator_counter = (validator_counter + 1) & OBJECTDB_VALIDATOR_MASK;
if (unlikely(validator_counter == 0)) { if (unlikely(validator_counter == 0)) {
validator_counter = 1; validator_counter = 1;
@ -1924,7 +1924,7 @@ ObjectID ObjectDB::add_instance(Object *p_object) {
id <<= OBJECTDB_SLOT_MAX_COUNT_BITS; id <<= OBJECTDB_SLOT_MAX_COUNT_BITS;
id |= uint64_t(slot); id |= uint64_t(slot);
if (p_object->is_reference()) { if (p_object->is_ref_counted()) {
id |= OBJECTDB_REFERENCE_BIT; id |= OBJECTDB_REFERENCE_BIT;
} }
@ -1962,7 +1962,7 @@ void ObjectDB::remove_instance(Object *p_object) {
object_slots[slot_count].next_free = slot; object_slots[slot_count].next_free = slot;
//invalidate, so checks against it fail //invalidate, so checks against it fail
object_slots[slot].validator = 0; object_slots[slot].validator = 0;
object_slots[slot].is_reference = false; object_slots[slot].is_ref_counted = false;
object_slots[slot].object = nullptr; object_slots[slot].object = nullptr;
spin_lock.unlock(); spin_lock.unlock();
@ -1997,7 +1997,7 @@ void ObjectDB::cleanup() {
extra_info = " - Resource path: " + String(resource_get_path->call(obj, nullptr, 0, call_error)); extra_info = " - Resource path: " + String(resource_get_path->call(obj, nullptr, 0, call_error));
} }
uint64_t id = uint64_t(i) | (uint64_t(object_slots[i].validator) << OBJECTDB_VALIDATOR_BITS) | (object_slots[i].is_reference ? OBJECTDB_REFERENCE_BIT : 0); uint64_t id = uint64_t(i) | (uint64_t(object_slots[i].validator) << OBJECTDB_VALIDATOR_BITS) | (object_slots[i].is_ref_counted ? OBJECTDB_REFERENCE_BIT : 0);
print_line("Leaked instance: " + String(obj->get_class()) + ":" + itos(id) + extra_info); print_line("Leaked instance: " + String(obj->get_class()) + ":" + itos(id) + extra_info);
count--; count--;

View file

@ -545,7 +545,7 @@ private:
_FORCE_INLINE_ void _construct_object(bool p_reference); _FORCE_INLINE_ void _construct_object(bool p_reference);
friend class Reference; friend class RefCounted;
bool type_is_reference = false; bool type_is_reference = false;
SafeNumeric<uint32_t> instance_binding_count; SafeNumeric<uint32_t> instance_binding_count;
void *_script_instance_bindings[MAX_SCRIPT_INSTANCE_BINDINGS]; void *_script_instance_bindings[MAX_SCRIPT_INSTANCE_BINDINGS];
@ -795,7 +795,7 @@ public:
void clear_internal_resource_paths(); void clear_internal_resource_paths();
_ALWAYS_INLINE_ bool is_reference() const { return type_is_reference; } _ALWAYS_INLINE_ bool is_ref_counted() const { return type_is_reference; }
Object(); Object();
virtual ~Object(); virtual ~Object();
@ -815,7 +815,7 @@ class ObjectDB {
struct ObjectSlot { //128 bits per slot struct ObjectSlot { //128 bits per slot
uint64_t validator : OBJECTDB_VALIDATOR_BITS; uint64_t validator : OBJECTDB_VALIDATOR_BITS;
uint64_t next_free : OBJECTDB_SLOT_MAX_COUNT_BITS; uint64_t next_free : OBJECTDB_SLOT_MAX_COUNT_BITS;
uint64_t is_reference : 1; uint64_t is_ref_counted : 1;
Object *object; Object *object;
}; };

View file

@ -42,7 +42,7 @@ class ObjectID {
uint64_t id = 0; uint64_t id = 0;
public: public:
_ALWAYS_INLINE_ bool is_reference() const { return (id & (uint64_t(1) << 63)) != 0; } _ALWAYS_INLINE_ bool is_ref_counted() const { return (id & (uint64_t(1) << 63)) != 0; }
_ALWAYS_INLINE_ bool is_valid() const { return id != 0; } _ALWAYS_INLINE_ bool is_valid() const { return id != 0; }
_ALWAYS_INLINE_ bool is_null() const { return id == 0; } _ALWAYS_INLINE_ bool is_null() const { return id == 0; }
_ALWAYS_INLINE_ operator uint64_t() const { return id; } _ALWAYS_INLINE_ operator uint64_t() const { return id; }

View file

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* reference.cpp */ /* ref_counted.cpp */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#include "reference.h" #include "ref_counted.h"
#include "core/object/script_language.h" #include "core/object/script_language.h"
bool Reference::init_ref() { bool RefCounted::init_ref() {
if (reference()) { if (reference()) {
if (!is_referenced() && refcount_init.unref()) { if (!is_referenced() && refcount_init.unref()) {
unreference(); // first referencing is already 1, so compensate for the ref above unreference(); // first referencing is already 1, so compensate for the ref above
@ -44,17 +44,17 @@ bool Reference::init_ref() {
} }
} }
void Reference::_bind_methods() { void RefCounted::_bind_methods() {
ClassDB::bind_method(D_METHOD("init_ref"), &Reference::init_ref); ClassDB::bind_method(D_METHOD("init_ref"), &RefCounted::init_ref);
ClassDB::bind_method(D_METHOD("reference"), &Reference::reference); ClassDB::bind_method(D_METHOD("reference"), &RefCounted::reference);
ClassDB::bind_method(D_METHOD("unreference"), &Reference::unreference); ClassDB::bind_method(D_METHOD("unreference"), &RefCounted::unreference);
} }
int Reference::reference_get_count() const { int RefCounted::reference_get_count() const {
return refcount.get(); return refcount.get();
} }
bool Reference::reference() { bool RefCounted::reference() {
uint32_t rc_val = refcount.refval(); uint32_t rc_val = refcount.refval();
bool success = rc_val != 0; bool success = rc_val != 0;
@ -77,7 +77,7 @@ bool Reference::reference() {
return success; return success;
} }
bool Reference::unreference() { bool RefCounted::unreference() {
uint32_t rc_val = refcount.unrefval(); uint32_t rc_val = refcount.unrefval();
bool die = rc_val == 0; bool die = rc_val == 0;
@ -102,7 +102,7 @@ bool Reference::unreference() {
return die; return die;
} }
Reference::Reference() : RefCounted::RefCounted() :
Object(true) { Object(true) {
refcount.init(); refcount.init();
refcount_init.init(); refcount_init.init();
@ -117,7 +117,7 @@ Variant WeakRef::get_ref() const {
if (!obj) { if (!obj) {
return Variant(); return Variant();
} }
Reference *r = cast_to<Reference>(obj); RefCounted *r = cast_to<RefCounted>(obj);
if (r) { if (r) {
return REF(r); return REF(r);
} }

View file

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* reference.h */ /* ref_counted.h */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef REFERENCE_H #ifndef REF_COUNTED_H
#define REFERENCE_H #define REF_COUNTED_H
#include "core/object/class_db.h" #include "core/object/class_db.h"
#include "core/templates/safe_refcount.h" #include "core/templates/safe_refcount.h"
class Reference : public Object { class RefCounted : public Object {
GDCLASS(Reference, Object); GDCLASS(RefCounted, Object);
SafeRefCount refcount; SafeRefCount refcount;
SafeRefCount refcount_init; SafeRefCount refcount_init;
@ -49,8 +49,8 @@ public:
bool unreference(); bool unreference();
int reference_get_count() const; int reference_get_count() const;
Reference(); RefCounted();
~Reference() {} ~RefCounted() {}
}; };
template <class T> template <class T>
@ -78,7 +78,7 @@ class Ref {
} }
} }
//virtual Reference * get_reference() const { return reference; } //virtual RefCounted * get_reference() const { return reference; }
public: public:
_FORCE_INLINE_ bool operator==(const T *p_ptr) const { _FORCE_INLINE_ bool operator==(const T *p_ptr) const {
return reference == p_ptr; return reference == p_ptr;
@ -130,7 +130,7 @@ public:
template <class T_Other> template <class T_Other>
void operator=(const Ref<T_Other> &p_from) { void operator=(const Ref<T_Other> &p_from) {
Reference *refb = const_cast<Reference *>(static_cast<const Reference *>(p_from.ptr())); RefCounted *refb = const_cast<RefCounted *>(static_cast<const RefCounted *>(p_from.ptr()));
if (!refb) { if (!refb) {
unref(); unref();
return; return;
@ -179,7 +179,7 @@ public:
template <class T_Other> template <class T_Other>
Ref(const Ref<T_Other> &p_from) { Ref(const Ref<T_Other> &p_from) {
Reference *refb = const_cast<Reference *>(static_cast<const Reference *>(p_from.ptr())); RefCounted *refb = const_cast<RefCounted *>(static_cast<const RefCounted *>(p_from.ptr()));
if (!refb) { if (!refb) {
unref(); unref();
return; return;
@ -234,10 +234,10 @@ public:
} }
}; };
typedef Ref<Reference> REF; typedef Ref<RefCounted> REF;
class WeakRef : public Reference { class WeakRef : public RefCounted {
GDCLASS(WeakRef, Reference); GDCLASS(WeakRef, RefCounted);
ObjectID ref; ObjectID ref;
@ -259,7 +259,7 @@ struct PtrToArg<Ref<T>> {
} }
_FORCE_INLINE_ static void encode(Ref<T> p_val, const void *p_ptr) { _FORCE_INLINE_ static void encode(Ref<T> p_val, const void *p_ptr) {
*(Ref<Reference> *)p_ptr = p_val; *(Ref<RefCounted> *)p_ptr = p_val;
} }
}; };
@ -294,4 +294,4 @@ struct GetTypeInfo<const Ref<T> &> {
#endif // DEBUG_METHODS_ENABLED #endif // DEBUG_METHODS_ENABLED
#endif // REFERENCE_H #endif // REF_COUNTED_H

View file

@ -122,8 +122,8 @@ void UndoRedo::add_do_method(Object *p_object, const StringName &p_method, VARIA
ERR_FAIL_COND((current_action + 1) >= actions.size()); ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op; Operation do_op;
do_op.object = p_object->get_instance_id(); do_op.object = p_object->get_instance_id();
if (Object::cast_to<Reference>(p_object)) { if (Object::cast_to<RefCounted>(p_object)) {
do_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object)); do_op.ref = Ref<RefCounted>(Object::cast_to<RefCounted>(p_object));
} }
do_op.type = Operation::TYPE_METHOD; do_op.type = Operation::TYPE_METHOD;
@ -148,8 +148,8 @@ void UndoRedo::add_undo_method(Object *p_object, const StringName &p_method, VAR
Operation undo_op; Operation undo_op;
undo_op.object = p_object->get_instance_id(); undo_op.object = p_object->get_instance_id();
if (Object::cast_to<Reference>(p_object)) { if (Object::cast_to<RefCounted>(p_object)) {
undo_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object)); undo_op.ref = Ref<RefCounted>(Object::cast_to<RefCounted>(p_object));
} }
undo_op.type = Operation::TYPE_METHOD; undo_op.type = Operation::TYPE_METHOD;
@ -167,8 +167,8 @@ void UndoRedo::add_do_property(Object *p_object, const StringName &p_property, c
ERR_FAIL_COND((current_action + 1) >= actions.size()); ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op; Operation do_op;
do_op.object = p_object->get_instance_id(); do_op.object = p_object->get_instance_id();
if (Object::cast_to<Reference>(p_object)) { if (Object::cast_to<RefCounted>(p_object)) {
do_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object)); do_op.ref = Ref<RefCounted>(Object::cast_to<RefCounted>(p_object));
} }
do_op.type = Operation::TYPE_PROPERTY; do_op.type = Operation::TYPE_PROPERTY;
@ -189,8 +189,8 @@ void UndoRedo::add_undo_property(Object *p_object, const StringName &p_property,
Operation undo_op; Operation undo_op;
undo_op.object = p_object->get_instance_id(); undo_op.object = p_object->get_instance_id();
if (Object::cast_to<Reference>(p_object)) { if (Object::cast_to<RefCounted>(p_object)) {
undo_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object)); undo_op.ref = Ref<RefCounted>(Object::cast_to<RefCounted>(p_object));
} }
undo_op.type = Operation::TYPE_PROPERTY; undo_op.type = Operation::TYPE_PROPERTY;
@ -205,8 +205,8 @@ void UndoRedo::add_do_reference(Object *p_object) {
ERR_FAIL_COND((current_action + 1) >= actions.size()); ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op; Operation do_op;
do_op.object = p_object->get_instance_id(); do_op.object = p_object->get_instance_id();
if (Object::cast_to<Reference>(p_object)) { if (Object::cast_to<RefCounted>(p_object)) {
do_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object)); do_op.ref = Ref<RefCounted>(Object::cast_to<RefCounted>(p_object));
} }
do_op.type = Operation::TYPE_REFERENCE; do_op.type = Operation::TYPE_REFERENCE;
@ -225,8 +225,8 @@ void UndoRedo::add_undo_reference(Object *p_object) {
Operation undo_op; Operation undo_op;
undo_op.object = p_object->get_instance_id(); undo_op.object = p_object->get_instance_id();
if (Object::cast_to<Reference>(p_object)) { if (Object::cast_to<RefCounted>(p_object)) {
undo_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object)); undo_op.ref = Ref<RefCounted>(Object::cast_to<RefCounted>(p_object));
} }
undo_op.type = Operation::TYPE_REFERENCE; undo_op.type = Operation::TYPE_REFERENCE;

View file

@ -32,7 +32,7 @@
#define UNDO_REDO_H #define UNDO_REDO_H
#include "core/object/class_db.h" #include "core/object/class_db.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
class UndoRedo : public Object { class UndoRedo : public Object {
GDCLASS(UndoRedo, Object); GDCLASS(UndoRedo, Object);
@ -61,7 +61,7 @@ private:
}; };
Type type; Type type;
Ref<Reference> ref; Ref<RefCounted> ref;
ObjectID object; ObjectID object;
StringName name; StringName name;
Variant args[VARIANT_ARG_MAX]; Variant args[VARIANT_ARG_MAX];

View file

@ -32,7 +32,7 @@
#define MAIN_LOOP_H #define MAIN_LOOP_H
#include "core/input/input_event.h" #include "core/input/input_event.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
#include "core/object/script_language.h" #include "core/object/script_language.h"
class MainLoop : public Object { class MainLoop : public Object {

View file

@ -131,7 +131,7 @@ void register_core_types() {
ClassDB::register_virtual_class<Script>(); ClassDB::register_virtual_class<Script>();
ClassDB::register_class<Reference>(); ClassDB::register_class<RefCounted>();
ClassDB::register_class<WeakRef>(); ClassDB::register_class<WeakRef>();
ClassDB::register_class<Resource>(); ClassDB::register_class<Resource>();
ClassDB::register_class<Image>(); ClassDB::register_class<Image>();

View file

@ -33,7 +33,7 @@
#include "callable_bind.h" #include "callable_bind.h"
#include "core/object/message_queue.h" #include "core/object/message_queue.h"
#include "core/object/object.h" #include "core/object/object.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
#include "core/object/script_language.h" #include "core/object/script_language.h"
void Callable::call_deferred(const Variant **p_arguments, int p_argcount) const { void Callable::call_deferred(const Variant **p_arguments, int p_argcount) const {

View file

@ -1115,9 +1115,9 @@ void Variant::reference(const Variant &p_variant) {
case OBJECT: { case OBJECT: {
memnew_placement(_data._mem, ObjData); memnew_placement(_data._mem, ObjData);
if (p_variant._get_obj().obj && p_variant._get_obj().id.is_reference()) { if (p_variant._get_obj().obj && p_variant._get_obj().id.is_ref_counted()) {
Reference *reference = static_cast<Reference *>(p_variant._get_obj().obj); RefCounted *ref_counted = static_cast<RefCounted *>(p_variant._get_obj().obj);
if (!reference->reference()) { if (!ref_counted->reference()) {
_get_obj().obj = nullptr; _get_obj().obj = nullptr;
_get_obj().id = ObjectID(); _get_obj().id = ObjectID();
break; break;
@ -1301,11 +1301,11 @@ void Variant::_clear_internal() {
reinterpret_cast<NodePath *>(_data._mem)->~NodePath(); reinterpret_cast<NodePath *>(_data._mem)->~NodePath();
} break; } break;
case OBJECT: { case OBJECT: {
if (_get_obj().id.is_reference()) { if (_get_obj().id.is_ref_counted()) {
//we are safe that there is a reference here //we are safe that there is a reference here
Reference *reference = static_cast<Reference *>(_get_obj().obj); RefCounted *ref_counted = static_cast<RefCounted *>(_get_obj().obj);
if (reference->unreference()) { if (ref_counted->unreference()) {
memdelete(reference); memdelete(ref_counted);
} }
} }
_get_obj().obj = nullptr; _get_obj().obj = nullptr;
@ -1830,7 +1830,7 @@ String Variant::stringify(List<const void *> &stack) const {
} break; } break;
case OBJECT: { case OBJECT: {
if (_get_obj().obj) { if (_get_obj().obj) {
if (!_get_obj().id.is_reference() && ObjectDB::get_instance(_get_obj().id) == nullptr) { if (!_get_obj().id.is_ref_counted() && ObjectDB::get_instance(_get_obj().id) == nullptr) {
return "[Freed Object]"; return "[Freed Object]";
} }
@ -2530,9 +2530,9 @@ Variant::Variant(const Object *p_object) {
memnew_placement(_data._mem, ObjData); memnew_placement(_data._mem, ObjData);
if (p_object) { if (p_object) {
if (p_object->is_reference()) { if (p_object->is_ref_counted()) {
Reference *reference = const_cast<Reference *>(static_cast<const Reference *>(p_object)); RefCounted *ref_counted = const_cast<RefCounted *>(static_cast<const RefCounted *>(p_object));
if (!reference->init_ref()) { if (!ref_counted->init_ref()) {
_get_obj().obj = nullptr; _get_obj().obj = nullptr;
_get_obj().id = ObjectID(); _get_obj().id = ObjectID();
return; return;
@ -2756,17 +2756,17 @@ void Variant::operator=(const Variant &p_variant) {
*reinterpret_cast<::RID *>(_data._mem) = *reinterpret_cast<const ::RID *>(p_variant._data._mem); *reinterpret_cast<::RID *>(_data._mem) = *reinterpret_cast<const ::RID *>(p_variant._data._mem);
} break; } break;
case OBJECT: { case OBJECT: {
if (_get_obj().id.is_reference()) { if (_get_obj().id.is_ref_counted()) {
//we are safe that there is a reference here //we are safe that there is a reference here
Reference *reference = static_cast<Reference *>(_get_obj().obj); RefCounted *ref_counted = static_cast<RefCounted *>(_get_obj().obj);
if (reference->unreference()) { if (ref_counted->unreference()) {
memdelete(reference); memdelete(ref_counted);
} }
} }
if (p_variant._get_obj().obj && p_variant._get_obj().id.is_reference()) { if (p_variant._get_obj().obj && p_variant._get_obj().id.is_ref_counted()) {
Reference *reference = static_cast<Reference *>(p_variant._get_obj().obj); RefCounted *ref_counted = static_cast<RefCounted *>(p_variant._get_obj().obj);
if (!reference->reference()) { if (!ref_counted->reference()) {
_get_obj().obj = nullptr; _get_obj().obj = nullptr;
_get_obj().id = ObjectID(); _get_obj().id = ObjectID();
break; break;
@ -3323,7 +3323,7 @@ bool Variant::hash_compare(const Variant &p_variant) const {
} }
bool Variant::is_ref() const { bool Variant::is_ref() const {
return type == OBJECT && _get_obj().id.is_reference(); return type == OBJECT && _get_obj().id.is_ref_counted();
} }
Vector<Variant> varray() { Vector<Variant> varray() {

View file

@ -972,7 +972,7 @@ void Variant::call(const StringName &p_method, const Variant **p_args, int p_arg
return; return;
} }
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (EngineDebugger::is_active() && !_get_obj().id.is_reference() && ObjectDB::get_instance(_get_obj().id) == nullptr) { if (EngineDebugger::is_active() && !_get_obj().id.is_ref_counted() && ObjectDB::get_instance(_get_obj().id) == nullptr) {
r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
return; return;
} }

View file

@ -836,9 +836,9 @@ String Variant::get_constructor_argument_name(Variant::Type p_type, int p_constr
void VariantInternal::object_assign(Variant *v, const Object *o) { void VariantInternal::object_assign(Variant *v, const Object *o) {
if (o) { if (o) {
if (o->is_reference()) { if (o->is_ref_counted()) {
Reference *reference = const_cast<Reference *>(static_cast<const Reference *>(o)); RefCounted *ref_counted = const_cast<RefCounted *>(static_cast<const RefCounted *>(o));
if (!reference->init_ref()) { if (!ref_counted->init_ref()) {
v->_get_obj().obj = nullptr; v->_get_obj().obj = nullptr;
v->_get_obj().id = ObjectID(); v->_get_obj().id = ObjectID();
return; return;

View file

@ -285,7 +285,7 @@ public:
v->clear(); v->clear();
} }
static void object_assign(Variant *v, const Object *o); // Needs Reference, so it's implemented elsewhere. static void object_assign(Variant *v, const Object *o); // Needs RefCounted, so it's implemented elsewhere.
_FORCE_INLINE_ static void object_assign(Variant *v, const Variant *o) { _FORCE_INLINE_ static void object_assign(Variant *v, const Variant *o) {
object_assign(v, o->_get_obj().obj); object_assign(v, o->_get_obj().obj);

View file

@ -742,7 +742,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return ERR_PARSE_ERROR; return ERR_PARSE_ERROR;
} }
REF ref = REF(Object::cast_to<Reference>(obj)); REF ref = REF(Object::cast_to<RefCounted>(obj));
get_token(p_stream, token, line, r_err_str); get_token(p_stream, token, line, r_err_str);
if (token.type != TK_COMMA) { if (token.type != TK_COMMA) {

View file

@ -1453,7 +1453,7 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (EngineDebugger::is_active() && !_get_obj().id.is_reference() && ObjectDB::get_instance(_get_obj().id) == nullptr) { if (EngineDebugger::is_active() && !_get_obj().id.is_ref_counted() && ObjectDB::get_instance(_get_obj().id) == nullptr) {
valid = false; valid = false;
return false; return false;
} }
@ -1680,7 +1680,7 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (EngineDebugger::is_active() && !_get_obj().id.is_reference() && ObjectDB::get_instance(_get_obj().id) == nullptr) { if (EngineDebugger::is_active() && !_get_obj().id.is_ref_counted() && ObjectDB::get_instance(_get_obj().id) == nullptr) {
valid = false; valid = false;
return false; return false;
} }
@ -1865,7 +1865,7 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
return Variant(); return Variant();
} }
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (EngineDebugger::is_active() && !_get_obj().id.is_reference() && ObjectDB::get_instance(_get_obj().id) == nullptr) { if (EngineDebugger::is_active() && !_get_obj().id.is_ref_counted() && ObjectDB::get_instance(_get_obj().id) == nullptr) {
r_valid = false; r_valid = false;
return Variant(); return Variant();
} }

View file

@ -32,7 +32,7 @@
#include "core/core_string_names.h" #include "core/core_string_names.h"
#include "core/io/marshalls.h" #include "core/io/marshalls.h"
#include "core/object/reference.h" #include "core/object/ref_counted.h"
#include "core/os/os.h" #include "core/os/os.h"
#include "core/templates/oa_hash_map.h" #include "core/templates/oa_hash_map.h"
#include "core/variant/binder_common.h" #include "core/variant/binder_common.h"

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="AESContext" inherits="Reference" version="4.0"> <class name="AESContext" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Interface to low level AES encryption features. Interface to low level AES encryption features.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="AStar" inherits="Reference" version="4.0"> <class name="AStar" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
An implementation of A* to find the shortest paths among connected points in space. An implementation of A* to find the shortest paths among connected points in space.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="AStar2D" inherits="Reference" version="4.0"> <class name="AStar2D" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
AStar class representation that uses 2D vectors as edges. AStar class representation that uses 2D vectors as edges.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationTrackEditPlugin" inherits="Reference" version="4.0"> <class name="AnimationTrackEditPlugin" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="AudioEffectInstance" inherits="Reference" version="4.0"> <class name="AudioEffectInstance" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="AudioStreamPlayback" inherits="Reference" version="4.0"> <class name="AudioStreamPlayback" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Meta class for playing back audio. Meta class for playing back audio.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="CameraFeed" inherits="Reference" version="4.0"> <class name="CameraFeed" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
A camera feed gives you access to a single physical camera attached to your device. A camera feed gives you access to a single physical camera attached to your device.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="CharFXTransform" inherits="Reference" version="4.0"> <class name="CharFXTransform" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Controls how an individual character will be displayed in a [RichTextEffect]. Controls how an individual character will be displayed in a [RichTextEffect].
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="ConfigFile" inherits="Reference" version="4.0"> <class name="ConfigFile" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Helper class to handle INI-style files. Helper class to handle INI-style files.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="Crypto" inherits="Reference" version="4.0"> <class name="Crypto" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Access to advanced cryptographic functionalities. Access to advanced cryptographic functionalities.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="DTLSServer" inherits="Reference" version="4.0"> <class name="DTLSServer" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Helper class to implement a DTLS server. Helper class to implement a DTLS server.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="Directory" inherits="Reference" version="4.0"> <class name="Directory" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Type used to handle the filesystem. Type used to handle the filesystem.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorExportPlugin" inherits="Reference" version="4.0"> <class name="EditorExportPlugin" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
A script that is executed when exporting the project. A script that is executed when exporting the project.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorFeatureProfile" inherits="Reference" version="4.0"> <class name="EditorFeatureProfile" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
An editor feature profile which can be used to disable specific features. An editor feature profile which can be used to disable specific features.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorInspectorPlugin" inherits="Reference" version="4.0"> <class name="EditorInspectorPlugin" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Plugin for adding custom property editors on inspector. Plugin for adding custom property editors on inspector.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorResourceConversionPlugin" inherits="Reference" version="4.0"> <class name="EditorResourceConversionPlugin" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorResourcePreviewGenerator" inherits="Reference" version="4.0"> <class name="EditorResourcePreviewGenerator" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Custom generator of previews. Custom generator of previews.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorSceneImporter" inherits="Reference" version="4.0"> <class name="EditorSceneImporter" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Imports scenes from third-parties' 3D files. Imports scenes from third-parties' 3D files.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorScenePostImport" inherits="Reference" version="4.0"> <class name="EditorScenePostImport" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Post-processes scenes after import. Post-processes scenes after import.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorScript" inherits="Reference" version="4.0"> <class name="EditorScript" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Base script that can be used to add extension functions to the editor. Base script that can be used to add extension functions to the editor.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorTranslationParserPlugin" inherits="Reference" version="4.0"> <class name="EditorTranslationParserPlugin" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Plugin for adding custom parsers to extract strings that are to be translated from custom files (.csv, .json etc.). Plugin for adding custom parsers to extract strings that are to be translated from custom files (.csv, .json etc.).
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="EncodedObjectAsID" inherits="Reference" version="4.0"> <class name="EncodedObjectAsID" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Holds a reference to an [Object]'s instance ID. Holds a reference to an [Object]'s instance ID.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="Expression" inherits="Reference" version="4.0"> <class name="Expression" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
A class that stores an expression you can execute. A class that stores an expression you can execute.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="File" inherits="Reference" version="4.0"> <class name="File" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Type to handle file reading and writing operations. Type to handle file reading and writing operations.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="HMACContext" inherits="Reference" version="4.0"> <class name="HMACContext" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Used to create an HMAC for a message using a key. Used to create an HMAC for a message using a key.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="HTTPClient" inherits="Reference" version="4.0"> <class name="HTTPClient" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Low-level hyper-text transfer protocol client. Low-level hyper-text transfer protocol client.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="HashingContext" inherits="Reference" version="4.0"> <class name="HashingContext" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Context to compute cryptographic hashes over multiple iterations. Context to compute cryptographic hashes over multiple iterations.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="JSONParseResult" inherits="Reference" version="4.0"> <class name="JSONParseResult" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Data class wrapper for decoded JSON. Data class wrapper for decoded JSON.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="JSONParser" inherits="Reference" version="4.0"> <class name="JSONParser" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="JavaClass" inherits="Reference" version="4.0"> <class name="JavaClass" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="JavaScriptObject" inherits="Reference" version="4.0"> <class name="JavaScriptObject" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
A wrapper class for native JavaScript objects. A wrapper class for native JavaScript objects.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="KinematicCollision2D" inherits="Reference" version="4.0"> <class name="KinematicCollision2D" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Collision data for [method PhysicsBody2D.move_and_collide] collisions. Collision data for [method PhysicsBody2D.move_and_collide] collisions.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="KinematicCollision3D" inherits="Reference" version="4.0"> <class name="KinematicCollision3D" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Collision data for [method PhysicsBody3D.move_and_collide] collisions. Collision data for [method PhysicsBody3D.move_and_collide] collisions.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="Lightmapper" inherits="Reference" version="4.0"> <class name="Lightmapper" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="MeshDataTool" inherits="Reference" version="4.0"> <class name="MeshDataTool" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Helper tool to access and edit [Mesh] data. Helper tool to access and edit [Mesh] data.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="MultiplayerAPI" inherits="Reference" version="4.0"> <class name="MultiplayerAPI" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
High-level multiplayer API. High-level multiplayer API.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="Mutex" inherits="Reference" version="4.0"> <class name="Mutex" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
A synchronization mutex (mutual exclusion). A synchronization mutex (mutual exclusion).
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="Node3DGizmo" inherits="Reference" version="4.0"> <class name="Node3DGizmo" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View file

@ -7,7 +7,7 @@
Every class which is not a built-in type inherits from this class. Every class which is not a built-in type inherits from this class.
You can construct Objects from scripting languages, using [code]Object.new()[/code] in GDScript, [code]new Object[/code] in C#, or the "Construct Object" node in VisualScript. You can construct Objects from scripting languages, using [code]Object.new()[/code] in GDScript, [code]new Object[/code] in C#, or the "Construct Object" node in VisualScript.
Objects do not manage memory. If a class inherits from Object, you will have to delete instances of it manually. To do so, call the [method free] method from your script or delete the instance from C++. Objects do not manage memory. If a class inherits from Object, you will have to delete instances of it manually. To do so, call the [method free] method from your script or delete the instance from C++.
Some classes that extend Object add memory management. This is the case of [Reference], which counts references and deletes itself automatically when no longer referenced. [Node], another fundamental type, deletes all its children when freed from memory. Some classes that extend Object add memory management. This is the case of [RefCounted], which counts references and deletes itself automatically when no longer referenced. [Node], another fundamental type, deletes all its children when freed from memory.
Objects export properties, which are mainly useful for storage and editing, but not really so much in programming. Properties are exported in [method _get_property_list] and handled in [method _get] and [method _set]. However, scripting languages and C++ have simpler means to export them. Objects export properties, which are mainly useful for storage and editing, but not really so much in programming. Properties are exported in [method _get_property_list] and handled in [method _get] and [method _set]. However, scripting languages and C++ have simpler means to export them.
Property membership can be tested directly in GDScript using [code]in[/code]: Property membership can be tested directly in GDScript using [code]in[/code]:
[codeblocks] [codeblocks]
@ -26,7 +26,7 @@
[/codeblocks] [/codeblocks]
The [code]in[/code] operator will evaluate to [code]true[/code] as long as the key exists, even if the value is [code]null[/code]. The [code]in[/code] operator will evaluate to [code]true[/code] as long as the key exists, even if the value is [code]null[/code].
Objects also receive notifications. Notifications are a simple way to notify the object about different events, so they can all be handled together. See [method _notification]. Objects also receive notifications. Notifications are a simple way to notify the object about different events, so they can all be handled together. See [method _notification].
[b]Note:[/b] Unlike references to a [Reference], references to an Object stored in a variable can become invalid without warning. Therefore, it's recommended to use [Reference] for data classes instead of [Object]. [b]Note:[/b] Unlike references to a [RefCounted], references to an Object stored in a variable can become invalid without warning. Therefore, it's recommended to use [RefCounted] for data classes instead of [Object].
</description> </description>
<tutorials> <tutorials>
<link title="When and how to avoid using nodes for everything">https://docs.godotengine.org/en/latest/getting_started/workflow/best_practices/node_alternatives.html</link> <link title="When and how to avoid using nodes for everything">https://docs.godotengine.org/en/latest/getting_started/workflow/best_practices/node_alternatives.html</link>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="PCKPacker" inherits="Reference" version="4.0"> <class name="PCKPacker" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Creates packages that can be loaded into a running project. Creates packages that can be loaded into a running project.
</brief_description> </brief_description>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="PackedDataContainerRef" inherits="Reference" version="4.0"> <class name="PackedDataContainerRef" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Reference version of [PackedDataContainer]. Reference-counted version of [PackedDataContainer].
</brief_description> </brief_description>
<description> <description>
</description> </description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="PacketPeer" inherits="Reference" version="4.0"> <class name="PacketPeer" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Abstraction and base class for packet-based protocols. Abstraction and base class for packet-based protocols.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="PhysicsShapeQueryParameters2D" inherits="Reference" version="4.0"> <class name="PhysicsShapeQueryParameters2D" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Parameters to be sent to a 2D shape physics query. Parameters to be sent to a 2D shape physics query.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="PhysicsShapeQueryParameters3D" inherits="Reference" version="4.0"> <class name="PhysicsShapeQueryParameters3D" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Parameters to be sent to a 3D shape physics query. Parameters to be sent to a 3D shape physics query.
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="PhysicsShapeQueryResult2D" inherits="Reference" version="4.0"> <class name="PhysicsShapeQueryResult2D" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Result of a 2D shape query in [PhysicsServer2D]. Result of a 2D shape query in [PhysicsServer2D].
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="PhysicsShapeQueryResult3D" inherits="Reference" version="4.0"> <class name="PhysicsShapeQueryResult3D" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
Result of a 3D shape query in [PhysicsServer3D]. Result of a 3D shape query in [PhysicsServer3D].
</brief_description> </brief_description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="PhysicsTestMotionResult2D" inherits="Reference" version="4.0"> <class name="PhysicsTestMotionResult2D" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="RDAttachmentFormat" inherits="Reference" version="4.0"> <class name="RDAttachmentFormat" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="RDPipelineColorBlendState" inherits="Reference" version="4.0"> <class name="RDPipelineColorBlendState" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="RDPipelineColorBlendStateAttachment" inherits="Reference" version="4.0"> <class name="RDPipelineColorBlendStateAttachment" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="RDPipelineDepthStencilState" inherits="Reference" version="4.0"> <class name="RDPipelineDepthStencilState" inherits="RefCounted" version="4.0">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

Some files were not shown because too many files have changed in this diff Show more