Minor re-organization

This commit is contained in:
Katy Coe
2020-06-30 00:13:18 +02:00
parent 18b94e08f3
commit 23db04c369
33 changed files with 27 additions and 27 deletions

View File

@@ -9,7 +9,7 @@ using System.Linq;
using CommandLine; using CommandLine;
using Il2CppInspector.Reflection; using Il2CppInspector.Reflection;
using Il2CppInspector.Outputs; using Il2CppInspector.Outputs;
using Il2CppInspector.CppUtils.UnityHeaders; using Il2CppInspector.Cpp.UnityHeaders;
namespace Il2CppInspector.CLI namespace Il2CppInspector.CLI
{ {

View File

@@ -5,15 +5,15 @@
All rights reserved. All rights reserved.
*/ */
using Il2CppInspector.CppUtils.UnityHeaders;
using Il2CppInspector.Reflection;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Il2CppInspector.Cpp.UnityHeaders;
using Il2CppInspector.Reflection;
namespace Il2CppInspector.CppUtils namespace Il2CppInspector.Cpp
{ {
// Class for generating C header declarations from Reflection objects (TypeInfo, etc.) // Class for generating C header declarations from Reflection objects (TypeInfo, etc.)
public class CppDeclarationGenerator public class CppDeclarationGenerator
@@ -149,7 +149,7 @@ namespace Il2CppInspector.CppUtils
} }
// Generate structure fields for each field of a given type // Generate structure fields for each field of a given type
private void GenerateFieldList(StringBuilder csrc, Namespace ns, TypeInfo ti) { private void GenerateFieldList(StringBuilder csrc, CppNamespace ns, TypeInfo ti) {
var namer = ns.MakeNamer<FieldInfo>((field) => field.Name.ToCIdentifier()); var namer = ns.MakeNamer<FieldInfo>((field) => field.Name.ToCIdentifier());
foreach (var field in ti.DeclaredFields) { foreach (var field in ti.DeclaredFields) {
if (field.IsLiteral || field.IsStatic) if (field.IsLiteral || field.IsStatic)
@@ -222,7 +222,7 @@ namespace Il2CppInspector.CppUtils
* This causes all classes to be aligned to the alignment of their base class. */ * This causes all classes to be aligned to the alignment of their base class. */
TypeInfo firstNonEmpty = null; TypeInfo firstNonEmpty = null;
foreach (var bti in baseClasses) { foreach (var bti in baseClasses) {
if (bti.DeclaredFields.Where((field) => !field.IsStatic && !field.IsLiteral).Any()) { if (bti.DeclaredFields.Any(field => !field.IsStatic && !field.IsLiteral)) {
firstNonEmpty = bti; firstNonEmpty = bti;
break; break;
} }
@@ -577,8 +577,8 @@ namespace Il2CppInspector.CppUtils
} }
// Reserve C/C++ keywords and built-in names // Reserve C/C++ keywords and built-in names
private static Namespace CreateNamespace() { private static CppNamespace CreateNamespace() {
var ns = new Namespace(); var ns = new CppNamespace();
/* Reserve C/C++ keywords */ /* Reserve C/C++ keywords */
foreach (var keyword in new string[] { "_Alignas", "_Alignof", "_Atomic", "_Bool", "_Complex", "_Generic", "_Imaginary", "_Noreturn", "_Static_assert", "_Thread_local", "alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case", "catch", "char", "char16_t", "char32_t", "char8_t", "class", "co_await", "co_return", "co_yield", "compl", "concept", "const", "const_cast", "consteval", "constexpr", "constinit", "continue", "decltype", "default", "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", "float", "for", "friend", "goto", "if", "inline", "int", "long", "mutable", "namespace", "new", "noexcept", "not", "not_eq", "nullptr", "operator", "or", "or_eq", "private", "protected", "public", "reflexpr", "register", "reinterpret_cast", "requires", "restrict", "return", "short", "signed", "sizeof", "static", "static_assert", "static_cast", "struct", "switch", "synchronized", "template", "this", "thread_local", "throw", "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using", "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq" }) { foreach (var keyword in new string[] { "_Alignas", "_Alignof", "_Atomic", "_Bool", "_Complex", "_Generic", "_Imaginary", "_Noreturn", "_Static_assert", "_Thread_local", "alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case", "catch", "char", "char16_t", "char32_t", "char8_t", "class", "co_await", "co_return", "co_yield", "compl", "concept", "const", "const_cast", "consteval", "constexpr", "constinit", "continue", "decltype", "default", "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", "float", "for", "friend", "goto", "if", "inline", "int", "long", "mutable", "namespace", "new", "noexcept", "not", "not_eq", "nullptr", "operator", "or", "or_eq", "private", "protected", "public", "reflexpr", "register", "reinterpret_cast", "requires", "restrict", "return", "short", "signed", "sizeof", "static", "static_assert", "static_cast", "struct", "switch", "synchronized", "template", "this", "thread_local", "throw", "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using", "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq" }) {
ns.ReserveName(keyword); ns.ReserveName(keyword);
@@ -593,16 +593,16 @@ namespace Il2CppInspector.CppUtils
/// <summary> /// <summary>
/// Namespace for all types and typedefs /// Namespace for all types and typedefs
/// </summary> /// </summary>
public Namespace TypeNamespace { get; private set; } public CppNamespace TypeNamespace { get; private set; }
public Namespace.Namer<TypeInfo> TypeNamer { get; private set; } public CppNamespace.Namer<TypeInfo> TypeNamer { get; private set; }
/// <summary> /// <summary>
/// Namespace for global variables, enum values and methods /// Namespace for global variables, enum values and methods
/// </summary> /// </summary>
public Namespace GlobalsNamespace { get; private set; } public CppNamespace GlobalsNamespace { get; private set; }
public Namespace.Namer<MethodBase> GlobalNamer { get; private set; } public CppNamespace.Namer<MethodBase> GlobalNamer { get; private set; }
public Namespace.Namer<FieldInfo> EnumNamer { get; private set; } public CppNamespace.Namer<FieldInfo> EnumNamer { get; private set; }
#endregion #endregion
} }
} }

View File

@@ -9,12 +9,12 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace Il2CppInspector.CppUtils namespace Il2CppInspector.Cpp
{ {
/// <summary> /// <summary>
/// A utility class for managing names in a common namespace. /// A utility class for managing names in a common namespace.
/// </summary> /// </summary>
public class Namespace public class CppNamespace
{ {
// The central data structure that keeps track of which names have been generated // The central data structure that keeps track of which names have been generated
// The value for any given key K is the number of unique objects originally named K, minus 1. // The value for any given key K is the number of unique objects originally named K, minus 1.
@@ -43,7 +43,7 @@ namespace Il2CppInspector.CppUtils
public class Namer<T> public class Namer<T>
{ {
// Parent namespace // Parent namespace
private Namespace ns; private CppNamespace ns;
// Names given out by this Namer. // Names given out by this Namer.
private readonly Dictionary<T, string> names = new Dictionary<T, string>(); private readonly Dictionary<T, string> names = new Dictionary<T, string>();
@@ -53,7 +53,7 @@ namespace Il2CppInspector.CppUtils
public delegate string KeyFunc(T t); public delegate string KeyFunc(T t);
private readonly KeyFunc keyFunc; private readonly KeyFunc keyFunc;
public Namer(Namespace ns, KeyFunc keyFunc) { public Namer(CppNamespace ns, KeyFunc keyFunc) {
this.ns = ns; this.ns = ns;
this.keyFunc = keyFunc; this.keyFunc = keyFunc;
} }

View File

@@ -10,7 +10,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
namespace Il2CppInspector.CppUtils.UnityHeaders namespace Il2CppInspector.Cpp.UnityHeaders
{ {
// Each instance of UnityHeader represents one header file which potentially covers multiple versions of Unity. // Each instance of UnityHeader represents one header file which potentially covers multiple versions of Unity.
public class UnityHeader public class UnityHeader

View File

@@ -8,7 +8,7 @@
using System; using System;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Il2CppInspector.CppUtils.UnityHeaders namespace Il2CppInspector.Cpp.UnityHeaders
{ {
// Parsed representation of a Unity version number, such as 5.3.0f1 or 2019.3.7. // Parsed representation of a Unity version number, such as 5.3.0f1 or 2019.3.7.
public class UnityVersion : IComparable<UnityVersion>, IEquatable<UnityVersion> public class UnityVersion : IComparable<UnityVersion>, IEquatable<UnityVersion>

View File

@@ -10,11 +10,11 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="CppUtils\UnityHeaders\**" /> <None Remove="Cpp\UnityHeaders\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="CppUtils\UnityHeaders\**" /> <EmbeddedResource Include="Cpp\UnityHeaders\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -9,8 +9,8 @@ using System.Linq;
using System.IO; using System.IO;
using System.Text; using System.Text;
using Il2CppInspector.Reflection; using Il2CppInspector.Reflection;
using Il2CppInspector.CppUtils; using Il2CppInspector.Cpp;
using Il2CppInspector.CppUtils.UnityHeaders; using Il2CppInspector.Cpp.UnityHeaders;
namespace Il2CppInspector.Outputs namespace Il2CppInspector.Outputs
{ {
@@ -113,7 +113,7 @@ typedef __int64 int64_t;
declGenerator.IncludeMethod(method); declGenerator.IncludeMethod(method);
writeDecls(declGenerator.GenerateRemainingTypeDeclarations()); writeDecls(declGenerator.GenerateRemainingTypeDeclarations());
var address = method.VirtualAddress.Value.Start; var address = method.VirtualAddress.Value.Start;
writeTypedName(address, declGenerator.GenerateMethodDeclaration(method), declGenerator.MethodNamer.GetName(method)); writeTypedName(address, declGenerator.GenerateMethodDeclaration(method), declGenerator.GlobalNamer.GetName(method));
writeComment(address, method); writeComment(address, method);
} }
} }
@@ -171,7 +171,7 @@ typedef __int64 int64_t;
declGenerator.IncludeMethod(method); declGenerator.IncludeMethod(method);
writeDecls(declGenerator.GenerateRemainingTypeDeclarations()); writeDecls(declGenerator.GenerateRemainingTypeDeclarations());
name = declGenerator.MethodNamer.GetName(method); name = declGenerator.GlobalNamer.GetName(method);
writeTypedName(address, "struct MethodInfo *", $"{name}__MethodInfo"); writeTypedName(address, "struct MethodInfo *", $"{name}__MethodInfo");
writeComment(address, method); writeComment(address, method);
break; break;

View File

@@ -28,7 +28,7 @@ using Il2CppInspector.Outputs;
using Il2CppInspector.Reflection; using Il2CppInspector.Reflection;
using Ookii.Dialogs.Wpf; using Ookii.Dialogs.Wpf;
using Path = System.IO.Path; using Path = System.IO.Path;
using Il2CppInspector.CppUtils.UnityHeaders; using Il2CppInspector.Cpp.UnityHeaders;
namespace Il2CppInspectorGUI namespace Il2CppInspectorGUI
{ {

View File

@@ -6,7 +6,7 @@
*/ */
using System.IO; using System.IO;
using Il2CppInspector.CppUtils.UnityHeaders; using Il2CppInspector.Cpp.UnityHeaders;
using Il2CppInspector.Reflection; using Il2CppInspector.Reflection;
using NUnit.Framework; using NUnit.Framework;