C++: Include primitive types in reserved name list
This commit is contained in:
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Il2CppInspector.Cpp
|
namespace Il2CppInspector.Cpp
|
||||||
{
|
{
|
||||||
@@ -31,6 +30,14 @@ namespace Il2CppInspector.Cpp
|
|||||||
renameCount[name] = 0;
|
renameCount[name] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to mark a name as reserved without assigning an object to it (e.g. for keywords and built-in names)
|
||||||
|
public bool TryReserveName(string name) {
|
||||||
|
if (renameCount.ContainsKey(name))
|
||||||
|
return false;
|
||||||
|
renameCount[name] = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a Namer object which will give names to objects of type T which are unique within this namespace
|
// Create a Namer object which will give names to objects of type T which are unique within this namespace
|
||||||
public Namer<T> MakeNamer<T>(Namer<T>.KeyFunc keyFunc) {
|
public Namer<T> MakeNamer<T>(Namer<T>.KeyFunc keyFunc) {
|
||||||
return new Namer<T>(this, keyFunc);
|
return new Namer<T>(this, keyFunc);
|
||||||
|
|||||||
@@ -577,29 +577,24 @@ namespace Il2CppInspector.Cpp
|
|||||||
cppTypes.SetGroup("il2cpp");
|
cppTypes.SetGroup("il2cpp");
|
||||||
|
|
||||||
// Add junk from config files we haven't included
|
// Add junk from config files we haven't included
|
||||||
|
// TODO: Remove these two lines when resolving #79
|
||||||
cppTypes.TypedefAliases.Add("Il2CppIManagedObjectHolder", cppTypes["void"].AsPointer(wordSize));
|
cppTypes.TypedefAliases.Add("Il2CppIManagedObjectHolder", cppTypes["void"].AsPointer(wordSize));
|
||||||
cppTypes.TypedefAliases.Add("Il2CppIUnknown", cppTypes["void"].AsPointer(wordSize));
|
cppTypes.TypedefAliases.Add("Il2CppIUnknown", cppTypes["void"].AsPointer(wordSize));
|
||||||
|
|
||||||
var headers = header.GetTypeHeaderText(wordSize);
|
var headers = header.GetTypeHeaderText(wordSize);
|
||||||
cppTypes.AddFromDeclarationText(headers);
|
cppTypes.AddFromDeclarationText(headers);
|
||||||
|
|
||||||
// Don't allow any of the header type names to be re-used; ignore primitive types
|
|
||||||
foreach (var type in cppTypes.GetTypeGroup("il2cpp"))
|
|
||||||
declGen?.TypeNamespace.ReserveName(type.Name);
|
|
||||||
|
|
||||||
foreach (var typedef in cppTypes.GetTypedefGroup("il2cpp"))
|
|
||||||
declGen?.GlobalsNamespace.ReserveName(typedef.Name);
|
|
||||||
|
|
||||||
cppTypes.SetGroup("il2cpp-api");
|
cppTypes.SetGroup("il2cpp-api");
|
||||||
|
|
||||||
var apis = header.GetAPIHeaderTypedefText();
|
var apis = header.GetAPIHeaderTypedefText();
|
||||||
cppTypes.AddFromDeclarationText(apis);
|
cppTypes.AddFromDeclarationText(apis);
|
||||||
|
|
||||||
foreach (var type in cppTypes.GetTypeGroup("il2cpp-api"))
|
// Don't allow any of the header type names or primitive type names to be re-used
|
||||||
declGen?.TypeNamespace.ReserveName(type.Name);
|
foreach (var type in cppTypes.Types.Values)
|
||||||
|
declGen?.TypeNamespace.TryReserveName(type.Name);
|
||||||
|
|
||||||
foreach (var typedef in cppTypes.GetTypedefGroup("il2cpp-api"))
|
foreach (var typedef in cppTypes.TypedefAliases.Values)
|
||||||
declGen?.GlobalsNamespace.ReserveName(typedef.Name);
|
declGen?.GlobalsNamespace.TryReserveName(typedef.Name);
|
||||||
|
|
||||||
cppTypes.SetGroup("");
|
cppTypes.SetGroup("");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user