Cleaned up Object and Reference.

This commit is contained in:
Relintai 2023-12-31 00:15:31 +01:00
parent 65e8c7ec13
commit e7d48023fd
3 changed files with 47 additions and 50 deletions

View File

@ -1,9 +1,6 @@
#include "object.h"
#include "database/database.h"
Object::Object() {
db = nullptr;
}
Object::~Object() {

View File

@ -1,13 +1,13 @@
#ifndef OBJECT_H
#define OBJECT_H
#include "core/string.h"
#include "core/containers/vector.h"
#include "ustring.h"
#include "vector.h"
class Database;
//taken from GodotEngine's object.h
#define RCPP_OBJECT(m_class, m_inherits) \
#define SFW_OBJECT(m_class, m_inherits) \
private: \
void operator=(const m_class &p_rval) {} \
\
@ -32,8 +32,12 @@ public:
static String inherits_static() { \
return String(#m_inherits); \
} \
virtual bool is_class(const String &p_class) const override { return (p_class == (#m_class)) ? true : m_inherits::is_class(p_class); } \
virtual bool is_class_ptr(void *p_ptr) const override { return (p_ptr == get_class_ptr_static()) ? true : m_inherits::is_class_ptr(p_ptr); } \
virtual bool is_class(const String &p_class) const override { \
return (p_class == (#m_class)) ? true : m_inherits::is_class(p_class); \
} \
virtual bool is_class_ptr(void *p_ptr) const override { \
return (p_ptr == get_class_ptr_static()) ? true : m_inherits::is_class_ptr(p_ptr); \
} \
\
static void get_valid_parents_static(Vector<String> *p_parents) { \
if (m_class::_get_valid_parents_static != m_inherits::_get_valid_parents_static) { \
@ -47,8 +51,6 @@ private:
class Object {
public:
Database *db;
virtual String get_class() const { return "Object"; }
static void *get_class_ptr_static() {
static int ptr;

View File

@ -5,14 +5,12 @@
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
#include "safe_refcount.h"
#include "object.h"
#include "object_id.h"
#include "memory.h"
#include "object.h"
#include "safe_refcount.h"
class Reference : public Object {
RCPP_OBJECT(Reference, Object);
SFW_OBJECT(Reference, Object);
public:
/*_FORCE_INLINE_*/ bool is_referenced() const { return refcount_init.get() != 1; }
@ -183,7 +181,7 @@ typedef Ref<Reference> REF;
/*
class WeakRef : public Reference {
RCPP_OBJECT(WeakRef, Reference);
SFW_OBJECT(WeakRef, Reference);
ObjectID ref;