From df6a27f5fda9dd307ae1bafe1abe7fcaf9f88bd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Kooi?= <48814281+RA-Kooi@users.noreply.github.com> Date: Tue, 21 Dec 2021 07:15:28 +0100 Subject: [PATCH] Fix class member generation It would duplicate members if the members were of a different type than TAG_member or TAG_typedef. But it didn't matter because those other tags got erroneously filtered out. --- DwarfOne2C/CWriter/Class.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/DwarfOne2C/CWriter/Class.cs b/DwarfOne2C/CWriter/Class.cs index 00c8b1c..f94c31f 100644 --- a/DwarfOne2C/CWriter/Class.cs +++ b/DwarfOne2C/CWriter/Class.cs @@ -68,10 +68,11 @@ private static List GenerateClassStruct( child.sibling != Tag.NoSibling; child = allTags[IDToIndex[child.sibling]]) { + // This is perhaps not needed anymore... // Work around weirdness where anonymous structs are generated // with members (padding) and functions (padding) as children. - if(child.tagType == TagType.Member - || child.tagType == TagType.TypeDef) + /*if(child.tagType == TagType.Member + || child.tagType == TagType.TypeDef)*/ children.Add(child); } @@ -119,13 +120,22 @@ private static List GenerateClassStruct( { child = children[i]; - code.AddRange( - TagDispatcher( + List innerCode = TagDispatcher( allTags, allMemberFuncs, IDToIndex, child, - depth + 1)); + depth + 1); + + if(innerCode.Count > 0) + { + innerCode.RemoveAt(innerCode.Count - 1); + + code.Add(""); + code.AddRange(innerCode); + + continue; + } if(child.accessLevel != accessLevel && child.accessLevel != AccessLevel.None)