Work on standard libraries.
- Allows Standard Libraries to work with actual luatypes, to prevent constant back and forth casting - adds ipairs function, doesn't do anything except maintain compatibility with lua - several tests
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Upsilon.BaseTypes.UserData
|
||||
var key = index.ToCSharpObject();
|
||||
if (Dictionary.Contains(key))
|
||||
{
|
||||
return Dictionary[key].ToLuaType();
|
||||
return Dictionary[key].ToScriptType();
|
||||
}
|
||||
//TODO: log error
|
||||
return new ScriptNull();
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Upsilon.BaseTypes.UserData
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return List[i].ToLuaType();
|
||||
return List[i].ToScriptType();
|
||||
}
|
||||
|
||||
public void Set(Diagnostics diagnostics, TextSpan span, ScriptType index, ScriptType value)
|
||||
|
||||
@@ -30,10 +30,12 @@ namespace Upsilon.BaseTypes.UserData
|
||||
public bool IsOptional { get; }
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
private List<UserDataMethodPart> MethodParts { get; }
|
||||
|
||||
public UserDataMethod(MethodInfo method)
|
||||
{
|
||||
Name = method.Name;
|
||||
var part = new UserDataMethodPart(method);
|
||||
MethodParts = new List<UserDataMethodPart>()
|
||||
{
|
||||
|
||||
@@ -40,15 +40,15 @@ namespace Upsilon.BaseTypes.UserData
|
||||
member = member.ToLowerInvariant();
|
||||
if (Variables.TryGetValue(member, out var info))
|
||||
{
|
||||
return (info.GetValue(value).ToLuaType(), false, null);
|
||||
return (info.GetValue(value).ToScriptType(), false, null);
|
||||
}
|
||||
if (Properties.TryGetValue(member, out var property))
|
||||
{
|
||||
return (property.GetValue(value).ToLuaType(), false, null);
|
||||
return (property.GetValue(value).ToScriptType(), false, null);
|
||||
}
|
||||
if (Methods.TryGetValue(member, out var method))
|
||||
{
|
||||
return (new ScriptMethodInfoFunction(method, value), false, null);
|
||||
return (new ScriptMethodInfoFunction(method, value, false), false, null);
|
||||
}
|
||||
|
||||
return (null, true, $"Can't find public member '{member}' on type '{Type}'.");
|
||||
@@ -85,7 +85,7 @@ namespace Upsilon.BaseTypes.UserData
|
||||
return (new ScriptNull(), true);
|
||||
}
|
||||
|
||||
return (method.Invoke(value, new[] {par1.ToCSharpObject(), par2.ToCSharpObject()}).ToLuaType(), false);
|
||||
return (method.Invoke(value, new[] {par1.ToCSharpObject(), par2.ToCSharpObject()}).ToScriptType(), false);
|
||||
}
|
||||
public (ScriptType Type, bool Failed) UnaryOperator(object value, ScriptType par1, OperatorType op)
|
||||
{
|
||||
@@ -95,7 +95,7 @@ namespace Upsilon.BaseTypes.UserData
|
||||
return (new ScriptNull(), true);
|
||||
}
|
||||
|
||||
return (method.Invoke(value, new[] {par1.ToCSharpObject()}).ToLuaType(), false);
|
||||
return (method.Invoke(value, new[] {par1.ToCSharpObject()}).ToScriptType(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user