mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-07-03 17:51:54 +00:00
ZoneCodeGenerator: Move usages postprocessor to be post commandfile instead of post headerfile
This commit is contained in:
@ -14,6 +14,7 @@ namespace ZoneCodeGenerator.Parsing.CommandFile
|
||||
private static readonly IDataPostProcessor[] postProcessors =
|
||||
{
|
||||
new PostProcessorDefaultBlock(),
|
||||
new PostProcessorUsages(),
|
||||
};
|
||||
|
||||
public static bool ReadFile(string path, CUISession session, bool verbose = false)
|
||||
|
@ -0,0 +1,54 @@
|
||||
using System.Linq;
|
||||
using ZoneCodeGenerator.Domain;
|
||||
using ZoneCodeGenerator.Persistence;
|
||||
|
||||
namespace ZoneCodeGenerator.Parsing.CommandFile.PostProcessor
|
||||
{
|
||||
class PostProcessorUsages : IDataPostProcessor
|
||||
{
|
||||
public bool PostProcess(IDataRepository repository)
|
||||
{
|
||||
foreach (var dataTypeWithMembers in repository.GetAllStructs()
|
||||
.AsEnumerable<DataTypeWithMembers>()
|
||||
.Concat(repository.GetAllUnions()))
|
||||
{
|
||||
var information = repository.GetInformationFor(dataTypeWithMembers);
|
||||
|
||||
foreach (var memberInformation in information.OrderedMembers)
|
||||
{
|
||||
if (memberInformation.StructureType == null) continue;
|
||||
|
||||
memberInformation.StructureType.Usages.Add(information);
|
||||
|
||||
if (IsNonEmbeddedReference(memberInformation.Member))
|
||||
memberInformation.StructureType.NonEmbeddedReferenceExists = true;
|
||||
|
||||
if (IsPointerReference(memberInformation.Member))
|
||||
memberInformation.StructureType.PointerReferenceExists = true;
|
||||
|
||||
if (IsArrayReference(memberInformation.Member))
|
||||
memberInformation.StructureType.PointerReferenceExists = true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool IsNonEmbeddedReference(Variable var)
|
||||
{
|
||||
return var.VariableType.References.Any();
|
||||
}
|
||||
|
||||
private static bool IsPointerReference(Variable var)
|
||||
{
|
||||
return var.VariableType.References.Any()
|
||||
&& var.VariableType.References.Last() is ReferenceTypePointer;
|
||||
}
|
||||
|
||||
private static bool IsArrayReference(Variable var)
|
||||
{
|
||||
return var.VariableType.References.Any()
|
||||
&& var.VariableType.References.Last() is ReferenceTypeArray;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user