1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

GDScript: Refactor builtin functions

They are now called "utility functions" to avoid confusion with methods
of builtin types, and be consistent with the naming in Variant.

Core utility functions are now available in GDScript. The ones missing
in core are added specifically to GDScript as helpers for convenience.

Some functions were remove when there are better ways to do, reducing
redundancy and cleaning up the global scope.
This commit is contained in:
George Marques
2020-11-26 11:56:32 -03:00
parent 613b76cfd5
commit c7b6a7adcc
17 changed files with 1085 additions and 2116 deletions

View File

@@ -34,7 +34,6 @@
#include "core/string/string_builder.h"
#include "gdscript.h"
#include "gdscript_functions.h"
static String _get_variant_string(const Variant &p_variant) {
String txt;
@@ -610,13 +609,49 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
incr = 5 + argc;
} break;
case OPCODE_CALL_BUILT_IN: {
text += "call-built-in ";
case OPCODE_CALL_UTILITY: {
text += "call-utility ";
int argc = _code_ptr[ip + 1 + instr_var_args];
text += DADDR(1 + argc) + " = ";
text += GDScriptFunctions::get_func_name(GDScriptFunctions::Function(_code_ptr[ip + 2 + instr_var_args]));
text += _global_names_ptr[_code_ptr[ip + 2 + instr_var_args]];
text += "(";
for (int i = 0; i < argc; i++) {
if (i > 0)
text += ", ";
text += DADDR(1 + i);
}
text += ")";
incr = 4 + argc;
} break;
case OPCODE_CALL_UTILITY_VALIDATED: {
text += "call-utility ";
int argc = _code_ptr[ip + 1 + instr_var_args];
text += DADDR(1 + argc) + " = ";
text += "<unkown function>";
text += "(";
for (int i = 0; i < argc; i++) {
if (i > 0)
text += ", ";
text += DADDR(1 + i);
}
text += ")";
incr = 4 + argc;
} break;
case OPCODE_CALL_GDSCRIPT_UTILITY: {
text += "call-gscript-utility ";
int argc = _code_ptr[ip + 1 + instr_var_args];
text += DADDR(1 + argc) + " = ";
text += "<unknown function>";
text += "(";
for (int i = 0; i < argc; i++) {