Browse Source

Generate by ref parameters of type a pointer to enum

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1344/head
Dimitar Dobrev 5 years ago committed by João Matos
parent
commit
653f4cc287
  1. 5
      src/Generator/Generators/ExtensionMethods.cs
  2. 9
      tests/CLI/CLI.Tests.cs
  3. 5
      tests/CLI/CLI.cpp
  4. 12
      tests/CLI/CLI.h
  5. 2
      tests/Common/Common.Tests.cs
  6. 16
      tests/Common/Common.cpp
  7. 8
      tests/Common/Common.h

5
src/Generator/Generators/ExtensionMethods.cs

@ -44,8 +44,9 @@ namespace CppSharp.Generators @@ -44,8 +44,9 @@ namespace CppSharp.Generators
PrimitiveType.ULongLong,
PrimitiveType.UShort
};
return type.IsPointerToPrimitiveType() &&
allowedToHaveDefaultPtrVals.Any(type.IsPointerToPrimitiveType);
return (type.IsPointerToPrimitiveType() &&
allowedToHaveDefaultPtrVals.Any(type.IsPointerToPrimitiveType)) ||
(type.IsAddress() && type.GetPointee().IsEnum());
}
public static Type GetMappedType(this Type type, TypeMapDatabase typeMaps,

9
tests/CLI/CLI.Tests.cs

@ -18,15 +18,6 @@ public class CLITests : GeneratorTestFixture @@ -18,15 +18,6 @@ public class CLITests : GeneratorTestFixture
Assert.AreEqual("test_test", new Date(0, 0, 0).TestStdString("test"));
}
[Test]
public void TestByRefEnumParam()
{
using (var byRefEnumParam = new TestByRefEnumParam())
{
Assert.AreEqual(EnumParam.E1, byRefEnumParam.GetPassedEnumParam(EnumParam.E1));
}
}
[Test]
public void GetEmployeeNameFromOrgTest()
{

5
tests/CLI/CLI.cpp

@ -27,11 +27,6 @@ DLL_API void useIncompleteStruct(IncompleteStruct * a) @@ -27,11 +27,6 @@ DLL_API void useIncompleteStruct(IncompleteStruct * a)
return;
}
EnumParam TestByRefEnumParam::GetPassedEnumParam(EnumParam & e)
{
return e;
}
TestMappedTypeNonConstRefParam::TestMappedTypeNonConstRefParam(const std::string str)
{
m_str = str;

12
tests/CLI/CLI.h

@ -63,18 +63,6 @@ typedef struct IncompleteStruct IncompleteStruct; @@ -63,18 +63,6 @@ typedef struct IncompleteStruct IncompleteStruct;
DLL_API IncompleteStruct* createIncompleteStruct();
DLL_API void useIncompleteStruct(IncompleteStruct* a);
enum EnumParam
{
E1,
E2
};
class DLL_API TestByRefEnumParam
{
public:
EnumParam GetPassedEnumParam(EnumParam& e);
};
class DLL_API TestMappedTypeNonConstRefParam
{
public:

2
tests/Common/Common.Tests.cs

@ -563,7 +563,7 @@ public class CommonTests : GeneratorTestFixture @@ -563,7 +563,7 @@ public class CommonTests : GeneratorTestFixture
public unsafe void TestArraysPointers()
{
var values = MyEnum.A;
var arrays = new TestArraysPointers(&values, 1);
var arrays = new TestArraysPointers(ref values, 1);
Assert.That(arrays.Value, Is.EqualTo(MyEnum.A));
}

16
tests/Common/Common.cpp

@ -260,13 +260,13 @@ bool Hello::TestPrimitiveOutRef(CS_OUT float& f) @@ -260,13 +260,13 @@ bool Hello::TestPrimitiveOutRef(CS_OUT float& f)
return true;
}
bool Hello::TestPrimitiveInOut(CS_IN_OUT int* i)
bool Hello::TestPrimitiveInOut(int* i)
{
*i += 10;
return true;
}
bool Hello::TestPrimitiveInOutRef(CS_IN_OUT int& i)
bool Hello::TestPrimitiveInOutRef(int& i)
{
i += 10;
return true;
@ -282,16 +282,16 @@ void Hello::EnumOutRef(int value, CS_OUT Enum& e) @@ -282,16 +282,16 @@ void Hello::EnumOutRef(int value, CS_OUT Enum& e)
e = (Enum)value;
}
void Hello::EnumInOut(CS_IN_OUT Enum* e)
void Hello::EnumInOut(Enum* e)
{
if (*e == Enum::E)
*e = Enum::F;
if (*e == Enum::E)
*e = Enum::F;
}
void Hello::EnumInOutRef(CS_IN_OUT Enum& e)
void Hello::EnumInOutRef(Enum& e)
{
if (e == Enum::E)
e = Enum::F;
if (e == Enum::E)
e = Enum::F;
}
void Hello::StringOut(CS_OUT const char** str)

8
tests/Common/Common.h

@ -234,14 +234,14 @@ public: @@ -234,14 +234,14 @@ public:
bool TestPrimitiveOut(CS_OUT float* f);
bool TestPrimitiveOutRef(CS_OUT float& f);
bool TestPrimitiveInOut(CS_IN_OUT int* i);
bool TestPrimitiveInOutRef(CS_IN_OUT int& i);
bool TestPrimitiveInOut(int* i);
bool TestPrimitiveInOutRef(int& i);
void EnumOut(int value, CS_OUT Enum* e);
void EnumOutRef(int value, CS_OUT Enum& e);
void EnumInOut(CS_IN_OUT Enum* e);
void EnumInOutRef(CS_IN_OUT Enum& e);
void EnumInOut(Enum* e);
void EnumInOutRef(Enum& e);
void StringOut(CS_OUT const char** str);
void StringOutRef(CS_OUT const char*& str);

Loading…
Cancel
Save