From 27b1f755f0d96c196e64b93a9d8d319c67b0973b Mon Sep 17 00:00:00 2001 From: somebody_master Date: Sun, 12 Feb 2023 12:49:37 +0100 Subject: [PATCH] =?UTF-8?q?Creaci=C3=B3n=20del=20primer=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: somebody_master --- gdextension/src/register_types.cpp | 48 ++++++++++++++++++++++++++++++ gdextension/src/register_types.h | 16 ++++++++++ gdextension/src/test.cpp | 2 +- gdextension/src/test.h | 15 ++++++++++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 gdextension/src/register_types.cpp create mode 100644 gdextension/src/register_types.h 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