summaryrefslogtreecommitdiff
path: root/modules/gdscript/gd_script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/gd_script.cpp')
-rw-r--r--modules/gdscript/gd_script.cpp60
1 files changed, 49 insertions, 11 deletions
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp
index 196e328769..b20fc51a03 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gd_script.cpp
@@ -1537,7 +1537,7 @@ void GDScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) {
_GDScriptMemberSort ms;
ERR_CONTINUE(!scr->member_indices.has(E->key()));
- ms.index=scr->member_indices[E->key()];
+ ms.index=scr->member_indices[E->key()].index;
ms.name=E->key();
msort.push_back(ms);
@@ -1626,9 +1626,11 @@ void GDScript::set_source_code(const String& p_code) {
source=p_code;
}
-void GDScript::update_exports() {
+
+void GDScript::_update_exports(Set<PlaceHolderScriptInstance*> *p_instances) {
#ifdef TOOLS_ENABLED
+
String basedir=path;
if (basedir=="")
@@ -1645,8 +1647,20 @@ void GDScript::update_exports() {
const GDParser::Node* root = parser.get_parse_tree();
ERR_FAIL_COND(root->type!=GDParser::Node::TYPE_CLASS);
+
+
const GDParser::ClassNode *c = static_cast<const GDParser::ClassNode*>(root);
+ if (c->extends_used && String(c->extends_file)!="") {
+
+ Ref<GDScript> bf = ResourceLoader::load(c->extends_file);
+ if (bf.is_valid()) {
+
+ bf->_update_exports(p_instances);
+
+ }
+ }
+
List<PropertyInfo> plist;
Map<StringName,Variant> default_values;
@@ -1660,10 +1674,19 @@ void GDScript::update_exports() {
}
- for (Set<PlaceHolderScriptInstance*>::Element *E=placeholders.front();E;E=E->next()) {
+ for (Set<PlaceHolderScriptInstance*>::Element *E=p_instances->front();E;E=E->next()) {
E->get()->update(plist,default_values);
}
+#endif
+}
+
+void GDScript::update_exports() {
+
+#ifdef TOOLS_ENABLED
+
+ _update_exports(&placeholders);
+
#endif
}
@@ -1938,9 +1961,9 @@ const Map<StringName,GDFunction>& GDScript::debug_get_member_functions() const {
StringName GDScript::debug_get_member_by_index(int p_idx) const {
- for(const Map<StringName,int>::Element *E=member_indices.front();E;E=E->next()) {
+ for(const Map<StringName,MemberInfo>::Element *E=member_indices.front();E;E=E->next()) {
- if (E->get()==p_idx)
+ if (E->get().index==p_idx)
return E->key();
}
@@ -1979,11 +2002,18 @@ bool GDInstance::set(const StringName& p_name, const Variant& p_value) {
//member
{
- const Map<StringName,int>::Element *E = script->member_indices.find(p_name);
+ const Map<StringName,GDScript::MemberInfo>::Element *E = script->member_indices.find(p_name);
if (E) {
- members[E->get()]=p_value;
+ members[E->get().index]=p_value;
+ if (E->get().setter) {
+ const Variant *val=&p_value;
+ Variant::CallError err;
+ call(E->get().setter,&val,1,err);
+ if (err.error==Variant::CallError::CALL_OK) {
+ return true; //function exists, call was successful
+ }
+ }
return true;
-
}
}
@@ -2016,9 +2046,16 @@ bool GDInstance::get(const StringName& p_name, Variant &r_ret) const {
while(sptr) {
{
- const Map<StringName,int>::Element *E = script->member_indices.find(p_name);
+ const Map<StringName,GDScript::MemberInfo>::Element *E = script->member_indices.find(p_name);
if (E) {
- r_ret=members[E->get()];
+ if (E->get().getter) {
+ Variant::CallError err;
+ r_ret=const_cast<GDInstance*>(this)->call(E->get().getter,NULL,0,err);
+ if (err.error==Variant::CallError::CALL_OK) {
+ return true;
+ }
+ }
+ r_ret=members[E->get().index];
return true; //index found
}
@@ -2108,7 +2145,7 @@ void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const {
_GDScriptMemberSort ms;
ERR_CONTINUE(!sptr->member_indices.has(E->key()));
- ms.index=sptr->member_indices[E->key()];
+ ms.index=sptr->member_indices[E->key()].index;
ms.name=E->key();
msort.push_back(ms);
@@ -2418,6 +2455,7 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
"false" ,
"tool",
"var",
+ "setget",
"pass",
"and",
"or",