Browse Source

Fixed out reference parameters in CLI backend (with test).

pull/61/merge
triton 12 years ago
parent
commit
bed92373ec
  1. 3
      src/Generator/Generators/CLI/CLISourcesTemplate.cs
  2. 10
      tests/Basic/Basic.Tests.cs
  3. 6
      tests/Basic/Basic.cpp
  4. 1
      tests/Basic/Basic.cs
  5. 2
      tests/Basic/Basic.h

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

@ -901,8 +901,9 @@ namespace CppSharp.Generators.CLI @@ -901,8 +901,9 @@ namespace CppSharp.Generators.CLI
var paramType = param.Type;
if (paramType is PointerType)
{
if (!paramType.IsReference())
paramMarshal.Prefix = "&";
paramType = (paramType as PointerType).Pointee;
paramMarshal.Prefix = "&";
}
var typePrinter = new CppTypePrinter(Driver.TypeDatabase);

10
tests/Basic/Basic.Tests.cs

@ -54,6 +54,16 @@ public class BasicTests @@ -54,6 +54,16 @@ public class BasicTests
Assert.That(f, Is.EqualTo(10.0f));
}
[Test]
public void TestPrimitiveOutRefParameters()
{
var hello = new Hello();
float f;
Assert.That(hello.TestPrimitiveOutRef(out f), Is.True);
Assert.That(f, Is.EqualTo(10.0f));
}
[Test]
public void TestNullRef()
{

6
tests/Basic/Basic.cpp

@ -101,6 +101,12 @@ bool Hello::TestPrimitiveOut(CS_OUT float* f) @@ -101,6 +101,12 @@ bool Hello::TestPrimitiveOut(CS_OUT float* f)
return true;
}
bool Hello::TestPrimitiveOutRef(CS_OUT float& f)
{
f = 10;
return true;
}
int unsafeFunction(const Bar& ret, char* testForString, void (*foo)(int))
{
return ret.A;

1
tests/Basic/Basic.cs

@ -16,6 +16,7 @@ namespace CppSharp.Tests @@ -16,6 +16,7 @@ namespace CppSharp.Tests
lib.SetClassAsValueType("Bar");
lib.SetClassAsValueType("Bar2");
lib.SetMethodParameterUsage("Hello", "TestPrimitiveOut", 1, ParameterUsage.Out);
lib.SetMethodParameterUsage("Hello", "TestPrimitiveOutRef", 1, ParameterUsage.Out);
}
static class Program

2
tests/Basic/Basic.h

@ -88,7 +88,7 @@ public: @@ -88,7 +88,7 @@ public:
Hello* RetNull();
bool TestPrimitiveOut(CS_OUT float* f);
bool TestPrimitiveOutRef(CS_OUT float& f);
};
class DLL_API AbstractFoo

Loading…
Cancel
Save