11//#include "$EnforceScriptExtensions:scripts/Game/Reflection/ESE_Reflection_v1.h"
22//#include "$EnforceScriptExtensions:scripts/Game/Reflection/ESE_Reflection_v2.h"
33
4- class ESE_Type : Managed
4+ class ESE_Type < Class T > : Managed
55{
6+ T Owner ;
67 typename Type ;
78 typename BaseType ;
89 bool IsByRef ;
910 bool IsArray ;
1011 bool IsClass ;
1112 bool IsEnum ;
1213
13- ESE_Reflection_EMemberTypes MemberType ;
14+ ESE_EMemberTypes MemberType ;
1415 string Name ;
1516
1617 bool EqualsObj (Class obj ) {return Type && obj ;}
17- bool EqualsType (typename T ) {return Type && T ;}
18- array < ESE_Type > FindMembers (ESE_Reflection_EMemberTypes memberType , ESE_Reflection_EBindingFlags bindingFlags )
18+ bool EqualsType (typename other ) {return Type && other ;}
19+ array < ESE_Type < Class >> FindMembers (ESE_EMemberTypes memberType = ESE_EMemberTypes . All , ESE_EBindingFlags bindingFlags = ESE_EBindingFlags . Default )
1920 {
20-
21+ /**
22+ array<ESE_Type<Class>> output = new array<ESE_Type<Class>>();
23+ int varCount = Type.GetVariableCount();
24+ for (int i = 0; i < varCount; i++)
25+ {
26+ string name = Type.GetVariableName(i);
27+ typename type = Type.GetVariableType(i);
28+ void val;
29+ Type.GetVariableValue(Owner, i, val);
30+ Print("name: " + name);
31+ Print("type: " + type);
32+ Print("value: " + val);
33+
34+ output.Insert( ESE_Reflection.TypeOf(val) );
35+ }
36+ return output;
37+ **/
38+ return null ;
2139 }
22-
23- void ESE_Type (typename type = typename .Empty )
40+
41+ void ESE_Type (T inst , typename type = typename .Empty )
2442 {
2543 if (!type )
2644 return ;
45+
46+ Owner = inst ;
2747 Type = type ;
2848 BaseType = Type .super .ClassName ().ToType ();
2949 if (Type .IsInherited (Class )) {IsByRef = true; IsClass = true;}
@@ -36,64 +56,186 @@ class ESE_Type: Managed
3656// ---------------------------------------------------------------------------------------------------------------
3757class ESE_Reflection
3858{
39- static const ESE_Reflection_EMemberTypes EMemberTypes ;
40- static const ESE_Reflection_EBindingFlags EBindingFlags ;
59+ static const ESE_EMemberTypes EMemberTypes ;
60+ static const ESE_EBindingFlags EBindingFlags ;
4161
4262 // -----------------------------------------------------------------------------------------------------------
63+ static array < string > GetAllClasses ()
64+ {
65+ array < string > allClasses = {}; //output
66+
67+ // go through all addons so we can find the files in each, like $core, $ArmaReforger, $EnforceScriptExtensions, etc.
68+ array < string > addons = {};
69+ GameProject .GetAvailableAddons (addons );
70+ array < string > duplicates = {};
71+ foreach (string addon : addons )
72+ {
73+ // find all the script files in the addon
74+ string addonID = GameProject .GetAddonID (addon );
75+ array < string > addonFiles = {};
76+ System .FindFiles (addonFiles .Insert , "$" + addonID + ":scripts/" , ".c" );
77+ //addonFiles.Debug();
78+
79+ foreach (string file : addonFiles )
80+ {
81+ string line ;
82+ FileHandle fHandle = FileIO .OpenFile (file , FileMode .READ );
83+ bool commentedOff = false;
84+ while (fHandle .FGets (line ) >= 0 )
85+ {
86+ // handle commented off sections of code
87+ if (line .Contains ("/*" ))
88+ {
89+ commentedOff = true;
90+ }
91+ if (line .Contains ("*/" ))
92+ {
93+ commentedOff = false;
94+ }
95+ if (commentedOff || line .Contains ("//" )) // change to starts with
96+ {
97+ continue ;
98+ }
99+ line .Replace (":" , "" );
100+ if (line .StartsWith ("class" ) || line .StartsWith ("sealed" ) || line .StartsWith ("modded" ))
101+ {
102+ array < string > tokens = {};
103+ line .Split (" " , tokens , true);
104+
105+ tokens .RemoveItemOrdered ("class" );
106+ tokens .RemoveItemOrdered ("sealed" );
107+ tokens .RemoveItemOrdered ("modded" );
108+ tokens .RemoveItemOrdered ("extends" );
109+
110+ // to handle template classes, since they have a space in their name like: Something<Class T>
111+ foreach (string element : tokens )
112+ {
113+ if (element .Contains (">" ) && !element .Contains ("<" ))
114+ {
115+ tokens [0 ] = tokens [0 ] + " " + element ;
116+ break ;
117+ }
118+ }
119+
120+ tokens .Insert (file );
121+ //Print(tokens);
122+ if (allClasses .Contains (tokens [0 ]))
123+ {
124+ duplicates .Insert (tokens [0 ] + " : " + file );
125+ }
126+ allClasses .Insert (tokens [0 ] + "," + file );
127+ }
128+ }
129+ fHandle .CloseFile ();
130+ }
131+ }
132+ Print (duplicates );
133+ return allClasses ;
134+ }
43135
136+ // -----------------------------------------------------------------------------------------------------------
137+ static void TestFunc (int in )
138+ {
139+ string valueStr = in .ToString ();
140+ typename type = int ;
141+ string typeStr = type .ToString ();
142+ Print (typeStr + " " + valueStr );
143+ }
144+ static void TestFunc (float in )
145+ {
146+ string valueStr = in .ToString ();
147+ typename type = float ;
148+ string typeStr = type .ToString ();
149+ Print (typeStr + " " + valueStr );
150+ }
151+ static void TestFunc (bool in )
152+ {
153+ string valueStr = in .ToString ();
154+ typename type = bool ;
155+ string typeStr = type .ToString ();
156+ Print (typeStr + " " + valueStr );
157+ }
158+ static void TestFunc (string in )
159+ {
160+ string valueStr = in ;
161+ typename type = string ;
162+ string typeStr = type .ToString ();
163+ Print (typeStr + " " + valueStr );
164+ }
165+ static void TestFunc (vector in )
166+ {
167+ string valueStr = in .ToString ();
168+ typename type = vector ;
169+ string typeStr = type .ToString ();
170+ Print (typeStr + " " + valueStr );
171+ }
172+ static void TestFunc (Class in )
173+ {
174+ string valueStr = in .ToString ();
175+ typename type = in .ClassName ().ToType ();
176+ string typeStr = type .ToString ();
177+ Print (typeStr + " " + valueStr );
178+ }
179+ static void TestFunc (typename in )
180+ {
181+ string valueStr = in .ToString ();
182+ typename type = in ;
183+ string typeStr = type .ToString ();
184+ Print (typeStr + " " + valueStr );
185+ }
44186
45187 // -----------------------------------------------------------------------------------------------------------
46- static ESE_Type TypeOf (int in )
188+ static ESE_Type < int > TypeOf (int in )
47189 {
48- ESE_Type T = new ESE_Type ( );
190+ ESE_Type < int > T = new ESE_Type < int > ( in );
49191 T .Type = int ; T .BaseType = int ;
50192 T .IsByRef = false; T .IsArray = false; T .IsClass = false; T .IsEnum = false;
51193 T .Name = in .ToString ();
52194 return T ;
53195 }
54- static ESE_Type TypeOf (float in )
196+ static ESE_Type < float > TypeOf (float in )
55197 {
56- ESE_Type T = new ESE_Type ( );
198+ ESE_Type < float > T = new ESE_Type < float > ( in );
57199 T .Type = float ; T .BaseType = float ;
58200 T .IsByRef = false; T .IsArray = false; T .IsClass = false; T .IsEnum = false;
59201 T .Name = in .ToString ();
60202 return T ;
61203 }
62- static ESE_Type TypeOf (bool in )
204+ static ESE_Type < bool > TypeOf (bool in )
63205 {
64- ESE_Type T = new ESE_Type ( );
206+ ESE_Type < bool > T = new ESE_Type < bool > ( in );
65207 T .Type = bool ; T .BaseType = bool ;
66208 T .IsByRef = false; T .IsArray = false; T .IsClass = false; T .IsEnum = false;
67209 T .Name = in .ToString ();
68210 return T ;
69211 }
70- static ESE_Type TypeOf (string in )
212+ static ESE_Type < string > TypeOf (string in )
71213 {
72- ESE_Type T = new ESE_Type ( );
214+ ESE_Type < string > T = new ESE_Type < string > ( in );
73215 T .Type = string ; T .BaseType = string ;
74216 T .IsByRef = false; T .IsArray = false; T .IsClass = false; T .IsEnum = false;
75217 T .Name = in ;
76218 return T ;
77219 }
78- static ESE_Type TypeOf (vector in )
220+ static ESE_Type < vector > TypeOf (vector in )
79221 {
80- ESE_Type T = new ESE_Type ( );
222+ ESE_Type < vector > T = new ESE_Type < vector > ( in );
81223 T .Type = vector ; T .BaseType = vector ;
82224 T .IsByRef = false; T .IsArray = false; T .IsClass = false; T .IsEnum = false;
83225 T .Name = in .ToString ();
84226 return T ;
85227 }
86- static ESE_Type TypeOf (Class in )
228+ static ESE_Type < Class > TypeOf (Class in )
87229 {
88- ESE_Type T = new ESE_Type ( );
230+ ESE_Type < Class > T = new ESE_Type < Class > ( in );
89231 T .Type = Class ; T .BaseType = Class ;
90232 T .IsByRef = true; T .IsArray = false; T .IsClass = true; T .IsEnum = false;
91233 T .Name = in .ToString ();
92234 return T ;
93235 }
94- static ESE_Type TypeOf (typename in )
236+ static ESE_Type < typename > TypeOf (typename in )
95237 {
96- ESE_Type T = new ESE_Type ( );
238+ ESE_Type < typename > T = new ESE_Type < typename > ( in );
97239 T .Type = typename ; T .BaseType = typename ;
98240 T .IsByRef = false; T .IsArray = false; T .IsClass = false; T .IsEnum = false;
99241 T .Name = in .ToString ();
0 commit comments