Skip to content

Commit 12381e0

Browse files
committed
Add support for code generation.
1 parent be778fd commit 12381e0

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

ReClass.NET/CodeGenerator/CSharpCodeGenerator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ public class CSharpCodeGenerator : ICodeGenerator
2222
[typeof(Int16Node)] = "short",
2323
[typeof(Int32Node)] = "int",
2424
[typeof(Int64Node)] = "long",
25+
[typeof(NIntNode)] = "IntPtr",
2526
[typeof(UInt8Node)] = "byte",
2627
[typeof(UInt16Node)] = "ushort",
2728
[typeof(UInt32Node)] = "uint",
2829
[typeof(UInt64Node)] = "ulong",
30+
[typeof(NUIntNode)] = "UIntPtr",
2931

3032
[typeof(FunctionPtrNode)] = "IntPtr",
3133
[typeof(Utf8TextPtrNode)] = "IntPtr",

ReClass.NET/CodeGenerator/CppCodeGenerator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,15 @@ public CppCodeGenerator(CppTypeMapping typeMapping)
136136
[typeof(Int16Node)] = typeMapping.TypeInt16,
137137
[typeof(Int32Node)] = typeMapping.TypeInt32,
138138
[typeof(Int64Node)] = typeMapping.TypeInt64,
139+
[typeof(NIntNode)] = typeMapping.TypeNInt,
139140
[typeof(Matrix3x3Node)] = typeMapping.TypeMatrix3x3,
140141
[typeof(Matrix3x4Node)] = typeMapping.TypeMatrix3x4,
141142
[typeof(Matrix4x4Node)] = typeMapping.TypeMatrix4x4,
142143
[typeof(UInt8Node)] = typeMapping.TypeUInt8,
143144
[typeof(UInt16Node)] = typeMapping.TypeUInt16,
144145
[typeof(UInt32Node)] = typeMapping.TypeUInt32,
145146
[typeof(UInt64Node)] = typeMapping.TypeUInt64,
147+
[typeof(NUIntNode)] = typeMapping.TypeNUInt,
146148
[typeof(Utf8CharacterNode)] = typeMapping.TypeUtf8Text,
147149
[typeof(Utf16CharacterNode)] = typeMapping.TypeUtf16Text,
148150
[typeof(Utf32CharacterNode)] = typeMapping.TypeUtf32Text,

ReClass.NET/Project/CppTypeMapping.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Xml.Linq;
1+
using System.Xml.Linq;
22
using ReClassNET.Util;
33

44
namespace ReClassNET.Project
@@ -11,11 +11,13 @@ public class CppTypeMapping
1111
public string TypeInt16 { get; set; } = "int16_t";
1212
public string TypeInt32 { get; set; } = "int32_t";
1313
public string TypeInt64 { get; set; } = "int64_t";
14+
public string TypeNInt { get; set; } = "ptrdiff_t";
1415

1516
public string TypeUInt8 { get; set; } = "uint8_t";
1617
public string TypeUInt16 { get; set; } = "uint16_t";
1718
public string TypeUInt32 { get; set; } = "uint32_t";
1819
public string TypeUInt64 { get; set; } = "uint64_t";
20+
public string TypeNUInt { get; set; } = "size_t";
1921

2022
public string TypeFloat { get; set; } = "float";
2123
public string TypeDouble { get; set; } = "double";
@@ -43,10 +45,12 @@ internal XElement Serialize(string name)
4345
XElementSerializer.ToXml(nameof(TypeInt16), TypeInt16),
4446
XElementSerializer.ToXml(nameof(TypeInt32), TypeInt32),
4547
XElementSerializer.ToXml(nameof(TypeInt64), TypeInt64),
48+
XElementSerializer.ToXml(nameof(TypeNInt), TypeNInt),
4649
XElementSerializer.ToXml(nameof(TypeUInt8), TypeUInt8),
4750
XElementSerializer.ToXml(nameof(TypeUInt16), TypeUInt16),
4851
XElementSerializer.ToXml(nameof(TypeUInt32), TypeUInt32),
4952
XElementSerializer.ToXml(nameof(TypeUInt64), TypeUInt64),
53+
XElementSerializer.ToXml(nameof(TypeNUInt), TypeNUInt),
5054
XElementSerializer.ToXml(nameof(TypeFloat), TypeFloat),
5155
XElementSerializer.ToXml(nameof(TypeDouble), TypeDouble),
5256
XElementSerializer.ToXml(nameof(TypeVector2), TypeVector2),
@@ -69,10 +73,12 @@ internal void Deserialize(XElement element)
6973
XElementSerializer.TryRead(element, nameof(TypeInt16), e => TypeInt16 = XElementSerializer.ToString(e));
7074
XElementSerializer.TryRead(element, nameof(TypeInt32), e => TypeInt32 = XElementSerializer.ToString(e));
7175
XElementSerializer.TryRead(element, nameof(TypeInt64), e => TypeInt64 = XElementSerializer.ToString(e));
76+
XElementSerializer.TryRead(element, nameof(TypeNInt), e => TypeNInt = XElementSerializer.ToString(e));
7277
XElementSerializer.TryRead(element, nameof(TypeUInt8), e => TypeUInt8 = XElementSerializer.ToString(e));
7378
XElementSerializer.TryRead(element, nameof(TypeUInt16), e => TypeUInt16 = XElementSerializer.ToString(e));
7479
XElementSerializer.TryRead(element, nameof(TypeUInt32), e => TypeUInt32 = XElementSerializer.ToString(e));
7580
XElementSerializer.TryRead(element, nameof(TypeUInt64), e => TypeUInt64 = XElementSerializer.ToString(e));
81+
XElementSerializer.TryRead(element, nameof(TypeNUInt), e => TypeNUInt = XElementSerializer.ToString(e));
7682
XElementSerializer.TryRead(element, nameof(TypeFloat), e => TypeFloat = XElementSerializer.ToString(e));
7783
XElementSerializer.TryRead(element, nameof(TypeDouble), e => TypeDouble = XElementSerializer.ToString(e));
7884
XElementSerializer.TryRead(element, nameof(TypeVector2), e => TypeVector2 = XElementSerializer.ToString(e));

0 commit comments

Comments
 (0)