From e69cab3297dd98a9c008900adca96451d0b17023 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Thu, 3 Dec 2020 22:15:07 +1000 Subject: [PATCH] Cleanup Win32LuaLibraries init --- .../tools/Lua/Win32LuaLibraries.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/Win32LuaLibraries.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/Win32LuaLibraries.cs index bca3dfb0f4..c99c92d807 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/Win32LuaLibraries.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/Win32LuaLibraries.cs @@ -14,11 +14,6 @@ namespace BizHawk.Client.EmuHawk { public class Win32LuaLibraries : LuaLibraries { - public Win32LuaLibraries() - { - if (true /*NLua.Lua.WhichLua == "NLua"*/) _lua["keepalives"] = _lua.NewTable(); - } - public Win32LuaLibraries( IEmulatorServiceProvider serviceProvider, MainForm mainForm, @@ -26,17 +21,16 @@ namespace BizHawk.Client.EmuHawk InputManager inputManager, Config config, IEmulator emulator, - IGameInfo game - ) : this() + IGameInfo game) { void EnumerateLuaFunctions(string name, Type type, LuaLibraryBase instance) { - instance?.Lua?.NewTable(name); + if (instance != null) _lua.NewTable(name); foreach (var method in type.GetMethods()) { var foundAttrs = method.GetCustomAttributes(typeof(LuaMethodAttribute), false); if (foundAttrs.Length == 0) continue; - instance?.Lua?.RegisterFunction($"{name}.{((LuaMethodAttribute) foundAttrs[0]).Name}", instance, method); + if (instance != null) _lua.RegisterFunction($"{name}.{((LuaMethodAttribute) foundAttrs[0]).Name}", instance, method); Docs.Add(new LibraryFunction( name, type.GetCustomAttributes(typeof(DescriptionAttribute), false).Cast() @@ -46,6 +40,7 @@ namespace BizHawk.Client.EmuHawk } } + if (true /*NLua.Lua.WhichLua == "NLua"*/) _lua["keepalives"] = _lua.NewTable(); _mainForm = mainForm; LuaWait = new AutoResetEvent(false); Docs.Clear();