Browse Source

Added better support for native printing of constant sized arrays as C# fixed buffers.

pull/1/head
triton 12 years ago
parent
commit
a1920c627a
  1. 15
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs

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

@ -31,6 +31,7 @@ namespace CppSharp.Generators.CSharp @@ -31,6 +31,7 @@ namespace CppSharp.Generators.CSharp
{
public string Type;
public TypeMap TypeMap;
public string NameSuffix;
public static implicit operator CSharpTypePrinterResult(string type)
{
@ -90,6 +91,20 @@ namespace CppSharp.Generators.CSharp @@ -90,6 +91,20 @@ namespace CppSharp.Generators.CSharp
public CSharpTypePrinterResult VisitArrayType(ArrayType array,
TypeQualifiers quals)
{
if (ContextKind == CSharpTypePrinterContextKind.Native &&
array.SizeType == ArrayType.ArraySize.Constant)
{
PrimitiveType primitive;
if (!array.Type.Desugar().IsPrimitiveType(out primitive))
throw new NotSupportedException();
return new CSharpTypePrinterResult()
{
Type = string.Format("fixed {0}", array.Type.Visit(this, quals)),
NameSuffix = string.Format("[{0}]", array.Size)
};
}
return string.Format("{0}[]", array.Type.Visit(this));
// C# only supports fixed arrays in unsafe sections

Loading…
Cancel
Save