|
|
|
@ -98,12 +98,20 @@ namespace CppSharp.Generators.CSharp |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
var arrayType = array.Type.Desugar(); |
|
|
|
var arrayType = array.Type.Desugar(); |
|
|
|
|
|
|
|
var finalArrayType = arrayType.GetPointee() ?? arrayType; |
|
|
|
Class @class; |
|
|
|
Class @class; |
|
|
|
if (arrayType.TryGetClass(out @class) && @class.IsRefType) |
|
|
|
if ((finalArrayType.TryGetClass(out @class)) && @class.IsRefType) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (arrayType == finalArrayType) |
|
|
|
supportBefore.WriteLineIndent( |
|
|
|
supportBefore.WriteLineIndent( |
|
|
|
"{0}[i] = {1}.{2}(*(({1}.{3}*)&({4}[i * sizeof({1}.{3})])));", |
|
|
|
"{0}[i] = {1}.{2}(*(({1}.{3}*)&({4}[i * sizeof({1}.{3})])));", |
|
|
|
value, array.Type, Helpers.CreateInstanceIdentifier, |
|
|
|
value, array.Type, Helpers.CreateInstanceIdentifier, |
|
|
|
Helpers.InternalStruct, Context.ReturnVarName); |
|
|
|
Helpers.InternalStruct, Context.ReturnVarName); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
supportBefore.WriteLineIndent( |
|
|
|
|
|
|
|
$@"{value}[i] = {finalArrayType}.{Helpers.CreateInstanceIdentifier}(({
|
|
|
|
|
|
|
|
CSharpTypePrinter.IntPtrType}) {Context.ReturnVarName}[i]);");
|
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (arrayType.IsPrimitiveType(PrimitiveType.Char) && |
|
|
|
if (arrayType.IsPrimitiveType(PrimitiveType.Char) && |
|
|
|
@ -483,7 +491,6 @@ namespace CppSharp.Generators.CSharp |
|
|
|
if (!VisitType(array, quals)) |
|
|
|
if (!VisitType(array, quals)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
var arrayType = array.Type.Desugar(); |
|
|
|
|
|
|
|
switch (array.SizeType) |
|
|
|
switch (array.SizeType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case ArrayType.ArraySize.Constant: |
|
|
|
case ArrayType.ArraySize.Constant: |
|
|
|
@ -497,7 +504,9 @@ namespace CppSharp.Generators.CSharp |
|
|
|
supportBefore.WriteLine("if ({0} != null)", Context.ArgName); |
|
|
|
supportBefore.WriteLine("if ({0} != null)", Context.ArgName); |
|
|
|
supportBefore.WriteStartBraceIndent(); |
|
|
|
supportBefore.WriteStartBraceIndent(); |
|
|
|
Class @class; |
|
|
|
Class @class; |
|
|
|
if (arrayType.TryGetClass(out @class) && @class.IsRefType) |
|
|
|
var arrayType = array.Type.Desugar(); |
|
|
|
|
|
|
|
var finalArrayType = arrayType.GetPointee() ?? arrayType; |
|
|
|
|
|
|
|
if (finalArrayType.TryGetClass(out @class) && @class.IsRefType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
supportBefore.WriteLine("if (value.Length != {0})", array.Size); |
|
|
|
supportBefore.WriteLine("if (value.Length != {0})", array.Size); |
|
|
|
ThrowArgumentOutOfRangeException(); |
|
|
|
ThrowArgumentOutOfRangeException(); |
|
|
|
@ -505,10 +514,15 @@ namespace CppSharp.Generators.CSharp |
|
|
|
supportBefore.WriteLine("for (int i = 0; i < {0}; i++)", array.Size); |
|
|
|
supportBefore.WriteLine("for (int i = 0; i < {0}; i++)", array.Size); |
|
|
|
if (@class != null && @class.IsRefType) |
|
|
|
if (@class != null && @class.IsRefType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (finalArrayType == arrayType) |
|
|
|
supportBefore.WriteLineIndent( |
|
|
|
supportBefore.WriteLineIndent( |
|
|
|
"*({1}.{2}*) &{0}[i * sizeof({1}.{2})] = *({1}.{2}*){3}[i].{4};", |
|
|
|
"*({1}.{2}*) &{0}[i * sizeof({1}.{2})] = *({1}.{2}*){3}[i].{4};", |
|
|
|
Context.ReturnVarName, arrayType, Helpers.InternalStruct, |
|
|
|
Context.ReturnVarName, arrayType, Helpers.InternalStruct, |
|
|
|
Context.ArgName, Helpers.InstanceIdentifier); |
|
|
|
Context.ArgName, Helpers.InstanceIdentifier); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
supportBefore.WriteLineIndent($@"{Context.ReturnVarName}[i] = ({
|
|
|
|
|
|
|
|
(Context.Context.TargetInfo.PointerWidth == 64 ? "long" : "int")}) { |
|
|
|
|
|
|
|
Context.ArgName}[i].{Helpers.InstanceIdentifier};");
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
|