Browse Source

Completed the handling of separate return types when generating functions.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/917/head
Dimitar Dobrev 8 years ago
parent
commit
f17441f371
  1. 8
      src/Generator/Generators/CLI/CLISources.cs
  2. 7
      src/Generator/Generators/CSharp/CSharpSources.cs

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

@ -391,11 +391,9 @@ namespace CppSharp.Generators.CLI @@ -391,11 +391,9 @@ namespace CppSharp.Generators.CLI
string variable;
if (decl is Variable)
variable = string.Format("::{0}::{1}",
@class.QualifiedOriginalName, decl.OriginalName);
variable = $"::{@class.QualifiedOriginalName}::{decl.OriginalName}";
else
variable = string.Format("((::{0}*)NativePtr)->{1}",
@class.QualifiedOriginalName, decl.OriginalName);
variable = $"((::{@class.QualifiedOriginalName}*)NativePtr)->{decl.OriginalName}";
var ctx = new MarshalContext(Context)
{
@ -938,7 +936,7 @@ namespace CppSharp.Generators.CLI @@ -938,7 +936,7 @@ namespace CppSharp.Generators.CLI
var retType = function.ReturnType;
if (publicRetType == null)
publicRetType = retType.Type;
var needsReturn = !retType.Type.IsPrimitiveType(PrimitiveType.Void);
var needsReturn = !publicRetType.IsPrimitiveType(PrimitiveType.Void);
const string valueMarshalName = "_this0";
var isValueType = @class != null && @class.IsValueType;

7
src/Generator/Generators/CSharp/CSharpSources.cs

@ -2445,7 +2445,8 @@ namespace CppSharp.Generators.CSharp @@ -2445,7 +2445,8 @@ namespace CppSharp.Generators.CSharp
}
private void GenerateVirtualPropertyCall(Method method, Class @class,
Property property, List<Parameter> parameters = null)
Property property, List<Parameter> parameters = null,
QualifiedType returnType = default(QualifiedType))
{
if (property.IsOverride && !property.IsPure &&
method.SynthKind != FunctionSynthKind.AbstractImplCall &&
@ -2454,7 +2455,7 @@ namespace CppSharp.Generators.CSharp @@ -2454,7 +2455,7 @@ namespace CppSharp.Generators.CSharp
"return base.{0};" : "base.{0} = value;", property.Name);
else
GenerateFunctionCall(GetVirtualCallDelegate(method, @class),
parameters ?? method.Parameters, method);
parameters ?? method.Parameters, method, returnType);
}
private void GenerateVirtualFunctionCall(Method method, Class @class,
@ -2613,7 +2614,7 @@ namespace CppSharp.Generators.CSharp @@ -2613,7 +2614,7 @@ namespace CppSharp.Generators.CSharp
var method = function as Method;
var hasThisReturnStructor = method != null && (method.IsConstructor || method.IsDestructor);
var needsReturn = !retType.Type.IsPrimitiveType(PrimitiveType.Void) && !hasThisReturnStructor;
var needsReturn = !returnType.Type.IsPrimitiveType(PrimitiveType.Void) && !hasThisReturnStructor;
var isValueType = false;
var needsInstance = false;

Loading…
Cancel
Save