Using 2D arrays
stonfute opened this issue · 5 comments
Hi,
I'm using NativeScript in a project and I've notice a problem when using 2D arrays.
In C# I'm defining 2D arrays as float[,] values
but this generate System::Array2<System::Single, System::Single>
in Bindings.h/cpp
System::Array2<System::Single, System::Single>
is not defined and it should generate System::Array2<System::Single>
.
Am I right ?
Am I using 2D array as designed in generator ? Should I use float[][]
instead of float[,]
?
Regards,
Hi @stonfute ,
float[][]
and float[,]
are quite different. The former is an array of arrays and may be jagged or even contain null
elements. The latter is a 2D array, i.e. one with "rank" 2.
Check out the first and second array articles from the series for more details. The first has a usage example for the config JSON:
{
"Arrays": [
{
"Type": "System.Int32"
},
{
"Type": "System.Single",
"Ranks": [ 1, 2, 3 ]
}
]
}
In your case, I suspect you should add just this:
{
"Arrays": [
{
"Type": "System.Single",
"Ranks": [ 2 ]
}
]
}
Hope that helps,
-Jackson
Thank you for your time.
In my case it was "Ranks": [ 1, 2 ]
cause I only want to use 2D arrays.
I will try.
This is still an issue with "Ranks": [ 1, 2, 3 ]
.
Also reproductible with 3D array of any type.
C# property with type int[,,]
generate System::Array3<System::Int32, System::Int32, System::Int32>
type for both get/set methods but it should be System::Array3<System::Int32>