Browse Source

Fixed incompilable code when a virtual function has ref params.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/503/merge
Dimitar Dobrev 10 years ago
parent
commit
78c3db80aa
  1. 11
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  2. 2
      tests/CSharpTemp/CSharpTemp.h

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

@ -284,10 +284,10 @@ namespace CppSharp.Generators.CSharp
if (parameter.Usage == ParameterUsage.Unknown || parameter.IsIn) if (parameter.Usage == ParameterUsage.Unknown || parameter.IsIn)
return base.VisitParameterDecl(parameter); return base.VisitParameterDecl(parameter);
var ctx = new CSharpMarshalContext(base.Context.Driver) var ctx = new CSharpMarshalContext(Context.Driver)
{ {
ReturnType = base.Context.ReturnType, ReturnType = Context.ReturnType,
ReturnVarName = base.Context.ReturnVarName ReturnVarName = Context.ReturnVarName
}; };
var marshal = new CSharpMarshalNativeToManagedPrinter(ctx); var marshal = new CSharpMarshalNativeToManagedPrinter(ctx);
@ -296,13 +296,14 @@ namespace CppSharp.Generators.CSharp
if (!string.IsNullOrWhiteSpace(ctx.SupportBefore)) if (!string.IsNullOrWhiteSpace(ctx.SupportBefore))
Context.SupportBefore.WriteLine(ctx.SupportBefore); Context.SupportBefore.WriteLine(ctx.SupportBefore);
if (!string.IsNullOrWhiteSpace(ctx.Return)) if (!string.IsNullOrWhiteSpace(ctx.Return) && !parameter.IsPrimitiveParameterConvertibleToRef())
{ {
Context.SupportBefore.WriteLine("var _{0} = {1};", parameter.Name, Context.SupportBefore.WriteLine("var _{0} = {1};", parameter.Name,
ctx.Return); ctx.Return);
} }
Context.Return.Write("_{0}", parameter.Name); Context.Return.Write("{0}{1}",
parameter.IsPrimitiveParameterConvertibleToRef() ? "ref *" : "_", parameter.Name);
return true; return true;
} }

2
tests/CSharpTemp/CSharpTemp.h

@ -624,7 +624,7 @@ class DLL_API MultiOverloadPtrToRef
public: public:
void funcPrimitivePtrToRef(int *pOne, char* pTwo, float* pThree, bool* pFour = 0); void funcPrimitivePtrToRef(int *pOne, char* pTwo, float* pThree, bool* pFour = 0);
void funcPrimitivePtrToRefWithDefVal(int* pOne, char* pTwo, Foo* pThree, int* pFour = 0); void funcPrimitivePtrToRefWithDefVal(int* pOne, char* pTwo, Foo* pThree, int* pFour = 0);
void funcPrimitivePtrToRefWithMultiOverload(int* pOne, char* pTwo, Foo* pThree, int* pFour = 0, long* pFive = 0); virtual void funcPrimitivePtrToRefWithMultiOverload(int* pOne, char* pTwo, Foo* pThree, int* pFour = 0, long* pFive = 0);
MultiOverloadPtrToRef(); MultiOverloadPtrToRef();
int* ReturnPrimTypePtr(); int* ReturnPrimTypePtr();

Loading…
Cancel
Save