Browse Source

Fixed wrong code generation for constant-size arrays of non-primitive types.

References #380.
pull/395/head
triton 12 years ago committed by Joao Matos
parent
commit
0e574bdd5b
  1. 11
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs
  2. 1
      tests/CSharpTemp/CSharpTemp.h

11
src/Generator/Generators/CSharp/CSharpTypePrinter.cs

@ -126,6 +126,17 @@ namespace CppSharp.Generators.CSharp @@ -126,6 +126,17 @@ namespace CppSharp.Generators.CSharp
}
return string.Format("{0}*", array.Type.Visit(this, quals));
}
Class @class;
if (arrayType.TryGetClass(out @class))
{
return new CSharpTypePrinterResult()
{
Type = "fixed byte",
NameSuffix = string.Format("[{0}]", array.Size * @class.Layout.Size)
};
}
// Do not write the fixed keyword multiple times for nested array types
var fixedKeyword = array.Type is ArrayType ? string.Empty : "fixed ";
return new CSharpTypePrinterResult()

1
tests/CSharpTemp/CSharpTemp.h

@ -59,6 +59,7 @@ public: @@ -59,6 +59,7 @@ public:
private:
int index;
Foo m_foo;
Foo foos[4];
};
Bar::Bar() {}

Loading…
Cancel
Save