Simplify Lua lib ctors
This commit is contained in:
parent
a4e2e1ad3f
commit
f5752294ff
|
@ -13,9 +13,6 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
private readonly IDictionary<Guid, ClientWebSocketWrapper> _websockets = new Dictionary<Guid, ClientWebSocketWrapper>();
|
||||
|
||||
public CommLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public CommLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -13,9 +13,6 @@ namespace BizHawk.Client.Common
|
|||
public Action FrameAdvanceCallback { get; set; }
|
||||
public Action YieldCallback { get; set; }
|
||||
|
||||
public EmulationLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public EmulationLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -7,9 +7,6 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public sealed class GameInfoLuaLibrary : DelegatingLuaLibrary
|
||||
{
|
||||
public GameInfoLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public GameInfoLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -9,9 +9,6 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public Func<int, int, int?, int?, LuaTable> CreateLuaCanvasCallback { get; set; }
|
||||
|
||||
public GuiLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public GuiLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -6,9 +6,6 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public sealed class InputLuaLibrary : DelegatingLuaLibrary
|
||||
{
|
||||
public InputLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public InputLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -8,9 +8,6 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public sealed class JoypadLuaLibrary : DelegatingLuaLibrary
|
||||
{
|
||||
public JoypadLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public JoypadLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -9,11 +9,6 @@ namespace BizHawk.Client.Common
|
|||
[Description("These functions behavior identically to the mainmemory functions but the user can set the memory domain to read and write from. The default domain is the system bus. Use getcurrentmemorydomain(), and usememorydomain() to control which domain is used. Each core has its own set of valid memory domains. Use getmemorydomainlist() to get a list of memory domains for the current core loaded.")]
|
||||
public sealed class MemoryLuaLibrary : DelegatingLuaLibrary
|
||||
{
|
||||
public MemoryLuaLibrary(Lua lua)
|
||||
: base(lua)
|
||||
{
|
||||
}
|
||||
|
||||
public MemoryLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback)
|
||||
{
|
||||
|
|
|
@ -7,9 +7,6 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public sealed class MemorySavestateLuaLibrary : DelegatingLuaLibrary
|
||||
{
|
||||
public MemorySavestateLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public MemorySavestateLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -7,9 +7,6 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public sealed class MovieLuaLibrary : DelegatingLuaLibrary
|
||||
{
|
||||
public MovieLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public MovieLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -10,9 +10,6 @@ namespace BizHawk.Client.Common
|
|||
[Description("A library for performing SQLite operations.")]
|
||||
public sealed class SQLiteLuaLibrary : DelegatingLuaLibrary
|
||||
{
|
||||
public SQLiteLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public SQLiteLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -8,9 +8,6 @@ namespace BizHawk.Client.Common
|
|||
[Description("A library for setting and retrieving dynamic data that will be saved and loaded with savestates")]
|
||||
public sealed class UserDataLuaLibrary : DelegatingLuaLibrary
|
||||
{
|
||||
public UserDataLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public UserDataLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@ namespace BizHawk.Client.Common
|
|||
/// <summary>Extends <see cref="LuaLibraryBase"/> by including an <see cref="ApiContainer"/> for the library to delegate its calls through.</summary>
|
||||
public abstract class DelegatingLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
protected DelegatingLuaLibrary(Lua lua) : base(lua) {}
|
||||
|
||||
protected DelegatingLuaLibrary(Lua lua, Action<string> logOutputCallback) : base(lua, logOutputCallback) {}
|
||||
|
||||
public ApiContainer APIs { protected get; set; }
|
||||
|
|
|
@ -9,9 +9,6 @@ namespace BizHawk.Client.Common
|
|||
[Description("A library for performing standard bitwise operations.")]
|
||||
public sealed class BitLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
public BitLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public BitLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -24,9 +24,6 @@ namespace BizHawk.Client.Common
|
|||
[OptionalService]
|
||||
private IMemoryDomains Domains { get; set; }
|
||||
|
||||
public EventsLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public EventsLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -11,9 +11,6 @@ namespace BizHawk.Client.Common
|
|||
[Description("Functions specific to GenesisHawk (functions may not run when an Genesis game is not loaded)")]
|
||||
public sealed class GenesisLuaLibrary : DelegatingLuaLibrary
|
||||
{
|
||||
public GenesisLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public GenesisLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -17,9 +17,6 @@ namespace BizHawk.Client.Common
|
|||
[OptionalService]
|
||||
private IMemoryDomains MemoryDomainCore { get; set; }
|
||||
|
||||
public MainMemoryLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public MainMemoryLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -21,9 +21,6 @@ namespace BizHawk.Client.Common
|
|||
[OptionalService]
|
||||
private IMemoryDomains MemoryDomains { get; set; }
|
||||
|
||||
public NESLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public NESLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -10,9 +10,6 @@ namespace BizHawk.Client.Common
|
|||
[Description("Functions specific to SNESHawk (functions may not run when an SNES game is not loaded)")]
|
||||
public sealed class SNESLuaLibrary : DelegatingLuaLibrary
|
||||
{
|
||||
public SNESLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public SNESLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -11,9 +11,6 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public override string Name => "bizstring";
|
||||
|
||||
public StringLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public StringLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -8,15 +8,10 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public abstract class LuaLibraryBase
|
||||
{
|
||||
protected LuaLibraryBase(Lua lua)
|
||||
{
|
||||
Lua = lua;
|
||||
}
|
||||
|
||||
protected LuaLibraryBase(Lua lua, Action<string> logOutputCallback)
|
||||
: this(lua)
|
||||
{
|
||||
LogOutputCallback = logOutputCallback;
|
||||
Lua = lua;
|
||||
}
|
||||
|
||||
protected static LuaFile CurrentFile { get; private set; }
|
||||
|
@ -25,7 +20,9 @@ namespace BizHawk.Client.Common
|
|||
private static readonly object ThreadMutex = new object();
|
||||
|
||||
public abstract string Name { get; }
|
||||
public Action<string> LogOutputCallback { protected get; set; }
|
||||
|
||||
protected readonly Action<string> LogOutputCallback;
|
||||
|
||||
public Lua Lua { get; }
|
||||
|
||||
public static void ClearCurrentThread()
|
||||
|
|
|
@ -27,9 +27,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public IMainFormForApi MainForm { get; set; }
|
||||
|
||||
public ClientLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public ClientLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -9,9 +9,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public sealed class ConsoleLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
public ConsoleLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public ConsoleLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -14,9 +14,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
[Description("A library for creating and managing custom dialogs")]
|
||||
public sealed class FormsLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
public FormsLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public FormsLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -8,9 +8,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public sealed class SaveStateLuaLibrary : DelegatingLuaLibrary
|
||||
{
|
||||
public SaveStateLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public SaveStateLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -16,9 +16,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
[LuaLibrary(released: true)]
|
||||
public sealed class TAStudioLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
public TAStudioLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public TAStudioLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
|
|
|
@ -57,8 +57,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (addLibrary)
|
||||
{
|
||||
var instance = (LuaLibraryBase)Activator.CreateInstance(lib, _lua);
|
||||
instance.LogOutputCallback = ConsoleLuaLibrary.LogOutput;
|
||||
var instance = (LuaLibraryBase) Activator.CreateInstance(lib, _lua, (Action<string>) ConsoleLuaLibrary.LogOutput);
|
||||
ServiceInjector.UpdateServices(serviceProvider, instance);
|
||||
|
||||
// TODO: make EmuHawk libraries have a base class with common properties such as this
|
||||
|
|
Loading…
Reference in New Issue