Browse Source

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.
pull/520/merge
triton 10 years ago
parent
commit
cf472f526c
  1. 2
      src/Generator/Generators/CLI/CLISourcesTemplate.cs
  2. 5
      tests/CLITemp/CLITemp.cpp
  3. 2
      tests/CLITemp/CLITemp.h

2
src/Generator/Generators/CLI/CLISourcesTemplate.cs

@ -654,7 +654,7 @@ namespace CppSharp.Generators.CLI @@ -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();
}

5
tests/CLITemp/CLITemp.cpp

@ -9,3 +9,8 @@ std::string Date::testStdString(std::string s) @@ -9,3 +9,8 @@ std::string Date::testStdString(std::string s)
{
return s + "_test";
}
void testFreeFunction()
{
}

2
tests/CLITemp/CLITemp.h

@ -47,3 +47,5 @@ std::ostream& operator<<(std::ostream& os, const Date& dt) @@ -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();
Loading…
Cancel
Save