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);
38 static FCDECL3(void, ArrayClear, ArrayBase* pArrayUNSAFE, INT32 iIndex, INT32 iLength);
40 // This method will create a new array of type type, with zero lower
42 static FCDECL4(Object*, CreateInstance, void* elementTypeHandle, INT32 rank, INT32* pLengths, INT32* pBounds);
44 // This method will return a TypedReference to the array element
45 static FCDECL4(void, GetReference, ArrayBase* refThisUNSAFE, TypedByRef* elemRef, INT32 rank, INT32* pIndices);
47 // This set of methods will set a value in an array
48 static FCDECL2(void, SetValue, TypedByRef* target, Object* objUNSAFE);
50 // This method will initialize an array from a TypeHandle
52 static FCDECL2_IV(void, InitializeArray, ArrayBase* vArrayRef, FCALLRuntimeFieldHandle structField);
55 // Helper for CreateInstance
56 static void CheckElementType(TypeHandle elementType);
58 // Return values for CanAssignArrayType
64 AssignBoxValueClassOrPrimitive,
65 AssignUnboxValueClass,
70 // The following functions are all helpers for ArrayCopy
71 static AssignArrayEnum CanAssignArrayTypeNoGC(const BASEARRAYREF pSrc, const BASEARRAYREF pDest);
72 static AssignArrayEnum CanAssignArrayType(const BASEARRAYREF pSrc, const BASEARRAYREF pDest);
73 static void ArrayCopyNoTypeCheck(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length);
74 static void CastCheckEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length);
75 static void BoxEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length);
76 static void UnBoxEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length);
77 static void PrimitiveWiden(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length);
81 #endif // _ARRAYNATIVE_H_