diff --git a/include/godot_cpp/core/class_db.hpp b/include/godot_cpp/core/class_db.hpp index 65694453..1d93b1a4 100644 --- a/include/godot_cpp/core/class_db.hpp +++ b/include/godot_cpp/core/class_db.hpp @@ -103,16 +103,12 @@ private: static void initialize_class(const ClassInfo &cl); static void bind_method_godot(const StringName &p_class_name, MethodBind *p_method); - template - static void _register_class(bool p_virtual = false, bool p_exposed = true); + template + static void _register_class(); public: - template - static void register_class(bool p_virtual = false); - template - static void register_abstract_class(); - template - static void register_internal_class(); + template + static void register_class(); template static void register_engine_class(); @@ -158,8 +154,8 @@ public: godot::ClassDB::bind_virtual_method(m_class::get_class_static(), #m_method, _call##m_method); \ } -template -void ClassDB::_register_class(bool p_virtual, bool p_exposed) { +template +void ClassDB::_register_class() { instance_binding_callbacks[T::get_class_static()] = &T::_gde_binding_callbacks; // Register this class within our plugin @@ -177,9 +173,9 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed) { // Register this class with Godot GDExtensionClassCreationInfo2 class_info = { - p_virtual, // GDExtensionBool is_virtual; + is_virtual, // GDExtensionBool is_virtual; is_abstract, // GDExtensionBool is_abstract; - p_exposed, // GDExtensionBool is_exposed; + is_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; @@ -206,19 +202,9 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed) { initialize_class(classes[cl.name]); } -template -void ClassDB::register_class(bool p_virtual) { - ClassDB::_register_class(p_virtual); -} - -template -void ClassDB::register_abstract_class() { - ClassDB::_register_class(); -} - -template -void ClassDB::register_internal_class() { - ClassDB::_register_class(false, false); +template +void ClassDB::register_class() { + ClassDB::_register_class(); } template @@ -282,9 +268,9 @@ MethodBind *ClassDB::bind_vararg_method(uint32_t p_flags, StringName p_name, M p } #define GDREGISTER_CLASS(m_class) ClassDB::register_class(); -#define GDREGISTER_VIRTUAL_CLASS(m_class) ClassDB::register_class(true); -#define GDREGISTER_ABSTRACT_CLASS(m_class) ClassDB::register_abstract_class(); -#define GDREGISTER_INTERNAL_CLASS(m_class) ClassDB::register_internal_class(); +#define GDREGISTER_VIRTUAL_CLASS(m_class) ClassDB::register_class(); +#define GDREGISTER_ABSTRACT_CLASS(m_class) ClassDB::register_class(); +#define GDREGISTER_INTERNAL_CLASS(m_class) ClassDB::register_class(); } // namespace godot diff --git a/test/src/example.h b/test/src/example.h index 6e00b7f5..5a8de5ca 100644 --- a/test/src/example.h +++ b/test/src/example.h @@ -177,4 +177,11 @@ protected: static void _bind_methods() {} }; +class ExampleInternal : public Object { + GDCLASS(ExampleInternal, Object); + +protected: + static void _bind_methods() {} +}; + #endif // EXAMPLE_CLASS_H diff --git a/test/src/register_types.cpp b/test/src/register_types.cpp index dbb37d90..1f6dbf10 100644 --- a/test/src/register_types.cpp +++ b/test/src/register_types.cpp @@ -21,11 +21,12 @@ void initialize_example_module(ModuleInitializationLevel p_level) { return; } - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(true); - ClassDB::register_abstract_class(); + GDREGISTER_CLASS(ExampleRef); + GDREGISTER_CLASS(ExampleMin); + GDREGISTER_CLASS(Example); + GDREGISTER_VIRTUAL_CLASS(ExampleVirtual); + GDREGISTER_ABSTRACT_CLASS(ExampleAbstract); + GDREGISTER_INTERNAL_CLASS(ExampleInternal); } void uninitialize_example_module(ModuleInitializationLevel p_level) {