Browse Source

Ensure typedefs of std::vector are mapped

pull/1316/head
Build Agent 5 years ago committed by João Matos
parent
commit
094e1ec65a
  1. 6
      src/Generator/Types/Std/Stdlib.cs
  2. 4
      tests/StandardLib/StandardLib.h

6
src/Generator/Types/Std/Stdlib.cs

@ -489,7 +489,8 @@ namespace CppSharp.Types.Std
public override void CLIMarshalToNative(MarshalContext ctx) public override void CLIMarshalToNative(MarshalContext ctx)
{ {
var templateType = Type as TemplateSpecializationType; var desugared = Type.Desugar();
var templateType = desugared as TemplateSpecializationType;
var type = templateType.Arguments[0].Type; var type = templateType.Arguments[0].Type;
var isPointerToPrimitive = type.Type.IsPointerToPrimitiveType(); var isPointerToPrimitive = type.Type.IsPointerToPrimitiveType();
var managedType = isPointerToPrimitive var managedType = isPointerToPrimitive
@ -546,7 +547,8 @@ namespace CppSharp.Types.Std
public override void CLIMarshalToManaged(MarshalContext ctx) public override void CLIMarshalToManaged(MarshalContext ctx)
{ {
var templateType = Type as TemplateSpecializationType; var desugared = Type.Desugar();
var templateType = desugared as TemplateSpecializationType;
var type = templateType.Arguments[0].Type; var type = templateType.Arguments[0].Type;
var isPointerToPrimitive = type.Type.IsPointerToPrimitiveType(); var isPointerToPrimitive = type.Type.IsPointerToPrimitiveType();
var managedType = isPointerToPrimitive var managedType = isPointerToPrimitive

4
tests/StandardLib/StandardLib.h

@ -12,6 +12,8 @@ struct DLL_API IntWrapperValueType
int Value; int Value;
}; };
typedef std::vector<IntWrapperValueType> VectorTypedef;
struct DLL_API TestVectors struct DLL_API TestVectors
{ {
TestVectors(); TestVectors();
@ -28,6 +30,8 @@ struct DLL_API TestVectors
std::vector<IntWrapper*> IntWrapperPtrVector; std::vector<IntWrapper*> IntWrapperPtrVector;
// Should get mapped to List<IntWrapperValueType> // Should get mapped to List<IntWrapperValueType>
std::vector<IntWrapperValueType> IntWrapperValueTypeVector; std::vector<IntWrapperValueType> IntWrapperValueTypeVector;
// Should get mapped to List<IntWrapperValueType>
VectorTypedef IntWrapperValueTypeVectorTypedef;
}; };
struct DLL_API OStreamTest struct DLL_API OStreamTest

Loading…
Cancel
Save