From cf472f526c87e9807a9f9868e7cbc07376efcbb6 Mon Sep 17 00:00:00 2001 From: triton Date: Mon, 20 Jul 2015 23:00:55 +0100 Subject: [PATCH] Fixed C++/CLI to handle namespace conflicts between free functions and namespaces. We generate free functions inside a global namespace-level class with the same name as the header. This means that there might be some conflict if we already have a class with the same name as the header. This fix changes the code to always fully quality classes so the code always compiles correctly. --- src/Generator/Generators/CLI/CLISourcesTemplate.cs | 2 +- tests/CLITemp/CLITemp.cpp | 5 +++++ tests/CLITemp/CLITemp.h | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Generator/Generators/CLI/CLISourcesTemplate.cs b/src/Generator/Generators/CLI/CLISourcesTemplate.cs index 52d3b079..a2b7f2ff 100644 --- a/src/Generator/Generators/CLI/CLISourcesTemplate.cs +++ b/src/Generator/Generators/CLI/CLISourcesTemplate.cs @@ -654,7 +654,7 @@ namespace CppSharp.Generators.CLI WriteLine("{0}^ {0}::{1}(::System::IntPtr native)", qualifiedIdentifier, Helpers.CreateInstanceIdentifier); WriteStartBraceIndent(); - WriteLine("return gcnew {0}(({1}) native.ToPointer());", qualifiedIdentifier, nativeType); + WriteLine("return gcnew ::{0}(({1}) native.ToPointer());", qualifiedIdentifier, nativeType); WriteCloseBraceIndent(); NewLine(); } diff --git a/tests/CLITemp/CLITemp.cpp b/tests/CLITemp/CLITemp.cpp index aa208561..39e4e3b3 100644 --- a/tests/CLITemp/CLITemp.cpp +++ b/tests/CLITemp/CLITemp.cpp @@ -9,3 +9,8 @@ std::string Date::testStdString(std::string s) { return s + "_test"; } + +void testFreeFunction() +{ + +} \ No newline at end of file diff --git a/tests/CLITemp/CLITemp.h b/tests/CLITemp/CLITemp.h index 13f3f053..ac317433 100644 --- a/tests/CLITemp/CLITemp.h +++ b/tests/CLITemp/CLITemp.h @@ -47,3 +47,5 @@ std::ostream& operator<<(std::ostream& os, const Date& dt) os << dt.mo << '/' << dt.da << '/' << dt.yr; return os; } + +DLL_API void testFreeFunction(); \ No newline at end of file