summaryrefslogtreecommitdiffstats
path: root/core/object/make_virtuals.py
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2023-08-04 20:34:14 -0500
committerDavid Snopek <dsnopek@gmail.com>2023-09-25 22:10:17 -0500
commit2733a6f762fc04956361a1eb49f1dffaa3d80489 (patch)
tree132e7ca1840b60a7a24423a4f011f0b716456f82 /core/object/make_virtuals.py
parentdf0a822323a79e1a645f0c6a17d51c7602f23166 (diff)
downloadredot-engine-2733a6f762fc04956361a1eb49f1dffaa3d80489.tar.gz
Implement reloading of GDExtensions
Diffstat (limited to 'core/object/make_virtuals.py')
-rw-r--r--core/object/make_virtuals.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/object/make_virtuals.py b/core/object/make_virtuals.py
index c2e69dc8e2..0f3cf3916a 100644
--- a/core/object/make_virtuals.py
+++ b/core/object/make_virtuals.py
@@ -22,6 +22,7 @@ _FORCE_INLINE_ bool _gdvirtual_##m_name##_call($CALLARGS) $CONST { \\
} else if (_get_extension()->get_virtual) {\\
_gdvirtual_##m_name = (void *)_get_extension()->get_virtual(_get_extension()->class_userdata, &_gdvirtual_##m_name##_sn);\\
}\\
+ GDVIRTUAL_TRACK(_gdvirtual_##m_name, _gdvirtual_##m_name##_initialized); \\
_gdvirtual_##m_name##_initialized = true;\\
}\\
if (_gdvirtual_##m_name) {\\
@@ -56,6 +57,7 @@ _FORCE_INLINE_ bool _gdvirtual_##m_name##_overridden() const { \\
} else if (_get_extension()->get_virtual) {\\
_gdvirtual_##m_name = (void *)_get_extension()->get_virtual(_get_extension()->class_userdata, &_gdvirtual_##m_name##_sn);\\
}\\
+ GDVIRTUAL_TRACK(_gdvirtual_##m_name, _gdvirtual_##m_name##_initialized); \\
_gdvirtual_##m_name##_initialized = true;\\
}\\
if (_gdvirtual_##m_name) {\\
@@ -175,6 +177,18 @@ def run(target, source, env):
#include "core/object/script_instance.h"
+#ifdef TOOLS_ENABLED
+#define GDVIRTUAL_TRACK(m_virtual, m_initialized) \\
+ if (_get_extension()->reloadable) {\\
+ VirtualMethodTracker *tracker = memnew(VirtualMethodTracker);\\
+ tracker->method = (void **)&m_virtual;\\
+ tracker->initialized = &m_initialized;\\
+ tracker->next = virtual_method_list;\\
+ virtual_method_list = tracker;\\
+ }
+#else
+#define GDVIRTUAL_TRACK(m_virtual, m_initialized)
+#endif
"""