diff options
| author | David Snopek <dsnopek@gmail.com> | 2024-02-21 07:51:52 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-21 07:51:52 -0600 |
| commit | f90085917b16c3daff7b2d195db9bf222119eea1 (patch) | |
| tree | dc26c7ec5800a5facbeb71e035bb4748c00b1bbc /test/src | |
| parent | a6d939334166602b85ee4d28c0daa1c87c9fba02 (diff) | |
| parent | fb884573ea1a0ec36d1968bf12a667cd17023d38 (diff) | |
| download | redot-cpp-f90085917b16c3daff7b2d195db9bf222119eea1.tar.gz | |
Merge pull request #1256 from dsnopek/placeholders
Allow registering "runtime classes"
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/example.cpp | 20 | ||||
| -rw-r--r-- | test/src/example.h | 16 | ||||
| -rw-r--r-- | test/src/register_types.cpp | 1 |
3 files changed, 37 insertions, 0 deletions
diff --git a/test/src/example.cpp b/test/src/example.cpp index 53d11f4..136ac94 100644 --- a/test/src/example.cpp +++ b/test/src/example.cpp @@ -637,3 +637,23 @@ String Example::test_virtual_implemented_in_script(const String &p_name, int p_v } return "Unimplemented"; } + +void ExampleRuntime::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_prop_value", "value"), &ExampleRuntime::set_prop_value); + ClassDB::bind_method(D_METHOD("get_prop_value"), &ExampleRuntime::get_prop_value); + ADD_PROPERTY(PropertyInfo(Variant::INT, "prop_value"), "set_prop_value", "get_prop_value"); +} + +void ExampleRuntime::set_prop_value(int p_prop_value) { + prop_value = p_prop_value; +} + +int ExampleRuntime::get_prop_value() const { + return prop_value; +} + +ExampleRuntime::ExampleRuntime() { +} + +ExampleRuntime::~ExampleRuntime() { +} diff --git a/test/src/example.h b/test/src/example.h index 1c57720..7da7b08 100644 --- a/test/src/example.h +++ b/test/src/example.h @@ -220,4 +220,20 @@ protected: virtual int test_function() override { return 25; } }; +class ExampleRuntime : public Node { + GDCLASS(ExampleRuntime, Node); + + int prop_value = 12; + +protected: + static void _bind_methods(); + +public: + void set_prop_value(int p_prop_value); + int get_prop_value() const; + + ExampleRuntime(); + ~ExampleRuntime(); +}; + #endif // EXAMPLE_CLASS_H diff --git a/test/src/register_types.cpp b/test/src/register_types.cpp index 58080d2..5c38241 100644 --- a/test/src/register_types.cpp +++ b/test/src/register_types.cpp @@ -27,6 +27,7 @@ void initialize_example_module(ModuleInitializationLevel p_level) { ClassDB::register_class<ExampleVirtual>(true); ClassDB::register_abstract_class<ExampleAbstractBase>(); ClassDB::register_class<ExampleConcrete>(); + ClassDB::register_runtime_class<ExampleRuntime>(); } void uninitialize_example_module(ModuleInitializationLevel p_level) { |
