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
} }
return string.Format("{0}*", array.Type.Visit(this, quals)); 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 // Do not write the fixed keyword multiple times for nested array types
var fixedKeyword = array.Type is ArrayType ? string.Empty : "fixed "; var fixedKeyword = array.Type is ArrayType ? string.Empty : "fixed ";
return new CSharpTypePrinterResult() return new CSharpTypePrinterResult()

1
tests/CSharpTemp/CSharpTemp.h

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

Loading…
Cancel
Save