Browse Source

Fixed marshaling of typedef'd const char strings.

pull/621/merge
Joao Matos 10 years ago
parent
commit
f8bd69790e
  1. 2
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  2. 1
      tests/Common/Common.Tests.cs
  3. 4
      tests/Common/Common.cpp
  4. 5
      tests/Common/Common.h

2
src/Generator/Generators/CSharp/CSharpMarshal.cs

@ -148,7 +148,7 @@ namespace CppSharp.Generators.CSharp @@ -148,7 +148,7 @@ namespace CppSharp.Generators.CSharp
if (CSharpTypePrinter.IsConstCharString(pointer) || marshalPointeeAsString)
{
Context.Return.Write(MarshalStringToManaged(Context.ReturnVarName,
pointer.GetFinalPointee() as BuiltinType));
pointer.GetFinalPointee().Desugar() as BuiltinType));
return true;
}

1
tests/Common/Common.Tests.cs

@ -94,6 +94,7 @@ public class CommonTests : GeneratorTestFixture @@ -94,6 +94,7 @@ public class CommonTests : GeneratorTestFixture
str = "Hello";
hello.StringInOutRef(ref str);
Assert.That(str, Is.EqualTo("StringInOutRef"));
hello.StringTypedef(str);
}
[Test]

4
tests/Common/Common.cpp

@ -270,6 +270,10 @@ void Hello::StringInOutRef(CS_IN_OUT const char*& str) @@ -270,6 +270,10 @@ void Hello::StringInOutRef(CS_IN_OUT const char*& str)
str = "Failed";
}
void Hello::StringTypedef(const TypedefChar* str)
{
}
int unsafeFunction(const Bar& ret, char* testForString, void (*foo)(int))
{
return ret.A;

5
tests/Common/Common.h

@ -142,6 +142,8 @@ enum Enum @@ -142,6 +142,8 @@ enum Enum
F = -9
};
typedef char TypedefChar;
class DLL_API Hello
{
union NestedPrivate {
@ -193,6 +195,8 @@ public: @@ -193,6 +195,8 @@ public:
void StringOutRef(CS_OUT const char*& str);
void StringInOut(CS_IN_OUT const char** str);
void StringInOutRef(CS_IN_OUT const char*& str);
void StringTypedef(const TypedefChar* str);
};
class DLL_API AbstractFoo
@ -1048,3 +1052,4 @@ class DLL_API DerivedFromTemplateInstantiationWithVirtual : public TemplateWithV @@ -1048,3 +1052,4 @@ class DLL_API DerivedFromTemplateInstantiationWithVirtual : public TemplateWithV
public:
DerivedFromTemplateInstantiationWithVirtual();
};

Loading…
Cancel
Save