MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _parse_script_properties

Method _parse_script_properties

scene/debugger/scene_debugger.cpp:780–832  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

778}
779
780void SceneDebuggerObject::_parse_script_properties(Script *p_script, ScriptInstance *p_instance) {
781 typedef HashMap<const Script *, HashSet<StringName>> ScriptMemberMap;
782 typedef HashMap<const Script *, HashMap<StringName, Variant>> ScriptConstantsMap;
783
784 ScriptMemberMap members;
785 if (p_instance) {
786 members[p_script] = HashSet<StringName>();
787 p_script->get_members(&(members[p_script]));
788 }
789
790 ScriptConstantsMap constants;
791 constants[p_script] = HashMap<StringName, Variant>();
792 p_script->get_constants(&(constants[p_script]));
793
794 Ref<Script> base = p_script->get_base_script();
795 while (base.is_valid()) {
796 if (p_instance) {
797 members[base.ptr()] = HashSet<StringName>();
798 base->get_members(&(members[base.ptr()]));
799 }
800
801 constants[base.ptr()] = HashMap<StringName, Variant>();
802 base->get_constants(&(constants[base.ptr()]));
803
804 base = base->get_base_script();
805 }
806
807 // Members
808 for (KeyValue<const Script *, HashSet<StringName>> sm : members) {
809 for (const StringName &E : sm.value) {
810 Variant m;
811 if (p_instance->get(E, m)) {
812 String script_path = sm.key == p_script ? "" : sm.key->get_path().get_file() + "/";
813 PropertyInfo pi(m.get_type(), "Members/" + script_path + E);
814 properties.push_back(SceneDebuggerProperty(pi, m));
815 }
816 }
817 }
818 // Constants
819 for (KeyValue<const Script *, HashMap<StringName, Variant>> &sc : constants) {
820 for (const KeyValue<StringName, Variant> &E : sc.value) {
821 String script_path = sc.key == p_script ? "" : sc.key->get_path().get_file() + "/";
822 if (E.value.get_type() == Variant::OBJECT) {
823 Variant inst_id = ((Object *)E.value)->get_instance_id();
824 PropertyInfo pi(inst_id.get_type(), "Constants/" + E.key, PROPERTY_HINT_OBJECT_ID, "Object");
825 properties.push_back(SceneDebuggerProperty(pi, inst_id));
826 } else {
827 PropertyInfo pi(E.value.get_type(), "Constants/" + script_path + E.key);
828 properties.push_back(SceneDebuggerProperty(pi, E.value));
829 }
830 }
831 }
832}
833
834void SceneDebuggerObject::serialize(Array &r_arr, int p_max_size) {
835 Array send_props;

Callers

nothing calls this directly

Calls 11

get_membersMethod · 0.45
get_constantsMethod · 0.45
get_base_scriptMethod · 0.45
is_validMethod · 0.45
ptrMethod · 0.45
getMethod · 0.45
get_fileMethod · 0.45
get_pathMethod · 0.45
get_typeMethod · 0.45
push_backMethod · 0.45
get_instance_idMethod · 0.45

Tested by

no test coverage detected