Browse Source

Use fixed c# statement when accessing fixed struct members

pull/821/head
Gilad Levi 8 years ago
parent
commit
5302f5870c
  1. 4
      src/Generator/Generators/CSharp/CSharpSources.cs
  2. 2
      tests/CSharp/CSharp.cs
  3. 6
      tests/CSharp/CSharp.h

4
src/Generator/Generators/CSharp/CSharpSources.cs

@ -833,7 +833,7 @@ namespace CppSharp.Generators.CSharp
var marshal = new CSharpMarshalManagedToNativePrinter(ctx); var marshal = new CSharpMarshalManagedToNativePrinter(ctx);
ctx.Declaration = field; ctx.Declaration = field;
var arrayType = field.Type as ArrayType; var arrayType = field.Type as ArrayType ?? field.QualifiedType.Type.Desugar() as ArrayType;
if (arrayType != null && @class.IsValueType) if (arrayType != null && @class.IsValueType)
{ {
@ -1077,7 +1077,7 @@ namespace CppSharp.Generators.CSharp
}; };
TypePrinter.PopContext(); TypePrinter.PopContext();
var arrayType = field.Type as ArrayType; var arrayType = field.Type as ArrayType ?? field.QualifiedType.Type.Desugar() as ArrayType;
if (arrayType != null && @class.IsValueType) if (arrayType != null && @class.IsValueType)
ctx.ReturnVarName = HandleValueArray(arrayType, field); ctx.ReturnVarName = HandleValueArray(arrayType, field);

2
tests/CSharp/CSharp.cs

@ -33,7 +33,7 @@ namespace CppSharp.Tests
ctx.SetClassAsValueType("QPoint"); ctx.SetClassAsValueType("QPoint");
ctx.SetClassAsValueType("QSize"); ctx.SetClassAsValueType("QSize");
ctx.SetClassAsValueType("QRect"); ctx.SetClassAsValueType("QRect");
ctx.SetClassAsValueType("StructTestArrayTypeFromTypedef");
ctx.IgnoreClassWithName("IgnoredTypeInheritingNonIgnoredWithNoEmptyCtor"); ctx.IgnoreClassWithName("IgnoredTypeInheritingNonIgnoredWithNoEmptyCtor");
} }

6
tests/CSharp/CSharp.h

@ -1170,3 +1170,9 @@ struct DLL_API ForwardDeclaredStruct {
DLL_API ForwardDeclaredStruct* createForwardDeclaredStruct(int i); DLL_API ForwardDeclaredStruct* createForwardDeclaredStruct(int i);
DLL_API int useForwardDeclaredStruct(ForwardDeclaredStruct* s); DLL_API int useForwardDeclaredStruct(ForwardDeclaredStruct* s);
typedef char charsArrayType[13];
struct StructTestArrayTypeFromTypedef
{
charsArrayType arr;
};
Loading…
Cancel
Save