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:
adelikat 2014-05-20 20:25:18 +00:00
parent 94b9761b31
commit f19d15d1ed
5 changed files with 9 additions and 36 deletions

View File

@ -16,19 +16,10 @@ namespace BizHawk.Client.Common
public override string Name { get { return "event"; } }
public Action<object> LogOutputCallback { get; set; }
public Lua CurrentThread { get; set; }
#region Events Library Helpers
private void Log(string message)
{
if (LogOutputCallback != null)
{
LogOutputCallback(message);
}
}
public LuaFunctionList RegisteredFunctions { get { return _luaFunctions; } }
public void CallSaveStateEvent(string name)

View File

@ -15,18 +15,9 @@ namespace BizHawk.Client.Common
}
public override string Name { get { return "mainmemory"; } }
public Action<string> LogOutputCallback { get; set; }
#region Main Memory Library Helpers
private void Log(object message)
{
if (LogOutputCallback != null)
{
LogOutputCallback(message.ToString());
}
}
private static int U2S(uint u, int size)
{
var s = (int)u;

View File

@ -16,18 +16,9 @@ namespace BizHawk.Client.Common
}
public override string Name { get { return "memory"; } }
public Action<string> LogOutputCallback { get; set; }
#region Memory Library Helpers
private void Log(object message)
{
if (LogOutputCallback != null)
{
LogOutputCallback(message.ToString());
}
}
private static int U2S(uint u, int size)
{
var s = (int)u;

View File

@ -8,6 +8,15 @@ namespace BizHawk.Client.Common
public abstract class LuaLibraryBase
{
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)
{

View File

@ -24,15 +24,6 @@ namespace BizHawk.Client.EmuHawk
public EmuHawkLuaLibrary() { }
public override string Name { get { return "client"; } }
public Action<object> LogOutputCallback { get; set; }
private void Log(string message)
{
if (LogOutputCallback != null)
{
LogOutputCallback(message);
}
}
[LuaMethodAttributes(
"clearautohold",