fixed typo in class auto-generation and included call site in auto-generated class name (id often useless)

This commit is contained in:
Max Cahill 2024-04-26 14:14:36 +10:00
parent 9597861822
commit db5351e898

View File

@ -64,7 +64,17 @@ local function class(config)
config = config or {}
local extends = config.extends
local implements = config.implements
local name = config.name or ("unnamed class %d)"):format(class_id)
local src_location = "call location not available"
if debug and debug.getinfo then
local dinfo = debug.getinfo(2)
local src = dinfo.short_src
local line = dinfo.currentline
src_location = ("%s:%d"):format(src, line)
end
local name = config.name or ("unnamed class %d (%s)"):format(
class_id,
src_location
)
local c = {}