diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-09-22 00:50:48 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-09-22 00:50:48 -0300 |
commit | 048fdc8aeabbd80ba9cc8914ec7f7baa00ad0c3d (patch) | |
tree | ddd39a348b41cfe3927075a8c6b11aa692511518 /modules/gdscript | |
parent | f195bf673fa8f282d2508e20ca6f08260c4e1fe7 (diff) |
-variables with export in script are now IMMEDIATELY AND ALWAYS visible in properties (#718)
-WorldEnvironment cleanup issues fixed (#563)
-Text Editor improvement to shift-mouse selection (#648)
-(Hopefully) fixed rare (but horrible) indexing bug in GDScript compiler (#652)
-Some changes to PhysicsBody API, renamed property "active" to "sleeping", which makes more sense
-Added add_collision_exception() API in PhysicsBody (more accessible)
-ability to select and copy in the output messages panel
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gd_compiler.cpp | 21 | ||||
-rw-r--r-- | modules/gdscript/gd_script.cpp | 47 | ||||
-rw-r--r-- | modules/gdscript/gd_script.h | 2 |
3 files changed, 65 insertions, 5 deletions
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp index e6dd9d9ae1..45eac23450 100644 --- a/modules/gdscript/gd_compiler.cpp +++ b/modules/gdscript/gd_compiler.cpp @@ -724,6 +724,8 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre return prev_pos; int retval=prev_pos; + //print_line("retval: "+itos(retval)); + if (retval&GDFunction::ADDR_TYPE_STACK<<GDFunction::ADDR_BITS) { slevel++; codegen.alloc_stack(slevel); @@ -732,6 +734,8 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre Vector<int> setchain; + int prev_key_idx=-1; + for(List<GDParser::OperatorNode*>::Element *E=chain.back();E;E=E->prev()) { @@ -743,16 +747,23 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre if (named) { - key_idx = codegen.get_name_map_pos(static_cast<const GDParser::IdentifierNode*>(E->get()->arguments[1])->name); + key_idx = codegen.get_name_map_pos(static_cast<const GDParser::IdentifierNode*>(E->get()->arguments[1])->name); + //printf("named key %x\n",key_idx); + } else { - GDParser::Node *key = E->get()->arguments[1]; - key_idx = _parse_expression(codegen,key,slevel); - if (retval&GDFunction::ADDR_TYPE_STACK<<GDFunction::ADDR_BITS) { + if (prev_pos&(GDFunction::ADDR_TYPE_STACK<<GDFunction::ADDR_BITS)) { slevel++; codegen.alloc_stack(slevel); } + GDParser::Node *key = E->get()->arguments[1]; + key_idx = _parse_expression(codegen,key,slevel); + //printf("expr key %x\n",key_idx); + + + //stack was raised here if retval was stack but.. + } if (key_idx<0) @@ -764,6 +775,7 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre slevel++; codegen.alloc_stack(slevel); int dst_pos = (GDFunction::ADDR_TYPE_STACK<<GDFunction::ADDR_BITS)|slevel; + codegen.opcodes.push_back(dst_pos); //add in reverse order, since it will be reverted @@ -773,6 +785,7 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre setchain.push_back(named ? GDFunction::OPCODE_SET_NAMED : GDFunction::OPCODE_SET); prev_pos=dst_pos; + prev_key_idx=key_idx; } diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 10053d4260..49d92e0746 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -1492,7 +1492,9 @@ Variant GDScript::_new(const Variant** p_args,int p_argcount,Variant::CallError& bool GDScript::can_instance() const { - return valid; //any script in GDscript can instance + //return valid; //any script in GDscript can instance + return valid || (!tool && !ScriptServer::is_scripting_enabled()); + } StringName GDScript::get_instance_base_type() const { @@ -1565,8 +1567,10 @@ void GDScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) { #endif ScriptInstance* GDScript::instance_create(Object *p_this) { + if (!tool && !ScriptServer::is_scripting_enabled()) { + #ifdef TOOLS_ENABLED //instance a fake script for editing the values @@ -1620,7 +1624,48 @@ String GDScript::get_source_code() const { void GDScript::set_source_code(const String& p_code) { source=p_code; +} + +void GDScript::update_exports() { + +#ifdef TOOLS_ENABLED + String basedir=path; + + if (basedir=="") + basedir=get_path(); + + if (basedir!="") + basedir=basedir.get_base_dir(); + + GDParser parser; + Error err = parser.parse(source,basedir,true); + if (err) + return; //do none + 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); + + List<PropertyInfo> plist; + + Map<StringName,Variant> default_values; + + for(int i=0;i<c->variables.size();i++) { + if (c->variables[i]._export.type==Variant::NIL) + continue; + + plist.push_back(c->variables[i]._export); + default_values[c->variables[i].identifier]=c->variables[i].default_value; + } + + + for (Set<PlaceHolderScriptInstance*>::Element *E=placeholders.front();E;E=E->next()) { + + E->get()->update(plist,default_values); + } + +#endif } void GDScript::_set_subclass_path(Ref<GDScript>& p_sc,const String& p_path) { diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index 62787cf6f8..2088606271 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -299,6 +299,8 @@ public: virtual bool has_source_code() const; virtual String get_source_code() const; virtual void set_source_code(const String& p_code); + virtual void update_exports(); + virtual Error reload(); virtual String get_node_type() const; |