mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
ZoneCodeGenerator: Fix forward declarations not being resolved for typedefs
This commit is contained in:
parent
ffda895f95
commit
42e571427b
@ -78,8 +78,9 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Impl
|
|||||||
{
|
{
|
||||||
var existingForwardDeclaration = forwardDeclarations[forwardDeclaration.FullName];
|
var existingForwardDeclaration = forwardDeclarations[forwardDeclaration.FullName];
|
||||||
|
|
||||||
if(existingForwardDeclaration.Type != forwardDeclaration.Type)
|
if (existingForwardDeclaration.Type != forwardDeclaration.Type)
|
||||||
throw new ParserException($"Forward declaration of type '{forwardDeclaration.FullName}' already done with different type.");
|
throw new ParserException(
|
||||||
|
$"Forward declaration of type '{forwardDeclaration.FullName}' already done with different type.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -91,7 +92,8 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Impl
|
|||||||
{
|
{
|
||||||
var currentNamespaceTypename = Namespace.Combine(CurrentNamespace, typename);
|
var currentNamespaceTypename = Namespace.Combine(CurrentNamespace, typename);
|
||||||
|
|
||||||
var baseType = DataTypeBaseType.BASE_TYPES.FirstOrDefault(databaseBaseType => databaseBaseType.Name.Equals(typename));
|
var baseType =
|
||||||
|
DataTypeBaseType.BASE_TYPES.FirstOrDefault(databaseBaseType => databaseBaseType.Name.Equals(typename));
|
||||||
|
|
||||||
if (baseType != null)
|
if (baseType != null)
|
||||||
return baseType;
|
return baseType;
|
||||||
@ -121,7 +123,7 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Impl
|
|||||||
|
|
||||||
public EnumMember FindEnumMember(string enumMemberName)
|
public EnumMember FindEnumMember(string enumMemberName)
|
||||||
{
|
{
|
||||||
foreach(var block in blockStack)
|
foreach (var block in blockStack)
|
||||||
{
|
{
|
||||||
if (!(block is BlockEnum blockEnum)) continue;
|
if (!(block is BlockEnum blockEnum)) continue;
|
||||||
|
|
||||||
@ -147,7 +149,7 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Impl
|
|||||||
|
|
||||||
private void ResolveForwardDeclarations()
|
private void ResolveForwardDeclarations()
|
||||||
{
|
{
|
||||||
foreach(var forwardDeclaration in forwardDeclarations.Values)
|
foreach (var forwardDeclaration in forwardDeclarations.Values)
|
||||||
{
|
{
|
||||||
var foundType = FindType(forwardDeclaration.FullName);
|
var foundType = FindType(forwardDeclaration.FullName);
|
||||||
|
|
||||||
@ -159,19 +161,25 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Impl
|
|||||||
|
|
||||||
foreach (var dataType in dataTypes.Values)
|
foreach (var dataType in dataTypes.Values)
|
||||||
{
|
{
|
||||||
if (!(dataType is DataTypeWithMembers dataTypeWithMembers)) continue;
|
if (dataType is DataTypeWithMembers dataTypeWithMembers)
|
||||||
|
|
||||||
foreach (var variable in dataTypeWithMembers.Members)
|
|
||||||
{
|
{
|
||||||
if (variable.VariableType.Type is ForwardDeclaration forwardDeclaration)
|
foreach (var variable in dataTypeWithMembers.Members)
|
||||||
variable.VariableType.Type = forwardDeclaration.ForwardedType;
|
{
|
||||||
|
if (variable.VariableType.Type is ForwardDeclaration forwardDeclaration)
|
||||||
|
variable.VariableType.Type = forwardDeclaration.ForwardedType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (dataType is DataTypeTypedef typeDef)
|
||||||
|
{
|
||||||
|
if (typeDef.TypeDefinition.Type is ForwardDeclaration forwardDeclaration)
|
||||||
|
typeDef.TypeDefinition.Type = forwardDeclaration.ForwardedType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FinishAndSaveTo(IDataRepository dataRepository)
|
public void FinishAndSaveTo(IDataRepository dataRepository)
|
||||||
{
|
{
|
||||||
if(blockStack.Count > 0)
|
if (blockStack.Count > 0)
|
||||||
throw new ParserException($"Parsing finished but {blockStack.Count} blocks were not closed.");
|
throw new ParserException($"Parsing finished but {blockStack.Count} blocks were not closed.");
|
||||||
|
|
||||||
ResolveForwardDeclarations();
|
ResolveForwardDeclarations();
|
||||||
|
@ -112,7 +112,14 @@ namespace ZoneCodeGenerator.Persistence
|
|||||||
{
|
{
|
||||||
StructureInformation memberStructureInformation = null;
|
StructureInformation memberStructureInformation = null;
|
||||||
|
|
||||||
if (member.VariableType.Type is DataTypeWithMembers memberType)
|
var memberDataType = member.VariableType.Type;
|
||||||
|
|
||||||
|
while (memberDataType is DataTypeTypedef typedef)
|
||||||
|
{
|
||||||
|
memberDataType = typedef.TypeDefinition.Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (memberDataType is DataTypeWithMembers memberType)
|
||||||
{
|
{
|
||||||
memberStructureInformation = GetInformationFor(memberType);
|
memberStructureInformation = GetInformationFor(memberType);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user