|
|
|
@ -2146,16 +2146,39 @@ namespace CppSharp.Generators.CSharp
@@ -2146,16 +2146,39 @@ namespace CppSharp.Generators.CSharp
|
|
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static string OverloadParamNameWithDefValue(Parameter p, ref int index) |
|
|
|
|
{ |
|
|
|
|
return (p.Type.IsPointerToPrimitiveType() && p.Usage == ParameterUsage.InOut && p.HasDefaultValue) |
|
|
|
|
? "ref param" + index++ |
|
|
|
|
: p.DefaultArgument.String; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void GenerateOverloadCall(Function function) |
|
|
|
|
{ |
|
|
|
|
Type type = function.OriginalReturnType.Type; |
|
|
|
|
for (int i = 0, j = 0; i < function.Parameters.Count; i++) |
|
|
|
|
{ |
|
|
|
|
var parameter = function.Parameters[i]; |
|
|
|
|
PrimitiveType primitiveType; |
|
|
|
|
if (parameter.Kind == ParameterKind.Regular && parameter.Ignore && |
|
|
|
|
parameter.Type.IsPointerToPrimitiveType(out primitiveType) && |
|
|
|
|
parameter.Usage == ParameterUsage.InOut && parameter.HasDefaultValue) |
|
|
|
|
{ |
|
|
|
|
var pointeeType = ((PointerType) parameter.Type).Pointee.ToString(); |
|
|
|
|
WriteLine("{0} param{1} = {2};", pointeeType, j++, |
|
|
|
|
primitiveType == PrimitiveType.Bool ? "false" : "0"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var index = 0; |
|
|
|
|
var type = function.OriginalReturnType.Type; |
|
|
|
|
WriteLine("{0}{1}({2});", |
|
|
|
|
type.IsPrimitiveType(PrimitiveType.Void) ? string.Empty : "return ", |
|
|
|
|
function.Name, |
|
|
|
|
string.Join(", ", |
|
|
|
|
function.Parameters.Where( |
|
|
|
|
p => p.Kind == ParameterKind.Regular).Select( |
|
|
|
|
p => p.Ignore ? p.DefaultArgument.String : p.Name))); |
|
|
|
|
p => p.Ignore ? OverloadParamNameWithDefValue(p, ref index) : |
|
|
|
|
(p.Usage == ParameterUsage.InOut ? "ref " : string.Empty) + p.Name))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void GenerateEquals(Function method, Class @class) |
|
|
|
@ -2498,6 +2521,10 @@ namespace CppSharp.Generators.CSharp
@@ -2498,6 +2521,10 @@ namespace CppSharp.Generators.CSharp
|
|
|
|
|
|
|
|
|
|
if (needsFixedThis && operatorParam == null) |
|
|
|
|
WriteCloseBraceIndent(); |
|
|
|
|
|
|
|
|
|
var numFixedBlocks = @params.Count(param => param.HasFixedBlock); |
|
|
|
|
for(var i = 0; i < numFixedBlocks; ++i) |
|
|
|
|
WriteCloseBraceIndent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private int GetInstanceParamIndex(Method method) |
|
|
|
@ -2519,6 +2546,8 @@ namespace CppSharp.Generators.CSharp
@@ -2519,6 +2546,8 @@ namespace CppSharp.Generators.CSharp
|
|
|
|
|
{ |
|
|
|
|
var param = paramInfo.Param; |
|
|
|
|
if (!(param.IsOut || param.IsInOut)) continue; |
|
|
|
|
if (param.IsPrimitiveParameterConvertibleToRef()) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
var nativeVarName = paramInfo.Name; |
|
|
|
|
|
|
|
|
@ -2548,6 +2577,7 @@ namespace CppSharp.Generators.CSharp
@@ -2548,6 +2577,7 @@ namespace CppSharp.Generators.CSharp
|
|
|
|
|
public string Name; |
|
|
|
|
public Parameter Param; |
|
|
|
|
public CSharpMarshalContext Context; |
|
|
|
|
public bool HasFixedBlock; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<ParamMarshal> GenerateFunctionParamsMarshal(IEnumerable<Parameter> @params, |
|
|
|
@ -2601,16 +2631,25 @@ namespace CppSharp.Generators.CSharp
@@ -2601,16 +2631,25 @@ namespace CppSharp.Generators.CSharp
|
|
|
|
|
|
|
|
|
|
paramMarshal.Context = ctx; |
|
|
|
|
|
|
|
|
|
var marshal = new CSharpMarshalManagedToNativePrinter(ctx); |
|
|
|
|
param.CSharpMarshalToNative(marshal); |
|
|
|
|
if (param.IsPrimitiveParameterConvertibleToRef()) |
|
|
|
|
{ |
|
|
|
|
WriteLine("fixed ({0} {1} = &{2})", param.Type.CSharpType(TypePrinter), argName, param.Name); |
|
|
|
|
paramMarshal.HasFixedBlock = true; |
|
|
|
|
WriteStartBraceIndent(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
var marshal = new CSharpMarshalManagedToNativePrinter(ctx); |
|
|
|
|
param.CSharpMarshalToNative(marshal); |
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(marshal.Context.Return)) |
|
|
|
|
throw new Exception("Cannot marshal argument of function"); |
|
|
|
|
if (string.IsNullOrEmpty(marshal.Context.Return)) |
|
|
|
|
throw new Exception("Cannot marshal argument of function"); |
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(marshal.Context.SupportBefore)) |
|
|
|
|
Write(marshal.Context.SupportBefore); |
|
|
|
|
if (!string.IsNullOrWhiteSpace(marshal.Context.SupportBefore)) |
|
|
|
|
Write(marshal.Context.SupportBefore); |
|
|
|
|
|
|
|
|
|
WriteLine("var {0} = {1};", argName, marshal.Context.Return); |
|
|
|
|
WriteLine("var {0} = {1};", argName, marshal.Context.Return); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return paramMarshal; |
|
|
|
|
} |
|
|
|
|