public static Type DecodeType(void *T) { TYPECODE *p = (TYPECODE *)T; return(DecodeType_impl(ref p)); }
private static Type DecodeType_impl(ref TYPECODE *p) { switch (*p++) { case TYPECODE.BOOL: return(typeof(bool)); case TYPECODE.CHAR: return(typeof(char)); case TYPECODE.STRING: return(typeof(string)); case TYPECODE.F32: return(typeof(float)); case TYPECODE.F64: return(typeof(double)); case TYPECODE.I8: return(typeof(sbyte)); case TYPECODE.U8: return(typeof(byte)); case TYPECODE.I16: return(typeof(short)); case TYPECODE.U16: return(typeof(ushort)); case TYPECODE.I32: return(typeof(int)); case TYPECODE.U32: return(typeof(uint)); case TYPECODE.I64: return(typeof(long)); case TYPECODE.U64: return(typeof(ulong)); case TYPECODE.LIST: return(typeof(List <>).MakeGenericType(DecodeType_impl(ref p))); case TYPECODE.TUPLE: { byte cnt = (byte)*(p++); Type[] elements = new Type[cnt]; for (int i = 0; i < cnt; ++i) { elements[i] = DecodeType_impl(ref p); } return(BuildValueTuple(elements)); } default: throw new TypeCodecException("Cannot decode type"); } }