|
|
@@ -47,7 +47,39 @@ public readonly struct LuaValue : IEquatable<LuaValue>
|
|
|
result = Unsafe.As<double, T>(ref v);
|
|
|
return true;
|
|
|
}
|
|
|
- else if (t == typeof(string))
|
|
|
+ else if (t == typeof(object))
|
|
|
+ {
|
|
|
+ result = (T)(object)value;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case LuaValueType.Boolean:
|
|
|
+ if (t == typeof(bool))
|
|
|
+ {
|
|
|
+ var v = value == 1;
|
|
|
+ result = Unsafe.As<bool, T>(ref v);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else if (t == typeof(object))
|
|
|
+ {
|
|
|
+ result = (T)(object)value;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case LuaValueType.String:
|
|
|
+ if (t == typeof(string))
|
|
|
+ {
|
|
|
+ var v = (string)referenceValue!;
|
|
|
+ result = Unsafe.As<string, T>(ref v);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else if (t == typeof(double))
|
|
|
{
|
|
|
var str = (string)referenceValue!;
|
|
|
var span = str.AsSpan().Trim();
|
|
|
@@ -82,38 +114,6 @@ public readonly struct LuaValue : IEquatable<LuaValue>
|
|
|
}
|
|
|
}
|
|
|
else if (t == typeof(object))
|
|
|
- {
|
|
|
- result = (T)(object)value;
|
|
|
- return true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- case LuaValueType.Boolean:
|
|
|
- if (t == typeof(bool))
|
|
|
- {
|
|
|
- var v = value == 1;
|
|
|
- result = Unsafe.As<bool, T>(ref v);
|
|
|
- return true;
|
|
|
- }
|
|
|
- else if (t == typeof(object))
|
|
|
- {
|
|
|
- result = (T)(object)value;
|
|
|
- return true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- case LuaValueType.String:
|
|
|
- if (t == typeof(string))
|
|
|
- {
|
|
|
- var v = (string)referenceValue!;
|
|
|
- result = Unsafe.As<string, T>(ref v);
|
|
|
- return true;
|
|
|
- }
|
|
|
- else if (t == typeof(object))
|
|
|
{
|
|
|
result = (T)referenceValue!;
|
|
|
return true;
|