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:
commit
d988d188ad
2 changed files with 27 additions and 0 deletions
|
@ -105,6 +105,7 @@ const char *GDScriptFunctions::get_func_name(Function p_func) {
|
||||||
"prints",
|
"prints",
|
||||||
"printerr",
|
"printerr",
|
||||||
"printraw",
|
"printraw",
|
||||||
|
"print_debug",
|
||||||
"var2str",
|
"var2str",
|
||||||
"str2var",
|
"str2var",
|
||||||
"var2bytes",
|
"var2bytes",
|
||||||
|
@ -702,6 +703,23 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
||||||
r_ret = Variant();
|
r_ret = Variant();
|
||||||
|
|
||||||
} break;
|
} 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: {
|
case VAR_TO_STR: {
|
||||||
VALIDATE_ARG_COUNT(1);
|
VALIDATE_ARG_COUNT(1);
|
||||||
String vars;
|
String vars;
|
||||||
|
@ -1732,6 +1750,14 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
|
||||||
mi.flags |= METHOD_FLAG_VARARG;
|
mi.flags |= METHOD_FLAG_VARARG;
|
||||||
return mi;
|
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;
|
} break;
|
||||||
case VAR_TO_STR: {
|
case VAR_TO_STR: {
|
||||||
MethodInfo mi("var2str", PropertyInfo(Variant::NIL, "var"));
|
MethodInfo mi("var2str", PropertyInfo(Variant::NIL, "var"));
|
||||||
|
|
|
@ -96,6 +96,7 @@ public:
|
||||||
TEXT_PRINT_SPACED,
|
TEXT_PRINT_SPACED,
|
||||||
TEXT_PRINTERR,
|
TEXT_PRINTERR,
|
||||||
TEXT_PRINTRAW,
|
TEXT_PRINTRAW,
|
||||||
|
TEXT_PRINT_DEBUG,
|
||||||
VAR_TO_STR,
|
VAR_TO_STR,
|
||||||
STR_TO_VAR,
|
STR_TO_VAR,
|
||||||
VAR_TO_BYTES,
|
VAR_TO_BYTES,
|
||||||
|
|
Loading…
Reference in a new issue