diff options
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gd_compiler.cpp | 33 | ||||
-rw-r--r-- | modules/gdscript/gd_compiler.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gd_editor.cpp | 4 | ||||
-rw-r--r-- | modules/gdscript/gd_functions.cpp | 38 | ||||
-rw-r--r-- | modules/gdscript/gd_functions.h | 4 | ||||
-rw-r--r-- | modules/gdscript/gd_parser.cpp | 5 | ||||
-rw-r--r-- | modules/gdscript/gd_parser.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gd_pretty_print.cpp | 2 | ||||
-rw-r--r-- | modules/gdscript/gd_pretty_print.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gd_script.cpp | 4 | ||||
-rw-r--r-- | modules/gdscript/gd_script.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gd_tokenizer.cpp | 2 | ||||
-rw-r--r-- | modules/gdscript/gd_tokenizer.h | 2 | ||||
-rw-r--r-- | modules/gdscript/register_types.h | 2 |
14 files changed, 85 insertions, 19 deletions
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp index 278651d642..b405555ec6 100644 --- a/modules/gdscript/gd_compiler.cpp +++ b/modules/gdscript/gd_compiler.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -559,7 +559,17 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre int index; if (named) { +#ifdef DEBUG_ENABLED + if (on->arguments[0]->type==GDParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) { + const Map<StringName,GDScript::MemberInfo>::Element *MI = codegen.script->member_indices.find(static_cast<GDParser::IdentifierNode*>(on->arguments[1])->name); + if (MI && MI->get().getter==codegen.function_node->name) { + String n = static_cast<GDParser::IdentifierNode*>(on->arguments[1])->name; + _set_error("Must use '"+n+"' instead of 'self."+n+"' in getter.",on); + return -1; + } + } +#endif index=codegen.get_name_map_pos(static_cast<GDParser::IdentifierNode*>(on->arguments[1])->name); } else { @@ -703,6 +713,25 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre if (on->arguments[0]->type==GDParser::Node::TYPE_OPERATOR && (static_cast<GDParser::OperatorNode*>(on->arguments[0])->op==GDParser::OperatorNode::OP_INDEX || static_cast<GDParser::OperatorNode*>(on->arguments[0])->op==GDParser::OperatorNode::OP_INDEX_NAMED)) { //SET (chained) MODE!! + +#ifdef DEBUG_ENABLED + if (static_cast<GDParser::OperatorNode*>(on->arguments[0])->op==GDParser::OperatorNode::OP_INDEX_NAMED) { + const GDParser::OperatorNode* inon = static_cast<GDParser::OperatorNode*>(on->arguments[0]); + + + if (inon->arguments[0]->type==GDParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) { + + const Map<StringName,GDScript::MemberInfo>::Element *MI = codegen.script->member_indices.find(static_cast<GDParser::IdentifierNode*>(inon->arguments[1])->name); + if (MI && MI->get().setter==codegen.function_node->name) { + String n = static_cast<GDParser::IdentifierNode*>(inon->arguments[1])->name; + _set_error("Must use '"+n+"' instead of 'self."+n+"' in setter.",inon); + return -1; + } + } + } +#endif + + int slevel=p_stack_level; GDParser::OperatorNode* op = static_cast<GDParser::OperatorNode*>(on->arguments[0]); @@ -1386,7 +1415,7 @@ Error GDCompiler::_parse_class(GDScript *p_script,GDScript *p_owner,const GDPars _set_error("Could not resolve relative path for parent class: "+path,p_class); return ERR_FILE_NOT_FOUND; } - path=base.get_base_dir().plus_file(path); + path=base.get_base_dir().plus_file(path).simplify_path(); } script = ResourceLoader::load(path); if (script.is_null()) { diff --git a/modules/gdscript/gd_compiler.h b/modules/gdscript/gd_compiler.h index 0c34c23b25..bdf4e9816a 100644 --- a/modules/gdscript/gd_compiler.h +++ b/modules/gdscript/gd_compiler.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index df091fbcc9..f59dbd91d3 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -33,7 +33,7 @@ void GDScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const { p_delimiters->push_back("#"); - p_delimiters->push_back("\"\"\""); + p_delimiters->push_back("\"\"\" \"\"\""); } void GDScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const { diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index f37b2f645a..e014921364 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -71,6 +71,7 @@ const char *GDFunctions::get_func_name(Function p_func) { "randi", "randf", "rand_range", + "seed", "rand_seed", "deg2rad", "rad2deg", @@ -97,6 +98,7 @@ const char *GDFunctions::get_func_name(Function p_func) { "dict2inst", "hash", "print_stack", + "instance_from_id", }; return _names[p_func]; @@ -328,6 +330,13 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va VALIDATE_ARG_NUM(1); r_ret=Math::random(*p_args[0],*p_args[1]); } break; + case MATH_SEED: { + VALIDATE_ARG_COUNT(1); + VALIDATE_ARG_NUM(0); + uint32_t seed=*p_args[0]; + Math::seed(seed); + r_ret=Variant(); + } break; case MATH_RANDSEED: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); @@ -575,7 +584,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va } //str+="\n"; - OS::get_singleton()->print("%s\n",str.utf8().get_data()); + OS::get_singleton()->print("%s",str.utf8().get_data()); r_ret=Variant(); } break; @@ -895,6 +904,20 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va }; } break; + case INSTANCE_FROM_ID: { + + VALIDATE_ARG_COUNT(1); + if (p_args[0]->get_type()!=Variant::INT && p_args[0]->get_type()!=Variant::REAL) { + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=0; + r_ret=Variant(); + break; + } + + uint32_t id=*p_args[0]; + r_ret=ObjectDB::get_instance(id); + + } break; case FUNC_MAX: { ERR_FAIL_V(); @@ -1130,6 +1153,11 @@ MethodInfo GDFunctions::get_info(Function p_func) { mi.return_val.type=Variant::REAL; return mi; } break; + case MATH_SEED: { + MethodInfo mi("seed",PropertyInfo(Variant::REAL,"seed")); + mi.return_val.type=Variant::NIL; + return mi; + } break; case MATH_RANDSEED: { MethodInfo mi("rand_seed",PropertyInfo(Variant::REAL,"seed")); mi.return_val.type=Variant::ARRAY; @@ -1288,6 +1316,12 @@ MethodInfo GDFunctions::get_info(Function p_func) { return mi; } break; + case INSTANCE_FROM_ID: { + MethodInfo mi("instance_from_id",PropertyInfo(Variant::INT,"instance_id")); + mi.return_val.type=Variant::OBJECT; + return mi; + } break; + case FUNC_MAX: { ERR_FAIL_V(MethodInfo()); diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h index 05ff6a2e73..ecd7d158be 100644 --- a/modules/gdscript/gd_functions.h +++ b/modules/gdscript/gd_functions.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -67,6 +67,7 @@ public: MATH_RAND, MATH_RANDF, MATH_RANDOM, + MATH_SEED, MATH_RANDSEED, MATH_DEG2RAD, MATH_RAD2DEG, @@ -93,6 +94,7 @@ public: DICT2INST, HASH, PRINT_STACK, + INSTANCE_FROM_ID, FUNC_MAX }; diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index aa2878f9e1..6242400663 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -1075,6 +1075,7 @@ GDParser::Node* GDParser::_reduce_expression(Node *p_node,bool p_to_const) { ConstantNode *cn = alloc_node<ConstantNode>(); Array arr(!p_to_const); + //print_line("mk array "+itos(!p_to_const)); arr.resize(an->elements.size()); for(int i=0;i<an->elements.size();i++) { ConstantNode *acn = static_cast<ConstantNode*>(an->elements[i]); @@ -1461,7 +1462,7 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) { } break; case GDTokenizer::TK_CF_PASS: { - if (tokenizer->get_token(1)!=GDTokenizer::TK_SEMICOLON && tokenizer->get_token(1)!=GDTokenizer::TK_NEWLINE ) { + if (tokenizer->get_token(1)!=GDTokenizer::TK_SEMICOLON && tokenizer->get_token(1)!=GDTokenizer::TK_NEWLINE && tokenizer->get_token(1)!=GDTokenizer::TK_EOF) { _set_error("Expected ';' or <NewLine>."); return; diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gd_parser.h index 44e7b55323..bf2c8c9ef2 100644 --- a/modules/gdscript/gd_parser.h +++ b/modules/gdscript/gd_parser.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdscript/gd_pretty_print.cpp b/modules/gdscript/gd_pretty_print.cpp index a5a993bb3a..9c290eac4a 100644 --- a/modules/gdscript/gd_pretty_print.cpp +++ b/modules/gdscript/gd_pretty_print.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdscript/gd_pretty_print.h b/modules/gdscript/gd_pretty_print.h index fbf002295b..998fdc53ab 100644 --- a/modules/gdscript/gd_pretty_print.h +++ b/modules/gdscript/gd_pretty_print.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 06c746c4fb..e260f70a91 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -1689,7 +1689,7 @@ bool GDScript::_update_exports() { } - if (c->extends_used && String(c->extends_file)!="") { + if (c->extends_used && String(c->extends_file)!="" && String(c->extends_file) != get_path()) { String path = c->extends_file; if (path.is_rel_path()) { diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index 5574b30d44..f505d51ba4 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index 1979577a17..56b283aa32 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdscript/gd_tokenizer.h b/modules/gdscript/gd_tokenizer.h index ff59c249a7..b63687d2b4 100644 --- a/modules/gdscript/gd_tokenizer.h +++ b/modules/gdscript/gd_tokenizer.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdscript/register_types.h b/modules/gdscript/register_types.h index ff7c2734df..9eb5d1846b 100644 --- a/modules/gdscript/register_types.h +++ b/modules/gdscript/register_types.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ |