Skip to content

Commit 7817b52

Browse files
committed
Tested indirect calls from native code of overrides in the target language.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent c3629a2 commit 7817b52

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

tests/CSharp/CSharp.Tests.cs

+21
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,27 @@ public void TestHasFixedArrayOfPointers()
12171217
}
12181218
}
12191219

1220+
[Test]
1221+
public void TestVirtualIndirectCallInNative()
1222+
{
1223+
using (Inter i = new Inter())
1224+
{
1225+
using (InterfaceTester tester = new InterfaceTester())
1226+
{
1227+
tester.SetInterface(i);
1228+
Assert.That(tester.Get(10), Is.EqualTo(IntPtr.Zero));
1229+
}
1230+
}
1231+
}
1232+
1233+
public class Inter : SimpleInterface
1234+
{
1235+
public override int Size => s;
1236+
public override int Capacity => s;
1237+
public override IntPtr Get(int n) { return new IntPtr(0); }
1238+
private int s = 0;
1239+
}
1240+
12201241
private class OverrideVirtualTemplate : VirtualTemplate<int>
12211242
{
12221243
public override int Function

tests/CSharp/CSharp.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -1495,3 +1495,39 @@ HasFixedArrayOfPointers::HasFixedArrayOfPointers()
14951495
HasFixedArrayOfPointers::~HasFixedArrayOfPointers()
14961496
{
14971497
}
1498+
1499+
SimpleInterface::SimpleInterface()
1500+
{
1501+
}
1502+
1503+
SimpleInterface::~SimpleInterface()
1504+
{
1505+
}
1506+
1507+
InterfaceTester::InterfaceTester() : interface(0)
1508+
{
1509+
}
1510+
1511+
InterfaceTester::~InterfaceTester()
1512+
{
1513+
}
1514+
1515+
int InterfaceTester::capacity()
1516+
{
1517+
return interface->capacity();
1518+
}
1519+
1520+
int InterfaceTester::size()
1521+
{
1522+
return interface->size();
1523+
}
1524+
1525+
void* InterfaceTester::get(int n)
1526+
{
1527+
return interface->get(n);
1528+
}
1529+
1530+
void InterfaceTester::setInterface(SimpleInterface* i)
1531+
{
1532+
interface = i;
1533+
}

tests/CSharp/CSharp.h

+25
Original file line numberDiff line numberDiff line change
@@ -1262,3 +1262,28 @@ struct DLL_API CSharp
12621262
};
12631263

12641264
static int FOOBAR_CONSTANT = 42;
1265+
1266+
1267+
1268+
class DLL_API SimpleInterface
1269+
{
1270+
public:
1271+
SimpleInterface();
1272+
~SimpleInterface();
1273+
virtual int size() const = 0;
1274+
virtual int capacity() const = 0;
1275+
virtual void* get(int n) = 0;
1276+
};
1277+
1278+
class DLL_API InterfaceTester
1279+
{
1280+
public:
1281+
InterfaceTester();
1282+
~InterfaceTester();
1283+
int capacity();
1284+
int size();
1285+
void* get(int n);
1286+
void setInterface(SimpleInterface* i);
1287+
private:
1288+
SimpleInterface* interface;
1289+
};

0 commit comments

Comments
 (0)