|
|
@ -447,19 +447,14 @@ namespace Cxxi.Generators.CLI |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
GenerateStructMarshaling(@class, nativePtr); |
|
|
|
GenerateStructMarshaling(@class, nativePtr + "->"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WriteCloseBraceIndent(); |
|
|
|
WriteCloseBraceIndent(); |
|
|
|
NewLine(); |
|
|
|
NewLine(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GenerateStructMarshaling(Class @class, string nativePointer) |
|
|
|
private void GenerateStructMarshaling(Class @class, string nativeVar) |
|
|
|
{ |
|
|
|
|
|
|
|
GenerateStructMarshalingFields(@class, nativePointer); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void GenerateStructMarshalingFields(Class @class, string nativePointer) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (var @base in @class.Bases) |
|
|
|
foreach (var @base in @class.Bases) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -467,15 +462,15 @@ namespace Cxxi.Generators.CLI |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
var baseClass = @base.Class; |
|
|
|
var baseClass = @base.Class; |
|
|
|
GenerateStructMarshalingFields(baseClass, nativePointer); |
|
|
|
GenerateStructMarshaling(baseClass, nativeVar); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach (var field in @class.Fields) |
|
|
|
foreach (var field in @class.Fields) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (CheckIgnoreField(@class, field)) continue; |
|
|
|
if (CheckIgnoreField(@class, field)) continue; |
|
|
|
|
|
|
|
|
|
|
|
var nativeField = string.Format("{0}->{1}", |
|
|
|
var nativeField = string.Format("{0}{1}", |
|
|
|
nativePointer, field.OriginalName); |
|
|
|
nativeVar, field.OriginalName); |
|
|
|
|
|
|
|
|
|
|
|
var ctx = new MarshalContext(Driver) |
|
|
|
var ctx = new MarshalContext(Driver) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -653,10 +648,20 @@ namespace Cxxi.Generators.CLI |
|
|
|
var retType = function.ReturnType; |
|
|
|
var retType = function.ReturnType; |
|
|
|
var needsReturn = !retType.IsPrimitiveType(PrimitiveType.Void); |
|
|
|
var needsReturn = !retType.IsPrimitiveType(PrimitiveType.Void); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const string valueMarshalName = "_this0"; |
|
|
|
var isValueType = @class != null && @class.IsValueType; |
|
|
|
var isValueType = @class != null && @class.IsValueType; |
|
|
|
if (isValueType) |
|
|
|
if (isValueType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WriteLine("auto this0 = (::{0}*) 0;", @class.QualifiedOriginalName); |
|
|
|
WriteLine("auto {0} = ::{1}();", valueMarshalName, @class.QualifiedOriginalName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var param = new Parameter() { Name = "(*this)" }; |
|
|
|
|
|
|
|
var ctx = new MarshalContext(Driver) { Parameter = param }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var marshal = new CLIMarshalManagedToNativePrinter(ctx); |
|
|
|
|
|
|
|
marshal.MarshalValueClassFields(@class, valueMarshalName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(marshal.Context.SupportBefore)) |
|
|
|
|
|
|
|
Write(marshal.Context.SupportBefore); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var @params = GenerateFunctionParamsMarshal(function.Parameters, function); |
|
|
|
var @params = GenerateFunctionParamsMarshal(function.Parameters, function); |
|
|
@ -666,7 +671,7 @@ namespace Cxxi.Generators.CLI |
|
|
|
|
|
|
|
|
|
|
|
if (isValueType) |
|
|
|
if (isValueType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Write("this0->"); |
|
|
|
Write("{0}.", valueMarshalName); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (IsInstanceFunction(function)) |
|
|
|
else if (IsInstanceFunction(function)) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -710,6 +715,11 @@ namespace Cxxi.Generators.CLI |
|
|
|
WriteLine("{0} = {1};",param.Name,marshal.Context.Return); |
|
|
|
WriteLine("{0} = {1};",param.Name,marshal.Context.Return); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isValueType) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GenerateStructMarshaling(@class, valueMarshalName + "."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (needsReturn) |
|
|
|
if (needsReturn) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var ctx = new MarshalContext(Driver) |
|
|
|
var ctx = new MarshalContext(Driver) |
|
|
|