Memoise a value during Lua lib function enumeration
This commit is contained in:
parent
ea810cb89b
commit
89e94be8c1
|
@ -37,6 +37,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
void EnumerateLuaFunctions(string name, Type type, LuaLibraryBase instance)
|
void EnumerateLuaFunctions(string name, Type type, LuaLibraryBase instance)
|
||||||
{
|
{
|
||||||
|
var libraryDesc = type.GetCustomAttributes(typeof(DescriptionAttribute), false).Cast<DescriptionAttribute>()
|
||||||
|
.Select(static descAttr => descAttr.Description)
|
||||||
|
.FirstOrDefault() ?? string.Empty;
|
||||||
if (instance != null) _lua.NewTable(name);
|
if (instance != null) _lua.NewTable(name);
|
||||||
foreach (var method in type.GetMethods())
|
foreach (var method in type.GetMethods())
|
||||||
{
|
{
|
||||||
|
@ -44,9 +47,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (foundAttrs.Length == 0) continue;
|
if (foundAttrs.Length == 0) continue;
|
||||||
if (instance != null) _lua.RegisterFunction($"{name}.{((LuaMethodAttribute)foundAttrs[0]).Name}", instance, method);
|
if (instance != null) _lua.RegisterFunction($"{name}.{((LuaMethodAttribute)foundAttrs[0]).Name}", instance, method);
|
||||||
LibraryFunction libFunc = new(
|
LibraryFunction libFunc = new(
|
||||||
name,
|
library: name,
|
||||||
type.GetCustomAttributes(typeof(DescriptionAttribute), false).Cast<DescriptionAttribute>()
|
libraryDescription: libraryDesc,
|
||||||
.Select(descAttr => descAttr.Description).FirstOrDefault() ?? string.Empty,
|
|
||||||
method,
|
method,
|
||||||
suggestInREPL: false
|
suggestInREPL: false
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue