mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
ZoneCodeGenerator: Make Usages PostProcessor only add usages when a member is used and not ignored
This commit is contained in:
parent
c547520ae8
commit
b79f237014
@ -1,40 +1,60 @@
|
|||||||
using System.Linq;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using ZoneCodeGenerator.Domain;
|
using ZoneCodeGenerator.Domain;
|
||||||
|
using ZoneCodeGenerator.Domain.Information;
|
||||||
using ZoneCodeGenerator.Persistence;
|
using ZoneCodeGenerator.Persistence;
|
||||||
|
|
||||||
namespace ZoneCodeGenerator.Parsing.CommandFile.PostProcessor
|
namespace ZoneCodeGenerator.Parsing.CommandFile.PostProcessor
|
||||||
{
|
{
|
||||||
class PostProcessorUsages : IDataPostProcessor
|
class PostProcessorUsages : IDataPostProcessor
|
||||||
{
|
{
|
||||||
public bool PostProcess(IDataRepository repository)
|
private static bool ProcessAsset(StructureInformation assetStructure)
|
||||||
{
|
{
|
||||||
foreach (var dataTypeWithMembers in repository.GetAllStructs()
|
var processedAssets = new HashSet<StructureInformation>();
|
||||||
.AsEnumerable<DataTypeWithMembers>()
|
var processingQueue = new Queue<StructureInformation>();
|
||||||
.Concat(repository.GetAllUnions()))
|
processingQueue.Enqueue(assetStructure);
|
||||||
|
|
||||||
|
while (processingQueue.Count != 0)
|
||||||
{
|
{
|
||||||
var information = repository.GetInformationFor(dataTypeWithMembers);
|
var currentStructure = processingQueue.Dequeue();
|
||||||
|
|
||||||
foreach (var memberInformation in information.OrderedMembers)
|
if (!processedAssets.Add(currentStructure))
|
||||||
{
|
{
|
||||||
if (memberInformation.StructureType == null) continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
memberInformation.StructureType.Usages.Add(information);
|
foreach (var member in currentStructure.OrderedMembers
|
||||||
|
.Where(member => member.StructureType != null)
|
||||||
|
.Where(member => !member.Computations.ShouldIgnore))
|
||||||
|
{
|
||||||
|
if (member.Computations.IsNonEmbeddedReference)
|
||||||
|
member.StructureType.NonEmbeddedReferenceExists = true;
|
||||||
|
|
||||||
if (memberInformation.Computations.IsNonEmbeddedReference)
|
if (member.Computations.IsSinglePointerReference)
|
||||||
memberInformation.StructureType.NonEmbeddedReferenceExists = true;
|
member.StructureType.SinglePointerReferenceExists = true;
|
||||||
|
|
||||||
if (memberInformation.Computations.IsSinglePointerReference)
|
if (member.Computations.IsArrayPointerReference)
|
||||||
memberInformation.StructureType.SinglePointerReferenceExists = true;
|
member.StructureType.ArrayPointerReferenceExists = true;
|
||||||
|
|
||||||
if (memberInformation.Computations.IsArrayPointerReference)
|
if (member.Computations.IsArrayReference)
|
||||||
memberInformation.StructureType.ArrayPointerReferenceExists = true;
|
member.StructureType.ArrayReferenceExists = true;
|
||||||
|
|
||||||
if (memberInformation.Computations.IsArrayReference)
|
member.StructureType.Usages.Add(currentStructure);
|
||||||
memberInformation.StructureType.ArrayReferenceExists = true;
|
processingQueue.Enqueue(member.StructureType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool PostProcess(IDataRepository repository)
|
||||||
|
{
|
||||||
|
return repository.GetAllStructs()
|
||||||
|
.AsEnumerable<DataTypeWithMembers>()
|
||||||
|
.Concat(repository.GetAllUnions())
|
||||||
|
.Select(repository.GetInformationFor)
|
||||||
|
.Where(information => information.IsAsset)
|
||||||
|
.All(ProcessAsset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user