mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-04-03 20:08:21 +00:00
WIP
This commit is contained in:
@@ -12,7 +12,7 @@ public class ArgumentDef
|
||||
|
||||
public bool Optional { get; set; }
|
||||
|
||||
public TRU Type { get; set; }
|
||||
public Tru Type { get; set; }
|
||||
|
||||
public ParameterInfo ParameterInfo { get; set; }
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ArgumentDef
|
||||
var cs = (uint)data[offset++];
|
||||
var name = data.GetString(offset, cs);
|
||||
offset += cs;
|
||||
var (size, type) = TRU.Parse(data, offset);
|
||||
var (size, type) = Tru.Parse(data, offset);
|
||||
|
||||
offset += size;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public class ConstantDef : MemberDef
|
||||
public object Value { get; set; }
|
||||
|
||||
public Map<string, string> Annotations { get; set; }
|
||||
public TRU ValueType { get; set; }
|
||||
public Tru ValueType { get; set; }
|
||||
|
||||
public FieldInfo FieldInfo { get; set; }
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ConstantDef : MemberDef
|
||||
var name = data.GetString(offset + 1, data[offset]);
|
||||
offset += (uint)data[offset] + 1;
|
||||
|
||||
var (dts, valueType) = TRU.Parse(data, offset);
|
||||
var (dts, valueType) = Tru.Parse(data, offset);
|
||||
|
||||
offset += dts;
|
||||
|
||||
@@ -100,7 +100,7 @@ public class ConstantDef : MemberDef
|
||||
{
|
||||
var annotationAttrs = ci.GetCustomAttributes<AnnotationAttribute>(true);
|
||||
|
||||
var valueType = TRU.FromType(ci.FieldType);
|
||||
var valueType = Tru.FromType(ci.FieldType);
|
||||
|
||||
if (valueType == null)
|
||||
throw new Exception($"Unsupported type `{ci.FieldType}` in constant `{type.Name}.{ci.Name}`");
|
||||
|
||||
@@ -29,7 +29,7 @@ public class EventDef : MemberDef
|
||||
|
||||
public EventInfo EventInfo { get; set; }
|
||||
|
||||
public TRU ArgumentType { get; set; }
|
||||
public Tru ArgumentType { get; set; }
|
||||
|
||||
|
||||
public static (uint, EventDef) Parse(byte[] data, uint offset, byte index, bool inherited)
|
||||
@@ -42,7 +42,7 @@ public class EventDef : MemberDef
|
||||
var name = data.GetString(offset + 1, data[offset]);
|
||||
offset += (uint)data[offset] + 1;
|
||||
|
||||
var (dts, argType) = TRU.Parse(data, offset);
|
||||
var (dts, argType) = Tru.Parse(data, offset);
|
||||
|
||||
offset += dts;
|
||||
|
||||
@@ -116,7 +116,7 @@ public class EventDef : MemberDef
|
||||
|
||||
|
||||
var argType = ei.EventHandlerType.GenericTypeArguments[0];
|
||||
var evtType = TRU.FromType(argType);
|
||||
var evtType = Tru.FromType(argType);
|
||||
|
||||
if (evtType == null)
|
||||
throw new Exception($"Unsupported type `{argType}` in event `{type.Name}.{ei.Name}`");
|
||||
|
||||
@@ -27,7 +27,7 @@ public class FunctionDef : MemberDef
|
||||
// set;
|
||||
//}
|
||||
|
||||
public TRU ReturnType { get; set; }
|
||||
public Tru ReturnType { get; set; }
|
||||
|
||||
public bool IsStatic { get; set; }
|
||||
|
||||
@@ -52,7 +52,7 @@ public class FunctionDef : MemberDef
|
||||
offset += (uint)data[offset] + 1;
|
||||
|
||||
// return type
|
||||
var (rts, returnType) = TRU.Parse(data, offset);
|
||||
var (rts, returnType) = Tru.Parse(data, offset);
|
||||
offset += rts;
|
||||
|
||||
// arguments count
|
||||
@@ -124,27 +124,27 @@ public class FunctionDef : MemberDef
|
||||
|
||||
var genericRtType = mi.ReturnType.IsGenericType ? mi.ReturnType.GetGenericTypeDefinition() : null;
|
||||
|
||||
TRU rtType;
|
||||
Tru rtType;
|
||||
|
||||
if (genericRtType == typeof(AsyncReply<>))
|
||||
{
|
||||
rtType = TRU.FromType(mi.ReturnType.GetGenericArguments()[0]);
|
||||
rtType = Tru.FromType(mi.ReturnType.GetGenericArguments()[0]);
|
||||
}
|
||||
else if (genericRtType == typeof(Task<>))
|
||||
{
|
||||
rtType = TRU.FromType(mi.ReturnType.GetGenericArguments()[0]);
|
||||
rtType = Tru.FromType(mi.ReturnType.GetGenericArguments()[0]);
|
||||
}
|
||||
else if (genericRtType == typeof(IEnumerable<>) || genericRtType == typeof(IAsyncEnumerable<>))
|
||||
{
|
||||
// get export
|
||||
rtType = TRU.FromType(mi.ReturnType.GetGenericArguments()[0]);
|
||||
rtType = Tru.FromType(mi.ReturnType.GetGenericArguments()[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mi.ReturnType == typeof(Task))
|
||||
rtType = TRU.FromType(null);
|
||||
rtType = Tru.FromType(null);
|
||||
else
|
||||
rtType = TRU.FromType(mi.ReturnType);
|
||||
rtType = Tru.FromType(mi.ReturnType);
|
||||
}
|
||||
|
||||
if (rtType == null)
|
||||
@@ -214,7 +214,7 @@ public class FunctionDef : MemberDef
|
||||
|
||||
var arguments = args.Select(x =>
|
||||
{
|
||||
var argType = TRU.FromType(x.ParameterType);
|
||||
var argType = Tru.FromType(x.ParameterType);
|
||||
|
||||
if (argType == null)
|
||||
throw new Exception($"Unsupported type `{x.ParameterType}` in method `{type.Name}.{mi.Name}` parameter `{x.Name}`");
|
||||
|
||||
@@ -24,7 +24,7 @@ public class PropertyDef : MemberDef
|
||||
set;
|
||||
}
|
||||
|
||||
public TRU ValueType { get; set; }
|
||||
public Tru ValueType { get; set; }
|
||||
|
||||
|
||||
/*
|
||||
@@ -93,7 +93,7 @@ public class PropertyDef : MemberDef
|
||||
|
||||
offset += (uint)data[offset] + 1;
|
||||
|
||||
var (dts, valueType) = TRU.Parse(data, offset);
|
||||
var (dts, valueType) = Tru.Parse(data, offset);
|
||||
|
||||
offset += dts;
|
||||
|
||||
@@ -200,8 +200,8 @@ public class PropertyDef : MemberDef
|
||||
var genericPropType = pi.PropertyType.IsGenericType ? pi.PropertyType.GetGenericTypeDefinition() : null;
|
||||
|
||||
var propType = genericPropType == typeof(PropertyContext<>) ?
|
||||
TRU.FromType(pi.PropertyType.GetGenericArguments()[0]) :
|
||||
TRU.FromType(pi.PropertyType);
|
||||
Tru.FromType(pi.PropertyType.GetGenericArguments()[0]) :
|
||||
Tru.FromType(pi.PropertyType);
|
||||
|
||||
if (propType == null)
|
||||
throw new Exception($"Unsupported type `{pi.PropertyType}` in property `{type.Name}.{pi.Name}`");
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace Esiur.Data.Types;
|
||||
public class TypeDef
|
||||
{
|
||||
|
||||
protected UUID typeId;
|
||||
protected UUID? parentId;
|
||||
protected Uuid typeId;
|
||||
protected Uuid? parentId;
|
||||
|
||||
public Map<string, string> Annotations { get; set; }
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TypeDef
|
||||
|
||||
protected byte[] content;
|
||||
|
||||
public UUID? ParentId => parentId;
|
||||
public Uuid? ParentId => parentId;
|
||||
|
||||
public byte[] Content
|
||||
{
|
||||
@@ -110,7 +110,7 @@ public class TypeDef
|
||||
return null;
|
||||
}
|
||||
|
||||
public UUID Id
|
||||
public Uuid Id
|
||||
{
|
||||
get { return typeId; }
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class TypeDef
|
||||
|
||||
}
|
||||
|
||||
public static UUID GetTypeUUID(Type type)
|
||||
public static Uuid GetTypeUUID(Type type)
|
||||
{
|
||||
var attr = type.GetCustomAttribute<TypeIdAttribute>();
|
||||
if (attr != null)
|
||||
@@ -153,7 +153,7 @@ public class TypeDef
|
||||
hash[6] = (byte)((hash[6] & 0xF) | 0x80);
|
||||
hash[8] = (byte)((hash[8] & 0xF) | 0x80);
|
||||
|
||||
var rt = new UUID(hash);
|
||||
var rt = new Uuid(hash);
|
||||
return rt;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user