public static int NormalizeDataTypeId(ProjectConverter P, int dataType) { if (dataType == 0) { return(EplSystemId.DataType_Int); } if (EplSystemId.IsLibDataType(dataType) && dataType != P.DataTypeId_IntPtr) { EplSystemId.DecomposeLibDataTypeId(dataType, out var libId, out var typeId); try { if (P.Libs[libId].DataType[typeId].IsEnum) { return(EplSystemId.DataType_Int); } } catch (Exception) { } try { if (P.EocLibs[libId].Enum.ContainsKey(P.Libs[libId].DataType[typeId].Name)) { return(EplSystemId.DataType_Int); } } catch (Exception) { } } return(dataType); }
public static CppTypeName Translate(ProjectConverter P, int id, bool isArray = false) { id = NormalizeDataTypeId(P, id); if (id == P.DataTypeId_IntPtr) { return(IntPtr); } if (!BasicTypeMap.TryGetValue(id, out var result)) { if (EplSystemId.GetType(id) == EplSystemId.Type_Class || EplSystemId.GetType(id) == EplSystemId.Type_Struct) { result = new CppTypeName(false, P.TypeNamespace + "::" + P.GetUserDefinedName_SimpleCppName(id)); } else { EplSystemId.DecomposeLibDataTypeId(id, out var libId, out var typeId); if (P.Libs[libId] == null) { return(ErrorType); } if (typeId >= P.Libs[libId].DataType.Length) { return(ErrorType); } var name = P.Libs[libId].DataType[typeId].Name; if (P.EocLibs[libId] == null) { return(ErrorType); } if (!P.EocLibs[libId].Type.ContainsKey(name)) { return(ErrorType); } result = P.EocLibs[libId].Type[name].CppName; } } if (isArray) { result = new CppTypeName(false, "e::system::array", new[] { result }); } return(result); }
public CppTypeName GetCppTypeName(int id, bool isArray = false) { id = TranslateDataTypeId(id); if (id == DataTypeId_IntPtr) { return(CppTypeName_IntPtr); } if (!BasicCppTypeNameMap.TryGetValue(id, out var result)) { if (EplSystemId.GetType(id) == EplSystemId.Type_Class || EplSystemId.GetType(id) == EplSystemId.Type_Struct) { result = new CppTypeName(false, TypeNamespace + "::" + GetUserDefinedName_SimpleCppName(id)); } else { EplSystemId.DecomposeLibDataTypeId(id, out var libId, out var typeId); if (Libs[libId] == null) { return(EocErrorType); } if (typeId >= Libs[libId].DataType.Length) { return(EocErrorType); } var name = Libs[libId].DataType[typeId].Name; if (EocLibs[libId] == null) { return(EocErrorType); } if (!EocLibs[libId].Type.ContainsKey(name)) { return(EocErrorType); } result = EocLibs[libId].Type[name].CppName; } } if (isArray) { result = new CppTypeName(false, "e::system::array", new[] { result }); } return(result); }
public int TranslateDataTypeId(int dataType) { if (dataType == 0) { return(EplSystemId.DataType_Int); } if (EplSystemId.IsLibDataType(dataType)) { EplSystemId.DecomposeLibDataTypeId(dataType, out var libId, out var typeId); try { if (EocLibs[libId].Enum.ContainsKey(Libs[libId].DataType[typeId].Name)) { return(EplSystemId.DataType_Int); } } catch (Exception) { } } return(dataType); }