Refactor managed array unboxing to handle case of C# array passes as object
#1415
This commit is contained in:
@@ -85,6 +85,7 @@ public:
|
||||
static MClass* GetClass(MClass* elementKlass);
|
||||
static int32 GetLength(const MArray* obj);
|
||||
static void* GetAddress(const MArray* obj);
|
||||
static MArray* Unbox(MObject* obj);
|
||||
|
||||
template<typename T>
|
||||
FORCE_INLINE static T* GetAddress(const MArray* obj)
|
||||
|
||||
@@ -363,11 +363,12 @@ struct MConverter<Array<T>>
|
||||
|
||||
void Unbox(Array<T>& result, MObject* data)
|
||||
{
|
||||
const int32 length = data ? MCore::Array::GetLength((MArray*)data) : 0;
|
||||
MArray* array = MCore::Array::Unbox(data);
|
||||
const int32 length = array ? MCore::Array::GetLength(array) : 0;
|
||||
result.Resize(length);
|
||||
MConverter<T> converter;
|
||||
Span<T> resultSpan(result.Get(), length);
|
||||
converter.ToNativeArray(resultSpan, (MArray*)data);
|
||||
converter.ToNativeArray(resultSpan, array);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user