Clean up hack in `MemoryLuaLibrary.GetMemoryDomainList`

This commit is contained in:
YoshiRulz 2025-05-24 09:56:01 +10:00
parent 6abed2b052
commit f3799fbb0e
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 2 additions and 3 deletions

View File

@ -1,4 +1,3 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
@ -18,7 +17,7 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local nlmemget = memory.getmemorydomainlist();")]
[LuaMethod("getmemorydomainlist", "Returns a string of the memory domains for the loaded platform core. List will be a single string delimited by line feeds")]
public LuaTable GetMemoryDomainList()
=> _th.ListToTable((List<string>) APIs.Memory.GetMemoryDomainList(), indexFrom: 0); //HACK cast will succeed as long as impl. returns .Select<T, string>().ToList() as IROC<string>
=> _th.EnumerateToLuaTable(APIs.Memory.GetMemoryDomainList(), indexFrom: 0);
[LuaMethodExample("local uimemget = memory.getmemorydomainsize( mainmemory.getname( ) );")]
[LuaMethod("getmemorydomainsize", "Returns the number of bytes of the specified memory domain. If no domain is specified, or the specified domain doesn't exist, returns the current domain size")]

View File

@ -8,6 +8,6 @@ namespace BizHawk.Client.Common
public static class LuaExtensions
{
public static LuaTable EnumerateToLuaTable<T>(this NLuaTableHelper tableHelper, IEnumerable<T> list, int indexFrom = 1)
=> tableHelper.ListToTable(list.ToList(), indexFrom);
=> tableHelper.ListToTable(list as IReadOnlyList<T> ?? list.ToList(), indexFrom);
}
}