-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateEnumCS.cs
111 lines (102 loc) · 3.15 KB
/
CreateEnumCS.cs
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
using System;
using System.IO;
namespace VulkanParser
{
/// <summary>
/// Description of CreateEnumCS.
/// </summary>
public static class CreaterEnumCS
{
public static void CreateEnumCS()
{
StreamWriter sw = File.CreateText(VKxmlParser.GetDestination()+"VKEnums.cs");
sw.WriteLine("// Document Created with VulkanParser.");
sw.WriteLine("// "+DateTime.Now.ToString("HH:mm:ss dd/mm/yyyy"));
sw.WriteLine("// by BROTHERHOOD OF THE BLACK SWORD.");
sw.WriteLine();
sw.WriteLine("using System;");
sw.WriteLine();
sw.WriteLine("namespace "+VKxmlParser.GetNamespace());
sw.WriteLine("{");
foreach (string key in EnumParser.d_Enums.Keys)
{
bool tvneg = false;
bool tvmasint = false;
//bool tvmaslong = false;
foreach (string key2 in EnumParser.d_Enums[key].Keys)
{
long tempval;
if (long.TryParse(EnumParser.d_Enums[key][key2], out tempval))
{
if (tempval < 0)
{
tvneg = true;
if ((tempval * -1) > int.MaxValue)
{
tvmasint = true;
}
}
else
{
if (tempval > int.MaxValue)
{
tvmasint = true;
/*if (tempval > int.MaxValue)
{
}*/
}
}
}
}
string tvalor = "";
if (tvneg)
{
if (tvmasint)
{
tvalor = "long";
}
else
{
tvalor = "int";
}
}
else
{
if (tvmasint)
{
tvalor = "ulong";
}
else
{
tvalor = "uint";
}
}
sw.WriteLine("\t"+"public enum "+key+" : "+tvalor);
sw.WriteLine("\t"+"{");
int maxkeys = EnumParser.d_Enums[key].Keys.Count;
int contador = 0;
foreach(string key2 in EnumParser.d_Enums[key].Keys)
{
if (EnumParser.d_EnumComments.ContainsKey(key2))
{
sw.WriteLine("\t"+"\t"+"/// <summary>"+EnumParser.d_EnumComments[key2]+"</summary>");
}
if (contador < maxkeys-1)
{
sw.WriteLine("\t"+"\t"+key2+" = "+EnumParser.d_Enums[key][key2]+",");
}
else
{
sw.WriteLine("\t"+"\t"+key2+" = "+EnumParser.d_Enums[key][key2]);
}
contador++;
}
sw.WriteLine("\t"+"}");
sw.WriteLine();
}
sw.WriteLine("}");
sw.WriteLine();
sw.Close();
}
}
}