|
| 1 | +using System.Xml.Linq; |
| 2 | +using ReClassNET.Util; |
| 3 | + |
| 4 | +namespace ReClassNET.Project |
| 5 | +{ |
| 6 | + public class CppTypeMapping |
| 7 | + { |
| 8 | + public string TypeBool { get; set; } = "bool"; |
| 9 | + |
| 10 | + public string TypeInt8 { get; set; } = "int8_t"; |
| 11 | + public string TypeInt16 { get; set; } = "int16_t"; |
| 12 | + public string TypeInt32 { get; set; } = "int32_t"; |
| 13 | + public string TypeInt64 { get; set; } = "int64_t"; |
| 14 | + |
| 15 | + public string TypeUInt8 { get; set; } = "uint8_t"; |
| 16 | + public string TypeUInt16 { get; set; } = "uint16_t"; |
| 17 | + public string TypeUInt32 { get; set; } = "uint32_t"; |
| 18 | + public string TypeUInt64 { get; set; } = "uint64_t"; |
| 19 | + |
| 20 | + public string TypeFloat { get; set; } = "float"; |
| 21 | + public string TypeDouble { get; set; } = "double"; |
| 22 | + |
| 23 | + public string TypeVector2 { get; set; } = "Vector2"; |
| 24 | + public string TypeVector3 { get; set; } = "Vector3"; |
| 25 | + public string TypeVector4 { get; set; } = "Vector4"; |
| 26 | + |
| 27 | + public string TypeMatrix3x3 { get; set; } = "Matrix3x3"; |
| 28 | + public string TypeMatrix3x4 { get; set; } = "Matrix3x4"; |
| 29 | + public string TypeMatrix4x4 { get; set; } = "Matrix4x4"; |
| 30 | + |
| 31 | + public string TypeUtf8Text { get; set; } = "char"; |
| 32 | + public string TypeUtf16Text { get; set; } = "wchar_t"; // Should be char16_t, but this type isn't well supported at the moment. |
| 33 | + public string TypeUtf32Text { get; set; } = "char32_t"; |
| 34 | + |
| 35 | + public string TypeFunctionPtr { get; set; } = "void*"; |
| 36 | + |
| 37 | + internal XElement Serialize(string name) |
| 38 | + { |
| 39 | + return new XElement( |
| 40 | + name, |
| 41 | + XElementSerializer.ToXml(nameof(TypeBool), TypeBool), |
| 42 | + XElementSerializer.ToXml(nameof(TypeInt8), TypeInt8), |
| 43 | + XElementSerializer.ToXml(nameof(TypeInt16), TypeInt16), |
| 44 | + XElementSerializer.ToXml(nameof(TypeInt32), TypeInt32), |
| 45 | + XElementSerializer.ToXml(nameof(TypeInt64), TypeInt64), |
| 46 | + XElementSerializer.ToXml(nameof(TypeUInt8), TypeUInt8), |
| 47 | + XElementSerializer.ToXml(nameof(TypeUInt16), TypeUInt16), |
| 48 | + XElementSerializer.ToXml(nameof(TypeUInt32), TypeUInt32), |
| 49 | + XElementSerializer.ToXml(nameof(TypeUInt64), TypeUInt64), |
| 50 | + XElementSerializer.ToXml(nameof(TypeFloat), TypeFloat), |
| 51 | + XElementSerializer.ToXml(nameof(TypeDouble), TypeDouble), |
| 52 | + XElementSerializer.ToXml(nameof(TypeVector2), TypeVector2), |
| 53 | + XElementSerializer.ToXml(nameof(TypeVector3), TypeVector3), |
| 54 | + XElementSerializer.ToXml(nameof(TypeVector4), TypeVector4), |
| 55 | + XElementSerializer.ToXml(nameof(TypeMatrix3x3), TypeMatrix3x3), |
| 56 | + XElementSerializer.ToXml(nameof(TypeMatrix3x4), TypeMatrix3x4), |
| 57 | + XElementSerializer.ToXml(nameof(TypeMatrix4x4), TypeMatrix4x4), |
| 58 | + XElementSerializer.ToXml(nameof(TypeUtf8Text), TypeUtf8Text), |
| 59 | + XElementSerializer.ToXml(nameof(TypeUtf16Text), TypeUtf16Text), |
| 60 | + XElementSerializer.ToXml(nameof(TypeUtf32Text), TypeUtf32Text), |
| 61 | + XElementSerializer.ToXml(nameof(TypeFunctionPtr), TypeFunctionPtr) |
| 62 | + ); |
| 63 | + } |
| 64 | + |
| 65 | + internal void Deserialize(XElement element) |
| 66 | + { |
| 67 | + XElementSerializer.TryRead(element, nameof(TypeBool), e => TypeBool = XElementSerializer.ToString(e)); |
| 68 | + XElementSerializer.TryRead(element, nameof(TypeInt8), e => TypeInt8 = XElementSerializer.ToString(e)); |
| 69 | + XElementSerializer.TryRead(element, nameof(TypeInt16), e => TypeInt16 = XElementSerializer.ToString(e)); |
| 70 | + XElementSerializer.TryRead(element, nameof(TypeInt32), e => TypeInt32 = XElementSerializer.ToString(e)); |
| 71 | + XElementSerializer.TryRead(element, nameof(TypeInt64), e => TypeInt64 = XElementSerializer.ToString(e)); |
| 72 | + XElementSerializer.TryRead(element, nameof(TypeUInt8), e => TypeUInt8 = XElementSerializer.ToString(e)); |
| 73 | + XElementSerializer.TryRead(element, nameof(TypeUInt16), e => TypeUInt16 = XElementSerializer.ToString(e)); |
| 74 | + XElementSerializer.TryRead(element, nameof(TypeUInt32), e => TypeUInt32 = XElementSerializer.ToString(e)); |
| 75 | + XElementSerializer.TryRead(element, nameof(TypeUInt64), e => TypeUInt64 = XElementSerializer.ToString(e)); |
| 76 | + XElementSerializer.TryRead(element, nameof(TypeFloat), e => TypeFloat = XElementSerializer.ToString(e)); |
| 77 | + XElementSerializer.TryRead(element, nameof(TypeDouble), e => TypeDouble = XElementSerializer.ToString(e)); |
| 78 | + XElementSerializer.TryRead(element, nameof(TypeVector2), e => TypeVector2 = XElementSerializer.ToString(e)); |
| 79 | + XElementSerializer.TryRead(element, nameof(TypeVector3), e => TypeVector3 = XElementSerializer.ToString(e)); |
| 80 | + XElementSerializer.TryRead(element, nameof(TypeVector4), e => TypeVector4 = XElementSerializer.ToString(e)); |
| 81 | + XElementSerializer.TryRead(element, nameof(TypeMatrix3x3), e => TypeMatrix3x3 = XElementSerializer.ToString(e)); |
| 82 | + XElementSerializer.TryRead(element, nameof(TypeMatrix3x4), e => TypeMatrix3x4 = XElementSerializer.ToString(e)); |
| 83 | + XElementSerializer.TryRead(element, nameof(TypeMatrix4x4), e => TypeMatrix4x4 = XElementSerializer.ToString(e)); |
| 84 | + XElementSerializer.TryRead(element, nameof(TypeUtf8Text), e => TypeUtf8Text = XElementSerializer.ToString(e)); |
| 85 | + XElementSerializer.TryRead(element, nameof(TypeUtf16Text), e => TypeUtf16Text = XElementSerializer.ToString(e)); |
| 86 | + XElementSerializer.TryRead(element, nameof(TypeUtf32Text), e => TypeUtf32Text = XElementSerializer.ToString(e)); |
| 87 | + XElementSerializer.TryRead(element, nameof(TypeFunctionPtr), e => TypeFunctionPtr = XElementSerializer.ToString(e)); |
| 88 | + } |
| 89 | + } |
| 90 | +} |
0 commit comments