|
|
|
@ -1950,15 +1950,15 @@ namespace CppSharp.Generators.CSharp |
|
|
|
var needsInstance = false; |
|
|
|
var needsInstance = false; |
|
|
|
|
|
|
|
|
|
|
|
var method = function as Method; |
|
|
|
var method = function as Method; |
|
|
|
|
|
|
|
Parameter operatorParam = null; |
|
|
|
if (method != null) |
|
|
|
if (method != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var @class = (Class) method.Namespace; |
|
|
|
var @class = (Class) method.Namespace; |
|
|
|
isValueType = @class.IsValueType; |
|
|
|
isValueType = @class.IsValueType; |
|
|
|
|
|
|
|
|
|
|
|
needsInstance = !method.IsStatic; |
|
|
|
operatorParam = method.Parameters.FirstOrDefault( |
|
|
|
|
|
|
|
p => p.Kind == ParameterKind.OperatorParameter); |
|
|
|
if (method.IsOperator) |
|
|
|
needsInstance = !method.IsStatic || operatorParam != null; |
|
|
|
needsInstance &= !Operators.IsBuiltinOperator(method.OperatorKind); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var needsFixedThis = needsInstance && isValueType; |
|
|
|
var needsFixedThis = needsInstance && isValueType; |
|
|
|
@ -1972,7 +1972,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
if (hiddenParam.Kind != ParameterKind.IndirectReturnType) |
|
|
|
if (hiddenParam.Kind != ParameterKind.IndirectReturnType) |
|
|
|
throw new NotSupportedException("Expected hidden structure parameter kind"); |
|
|
|
throw new NotSupportedException("Expected hidden structure parameter kind"); |
|
|
|
|
|
|
|
|
|
|
|
Class retClass = null; |
|
|
|
Class retClass; |
|
|
|
hiddenParam.Type.Desugar().IsTagDecl(out retClass); |
|
|
|
hiddenParam.Type.Desugar().IsTagDecl(out retClass); |
|
|
|
WriteLine("var {0} = new {1}.Internal();", GeneratedIdentifier("ret"), |
|
|
|
WriteLine("var {0} = new {1}.Internal();", GeneratedIdentifier("ret"), |
|
|
|
QualifiedIdentifier(retClass.OriginalClass ?? retClass)); |
|
|
|
QualifiedIdentifier(retClass.OriginalClass ?? retClass)); |
|
|
|
@ -1981,6 +1981,9 @@ namespace CppSharp.Generators.CSharp |
|
|
|
var names = new List<string>(); |
|
|
|
var names = new List<string>(); |
|
|
|
foreach (var param in @params) |
|
|
|
foreach (var param in @params) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (param.Param == operatorParam && needsInstance) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
var name = string.Empty; |
|
|
|
var name = string.Empty; |
|
|
|
if (param.Context != null |
|
|
|
if (param.Context != null |
|
|
|
&& !string.IsNullOrWhiteSpace(param.Context.ArgumentPrefix)) |
|
|
|
&& !string.IsNullOrWhiteSpace(param.Context.ArgumentPrefix)) |
|
|
|
@ -1998,16 +2001,28 @@ namespace CppSharp.Generators.CSharp |
|
|
|
|
|
|
|
|
|
|
|
if (needsInstance) |
|
|
|
if (needsInstance) |
|
|
|
{ |
|
|
|
{ |
|
|
|
names.Insert(0, needsFixedThis ? string.Format("new global::System.IntPtr(&{0})", |
|
|
|
if (needsFixedThis) |
|
|
|
GeneratedIdentifier("fixedInstance")) : Helpers.InstanceIdentifier); |
|
|
|
{ |
|
|
|
|
|
|
|
names.Insert(0, string.Format("new global::System.IntPtr(&{0})", |
|
|
|
|
|
|
|
GeneratedIdentifier("fixedInstance"))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (operatorParam != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
names.Insert(0, operatorParam.Name + "." + Helpers.InstanceIdentifier); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
names.Insert(0, Helpers.InstanceIdentifier); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (needsFixedThis) |
|
|
|
if (needsFixedThis) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//WriteLine("fixed({0}* {1} = &this)", @class.QualifiedName,
|
|
|
|
WriteLine("var {0} = {1};", Generator.GeneratedIdentifier("fixedInstance"), |
|
|
|
// GeneratedIdentifier("instance"));
|
|
|
|
method.IsOperator ? "__arg0" : "ToInternal()"); |
|
|
|
//WriteStartBraceIndent();
|
|
|
|
|
|
|
|
WriteLine("var {0} = ToInternal();", Generator.GeneratedIdentifier("fixedInstance")); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (needsReturn && !originalFunction.HasIndirectReturnTypeParameter) |
|
|
|
if (needsReturn && !originalFunction.HasIndirectReturnTypeParameter) |
|
|
|
@ -2018,14 +2033,11 @@ namespace CppSharp.Generators.CSharp |
|
|
|
var cleanups = new List<TextGenerator>(); |
|
|
|
var cleanups = new List<TextGenerator>(); |
|
|
|
GenerateFunctionCallOutParams(@params, cleanups); |
|
|
|
GenerateFunctionCallOutParams(@params, cleanups); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var param in @params) |
|
|
|
cleanups.AddRange( |
|
|
|
{ |
|
|
|
from param in @params |
|
|
|
var context = param.Context; |
|
|
|
select param.Context into context |
|
|
|
if (context == null) continue; |
|
|
|
where context != null && !string.IsNullOrWhiteSpace(context.Cleanup) |
|
|
|
|
|
|
|
select context.Cleanup); |
|
|
|
if (!string.IsNullOrWhiteSpace(context.Cleanup)) |
|
|
|
|
|
|
|
cleanups.Add(context.Cleanup); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var cleanup in cleanups) |
|
|
|
foreach (var cleanup in cleanups) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -2034,8 +2046,15 @@ namespace CppSharp.Generators.CSharp |
|
|
|
|
|
|
|
|
|
|
|
if (needsFixedThis) |
|
|
|
if (needsFixedThis) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// WriteCloseBraceIndent();
|
|
|
|
if (operatorParam != null) |
|
|
|
WriteLine("FromInternal(&{0});", Generator.GeneratedIdentifier("fixedInstance")); |
|
|
|
{ |
|
|
|
|
|
|
|
WriteLine("{0}.FromInternal(&{1});", |
|
|
|
|
|
|
|
operatorParam.Name, Generator.GeneratedIdentifier("fixedInstance")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
WriteLine("FromInternal(&{0});", Generator.GeneratedIdentifier("fixedInstance")); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (needsReturn) |
|
|
|
if (needsReturn) |
|
|
|
|