Reworked compatible external function parameters handling
This commit is contained in:
parent
2e0ac29878
commit
00cc59dfbd
|
@ -140,26 +140,48 @@ namespace Upsilon.StandardLibraries
|
|||
|
||||
private static Type DeriveValidTypes(System.Type type)
|
||||
{
|
||||
var typeCode = System.Type.GetTypeCode(type);
|
||||
switch (typeCode)
|
||||
{
|
||||
case TypeCode.Boolean:
|
||||
return Type.Boolean;
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.SByte:
|
||||
case TypeCode.Decimal:
|
||||
case TypeCode.Double:
|
||||
case TypeCode.Single:
|
||||
case TypeCode.Int16:
|
||||
case TypeCode.Int32:
|
||||
case TypeCode.Int64:
|
||||
case TypeCode.UInt16:
|
||||
case TypeCode.UInt32:
|
||||
case TypeCode.UInt64:
|
||||
return Type.Number;
|
||||
case TypeCode.Char:
|
||||
case TypeCode.String:
|
||||
return Type.String;
|
||||
case TypeCode.Object:
|
||||
// allows every type
|
||||
return (Type) 255;
|
||||
}
|
||||
if (type == typeof(ScriptString))
|
||||
return Type.String;
|
||||
if (typeof(ScriptNumber).IsAssignableFrom(type))
|
||||
return Type.Number;
|
||||
if (type == typeof(ScriptBoolean))
|
||||
return Type.Boolean;
|
||||
if (type == typeof(IIterable))
|
||||
return Type.Table | Type.UserData;
|
||||
if (typeof(ScriptTable).IsAssignableFrom(type))
|
||||
return Type.Table;
|
||||
if (type == typeof(ScriptType))
|
||||
// allows every type
|
||||
return (Type) 255;
|
||||
if (type == typeof(object))
|
||||
// allows every type
|
||||
return (Type) 255;
|
||||
|
||||
|
||||
if (type == typeof(IIterable))
|
||||
return Type.Table | Type.UserData;
|
||||
|
||||
if (type.IsEnum)
|
||||
return Type.Number;
|
||||
if (type == typeof(string))
|
||||
return Type.String;
|
||||
return Type.UserData | Type.Number;
|
||||
if (typeof(IEnumerable).IsAssignableFrom(type))
|
||||
return Type.Table | Type.UserData;
|
||||
return Type.UserData;
|
||||
|
|
Loading…
Reference in New Issue