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 List<Variable> Members { get; }
|
||||||
|
|
||||||
|
public bool IsAnonymous { get; set; }
|
||||||
|
|
||||||
private bool finalized;
|
private bool finalized;
|
||||||
public void FinalizeDataType()
|
public void FinalizeDataType()
|
||||||
{
|
{
|
||||||
@ -30,6 +32,7 @@ namespace ZoneCodeGenerator.Domain
|
|||||||
Members = new List<Variable>();
|
Members = new List<Variable>();
|
||||||
Pack = pack;
|
Pack = pack;
|
||||||
finalized = false;
|
finalized = false;
|
||||||
|
IsAnonymous = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CalculateProperties()
|
private void CalculateProperties()
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using ZoneCodeGenerator.Domain;
|
using ZoneCodeGenerator.Domain;
|
||||||
using ZoneCodeGenerator.Parsing.C_Header.Tests;
|
using ZoneCodeGenerator.Parsing.C_Header.Tests;
|
||||||
using ZoneCodeGenerator.Parsing.Testing;
|
using ZoneCodeGenerator.Parsing.Testing;
|
||||||
|
using ZoneCodeGenerator.Utils;
|
||||||
|
|
||||||
namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
||||||
{
|
{
|
||||||
@ -18,6 +19,8 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
|||||||
};
|
};
|
||||||
|
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
public bool IsAnonymous { get; }
|
||||||
|
|
||||||
public string AssignedName { get; private set; }
|
public string AssignedName { get; private set; }
|
||||||
public string Namespace { get; private set; }
|
public string Namespace { get; private set; }
|
||||||
public bool IsTypedef { get; }
|
public bool IsTypedef { get; }
|
||||||
@ -30,7 +33,17 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
|||||||
|
|
||||||
public BlockStruct(IHeaderParserState headerParserState, string name, bool isTypedef) : base(headerParserState, BlockType.Struct)
|
public BlockStruct(IHeaderParserState headerParserState, string name, bool isTypedef) : base(headerParserState, BlockType.Struct)
|
||||||
{
|
{
|
||||||
Name = name;
|
if (!string.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
IsAnonymous = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Name = RandomName.GenerateName();
|
||||||
|
IsAnonymous = true;
|
||||||
|
}
|
||||||
|
|
||||||
IsTypedef = isTypedef;
|
IsTypedef = isTypedef;
|
||||||
Variables = new List<Variable>();
|
Variables = new List<Variable>();
|
||||||
AssignedName = "";
|
AssignedName = "";
|
||||||
@ -63,7 +76,8 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
|||||||
|
|
||||||
_struct = new DataTypeStruct(Namespace, Name, Pack)
|
_struct = new DataTypeStruct(Namespace, Name, Pack)
|
||||||
{
|
{
|
||||||
AlignmentOverride = CustomAlignment
|
AlignmentOverride = CustomAlignment,
|
||||||
|
IsAnonymous = IsAnonymous
|
||||||
};
|
};
|
||||||
|
|
||||||
_struct.Members.AddRange(Variables);
|
_struct.Members.AddRange(Variables);
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using ZoneCodeGenerator.Domain;
|
using ZoneCodeGenerator.Domain;
|
||||||
using ZoneCodeGenerator.Parsing.C_Header.Tests;
|
using ZoneCodeGenerator.Parsing.C_Header.Tests;
|
||||||
using ZoneCodeGenerator.Parsing.Testing;
|
using ZoneCodeGenerator.Parsing.Testing;
|
||||||
|
using ZoneCodeGenerator.Utils;
|
||||||
|
|
||||||
namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
||||||
{
|
{
|
||||||
@ -18,6 +19,8 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
|||||||
};
|
};
|
||||||
|
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
public bool IsAnonymous { get; }
|
||||||
|
|
||||||
public string AssignedName { get; private set; }
|
public string AssignedName { get; private set; }
|
||||||
public string Namespace { get; private set; }
|
public string Namespace { get; private set; }
|
||||||
public bool IsTypedef { get; }
|
public bool IsTypedef { get; }
|
||||||
@ -30,7 +33,17 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
|||||||
|
|
||||||
public BlockUnion(IHeaderParserState headerParserState, string name, bool isTypedef) : base(headerParserState, BlockType.Union)
|
public BlockUnion(IHeaderParserState headerParserState, string name, bool isTypedef) : base(headerParserState, BlockType.Union)
|
||||||
{
|
{
|
||||||
Name = name;
|
if (!string.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
IsAnonymous = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Name = RandomName.GenerateName();
|
||||||
|
IsAnonymous = true;
|
||||||
|
}
|
||||||
|
|
||||||
IsTypedef = isTypedef;
|
IsTypedef = isTypedef;
|
||||||
Variables = new List<Variable>();
|
Variables = new List<Variable>();
|
||||||
CustomAlignment = null;
|
CustomAlignment = null;
|
||||||
@ -63,7 +76,8 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Blocks
|
|||||||
|
|
||||||
union = new DataTypeUnion(Namespace, Name, Pack)
|
union = new DataTypeUnion(Namespace, Name, Pack)
|
||||||
{
|
{
|
||||||
AlignmentOverride = CustomAlignment
|
AlignmentOverride = CustomAlignment,
|
||||||
|
IsAnonymous = IsAnonymous
|
||||||
};
|
};
|
||||||
|
|
||||||
union.Members.AddRange(Variables);
|
union.Members.AddRange(Variables);
|
||||||
|
@ -43,7 +43,7 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Tests
|
|||||||
protected override void ProcessMatch(IHeaderParserState state)
|
protected override void ProcessMatch(IHeaderParserState state)
|
||||||
{
|
{
|
||||||
var isTypedef = HasMatcherTokens(TypedefToken);
|
var isTypedef = HasMatcherTokens(TypedefToken);
|
||||||
var name = NextMatch(NameToken) ?? RandomName.GenerateName();
|
var name = NextMatch(NameToken) ?? "";
|
||||||
|
|
||||||
var block = new BlockStruct(state, name, isTypedef);
|
var block = new BlockStruct(state, name, isTypedef);
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ namespace ZoneCodeGenerator.Parsing.C_Header.Tests
|
|||||||
protected override void ProcessMatch(IHeaderParserState state)
|
protected override void ProcessMatch(IHeaderParserState state)
|
||||||
{
|
{
|
||||||
var isTypedef = HasMatcherTokens(TypedefToken);
|
var isTypedef = HasMatcherTokens(TypedefToken);
|
||||||
var name = NextMatch(NameToken) ?? RandomName.GenerateName();
|
var name = NextMatch(NameToken) ?? "";
|
||||||
|
|
||||||
var block = new BlockUnion(state, name, isTypedef);
|
var block = new BlockUnion(state, name, isTypedef);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user