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.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp
index 99ddc74bb4..c3cc779bce 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gd_script.cpp
@@ -1449,7 +1449,7 @@ Object *GDNativeClass::instance() {
-GDInstance* GDScript::_create_instance(const Variant** p_args,int p_argcount,Object *p_owner,bool p_isref) {
+GDInstance* GDScript::_create_instance(const Variant** p_args,int p_argcount,Object *p_owner,bool p_isref,Variant::CallError& r_error) {
/* STEP 1, CREATE */
@@ -1465,14 +1465,13 @@ GDInstance* GDScript::_create_instance(const Variant** p_args,int p_argcount,Obj
instances.insert(instance->owner);
- Variant::CallError err;
- initializer->call(instance,p_args,p_argcount,err);
+ initializer->call(instance,p_args,p_argcount,r_error);
- if (err.error!=Variant::CallError::CALL_OK) {
+ if (r_error.error!=Variant::CallError::CALL_OK) {
instance->script=Ref<GDScript>();
instance->owner->set_script_instance(NULL);
instances.erase(p_owner);
- ERR_FAIL_COND_V(err.error!=Variant::CallError::CALL_OK, NULL); //error consrtucting
+ ERR_FAIL_COND_V(r_error.error!=Variant::CallError::CALL_OK, NULL); //error constructing
}
//@TODO make thread safe
@@ -1505,7 +1504,7 @@ Variant GDScript::_new(const Variant** p_args,int p_argcount,Variant::CallError&
}
- GDInstance* instance = _create_instance(p_args,p_argcount,owner,r!=NULL);
+ GDInstance* instance = _create_instance(p_args,p_argcount,owner,r!=NULL,r_error);
if (!instance) {
if (ref.is_null()) {
memdelete(owner); //no owner, sorry
@@ -1637,7 +1636,8 @@ ScriptInstance* GDScript::instance_create(Object *p_this) {
}
}
- return _create_instance(NULL,0,p_this,p_this->cast_to<Reference>());
+ Variant::CallError unchecked_error;
+ return _create_instance(NULL,0,p_this,p_this->cast_to<Reference>(),unchecked_error);
}
bool GDScript::instance_has(const Object *p_this) const {
@@ -2274,6 +2274,26 @@ bool GDInstance::get(const StringName& p_name, Variant &r_ret) const {
return false;
}
+
+Variant::Type GDInstance::get_property_type(const StringName& p_name,bool *r_is_valid) const {
+
+
+ const GDScript *sptr=script.ptr();
+ while(sptr) {
+
+ if (sptr->member_info.has(p_name)) {
+ if (r_is_valid)
+ *r_is_valid=true;
+ return sptr->member_info[p_name].type;
+ }
+ sptr = sptr->_base;
+ }
+
+ if (r_is_valid)
+ *r_is_valid=false;
+ return Variant::NIL;
+}
+
void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const {
// exported members, not doen yet!