From 44ce759a3368e5190648e0a7587777ba1387a885 Mon Sep 17 00:00:00 2001 From: triton Date: Thu, 31 Oct 2013 01:43:54 +0000 Subject: [PATCH] V-table method delegates need to take into account same-named overloads. Fixes #88. --- src/Generator/Generators/CSharp/CSharpTextTemplate.cs | 8 ++++++-- tests/VTables/VTables.cpp | 10 ++++++++++ tests/VTables/VTables.h | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index 2c2770c0..640bf007 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -1370,8 +1370,12 @@ namespace CppSharp.Generators.CSharp public string GetVTableMethodDelegateName(Method method) { - // trim '@' (if any) because '@' is valid only as the first symbol - return string.Format("_{0}Delegate", GetFunctionIdentifier(method).Trim('@')); + var nativeId = GetFunctionNativeIdentifier(method); + + // Trim '@' (if any) because '@' is valid only as the first symbol. + nativeId = nativeId.Trim('@'); + + return string.Format("_{0}Delegate", nativeId); } public void GenerateVTablePointers(Class @class) diff --git a/tests/VTables/VTables.cpp b/tests/VTables/VTables.cpp index 6d3a6a96..249d3bd1 100644 --- a/tests/VTables/VTables.cpp +++ b/tests/VTables/VTables.cpp @@ -14,6 +14,16 @@ int Foo::vbar() return 3; } +int Foo::append() +{ + return 1; +} + +int Foo::append(int a) +{ + return ++a; +} + int FooCallFoo(Foo* foo) { return foo->vfoo() + 2; diff --git a/tests/VTables/VTables.h b/tests/VTables/VTables.h index 822108a7..17bf3224 100644 --- a/tests/VTables/VTables.h +++ b/tests/VTables/VTables.h @@ -15,6 +15,9 @@ public: Foo(); virtual int vfoo(); virtual int vbar(); + + virtual int append(); + virtual int append(int a); }; DLL_API int FooCallFoo(Foo* foo);