summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp/classes/wrapped.hpp
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2023-10-11 22:59:59 -0500
committerDavid Snopek <dsnopek@gmail.com>2023-10-16 10:19:11 -0500
commitb507b3e5913344a97e90ba27b221e28924f555ab (patch)
tree3f74866f963be20325c590f2e4eee105e9d4bbe3 /include/godot_cpp/classes/wrapped.hpp
parentef2f63a00c5496cc325e8546acd743787e87a83d (diff)
downloadredot-cpp-b507b3e5913344a97e90ba27b221e28924f555ab.tar.gz
Automatically register only engine classes whose header has been included
Diffstat (limited to 'include/godot_cpp/classes/wrapped.hpp')
-rw-r--r--include/godot_cpp/classes/wrapped.hpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/godot_cpp/classes/wrapped.hpp b/include/godot_cpp/classes/wrapped.hpp
index 879346b..2bbffc0 100644
--- a/include/godot_cpp/classes/wrapped.hpp
+++ b/include/godot_cpp/classes/wrapped.hpp
@@ -111,6 +111,22 @@ namespace internal {
GDExtensionPropertyInfo *create_c_property_list(const ::godot::List<::godot::PropertyInfo> &plist_cpp, uint32_t *r_size);
void free_c_property_list(GDExtensionPropertyInfo *plist);
+typedef void (*EngineClassRegistrationCallback)();
+void add_engine_class_registration_callback(EngineClassRegistrationCallback p_callback);
+void register_engine_class(const StringName &p_name, const GDExtensionInstanceBindingCallbacks *p_callbacks);
+void register_engine_classes();
+
+template <class T>
+struct EngineClassRegistration {
+ EngineClassRegistration() {
+ add_engine_class_registration_callback(&EngineClassRegistration<T>::callback);
+ }
+
+ static void callback() {
+ register_engine_class(T::get_class_static(), &T::_gde_binding_callbacks);
+ }
+};
+
} // namespace internal
} // namespace godot
@@ -352,6 +368,7 @@ public:
// Don't use this for your classes, use GDCLASS() instead.
#define GDEXTENSION_CLASS_ALIAS(m_class, m_alias_for, m_inherits) \
private: \
+ inline static ::godot::internal::EngineClassRegistration<m_class> _gde_engine_class_registration_helper; \
void operator=(const m_class &p_rval) {} \
\
protected: \