diff options
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gd_compiler.cpp | 8 | ||||
-rw-r--r-- | modules/gdscript/gd_compiler.h | 15 | ||||
-rw-r--r-- | modules/gdscript/gd_editor.cpp | 491 | ||||
-rw-r--r-- | modules/gdscript/gd_function.cpp | 32 | ||||
-rw-r--r-- | modules/gdscript/gd_function.h | 5 | ||||
-rw-r--r-- | modules/gdscript/gd_functions.cpp | 66 | ||||
-rw-r--r-- | modules/gdscript/gd_functions.h | 4 | ||||
-rw-r--r-- | modules/gdscript/gd_parser.cpp | 65 | ||||
-rw-r--r-- | modules/gdscript/gd_parser.h | 6 | ||||
-rw-r--r-- | modules/gdscript/gd_script.cpp | 125 | ||||
-rw-r--r-- | modules/gdscript/gd_script.h | 4 | ||||
-rw-r--r-- | modules/gdscript/gd_tokenizer.cpp | 56 | ||||
-rw-r--r-- | modules/gdscript/gd_tokenizer.h | 2 | ||||
-rw-r--r-- | modules/gdscript/register_types.cpp | 105 | ||||
-rw-r--r-- | modules/gdscript/register_types.h | 2 |
15 files changed, 416 insertions, 570 deletions
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp index d4ede4cb17..4803781c67 100644 --- a/modules/gdscript/gd_compiler.cpp +++ b/modules/gdscript/gd_compiler.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -1451,15 +1451,13 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode codegen.opcodes.push_back(GDFunction::OPCODE_END); - GDFunction *gdfunc = NULL; - /* if (String(p_func->name)=="") { //initializer func gdfunc = &p_script->initializer; */ //} else { //regular func p_script->member_functions[func_name] = memnew(GDFunction); - gdfunc = p_script->member_functions[func_name]; + GDFunction *gdfunc = p_script->member_functions[func_name]; //} if (p_func) { @@ -1973,7 +1971,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa p_script->placeholders.erase(psi); //remove placeholder GDInstance *instance = memnew(GDInstance); - instance->base_ref = E->get()->cast_to<Reference>(); + instance->base_ref = Object::cast_to<Reference>(E->get()); instance->members.resize(p_script->member_indices.size()); instance->script = Ref<GDScript>(p_script); instance->owner = E->get(); diff --git a/modules/gdscript/gd_compiler.h b/modules/gdscript/gd_compiler.h index b7ff092eba..ac713ae75b 100644 --- a/modules/gdscript/gd_compiler.h +++ b/modules/gdscript/gd_compiler.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -91,7 +91,6 @@ class GDCompiler { } } - //int get_identifier_pos(const StringName& p_dentifier) const; HashMap<Variant, int, VariantHasher, VariantComparator> constant_map; Map<StringName, int> name_map; @@ -127,17 +126,6 @@ class GDCompiler { int call_max; }; -#if 0 - void _create_index(const GDParser::OperatorNode *on); - void _create_call(const GDParser::OperatorNode *on); - - - int _parse_expression(const GDParser::Node *p_expr,CodeGen& codegen); - void _parse_block(GDParser::BlockNode *p_block); - void _parse_function(GDParser::FunctionNode *p_func); - Ref<GDScript> _parse_class(GDParser::ClassNode *p_class); -#endif - bool _is_class_member_property(CodeGen &codegen, const StringName &p_name); bool _is_class_member_property(GDScript *owner, const StringName &p_name); @@ -146,7 +134,6 @@ class GDCompiler { bool _create_unary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level); bool _create_binary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer = false); - //int _parse_subexpression(CodeGen& codegen,const GDParser::BlockNode *p_block,const GDParser::Node *p_expression); int _parse_assign_right_expression(CodeGen &codegen, const GDParser::OperatorNode *p_expression, int p_stack_level); int _parse_expression(CodeGen &codegen, const GDParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false); Error _parse_block(CodeGen &codegen, const GDParser::BlockNode *p_block, int p_stack_level = 0, int p_break_addr = -1, int p_continue_addr = -1); diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index f8b45af85a..70e7da5748 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -27,14 +27,18 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#include "gd_script.h" + #include "editor/editor_settings.h" #include "gd_compiler.h" -#include "gd_script.h" +#include "global_constants.h" #include "os/file_access.h" #include "project_settings.h" + #ifdef TOOLS_ENABLED #include "editor/editor_file_system.h" #include "editor/editor_settings.h" +#include "engine.h" #endif void GDScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const { @@ -293,23 +297,25 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const //not really "functions", but.. { MethodInfo mi; - mi.name = "preload:Resource"; + mi.name = "preload"; 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:GDFunctionState"; + 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.return_val = PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, "GDFunctionState"); p_functions->push_back(mi); } { MethodInfo mi; mi.name = "assert"; + mi.return_val.type = Variant::NIL; mi.arguments.push_back(PropertyInfo(Variant::BOOL, "condition")); p_functions->push_back(mi); } @@ -354,13 +360,14 @@ String GDScriptLanguage::make_function(const String &p_class, const String &p_na struct GDCompletionIdentifier { + String enumeration; StringName obj_type; Ref<GDScript> script; Variant::Type type; Variant value; //im case there is a value, also return it }; -static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant) { +static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant, bool p_allow_gdnative_class = false) { GDCompletionIdentifier t; t.type = p_variant.get_type(); @@ -368,14 +375,14 @@ static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant) { if (p_variant.get_type() == Variant::OBJECT) { Object *obj = p_variant; if (obj) { - /* - if (obj->cast_to<GDNativeClass>()) { - t.obj_type=obj->cast_to<GDNativeClass>()->get_name(); - t.value=Variant(); + + if (p_allow_gdnative_class && Object::cast_to<GDNativeClass>(obj)) { + t.obj_type = Object::cast_to<GDNativeClass>(obj)->get_name(); + t.value = Variant(); } else { - */ - t.obj_type = obj->get_class(); - //} + + t.obj_type = obj->get_class(); + } } } return t; @@ -508,9 +515,9 @@ static GDCompletionIdentifier _get_native_class(GDCompletionContext &context) { return id; } -static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type); +static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type, bool p_for_indexing); -static bool _guess_expression_type(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, GDCompletionIdentifier &r_type) { +static bool _guess_expression_type(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, GDCompletionIdentifier &r_type, bool p_for_indexing = false) { if (p_node->type == GDParser::Node::TYPE_CONSTANT) { @@ -561,7 +568,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: return true; } else if (p_node->type == GDParser::Node::TYPE_IDENTIFIER) { - return _guess_identifier_type(context, p_line - 1, static_cast<const GDParser::IdentifierNode *>(p_node)->name, r_type); + return _guess_identifier_type(context, p_line - 1, static_cast<const GDParser::IdentifierNode *>(p_node)->name, r_type, p_for_indexing); } else if (p_node->type == GDParser::Node::TYPE_SELF) { //eeh... @@ -572,6 +579,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(p_node); if (op->op == GDParser::OperatorNode::OP_CALL) { + if (op->arguments[0]->type == GDParser::Node::TYPE_TYPE) { const GDParser::TypeNode *tn = static_cast<const GDParser::TypeNode *>(op->arguments[0]); @@ -584,22 +592,45 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: } else if (op->arguments.size() > 1 && op->arguments[1]->type == GDParser::Node::TYPE_IDENTIFIER) { + StringName id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name; + + if (op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && String(id) == "new") { + + //shortcut + StringName identifier = static_cast<const GDParser::IdentifierNode *>(op->arguments[0])->name; + + if (ClassDB::class_exists(identifier)) { + r_type.type = Variant::OBJECT; + r_type.value = Variant(); + r_type.obj_type = identifier; + return true; + } + } + GDCompletionIdentifier base; if (!_guess_expression_type(context, op->arguments[0], p_line, base)) return false; - StringName id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name; - if (base.type == Variant::OBJECT) { if (id.operator String() == "new" && base.value.get_type() == Variant::OBJECT) { + Object *obj = base.value; - if (obj && obj->cast_to<GDNativeClass>()) { - GDNativeClass *gdnc = obj->cast_to<GDNativeClass>(); + if (obj && Object::cast_to<GDNativeClass>(obj)) { + GDNativeClass *gdnc = Object::cast_to<GDNativeClass>(obj); r_type.type = Variant::OBJECT; r_type.value = Variant(); r_type.obj_type = gdnc->get_name(); return true; + } else { + + if (base.obj_type != StringName()) { + + r_type.type = Variant::OBJECT; + r_type.value = Variant(); + r_type.obj_type = base.obj_type; + return true; + } } } @@ -607,7 +638,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: #ifdef TOOLS_ENABLED MethodBind *mb = ClassDB::get_method(base.obj_type, id); - PropertyInfo pi = mb->get_argument_info(-1); + PropertyInfo pi = mb->get_return_info(); //try calling the function if constant and all args are constant, should not crash.. Object *baseptr = base.value; @@ -808,6 +839,47 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: if (p1.value.get_type() == Variant::OBJECT) { //?? + + if (p1.obj_type != StringName() && p2.type == Variant::STRING) { + + StringName base_type = p1.obj_type; + + if (p1.obj_type == "GDNativeClass") { + //native enum + Ref<GDNativeClass> gdn = p1.value; + if (gdn.is_valid()) { + + base_type = gdn->get_name(); + } + } + StringName index = p2.value; + bool valid; + Variant::Type t = ClassDB::get_property_type(base_type, index, &valid); + if (t != Variant::NIL && valid) { + r_type.type = t; + if (t == Variant::INT || t == Variant::OBJECT) { +//check for enum! +#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED) + + StringName getter = ClassDB::get_property_getter(base_type, index); + if (getter != StringName()) { + MethodBind *mb = ClassDB::get_method(base_type, getter); + if (mb) { + PropertyInfo rt = mb->get_return_info(); + if (rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM && t == Variant::INT) { + r_type.enumeration = rt.class_name; + } else if (t == Variant::OBJECT) { + + r_type.obj_type = rt.class_name; + } + } + } +#endif + } + + return true; + } + } } else if (p1.value.get_type() != Variant::NIL) { bool valid; @@ -901,12 +973,42 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type) { + if (context.block->if_condition && context.block->if_condition->type == GDParser::Node::TYPE_OPERATOR && static_cast<const GDParser::OperatorNode *>(context.block->if_condition)->op == GDParser::OperatorNode::OP_IS) { + //is used, check if identifier is in there! this helps resolve in blocks that are (if (identifier is value)): which are very common.. + //super dirty hack, but very useful + //credit: Zylann + //TODO: this could be hacked to detect ANDed conditions too.. + const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(context.block->if_condition); + if (op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && static_cast<const GDParser::IdentifierNode *>(op->arguments[0])->name == p_identifier) { + //bingo + if (_guess_expression_type(context, op->arguments[1], op->line, r_type)) { + return true; + } + } + } + GDCompletionIdentifier gdi = _get_native_class(context); if (gdi.obj_type != StringName()) { bool valid; Variant::Type t = ClassDB::get_property_type(gdi.obj_type, p_identifier, &valid); if (t != Variant::NIL && valid) { r_type.type = t; + if (t == Variant::INT) { +//check for enum! +#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED) + + StringName getter = ClassDB::get_property_getter(gdi.obj_type, p_identifier); + if (getter != StringName()) { + MethodBind *mb = ClassDB::get_method(gdi.obj_type, getter); + if (mb) { + PropertyInfo rt = mb->get_return_info(); + if (rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { + r_type.enumeration = rt.class_name; + } + } + } +#endif + } return true; } } @@ -996,7 +1098,7 @@ static bool _guess_identifier_from_assignment_in_function(GDCompletionContext &c return false; } -static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type) { +static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type, bool p_for_indexing) { //go to block first @@ -1040,11 +1142,11 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con PropertyInfo arg = E->get().arguments[argindex]; - int scp = arg.name.find(":"); + int scp = String(arg.name).find(":"); if (scp != -1) { r_type.type = Variant::OBJECT; - r_type.obj_type = arg.name.substr(scp + 1, arg.name.length()); + r_type.obj_type = String(arg.name).substr(scp + 1, String(arg.name).length()); return true; } else { @@ -1150,7 +1252,7 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con for (Map<StringName, int>::Element *E = GDScriptLanguage::get_singleton()->get_global_map().front(); E; E = E->next()) { if (E->key() == p_identifier) { - r_type = _get_type_from_variant(GDScriptLanguage::get_singleton()->get_global_array()[E->get()]); + r_type = _get_type_from_variant(GDScriptLanguage::get_singleton()->get_global_array()[E->get()], !p_for_indexing); return true; } } @@ -1270,7 +1372,7 @@ static void _find_identifiers_in_class(GDCompletionContext &context, bool p_stat for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { if (E->get().usage & (PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY)) continue; - if (E->get().name.find("/") != -1) + if (String(E->get().name).find("/") != -1) continue; result.insert(E->get().name); } @@ -1435,7 +1537,7 @@ void get_directory_contents(EditorFileSystemDirectory *p_dir, Set<String> &r_lis } } -static void _find_type_arguments(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, const StringName &p_method, const GDCompletionIdentifier &id, int p_argidx, Set<String> &result, String &arghint) { +static void _find_type_arguments(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, const StringName &p_method, const GDCompletionIdentifier &id, int p_argidx, Set<String> &result, bool &r_forced, String &arghint) { //print_line("find type arguments?"); if (id.type == Variant::OBJECT && id.obj_type != StringName()) { @@ -1450,46 +1552,45 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N if (id.value.get_type()) { Object *obj = id.value; - if (obj) { - - GDScript *scr = obj->cast_to<GDScript>(); - if (scr) { - while (scr) { + GDScript *scr = Object::cast_to<GDScript>(obj); + if (scr) { + while (scr) { - for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { - if (E->get()->is_static() && p_method == E->get()->get_name()) { - arghint = "static func " + String(p_method) + "("; - for (int i = 0; i < E->get()->get_argument_count(); i++) { - if (i > 0) - arghint += ", "; - else - arghint += " "; - if (i == p_argidx) { - arghint += String::chr(0xFFFF); - } - arghint += "var " + E->get()->get_argument_name(i); - int deffrom = E->get()->get_argument_count() - E->get()->get_default_argument_count(); - if (i >= deffrom) { - int defidx = deffrom - i; - if (defidx >= 0 && defidx < E->get()->get_default_argument_count()) { - arghint += "=" + E->get()->get_default_argument(defidx).get_construct_string(); - } - } - if (i == p_argidx) { - arghint += String::chr(0xFFFF); + for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { + if (E->get()->is_static() && p_method == E->get()->get_name()) { + arghint = "static func " + String(p_method) + "("; + for (int i = 0; i < E->get()->get_argument_count(); i++) { + if (i > 0) + arghint += ", "; + else + arghint += " "; + if (i == p_argidx) { + arghint += String::chr(0xFFFF); + } + arghint += "var " + E->get()->get_argument_name(i); + int deffrom = E->get()->get_argument_count() - E->get()->get_default_argument_count(); + if (i >= deffrom) { + int defidx = deffrom - i; + if (defidx >= 0 && defidx < E->get()->get_default_argument_count()) { + arghint += "=" + E->get()->get_default_argument(defidx).get_construct_string(); } } - arghint += ")"; - return; //found + if (i == p_argidx) { + arghint += String::chr(0xFFFF); + } } + arghint += ")"; + return; //found } - - if (scr->get_base().is_valid()) - scr = scr->get_base().ptr(); - else - scr = NULL; } - } else { + + if (scr->get_base().is_valid()) + scr = scr->get_base().ptr(); + else + scr = NULL; + } + } else { + if (obj) { on_script = obj->get_script(); } } @@ -1615,21 +1716,6 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N return; //found } } -#if 0 - //use class directly, no code was found - if (!isfunction) { - for (const Map<StringName,Variant>::Element *E=scr->get_constants().front();E;E=E->next()) { - options.insert(E->key()); - } - } - for (const Map<StringName,GDFunction>::Element *E=scr->get_member_functions().front();E;E=E->next()) { - options.insert(String(E->key())+"("); - } - - for (const Set<StringName>::Element *E=scr->get_members().front();E;E=E->next()) { - options.insert(E->get()); - } -#endif } if (scr->get_base().is_valid()) @@ -1641,8 +1727,43 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N } } else { - //regular method +//regular method +#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED) + if (p_argidx < m->get_argument_count()) { + PropertyInfo pi = m->get_argument_info(p_argidx); + + if (pi.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { + String enumeration = pi.class_name; + if (enumeration.find(".") != -1) { + //class constant + List<StringName> constants; + String cls = enumeration.get_slice(".", 0); + String enm = enumeration.get_slice(".", 1); + + ClassDB::get_enum_constants(cls, enm, &constants); + //constants.sort_custom<StringName::AlphCompare>(); + for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { + String add = cls + "." + E->get(); + result.insert(add); + r_forced = true; + } + } else { + + //global constant + StringName current_enum = enumeration; + + for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) { + if (GlobalConstants::get_global_constant_enum(i) == current_enum) { + result.insert(GlobalConstants::get_global_constant_name(i)); + r_forced = true; + } + } + //global + } + } + } +#endif if (p_method.operator String() == "connect" || (p_method.operator String() == "emit_signal" && p_argidx == 0)) { if (p_argidx == 0) { @@ -1663,6 +1784,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N for (List<MethodInfo>::Element *E = sigs.front(); E; E = E->next()) { result.insert("\"" + E->get().name + "\""); + r_forced = true; } } else if (p_argidx == 2) { @@ -1670,6 +1792,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N if (context._class) { for (int i = 0; i < context._class->functions.size(); i++) { result.insert("\"" + context._class->functions[i]->name + "\""); + r_forced = true; } } } @@ -1695,6 +1818,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N //print_line("found "+s); String name = s.get_slice("/", 1); result.insert("\"/root/" + name + "\""); + r_forced = true; } } @@ -1706,11 +1830,12 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N for (List<String>::Element *E = options.front(); E; E = E->next()) { result.insert(E->get()); + r_forced = true; } } } - arghint = _get_visual_datatype(m->get_argument_info(-1), false) + " " + p_method.operator String() + String("("); + arghint = _get_visual_datatype(m->get_return_info(), false) + " " + p_method.operator String() + String("("); for (int i = 0; i < m->get_argument_count(); i++) { if (i > 0) @@ -1749,7 +1874,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N } } -static void _find_call_arguments(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, int p_argidx, Set<String> &result, String &arghint) { +static void _find_call_arguments(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, int p_argidx, Set<String> &result, bool &r_forced, String &arghint) { if (!p_node || p_node->type != GDParser::Node::TYPE_OPERATOR) { @@ -1778,11 +1903,11 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N arghint += ", "; else arghint += " "; - if (i == p_argidx) { + if (i == p_argidx || (mi.flags & METHOD_FLAG_VARARG && i > p_argidx)) { arghint += String::chr(0xFFFF); } arghint += _get_visual_datatype(mi.arguments[i]) + " " + mi.arguments[i].name; - if (i == p_argidx) { + if (i == p_argidx || (mi.flags & METHOD_FLAG_VARARG && i > p_argidx)) { arghint += String::chr(0xFFFF); } } @@ -1904,7 +2029,7 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N if (!context._class->owner) ci.value = context.base; - _find_type_arguments(context, p_node, p_line, id->name, ci, p_argidx, result, arghint); + _find_type_arguments(context, p_node, p_line, id->name, ci, p_argidx, result, r_forced, arghint); //guess type.. /* List<MethodInfo> methods; @@ -1926,114 +2051,21 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N GDCompletionIdentifier ci; if (_guess_expression_type(context, op->arguments[0], p_line, ci)) { - _find_type_arguments(context, p_node, p_line, id->name, ci, p_argidx, result, arghint); + _find_type_arguments(context, p_node, p_line, id->name, ci, p_argidx, result, r_forced, arghint); return; } } } -#if 0 - bool _static=context.function->_static; - - - - - for(int i=0;i<context._class->static_functions.size();i++) { - if (context._class->static_functions[i]->arguments.size()) - result.insert(context._class->static_functions[i]->name.operator String()+"("); - else - result.insert(context._class->static_functions[i]->name.operator String()+"()"); - } - - if (!p_static) { - - for(int i=0;i<context._class->functions.size();i++) { - if (context._class->functions[i]->arguments.size()) - result.insert(context._class->functions[i]->name.operator String()+"("); - else - result.insert(context._class->functions[i]->name.operator String()+"()"); - } - } - - Ref<Reference> base = _get_parent_class(context); - - while(true) { - - Ref<GDScript> script = base; - Ref<GDNativeClass> nc = base; - if (script.is_valid()) { - - if (!p_static && !p_only_functions) { - for (const Set<StringName>::Element *E=script->get_members().front();E;E=E->next()) { - result.insert(E->get().operator String()); - } - } - - if (!p_only_functions) { - for (const Map<StringName,Variant>::Element *E=script->get_constants().front();E;E=E->next()) { - result.insert(E->key().operator String()); - } - } - - for (const Map<StringName,GDFunction>::Element *E=script->get_member_functions().front();E;E=E->next()) { - if (!p_static || E->get().is_static()) { - if (E->get().get_argument_count()) - result.insert(E->key().operator String()+"("); - else - result.insert(E->key().operator String()+"()"); - } - } - - if (!p_only_functions) { - for (const Map<StringName,Ref<GDScript> >::Element *E=script->get_subclasses().front();E;E=E->next()) { - result.insert(E->key().operator String()); - } - } - - base=script->get_base(); - if (base.is_null()) - base=script->get_native(); - } else if (nc.is_valid()) { - - if (!p_only_functions) { - - StringName type = nc->get_name(); - List<String> constants; - ClassDB::get_integer_constant_list(type,&constants); - for(List<String>::Element *E=constants.front();E;E=E->next()) { - result.insert(E->get()); - } - - List<MethodInfo> methods; - ClassDB::get_method_list(type,&methods); - for(List<MethodInfo>::Element *E=methods.front();E;E=E->next()) { - if (E->get().arguments.size()) - result.insert(E->get().name+"("); - else - result.insert(E->get().name+"()"); - } - } - break; - } else - break; - - } - - for(int i=0;i<GDFunctions::FUNC_MAX;i++) { - - result.insert(GDFunctions::get_func_name(GDFunctions::Function(i))); - } - -#endif } -Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint) { +Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_forced, String &r_call_hint) { GDParser p; p.parse(p_code, p_base_path, false, "", true); bool isfunction = false; Set<String> options; - + r_forced = false; GDCompletionContext context; context._class = p.get_completion_class(); context.block = p.get_completion_block(); @@ -2072,6 +2104,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base String opt = E->get().strip_edges(); if (opt.begins_with("\"") && opt.ends_with("\"")) { + r_forced = true; String idopt = opt.substr(1, opt.length() - 2); if (idopt.replace("/", "_").is_valid_identifier()) { options.insert(idopt); @@ -2091,7 +2124,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base break; GDCompletionIdentifier t; - if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t)) { + if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t, true)) { if (t.type == Variant::OBJECT && t.obj_type == "GDNativeClass") { //native enum @@ -2110,7 +2143,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { if (E->get().usage & (PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY)) continue; - if (E->get().name.find("/") != -1) + if (String(E->get().name).find("/") != -1) continue; options.insert(E->get().name); } @@ -2122,28 +2155,27 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base if (t.value.get_type()) { Object *obj = t.value; - if (obj) { - - GDScript *scr = obj->cast_to<GDScript>(); - if (scr) { - while (scr) { + GDScript *scr = Object::cast_to<GDScript>(obj); + if (scr) { + while (scr) { - if (!isfunction) { - for (const Map<StringName, Variant>::Element *E = scr->get_constants().front(); E; E = E->next()) { - options.insert(E->key()); - } + if (!isfunction) { + for (const Map<StringName, Variant>::Element *E = scr->get_constants().front(); E; E = E->next()) { + options.insert(E->key()); } - for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { - if (E->get()->is_static()) - options.insert(E->key()); - } - - if (scr->get_base().is_valid()) - scr = scr->get_base().ptr(); - else - scr = NULL; } - } else { + for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { + if (E->get()->is_static()) + options.insert(E->key()); + } + + if (scr->get_base().is_valid()) + scr = scr->get_base().ptr(); + else + scr = NULL; + } + } else { + if (obj) { on_script = obj->get_script(); } } @@ -2244,7 +2276,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { if (E->get().usage & (PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY)) continue; - if (E->get().name.find("/") != -1) + if (String(E->get().name).find("/") != -1) continue; r_options->push_back(E->get().name); } @@ -2276,7 +2308,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base t.value.get_property_list(&pl); for (List<PropertyInfo>::Element *E = pl.front(); E; E = E->next()) { - if (E->get().name.find("/") == -1) + if (String(E->get().name).find("/") == -1) options.insert(E->get().name); } } @@ -2296,7 +2328,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base } break; case GDParser::COMPLETION_CALL_ARGUMENTS: { - _find_call_arguments(context, p.get_completion_node(), p.get_completion_line(), p.get_completion_argument_index(), options, r_call_hint); + _find_call_arguments(context, p.get_completion_node(), p.get_completion_line(), p.get_completion_argument_index(), options, r_forced, r_call_hint); } break; case GDParser::COMPLETION_VIRTUAL_FUNC: { @@ -2343,6 +2375,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base ClassDB::get_signal_list(t.obj_type, &sigs); for (List<MethodInfo>::Element *E = sigs.front(); E; E = E->next()) { options.insert("\"" + E->get().name + "\""); + r_forced = true; } } @@ -2352,6 +2385,42 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base if (EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths")) get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), options); } break; + case GDParser::COMPLETION_ASSIGN: { +#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED) + + GDCompletionIdentifier ci; + if (_guess_expression_type(context, p.get_completion_node(), p.get_completion_line(), ci)) { + + String enumeration = ci.enumeration; + if (enumeration.find(".") != -1) { + //class constant + List<StringName> constants; + String cls = enumeration.get_slice(".", 0); + String enm = enumeration.get_slice(".", 1); + + ClassDB::get_enum_constants(cls, enm, &constants); + //constants.sort_custom<StringName::AlphCompare>(); + for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { + String add = cls + "." + E->get(); + r_options->push_back(add); + r_forced = true; + } + } else { + + //global constant + StringName current_enum = enumeration; + + for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) { + if (GlobalConstants::get_global_constant_enum(i) == current_enum) { + r_options->push_back(GlobalConstants::get_global_constant_name(i)); + r_forced = true; + } + } + //global + } + } +#endif + } break; } for (Set<String>::Element *E = options.front(); E; E = E->next()) { @@ -2363,7 +2432,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base #else -Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint) { +Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_forced, String &r_call_hint) { return OK; } @@ -2371,7 +2440,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base String GDScriptLanguage::_get_indentation() const { #ifdef TOOLS_ENABLED - if (SceneTree::get_singleton()->is_editor_hint()) { + if (Engine::get_singleton()->is_editor_hint()) { bool use_space_indentation = EDITOR_DEF("text_editor/indent/type", 0); if (use_space_indentation) { @@ -2700,9 +2769,9 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol Object *obj = value; if (obj) { - if (obj->cast_to<GDNativeClass>()) { + if (Object::cast_to<GDNativeClass>(obj)) { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; - r_result.class_name = obj->cast_to<GDNativeClass>()->get_name(); + r_result.class_name = Object::cast_to<GDNativeClass>(obj)->get_name(); } else { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; @@ -2719,18 +2788,6 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol } } } -#if 0 - GDCompletionIdentifier identifier; - if (_guess_identifier_type(context,p.get_completion_line(),p_symbol,identifier)) { - - print_line("var type: "+Variant::get_type_name(identifier.type)); - if (identifier.script.is_valid()) { - print_line("var script: "+identifier.script->get_path()); - } - print_line("obj type: "+String(identifier.obj_type)); - print_line("value: "+String(identifier.value)); - } -#endif } } break; diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp index cafcc1e965..e6f65fe0c2 100644 --- a/modules/gdscript/gd_function.cpp +++ b/modules/gdscript/gd_function.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -371,7 +371,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a Object *obj_A = *a; Object *obj_B = *b; - GDScript *scr_B = obj_B->cast_to<GDScript>(); + GDScript *scr_B = Object::cast_to<GDScript>(obj_B); bool extends_ok = false; @@ -397,7 +397,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } else { - GDNativeClass *nc = obj_B->cast_to<GDNativeClass>(); + GDNativeClass *nc = Object::cast_to<GDNativeClass>(obj_B); if (!nc) { @@ -1233,10 +1233,10 @@ int GDFunction::get_default_argument_count() const { return default_arguments.size(); } -int GDFunction::get_default_argument_addr(int p_arg) const { +int GDFunction::get_default_argument_addr(int p_idx) const { - ERR_FAIL_INDEX_V(p_arg, default_arguments.size(), -1); - return default_arguments[p_arg]; + ERR_FAIL_INDEX_V(p_idx, default_arguments.size(), -1); + return default_arguments[p_idx]; } StringName GDFunction::get_name() const { @@ -1319,22 +1319,6 @@ void GDFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, } } -#if 0 -void GDFunction::clear() { - - name=StringName(); - constants.clear(); - _stack_size=0; - code.clear(); - _constants_ptr=NULL; - _constant_count=0; - _global_names_ptr=NULL; - _global_names_count=0; - _code_ptr=NULL; - _code_size=0; - -} -#endif GDFunction::GDFunction() : function_list(this) { @@ -1434,7 +1418,7 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount // If the return value is a GDFunctionState reference, // then the function did yield again after resuming. if (ret.is_ref()) { - GDFunctionState *gdfs = ret.operator Object *()->cast_to<GDFunctionState>(); + GDFunctionState *gdfs = Object::cast_to<GDFunctionState>(ret); if (gdfs && gdfs->function == function) completed = false; } @@ -1490,7 +1474,7 @@ Variant GDFunctionState::resume(const Variant &p_arg) { // If the return value is a GDFunctionState reference, // then the function did yield again after resuming. if (ret.is_ref()) { - GDFunctionState *gdfs = ret.operator Object *()->cast_to<GDFunctionState>(); + GDFunctionState *gdfs = Object::cast_to<GDFunctionState>(ret); if (gdfs && gdfs->function == function) completed = false; } diff --git a/modules/gdscript/gd_function.h b/modules/gdscript/gd_function.h index 6d20b19777..bf5ff5f8da 100644 --- a/modules/gdscript/gd_function.h +++ b/modules/gdscript/gd_function.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -210,8 +210,9 @@ public: #ifdef TOOLS_ENABLED ERR_FAIL_INDEX_V(p_idx, arg_names.size(), StringName()); return arg_names[p_idx]; -#endif +#else return StringName(); +#endif } Variant get_default_argument(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, default_arguments.size(), Variant()); diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index 209bdadd67..f0cfdd6258 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -70,6 +70,8 @@ const char *GDFunctions::get_func_name(Function p_func) { "decimals", "stepify", "lerp", + "inverse_lerp", + "range_lerp", "dectime", "randomize", "randi", @@ -326,6 +328,22 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, VALIDATE_ARG_NUM(2); r_ret = Math::lerp((double)*p_args[0], (double)*p_args[1], (double)*p_args[2]); } break; + case MATH_INVERSE_LERP: { + VALIDATE_ARG_COUNT(3); + VALIDATE_ARG_NUM(0); + VALIDATE_ARG_NUM(1); + VALIDATE_ARG_NUM(2); + r_ret = Math::inverse_lerp((double)*p_args[0], (double)*p_args[1], (double)*p_args[2]); + } break; + case MATH_RANGE_LERP: { + VALIDATE_ARG_COUNT(5); + VALIDATE_ARG_NUM(0); + VALIDATE_ARG_NUM(1); + VALIDATE_ARG_NUM(2); + VALIDATE_ARG_NUM(3); + VALIDATE_ARG_NUM(4); + r_ret = Math::range_lerp((double)*p_args[0], (double)*p_args[1], (double)*p_args[2], (double)*p_args[3], (double)*p_args[4]); + } break; case MATH_DECTIME: { VALIDATE_ARG_COUNT(3); VALIDATE_ARG_NUM(0); @@ -446,7 +464,7 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); int64_t num = *p_args[0]; - r_ret = nearest_power_of_2(num); + r_ret = next_power_of_2(num); } break; case OBJ_WEAKREF: { VALIDATE_ARG_COUNT(1); @@ -1252,6 +1270,8 @@ bool GDFunctions::is_deterministic(Function p_func) { case MATH_DECIMALS: case MATH_STEPIFY: case MATH_LERP: + case MATH_INVERSE_LERP: + case MATH_RANGE_LERP: case MATH_DECTIME: case MATH_DEG2RAD: case MATH_RAD2DEG: @@ -1420,6 +1440,16 @@ MethodInfo GDFunctions::get_info(Function p_func) { mi.return_val.type = Variant::REAL; return mi; } break; + case MATH_INVERSE_LERP: { + MethodInfo mi("inverse_lerp", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "value")); + mi.return_val.type = Variant::REAL; + return mi; + } break; + case MATH_RANGE_LERP: { + MethodInfo mi("range_lerp", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "istart"), PropertyInfo(Variant::REAL, "istop"), PropertyInfo(Variant::REAL, "ostart"), PropertyInfo(Variant::REAL, "ostop")); + mi.return_val.type = Variant::REAL; + return mi; + } break; case MATH_DECTIME: { MethodInfo mi("dectime", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "amount"), PropertyInfo(Variant::REAL, "step")); mi.return_val.type = Variant::REAL; @@ -1542,43 +1572,49 @@ MethodInfo GDFunctions::get_info(Function p_func) { } break; case TEXT_STR: { - MethodInfo mi("str", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "...")); + MethodInfo mi("str"); mi.return_val.type = Variant::STRING; + mi.flags |= METHOD_FLAG_VARARG; return mi; } break; case TEXT_PRINT: { - MethodInfo mi("print", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "...")); + MethodInfo mi("print"); mi.return_val.type = Variant::NIL; + mi.flags |= METHOD_FLAG_VARARG; return mi; } break; case TEXT_PRINT_TABBED: { - MethodInfo mi("printt", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "...")); + MethodInfo mi("printt"); mi.return_val.type = Variant::NIL; + mi.flags |= METHOD_FLAG_VARARG; return mi; } break; case TEXT_PRINT_SPACED: { - MethodInfo mi("prints", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "...")); + MethodInfo mi("prints"); mi.return_val.type = Variant::NIL; + mi.flags |= METHOD_FLAG_VARARG; return mi; } break; case TEXT_PRINTERR: { - MethodInfo mi("printerr", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "...")); + MethodInfo mi("printerr"); mi.return_val.type = Variant::NIL; + mi.flags |= METHOD_FLAG_VARARG; return mi; } break; case TEXT_PRINTRAW: { - MethodInfo mi("printraw", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "...")); + MethodInfo mi("printraw"); mi.return_val.type = Variant::NIL; + mi.flags |= METHOD_FLAG_VARARG; return mi; } break; @@ -1590,8 +1626,9 @@ MethodInfo GDFunctions::get_info(Function p_func) { } break; case STR_TO_VAR: { - MethodInfo mi("str2var:Variant", PropertyInfo(Variant::STRING, "string")); + MethodInfo mi(Variant::NIL, "str2var", PropertyInfo(Variant::STRING, "string")); mi.return_val.type = Variant::NIL; + mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; return mi; } break; case VAR_TO_BYTES: { @@ -1602,14 +1639,16 @@ MethodInfo GDFunctions::get_info(Function p_func) { } break; case BYTES_TO_VAR: { - MethodInfo mi("bytes2var:Variant", PropertyInfo(Variant::POOL_BYTE_ARRAY, "bytes")); + MethodInfo mi(Variant::NIL, "bytes2var", PropertyInfo(Variant::POOL_BYTE_ARRAY, "bytes")); mi.return_val.type = Variant::NIL; + mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; return mi; } break; case GEN_RANGE: { - MethodInfo mi("range", PropertyInfo(Variant::NIL, "...")); + MethodInfo mi("range"); mi.return_val.type = Variant::ARRAY; + mi.flags |= METHOD_FLAG_VARARG; return mi; } break; case RESOURCE_LOAD: { @@ -1633,14 +1672,15 @@ MethodInfo GDFunctions::get_info(Function p_func) { } break; case VALIDATE_JSON: { - MethodInfo mi("validate_json:Variant", PropertyInfo(Variant::STRING, "json")); + MethodInfo mi("validate_json", PropertyInfo(Variant::STRING, "json")); mi.return_val.type = Variant::STRING; return mi; } break; case PARSE_JSON: { - MethodInfo mi("parse_json:Variant", PropertyInfo(Variant::STRING, "json")); + MethodInfo mi(Variant::NIL, "parse_json", PropertyInfo(Variant::STRING, "json")); mi.return_val.type = Variant::NIL; + mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; return mi; } break; case TO_JSON: { diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h index 93cb524118..a568c8f1cf 100644 --- a/modules/gdscript/gd_functions.h +++ b/modules/gdscript/gd_functions.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -62,6 +62,8 @@ public: MATH_DECIMALS, MATH_STEPIFY, MATH_LERP, + MATH_INVERSE_LERP, + MATH_RANGE_LERP, MATH_DECTIME, MATH_RANDOMIZE, MATH_RAND, diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 9023fd4bf4..072937a521 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -1044,6 +1044,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool return NULL; \ } \ p_allow_assign = false; + switch (tokenizer->get_token()) { //see operator case GDTokenizer::TK_OP_IN: op = OperatorNode::OP_IN; break; @@ -1065,7 +1066,22 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool //case GDTokenizer::TK_OP_NEG: op=OperatorNode::OP_NEG ; break; case GDTokenizer::TK_OP_SHIFT_LEFT: op = OperatorNode::OP_SHIFT_LEFT; break; case GDTokenizer::TK_OP_SHIFT_RIGHT: op = OperatorNode::OP_SHIFT_RIGHT; break; - case GDTokenizer::TK_OP_ASSIGN: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN; break; + case GDTokenizer::TK_OP_ASSIGN: { + _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN; + + if (tokenizer->get_token(1) == GDTokenizer::TK_CURSOR) { + //code complete assignment + completion_type = COMPLETION_ASSIGN; + completion_node = expr; + completion_class = current_class; + completion_function = current_function; + completion_line = tokenizer->get_token_line(); + completion_block = current_block; + completion_found = true; + tokenizer->advance(); + } + + } break; case GDTokenizer::TK_OP_ASSIGN_ADD: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_ADD; break; case GDTokenizer::TK_OP_ASSIGN_SUB: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SUB; break; case GDTokenizer::TK_OP_ASSIGN_MUL: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_MUL; break; @@ -1894,7 +1910,26 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) { return NULL; } - if (value->type != Node::TYPE_IDENTIFIER && value->type != Node::TYPE_CONSTANT) { + if (value->type == Node::TYPE_OPERATOR) { + // Maybe it's SomeEnum.VALUE + Node *current_value = value; + + while (current_value->type == Node::TYPE_OPERATOR) { + OperatorNode *op_node = static_cast<OperatorNode *>(current_value); + + if (op_node->op != OperatorNode::OP_INDEX_NAMED) { + _set_error("Invalid operator in pattern. Only index (`A.B`) is allowed"); + return NULL; + } + current_value = op_node->arguments[0]; + } + + if (current_value->type != Node::TYPE_IDENTIFIER) { + _set_error("Only constant expression or variables allowed in a pattern"); + return NULL; + } + + } else if (value->type != Node::TYPE_IDENTIFIER && value->type != Node::TYPE_CONSTANT) { _set_error("Only constant expressions or variables allowed in a pattern"); return NULL; } @@ -2381,9 +2416,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) { tokenizer->advance(); - Node *subexpr = NULL; - - subexpr = _parse_and_reduce_expression(p_block, p_static); + Node *subexpr = _parse_and_reduce_expression(p_block, p_static); if (!subexpr) { if (_recover_from_completion()) { break; @@ -2437,6 +2470,8 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { cf_if->body = alloc_node<BlockNode>(); cf_if->body->parent_block = p_block; + cf_if->body->if_condition = condition; //helps code completion + p_block->sub_blocks.push_back(cf_if->body); if (!_enter_indent_block(cf_if->body)) { @@ -3135,9 +3170,7 @@ void GDParser::_parse_class(ClassNode *p_class) { if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) { defaulting = true; tokenizer->advance(1); - Node *defval = NULL; - - defval = _parse_and_reduce_expression(p_class, _static); + Node *defval = _parse_and_reduce_expression(p_class, _static); if (!defval || error_set) return; @@ -3875,9 +3908,7 @@ void GDParser::_parse_class(ClassNode *p_class) { #endif tokenizer->advance(); - Node *subexpr = NULL; - - subexpr = _parse_and_reduce_expression(p_class, false, autoexport); + Node *subexpr = _parse_and_reduce_expression(p_class, false, autoexport); if (!subexpr) { if (_recover_from_completion()) { break; @@ -3928,7 +3959,7 @@ void GDParser::_parse_class(ClassNode *p_class) { member._export.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE; if (cn->value.get_type() == Variant::OBJECT) { Object *obj = cn->value; - Resource *res = obj->cast_to<Resource>(); + Resource *res = Object::cast_to<Resource>(obj); if (res == NULL) { _set_error("Exported constant not a type or resource."); return; @@ -4035,9 +4066,7 @@ void GDParser::_parse_class(ClassNode *p_class) { tokenizer->advance(); - Node *subexpr = NULL; - - subexpr = _parse_and_reduce_expression(p_class, true, true); + Node *subexpr = _parse_and_reduce_expression(p_class, true, true); if (!subexpr) { if (_recover_from_completion()) { break; @@ -4103,9 +4132,7 @@ void GDParser::_parse_class(ClassNode *p_class) { if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) { tokenizer->advance(); - Node *subexpr = NULL; - - subexpr = _parse_and_reduce_expression(p_class, true, true); + Node *subexpr = _parse_and_reduce_expression(p_class, true, true); if (!subexpr) { if (_recover_from_completion()) { break; diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gd_parser.h index 3ad3466624..7e88fd9746 100644 --- a/modules/gdscript/gd_parser.h +++ b/modules/gdscript/gd_parser.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -146,10 +146,13 @@ public: Vector<StringName> variables; Vector<int> variable_lines; + Node *if_condition; //tiny hack to improve code completion on if () blocks + //the following is useful for code completion List<BlockNode *> sub_blocks; int end_line; BlockNode() { + if_condition = NULL; type = TYPE_BLOCK; end_line = -1; parent_block = NULL; @@ -441,6 +444,7 @@ public: COMPLETION_INDEX, COMPLETION_VIRTUAL_FUNC, COMPLETION_YIELD, + COMPLETION_ASSIGN, }; private: diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 9d304c6d34..cf6529d5ae 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "gd_script.h" + #include "gd_compiler.h" #include "global_constants.h" #include "io/file_access_encrypted.h" @@ -42,11 +43,6 @@ GDNativeClass::GDNativeClass(const StringName &p_name) { name = p_name; } -/*void GDNativeClass::call_multilevel(const StringName& p_method,const Variant** p_args,int p_argcount){ - - -}*/ - bool GDNativeClass::_get(const StringName &p_name, Variant &r_ret) const { bool ok; @@ -73,7 +69,7 @@ Variant GDNativeClass::_new() { ERR_FAIL_COND_V(!o, Variant()); } - Reference *ref = o->cast_to<Reference>(); + Reference *ref = Object::cast_to<Reference>(o); if (ref) { return REF(ref); } else { @@ -161,7 +157,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro owner = memnew(Reference); //by default, no base means use reference } - Reference *r = owner->cast_to<Reference>(); + Reference *r = Object::cast_to<Reference>(owner); if (r) { ref = REF(r); } @@ -183,7 +179,6 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro bool GDScript::can_instance() const { - //return valid; //any script in GDscript can instance return valid || (!tool && !ScriptServer::is_scripting_enabled()); } @@ -218,49 +213,6 @@ void GDScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) { placeholders.erase(p_placeholder); } - -/* -void GDScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) { - - - List<PropertyInfo> plist; - GDScript *scr=this; - - Map<StringName,Variant> default_values; - while(scr) { - - Vector<_GDScriptMemberSort> msort; - for(Map<StringName,PropertyInfo>::Element *E=scr->member_info.front();E;E=E->next()) { - - _GDScriptMemberSort ms; - ERR_CONTINUE(!scr->member_indices.has(E->key())); - ms.index=scr->member_indices[E->key()].index; - ms.name=E->key(); - - msort.push_back(ms); - - } - - msort.sort(); - msort.invert(); - for(int i=0;i<msort.size();i++) { - - plist.push_front(scr->member_info[msort[i].name]); - if (scr->member_default_values.has(msort[i].name)) - default_values[msort[i].name]=scr->member_default_values[msort[i].name]; - else { - Variant::CallError err; - default_values[msort[i].name]=Variant::construct(scr->member_info[msort[i].name].type,NULL,0,err); - } - } - - scr=scr->_base; - } - - - p_placeholder->update(plist,default_values); - -}*/ #endif void GDScript::get_script_method_list(List<MethodInfo> *p_list) const { @@ -397,7 +349,7 @@ ScriptInstance *GDScript::instance_create(Object *p_this) { } Variant::CallError unchecked_error; - return _create_instance(NULL, 0, p_this, p_this->cast_to<Reference>(), unchecked_error); + return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this), unchecked_error); } bool GDScript::instance_has(const Object *p_this) const { @@ -428,7 +380,6 @@ void GDScript::set_source_code(const String &p_code) { source = p_code; #ifdef TOOLS_ENABLED source_changed_cache = true; -//print_line("SC CHANGED "+get_path()); #endif } @@ -559,8 +510,9 @@ bool GDScript::_update_exports() { return changed; -#endif +#else return false; +#endif } void GDScript::update_exports() { @@ -574,9 +526,7 @@ void GDScript::update_exports() { //print_line("update exports for "+get_path()+" ic: "+itos(copy.size())); for (Set<ObjectID>::Element *E = copy.front(); E; E = E->next()) { Object *id = ObjectDB::get_instance(E->get()); - if (!id) - continue; - GDScript *s = id->cast_to<GDScript>(); + GDScript *s = Object::cast_to<GDScript>(id); if (!s) continue; s->update_exports(); @@ -615,7 +565,7 @@ Error GDScript::reload(bool p_keep_state) { if (basedir != "") basedir = basedir.get_base_dir(); - if (basedir.find("res://") == -1 && basedir.find("user://") == -1) { + if (source.find("%BASE%") != -1) { //loading a template, don't parse return OK; } @@ -656,12 +606,6 @@ Error GDScript::reload(bool p_keep_state) { _set_subclass_path(E->get(), path); } -#ifdef TOOLS_ENABLED -/*for (Set<PlaceHolderScriptInstance*>::Element *E=placeholders.front();E;E=E->next()) { - - _update_placeholder(E->get()); - }*/ -#endif return OK; } @@ -1142,53 +1086,10 @@ void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const { props.push_front(sptr->member_info[msort[i].name]); } -#if 0 - if (sptr->member_functions.has("_get_property_list")) { - - Variant::CallError err; - GDFunction *f = const_cast<GDFunction*>(sptr->member_functions["_get_property_list"]); - Variant plv = f->call(const_cast<GDInstance*>(this),NULL,0,err); - - if (plv.get_type()!=Variant::ARRAY) { - - ERR_PRINT("_get_property_list: expected array returned"); - } else { - - Array pl=plv; - - for(int i=0;i<pl.size();i++) { - - Dictionary p = pl[i]; - PropertyInfo pinfo; - if (!p.has("name")) { - ERR_PRINT("_get_property_list: expected 'name' key of type string.") - continue; - } - if (!p.has("type")) { - ERR_PRINT("_get_property_list: expected 'type' key of type integer.") - continue; - } - pinfo.name=p["name"]; - pinfo.type=Variant::Type(int(p["type"])); - if (p.has("hint")) - pinfo.hint=PropertyHint(int(p["hint"])); - if (p.has("hint_string")) - pinfo.hint_string=p["hint_string"]; - if (p.has("usage")) - pinfo.usage=p["usage"]; - - - props.push_back(pinfo); - } - } - } -#endif sptr = sptr->_base; } - //props.invert(); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { p_properties->push_back(E->get()); @@ -1391,10 +1292,6 @@ GDInstance::~GDInstance() { } /************* SCRIPT LANGUAGE **************/ -/************* SCRIPT LANGUAGE **************/ -/************* SCRIPT LANGUAGE **************/ -/************* SCRIPT LANGUAGE **************/ -/************* SCRIPT LANGUAGE **************/ GDScriptLanguage *GDScriptLanguage::singleton = NULL; @@ -2005,11 +1902,11 @@ Error ResourceFormatSaverGDScript::save(const String &p_path, const RES &p_resou void ResourceFormatSaverGDScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { - if (p_resource->cast_to<GDScript>()) { + if (Object::cast_to<GDScript>(*p_resource)) { p_extensions->push_back("gd"); } } bool ResourceFormatSaverGDScript::recognize(const RES &p_resource) const { - return p_resource->cast_to<GDScript>() != NULL; + return Object::cast_to<GDScript>(*p_resource) != NULL; } diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index 17e7b0bc03..6f05a4770b 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -390,7 +390,7 @@ public: virtual int find_function(const String &p_function, const String &p_code) const; virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const; virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return OK; } - virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint); + virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_forced, String &r_call_hint); #ifdef TOOLS_ENABLED virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_base_path, Object *p_owner, LookupResult &r_result); #endif diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index 5803046185..5f85158232 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "gd_tokenizer.h" + #include "gd_functions.h" #include "io/marshalls.h" #include "map.h" @@ -504,7 +505,6 @@ void GDTokenizerText::_advance() { _make_newline(i); return; } -#if 1 //py style tokenizer case '#': { // line comment skip while (GETCHAR(0) != '\n') { @@ -526,57 +526,9 @@ void GDTokenizerText::_advance() { return; } break; -#endif case '/': { switch (GETCHAR(1)) { -#if 0 // c style tokenizer - case '*': { // block comment - int pos = code_pos+2; - int new_line=line; - int new_col=column+2; - - while(true) { - if (_code[pos]=='0') { - _make_error("Unterminated Comment"); - code_pos=pos; - return; - } - if (_code[pos]=='*' && _code[pos+1]=='/') { - new_col+=2; - pos+=2; //compensate - break; - } else if (_code[pos]=='\n') { - new_line++; - new_col=1; - } else { - new_col++; - } - pos++; - } - - column=new_col; - line=new_line; - code_pos=pos; - continue; - - } break; - case '/': { // line comment skip - - while(GETCHAR(0)!='\n') { - code_pos++; - if (GETCHAR(0)==0) { //end of file - _make_error("Unterminated Comment"); - return; - } - } - INCPOS(1); - column=1; - line++; - continue; - - } break; -#endif case '=': { // diveq _make_token(TK_OP_ASSIGN_DIV); @@ -1187,9 +1139,7 @@ Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) { int line_count = decode_uint32(&buf[16]); int token_count = decode_uint32(&buf[20]); - const uint8_t *b = buf; - - b = &buf[24]; + const uint8_t *b = &buf[24]; total_len -= 24; identifiers.resize(identifier_count); diff --git a/modules/gdscript/gd_tokenizer.h b/modules/gdscript/gd_tokenizer.h index 4e868301a3..c935ce45a1 100644 --- a/modules/gdscript/gd_tokenizer.h +++ b/modules/gdscript/gd_tokenizer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp index 41ea0c2a26..036274c8f2 100644 --- a/modules/gdscript/register_types.cpp +++ b/modules/gdscript/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -37,103 +37,7 @@ GDScriptLanguage *script_language_gd = NULL; ResourceFormatLoaderGDScript *resource_loader_gd = NULL; ResourceFormatSaverGDScript *resource_saver_gd = NULL; -#if 0 -#ifdef TOOLS_ENABLED -#include "editor/editor_import_export.h" -#include "editor/editor_node.h" -#include "editor/editor_settings.h" -#include "gd_tokenizer.h" - -class EditorExportGDScript : public EditorExportPlugin { - - GDCLASS(EditorExportGDScript,EditorExportPlugin); - -public: - - virtual Vector<uint8_t> custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) { - //compile gdscript to bytecode - - if (EditorImportExport::get_singleton()->script_get_action()!=EditorImportExport::SCRIPT_ACTION_NONE) { - - if (p_path.ends_with(".gd")) { - Vector<uint8_t> file = FileAccess::get_file_as_array(p_path); - if (file.empty()) - return file; - String txt; - txt.parse_utf8((const char*)file.ptr(),file.size()); - file = GDTokenizerBuffer::parse_code_string(txt); - - if (!file.empty()) { - - if (EditorImportExport::get_singleton()->script_get_action()==EditorImportExport::SCRIPT_ACTION_ENCRYPT) { - - String tmp_path=EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/script.gde"); - FileAccess *fa = FileAccess::open(tmp_path,FileAccess::WRITE); - String skey=EditorImportExport::get_singleton()->script_get_encryption_key().to_lower(); - Vector<uint8_t> key; - key.resize(32); - for(int i=0;i<32;i++) { - int v=0; - if (i*2<skey.length()) { - CharType ct = skey[i*2]; - if (ct>='0' && ct<='9') - ct=ct-'0'; - else if (ct>='a' && ct<='f') - ct=10+ct-'a'; - v|=ct<<4; - } - - if (i*2+1<skey.length()) { - CharType ct = skey[i*2+1]; - if (ct>='0' && ct<='9') - ct=ct-'0'; - else if (ct>='a' && ct<='f') - ct=10+ct-'a'; - v|=ct; - } - key[i]=v; - } - FileAccessEncrypted *fae=memnew(FileAccessEncrypted); - Error err = fae->open_and_parse(fa,key,FileAccessEncrypted::MODE_WRITE_AES256); - if (err==OK) { - - fae->store_buffer(file.ptr(),file.size()); - p_path=p_path.get_basename()+".gde"; - } - - memdelete(fae); - - file=FileAccess::get_file_as_array(tmp_path); - return file; - - - } else { - - p_path=p_path.get_basename()+".gdc"; - return file; - } - } - - } - } - - return Vector<uint8_t>(); - } - - - EditorExportGDScript(){} - -}; - -static void register_editor_plugin() { - - Ref<EditorExportGDScript> egd = memnew( EditorExportGDScript ); - EditorImportExport::get_singleton()->add_export_plugin(egd); -} - -#endif -#endif void register_gdscript_types() { ClassDB::register_class<GDScript>(); @@ -146,13 +50,8 @@ void register_gdscript_types() { ResourceLoader::add_resource_format_loader(resource_loader_gd); resource_saver_gd = memnew(ResourceFormatSaverGDScript); ResourceSaver::add_resource_format_saver(resource_saver_gd); -#if 0 -#ifdef TOOLS_ENABLED - - EditorNode::add_init_callback(register_editor_plugin); -#endif -#endif } + void unregister_gdscript_types() { ScriptServer::unregister_language(script_language_gd); diff --git a/modules/gdscript/register_types.h b/modules/gdscript/register_types.h index 4e969f5bd4..a674877f37 100644 --- a/modules/gdscript/register_types.h +++ b/modules/gdscript/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ |