Browse Source

Fixed issue with const pointer.

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

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

@ -90,12 +90,16 @@ namespace CppSharp.Generators.CLI
} }
if (pointee.IsPrimitiveType(out primitive)) 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) if (pointer.Pointee is TypedefType)
Context.Return.Write("reinterpret_cast<{0}>({1})", pointer, Context.Return.Write("reinterpret_cast<{0}>({1})", pointer,
Context.ReturnVarName); returnVarName);
else else
Context.Return.Write(Context.ReturnVarName); Context.Return.Write(returnVarName);
return true; return true;
} }

4
tests/Basic/Basic.h

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

Loading…
Cancel
Save