Browse Source

Fixed generation of unions.

pull/68/merge
triton 12 years ago
parent
commit
18b1515412
  1. 7
      src/Generator/Generators/CLI/CLIHeadersTemplate.cs

7
src/Generator/Generators/CLI/CLIHeadersTemplate.cs

@ -352,7 +352,8 @@ namespace CppSharp.Generators.CLI
GenerateDeclarationCommon(field); GenerateDeclarationCommon(field);
if (@class.IsUnion) if (@class.IsUnion)
WriteLine("[FieldOffset({0})]", field.Offset); WriteLine("[System::Runtime::InteropServices::FieldOffset({0})]",
field.Offset);
WriteLine("{0} {1};", field.Type, SafeIdentifier(field.Name)); WriteLine("{0} {1};", field.Type, SafeIdentifier(field.Name));
} }
PopIndent(); PopIndent();
@ -454,7 +455,9 @@ namespace CppSharp.Generators.CLI
public bool GenerateClassProlog(Class @class) public bool GenerateClassProlog(Class @class)
{ {
Write("public "); if (@class.IsUnion)
WriteLine("[System::Runtime::InteropServices::StructLayout({0})]",
"System::Runtime::InteropServices::LayoutKind::Explicit");
// Nested types cannot have visibility modifiers in C++/CLI. // Nested types cannot have visibility modifiers in C++/CLI.
var isTopLevel = @class.Namespace is TranslationUnit || var isTopLevel = @class.Namespace is TranslationUnit ||

Loading…
Cancel
Save