Skip to content

Commit bd051d5

Browse files
committed
[SharpGen] Make sure pack is applied for a struct
1 parent 10531ea commit bd051d5

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Source/Tools/SharpGen/Model/CsStruct.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,18 @@ public CsStruct(CppStruct cppStruct)
4343
IsIn = true;
4444
IsOut = false;
4545
CppElement = cppStruct;
46-
// Align was not overloaded by MappingRule tag, then we can take the default value
47-
if (cppStruct != null && Align == 0)
48-
Align = cppStruct.Align;
4946
}
5047

5148
protected override void UpdateFromTag(MappingRule tag)
5249
{
5350
base.UpdateFromTag(tag);
54-
Align = tag.StructPack != null ? tag.StructPack.Value : Align;
55-
HasMarshalType = tag.StructHasNativeValueType != null ? tag.StructHasNativeValueType.Value : false;
56-
GenerateAsClass = tag.StructToClass != null ? tag.StructToClass.Value : false;
57-
HasCustomMarshal = tag.StructCustomMarshal != null ? tag.StructCustomMarshal.Value : false;
58-
IsStaticMarshal = tag.IsStaticMarshal != null ? tag.IsStaticMarshal.Value : false;
59-
HasCustomNew = tag.StructCustomNew != null ? tag.StructCustomNew.Value : false;
60-
IsOut = tag.StructForceMarshalToToBeGenerated != null ? tag.StructForceMarshalToToBeGenerated.Value : false;
51+
Align = tag.StructPack ?? 0;
52+
HasMarshalType = tag.StructHasNativeValueType ?? false;
53+
GenerateAsClass = tag.StructToClass ?? false;
54+
HasCustomMarshal = tag.StructCustomMarshal ?? false;
55+
IsStaticMarshal = tag.IsStaticMarshal ?? false;
56+
HasCustomNew = tag.StructCustomNew ?? false;
57+
IsOut = tag.StructForceMarshalToToBeGenerated ?? false;
6158

6259
// Force a marshalling if a struct need to be treated as a class)
6360
if (GenerateAsClass)

0 commit comments

Comments
 (0)