public static async Task <string> MakeUniqueCppName(GenericTypes.UEStruct ss) { string name = string.Empty; if (ss.IsValid()) { if (ObjectsStore.CountObjects <GenericTypes.UEStruct>(await ss.GetName()) > 1) { name = $"{MakeValidName((await ss.GetOuter()).GetNameCpp().Result)}_"; } } return($"{name}{MakeValidName(await ss.GetNameCpp())}"); }
/// <summary> /// Generates the members of a struct or class. /// </summary> /// <param name="structObj">The structure object.</param> /// <param name="offset">The start offset.</param> /// <param name="properties">The properties describing the members.</param> /// <returns>The members of the struct or class.</returns> private async Task <List <Member> > GenerateMembers(GenericTypes.UEStruct structObj, int offset, List <GenericTypes.UEProperty> properties) { var members = new List <Member>(); var uniqueMemberNames = new Dictionary <string, int>(); int unknownDataCounter = 0; var previousBitfieldProperty = new GenericTypes.UEBoolProperty(); foreach (var prop in properties) { if (offset < await prop.GetOffset()) { int size = await prop.GetOffset() - offset; members.Add(CreatePadding(unknownDataCounter++, offset, size, "MISSED OFFSET")); } var info = await prop.GetInfo(); if (info.Type != GenericTypes.UEProperty.PropertyType.Unknown) { var sp = new Member { Offset = await prop.GetOffset(), Size = info.Size, Type = info.CppType, Name = NameValidator.MakeValidName(await prop.GetName()) }; if (!uniqueMemberNames.ContainsKey(sp.Name)) { uniqueMemberNames[sp.Name] = 1; } else { uniqueMemberNames[sp.Name]++; sp.Name += uniqueMemberNames[sp.Name]; } if (await prop.GetArrayDim() > 1) { sp.Name += $"[0x{await prop.GetArrayDim():X}]"; } if (await prop.IsA <GenericTypes.UEBoolProperty>() && await prop.Cast <GenericTypes.UEBoolProperty>().IsBitfield()) { var boolProp = prop.Cast <GenericTypes.UEBoolProperty>(); var missingBits = await boolProp.GetMissingBitsCount(previousBitfieldProperty); if (missingBits[1] != -1) { if (missingBits[0] > 0) { members.Add(CreateBitfieldPadding(unknownDataCounter++, await previousBitfieldProperty.GetOffset(), info.CppType, missingBits[0])); } if (missingBits[1] > 0) { members.Add(CreateBitfieldPadding(unknownDataCounter++, sp.Offset, info.CppType, missingBits[1])); } } else if (missingBits[0] > 0) { members.Add(CreateBitfieldPadding(unknownDataCounter++, sp.Offset, info.CppType, missingBits[0])); } previousBitfieldProperty = boolProp; sp.Name += " : 1"; } sp.Name = Generator.GetSafeKeywordsName(sp.Name); sp.Flags = (int)await prop.GetPropertyFlags(); sp.FlagsString = PropertyFlags.StringifyFlags(await prop.GetPropertyFlags()); members.Add(sp); int sizeMismatch = (await prop.GetElementSize() * await prop.GetArrayDim()) - (info.Size * await prop.GetArrayDim()); if (sizeMismatch > 0) { members.Add(CreatePadding(unknownDataCounter++, offset, sizeMismatch, "FIX WRONG TYPE SIZE OF PREVIOUS PROPERTY")); } } else { var size = await prop.GetElementSize() * await prop.GetArrayDim(); members.Add(CreatePadding(unknownDataCounter++, offset, size, "UNKNOWN PROPERTY: " + await prop.GetFullName())); } offset = await prop.GetOffset() + await prop.GetElementSize() * await prop.GetArrayDim(); } if (offset < await structObj.GetPropertySize()) { int size = await structObj.GetPropertySize() - offset; members.Add(CreatePadding(unknownDataCounter, offset, size, "MISSED OFFSET")); } return(members); }