Merge pull request #18966 from chanon/new-debug-print

Add new debug print method that shows line number where the print came from
This commit is contained in:
Max Hilbrunner 2018-07-04 23:50:45 +02:00 committed by GitHub
commit d988d188ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View file

@ -105,6 +105,7 @@ const char *GDScriptFunctions::get_func_name(Function p_func) {
"prints",
"printerr",
"printraw",
"print_debug",
"var2str",
"str2var",
"var2bytes",
@ -702,6 +703,23 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
r_ret = Variant();
} break;
case TEXT_PRINT_DEBUG: {
String str;
for (int i = 0; i < p_arg_count; i++) {
str += p_args[i]->operator String();
}
ScriptLanguage *script = GDScriptLanguage::get_singleton();
if (script->debug_get_stack_level_count() > 0) {
str += "\n\t";
str += "At: " + script->debug_get_stack_level_source(0) + ":" + itos(script->debug_get_stack_level_line(0)); // + " in function '" + script->debug_get_stack_level_function(0) + "'";
}
//str+="\n";
print_line(str);
r_ret = Variant();
} break;
case VAR_TO_STR: {
VALIDATE_ARG_COUNT(1);
String vars;
@ -1732,6 +1750,14 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case TEXT_PRINT_DEBUG: {
MethodInfo mi("print_debug");
mi.return_val.type = Variant::NIL;
mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case VAR_TO_STR: {
MethodInfo mi("var2str", PropertyInfo(Variant::NIL, "var"));

View file

@ -96,6 +96,7 @@ public:
TEXT_PRINT_SPACED,
TEXT_PRINTERR,
TEXT_PRINTRAW,
TEXT_PRINT_DEBUG,
VAR_TO_STR,
STR_TO_VAR,
VAR_TO_BYTES,