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

Method get_property_list

modules/gdscript/gdscript.cpp:1885–1963  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1883}
1884
1885void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
1886 // exported members, not done yet!
1887
1888 const GDScript *sptr = script.ptr();
1889 List<PropertyInfo> props;
1890
1891 while (sptr) {
1892 if (likely(sptr->valid)) {
1893 HashMap<StringName, GDScriptFunction *>::ConstIterator E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list);
1894 if (E) {
1895 Callable::CallError err;
1896 Variant ret = E->value->call(const_cast<GDScriptInstance *>(this), nullptr, 0, err);
1897 if (err.error == Callable::CallError::CALL_OK) {
1898 ERR_FAIL_COND_MSG(ret.get_type() != Variant::ARRAY, "Wrong type for _get_property_list, must be an array of dictionaries.");
1899
1900 Array arr = ret;
1901 for (int i = 0; i < arr.size(); i++) {
1902 Dictionary d = arr[i];
1903 ERR_CONTINUE(!d.has("name"));
1904 ERR_CONTINUE(!d.has("type"));
1905
1906 PropertyInfo pinfo;
1907 pinfo.name = d["name"];
1908 pinfo.type = Variant::Type(d["type"].operator int());
1909 if (d.has("hint")) {
1910 pinfo.hint = PropertyHint(d["hint"].operator int());
1911 }
1912 if (d.has("hint_string")) {
1913 pinfo.hint_string = d["hint_string"];
1914 }
1915 if (d.has("usage")) {
1916 pinfo.usage = d["usage"];
1917 }
1918 if (d.has("class_name")) {
1919 pinfo.class_name = d["class_name"];
1920 }
1921
1922 ERR_CONTINUE(pinfo.name.is_empty() && (pinfo.usage & PROPERTY_USAGE_STORAGE));
1923 ERR_CONTINUE(pinfo.type < 0 || pinfo.type >= Variant::VARIANT_MAX);
1924
1925 props.push_back(pinfo);
1926 }
1927 }
1928 }
1929 }
1930
1931 //instance a fake script for editing the values
1932
1933 Vector<_GDScriptMemberSort> msort;
1934 for (const KeyValue<StringName, GDScript::MemberInfo> &F : sptr->member_indices) {
1935 if (!sptr->members.has(F.key)) {
1936 continue; // Skip base class members.
1937 }
1938 _GDScriptMemberSort ms;
1939 ms.index = F.value.index;
1940 ms.name = F.key;
1941 msort.push_back(ms);
1942 }

Callers 6

_list_call_argumentsFunction · 0.45
complete_codeMethod · 0.45

Calls 15

get_class_categoryMethod · 0.80
TypeEnum · 0.70
sizeMethod · 0.65
PropertyHintEnum · 0.50
validate_propertyFunction · 0.50
ptrMethod · 0.45
findMethod · 0.45
callMethod · 0.45
get_typeMethod · 0.45
hasMethod · 0.45
is_emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected