本文整理汇总了C++中CLR_RT_HeapBlock::InitializeArrayReferenceDirect方法的典型用法代码示例。如果您正苦于以下问题:C++ CLR_RT_HeapBlock::InitializeArrayReferenceDirect方法的具体用法?C++ CLR_RT_HeapBlock::InitializeArrayReferenceDirect怎么用?C++ CLR_RT_HeapBlock::InitializeArrayReferenceDirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLR_RT_HeapBlock
的用法示例。
在下文中一共展示了CLR_RT_HeapBlock::InitializeArrayReferenceDirect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Copy
//.........这里部分代码省略.........
if(arraySrc->SameHeader( *arrayDst ))
{
CLR_UINT8* dataSrc = arraySrc->GetFirstElement();
CLR_UINT8* dataDst = arrayDst->GetFirstElement();
CLR_UINT8 sizeElem = arraySrc->m_sizeOfElement;
dataSrc += indexSrc * sizeElem;
dataDst += indexDst * sizeElem;
if(!arraySrc->m_fReference)
{
memmove( dataDst, dataSrc, length * sizeElem );
}
else
{
CLR_RT_HeapBlock* ptrSrc = (CLR_RT_HeapBlock*)dataSrc;
CLR_RT_HeapBlock* ptrDst = (CLR_RT_HeapBlock*)dataDst;
int incr;
if(arraySrc == arrayDst && ptrSrc < ptrDst)
{
incr = -1;
ptrSrc += length-1;
ptrDst += length-1;
}
else
{
incr = 1;
}
for(int i=0; i<length; i++, ptrSrc += incr, ptrDst += incr)
{
TINYCLR_CHECK_HRESULT(ptrDst->Reassign( *ptrSrc ));
}
}
}
else if(arraySrc->m_fReference && arrayDst->m_fReference)
{
CLR_RT_TypeDescriptor descSrc;
CLR_RT_TypeDescriptor descDst;
CLR_RT_HeapBlock* ptrSrc = (CLR_RT_HeapBlock*)arraySrc->GetElement( indexSrc );
CLR_RT_HeapBlock* ptrDst = (CLR_RT_HeapBlock*)arrayDst->GetElement( indexDst );
TINYCLR_CHECK_HRESULT(descDst.InitializeFromObject( *arrayDst )); descDst.GetElementType( descDst );
for(int i=0; i<length; i++, ptrSrc++, ptrDst++)
{
if(ptrSrc->DataType() == DATATYPE_OBJECT && ptrSrc->Dereference() == NULL)
{
;
}
else
{
TINYCLR_CHECK_HRESULT(descSrc.InitializeFromObject( *ptrSrc ));
if(CLR_RT_ExecutionEngine::IsInstanceOf( descSrc, descDst ) == false)
{
TINYCLR_SET_AND_LEAVE(CLR_E_INVALID_CAST);
}
}
TINYCLR_CHECK_HRESULT(ptrDst->Reassign( *ptrSrc ));
}
}
else
{
CLR_RT_TypeDescriptor descSrc;
CLR_RT_TypeDescriptor descDst;
CLR_RT_HeapBlock ref;
CLR_RT_HeapBlock elem; elem.SetObjectReference( NULL );
CLR_RT_ProtectFromGC gc( elem );
TINYCLR_CHECK_HRESULT(descDst.InitializeFromObject( *arrayDst )); descDst.GetElementType( descDst );
for(int i=0; i<length; i++)
{
ref.InitializeArrayReferenceDirect( *arraySrc, indexSrc++ ); TINYCLR_CHECK_HRESULT(elem.LoadFromReference( ref ));
if(elem.DataType() == DATATYPE_OBJECT && elem.Dereference() == NULL)
{
;
}
else
{
TINYCLR_CHECK_HRESULT(descSrc.InitializeFromObject( elem ));
if(CLR_RT_ExecutionEngine::IsInstanceOf( descSrc, descDst ) == false)
{
TINYCLR_SET_AND_LEAVE(CLR_E_INVALID_CAST);
}
}
ref.InitializeArrayReferenceDirect( *arrayDst, indexDst++ ); TINYCLR_CHECK_HRESULT(elem.StoreToReference( ref, 0 ));
}
}
}
TINYCLR_NOCLEANUP();
}