当前位置: 首页>>代码示例>>C++>>正文


C++ CLR_RT_HeapBlock::SetObjectReference方法代码示例

本文整理汇总了C++中CLR_RT_HeapBlock::SetObjectReference方法的典型用法代码示例。如果您正苦于以下问题:C++ CLR_RT_HeapBlock::SetObjectReference方法的具体用法?C++ CLR_RT_HeapBlock::SetObjectReference怎么用?C++ CLR_RT_HeapBlock::SetObjectReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CLR_RT_HeapBlock的用法示例。


在下文中一共展示了CLR_RT_HeapBlock::SetObjectReference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateInstance

HRESULT CLR_RT_HeapBlock_Array::CreateInstance( CLR_RT_HeapBlock& reference, CLR_UINT32 length, const CLR_RT_ReflectionDef_Index& reflex )
{
    NATIVE_PROFILE_CLR_CORE();
    TINYCLR_HEADER();

    CLR_RT_HeapBlock_Array* pArray;
    CLR_RT_TypeDef_Index    cls;
    CLR_RT_TypeDef_Instance inst;

    reference.SetObjectReference( NULL );

    if((CLR_INT32)length < 0) TINYCLR_SET_AND_LEAVE(CLR_E_OUT_OF_RANGE);

    if(reflex.m_kind != REFLECTION_TYPE)
    {
        TINYCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE);
    }

    if(reflex.m_levels == 1)
    {
        cls = reflex.m_data.m_type;
    }
    else
    {
        cls = g_CLR_RT_WellKnownTypes.m_Array;
    }

    if(inst.InitializeFromIndex( cls ) == false)
    {
        TINYCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE);
    }
    else
    {
        CLR_DataType                 dt  = (CLR_DataType)inst.m_target->dataType;
        const CLR_RT_DataTypeLookup& dtl = c_CLR_RT_DataTypeLookup[ dt ];

        if(dtl.m_sizeInBytes == CLR_RT_DataTypeLookup::c_NA)
        {
            TINYCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE);
        }

        pArray    = (CLR_RT_HeapBlock_Array*)g_CLR_RT_ExecutionEngine.ExtractHeapBlocksForArray( inst, length, reflex ); CHECK_ALLOCATION(pArray);

        reference.SetObjectReference( pArray );

        TINYCLR_SET_AND_LEAVE(pArray->ClearElements( 0, length ));
    }

    TINYCLR_NOCLEANUP();
}
开发者ID:EddieGarmon,项目名称:netduino-netmf,代码行数:50,代码来源:CLR_RT_HeapBlock_Array.cpp

示例2: MarshalSockAddress

HRESULT Library_spot_net_native_Microsoft_SPOT_Net_SocketNative::MarshalSockAddress( CLR_RT_HeapBlock& blkDst, const struct SOCK_sockaddr* addrSrc, CLR_UINT32 addrLenSrc )
{
    NATIVE_PROFILE_CLR_NETWORK();
    TINYCLR_HEADER();

    CLR_RT_HeapBlock_Array* arr = NULL;

    CLR_RT_HeapBlock blkArr; blkArr.SetObjectReference( NULL );
    CLR_RT_ProtectFromGC gc( blkArr );
    SOCK_sockaddr_in* dst;
    SOCK_sockaddr_in* src = (SOCK_sockaddr_in*)addrSrc;
        
    TINYCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( blkArr, addrLenSrc, g_CLR_RT_WellKnownTypes.m_UInt8 ));
    
    arr = blkArr.DereferenceArray();

    _ASSERTE(arr);

    dst = (SOCK_sockaddr_in*)arr->GetFirstElement();

    dst->sin_family           = SwapEndianIfBEc16(src->sin_family);
    dst->sin_port             = src->sin_port;
    dst->sin_addr.S_un.S_addr = src->sin_addr.S_un.S_addr;

    memcpy(dst->sin_zero, src->sin_zero, sizeof(dst->sin_zero));

    _ASSERTE(blkDst.DataType() == DATATYPE_BYREF || blkDst.DataType() == DATATYPE_ARRAY_BYREF);

    TINYCLR_CHECK_HRESULT(blkArr.StoreToReference( blkDst, 0 ));

    TINYCLR_NOCLEANUP();
}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:32,代码来源:spot_net_native_Microsoft_SPOT_Net_SocketNative.cpp

示例3: CreateInstance

HRESULT CLR_RT_HeapBlock_String::CreateInstance( CLR_RT_HeapBlock& reference, LPCSTR szText, CLR_RT_Assembly* assm )
{        
    NATIVE_PROFILE_CLR_CORE();
    TINYCLR_HEADER();

    CLR_RT_HeapBlock_String* str;

    reference.SetObjectReference( NULL );

    str = (CLR_RT_HeapBlock_String*)g_CLR_RT_ExecutionEngine.ExtractHeapBytesForObjects( DATATYPE_STRING, 0, sizeof(CLR_RT_HeapBlock_String) ); CHECK_ALLOCATION(str);

    reference.SetObjectReference( str );

#if defined(TINYCLR_NO_ASSEMBLY_STRINGS)            
    TINYCLR_CHECK_HRESULT( CLR_RT_HeapBlock_String::CreateInstance( reference, assm->GetString( CLR_DataFromTk( token ) ) ));    
#else
    str->SetStringText( szText, assm );
#endif

    TINYCLR_NOCLEANUP();
}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:21,代码来源:CLR_RT_HeapBlock_String.cpp

示例4: CreateInstance

HRESULT CLR_RT_HeapBlock_BinaryBlob::CreateInstance( CLR_RT_HeapBlock& reference, CLR_UINT32 length, CLR_RT_MarkingHandler mark, CLR_RT_RelocationHandler relocate, CLR_UINT32 flags )
{
    NATIVE_PROFILE_CLR_CORE();
    TINYCLR_HEADER();

    CLR_RT_HeapBlock_BinaryBlob* obj = Allocate( length, flags ); CHECK_ALLOCATION(obj);

    reference.SetObjectReference( obj );

    obj->SetBinaryBlobHandlers( mark, relocate );
    obj->m_assembly = NULL;

    TINYCLR_NOCLEANUP();
}
开发者ID:Sorcha,项目名称:NETMF-LPC,代码行数:14,代码来源:CLR_RT_HeapBlock_BinaryBlob.cpp

示例5: Grow

HRESULT CLR_RT_HeapBlock_XmlNameTable::Grow()
{
    TINYCLR_HEADER();
    
    CLR_RT_HeapBlock_Array*              oldEntries;
    CLR_RT_HeapBlock                     newEntriesHB;
    CLR_RT_HeapBlock_Array*              newEntries;
    CLR_RT_HeapBlock_XmlNameTable_Entry* entry;
    CLR_RT_HeapBlock_XmlNameTable_Entry* next;
    CLR_RT_HeapBlock*                    newEntryHB;

    CLR_UINT32                           i;
    CLR_INT32                            newIndex;
    CLR_INT32                            newMask;

    newMask = GetMask() * 2 + 1;

    // allocate a new instance of Entry array
    TINYCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( newEntriesHB, newMask + 1, g_CLR_RT_WellKnownTypes.m_XmlNameTable_Entry ));

    newEntries = newEntriesHB.DereferenceArray();
    oldEntries = GetEntries();

    // Go through the old buckets, and resort them
    for(i = 0; i < oldEntries->m_numOfElements; i++)
    {
        entry = (CLR_RT_HeapBlock_XmlNameTable_Entry*)((CLR_RT_HeapBlock*)oldEntries->GetElement( i ))->Dereference();
    
        while(entry != NULL)
        {
            newIndex = entry->GetHashCode() & newMask;
            next = entry->GetNext();
    
            newEntryHB = (CLR_RT_HeapBlock*)newEntries->GetElement( newIndex );
    
            entry->SetNext( (CLR_RT_HeapBlock_XmlNameTable_Entry*)newEntryHB->Dereference() );
    
            newEntryHB->SetObjectReference( entry );
    
            entry = next;
        }
    }

    SetEntries( newEntries );
    SetMask   ( newMask    );

    TINYCLR_NOCLEANUP();
}
开发者ID:EddieGarmon,项目名称:netduino-netmf,代码行数:48,代码来源:XmlNameTable.cpp

示例6: Enqueue

// May Trigger GC, but parameter value will be protected
HRESULT CLR_RT_HeapBlock_Queue::Enqueue( CLR_RT_HeapBlock* value )
{
    NATIVE_PROFILE_CLR_CORE();
    TINYCLR_HEADER();

    CLR_RT_HeapBlock_Array* array    = GetArray();
    CLR_INT32               size     = GetSize();
    CLR_INT32               tail     = GetTail();
    CLR_INT32               capacity = array->m_numOfElements;

    if(size == capacity)
    {
        // Set new capacity
        CLR_RT_HeapBlock newArrayHB;
        
        // Protect value from GC, in case CreateInstance triggers one
        CLR_RT_HeapBlock valueHB; valueHB.SetObjectReference( value );
        CLR_RT_ProtectFromGC gc( valueHB );

        capacity *= 2;

        TINYCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( newArrayHB, capacity, g_CLR_RT_WellKnownTypes.m_Object ));

        array = newArrayHB.DereferenceArray();

        CopyTo( array, 0 );

        tail = size;

        SetArray( array );
        SetHead ( 0     );
        SetTail ( tail  );
    }

    ((CLR_RT_HeapBlock*)array->GetElement( tail ))->SetObjectReference( value );

    SetTail( (tail + 1) % capacity );

    SetSize( size + 1 );

    TINYCLR_NOCLEANUP();
}
开发者ID:EddieGarmon,项目名称:netduino-netmf,代码行数:43,代码来源:CLR_RT_HeapBlock_Queue.cpp

示例7: CreateDomain___STATIC__SystemAppDomain__STRING

HRESULT Library_corlib_native_System_AppDomain::CreateDomain___STATIC__SystemAppDomain__STRING( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_CORE();
    TINYCLR_HEADER();
   
    CLR_RT_AppDomain*    appDomain   = NULL;        
    CLR_RT_HeapBlock&    pArgs       = stack.Arg0();    
    CLR_RT_HeapBlock     res; res.SetObjectReference( NULL );
    CLR_RT_ProtectFromGC gc( res );
    LPCSTR               szName;

    szName = pArgs.RecoverString(); FAULT_ON_NULL(szName);
    
    TINYCLR_CHECK_HRESULT(CLR_RT_AppDomain::CreateInstance( szName, appDomain ));

    //load mscorlib
    TINYCLR_CHECK_HRESULT(appDomain->LoadAssembly( g_CLR_RT_TypeSystem.m_assemblyMscorlib ));        
    //load Native
    TINYCLR_CHECK_HRESULT(appDomain->LoadAssembly( g_CLR_RT_TypeSystem.m_assemblyNative   ));
    
    TINYCLR_CHECK_HRESULT(appDomain->GetManagedObject( res ));

    //Marshal the new AD to the calling AD.
    TINYCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.GetCurrentAppDomain()->MarshalObject( res, res, appDomain ));

    stack.PushValueAndAssign( res );

    TINYCLR_CLEANUP();

    if(FAILED(hr))
    {
        if(appDomain)
        {
            appDomain->DestroyInstance();
        }        
    }

    TINYCLR_CLEANUP_END();
}
开发者ID:dienbk7x,项目名称:NetmfSTM32,代码行数:39,代码来源:corlib_native_System_AppDomain.cpp

示例8:

HRESULT Library_spot_native_Microsoft_SPOT_CryptoState::Buffer::Allocate( CLR_RT_HeapBlock& ref, int size )
{
    TINYCLR_HEADER();

    ref.SetObjectReference( NULL );

    if(size)
    {
        TINYCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( ref, size, g_CLR_RT_WellKnownTypes.m_UInt8 ));

        m_array = ref.DereferenceArray();
    }
    else
    {
        m_array = NULL;
    }

    m_offset = 0;
    m_count  = size;

    TINYCLR_NOCLEANUP();
}
开发者ID:Wampamba-Nooh,项目名称:MicroFrameworkSDK-Mono,代码行数:22,代码来源:spot_native_Microsoft_SPOT_Cryptography_Key.cpp

示例9: MarshalSockAddress

HRESULT Library_spot_net_native_Microsoft_SPOT_Net_SocketNative::MarshalSockAddress( CLR_RT_HeapBlock& blkDst, const struct SOCK_sockaddr* addrSrc, CLR_UINT32 addrLenSrc )
{
    NATIVE_PROFILE_CLR_NETWORK();
    TINYCLR_HEADER();

    CLR_RT_HeapBlock_Array* arr = NULL;

    CLR_RT_HeapBlock blkArr; blkArr.SetObjectReference( NULL );
    CLR_RT_ProtectFromGC gc( blkArr );
        
    TINYCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( blkArr, addrLenSrc, g_CLR_RT_WellKnownTypes.m_UInt8 ));
    
    arr = blkArr.DereferenceArray();

    _ASSERTE(arr);

    memcpy( arr->GetFirstElement(), addrSrc, addrLenSrc );

    _ASSERTE(blkDst.DataType() == DATATYPE_BYREF || blkDst.DataType() == DATATYPE_ARRAY_BYREF);

    TINYCLR_CHECK_HRESULT(blkArr.StoreToReference( blkDst, 0 ));

    TINYCLR_NOCLEANUP();
}
开发者ID:Wampamba-Nooh,项目名称:MicroFrameworkSDK-Mono,代码行数:24,代码来源:spot_net_native_Microsoft_SPOT_Net_SocketNative.cpp

示例10: gc

HRESULT Library_corlib_native_System_Text_UTF8Encoding::Helper__GetChars(CLR_RT_StackFrame& stack, bool fIndexed)
{
    NATIVE_PROFILE_CLR_CORE();
    TINYCLR_HEADER();

    LPSTR szText;
    CLR_RT_HeapBlock ref;
    ref.SetObjectReference( NULL );
    CLR_RT_ProtectFromGC gc( ref );
    CLR_RT_HeapBlock_Array* pArrayBytes = stack.Arg1().DereferenceArray();
    CLR_INT32               byteIdx     = fIndexed ? stack.Arg2().NumericByRef().s4 : 0;
    CLR_INT32               byteCnt     = fIndexed ? stack.Arg3().NumericByRef().s4 : pArrayBytes->m_numOfElements;
    CLR_RT_HeapBlock_Array* pArrayBytesCopy;
    CLR_RT_HeapBlock_Array* arrTmp;
    int cBytesCopy;

    FAULT_ON_NULL(pArrayBytes);

    _ASSERTE(pArrayBytes->m_typeOfElement == DATATYPE_U1);

    if((byteIdx + byteCnt) > (CLR_INT32)pArrayBytes->m_numOfElements) TINYCLR_SET_AND_LEAVE(CLR_E_OUT_OF_RANGE);

    cBytesCopy = byteCnt+1;

    /* Copy the array to a temporary buffer to create a zero-terminated string */
    TINYCLR_CHECK_HRESULT( CLR_RT_HeapBlock_Array::CreateInstance( ref, cBytesCopy, g_CLR_RT_WellKnownTypes.m_UInt8 ));

    pArrayBytesCopy = ref.DereferenceArray();
    szText = (LPSTR)pArrayBytesCopy->GetFirstElement();

    hal_strncpy_s( szText, cBytesCopy, (LPSTR)pArrayBytes->GetElement(byteIdx), byteCnt );

    TINYCLR_CHECK_HRESULT(Library_corlib_native_System_String::ConvertToCharArray( szText, stack.PushValueAndClear(), arrTmp, 0, -1 ));

    TINYCLR_NOCLEANUP();
}
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:36,代码来源:corlib_native_System_Text_UTF8Encoding.cpp

示例11: Dequeue

HRESULT CLR_RT_HeapBlock_Queue::Dequeue( CLR_RT_HeapBlock*& value )
{
    NATIVE_PROFILE_CLR_CORE();
    TINYCLR_HEADER();

    CLR_RT_HeapBlock_Array* array   = GetArray();
    CLR_INT32               size    = GetSize();
    CLR_INT32               head    = Head();
    CLR_RT_HeapBlock*       removed;

    if(size == 0) TINYCLR_SET_AND_LEAVE(CLR_E_INVALID_OPERATION);

    removed = (CLR_RT_HeapBlock*)array->GetElement( head );

    value = removed->Dereference();

    removed->SetObjectReference( NULL );

    SetHead( (head + 1) % array->m_numOfElements );
    
    SetSize( size - 1 );

    TINYCLR_NOCLEANUP();
}
开发者ID:EddieGarmon,项目名称:netduino-netmf,代码行数:24,代码来源:CLR_RT_HeapBlock_Queue.cpp

示例12: AddEntry

HRESULT CLR_RT_HeapBlock_XmlNameTable::AddEntry( CLR_RT_HeapBlock_String*& str, CLR_INT32 hashCode )
{
    TINYCLR_HEADER();
    
    CLR_RT_HeapBlock                     newEntryHB;
    CLR_RT_HeapBlock_XmlNameTable_Entry* newEntry;
    CLR_RT_HeapBlock*                    entryHB;

    CLR_INT32                            count;  

    // create a new instance of the Entry object
    TINYCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex( newEntryHB, g_CLR_RT_WellKnownTypes.m_XmlNameTable_Entry ));
    
    newEntry = (CLR_RT_HeapBlock_XmlNameTable_Entry*)newEntryHB.Dereference();
    
    // attach it to the front of the bucket
    entryHB = (CLR_RT_HeapBlock*)GetEntries()->GetElement( GetMask() & hashCode );

    newEntry->SetStr( str );
    newEntry->SetHashCode( hashCode );
    newEntry->SetNext( (CLR_RT_HeapBlock_XmlNameTable_Entry*)entryHB->Dereference() );
    
    entryHB->SetObjectReference( newEntry );

    count = GetCount() + 1;
    
    SetCount( count );

    // if we reach the threshold, we'll grow the buckets
    if(count == GetMask())
    {
        Grow();
    }

    TINYCLR_NOCLEANUP();
}
开发者ID:EddieGarmon,项目名称:netduino-netmf,代码行数:36,代码来源:XmlNameTable.cpp

示例13: Pop


//.........这里部分代码省略.........
                {
                    //Do nothing here. Pushing return values onto stack frames that don't expect them are a bad idea.
                }
#if defined(TINYCLR_APPDOMAINS)
                else if((m_flags & CLR_RT_StackFrame::c_AppDomainTransition) != 0)
                {
                    (void)PopAppDomainTransition();
                }
#endif
            }
            else //!c_moreFlagsToCheck
            {
                //
                // Push the return, if any.
                //
                if(m_call.m_target->retVal != DATATYPE_VOID)
                {
                    if(m_owningThread->m_currentException.Dereference() == NULL)
                    {
                        CLR_RT_HeapBlock& src = this  ->TopValue          (     );
                        CLR_RT_HeapBlock& dst = caller->PushValueAndAssign( src );

                        dst.Promote();
                    }
                }
            }
        }
    }
#if defined(TINYCLR_ENABLE_SOURCELEVELDEBUGGING)
    else
    {
        int idx = m_owningThread->m_scratchPad;

        if(idx >= 0)
        {
            CLR_RT_HeapBlock_Array* array = g_CLR_RT_ExecutionEngine.m_scratchPadArray;

            if(array && array->m_numOfElements > (CLR_UINT32)idx)
            {
                CLR_RT_HeapBlock* dst       = (CLR_RT_HeapBlock*)array->GetElement( (CLR_UINT32)idx );
                CLR_RT_HeapBlock* exception = m_owningThread->m_currentException.Dereference();

                dst->SetObjectReference( NULL );

                if(exception != NULL)
                {
                    dst->SetObjectReference( exception );
                }
                else if(m_call.m_target->retVal != DATATYPE_VOID)
                {
                    CLR_RT_SignatureParser sig;
                    sig.Initialize_MethodSignature( this->m_call.m_assm, this->m_call.m_target );
                    CLR_RT_SignatureParser::Element res;
                    CLR_RT_TypeDescriptor           desc;

                    dst->Assign( this->TopValue() );

                    //Perform boxing, if needed.

                    //Box to the return value type
                    _SIDE_ASSERTE(SUCCEEDED(sig.Advance( res )));
                    _SIDE_ASSERTE(SUCCEEDED(desc.InitializeFromType( res.m_cls )));


                    if(c_CLR_RT_DataTypeLookup[ this->DataType() ].m_flags & CLR_RT_DataTypeLookup::c_OptimizedValueType
                            || desc.m_handlerCls.m_target->IsEnum()
                      )
                    {
                        if(FAILED(dst->PerformBoxing( desc.m_handlerCls )))
                        {
                            dst->SetObjectReference( NULL );
                        }
                    }
                }
            }
        }
    }
#endif

    //
    // We could be jumping outside of a nested exception handler.
    //

    m_owningThread->PopEH( this, NULL );


    //
    // If this StackFrame owns a SubThread, kill it.
    //
    {
        CLR_RT_SubThread* sth = (CLR_RT_SubThread*)m_owningSubThread->Next();

        if(sth->Next() && sth->m_owningStackFrame == this)
        {
            CLR_RT_SubThread::DestroyInstance( sth->m_owningThread, sth, CLR_RT_SubThread::MODE_IncludeSelf );
        }
    }

    g_CLR_RT_EventCache.Append_Node( this );
}
开发者ID:awakegod,项目名称:NETMF-LPC,代码行数:101,代码来源:CLR_RT_StackFrame.cpp

示例14: gc

HRESULT Library_spot_net_native_Microsoft_SPOT_Net_SocketNative::getaddrinfo___STATIC__VOID__STRING__BYREF_STRING__BYREF_SZARRAY_SZARRAY_U1( CLR_RT_StackFrame& stack )
{
    NATIVE_PROFILE_CLR_NETWORK();
    TINYCLR_HEADER();

    LPCSTR szName = stack.Arg0().RecoverString();
    struct SOCK_addrinfo hints;
    struct SOCK_addrinfo* addr = NULL;
    struct SOCK_addrinfo* addrT;
    CLR_UINT32        cAddresses = 0;
    CLR_RT_HeapBlock* pAddress;
    CLR_INT32         timeout_ms = 30000;
    CLR_RT_HeapBlock  hbTimeout;
    CLR_INT32         ret;
    bool              fRes = true;
    CLR_INT64*        timeout;

    hbTimeout.SetInteger( timeout_ms );

    TINYCLR_CHECK_HRESULT(stack.SetupTimeout( hbTimeout, timeout ));

    do
    {
        memset( &hints, 0, sizeof(hints) );

        ret = SOCK_getaddrinfo( szName, NULL, &hints, &addr );

        if(ret == SOCK_SOCKET_ERROR)
        {
            if(SOCK_getlasterror() == SOCK_EWOULDBLOCK)
            {
                // non-blocking - allow other threads to run while we wait for handle activity
                TINYCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.WaitEvents( stack.m_owningThread, *timeout, CLR_RT_ExecutionEngine::c_Event_Socket, fRes ));
            }
            else
            {
                break;
            }
        }
        else
        {
            break;
        }
    }
    while(fRes);
    
    // timeout expired
    if(!fRes)
    {
        ret = SOCK_SOCKET_ERROR;
        
        ThrowError( stack, SOCK_ETIMEDOUT );
    
        TINYCLR_SET_AND_LEAVE( CLR_E_PROCESS_EXCEPTION );
    }

    // getaddrinfo returns a winsock error code rather than SOCK_SOCKET_ERROR, so pass this on to the exception handling
    if(ret != 0)
    {
        ThrowError( stack, ret );
        TINYCLR_SET_AND_LEAVE(CLR_E_PROCESS_EXCEPTION);
    }

    {
        CLR_RT_HeapBlock  hbCanonicalName;
        CLR_RT_HeapBlock  hbAddresses;
        
        hbCanonicalName.SetObjectReference( NULL );
        CLR_RT_ProtectFromGC gc( hbCanonicalName );

        hbAddresses.SetObjectReference( NULL );
        CLR_RT_ProtectFromGC gc2( hbAddresses );

        for(int pass = 0; pass < 2; pass++)
        {                                    
            cAddresses = 0;

            for(addrT = addr; addrT != NULL; addrT = addrT->ai_next)
            {
                if(pass == 1)
                {
                    if(addrT->ai_canonname && addrT->ai_canonname[ 0 ])
                    {
                        //allocate return string
                        TINYCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( hbCanonicalName, addrT->ai_canonname ));
                        TINYCLR_CHECK_HRESULT(hbCanonicalName.StoreToReference( stack.Arg1(), 0 ));
                    }

                    //allocate address and store into array
                    pAddress = (CLR_RT_HeapBlock*)hbAddresses.DereferenceArray()->GetElement( cAddresses );

                    TINYCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( *pAddress, (CLR_UINT32)addrT->ai_addrlen, g_CLR_RT_WellKnownTypes.m_UInt8 ));

                    //copy address.
                    memcpy( pAddress->DereferenceArray()->GetFirstElement(), addrT->ai_addr, addrT->ai_addrlen );
                }
                                
                cAddresses++;
            }
                            
//.........这里部分代码省略.........
开发者ID:Wampamba-Nooh,项目名称:MicroFrameworkSDK-Mono,代码行数:101,代码来源:spot_net_native_Microsoft_SPOT_Net_SocketNative.cpp

示例15: PopAppDomainTransition

HRESULT CLR_RT_StackFrame::PopAppDomainTransition()
{
    NATIVE_PROFILE_CLR_CORE();
    TINYCLR_HEADER();

    bool fException = false;
    CLR_RT_HeapBlock exception;
    CLR_RT_StackFrame* caller = this->Caller();

    exception.SetObjectReference( NULL );

    if(m_flags & CLR_RT_StackFrame::c_AppDomainInjectException)
    {
        //this is the last frame on the thread in a doomed AppDomain
        //Convert the current ThreadAbortException into an AppDomainUnloaded exception

        _ASSERTE(m_owningThread->m_flags & CLR_RT_Thread::TH_F_Aborted);
        _ASSERTE(m_owningThread->m_flags & CLR_RT_Thread::TH_F_ContainsDoomedAppDomain);
        _ASSERTE(m_owningThread->m_currentException.Dereference() != NULL);
        _ASSERTE(m_owningThread->m_currentException.Dereference()->ObjectCls().m_data == g_CLR_RT_WellKnownTypes.m_ThreadAbortException.m_data);
        _ASSERTE(!m_appDomain->IsLoaded());

        m_owningThread->m_flags &= ~(CLR_RT_Thread::TH_F_Aborted | CLR_RT_Thread::TH_F_ContainsDoomedAppDomain);

        hr = CLR_E_APPDOMAIN_EXITED;
    }
    else if(m_owningThread->m_currentException.Dereference() == NULL)
    {
        _ASSERTE((m_flags & CLR_RT_StackFrame::c_AppDomainInjectException) == 0);

        //Normal return.  No exception is in flight

        if(m_flags & CLR_RT_StackFrame::c_AppDomainMethodInvoke)
        {
            //  For dynamic invoke,
            //  we do not marshal byRef parameters back to the calling AppDomain
            //  The caller is a native method (MethodBase::Invoke), and does not have the args on it's eval stack.
        }
        else
        {
            int cArgs = m_call.m_target->numArgs;

            //First marshal the ref parameters
            TINYCLR_CHECK_HRESULT(caller->m_appDomain->MarshalParameters( &caller->m_evalStackPos[ -cArgs ], m_arguments, cArgs, true ));

            //Now, pop the caller's arguments off the eval stack
            caller->m_evalStackPos -= cArgs;
        }

        // Now, push the return, if any.
        if(m_call.m_target->retVal != DATATYPE_VOID)
        {
            CLR_RT_HeapBlock& dst = caller->PushValueAndClear();
            CLR_RT_HeapBlock& src = this  ->TopValue ();

            TINYCLR_CHECK_HRESULT(caller->m_appDomain->MarshalObject( src, dst ));

            dst.Promote();
        }
    }
    else //Exception
    {
        //Normal exceptions must be marshaled to the caller's AppDomain
        TINYCLR_CHECK_HRESULT(caller->m_appDomain->MarshalObject( m_owningThread->m_currentException, exception ));
        fException = true;
    }

    TINYCLR_CLEANUP();

    if(FAILED(hr) || fException)
    {
        if(FAILED(hr))
        {
            (void)Library_corlib_native_System_Exception::CreateInstance( exception, hr, caller );
        }

        m_owningThread->m_currentException.Assign( exception );
    }

    (void)g_CLR_RT_ExecutionEngine.SetCurrentAppDomain( caller->m_appDomain );

    TINYCLR_CLEANUP_END();
}
开发者ID:awakegod,项目名称:NETMF-LPC,代码行数:83,代码来源:CLR_RT_StackFrame.cpp


注:本文中的CLR_RT_HeapBlock::SetObjectReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。