summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-05-28 11:59:18 +0200
committerGitHub <noreply@github.com>2018-05-28 11:59:18 +0200
commitbce002f5c3555080cc9edec7fa6650c9f072e632 (patch)
tree101a4a24dc576272029103ace8a454446320d066
parent98846b39ee039358584884b439b96e799f1d2bd0 (diff)
parent7e499683a2f147ae84ca431fdbb69a6a0e4b783b (diff)
Merge pull request #18410 from GodotExplorer/debugger-inherited-variables
Add inherited variables support for script debugger
-rw-r--r--core/script_debugger_remote.cpp56
1 files changed, 41 insertions, 15 deletions
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 7a30a33c67..22e9fe31b5 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -567,22 +567,46 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
if (ScriptInstance *si = obj->get_script_instance()) {
if (!si->get_script().is_null()) {
- Set<StringName> members;
- si->get_script()->get_members(&members);
- for (Set<StringName>::Element *E = members.front(); E; E = E->next()) {
-
- Variant m;
- if (si->get(E->get(), m)) {
- PropertyInfo pi(m.get_type(), String("Members/") + E->get());
- properties.push_back(PropertyDesc(pi, m));
+ typedef Map<const Script *, Set<StringName> > ScriptMemberMap;
+ typedef Map<const Script *, Map<StringName, Variant> > ScriptConstantsMap;
+
+ ScriptMemberMap members;
+ members[si->get_script().ptr()] = Set<StringName>();
+ si->get_script()->get_members(&(members[si->get_script().ptr()]));
+
+ ScriptConstantsMap constants;
+ constants[si->get_script().ptr()] = Map<StringName, Variant>();
+ si->get_script()->get_constants(&(constants[si->get_script().ptr()]));
+
+ Ref<Script> base = si->get_script()->get_base_script();
+ while (base.is_valid()) {
+
+ members[base.ptr()] = Set<StringName>();
+ base->get_members(&(members[base.ptr()]));
+
+ constants[base.ptr()] = Map<StringName, Variant>();
+ base->get_constants(&(constants[base.ptr()]));
+
+ base = base->get_base_script();
+ }
+
+ for (ScriptMemberMap::Element *sm = members.front(); sm; sm = sm->next()) {
+ for (Set<StringName>::Element *E = sm->get().front(); E; E = E->next()) {
+ Variant m;
+ if (si->get(E->get(), m)) {
+ String script_path = sm->key() == si->get_script().ptr() ? "" : sm->key()->get_path().get_file() + "/";
+ PropertyInfo pi(m.get_type(), "Members/" + script_path + E->get());
+ properties.push_back(PropertyDesc(pi, m));
+ }
}
}
- Map<StringName, Variant> constants;
- si->get_script()->get_constants(&constants);
- for (Map<StringName, Variant>::Element *E = constants.front(); E; E = E->next()) {
- PropertyInfo pi(E->value().get_type(), (String("Constants/") + E->key()));
- properties.push_back(PropertyDesc(pi, E->value()));
+ for (ScriptConstantsMap::Element *sc = constants.front(); sc; sc = sc->next()) {
+ for (Map<StringName, Variant>::Element *E = sc->get().front(); E; E = E->next()) {
+ String script_path = sc->key() == si->get_script().ptr() ? "" : sc->key()->get_path().get_file() + "/";
+ PropertyInfo pi(E->value().get_type(), "Constants/" + script_path + E->key());
+ properties.push_back(PropertyDesc(pi, E->value()));
+ }
}
}
}
@@ -658,8 +682,10 @@ void ScriptDebuggerRemote::_set_object_property(ObjectID p_id, const String &p_p
return;
String prop_name = p_property;
- if (p_property.begins_with("Members/"))
- prop_name = p_property.substr(8, p_property.length());
+ if (p_property.begins_with("Members/")) {
+ Vector<String> ss = p_property.split("/");
+ prop_name = ss[ss.size() - 1];
+ }
obj->set(prop_name, p_value);
}