summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gd_function.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-01-04 17:37:45 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-01-04 17:37:45 -0300
commit9e477babb3bf0ce5179395c2a5155a3f3cd36798 (patch)
tree5246a7c0bc09580f60ea17b694aacc9cd8da8731 /modules/gdscript/gd_function.cpp
parent76c2e8583e70e8c976a306e77a40e8e7226aa249 (diff)
downloadredot-engine-9e477babb3bf0ce5179395c2a5155a3f3cd36798.tar.gz
-GDScript support for accessing properties directly
-Added code lookup and code completion support for properties too
Diffstat (limited to 'modules/gdscript/gd_function.cpp')
-rw-r--r--modules/gdscript/gd_function.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp
index 2bacb50d86..e3217e9218 100644
--- a/modules/gdscript/gd_function.cpp
+++ b/modules/gdscript/gd_function.cpp
@@ -487,7 +487,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
case OPCODE_GET_NAMED: {
- CHECK_SPACE(3);
+ CHECK_SPACE(4);
GET_VARIANT_PTR(src,1);
GET_VARIANT_PTR(dst,3);
@@ -519,6 +519,46 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
#endif
ip+=4;
} continue;
+ case OPCODE_SET_MEMBER: {
+
+ CHECK_SPACE(3);
+ int indexname = _code_ptr[ip+1];
+ ERR_BREAK(indexname<0 || indexname>=_global_names_count);
+ const StringName *index = &_global_names_ptr[indexname];
+ GET_VARIANT_PTR(src,2);
+
+ bool valid;
+ bool ok = ClassDB::set_property(p_instance->owner,*index,*src,&valid);
+#ifdef DEBUG_ENABLED
+ if (!ok) {
+ err_text="Internal error setting property: "+String(*index);
+ break;
+ } else if (!valid) {
+ err_text="Error setting property '"+String(*index)+"' with value of type "+Variant::get_type_name(src->get_type())+".";
+ break;
+
+ }
+#endif
+ ip+=3;
+ } continue;
+ case OPCODE_GET_MEMBER: {
+
+ CHECK_SPACE(3);
+ int indexname = _code_ptr[ip+1];
+ ERR_BREAK(indexname<0 || indexname>=_global_names_count);
+ const StringName *index = &_global_names_ptr[indexname];
+ GET_VARIANT_PTR(dst,2);
+ bool ok = ClassDB::get_property(p_instance->owner,*index,*dst);
+
+#ifdef DEBUG_ENABLED
+ if (!ok) {
+ err_text="Internal error getting property: "+String(*index);
+ break;
+ }
+#endif
+ ip+=3;
+
+ } continue;
case OPCODE_ASSIGN: {
CHECK_SPACE(3);