Skip to content

Commit

Permalink
Tested indirect calls from native code of overrides in the target lan…
Browse files Browse the repository at this point in the history
…guage.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information
ddobrev committed Jan 14, 2019
1 parent c3629a2 commit 7817b52
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/CSharp/CSharp.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,27 @@ public void TestHasFixedArrayOfPointers()
}
}

[Test]
public void TestVirtualIndirectCallInNative()
{
using (Inter i = new Inter())
{
using (InterfaceTester tester = new InterfaceTester())
{
tester.SetInterface(i);
Assert.That(tester.Get(10), Is.EqualTo(IntPtr.Zero));
}
}
}

public class Inter : SimpleInterface
{
public override int Size => s;
public override int Capacity => s;
public override IntPtr Get(int n) { return new IntPtr(0); }
private int s = 0;
}

private class OverrideVirtualTemplate : VirtualTemplate<int>
{
public override int Function
Expand Down
36 changes: 36 additions & 0 deletions tests/CSharp/CSharp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,3 +1495,39 @@ HasFixedArrayOfPointers::HasFixedArrayOfPointers()
HasFixedArrayOfPointers::~HasFixedArrayOfPointers()
{
}

SimpleInterface::SimpleInterface()
{
}

SimpleInterface::~SimpleInterface()
{
}

InterfaceTester::InterfaceTester() : interface(0)
{
}

InterfaceTester::~InterfaceTester()
{
}

int InterfaceTester::capacity()
{
return interface->capacity();
}

int InterfaceTester::size()
{
return interface->size();
}

void* InterfaceTester::get(int n)
{
return interface->get(n);
}

void InterfaceTester::setInterface(SimpleInterface* i)
{
interface = i;
}
25 changes: 25 additions & 0 deletions tests/CSharp/CSharp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1262,3 +1262,28 @@ struct DLL_API CSharp
};

static int FOOBAR_CONSTANT = 42;



class DLL_API SimpleInterface
{
public:
SimpleInterface();
~SimpleInterface();
virtual int size() const = 0;
virtual int capacity() const = 0;
virtual void* get(int n) = 0;
};

class DLL_API InterfaceTester
{
public:
InterfaceTester();
~InterfaceTester();
int capacity();
int size();
void* get(int n);
void setInterface(SimpleInterface* i);
private:
SimpleInterface* interface;
};

0 comments on commit 7817b52

Please sign in to comment.