mirror of https://github.com/mono/CppSharp.git
5 changed files with 105 additions and 0 deletions
@ -0,0 +1,32 @@ |
|||||||
|
using System; |
||||||
|
using NUnit.Framework; |
||||||
|
using VTables; |
||||||
|
|
||||||
|
public class FooDerived : Foo |
||||||
|
{ |
||||||
|
public override int Vfoo() |
||||||
|
{ |
||||||
|
Console.WriteLine("Hello from FooDerived"); |
||||||
|
return 10; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
[TestFixture] |
||||||
|
public class VTablesTests |
||||||
|
{ |
||||||
|
[Test] |
||||||
|
public void TestFoo() |
||||||
|
{ |
||||||
|
var foo = new Foo(); |
||||||
|
Assert.That(foo.Vfoo(), Is.EqualTo(5)); |
||||||
|
Assert.That(foo.Vbar(), Is.EqualTo(3)); |
||||||
|
Assert.That(foo.CallFoo(), Is.EqualTo(7)); |
||||||
|
|
||||||
|
var foo2 = new FooDerived(); |
||||||
|
Assert.That(foo2.CallFoo(), Is.EqualTo(12)); |
||||||
|
} |
||||||
|
|
||||||
|
static void Main(string[] args) |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
#include "VTables.h" |
||||||
|
|
||||||
|
Foo::Foo() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
int Foo::vfoo() |
||||||
|
{ |
||||||
|
return 5; |
||||||
|
} |
||||||
|
|
||||||
|
int Foo::vbar() |
||||||
|
{ |
||||||
|
return 3; |
||||||
|
} |
||||||
|
|
||||||
|
int FooCallFoo(Foo* foo) |
||||||
|
{ |
||||||
|
return foo->vfoo() + 2; |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
using CppSharp.AST; |
||||||
|
using CppSharp.Generators; |
||||||
|
using CppSharp.Passes; |
||||||
|
using CppSharp.Utils; |
||||||
|
|
||||||
|
namespace CppSharp.Tests |
||||||
|
{ |
||||||
|
public class VTableTests : LibraryTest |
||||||
|
{ |
||||||
|
public VTableTests(LanguageGeneratorKind kind) |
||||||
|
: base("VTables", kind) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public override void SetupPasses(Driver driver) |
||||||
|
{ |
||||||
|
driver.TranslationUnitPasses.RenameDeclsUpperCase(RenameTargets.Any); |
||||||
|
driver.TranslationUnitPasses.AddPass(new FunctionToInstanceMethodPass()); |
||||||
|
} |
||||||
|
|
||||||
|
public override void Preprocess(Driver driver, Library lib) |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
static class Program |
||||||
|
{ |
||||||
|
public static void Main(string[] args) |
||||||
|
{ |
||||||
|
ConsoleDriver.Run(new VTableTests(LanguageGeneratorKind.CPlusPlusCLI)); |
||||||
|
ConsoleDriver.Run(new VTableTests(LanguageGeneratorKind.CSharp)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
#if defined(_MSC_VER) |
||||||
|
#define DLL_API __declspec(dllexport) |
||||||
|
#else |
||||||
|
#define DLL_API |
||||||
|
#endif |
||||||
|
|
||||||
|
class DLL_API Foo |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
Foo(); |
||||||
|
virtual int vfoo(); |
||||||
|
virtual int vbar(); |
||||||
|
}; |
||||||
|
|
||||||
|
DLL_API int FooCallFoo(Foo* foo); |
Loading…
Reference in new issue