From 810f049edfdb0827bc3808da271f767cd860ed34 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 1 Jan 2016 10:27:25 -0300 Subject: [PATCH] introspection of signals and signal connections from GDScript was not working, fixes #2325 --- core/object.cpp | 69 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/core/object.cpp b/core/object.cpp index 773581d41d0..52c8eec3d32 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1011,6 +1011,27 @@ Array Object::_get_property_list_bind() const { return convert_property_list(&lpi); } + +static Dictionary _get_dict_from_method(const MethodInfo &mi) { + + Dictionary d; + d["name"]=mi.name; + d["args"]=convert_property_list(&mi.arguments); + Array da; + for(int i=0;i ml; @@ -1019,20 +1040,7 @@ Array Object::_get_method_list_bind() const { for(List::Element *E=ml.front();E;E=E->next()) { - Dictionary d; - d["name"]=E->get().name; - d["args"]=convert_property_list(&E->get().arguments); - Array da; - for(int i=0;iget().default_arguments.size();i++) - da.push_back(E->get().default_arguments[i]); - d["default_args"]=da; - d["flags"]=E->get().flags; - d["id"]=E->get().id; - Dictionary r; - r["type"]=E->get().return_val.type; - r["hint"]=E->get().return_val.hint; - r["hint_string"]=E->get().return_val.hint_string; - d["return_type"]=r; + Dictionary d = _get_dict_from_method(E->get()); //va.push_back(d); ret.push_back(d); } @@ -1299,11 +1307,39 @@ void Object::_emit_signal(const StringName& p_name,const Array& p_pargs){ #endif Array Object::_get_signal_list() const{ - return Array(); + List signal_list; + get_signal_list(&signal_list); + + Array ret; + for (List::Element *E=signal_list.front();E;E=E->next()) { + + ret.push_back(_get_dict_from_method(E->get())); + } + + return ret; } Array Object::_get_signal_connection_list(const String& p_signal) const{ - return Array(); + List conns; + get_all_signal_connections(&conns); + + Array ret; + + for (List::Element *E=conns.front();E;E=E->next()) { + + Connection &c=E->get(); + Dictionary rc; + rc["signal"]=c.signal; + rc["method"]=c.method; + rc["source"]=c.source; + rc["target"]=c.target; + rc["binds"]=c.binds; + rc["flags"]=c.flags; + ret.push_back(rc); + } + + return ret; + } @@ -1618,6 +1654,7 @@ void Object::_bind_methods() { ObjectTypeDB::bind_method(_MD("has_method","method"),&Object::has_method); ObjectTypeDB::bind_method(_MD("get_signal_list"),&Object::_get_signal_list); + ObjectTypeDB::bind_method(_MD("get_signal_connection_list","signal"),&Object::_get_signal_connection_list); ObjectTypeDB::bind_method(_MD("connect","signal","target:Object","method","binds","flags"),&Object::connect,DEFVAL(Array()),DEFVAL(0)); ObjectTypeDB::bind_method(_MD("disconnect","signal","target:Object","method"),&Object::disconnect);