77using ReClassNET . Extensions ;
88using ReClassNET . Logger ;
99using ReClassNET . Nodes ;
10+ using ReClassNET . Project ;
1011using ReClassNET . UI ;
1112
1213namespace ReClassNET . CodeGenerator
@@ -47,30 +48,7 @@ private static ICustomCppCodeGenerator GetCustomCodeGeneratorForNode(BaseNode no
4748
4849 #endregion
4950
50- private static readonly Dictionary < Type , string > nodeTypeToTypeDefinationMap = new Dictionary < Type , string >
51- {
52- [ typeof ( BoolNode ) ] = Program . Settings . TypeBool ,
53- [ typeof ( DoubleNode ) ] = Program . Settings . TypeDouble ,
54- [ typeof ( FloatNode ) ] = Program . Settings . TypeFloat ,
55- [ typeof ( FunctionPtrNode ) ] = Program . Settings . TypeFunctionPtr ,
56- [ typeof ( Int8Node ) ] = Program . Settings . TypeInt8 ,
57- [ typeof ( Int16Node ) ] = Program . Settings . TypeInt16 ,
58- [ typeof ( Int32Node ) ] = Program . Settings . TypeInt32 ,
59- [ typeof ( Int64Node ) ] = Program . Settings . TypeInt64 ,
60- [ typeof ( Matrix3x3Node ) ] = Program . Settings . TypeMatrix3x3 ,
61- [ typeof ( Matrix3x4Node ) ] = Program . Settings . TypeMatrix3x4 ,
62- [ typeof ( Matrix4x4Node ) ] = Program . Settings . TypeMatrix4x4 ,
63- [ typeof ( UInt8Node ) ] = Program . Settings . TypeUInt8 ,
64- [ typeof ( UInt16Node ) ] = Program . Settings . TypeUInt16 ,
65- [ typeof ( UInt32Node ) ] = Program . Settings . TypeUInt32 ,
66- [ typeof ( UInt64Node ) ] = Program . Settings . TypeUInt64 ,
67- [ typeof ( Utf8CharacterNode ) ] = Program . Settings . TypeUTF8Text ,
68- [ typeof ( Utf16CharacterNode ) ] = Program . Settings . TypeUTF16Text ,
69- [ typeof ( Utf32CharacterNode ) ] = Program . Settings . TypeUTF32Text ,
70- [ typeof ( Vector2Node ) ] = Program . Settings . TypeVector2 ,
71- [ typeof ( Vector3Node ) ] = Program . Settings . TypeVector3 ,
72- [ typeof ( Vector4Node ) ] = Program . Settings . TypeVector4
73- } ;
51+ private readonly Dictionary < Type , string > nodeTypeToTypeDefinationMap ;
7452
7553 #region HelperNodes
7654
@@ -102,6 +80,34 @@ private class Utf32CharacterNode : BaseNode
10280
10381 public Language Language => Language . Cpp ;
10482
83+ public CppCodeGenerator ( CppTypeMapping typeMapping )
84+ {
85+ nodeTypeToTypeDefinationMap = new Dictionary < Type , string >
86+ {
87+ [ typeof ( BoolNode ) ] = typeMapping . TypeBool ,
88+ [ typeof ( DoubleNode ) ] = typeMapping . TypeDouble ,
89+ [ typeof ( FloatNode ) ] = typeMapping . TypeFloat ,
90+ [ typeof ( FunctionPtrNode ) ] = typeMapping . TypeFunctionPtr ,
91+ [ typeof ( Int8Node ) ] = typeMapping . TypeInt8 ,
92+ [ typeof ( Int16Node ) ] = typeMapping . TypeInt16 ,
93+ [ typeof ( Int32Node ) ] = typeMapping . TypeInt32 ,
94+ [ typeof ( Int64Node ) ] = typeMapping . TypeInt64 ,
95+ [ typeof ( Matrix3x3Node ) ] = typeMapping . TypeMatrix3x3 ,
96+ [ typeof ( Matrix3x4Node ) ] = typeMapping . TypeMatrix3x4 ,
97+ [ typeof ( Matrix4x4Node ) ] = typeMapping . TypeMatrix4x4 ,
98+ [ typeof ( UInt8Node ) ] = typeMapping . TypeUInt8 ,
99+ [ typeof ( UInt16Node ) ] = typeMapping . TypeUInt16 ,
100+ [ typeof ( UInt32Node ) ] = typeMapping . TypeUInt32 ,
101+ [ typeof ( UInt64Node ) ] = typeMapping . TypeUInt64 ,
102+ [ typeof ( Utf8CharacterNode ) ] = typeMapping . TypeUtf8Text ,
103+ [ typeof ( Utf16CharacterNode ) ] = typeMapping . TypeUtf16Text ,
104+ [ typeof ( Utf32CharacterNode ) ] = typeMapping . TypeUtf32Text ,
105+ [ typeof ( Vector2Node ) ] = typeMapping . TypeVector2 ,
106+ [ typeof ( Vector3Node ) ] = typeMapping . TypeVector3 ,
107+ [ typeof ( Vector4Node ) ] = typeMapping . TypeVector4
108+ } ;
109+ }
110+
105111 public string GenerateCode ( IEnumerable < ClassNode > classes , ILogger logger )
106112 {
107113 var classNodes = classes as IList < ClassNode > ?? classes . ToList ( ) ;
@@ -212,7 +218,7 @@ private static IEnumerable<ClassNode> YieldReversedHierarchy(ClassNode node, ISe
212218 . Append ( node ) ;
213219 }
214220
215- private static IEnumerable < string > GetTypeDeclerationsForNodes ( IEnumerable < BaseNode > members , ILogger logger )
221+ private IEnumerable < string > GetTypeDeclerationsForNodes ( IEnumerable < BaseNode > members , ILogger logger )
216222 {
217223 Contract . Requires ( members != null ) ;
218224 Contract . Requires ( Contract . ForAll ( members , m => m != null ) ) ;
@@ -274,7 +280,7 @@ BaseNode CreatePaddingMember(int offset, int count)
274280 }
275281 }
276282
277- private static string GetTypeDefinition ( BaseNode node , ILogger logger )
283+ private string GetTypeDefinition ( BaseNode node , ILogger logger )
278284 {
279285 var custom = GetCustomCodeGeneratorForNode ( node ) ;
280286 if ( custom != null )
@@ -295,7 +301,7 @@ private static string GetTypeDefinition(BaseNode node, ILogger logger)
295301 return null ;
296302 }
297303
298- private static string GetTypeDeclerationForNode ( BaseNode node , ILogger logger )
304+ private string GetTypeDeclerationForNode ( BaseNode node , ILogger logger )
299305 {
300306 var transformedNode = TransformNode ( node ) ;
301307
@@ -319,7 +325,7 @@ private static string GetTypeDeclerationForNode(BaseNode node, ILogger logger)
319325 return null ;
320326 }
321327
322- private static string ResolveWrappedType ( BaseNode node , bool isAnonymousExpression , ILogger logger )
328+ private string ResolveWrappedType ( BaseNode node , bool isAnonymousExpression , ILogger logger )
323329 {
324330 Contract . Requires ( node != null ) ;
325331
0 commit comments