Browse Source

Fixed issue with const pointer.

pull/225/head
Elias Holzer 12 years ago
parent
commit
570f13112b
  1. 8
      src/Generator/Generators/CLI/CLIMarshal.cs
  2. 4
      tests/Basic/Basic.h

8
src/Generator/Generators/CLI/CLIMarshal.cs

@ -91,11 +91,15 @@ namespace CppSharp.Generators.CLI @@ -91,11 +91,15 @@ namespace CppSharp.Generators.CLI
if (pointee.IsPrimitiveType(out primitive))
{
var returnVarName = Context.ReturnVarName;
if (quals.IsConst != Context.ReturnType.Qualifiers.IsConst)
returnVarName = string.Format("const_cast<{0}>({1})",
Context.ReturnType, Context.ReturnVarName);
if (pointer.Pointee is TypedefType)
Context.Return.Write("reinterpret_cast<{0}>({1})", pointer,
Context.ReturnVarName);
returnVarName);
else
Context.Return.Write(Context.ReturnVarName);
Context.Return.Write(returnVarName);
return true;
}

4
tests/Basic/Basic.h

@ -21,8 +21,8 @@ public: @@ -21,8 +21,8 @@ public:
// Not properly handled yet - ignore
float nested_array[2][2];
// Primitive pointer types
int* SomePointer;
int** SomePointerPointer;
const int* SomePointer;
const int** SomePointerPointer;
};
struct DLL_API Bar

Loading…
Cancel
Save