diff options
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gd_parser.cpp | 6 | ||||
-rw-r--r-- | modules/gdscript/gd_script.cpp | 34 | ||||
-rw-r--r-- | modules/gdscript/gd_script.h | 4 |
3 files changed, 34 insertions, 10 deletions
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 202ab76da0..c55bfee591 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -65,8 +65,10 @@ bool GDParser::_enter_indent_block(BlockNode* p_block) { if (tokenizer->get_token()!=GDTokenizer::TK_COLON) { - - _set_error("':' expected at end of line."); + // report location at the previous token (on the previous line) + int error_line = tokenizer->get_token_line(-1); + int error_column = tokenizer->get_token_column(-1); + _set_error("':' expected at end of line.",error_line,error_column); return false; } tokenizer->advance(); 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! diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index 37ef47af6c..3d16b59065 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -286,7 +286,7 @@ friend class GDScriptLanguage; String name; - GDInstance* _create_instance(const Variant** p_args,int p_argcount,Object *p_owner,bool p_isref); + GDInstance* _create_instance(const Variant** p_args,int p_argcount,Object *p_owner,bool p_isref,Variant::CallError &r_error); void _set_subclass_path(Ref<GDScript>& p_sc,const String& p_path); @@ -373,6 +373,8 @@ public: virtual bool set(const StringName& p_name, const Variant& p_value); virtual bool get(const StringName& p_name, Variant &r_ret) const; virtual void get_property_list(List<PropertyInfo> *p_properties) const; + virtual Variant::Type get_property_type(const StringName& p_name,bool *r_is_valid=NULL) const; + virtual void get_method_list(List<MethodInfo> *p_list) const; virtual bool has_method(const StringName& p_method) const; |