diff --git a/gdextension/src/register_types.cpp b/gdextension/src/register_types.cpp new file mode 100644 index 0000000..0bff7d2 --- /dev/null +++ b/gdextension/src/register_types.cpp @@ -0,0 +1,48 @@ +/* godot-cpp integration testing project. + * + * This is free and unencumbered software released into the public domain. + */ + +#include "register_types.h" + +#include + +#include +#include +#include + +#include "test.h" + +using namespace godot; + +void initialize_test_module(ModuleInitializationLevel p_level) { + if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { + return; + } + + ClassDB::register_class(); +} + +void uninitialize_test_module(ModuleInitializationLevel p_level) { + if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { + return; + } +} + +extern "C" { +// Initialization. +GDExtensionBool GDE_EXPORT +test_library_init(const GDExtensionInterface *p_interface, + GDExtensionClassLibraryPtr p_library, + GDExtensionInitialization *r_initialization) { + godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, + r_initialization); + + init_obj.register_initializer(initialize_test_module); + init_obj.register_terminator(uninitialize_test_module); + init_obj.set_minimum_library_initialization_level( + MODULE_INITIALIZATION_LEVEL_SCENE); + + return init_obj.init(); +} +} diff --git a/gdextension/src/register_types.h b/gdextension/src/register_types.h new file mode 100644 index 0000000..d7c328b --- /dev/null +++ b/gdextension/src/register_types.h @@ -0,0 +1,16 @@ +/* godot-cpp integration testing project. + * + * This is free and unencumbered software released into the public domain. + */ + +#ifndef EXAMPLE_REGISTER_TYPES_H +#define EXAMPLE_REGISTER_TYPES_H + +#include + +using namespace godot; + +void initialize_test_module(ModuleInitializationLevel p_level); +void uninitialize_test_module(ModuleInitializationLevel p_level); + +#endif // EXAMPLE_REGISTER_TYPES_H diff --git a/gdextension/src/test.cpp b/gdextension/src/test.cpp index 91ab081..33296cc 100644 --- a/gdextension/src/test.cpp +++ b/gdextension/src/test.cpp @@ -1 +1 @@ -#include "test.h" \ No newline at end of file +#include "test.h" diff --git a/gdextension/src/test.h b/gdextension/src/test.h index e69de29..257b016 100644 --- a/gdextension/src/test.h +++ b/gdextension/src/test.h @@ -0,0 +1,15 @@ +#ifndef TEST_H +#define TEST_H + +#include + +using namespace godot; + +class Test : public Node3D { + GDCLASS(Test, Node3D); + +protected: + static void _bind_methods() {} +}; + +#endif