summaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2024-02-02 10:07:45 -0600
committerDavid Snopek <dsnopek@gmail.com>2024-02-22 14:39:50 -0600
commit23c010900c9a09c5c99bfbb0d465cd468aa74b6c (patch)
tree3eb67fc38be5fc6e0e0a168825f9a86b4d977ae0 /test/src
parentf90085917b16c3daff7b2d195db9bf222119eea1 (diff)
downloadredot-cpp-23c010900c9a09c5c99bfbb0d465cd468aa74b6c.tar.gz
Fix _notification with parent and child classes
Diffstat (limited to 'test/src')
-rw-r--r--test/src/example.cpp18
-rw-r--r--test/src/example.h25
-rw-r--r--test/src/register_types.cpp2
3 files changed, 45 insertions, 0 deletions
diff --git a/test/src/example.cpp b/test/src/example.cpp
index 136ac94..ede39ec 100644
--- a/test/src/example.cpp
+++ b/test/src/example.cpp
@@ -630,6 +630,24 @@ void Example::_input(const Ref<InputEvent> &event) {
}
}
+void ExampleBase::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_value1"), &ExampleBase::get_value1);
+ ClassDB::bind_method(D_METHOD("get_value2"), &ExampleBase::get_value2);
+}
+
+void ExampleBase::_notification(int p_what) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ value1 = 11;
+ value2 = 22;
+ }
+}
+
+void ExampleChild::_notification(int p_what) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ value2 = 33;
+ }
+}
+
String Example::test_virtual_implemented_in_script(const String &p_name, int p_value) {
String ret;
if (GDVIRTUAL_CALL(_do_something_virtual, p_name, p_value, ret)) {
diff --git a/test/src/example.h b/test/src/example.h
index 7da7b08..c66ee96 100644
--- a/test/src/example.h
+++ b/test/src/example.h
@@ -220,6 +220,31 @@ protected:
virtual int test_function() override { return 25; }
};
+class ExampleBase : public Node {
+ GDCLASS(ExampleBase, Node);
+
+protected:
+ int value1 = 0;
+ int value2 = 0;
+
+ static void _bind_methods();
+
+ void _notification(int p_what);
+
+public:
+ int get_value1() { return value1; }
+ int get_value2() { return value2; }
+};
+
+class ExampleChild : public ExampleBase {
+ GDCLASS(ExampleChild, ExampleBase);
+
+protected:
+ static void _bind_methods() {}
+
+ void _notification(int p_what);
+};
+
class ExampleRuntime : public Node {
GDCLASS(ExampleRuntime, Node);
diff --git a/test/src/register_types.cpp b/test/src/register_types.cpp
index 5c38241..cbede66 100644
--- a/test/src/register_types.cpp
+++ b/test/src/register_types.cpp
@@ -27,6 +27,8 @@ void initialize_example_module(ModuleInitializationLevel p_level) {
ClassDB::register_class<ExampleVirtual>(true);
ClassDB::register_abstract_class<ExampleAbstractBase>();
ClassDB::register_class<ExampleConcrete>();
+ ClassDB::register_class<ExampleBase>();
+ ClassDB::register_class<ExampleChild>();
ClassDB::register_runtime_class<ExampleRuntime>();
}