2013-04-14 23:56:45 +00:00
|
|
|
|
using System.Collections.Generic;
|
2012-07-11 15:03:51 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2012-07-23 01:02:04 +00:00
|
|
|
|
|
2013-10-25 00:57:23 +00:00
|
|
|
|
namespace BizHawk.MultiClient
|
2012-07-11 15:03:51 +00:00
|
|
|
|
{
|
|
|
|
|
public class LuaDocumentation
|
|
|
|
|
{
|
|
|
|
|
public List<LibraryFunction> FunctionList = new List<LibraryFunction>();
|
|
|
|
|
|
|
|
|
|
public void Add(string method_lib, string method_name, System.Reflection.MethodInfo method)
|
|
|
|
|
{
|
|
|
|
|
LibraryFunction f = new LibraryFunction(method_lib, method_name, method);
|
|
|
|
|
FunctionList.Add(f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Clear()
|
|
|
|
|
{
|
|
|
|
|
FunctionList = new List<LibraryFunction>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Sort()
|
|
|
|
|
{
|
2012-07-12 00:57:09 +00:00
|
|
|
|
FunctionList = FunctionList.OrderBy(x => x.library).ThenBy(x => x.name).ToList();
|
2012-07-11 15:03:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-23 01:02:04 +00:00
|
|
|
|
public List<string> GetLibraryList()
|
|
|
|
|
{
|
|
|
|
|
HashSet<string> libs = new HashSet<string>();
|
|
|
|
|
foreach (LibraryFunction function in FunctionList)
|
|
|
|
|
{
|
|
|
|
|
libs.Add(function.library);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return libs.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-23 02:24:48 +00:00
|
|
|
|
public List<string> GetFunctionsByLibrary(string library)
|
|
|
|
|
{
|
2013-04-14 23:56:45 +00:00
|
|
|
|
return (from t in FunctionList where t.library == library select t.name).ToList();
|
2012-07-23 02:24:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-11 15:03:51 +00:00
|
|
|
|
public class LibraryFunction
|
|
|
|
|
{
|
|
|
|
|
public LibraryFunction(string method_lib, string method_name, System.Reflection.MethodInfo method)
|
|
|
|
|
{
|
|
|
|
|
library = method_lib;
|
|
|
|
|
name = method_name;
|
|
|
|
|
System.Reflection.ParameterInfo[] info = method.GetParameters();
|
|
|
|
|
foreach (System.Reflection.ParameterInfo p in info)
|
|
|
|
|
{
|
|
|
|
|
parameters.Add(p.ToString());
|
|
|
|
|
}
|
|
|
|
|
return_type = method.ReturnType.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string library = "";
|
|
|
|
|
public string name = "";
|
|
|
|
|
public List<string> parameters = new List<string>();
|
|
|
|
|
public string return_type = "";
|
2012-07-12 00:57:09 +00:00
|
|
|
|
|
|
|
|
|
public string ParameterList
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
StringBuilder list = new StringBuilder();
|
|
|
|
|
list.Append('(');
|
|
|
|
|
for (int i = 0; i < parameters.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
string param = parameters[i].Replace("System", "").Replace("Object", "").Replace(" ", "").Replace(".", "").Replace("LuaInterface", "");
|
|
|
|
|
list.Append(param);
|
|
|
|
|
if (i < parameters.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
list.Append(',');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
list.Append(')');
|
|
|
|
|
return list.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string ReturnType
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2013-04-14 23:56:45 +00:00
|
|
|
|
return return_type.Replace("System.", "").Replace("LuaInterface.", "").ToLower().Trim();
|
2012-07-12 00:57:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-11 15:03:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|