summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/doc_classes/GDScript.xml3
-rw-r--r--modules/gdscript/doc_classes/GDScriptFunctionState.xml2
-rw-r--r--modules/gdscript/doc_classes/GDScriptNativeClass.xml2
-rw-r--r--modules/gdscript/gdscript.cpp2
-rw-r--r--modules/gdscript/gdscript.h4
-rw-r--r--modules/gdscript/gdscript_compiler.cpp38
-rw-r--r--modules/gdscript/gdscript_editor.cpp20
-rw-r--r--modules/gdscript/gdscript_functions.cpp8
-rw-r--r--modules/gdscript/gdscript_parser.cpp8
9 files changed, 51 insertions, 36 deletions
diff --git a/modules/gdscript/doc_classes/GDScript.xml b/modules/gdscript/doc_classes/GDScript.xml
index cc617c5c67..59cb00e3f6 100644
--- a/modules/gdscript/doc_classes/GDScript.xml
+++ b/modules/gdscript/doc_classes/GDScript.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDScript" inherits="Script" category="Core" version="3.0-beta">
+<class name="GDScript" inherits="Script" category="Core" version="3.0-stable">
<brief_description>
A script implemented in the GDScript programming language.
</brief_description>
@@ -8,6 +8,7 @@
[method new] creates a new instance of the script. [method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes.
</description>
<tutorials>
+ http://docs.godotengine.org/en/3.0/getting_started/scripting/gdscript/index.html
</tutorials>
<demos>
</demos>
diff --git a/modules/gdscript/doc_classes/GDScriptFunctionState.xml b/modules/gdscript/doc_classes/GDScriptFunctionState.xml
index 465a4f438b..8510136f68 100644
--- a/modules/gdscript/doc_classes/GDScriptFunctionState.xml
+++ b/modules/gdscript/doc_classes/GDScriptFunctionState.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDScriptFunctionState" inherits="Reference" category="Core" version="3.0-beta">
+<class name="GDScriptFunctionState" inherits="Reference" category="Core" version="3.0-stable">
<brief_description>
State of a function call after yielding.
</brief_description>
diff --git a/modules/gdscript/doc_classes/GDScriptNativeClass.xml b/modules/gdscript/doc_classes/GDScriptNativeClass.xml
index 948254e0ad..48826ec1e0 100644
--- a/modules/gdscript/doc_classes/GDScriptNativeClass.xml
+++ b/modules/gdscript/doc_classes/GDScriptNativeClass.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDScriptNativeClass" inherits="Reference" category="Core" version="3.0-beta">
+<class name="GDScriptNativeClass" inherits="Reference" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 228c7dc56f..4e3ee4d22c 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -705,7 +705,7 @@ bool GDScript::_set(const StringName &p_name, const Variant &p_value) {
void GDScript::_get_property_list(List<PropertyInfo> *p_properties) const {
- p_properties->push_back(PropertyInfo(Variant::STRING, "script/source", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_properties->push_back(PropertyInfo(Variant::STRING, "script/source", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
}
void GDScript::_bind_methods() {
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index b5bbaa6dc9..9566e3b32e 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -349,7 +349,9 @@ public:
csi.resize(_debug_call_stack_pos);
for (int i = 0; i < _debug_call_stack_pos; i++) {
csi[_debug_call_stack_pos - i - 1].line = _call_stack[i].line ? *_call_stack[i].line : 0;
- csi[_debug_call_stack_pos - i - 1].script = Ref<GDScript>(_call_stack[i].function->get_script());
+ if (_call_stack[i].function)
+ csi[_debug_call_stack_pos - i - 1].func = _call_stack[i].function->get_name();
+ csi[_debug_call_stack_pos - i - 1].file = _call_stack[i].function->get_script()->get_path();
}
return csi;
}
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index f380bedf7f..1649fb52f2 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -37,6 +37,9 @@ bool GDScriptCompiler::_is_class_member_property(CodeGen &codegen, const StringN
if (!codegen.function_node || codegen.function_node->_static)
return false;
+ if (codegen.stack_identifiers.has(p_name))
+ return false; //shadowed
+
return _is_class_member_property(codegen.script, p_name);
}
@@ -184,6 +187,14 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
StringName identifier = in->name;
+ // TRY STACK!
+ if (!p_initializer && codegen.stack_identifiers.has(identifier)) {
+
+ int pos = codegen.stack_identifiers[identifier];
+ return pos | (GDScriptFunction::ADDR_TYPE_STACK_VARIABLE << GDScriptFunction::ADDR_BITS);
+ }
+
+ // TRY CLASS MEMBER
if (_is_class_member_property(codegen, identifier)) {
//get property
codegen.opcodes.push_back(GDScriptFunction::OPCODE_GET_MEMBER); // perform operator
@@ -194,12 +205,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
return dst_addr;
}
- // TRY STACK!
- if (!p_initializer && codegen.stack_identifiers.has(identifier)) {
-
- int pos = codegen.stack_identifiers[identifier];
- return pos | (GDScriptFunction::ADDR_TYPE_STACK_VARIABLE << GDScriptFunction::ADDR_BITS);
- }
//TRY MEMBERS!
if (!codegen.function_node || !codegen.function_node->_static) {
@@ -1336,10 +1341,12 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(s);
- if (_is_class_member_property(codegen, lv->name)) {
- _set_error("Name for local variable '" + String(lv->name) + "' can't shadow class property of the same name.", lv);
- return ERR_ALREADY_EXISTS;
- }
+ // since we are using properties now for most class access, allow shadowing of class members to make user's life easier.
+ //
+ //if (_is_class_member_property(codegen, lv->name)) {
+ // _set_error("Name for local variable '" + String(lv->name) + "' can't shadow class property of the same name.", lv);
+ // return ERR_ALREADY_EXISTS;
+ //}
codegen.add_stack_identifier(lv->name, p_stack_level++);
codegen.alloc_stack(p_stack_level);
@@ -1376,10 +1383,13 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
if (p_func) {
for (int i = 0; i < p_func->arguments.size(); i++) {
- if (_is_class_member_property(p_script, p_func->arguments[i])) {
- _set_error("Name for argument '" + String(p_func->arguments[i]) + "' can't shadow class property of the same name.", p_func);
- return ERR_ALREADY_EXISTS;
- }
+ // since we are using properties now for most class access, allow shadowing of class members to make user's life easier.
+ //
+ //if (_is_class_member_property(p_script, p_func->arguments[i])) {
+ // _set_error("Name for argument '" + String(p_func->arguments[i]) + "' can't shadow class property of the same name.", p_func);
+ // return ERR_ALREADY_EXISTS;
+ //}
+
codegen.add_stack_identifier(p_func->arguments[i], i);
#ifdef TOOLS_ENABLED
argnames.push_back(p_func->arguments[i]);
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index bcfe8525b4..505562324f 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -369,8 +369,8 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const
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);
+ mi.default_arguments.push_back(Variant());
+ mi.default_arguments.push_back(String());
mi.return_val = PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, "GDScriptFunctionState");
p_functions->push_back(mi);
}
@@ -491,8 +491,8 @@ static Ref<Reference> _get_parent_class(GDScriptCompletionContext &context) {
path = context.base_path.plus_file(path);
}
- if (ScriptCodeCompletionCache::get_sigleton())
- script = ScriptCodeCompletionCache::get_sigleton()->get_cached_resource(path);
+ if (ScriptCodeCompletionCache::get_singleton())
+ script = ScriptCodeCompletionCache::get_singleton()->get_cached_resource(path);
else
script = ResourceLoader::load(path);
@@ -765,8 +765,8 @@ static bool _guess_expression_type(GDScriptCompletionContext &context, const GDS
//print_line("is a script");
Ref<Script> scr;
- if (ScriptCodeCompletionCache::get_sigleton())
- scr = ScriptCodeCompletionCache::get_sigleton()->get_cached_resource(script);
+ if (ScriptCodeCompletionCache::get_singleton())
+ scr = ScriptCodeCompletionCache::get_singleton()->get_cached_resource(script);
else
scr = ResourceLoader::load(script);
@@ -1301,8 +1301,8 @@ static bool _guess_identifier_type(GDScriptCompletionContext &context, int p_lin
//print_line("is a script");
Ref<Script> scr;
- if (ScriptCodeCompletionCache::get_sigleton())
- scr = ScriptCodeCompletionCache::get_sigleton()->get_cached_resource(script);
+ if (ScriptCodeCompletionCache::get_singleton())
+ scr = ScriptCodeCompletionCache::get_singleton()->get_cached_resource(script);
else
scr = ResourceLoader::load(script);
@@ -2450,8 +2450,10 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
} break;
case GDScriptParser::COMPLETION_RESOURCE_PATH: {
- if (EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths"))
+ if (EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths")) {
get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), options);
+ r_forced = true;
+ }
} break;
case GDScriptParser::COMPLETION_ASSIGN: {
#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index f15f2197da..c067d5409f 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -1483,7 +1483,7 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case MATH_INVERSE_LERP: {
- MethodInfo mi("inverse_lerp", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "value"));
+ MethodInfo mi("inverse_lerp", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "weight"));
mi.return_val.type = Variant::REAL;
return mi;
} break;
@@ -1579,12 +1579,12 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case LOGIC_CLAMP: {
- MethodInfo mi("clamp", PropertyInfo(Variant::REAL, "val"), PropertyInfo(Variant::REAL, "min"), PropertyInfo(Variant::REAL, "max"));
+ MethodInfo mi("clamp", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "min"), PropertyInfo(Variant::REAL, "max"));
mi.return_val.type = Variant::REAL;
return mi;
} break;
case LOGIC_NEAREST_PO2: {
- MethodInfo mi("nearest_po2", PropertyInfo(Variant::INT, "val"));
+ MethodInfo mi("nearest_po2", PropertyInfo(Variant::INT, "value"));
mi.return_val.type = Variant::INT;
return mi;
} break;
@@ -1760,12 +1760,14 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
case COLOR8: {
MethodInfo mi("Color8", PropertyInfo(Variant::INT, "r8"), PropertyInfo(Variant::INT, "g8"), PropertyInfo(Variant::INT, "b8"), PropertyInfo(Variant::INT, "a8"));
+ mi.default_arguments.push_back(255);
mi.return_val.type = Variant::COLOR;
return mi;
} break;
case COLORN: {
MethodInfo mi("ColorN", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::REAL, "alpha"));
+ mi.default_arguments.push_back(1.0f);
mi.return_val.type = Variant::COLOR;
return mi;
} break;
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 2a6d37812e..1392323d56 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -95,8 +95,6 @@ bool GDScriptParser::_enter_indent_block(BlockNode *p_block) {
int indent = tokenizer->get_token_line_indent();
int current = tab_level.back()->get();
if (indent <= current) {
- print_line("current: " + itos(current) + " indent: " + itos(indent));
- print_line("less than current");
return false;
}
@@ -458,9 +456,9 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (!validating) {
//this can be too slow for just validating code
- if (for_completion && ScriptCodeCompletionCache::get_sigleton()) {
- res = ScriptCodeCompletionCache::get_sigleton()->get_cached_resource(path);
- } else {
+ if (for_completion && ScriptCodeCompletionCache::get_singleton()) {
+ res = ScriptCodeCompletionCache::get_singleton()->get_cached_resource(path);
+ } else { // essential; see issue 15902
res = ResourceLoader::load(path);
}
if (!res.is_valid()) {