|
|
@ -852,7 +852,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
return Tuple.Create(library, decl.Mangled); |
|
|
|
return Tuple.Create(library, decl.Mangled); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GeneratePropertySetter<T>(QualifiedType returnType, T decl, Class @class) |
|
|
|
private void GeneratePropertySetter<T>(QualifiedType returnType, T decl, Class @class, bool isAbstract = false) |
|
|
|
where T : Declaration, ITypedDecl |
|
|
|
where T : Declaration, ITypedDecl |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!(decl is Function || decl is Field) ) |
|
|
|
if (!(decl is Function || decl is Field) ) |
|
|
@ -861,7 +861,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PushBlock(CSharpBlockKind.Method); |
|
|
|
PushBlock(CSharpBlockKind.Method); |
|
|
|
WriteLine("set"); |
|
|
|
Write("set"); |
|
|
|
|
|
|
|
|
|
|
|
var param = new Parameter |
|
|
|
var param = new Parameter |
|
|
|
{ |
|
|
|
{ |
|
|
@ -878,27 +878,28 @@ namespace CppSharp.Generators.CSharp |
|
|
|
if (decl is Function) |
|
|
|
if (decl is Function) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var function = decl as Function; |
|
|
|
var function = decl as Function; |
|
|
|
if (function.IsPure && Driver.Options.GenerateAbstractImpls) |
|
|
|
if (isAbstract && Driver.Options.GenerateAbstractImpls) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Write(";"); |
|
|
|
Write(";"); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NewLine(); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
if (function.Parameters.Count == 0) |
|
|
|
if (function.Parameters.Count == 0) |
|
|
|
throw new NotSupportedException("Expected at least one parameter in setter"); |
|
|
|
throw new NotSupportedException("Expected at least one parameter in setter"); |
|
|
|
|
|
|
|
|
|
|
|
param.QualifiedType = function.Parameters[0].QualifiedType; |
|
|
|
param.QualifiedType = function.Parameters[0].QualifiedType; |
|
|
|
|
|
|
|
|
|
|
|
var method = function as Method; |
|
|
|
if (function.SynthKind == FunctionSynthKind.AbstractImplCall) |
|
|
|
if (method != null && method.OperatorKind == CXXOperatorKind.Subscript) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (method.SynthKind == FunctionSynthKind.AbstractImplCall) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
GenerateAbstractImplCall(method, @class); |
|
|
|
GenerateAbstractImplCall(function, @class); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var method = function as Method; |
|
|
|
|
|
|
|
if (method != null && method.OperatorKind == CXXOperatorKind.Subscript) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (method.OperatorKind == CXXOperatorKind.Subscript) |
|
|
|
if (method.OperatorKind == CXXOperatorKind.Subscript) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -910,11 +911,10 @@ namespace CppSharp.Generators.CSharp |
|
|
|
GenerateInternalFunctionCall(function, parameters); |
|
|
|
GenerateInternalFunctionCall(function, parameters); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
var parameters = new List<Parameter> { param }; |
|
|
|
GenerateInternalFunctionCall(function, new List<Parameter> { param }); |
|
|
|
GenerateInternalFunctionCall(function, parameters); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
WriteCloseBraceIndent(); |
|
|
|
WriteCloseBraceIndent(); |
|
|
|
} |
|
|
|
} |
|
|
@ -927,6 +927,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (@class.IsUnion) |
|
|
|
if (@class.IsUnion) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
NewLine(); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
WriteLine("{0} = value;", decl.Name); |
|
|
|
WriteLine("{0} = value;", decl.Name); |
|
|
|
WriteCloseBraceIndent(); |
|
|
|
WriteCloseBraceIndent(); |
|
|
@ -938,6 +939,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NewLine(); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
|
|
|
|
|
|
|
|
WriteLine("var {0} = (Internal*){1}.ToPointer();", |
|
|
|
WriteLine("var {0} = (Internal*){1}.ToPointer();", |
|
|
@ -1001,7 +1003,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GeneratePropertyGetter<T>(QualifiedType returnType, T decl, Class @class) |
|
|
|
private void GeneratePropertyGetter<T>(QualifiedType returnType, T decl, Class @class, bool isAbstract = false) |
|
|
|
where T : Declaration, ITypedDecl |
|
|
|
where T : Declaration, ITypedDecl |
|
|
|
{ |
|
|
|
{ |
|
|
|
PushBlock(CSharpBlockKind.Method); |
|
|
|
PushBlock(CSharpBlockKind.Method); |
|
|
@ -1010,7 +1012,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
if (decl is Function) |
|
|
|
if (decl is Function) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var function = decl as Function; |
|
|
|
var function = decl as Function; |
|
|
|
if (function.IsPure && Driver.Options.GenerateAbstractImpls) |
|
|
|
if (isAbstract && Driver.Options.GenerateAbstractImpls) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Write(";"); |
|
|
|
Write(";"); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
@ -1234,16 +1236,15 @@ namespace CppSharp.Generators.CSharp |
|
|
|
GeneratePropertyGetter(prop.QualifiedType, prop.Field, @class); |
|
|
|
GeneratePropertyGetter(prop.QualifiedType, prop.Field, @class); |
|
|
|
|
|
|
|
|
|
|
|
if (prop.HasSetter) |
|
|
|
if (prop.HasSetter) |
|
|
|
GeneratePropertySetter(prop.Field.QualifiedType, prop.Field, |
|
|
|
GeneratePropertySetter(prop.Field.QualifiedType, prop.Field, @class); |
|
|
|
@class); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (prop.HasGetter) |
|
|
|
if (prop.HasGetter) |
|
|
|
GeneratePropertyGetter(prop.QualifiedType, prop.GetMethod, @class); |
|
|
|
GeneratePropertyGetter(prop.QualifiedType, prop.GetMethod, @class, prop.IsPure); |
|
|
|
|
|
|
|
|
|
|
|
if (prop.HasSetter) |
|
|
|
if (prop.HasSetter) |
|
|
|
GeneratePropertySetter(prop.QualifiedType, prop.SetMethod, @class); |
|
|
|
GeneratePropertySetter(prop.QualifiedType, prop.SetMethod, @class, prop.IsPure); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WriteCloseBraceIndent(); |
|
|
|
WriteCloseBraceIndent(); |
|
|
@ -1620,9 +1621,9 @@ namespace CppSharp.Generators.CSharp |
|
|
|
PopBlock(NewLineKind.Always); |
|
|
|
PopBlock(NewLineKind.Always); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public string GetVTableMethodDelegateName(Method method) |
|
|
|
public string GetVTableMethodDelegateName(Function function) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var nativeId = GetFunctionNativeIdentifier(method); |
|
|
|
var nativeId = GetFunctionNativeIdentifier(function); |
|
|
|
|
|
|
|
|
|
|
|
// Trim '@' (if any) because '@' is valid only as the first symbol.
|
|
|
|
// Trim '@' (if any) because '@' is valid only as the first symbol.
|
|
|
|
nativeId = nativeId.Trim('@'); |
|
|
|
nativeId = nativeId.Trim('@'); |
|
|
@ -2132,23 +2133,23 @@ namespace CppSharp.Generators.CSharp |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GenerateAbstractImplCall(Method method, Class @class) |
|
|
|
private void GenerateAbstractImplCall(Function function, Class @class) |
|
|
|
{ |
|
|
|
{ |
|
|
|
string delegateId; |
|
|
|
string delegateId; |
|
|
|
Write(GetAbstractCallDelegate(method, @class, out delegateId)); |
|
|
|
Write(GetAbstractCallDelegate(function, @class, out delegateId)); |
|
|
|
GenerateFunctionCall(delegateId, method.Parameters, method); |
|
|
|
GenerateFunctionCall(delegateId, function.Parameters, function); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public string GetAbstractCallDelegate(Method method, Class @class, |
|
|
|
public string GetAbstractCallDelegate(Function function, Class @class, |
|
|
|
out string delegateId) |
|
|
|
out string delegateId) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var virtualCallBuilder = new StringBuilder(); |
|
|
|
var virtualCallBuilder = new StringBuilder(); |
|
|
|
var i = VTables.GetVTableIndex(method, @class); |
|
|
|
var i = VTables.GetVTableIndex(function, @class); |
|
|
|
virtualCallBuilder.AppendFormat("void* slot = *(void**) ((({0}.Internal*) {1})->vfptr0 + {2} * {3});", |
|
|
|
virtualCallBuilder.AppendFormat("void* slot = *(void**) ((({0}.Internal*) {1})->vfptr0 + {2} * {3});", |
|
|
|
@class.BaseClass.Name, Helpers.InstanceIdentifier, i, Driver.TargetInfo.PointerWidth / 8); |
|
|
|
@class.BaseClass.Name, Helpers.InstanceIdentifier, i, Driver.TargetInfo.PointerWidth / 8); |
|
|
|
virtualCallBuilder.AppendLine(); |
|
|
|
virtualCallBuilder.AppendLine(); |
|
|
|
|
|
|
|
|
|
|
|
string @delegate = GetVTableMethodDelegateName((Method) method.OriginalFunction); |
|
|
|
string @delegate = GetVTableMethodDelegateName(function.OriginalFunction); |
|
|
|
delegateId = Generator.GeneratedIdentifier(@delegate); |
|
|
|
delegateId = Generator.GeneratedIdentifier(@delegate); |
|
|
|
|
|
|
|
|
|
|
|
virtualCallBuilder.AppendFormat( |
|
|
|
virtualCallBuilder.AppendFormat( |
|
|
|