From 4cfc29611e21811065d024a6de1685418e60111e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 16 Nov 2017 18:38:18 +0100 Subject: [PATCH] GDScript: Refactor "GD" class prefix to "GDScript" --- doc/classes/@GDScript.xml | 4 +- main/tests/test_gdscript.cpp | 298 ++++---- modules/gdscript/config.py | 4 +- ...ionState.xml => GDScriptFunctionState.xml} | 4 +- ...ativeClass.xml => GDScriptNativeClass.xml} | 2 +- .../gdscript/{gd_script.cpp => gdscript.cpp} | 128 ++-- modules/gdscript/{gd_script.h => gdscript.h} | 63 +- ...{gd_compiler.cpp => gdscript_compiler.cpp} | 557 +++++++------- .../{gd_compiler.h => gdscript_compiler.h} | 46 +- .../{gd_editor.cpp => gdscript_editor.cpp} | 460 ++++++------ ...{gd_function.cpp => gdscript_function.cpp} | 78 +- .../{gd_function.h => gdscript_function.h} | 40 +- ...d_functions.cpp => gdscript_functions.cpp} | 19 +- .../{gd_functions.h => gdscript_functions.h} | 10 +- .../{gd_parser.cpp => gdscript_parser.cpp} | 695 +++++++++--------- .../{gd_parser.h => gdscript_parser.h} | 22 +- ...d_tokenizer.cpp => gdscript_tokenizer.cpp} | 192 ++--- .../{gd_tokenizer.h => gdscript_tokenizer.h} | 30 +- modules/gdscript/register_types.cpp | 5 +- 19 files changed, 1330 insertions(+), 1327 deletions(-) rename modules/gdscript/doc_classes/{GDFunctionState.xml => GDScriptFunctionState.xml} (84%) rename modules/gdscript/doc_classes/{GDNativeClass.xml => GDScriptNativeClass.xml} (78%) rename modules/gdscript/{gd_script.cpp => gdscript.cpp} (89%) rename modules/gdscript/{gd_script.h => gdscript.h} (91%) rename modules/gdscript/{gd_compiler.cpp => gdscript_compiler.cpp} (67%) rename modules/gdscript/{gd_compiler.h => gdscript_compiler.h} (74%) rename modules/gdscript/{gd_editor.cpp => gdscript_editor.cpp} (80%) rename modules/gdscript/{gd_function.cpp => gdscript_function.cpp} (93%) rename modules/gdscript/{gd_function.h => gdscript_function.h} (87%) rename modules/gdscript/{gd_functions.cpp => gdscript_functions.cpp} (98%) rename modules/gdscript/{gd_functions.h => gdscript_functions.h} (95%) rename modules/gdscript/{gd_parser.cpp => gdscript_parser.cpp} (79%) rename modules/gdscript/{gd_parser.h => gdscript_parser.h} (97%) rename modules/gdscript/{gd_tokenizer.cpp => gdscript_tokenizer.cpp} (84%) rename modules/gdscript/{gd_tokenizer.h => gdscript_tokenizer.h} (90%) diff --git a/doc/classes/@GDScript.xml b/doc/classes/@GDScript.xml index 3f2d0c71e70..49ec412ba00 100644 --- a/doc/classes/@GDScript.xml +++ b/doc/classes/@GDScript.xml @@ -1103,14 +1103,14 @@ - + - Stops the function execution and returns the current state. Call [method GDFunctionState.resume] on the state to resume execution. This invalidates the state. + Stops the function execution and returns the current state. Call [method GDScriptFunctionState.resume] on the state to resume execution. This invalidates the state. Returns anything that was passed to the resume function call. If passed an object and a signal, the execution is resumed when the object's signal is emitted. diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp index bcf4278bdef..b41b5f64522 100644 --- a/main/tests/test_gdscript.cpp +++ b/main/tests/test_gdscript.cpp @@ -35,10 +35,10 @@ #ifdef GDSCRIPT_ENABLED -#include "modules/gdscript/gd_compiler.h" -#include "modules/gdscript/gd_parser.h" -#include "modules/gdscript/gd_script.h" -#include "modules/gdscript/gd_tokenizer.h" +#include "modules/gdscript/gdscript.h" +#include "modules/gdscript/gdscript_compiler.h" +#include "modules/gdscript/gdscript_parser.h" +#include "modules/gdscript/gdscript_tokenizer.h" namespace TestGDScript { @@ -52,7 +52,7 @@ static void _print_indent(int p_ident, const String &p_text) { print_line(txt + p_text); } -static String _parser_extends(const GDParser::ClassNode *p_class) { +static String _parser_extends(const GDScriptParser::ClassNode *p_class) { String txt = "extends "; if (String(p_class->extends_file) != "") { @@ -72,29 +72,29 @@ static String _parser_extends(const GDParser::ClassNode *p_class) { return txt; } -static String _parser_expr(const GDParser::Node *p_expr) { +static String _parser_expr(const GDScriptParser::Node *p_expr) { String txt; switch (p_expr->type) { - case GDParser::Node::TYPE_IDENTIFIER: { + case GDScriptParser::Node::TYPE_IDENTIFIER: { - const GDParser::IdentifierNode *id_node = static_cast(p_expr); + const GDScriptParser::IdentifierNode *id_node = static_cast(p_expr); txt = id_node->name; } break; - case GDParser::Node::TYPE_CONSTANT: { - const GDParser::ConstantNode *c_node = static_cast(p_expr); + case GDScriptParser::Node::TYPE_CONSTANT: { + const GDScriptParser::ConstantNode *c_node = static_cast(p_expr); if (c_node->value.get_type() == Variant::STRING) txt = "\"" + String(c_node->value) + "\""; else txt = c_node->value; } break; - case GDParser::Node::TYPE_SELF: { + case GDScriptParser::Node::TYPE_SELF: { txt = "self"; } break; - case GDParser::Node::TYPE_ARRAY: { - const GDParser::ArrayNode *arr_node = static_cast(p_expr); + case GDScriptParser::Node::TYPE_ARRAY: { + const GDScriptParser::ArrayNode *arr_node = static_cast(p_expr); txt += "["; for (int i = 0; i < arr_node->elements.size(); i++) { @@ -104,51 +104,51 @@ static String _parser_expr(const GDParser::Node *p_expr) { } txt += "]"; } break; - case GDParser::Node::TYPE_DICTIONARY: { - const GDParser::DictionaryNode *dict_node = static_cast(p_expr); + case GDScriptParser::Node::TYPE_DICTIONARY: { + const GDScriptParser::DictionaryNode *dict_node = static_cast(p_expr); txt += "{"; for (int i = 0; i < dict_node->elements.size(); i++) { if (i > 0) txt += ", "; - const GDParser::DictionaryNode::Pair &p = dict_node->elements[i]; + const GDScriptParser::DictionaryNode::Pair &p = dict_node->elements[i]; txt += _parser_expr(p.key); txt += ":"; txt += _parser_expr(p.value); } txt += "}"; } break; - case GDParser::Node::TYPE_OPERATOR: { + case GDScriptParser::Node::TYPE_OPERATOR: { - const GDParser::OperatorNode *c_node = static_cast(p_expr); + const GDScriptParser::OperatorNode *c_node = static_cast(p_expr); switch (c_node->op) { - case GDParser::OperatorNode::OP_PARENT_CALL: + case GDScriptParser::OperatorNode::OP_PARENT_CALL: txt += "."; - case GDParser::OperatorNode::OP_CALL: { + case GDScriptParser::OperatorNode::OP_CALL: { ERR_FAIL_COND_V(c_node->arguments.size() < 1, ""); String func_name; - const GDParser::Node *nfunc = c_node->arguments[0]; + const GDScriptParser::Node *nfunc = c_node->arguments[0]; int arg_ofs = 0; - if (nfunc->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) { + if (nfunc->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) { - const GDParser::BuiltInFunctionNode *bif_node = static_cast(nfunc); - func_name = GDFunctions::get_func_name(bif_node->function); + const GDScriptParser::BuiltInFunctionNode *bif_node = static_cast(nfunc); + func_name = GDScriptFunctions::get_func_name(bif_node->function); arg_ofs = 1; - } else if (nfunc->type == GDParser::Node::TYPE_TYPE) { + } else if (nfunc->type == GDScriptParser::Node::TYPE_TYPE) { - const GDParser::TypeNode *t_node = static_cast(nfunc); + const GDScriptParser::TypeNode *t_node = static_cast(nfunc); func_name = Variant::get_type_name(t_node->vtype); arg_ofs = 1; } else { ERR_FAIL_COND_V(c_node->arguments.size() < 2, ""); nfunc = c_node->arguments[1]; - ERR_FAIL_COND_V(nfunc->type != GDParser::Node::TYPE_IDENTIFIER, ""); + ERR_FAIL_COND_V(nfunc->type != GDScriptParser::Node::TYPE_IDENTIFIER, ""); - if (c_node->arguments[0]->type != GDParser::Node::TYPE_SELF) + if (c_node->arguments[0]->type != GDScriptParser::Node::TYPE_SELF) func_name = _parser_expr(c_node->arguments[0]) + "."; func_name += _parser_expr(nfunc); @@ -159,7 +159,7 @@ static String _parser_expr(const GDParser::Node *p_expr) { for (int i = arg_ofs; i < c_node->arguments.size(); i++) { - const GDParser::Node *arg = c_node->arguments[i]; + const GDScriptParser::Node *arg = c_node->arguments[i]; if (i > arg_ofs) txt += ", "; txt += _parser_expr(arg); @@ -168,7 +168,7 @@ static String _parser_expr(const GDParser::Node *p_expr) { txt += ")"; } break; - case GDParser::OperatorNode::OP_INDEX: { + case GDScriptParser::OperatorNode::OP_INDEX: { ERR_FAIL_COND_V(c_node->arguments.size() != 2, ""); @@ -176,125 +176,125 @@ static String _parser_expr(const GDParser::Node *p_expr) { txt = _parser_expr(c_node->arguments[0]) + "[" + _parser_expr(c_node->arguments[1]) + "]"; } break; - case GDParser::OperatorNode::OP_INDEX_NAMED: { + case GDScriptParser::OperatorNode::OP_INDEX_NAMED: { ERR_FAIL_COND_V(c_node->arguments.size() != 2, ""); txt = _parser_expr(c_node->arguments[0]) + "." + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_NEG: { + case GDScriptParser::OperatorNode::OP_NEG: { txt = "-" + _parser_expr(c_node->arguments[0]); } break; - case GDParser::OperatorNode::OP_NOT: { + case GDScriptParser::OperatorNode::OP_NOT: { txt = "not " + _parser_expr(c_node->arguments[0]); } break; - case GDParser::OperatorNode::OP_BIT_INVERT: { + case GDScriptParser::OperatorNode::OP_BIT_INVERT: { txt = "~" + _parser_expr(c_node->arguments[0]); } break; - case GDParser::OperatorNode::OP_PREINC: { + case GDScriptParser::OperatorNode::OP_PREINC: { } break; - case GDParser::OperatorNode::OP_PREDEC: { + case GDScriptParser::OperatorNode::OP_PREDEC: { } break; - case GDParser::OperatorNode::OP_INC: { + case GDScriptParser::OperatorNode::OP_INC: { } break; - case GDParser::OperatorNode::OP_DEC: { + case GDScriptParser::OperatorNode::OP_DEC: { } break; - case GDParser::OperatorNode::OP_IN: { + case GDScriptParser::OperatorNode::OP_IN: { txt = _parser_expr(c_node->arguments[0]) + " in " + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_EQUAL: { + case GDScriptParser::OperatorNode::OP_EQUAL: { txt = _parser_expr(c_node->arguments[0]) + "==" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_NOT_EQUAL: { + case GDScriptParser::OperatorNode::OP_NOT_EQUAL: { txt = _parser_expr(c_node->arguments[0]) + "!=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_LESS: { + case GDScriptParser::OperatorNode::OP_LESS: { txt = _parser_expr(c_node->arguments[0]) + "<" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_LESS_EQUAL: { + case GDScriptParser::OperatorNode::OP_LESS_EQUAL: { txt = _parser_expr(c_node->arguments[0]) + "<=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_GREATER: { + case GDScriptParser::OperatorNode::OP_GREATER: { txt = _parser_expr(c_node->arguments[0]) + ">" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_GREATER_EQUAL: { + case GDScriptParser::OperatorNode::OP_GREATER_EQUAL: { txt = _parser_expr(c_node->arguments[0]) + ">=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_AND: { + case GDScriptParser::OperatorNode::OP_AND: { txt = _parser_expr(c_node->arguments[0]) + " and " + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_OR: { + case GDScriptParser::OperatorNode::OP_OR: { txt = _parser_expr(c_node->arguments[0]) + " or " + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ADD: { + case GDScriptParser::OperatorNode::OP_ADD: { txt = _parser_expr(c_node->arguments[0]) + "+" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_SUB: { + case GDScriptParser::OperatorNode::OP_SUB: { txt = _parser_expr(c_node->arguments[0]) + "-" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_MUL: { + case GDScriptParser::OperatorNode::OP_MUL: { txt = _parser_expr(c_node->arguments[0]) + "*" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_DIV: { + case GDScriptParser::OperatorNode::OP_DIV: { txt = _parser_expr(c_node->arguments[0]) + "/" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_MOD: { + case GDScriptParser::OperatorNode::OP_MOD: { txt = _parser_expr(c_node->arguments[0]) + "%" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_SHIFT_LEFT: { + case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: { txt = _parser_expr(c_node->arguments[0]) + "<<" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_SHIFT_RIGHT: { + case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: { txt = _parser_expr(c_node->arguments[0]) + ">>" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN: { + case GDScriptParser::OperatorNode::OP_ASSIGN: { txt = _parser_expr(c_node->arguments[0]) + "=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_ADD: { + case GDScriptParser::OperatorNode::OP_ASSIGN_ADD: { txt = _parser_expr(c_node->arguments[0]) + "+=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_SUB: { + case GDScriptParser::OperatorNode::OP_ASSIGN_SUB: { txt = _parser_expr(c_node->arguments[0]) + "-=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_MUL: { + case GDScriptParser::OperatorNode::OP_ASSIGN_MUL: { txt = _parser_expr(c_node->arguments[0]) + "*=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_DIV: { + case GDScriptParser::OperatorNode::OP_ASSIGN_DIV: { txt = _parser_expr(c_node->arguments[0]) + "/=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_MOD: { + case GDScriptParser::OperatorNode::OP_ASSIGN_MOD: { txt = _parser_expr(c_node->arguments[0]) + "%=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: { + case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: { txt = _parser_expr(c_node->arguments[0]) + "<<=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: { + case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: { txt = _parser_expr(c_node->arguments[0]) + ">>=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_BIT_AND: { + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_AND: { txt = _parser_expr(c_node->arguments[0]) + "&=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_BIT_OR: { + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_OR: { txt = _parser_expr(c_node->arguments[0]) + "|=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR: { + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_XOR: { txt = _parser_expr(c_node->arguments[0]) + "^=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_BIT_AND: { + case GDScriptParser::OperatorNode::OP_BIT_AND: { txt = _parser_expr(c_node->arguments[0]) + "&" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_BIT_OR: { + case GDScriptParser::OperatorNode::OP_BIT_OR: { txt = _parser_expr(c_node->arguments[0]) + "|" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_BIT_XOR: { + case GDScriptParser::OperatorNode::OP_BIT_XOR: { txt = _parser_expr(c_node->arguments[0]) + "^" + _parser_expr(c_node->arguments[1]); } break; default: {} } } break; - case GDParser::Node::TYPE_NEWLINE: { + case GDScriptParser::Node::TYPE_NEWLINE: { //skippie } break; @@ -310,20 +310,20 @@ static String _parser_expr(const GDParser::Node *p_expr) { //return "("+txt+")"; } -static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) { +static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_indent) { for (int i = 0; i < p_block->statements.size(); i++) { - const GDParser::Node *statement = p_block->statements[i]; + const GDScriptParser::Node *statement = p_block->statements[i]; switch (statement->type) { - case GDParser::Node::TYPE_CONTROL_FLOW: { + case GDScriptParser::Node::TYPE_CONTROL_FLOW: { - const GDParser::ControlFlowNode *cf_node = static_cast(statement); + const GDScriptParser::ControlFlowNode *cf_node = static_cast(statement); switch (cf_node->cf_type) { - case GDParser::ControlFlowNode::CF_IF: { + case GDScriptParser::ControlFlowNode::CF_IF: { ERR_FAIL_COND(cf_node->arguments.size() != 1); String txt; @@ -339,7 +339,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) } } break; - case GDParser::ControlFlowNode::CF_FOR: { + case GDScriptParser::ControlFlowNode::CF_FOR: { ERR_FAIL_COND(cf_node->arguments.size() != 2); String txt; txt += "for "; @@ -352,7 +352,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) _parser_show_block(cf_node->body, p_indent + 1); } break; - case GDParser::ControlFlowNode::CF_WHILE: { + case GDScriptParser::ControlFlowNode::CF_WHILE: { ERR_FAIL_COND(cf_node->arguments.size() != 1); String txt; @@ -364,18 +364,18 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) _parser_show_block(cf_node->body, p_indent + 1); } break; - case GDParser::ControlFlowNode::CF_SWITCH: { + case GDScriptParser::ControlFlowNode::CF_SWITCH: { } break; - case GDParser::ControlFlowNode::CF_CONTINUE: { + case GDScriptParser::ControlFlowNode::CF_CONTINUE: { _print_indent(p_indent, "continue"); } break; - case GDParser::ControlFlowNode::CF_BREAK: { + case GDScriptParser::ControlFlowNode::CF_BREAK: { _print_indent(p_indent, "break"); } break; - case GDParser::ControlFlowNode::CF_RETURN: { + case GDScriptParser::ControlFlowNode::CF_RETURN: { if (cf_node->arguments.size()) _print_indent(p_indent, "return " + _parser_expr(cf_node->arguments[0])); @@ -385,9 +385,9 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) } } break; - case GDParser::Node::TYPE_LOCAL_VAR: { + case GDScriptParser::Node::TYPE_LOCAL_VAR: { - const GDParser::LocalVarNode *lv_node = static_cast(statement); + const GDScriptParser::LocalVarNode *lv_node = static_cast(statement); _print_indent(p_indent, "var " + String(lv_node->name)); } break; default: { @@ -398,7 +398,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) } } -static void _parser_show_function(const GDParser::FunctionNode *p_func, int p_indent, GDParser::BlockNode *p_initializer = NULL) { +static void _parser_show_function(const GDScriptParser::FunctionNode *p_func, int p_indent, GDScriptParser::BlockNode *p_initializer = NULL) { String txt; if (p_func->_static) @@ -434,7 +434,7 @@ static void _parser_show_function(const GDParser::FunctionNode *p_func, int p_in _parser_show_block(p_func->body, p_indent + 1); } -static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent, const Vector &p_code) { +static void _parser_show_class(const GDScriptParser::ClassNode *p_class, int p_indent, const Vector &p_code) { if (p_indent == 0 && (String(p_class->extends_file) != "" || p_class->extends_class.size())) { @@ -444,7 +444,7 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent, for (int i = 0; i < p_class->subclasses.size(); i++) { - const GDParser::ClassNode *subclass = p_class->subclasses[i]; + const GDScriptParser::ClassNode *subclass = p_class->subclasses[i]; String line = "class " + subclass->name; if (String(subclass->extends_file) != "" || subclass->extends_class.size()) line += " " + _parser_extends(subclass); @@ -456,13 +456,13 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent, for (int i = 0; i < p_class->constant_expressions.size(); i++) { - const GDParser::ClassNode::Constant &constant = p_class->constant_expressions[i]; + const GDScriptParser::ClassNode::Constant &constant = p_class->constant_expressions[i]; _print_indent(p_indent, "const " + String(constant.identifier) + "=" + _parser_expr(constant.expression)); } for (int i = 0; i < p_class->variables.size(); i++) { - const GDParser::ClassNode::Member &m = p_class->variables[i]; + const GDScriptParser::ClassNode::Member &m = p_class->variables[i]; _print_indent(p_indent, "var " + String(m.identifier)); } @@ -487,27 +487,27 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent, print_line("\n"); } -static String _disassemble_addr(const Ref &p_script, const GDFunction &func, int p_addr) { +static String _disassemble_addr(const Ref &p_script, const GDScriptFunction &func, int p_addr) { - int addr = p_addr & GDFunction::ADDR_MASK; + int addr = p_addr & GDScriptFunction::ADDR_MASK; - switch (p_addr >> GDFunction::ADDR_BITS) { + switch (p_addr >> GDScriptFunction::ADDR_BITS) { - case GDFunction::ADDR_TYPE_SELF: { + case GDScriptFunction::ADDR_TYPE_SELF: { return "self"; } break; - case GDFunction::ADDR_TYPE_CLASS: { + case GDScriptFunction::ADDR_TYPE_CLASS: { return "class"; } break; - case GDFunction::ADDR_TYPE_MEMBER: { + case GDScriptFunction::ADDR_TYPE_MEMBER: { return "member(" + p_script->debug_get_member_by_index(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_CLASS_CONSTANT: { + case GDScriptFunction::ADDR_TYPE_CLASS_CONSTANT: { return "class_const(" + func.get_global_name(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_LOCAL_CONSTANT: { + case GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT: { Variant v = func.get_constant(addr); String txt; @@ -517,19 +517,19 @@ static String _disassemble_addr(const Ref &p_script, const GDFunction txt = v; return "const(" + txt + ")"; } break; - case GDFunction::ADDR_TYPE_STACK: { + case GDScriptFunction::ADDR_TYPE_STACK: { return "stack(" + itos(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_STACK_VARIABLE: { + case GDScriptFunction::ADDR_TYPE_STACK_VARIABLE: { return "var_stack(" + itos(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_GLOBAL: { + case GDScriptFunction::ADDR_TYPE_GLOBAL: { return "global(" + func.get_global_name(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_NIL: { + case GDScriptFunction::ADDR_TYPE_NIL: { return "nil"; } break; } @@ -539,11 +539,11 @@ static String _disassemble_addr(const Ref &p_script, const GDFunction static void _disassemble_class(const Ref &p_class, const Vector &p_code) { - const Map &mf = p_class->debug_get_member_functions(); + const Map &mf = p_class->debug_get_member_functions(); - for (const Map::Element *E = mf.front(); E; E = E->next()) { + for (const Map::Element *E = mf.front(); E; E = E->next()) { - const GDFunction &func = *E->get(); + const GDScriptFunction &func = *E->get(); const int *code = func.get_code(); int codelen = func.get_code_size(); String defargs; @@ -568,7 +568,7 @@ static void _disassemble_class(const Ref &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector= 0 && line < p_code.size()) @@ -884,12 +884,12 @@ static void _disassemble_class(const Ref &p_class, const Vectortype != GDParser::Node::TYPE_CLASS, NULL); - const GDParser::ClassNode *cnode = static_cast(root); + const GDScriptParser::Node *root = parser.get_parse_tree(); + ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, NULL); + const GDScriptParser::ClassNode *cnode = static_cast(root); _parser_show_class(cnode, 0, lines); } if (p_type == TEST_COMPILER) { - GDParser parser; + GDScriptParser parser; Error err = parser.parse(code); if (err) { @@ -1023,7 +1023,7 @@ MainLoop *test(TestType p_type) { GDScript *script = memnew(GDScript); - GDCompiler gdc; + GDScriptCompiler gdc; err = gdc.compile(&parser, script); if (err) { @@ -1046,7 +1046,7 @@ MainLoop *test(TestType p_type) { } else if (p_type == TEST_BYTECODE) { - Vector buf = GDTokenizerBuffer::parse_code_string(code); + Vector buf = GDScriptTokenizerBuffer::parse_code_string(code); String dst = test.get_basename() + ".gdc"; FileAccess *fw = FileAccess::open(dst, FileAccess::WRITE); fw->store_buffer(buf.ptr(), buf.size()); diff --git a/modules/gdscript/config.py b/modules/gdscript/config.py index 6e8994d6433..6496b59d756 100644 --- a/modules/gdscript/config.py +++ b/modules/gdscript/config.py @@ -6,9 +6,9 @@ def configure(env): def get_doc_classes(): return [ - "GDFunctionState", - "GDNativeClass", "GDScript", + "GDScriptFunctionState", + "GDScriptNativeClass", ] def get_doc_path(): diff --git a/modules/gdscript/doc_classes/GDFunctionState.xml b/modules/gdscript/doc_classes/GDScriptFunctionState.xml similarity index 84% rename from modules/gdscript/doc_classes/GDFunctionState.xml rename to modules/gdscript/doc_classes/GDScriptFunctionState.xml index e1aafa8a5bb..2df4e7c217e 100644 --- a/modules/gdscript/doc_classes/GDFunctionState.xml +++ b/modules/gdscript/doc_classes/GDScriptFunctionState.xml @@ -1,5 +1,5 @@ - + State of a function call after yielding. @@ -18,7 +18,7 @@ Check whether the function call may be resumed. This is not the case if the function state was already resumed. - If [code]extended_check[/code] is enabled, it also checks if the associated script and object still exist. The extended check is done in debug mode as part of [method GDFunctionState.resume], but you can use this if you know you may be trying to resume without knowing for sure the object and/or script have survived up to that point. + If [code]extended_check[/code] is enabled, it also checks if the associated script and object still exist. The extended check is done in debug mode as part of [method GDScriptFunctionState.resume], but you can use this if you know you may be trying to resume without knowing for sure the object and/or script have survived up to that point. diff --git a/modules/gdscript/doc_classes/GDNativeClass.xml b/modules/gdscript/doc_classes/GDScriptNativeClass.xml similarity index 78% rename from modules/gdscript/doc_classes/GDNativeClass.xml rename to modules/gdscript/doc_classes/GDScriptNativeClass.xml index 95789e1b630..4514a784694 100644 --- a/modules/gdscript/doc_classes/GDNativeClass.xml +++ b/modules/gdscript/doc_classes/GDScriptNativeClass.xml @@ -1,5 +1,5 @@ - + diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gdscript.cpp similarity index 89% rename from modules/gdscript/gd_script.cpp rename to modules/gdscript/gdscript.cpp index e5d834c9e75..55ea8a5f248 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_script.cpp */ +/* gdscript.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,10 +27,10 @@ /* 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 "gdscript.h" #include "engine.h" -#include "gd_compiler.h" +#include "gdscript_compiler.h" #include "global_constants.h" #include "io/file_access_encrypted.h" #include "os/file_access.h" @@ -39,12 +39,12 @@ /////////////////////////// -GDNativeClass::GDNativeClass(const StringName &p_name) { +GDScriptNativeClass::GDScriptNativeClass(const StringName &p_name) { name = p_name; } -bool GDNativeClass::_get(const StringName &p_name, Variant &r_ret) const { +bool GDScriptNativeClass::_get(const StringName &p_name, Variant &r_ret) const { bool ok; int v = ClassDB::get_integer_constant(name, p_name, &ok); @@ -57,12 +57,12 @@ bool GDNativeClass::_get(const StringName &p_name, Variant &r_ret) const { } } -void GDNativeClass::_bind_methods() { +void GDScriptNativeClass::_bind_methods() { - ClassDB::bind_method(D_METHOD("new"), &GDNativeClass::_new); + ClassDB::bind_method(D_METHOD("new"), &GDScriptNativeClass::_new); } -Variant GDNativeClass::_new() { +Variant GDScriptNativeClass::_new() { Object *o = instance(); if (!o) { @@ -78,16 +78,16 @@ Variant GDNativeClass::_new() { } } -Object *GDNativeClass::instance() { +Object *GDScriptNativeClass::instance() { return ClassDB::instance(name); } -GDInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error) { +GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error) { /* STEP 1, CREATE */ - GDInstance *instance = memnew(GDInstance); + GDScriptInstance *instance = memnew(GDScriptInstance); instance->base_ref = p_isref; instance->members.resize(member_indices.size()); instance->script = Ref(this); @@ -163,7 +163,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro ref = REF(r); } - GDInstance *instance = _create_instance(p_args, p_argcount, owner, r != NULL, r_error); + GDScriptInstance *instance = _create_instance(p_args, p_argcount, owner, r != NULL, r_error); if (!instance) { if (ref.is_null()) { memdelete(owner); //no owner, sorry @@ -218,7 +218,7 @@ void GDScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) { void GDScript::get_script_method_list(List *p_list) const { - for (const Map::Element *E = member_functions.front(); E; E = E->next()) { + for (const Map::Element *E = member_functions.front(); E; E = E->next()) { MethodInfo mi; mi.name = E->key(); for (int i = 0; i < E->get()->get_argument_count(); i++) { @@ -272,7 +272,7 @@ bool GDScript::has_method(const StringName &p_method) const { MethodInfo GDScript::get_method_info(const StringName &p_method) const { - const Map::Element *E = member_functions.find(p_method); + const Map::Element *E = member_functions.find(p_method); if (!E) return MethodInfo(); @@ -420,15 +420,15 @@ bool GDScript::_update_exports() { if (basedir != "") basedir = basedir.get_base_dir(); - GDParser parser; + GDScriptParser parser; Error err = parser.parse(source, basedir, true, path); if (err == OK) { - const GDParser::Node *root = parser.get_parse_tree(); - ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, false); + const GDScriptParser::Node *root = parser.get_parse_tree(); + ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, false); - const GDParser::ClassNode *c = static_cast(root); + const GDScriptParser::ClassNode *c = static_cast(root); if (base_cache.is_valid()) { base_cache->inheriters_cache.erase(get_instance_id()); @@ -572,7 +572,7 @@ Error GDScript::reload(bool p_keep_state) { } valid = false; - GDParser parser; + GDScriptParser parser; Error err = parser.parse(source, basedir, false, path); if (err) { if (ScriptDebugger::get_singleton()) { @@ -584,7 +584,7 @@ Error GDScript::reload(bool p_keep_state) { bool can_run = ScriptServer::is_scripting_enabled() || parser.is_tool_script(); - GDCompiler compiler; + GDScriptCompiler compiler; err = compiler.compile(&parser, this, p_keep_state); if (err) { @@ -620,7 +620,7 @@ Variant GDScript::call(const StringName &p_method, const Variant **p_args, int p GDScript *top = this; while (top) { - Map::Element *E = top->member_functions.find(p_method); + Map::Element *E = top->member_functions.find(p_method); if (E) { if (!E->get()->is_static()) { @@ -699,7 +699,7 @@ void GDScript::_bind_methods() { Vector GDScript::get_as_byte_code() const { - GDTokenizerBuffer tokenizer; + GDScriptTokenizerBuffer tokenizer; return tokenizer.parse_code_string(source); }; @@ -739,14 +739,14 @@ Error GDScript::load_byte_code(const String &p_path) { basedir = basedir.get_base_dir(); valid = false; - GDParser parser; + GDScriptParser parser; Error err = parser.parse_bytecode(bytecode, basedir, get_path()); if (err) { _err_print_error("GDScript::load_byte_code", path.empty() ? "built-in" : (const char *)path.utf8().get_data(), parser.get_error_line(), ("Parse Error: " + parser.get_error()).utf8().get_data(), ERR_HANDLER_SCRIPT); ERR_FAIL_V(ERR_PARSE_ERROR); } - GDCompiler compiler; + GDScriptCompiler compiler; err = compiler.compile(&parser, this); if (err) { @@ -799,7 +799,7 @@ Error GDScript::load_source_code(const String &p_path) { return OK; } -const Map &GDScript::debug_get_member_functions() const { +const Map &GDScript::debug_get_member_functions() const { return member_functions; } @@ -886,7 +886,7 @@ GDScript::GDScript() } GDScript::~GDScript() { - for (Map::Element *E = member_functions.front(); E; E = E->next()) { + for (Map::Element *E = member_functions.front(); E; E = E->next()) { memdelete(E->get()); } @@ -910,7 +910,7 @@ GDScript::~GDScript() { // INSTANCE // ////////////////////////////// -bool GDInstance::set(const StringName &p_name, const Variant &p_value) { +bool GDScriptInstance::set(const StringName &p_name, const Variant &p_value) { //member { @@ -932,7 +932,7 @@ bool GDInstance::set(const StringName &p_name, const Variant &p_value) { GDScript *sptr = script.ptr(); while (sptr) { - Map::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._set); + Map::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._set); if (E) { Variant name = p_name; @@ -949,7 +949,7 @@ bool GDInstance::set(const StringName &p_name, const Variant &p_value) { return false; } -bool GDInstance::get(const StringName &p_name, Variant &r_ret) const { +bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const { const GDScript *sptr = script.ptr(); while (sptr) { @@ -959,7 +959,7 @@ bool GDInstance::get(const StringName &p_name, Variant &r_ret) const { if (E) { if (E->get().getter) { Variant::CallError err; - r_ret = const_cast(this)->call(E->get().getter, NULL, 0, err); + r_ret = const_cast(this)->call(E->get().getter, NULL, 0, err); if (err.error == Variant::CallError::CALL_OK) { return true; } @@ -983,14 +983,14 @@ bool GDInstance::get(const StringName &p_name, Variant &r_ret) const { } { - const Map::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get); + const Map::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get); if (E) { Variant name = p_name; const Variant *args[1] = { &name }; Variant::CallError err; - Variant ret = const_cast(E->get())->call(const_cast(this), (const Variant **)args, 1, err); + Variant ret = const_cast(E->get())->call(const_cast(this), (const Variant **)args, 1, err); if (err.error == Variant::CallError::CALL_OK && ret.get_type() != Variant::NIL) { r_ret = ret; return true; @@ -1003,7 +1003,7 @@ bool GDInstance::get(const StringName &p_name, Variant &r_ret) const { return false; } -Variant::Type GDInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const { +Variant::Type GDScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const { const GDScript *sptr = script.ptr(); while (sptr) { @@ -1021,7 +1021,7 @@ Variant::Type GDInstance::get_property_type(const StringName &p_name, bool *r_is return Variant::NIL; } -void GDInstance::get_property_list(List *p_properties) const { +void GDScriptInstance::get_property_list(List *p_properties) const { // exported members, not doen yet! const GDScript *sptr = script.ptr(); @@ -1029,11 +1029,11 @@ void GDInstance::get_property_list(List *p_properties) const { while (sptr) { - const Map::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list); + const Map::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list); if (E) { Variant::CallError err; - Variant ret = const_cast(E->get())->call(const_cast(this), NULL, 0, err); + Variant ret = const_cast(E->get())->call(const_cast(this), NULL, 0, err); if (err.error == Variant::CallError::CALL_OK) { if (ret.get_type() != Variant::ARRAY) { @@ -1092,12 +1092,12 @@ void GDInstance::get_property_list(List *p_properties) const { } } -void GDInstance::get_method_list(List *p_list) const { +void GDScriptInstance::get_method_list(List *p_list) const { const GDScript *sptr = script.ptr(); while (sptr) { - for (Map::Element *E = sptr->member_functions.front(); E; E = E->next()) { + for (Map::Element *E = sptr->member_functions.front(); E; E = E->next()) { MethodInfo mi; mi.name = E->key(); @@ -1110,11 +1110,11 @@ void GDInstance::get_method_list(List *p_list) const { } } -bool GDInstance::has_method(const StringName &p_method) const { +bool GDScriptInstance::has_method(const StringName &p_method) const { const GDScript *sptr = script.ptr(); while (sptr) { - const Map::Element *E = sptr->member_functions.find(p_method); + const Map::Element *E = sptr->member_functions.find(p_method); if (E) return true; sptr = sptr->_base; @@ -1122,13 +1122,13 @@ bool GDInstance::has_method(const StringName &p_method) const { return false; } -Variant GDInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) { +Variant GDScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) { //printf("calling %ls:%i method %ls\n", script->get_path().c_str(), -1, String(p_method).c_str()); GDScript *sptr = script.ptr(); while (sptr) { - Map::Element *E = sptr->member_functions.find(p_method); + Map::Element *E = sptr->member_functions.find(p_method); if (E) { return E->get()->call(this, p_args, p_argcount, r_error); } @@ -1138,13 +1138,13 @@ Variant GDInstance::call(const StringName &p_method, const Variant **p_args, int return Variant(); } -void GDInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) { +void GDScriptInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) { GDScript *sptr = script.ptr(); Variant::CallError ce; while (sptr) { - Map::Element *E = sptr->member_functions.find(p_method); + Map::Element *E = sptr->member_functions.find(p_method); if (E) { E->get()->call(this, p_args, p_argcount, ce); } @@ -1152,27 +1152,27 @@ void GDInstance::call_multilevel(const StringName &p_method, const Variant **p_a } } -void GDInstance::_ml_call_reversed(GDScript *sptr, const StringName &p_method, const Variant **p_args, int p_argcount) { +void GDScriptInstance::_ml_call_reversed(GDScript *sptr, const StringName &p_method, const Variant **p_args, int p_argcount) { if (sptr->_base) _ml_call_reversed(sptr->_base, p_method, p_args, p_argcount); Variant::CallError ce; - Map::Element *E = sptr->member_functions.find(p_method); + Map::Element *E = sptr->member_functions.find(p_method); if (E) { E->get()->call(this, p_args, p_argcount, ce); } } -void GDInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) { +void GDScriptInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) { if (script.ptr()) { _ml_call_reversed(script.ptr(), p_method, p_args, p_argcount); } } -void GDInstance::notification(int p_notification) { +void GDScriptInstance::notification(int p_notification) { //notification is not virtual, it gets called at ALL levels just like in C. Variant value = p_notification; @@ -1180,7 +1180,7 @@ void GDInstance::notification(int p_notification) { GDScript *sptr = script.ptr(); while (sptr) { - Map::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._notification); + Map::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._notification); if (E) { Variant::CallError err; E->get()->call(this, args, 1, err); @@ -1192,22 +1192,22 @@ void GDInstance::notification(int p_notification) { } } -Ref