Lua - add a Log callback to the LuaLibraryBase class instead of having misc libraries have to build out this behavior when they need it
This commit is contained in:
parent
94b9761b31
commit
f19d15d1ed
|
@ -16,19 +16,10 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public override string Name { get { return "event"; } }
|
public override string Name { get { return "event"; } }
|
||||||
|
|
||||||
public Action<object> LogOutputCallback { get; set; }
|
|
||||||
public Lua CurrentThread { get; set; }
|
public Lua CurrentThread { get; set; }
|
||||||
|
|
||||||
#region Events Library Helpers
|
#region Events Library Helpers
|
||||||
|
|
||||||
private void Log(string message)
|
|
||||||
{
|
|
||||||
if (LogOutputCallback != null)
|
|
||||||
{
|
|
||||||
LogOutputCallback(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public LuaFunctionList RegisteredFunctions { get { return _luaFunctions; } }
|
public LuaFunctionList RegisteredFunctions { get { return _luaFunctions; } }
|
||||||
|
|
||||||
public void CallSaveStateEvent(string name)
|
public void CallSaveStateEvent(string name)
|
||||||
|
|
|
@ -15,18 +15,9 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Name { get { return "mainmemory"; } }
|
public override string Name { get { return "mainmemory"; } }
|
||||||
public Action<string> LogOutputCallback { get; set; }
|
|
||||||
|
|
||||||
#region Main Memory Library Helpers
|
#region Main Memory Library Helpers
|
||||||
|
|
||||||
private void Log(object message)
|
|
||||||
{
|
|
||||||
if (LogOutputCallback != null)
|
|
||||||
{
|
|
||||||
LogOutputCallback(message.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int U2S(uint u, int size)
|
private static int U2S(uint u, int size)
|
||||||
{
|
{
|
||||||
var s = (int)u;
|
var s = (int)u;
|
||||||
|
|
|
@ -16,18 +16,9 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Name { get { return "memory"; } }
|
public override string Name { get { return "memory"; } }
|
||||||
public Action<string> LogOutputCallback { get; set; }
|
|
||||||
|
|
||||||
#region Memory Library Helpers
|
#region Memory Library Helpers
|
||||||
|
|
||||||
private void Log(object message)
|
|
||||||
{
|
|
||||||
if (LogOutputCallback != null)
|
|
||||||
{
|
|
||||||
LogOutputCallback(message.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int U2S(uint u, int size)
|
private static int U2S(uint u, int size)
|
||||||
{
|
{
|
||||||
var s = (int)u;
|
var s = (int)u;
|
||||||
|
|
|
@ -8,6 +8,15 @@ namespace BizHawk.Client.Common
|
||||||
public abstract class LuaLibraryBase
|
public abstract class LuaLibraryBase
|
||||||
{
|
{
|
||||||
public abstract string Name { get; }
|
public abstract string Name { get; }
|
||||||
|
public Action<string> LogOutputCallback { get; set; }
|
||||||
|
|
||||||
|
protected void Log(object message)
|
||||||
|
{
|
||||||
|
if (LogOutputCallback != null)
|
||||||
|
{
|
||||||
|
LogOutputCallback(message.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void LuaRegister(Lua lua, ILuaDocumentation docs = null)
|
public virtual void LuaRegister(Lua lua, ILuaDocumentation docs = null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,15 +24,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public EmuHawkLuaLibrary() { }
|
public EmuHawkLuaLibrary() { }
|
||||||
|
|
||||||
public override string Name { get { return "client"; } }
|
public override string Name { get { return "client"; } }
|
||||||
public Action<object> LogOutputCallback { get; set; }
|
|
||||||
|
|
||||||
private void Log(string message)
|
|
||||||
{
|
|
||||||
if (LogOutputCallback != null)
|
|
||||||
{
|
|
||||||
LogOutputCallback(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[LuaMethodAttributes(
|
[LuaMethodAttributes(
|
||||||
"clearautohold",
|
"clearautohold",
|
||||||
|
|
Loading…
Reference in New Issue