Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gdextension/gdextension_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ typedef struct {
typedef struct {
GDExtensionBool is_virtual;
GDExtensionBool is_abstract;
GDExtensionBool is_exposed;
GDExtensionClassSet set_func;
GDExtensionClassGet get_func;
GDExtensionClassGetPropertyList get_property_list_func;
Expand Down
13 changes: 11 additions & 2 deletions include/godot_cpp/core/class_db.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,16 @@ class ClassDB {
static void bind_method_godot(const StringName &p_class_name, MethodBind *p_method);

template <class T, bool is_abstract>
static void _register_class(bool p_virtual = false);
static void _register_class(bool p_virtual = false, bool p_exposed = true);

public:
template <class T>
static void register_class(bool p_virtual = false);
template <class T>
static void register_abstract_class();
template <class T>
static void register_internal_class();
template <class T>
static void register_engine_class();

template <class N, class M, typename... VarArgs>
Expand Down Expand Up @@ -157,7 +159,7 @@ class ClassDB {
}

template <class T, bool is_abstract>
void ClassDB::_register_class(bool p_virtual) {
void ClassDB::_register_class(bool p_virtual, bool p_exposed) {
instance_binding_callbacks[T::get_class_static()] = &T::_gde_binding_callbacks;

// Register this class within our plugin
Expand All @@ -177,6 +179,7 @@ void ClassDB::_register_class(bool p_virtual) {
GDExtensionClassCreationInfo2 class_info = {
p_virtual, // GDExtensionBool is_virtual;
is_abstract, // GDExtensionBool is_abstract;
p_exposed, // GDExtensionBool is_exposed;
T::set_bind, // GDExtensionClassSet set_func;
T::get_bind, // GDExtensionClassGet get_func;
T::has_get_property_list() ? T::get_property_list_bind : nullptr, // GDExtensionClassGetPropertyList get_property_list_func;
Expand Down Expand Up @@ -213,6 +216,11 @@ void ClassDB::register_abstract_class() {
ClassDB::_register_class<T, true>();
}

template <class T>
void ClassDB::register_internal_class() {
ClassDB::_register_class<T, false>(false, false);
}

template <class T>
void ClassDB::register_engine_class() {
instance_binding_callbacks[T::get_class_static()] = &T::_gde_binding_callbacks;
Expand Down Expand Up @@ -276,6 +284,7 @@ MethodBind *ClassDB::bind_vararg_method(uint32_t p_flags, StringName p_name, M p
#define GDREGISTER_CLASS(m_class) ClassDB::register_class<m_class>();
#define GDREGISTER_VIRTUAL_CLASS(m_class) ClassDB::register_class<m_class>(true);
#define GDREGISTER_ABSTRACT_CLASS(m_class) ClassDB::register_abstract_class<m_class>();
#define GDREGISTER_INTERNAL_CLASS(m_class) ClassDB::register_internal_class<m_class>();

} // namespace godot

Expand Down