1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
10 // This file defines the native methods for the Array
14 #ifndef _ARRAYNATIVE_H_
15 #define _ARRAYNATIVE_H_
19 struct FCALLRuntimeFieldHandle
21 ReflectFieldObject *pFieldDONOTUSEDIRECTLY;
23 #define FCALL_RFH_TO_REFLECTFIELD(x) (x).pFieldDONOTUSEDIRECTLY
28 static FCDECL1(INT32, GetRank, ArrayBase* pArray);
29 static FCDECL1(INT32, GetDataPtrOffsetInternal, ArrayBase* array);
30 static FCDECL2(INT32, GetLowerBound, ArrayBase* pArray, unsigned int dimension);
31 static FCDECL2(INT32, GetUpperBound, ArrayBase* pArray, unsigned int dimension);
32 static FCDECL1(INT32, GetLengthNoRank, ArrayBase* pArray);
33 static FCDECL1(INT64, GetLongLengthNoRank, ArrayBase* pArray);
34 static FCDECL2(INT32, GetLength, ArrayBase* pArray, unsigned int dimension);
35 static FCDECL1(void, Initialize, ArrayBase* pArray);
37 static FCDECL6(void, ArrayCopy, ArrayBase* m_pSrc, INT32 m_iSrcIndex, ArrayBase* m_pDst, INT32 m_iDstIndex, INT32 m_iLength, CLR_BOOL reliable);
39 static FCDECL5(void*, GetRawArrayGeometry, ArrayBase* pArray, UINT32* pNumComponents, UINT32* pElementSize, INT32* pLowerBound, CLR_BOOL* pContainsGCPointers);
41 // This method will create a new array of type type, with zero lower
43 static FCDECL4(Object*, CreateInstance, void* elementTypeHandle, INT32 rank, INT32* pLengths, INT32* pBounds);
45 // This method will return a TypedReference to the array element
46 static FCDECL4(void, GetReference, ArrayBase* refThisUNSAFE, TypedByRef* elemRef, INT32 rank, INT32* pIndices);
48 // This set of methods will set a value in an array
49 static FCDECL2(void, SetValue, TypedByRef* target, Object* objUNSAFE);
51 // This method will initialize an array from a TypeHandle
53 static FCDECL2_IV(void, InitializeArray, ArrayBase* vArrayRef, FCALLRuntimeFieldHandle structField);
56 // Helper for CreateInstance
57 static void CheckElementType(TypeHandle elementType);
59 // Return values for CanAssignArrayType
65 AssignBoxValueClassOrPrimitive,
66 AssignUnboxValueClass,
71 // The following functions are all helpers for ArrayCopy
72 static AssignArrayEnum CanAssignArrayTypeNoGC(const BASEARRAYREF pSrc, const BASEARRAYREF pDest);
73 static AssignArrayEnum CanAssignArrayType(const BASEARRAYREF pSrc, const BASEARRAYREF pDest);
74 static void ArrayCopyNoTypeCheck(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length);
75 static void CastCheckEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length);
76 static void BoxEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length);
77 static void UnBoxEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length);
78 static void PrimitiveWiden(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length);
82 #endif // _ARRAYNATIVE_H_