From 69c95f4b4c128a22777af1e155bc24c7033decca Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 19 Feb 2020 16:27:19 -0300 Subject: Reworked signal connection system, added support for Callable and Signal objects and made them default. --- core/class_db.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'core/class_db.cpp') diff --git a/core/class_db.cpp b/core/class_db.cpp index a2941d70f6..35e216a58f 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -1033,7 +1033,7 @@ bool ClassDB::set_property(Object *p_object, const StringName &p_property, const return true; //return true but do nothing } - Variant::CallError ce; + Callable::CallError ce; if (psg->index >= 0) { Variant index = psg->index; @@ -1055,7 +1055,7 @@ bool ClassDB::set_property(Object *p_object, const StringName &p_property, const } if (r_valid) - *r_valid = ce.error == Variant::CallError::CALL_OK; + *r_valid = ce.error == Callable::CallError::CALL_OK; return true; } @@ -1078,12 +1078,12 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia if (psg->index >= 0) { Variant index = psg->index; const Variant *arg[1] = { &index }; - Variant::CallError ce; + Callable::CallError ce; r_value = p_object->call(psg->getter, arg, 1, ce); } else { - Variant::CallError ce; + Callable::CallError ce; if (psg->_getptr) { r_value = psg->_getptr->call(p_object, NULL, 0, ce); @@ -1094,13 +1094,23 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia return true; } - const int *c = check->constant_map.getptr(p_property); + const int *c = check->constant_map.getptr(p_property); //constants count if (c) { r_value = *c; return true; } + if (check->method_map.has(p_property)) { //methods count + r_value = Callable(p_object, p_property); + return true; + } + + if (check->signal_map.has(p_property)) { //signals count + r_value = Signal(p_object, p_property); + return true; + } + check = check->inherits_ptr; } -- cgit v1.2.3