diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gd_compiler.cpp | 6 | ||||
-rw-r--r-- | modules/gdscript/gd_compiler.h | 8 | ||||
-rw-r--r-- | modules/gdscript/gd_editor.cpp | 29 | ||||
-rw-r--r-- | modules/gdscript/gd_parser.cpp | 4 | ||||
-rw-r--r-- | modules/gdscript/gd_script.cpp | 73 | ||||
-rw-r--r-- | modules/gdscript/gd_script.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gd_tokenizer.cpp | 18 | ||||
-rw-r--r-- | modules/gridmap/grid_map.cpp | 6 |
8 files changed, 93 insertions, 53 deletions
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp index 53519030fc..e8e8ce4e96 100644 --- a/modules/gdscript/gd_compiler.cpp +++ b/modules/gdscript/gd_compiler.cpp @@ -776,7 +776,7 @@ 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 { @@ -1567,7 +1567,7 @@ Error GDCompiler::_parse_class(GDScript *p_script,GDScript *p_owner,const GDPars GDScript::MemberInfo minfo; minfo.index = p_script->member_indices.size(); minfo.setter = p_class->variables[i].setter; - minfo.getter = p_class->variables[i].getter; + minfo.getter = p_class->variables[i].getter; p_script->member_indices[name]=minfo; p_script->members.insert(name); @@ -1712,6 +1712,8 @@ Error GDCompiler::_parse_class(GDScript *p_script,GDScript *p_owner,const GDPars } } #endif + + p_script->valid=true; return OK; } diff --git a/modules/gdscript/gd_compiler.h b/modules/gdscript/gd_compiler.h index 5bf7ec980d..32e18c6dcf 100644 --- a/modules/gdscript/gd_compiler.h +++ b/modules/gdscript/gd_compiler.h @@ -44,7 +44,7 @@ class GDCompiler { List< Map<StringName,int> > stack_id_stack; Map<StringName,int> stack_identifiers; - + List<GDFunction::StackDebug> stack_debug; List< Map<StringName,int> > block_identifier_stack; Map<StringName,int> block_identifiers; @@ -65,7 +65,7 @@ class GDCompiler { void push_stack_identifiers() { stack_id_stack.push_back( stack_identifiers ); if (debug_stack) { - + block_identifier_stack.push_back(block_identifiers); block_identifiers.clear(); } @@ -74,10 +74,10 @@ class GDCompiler { void pop_stack_identifiers() { stack_identifiers = stack_id_stack.back()->get(); stack_id_stack.pop_back(); - + if (debug_stack) { for (Map<StringName,int>::Element *E=block_identifiers.front();E;E=E->next()) { - + GDFunction::StackDebug sd; sd.added=false; sd.identifier=E->key(); diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 126a8cd1eb..ff19518ad5 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -52,6 +52,7 @@ String GDScriptLanguage::get_template(const String& p_class_name, const String& "# var a=2\n"+ "# var b=\"textvar\"\n\n"+ "func _ready():\n"+ + "\t# Called every time the node is added to the scene.\n"+ "\t# Initialization here\n"+ "\tpass\n"+ "\n"+ @@ -285,6 +286,30 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const p_functions->push_back(GDFunctions::get_info(GDFunctions::Function(i))); } + + //not really "functions", but.. + { + MethodInfo mi; + mi.name="preload:Resource"; + mi.arguments.push_back(PropertyInfo(Variant::STRING,"path")); + mi.return_val=PropertyInfo(Variant::OBJECT,"",PROPERTY_HINT_RESOURCE_TYPE,"Resource"); + p_functions->push_back(mi); + } + { + MethodInfo mi; + mi.name="yield"; + mi.arguments.push_back(PropertyInfo(Variant::OBJECT,"object")); + mi.arguments.push_back(PropertyInfo(Variant::STRING,"signal")); + mi.default_arguments.push_back(Variant::NIL); + mi.default_arguments.push_back(Variant::STRING); + p_functions->push_back(mi); + } + { + MethodInfo mi; + mi.name="assert"; + mi.arguments.push_back(PropertyInfo(Variant::BOOL,"condition")); + p_functions->push_back(mi); + } } void GDScriptLanguage::get_public_constants(List<Pair<String,Variant> > *p_constants) const { @@ -2300,8 +2325,8 @@ Error GDScriptLanguage::complete_code(const String& p_code, const String& p_base "# Key", "# MouseMotion", "# MouseButton", - "# JoyMotion", - "# JoyButton", + "# JoystickMotion", + "# JoystickButton", "# ScreenTouch", "# ScreenDrag", "# Action" diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index b6e8478846..b713dc318f 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -912,7 +912,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_ default: valid=false; break; } - if (valid) { + if (valid) { e.is_op=true; e.op=op; expression.push_back(e); @@ -1790,7 +1790,7 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) { p_block->sub_blocks.push_back(cf_for->body); if (!_enter_indent_block(cf_for->body)) { - _set_error("Expected indented block after 'while'"); + _set_error("Expected indented block after 'for'"); p_block->end_line=tokenizer->get_token_line(); return; } diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 62c5eb735a..beec314e44 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -1481,6 +1481,11 @@ Variant GDScript::_new(const Variant** p_args,int p_argcount,Variant::CallError& /* STEP 1, CREATE */ + if (!valid) { + r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD; + return Variant(); + } + r_error.error=Variant::CallError::CALL_OK; REF ref; Object *owner=NULL; @@ -1510,7 +1515,7 @@ Variant GDScript::_new(const Variant** p_args,int p_argcount,Variant::CallError& return Variant(); } - if (ref.is_valid()) { + if (ref.is_valid()) { return ref; } else { return owner; @@ -2008,7 +2013,7 @@ void GDScript::_get_property_list(List<PropertyInfo> *p_properties) const { void GDScript::_bind_methods() { - ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"new",&GDScript::_new,MethodInfo("new")); + ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"new",&GDScript::_new,MethodInfo("new")); ObjectTypeDB::bind_method(_MD("get_as_byte_code"),&GDScript::get_as_byte_code); @@ -2456,6 +2461,7 @@ void GDInstance::get_method_list(List<MethodInfo> *p_list) const { MethodInfo mi; mi.name=E->key(); + mi.flags|=METHOD_FLAG_FROM_SCRIPT; for(int i=0;i<E->get().get_argument_count();i++) mi.arguments.push_back(PropertyInfo(Variant::NIL,"arg"+itos(i))); p_list->push_back(mi); @@ -2677,40 +2683,47 @@ void GDScriptLanguage::frame() { void GDScriptLanguage::get_reserved_words(List<String> *p_words) const { static const char *_reserved_words[]={ - "break", - "class", - "continue", - "const", - "else", - "elif", - "enum", - "extends" , - "onready", - "for" , - "func" , - "if" , - "in" , - "null" , - "not" , - "return" , - "self" , - "while" , - "true" , - "false" , - "tool", - "var", - "setget", - "pass", + // operators "and", + "in", + "not", "or", - "export", + // types and values + "false", + "float", + "int", + "null", + "PI", + "self", + "true", + // functions "assert", "breakpoint", + "class", + "extends", + "func", + "preload", + "setget", + "signal", + "tool", "yield", + // var + "const", + "enum", + "export", + "onready", "static", - "float", - "int", - "signal", + "var", + // control flow + "break", + "continue", + "if", + "elif", + "else", + "for", + "pass", + "return", + "while", 0}; diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index a69f99314a..663fc985a7 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -260,7 +260,7 @@ friend class GDScriptLanguage; Map<StringName,Variant> constants; Map<StringName,GDFunction> member_functions; Map<StringName,MemberInfo> member_indices; //members are just indices to the instanced script. - Map<StringName,Ref<GDScript> > subclasses; + Map<StringName,Ref<GDScript> > subclasses; Map<StringName,Vector<StringName> > _signals; #ifdef TOOLS_ENABLED diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index 71c56aba01..56eacfd20e 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -541,14 +541,14 @@ void GDTokenizerText::_advance() { } INCPOS(1); is_node_path=true; - + case '\'': case '"': { - + if (GETCHAR(0)=='\'') string_mode=STRING_SINGLE_QUOTE; - - + + int i=1; if (string_mode==STRING_DOUBLE_QUOTE && GETCHAR(i)=='"' && GETCHAR(i+1)=='"') { i+=2; @@ -1054,7 +1054,7 @@ Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> & p_buffer) { const uint8_t *buf=p_buffer.ptr(); int total_len=p_buffer.size(); ERR_FAIL_COND_V( p_buffer.size()<24 || p_buffer[0]!='G' || p_buffer[1]!='D' || p_buffer[2]!='S' || p_buffer[3]!='C',ERR_INVALID_DATA); - + int version = decode_uint32(&buf[4]); if (version>BYTECODE_VERSION) { ERR_EXPLAIN("Bytecode is too New! Please use a newer engine version."); @@ -1066,13 +1066,13 @@ Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> & p_buffer) { int token_count = decode_uint32(&buf[20]); const uint8_t *b=buf; - + b=&buf[24]; total_len-=24; - + identifiers.resize(identifier_count); for(int i=0;i<identifier_count;i++) { - + int len = decode_uint32(b); ERR_FAIL_COND_V(len>total_len,ERR_INVALID_DATA); b+=4; @@ -1089,7 +1089,7 @@ Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> & p_buffer) { total_len-=len+4; identifiers[i]=s; } - + constants.resize(constant_count); for(int i=0;i<constant_count;i++) { diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 7d463b13d4..e8b443a9e3 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -122,7 +122,7 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) { Octant &g = *octant_map[ok]; g.baked=b; - g.bake_instance=VS::get_singleton()->instance_create();; + g.bake_instance=VS::get_singleton()->instance_create();; VS::get_singleton()->instance_set_base(g.bake_instance,g.baked->get_rid()); VS::get_singleton()->instance_geometry_set_baked_light(g.bake_instance,baked_light_instance?baked_light_instance->get_baked_light_instance():RID()); } @@ -398,7 +398,7 @@ void GridMap::set_cell_item(int p_x,int p_y,int p_z, int p_item,int p_rot){ PhysicsServer::get_singleton()->free(g.collision_debug_instance); } - memdelete(&g); + memdelete(&g); octant_map.erase(octantkey); } else { @@ -984,7 +984,7 @@ void GridMap::_notification(int p_what) { void GridMap::_queue_dirty_map() { if (awaiting_update) - return; + return; if (is_inside_world()) { |