diff options
| author | Aaron Franke <arnfranke@yahoo.com> | 2021-07-10 19:23:36 -0400 |
|---|---|---|
| committer | Aaron Franke <arnfranke@yahoo.com> | 2021-07-10 19:23:36 -0400 |
| commit | 95ff72706d447e8e27a80de668d477775de9bfd0 (patch) | |
| tree | 53a8c6382ab6e84fe0906ef92d0d2743bbc4bad6 /include/core | |
| parent | e08ecdc28c5409cb5366027227e996c342dcee93 (diff) | |
| download | redot-cpp-95ff72706d447e8e27a80de668d477775de9bfd0.tar.gz | |
Add ability to easily register signals with no arguments
Diffstat (limited to 'include/core')
| -rw-r--r-- | include/core/Godot.hpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/include/core/Godot.hpp b/include/core/Godot.hpp index bf52d7b..a56a61e 100644 --- a/include/core/Godot.hpp +++ b/include/core/Godot.hpp @@ -496,7 +496,7 @@ void register_property(const char *name, void (T::*setter)(P), P (T::*getter)() } template <class T> -void register_signal(String name, Dictionary args = Dictionary()) { +void register_signal(String name, Dictionary args) { static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes"); godot_signal signal = {}; @@ -540,6 +540,17 @@ void register_signal(String name, Args... varargs) { register_signal<T>(name, Dictionary::make(varargs...)); } +template <class T> +void register_signal(String name) { + static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes"); + + godot_signal signal = {}; + signal.name = *(godot_string *)&name; + + godot::nativescript_api->godot_nativescript_register_signal(godot::_RegisterState::nativescript_handle, + T::___get_class_name(), &signal); +} + #ifndef GODOT_CPP_NO_OBJECT_CAST template <class T> T *Object::cast_to(const Object *obj) { |
