Refactor the LuaDocumentation class to remove a bunch of unnecessary stuff
This commit is contained in:
parent
bb1b1ff5b5
commit
ba4e7d620b
|
@ -5,45 +5,10 @@ using System.Text;
|
|||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public interface ILuaDocumentation
|
||||
{
|
||||
void Add(string methodLib, string methodName, MethodInfo method, string description);
|
||||
}
|
||||
|
||||
public class LuaDocumentation : ILuaDocumentation
|
||||
public class LuaDocumentation : List<LibraryFunction>
|
||||
{
|
||||
public LuaDocumentation()
|
||||
{
|
||||
FunctionList = new List<LibraryFunction>();
|
||||
}
|
||||
|
||||
public List<LibraryFunction> FunctionList { get; set; }
|
||||
|
||||
public void Add(string methodLib, string methodName, MethodInfo method, string description)
|
||||
{
|
||||
FunctionList.Add(
|
||||
new LibraryFunction(methodLib, methodName, method, description));
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
FunctionList = new List<LibraryFunction>();
|
||||
}
|
||||
|
||||
public void Sort()
|
||||
{
|
||||
FunctionList = FunctionList.OrderBy(x => x.Library).ThenBy(x => x.Name).ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetLibraryList()
|
||||
{
|
||||
return FunctionList.Select(x => x.Library);
|
||||
}
|
||||
|
||||
public IEnumerable<LibraryFunction> GetFunctionsByLibrary(string library)
|
||||
{
|
||||
return FunctionList
|
||||
.Where(func => func.Library == library);
|
||||
:base() { }
|
||||
}
|
||||
|
||||
public class LibraryFunction
|
||||
|
@ -62,7 +27,7 @@ namespace BizHawk.Client.Common
|
|||
Parameters.Add(p.ToString());
|
||||
}
|
||||
|
||||
this._returnType = method.ReturnType.ToString();
|
||||
_returnType = method.ReturnType.ToString();
|
||||
|
||||
Description = description;
|
||||
}
|
||||
|
@ -134,4 +99,3 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public virtual void LuaRegister(ILuaDocumentation docs = null)
|
||||
public virtual void LuaRegister(LuaDocumentation docs = null)
|
||||
{
|
||||
Lua.NewTable(Name);
|
||||
|
||||
|
@ -48,7 +48,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (docs != null)
|
||||
{
|
||||
docs.Add(Name, luaMethodAttr.Name, method, luaMethodAttr.Description);
|
||||
docs.Add(new LibraryFunction(Name, luaMethodAttr.Name, method, luaMethodAttr.Description));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public static string GetLuaFunctionsList()
|
||||
{
|
||||
var list = new StringBuilder();
|
||||
foreach (var function in GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList)
|
||||
foreach (var function in GlobalWin.Tools.LuaConsole.LuaImp.Docs)
|
||||
{
|
||||
list.AppendLine(function.Name);
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
private readonly Sorting _columnSort = new Sorting();
|
||||
|
||||
private List<LuaDocumentation.LibraryFunction> FunctionList = new List<LuaDocumentation.LibraryFunction>();
|
||||
private List<LibraryFunction> FunctionList = new List<LibraryFunction>();
|
||||
|
||||
private List<LuaDocumentation.LibraryFunction> FilteredList
|
||||
private List<LibraryFunction> FilteredList
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void LuaFunctionList_Load(object sender, EventArgs e)
|
||||
{
|
||||
FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList.ToList();
|
||||
FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.ToList();
|
||||
UpdateList();
|
||||
FilterBox.Focus();
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
foreach (int index in indexes)
|
||||
{
|
||||
var libraryFunction = GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList[index];
|
||||
var libraryFunction = GlobalWin.Tools.LuaConsole.LuaImp.Docs[index];
|
||||
sb.Append(libraryFunction.Library).Append('.').Append(libraryFunction.Name).Append("()\n");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue