From 95ff72706d447e8e27a80de668d477775de9bfd0 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Sat, 10 Jul 2021 19:23:36 -0400 Subject: [PATCH] Add ability to easily register signals with no arguments --- include/core/Godot.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/include/core/Godot.hpp b/include/core/Godot.hpp index bf52d7bb..a56a61e8 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 -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(name, Dictionary::make(varargs...)); } +template +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 T *Object::cast_to(const Object *obj) {