Skip to content
Snippets Groups Projects
Verified Commit 1182c59a authored by Petr Špaček's avatar Petr Špaček
Browse files

table_print: do not run hook for C functions

It would be pointless anyway as it cannot provide more information.
parent e44a31a2
Branches
Tags
1 merge request!801Table print improvements
......@@ -370,6 +370,11 @@ local function funcsign(f)
-- thanks to AnandA777 from StackOverflow! Function funcsign is adapted version of
-- https://stackoverflow.com/questions/51095022/inspect-function-signature-in-lua-5-1
assert(type(f) == 'function', "bad argument #1 to 'funcsign' (function expected)")
local debuginfo = debug.getinfo(f)
if debuginfo.what == 'C' then -- names N/A
return '(?)'
end
local func_args = {}
pcall(function()
local oldhook
......@@ -378,14 +383,11 @@ local function funcsign(f)
delay = delay - 1
if delay == 0 then -- call this only for the introspected function
-- stack depth 2 is the introspected function
local debuginfo = debug.getinfo(2)
for i = 1, debuginfo.nparams do
local k = debug.getlocal(2, i)
table.insert(func_args, k)
end
if debuginfo.what == 'C' then -- names N/A
table.insert(func_args, '?')
elseif debuginfo.isvararg then
if debuginfo.isvararg then
table.insert(func_args, "...")
end
debug.sethook(oldhook)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment