Merge pull request #18976 from chanon/new-get-stack
Add new get_stack function to get GDScript stack trace as array
This commit is contained in:
commit
5885e1c6dd
2 changed files with 23 additions and 0 deletions
|
@ -120,6 +120,7 @@ const char *GDScriptFunctions::get_func_name(Function p_func) {
|
||||||
"Color8",
|
"Color8",
|
||||||
"ColorN",
|
"ColorN",
|
||||||
"print_stack",
|
"print_stack",
|
||||||
|
"get_stack",
|
||||||
"instance_from_id",
|
"instance_from_id",
|
||||||
"len",
|
"len",
|
||||||
"is_instance_valid",
|
"is_instance_valid",
|
||||||
|
@ -1213,6 +1214,22 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
||||||
};
|
};
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case GET_STACK: {
|
||||||
|
VALIDATE_ARG_COUNT(0);
|
||||||
|
|
||||||
|
ScriptLanguage *script = GDScriptLanguage::get_singleton();
|
||||||
|
Array ret;
|
||||||
|
for (int i = 0; i < script->debug_get_stack_level_count(); i++) {
|
||||||
|
|
||||||
|
Dictionary frame;
|
||||||
|
frame["source"] = script->debug_get_stack_level_source(i);
|
||||||
|
frame["function"] = script->debug_get_stack_level_function(i);
|
||||||
|
frame["line"] = script->debug_get_stack_level_line(i);
|
||||||
|
ret.push_back(frame);
|
||||||
|
};
|
||||||
|
r_ret = ret;
|
||||||
|
} break;
|
||||||
|
|
||||||
case INSTANCE_FROM_ID: {
|
case INSTANCE_FROM_ID: {
|
||||||
|
|
||||||
VALIDATE_ARG_COUNT(1);
|
VALIDATE_ARG_COUNT(1);
|
||||||
|
@ -1813,6 +1830,11 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
|
||||||
mi.return_val.type = Variant::NIL;
|
mi.return_val.type = Variant::NIL;
|
||||||
return mi;
|
return mi;
|
||||||
} break;
|
} break;
|
||||||
|
case GET_STACK: {
|
||||||
|
MethodInfo mi("get_stack");
|
||||||
|
mi.return_val.type = Variant::NIL;
|
||||||
|
return mi;
|
||||||
|
} break;
|
||||||
|
|
||||||
case INSTANCE_FROM_ID: {
|
case INSTANCE_FROM_ID: {
|
||||||
MethodInfo mi("instance_from_id", PropertyInfo(Variant::INT, "instance_id"));
|
MethodInfo mi("instance_from_id", PropertyInfo(Variant::INT, "instance_id"));
|
||||||
|
|
|
@ -111,6 +111,7 @@ public:
|
||||||
COLOR8,
|
COLOR8,
|
||||||
COLORN,
|
COLORN,
|
||||||
PRINT_STACK,
|
PRINT_STACK,
|
||||||
|
GET_STACK,
|
||||||
INSTANCE_FROM_ID,
|
INSTANCE_FROM_ID,
|
||||||
LEN,
|
LEN,
|
||||||
IS_INSTANCE_VALID,
|
IS_INSTANCE_VALID,
|
||||||
|
|
Loading…
Add table
Reference in a new issue