mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
ZoneCodeGenerator: Save whether a structure is anonymous and therefore a name has been generated or not.
This commit is contained in:
parent
f777c049c6
commit
b59ca3b261
@ -16,6 +16,8 @@ namespace ZoneCodeGenerator.Domain
|
||||
|
||||
public List<Variable> Members { get; }
|
||||
|
||||
public bool IsAnonymous { get; set; }
|
||||
|
||||
private bool finalized;
|
||||
public void FinalizeDataType()
|
||||
{
|
||||
@ -30,6 +32,7 @@ namespace ZoneCodeGenerator.Domain
|
||||
Members = new List<Variable>();
|
||||
Pack = pack;
|
||||
finalized = false;
|
||||
IsAnonymous = false;
|
||||
}
|
||||
|
||||
private void CalculateProperties()
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using ZoneCodeGenerator.Domain;
|
||||
using ZoneCodeGenerator.Parsing.C_Header.Tests;
|
||||
using ZoneCodeGenerator.Parsing.Testing;
|
||||
using ZoneCodeGenerator.Utils;
|
||||
|
||||
namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
||||
{
|
||||
@ -18,6 +19,8 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
||||
};
|
||||
|
||||
public string Name { get; }
|
||||
public bool IsAnonymous { get; }
|
||||
|
||||
public string AssignedName { get; private set; }
|
||||
public string Namespace { get; private set; }
|
||||
public bool IsTypedef { get; }
|
||||
@ -29,8 +32,18 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
||||
private DataTypeTypedef typedef;
|
||||
|
||||
public BlockStruct(IHeaderParserState headerParserState, string name, bool isTypedef) : base(headerParserState, BlockType.Struct)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
Name = name;
|
||||
IsAnonymous = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Name = RandomName.GenerateName();
|
||||
IsAnonymous = true;
|
||||
}
|
||||
|
||||
IsTypedef = isTypedef;
|
||||
Variables = new List<Variable>();
|
||||
AssignedName = "";
|
||||
@ -63,7 +76,8 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
||||
|
||||
_struct = new DataTypeStruct(Namespace, Name, Pack)
|
||||
{
|
||||
AlignmentOverride = CustomAlignment
|
||||
AlignmentOverride = CustomAlignment,
|
||||
IsAnonymous = IsAnonymous
|
||||
};
|
||||
|
||||
_struct.Members.AddRange(Variables);
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using ZoneCodeGenerator.Domain;
|
||||
using ZoneCodeGenerator.Parsing.C_Header.Tests;
|
||||
using ZoneCodeGenerator.Parsing.Testing;
|
||||
using ZoneCodeGenerator.Utils;
|
||||
|
||||
namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
||||
{
|
||||
@ -18,6 +19,8 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
||||
};
|
||||
|
||||
public string Name { get; }
|
||||
public bool IsAnonymous { get; }
|
||||
|
||||
public string AssignedName { get; private set; }
|
||||
public string Namespace { get; private set; }
|
||||
public bool IsTypedef { get; }
|
||||
@ -29,8 +32,18 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
||||
private DataTypeTypedef typedef;
|
||||
|
||||
public BlockUnion(IHeaderParserState headerParserState, string name, bool isTypedef) : base(headerParserState, BlockType.Union)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
Name = name;
|
||||
IsAnonymous = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Name = RandomName.GenerateName();
|
||||
IsAnonymous = true;
|
||||
}
|
||||
|
||||
IsTypedef = isTypedef;
|
||||
Variables = new List<Variable>();
|
||||
CustomAlignment = null;
|
||||
@ -63,7 +76,8 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
||||
|
||||
union = new DataTypeUnion(Namespace, Name, Pack)
|
||||
{
|
||||
AlignmentOverride = CustomAlignment
|
||||
AlignmentOverride = CustomAlignment,
|
||||
IsAnonymous = IsAnonymous
|
||||
};
|
||||
|
||||
union.Members.AddRange(Variables);
|
||||
|
@ -43,7 +43,7 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Tests
|
||||
protected override void ProcessMatch(IHeaderParserState state)
|
||||
{
|
||||
var isTypedef = HasMatcherTokens(TypedefToken);
|
||||
var name = NextMatch(NameToken) ?? RandomName.GenerateName();
|
||||
var name = NextMatch(NameToken) ?? "";
|
||||
|
||||
var block = new BlockStruct(state, name, isTypedef);
|
||||
|
||||
|
@ -43,7 +43,7 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Tests
|
||||
protected override void ProcessMatch(IHeaderParserState state)
|
||||
{
|
||||
var isTypedef = HasMatcherTokens(TypedefToken);
|
||||
var name = NextMatch(NameToken) ?? RandomName.GenerateName();
|
||||
var name = NextMatch(NameToken) ?? "";
|
||||
|
||||
var block = new BlockUnion(state, name, isTypedef);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user