-
Notifications
You must be signed in to change notification settings - Fork 350
Expand file tree
/
Copy pathTypeInfo.cs
More file actions
173 lines (161 loc) · 6.63 KB
/
TypeInfo.cs
File metadata and controls
173 lines (161 loc) · 6.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
using System.Collections.Generic;
namespace CodeGenerator
{
public class TypeInfo
{
public static readonly Dictionary<string, string> WellKnownTypes = new Dictionary<string, string>()
{
{ "bool", "byte" },
{ "unsigned char", "byte" },
{ "signed char", "sbyte" },
{ "char", "byte" },
{ "ImWchar", "ushort" },
{ "ImFileHandle", "IntPtr" },
{ "ImU8", "byte" },
{ "ImS8", "sbyte" },
{ "ImU16", "ushort" },
{ "ImS16", "short" },
{ "ImU32", "uint" },
{ "ImS32", "int" },
{ "ImU64", "ulong" },
{ "ImS64", "long" },
{ "unsigned short", "ushort" },
{ "unsigned int", "uint" },
{ "ImVec2", "Vector2" },
{ "ImVec2_Simple", "Vector2" },
{ "ImVec3", "Vector3" },
{ "ImVec4", "Vector4" },
{ "ImWchar16", "ushort" }, //char is not blittable
{ "ImVec4_Simple", "Vector4" },
{ "ImColor_Simple", "ImColor" },
{ "ImTextureID", "IntPtr" },
{ "ImGuiID", "uint" },
{ "ImDrawIdx", "ushort" },
{ "ImDrawListSharedData", "IntPtr" },
{ "ImDrawListSharedData*", "IntPtr" },
{ "ImDrawCallback", "IntPtr" },
{ "size_t", "uint" },
{ "ImGuiContext*", "IntPtr" },
{ "ImPlotContext*", "IntPtr" },
{ "EditorContext*", "IntPtr" },
{ "ImGuiMemAllocFunc", "IntPtr" },
{ "ImGuiMemFreeFunc", "IntPtr" },
{ "ImFontBuilderIO", "IntPtr" },
{ "float[2]", "Vector2*" },
{ "float[3]", "Vector3*" },
{ "float[4]", "Vector4*" },
{ "int[2]", "int*" },
{ "int[3]", "int*" },
{ "int[4]", "int*" },
{ "float&", "float*" },
{ "ImVec2[2]", "Vector2*" },
{ "char* []", "byte**" },
{ "unsigned char[256]", "byte*"},
{ "ImPlotFormatter", "IntPtr" },
{ "ImPlotGetter", "IntPtr" },
{ "ImPlotTransform", "IntPtr" },
{ "ImGuiKeyChord", "ImGuiKey" },
};
public static readonly List<string> WellKnownEnums = new List<string>()
{
"ImGuiMouseButton"
};
public static readonly Dictionary<string, string> AlternateEnumPrefixes = new Dictionary<string, string>()
{
{ "ImGuiKey", "ImGuiMod" },
};
public static readonly Dictionary<string, string> AlternateEnumPrefixSubstitutions = new Dictionary<string, string>()
{
{ "ImGuiMod_", "Mod" },
};
public static readonly Dictionary<string, string> WellKnownFieldReplacements = new Dictionary<string, string>()
{
{ "bool", "bool" }, // Force bool to remain as bool in type-safe wrappers.
};
public static readonly HashSet<string> CustomDefinedTypes = new HashSet<string>()
{
"ImVector",
"ImVec2",
"ImVec4",
"ImGuiStoragePair",
};
public static readonly Dictionary<string, string> WellKnownDefaultValues = new Dictionary<string, string>()
{
{ "((void *)0)", "null" },
{ "((void*)0)", "null" },
{ "NULL", "null"},
{ "nullptr", "null"},
{ "ImVec2(0,0)", "new Vector2()" },
{ "ImVec2(0.0f,0.0f)", "new Vector2()" },
{ "ImVec2(-FLT_MIN,0)", "new Vector2(-float.MinValue, 0.0f)" },
{ "ImVec2(-1,0)", "new Vector2(-1, 0)" },
{ "ImVec2(1,0)", "new Vector2(1, 0)" },
{ "ImVec2(1,1)", "new Vector2(1, 1)" },
{ "ImVec2(0,1)", "new Vector2(0, 1)" },
{ "ImVec4(0,0,0,0)", "new Vector4()" },
{ "ImVec4(1,1,1,1)", "new Vector4(1, 1, 1, 1)" },
{ "ImVec4(0,0,0,-1)", "new Vector4(0, 0, 0, -1)" },
{ "ImPlotPoint(0,0)", "new ImPlotPoint { x = 0, y = 0 }" },
{ "ImPlotPoint(1,1)", "new ImPlotPoint { x = 1, y = 1 }" },
{ "ImDrawCornerFlags_All", "ImDrawCornerFlags.All" },
{ "ImPlotFlags_None", "ImPlotFlags.None"},
{ "ImPlotAxisFlags_None", "ImPlotAxisFlags.None"},
{ "ImPlotAxisFlags_NoGridLines", "ImPlotAxisFlags.NoGridLines"},
{ "ImGuiCond_Once", "ImGuiCond.Once"},
{ "ImPlotOrientation_Vertical", "ImPlotOrientation.Vertical"},
{ "PinShape_CircleFilled", "PinShape.CircleFilled"},
{ "ImGuiPopupFlags_None", "ImGuiPopupFlags.None"},
{ "ImGuiNavHighlightFlags_TypeDefault", "ImGuiNavHighlightFlags.TypeDefault"},
{ "ImGuiKeyModFlags_Ctrl", "ImGuiKeyModFlags.Ctrl"},
{ "ImPlotYAxis_1", "ImPlotYAxis._1"},
{ "FLT_MAX", "float.MaxValue" },
{ "(((ImU32)(255)<<24)|((ImU32)(255)<<16)|((ImU32)(255)<<8)|((ImU32)(255)<<0))", "0xFFFFFFFF" },
{ "sizeof(ImU8)", "sizeof(byte)"},
{ "sizeof(ImS8)", "sizeof(sbyte)"},
{ "sizeof(ImU16)", "sizeof(ushort)"},
{ "sizeof(ImS16)", "sizeof(short)"},
{ "sizeof(ImU32)", "sizeof(uint)"},
{ "sizeof(ImS32)", "sizeof(int)"},
{ "sizeof(ImU64)", "sizeof(ulong)"},
{ "sizeof(ImS64)", "sizeof(long)"},
{ "ImPlotBin_Sturges", "(int)ImPlotBin.Sturges" },
{ "ImPlotRect()", "new ImPlotRect()" },
{ "ImPlotCond_Once", "ImPlotCond.Once" },
{ "ImPlotRange()", "new ImPlotRange()" },
};
public static readonly Dictionary<string, string> IdentifierReplacements = new Dictionary<string, string>()
{
{ "in", "@in" },
{ "out", "@out" },
{ "ref", "@ref" },
};
public static readonly HashSet<string> LegalFixedTypes = new HashSet<string>()
{
"byte",
"sbyte",
"char",
"ushort",
"short",
"uint",
"int",
"ulong",
"long",
"float",
"double",
};
public static readonly HashSet<string> SkippedFunctions = new HashSet<string>()
{
"igInputText",
"igInputTextMultiline",
"igInputTextWithHint"
};
public static string GetTypeForBitfield(int size) => size switch
{
_ when size <= 8 => "byte",
_ when size <= 16 => "ushort",
_ when size <= 32 => "uint",
_ when size <= 64 => "ulong",
_ => throw new System.NotSupportedException("Unsupported bitfield size: " + size)
};
}
}