diff -ur /usr/local/src/112/bridges/source/cpp_uno/gcc3_linux_sparc/cpp2uno.cxx source/cpp_uno/gcc3_linux_sparc/cpp2uno.cxx --- /usr/local/src/112/bridges/source/cpp_uno/gcc3_linux_sparc/cpp2uno.cxx 2004-05-04 01:43:35.000000000 +1000 +++ source/cpp_uno/gcc3_linux_sparc/cpp2uno.cxx 2004-05-23 19:17:11.862590000 +1000 @@ -2,9 +2,9 @@ * * $RCSfile: cpp2uno.cxx,v $ * - * $Revision: 1.2.34.1 $ + * $Revision: 1.4 $ * - * last change: $Author: vg $ $Date: 2004/05/03 15:43:35 $ + * last change: $Author: svesik $ $Date: 2004/04/21 13:40:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -58,51 +58,22 @@ * * ************************************************************************/ - -#define LEAK_STATIC_DATA -// #define TRACE(x) OSL_TRACE(x) -#define TRACE(x) - -#include -#include -#include -#include -#ifndef _RTL_ALLOC_H_ -#include -#endif -#ifndef _OSL_MUTEX_HXX_ -#include -#endif - -#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_ +#include #include -#endif -#ifndef _UNO_DATA_H_ #include -#endif -#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_ -#include -#endif -#ifndef _BRIDGES_CPP_UNO_TYPE_MISC_HXX_ -#include -#endif - +#include "bridges/cpp_uno/shared/bridge.hxx" +#include "bridges/cpp_uno/shared/cppinterfaceproxy.hxx" +#include "bridges/cpp_uno/shared/types.hxx" +#include "bridges/cpp_uno/shared/vtablefactory.hxx" #include "share.hxx" using namespace com::sun::star::uno; -using namespace std; -using namespace osl; -using namespace rtl; -namespace CPPU_CURRENT_NAMESPACE +namespace { - -//================================================================================================== -rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT; - //================================================================================================== static typelib_TypeClass cpp2uno_call( - cppu_cppInterfaceProxy * pThis, + bridges::cpp_uno::shared::CppInterfaceProxy * pThis, const typelib_TypeDescription * pMemberTypeDescr, typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return sal_Int32 nParams, typelib_MethodParameter * pParams, @@ -122,16 +93,19 @@ if (pReturnTypeDescr) { - if (cppu_isSimpleType( pReturnTypeDescr )) + if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr )) + { pUnoReturn = pRegisterReturn; // direct way for simple types + } else // complex return via ptr (pCppReturn) { pCppReturn = *(void**)pCppStack; - - pUnoReturn = (cppu_relatesToInterface( pReturnTypeDescr ) + pCppStack += sizeof( void* ); + pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( + pReturnTypeDescr ) ? alloca( pReturnTypeDescr->nSize ) : pCppReturn); // direct way - pCppStack += sizeof( void* ); + } } // pop this @@ -155,10 +129,10 @@ typelib_TypeDescription * pParamTypeDescr = 0; TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef ); - if (!rParam.bOut && cppu_isSimpleType( pParamTypeDescr )) // value + if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) // value { - pCppArgs[nPos] = pUnoArgs[nPos] = - adjustPointer( pCppStack, pParamTypeDescr ); + pCppArgs[nPos] = pCppStack; + pUnoArgs[nPos] = pCppStack; switch (pParamTypeDescr->eTypeClass) { case typelib_TypeClass_HYPER: @@ -195,11 +169,12 @@ ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; } // is in/inout - else if (cppu_relatesToInterface( pParamTypeDescr )) + else if (bridges::cpp_uno::shared::relatesToInterfaceType( + pParamTypeDescr )) { uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ), *(void **)pCppStack, pParamTypeDescr, - &pThis->pBridge->aCpp2Uno ); + pThis->getBridge()->getCpp2Uno() ); pTempIndizes[nTempIndizes] = nPos; // has to be reconverted // will be released at reconversion ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; @@ -219,8 +194,7 @@ uno_Any * pUnoExc = &aUnoExc; // invoke uno dispatch call - (*pThis->pUnoI->pDispatcher)( pThis->pUnoI, pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc ); - + (*pThis->getUnoI()->pDispatcher)(pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc ); // in case an exception occured... if (pUnoExc) { @@ -235,9 +209,10 @@ } if (pReturnTypeDescr) TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); - - raiseException( &aUnoExc, &pThis->pBridge->aUno2Cpp ); // has to destruct the any - // is here for dummy + CPPU_CURRENT_NAMESPACE::raiseException( + &aUnoExc, pThis->getBridge()->getUno2Cpp() ); + // has to destruct the any + // is here for dummy return typelib_TypeClass_VOID; } else // else no exception occured... @@ -253,7 +228,7 @@ // convert and assign uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release ); uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr, - &pThis->pBridge->aUno2Cpp ); + pThis->getBridge()->getUno2Cpp() ); } // destroy temp uno param uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); @@ -266,7 +241,7 @@ if (pUnoReturn != pCppReturn) // needs reconversion { uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr, - &pThis->pBridge->aUno2Cpp ); + pThis->getBridge()->getUno2Cpp() ); // destroy temp uno return uno_destructData( pUnoReturn, pReturnTypeDescr, 0 ); } @@ -287,51 +262,53 @@ //================================================================================================== static typelib_TypeClass cpp_mediate( - sal_Int32 nVtableCall, - void ** pCallStack, - sal_Int64 * pRegisterReturn /* space for register return */ ) + int nFunctionIndex, + void ** pCallStack, + int nVtableOffset, + sal_Int64 * pRegisterReturn /* space for register return */ ) { OSL_ENSURE( sizeof(sal_Int32)==sizeof(void *), "### unexpected!" ); - // pCallStack: this, params // eventual [ret*] lies at pCallStack -1 // so count down pCallStack by one to keep it simple - // _this_ ptr is patched cppu_XInterfaceProxy object - cppu_cppInterfaceProxy * pCppI = NULL; - pCppI = (cppu_cppInterfaceProxy *)(XInterface *)*pCallStack; - if( nVtableCall & 0x80000000 ) + void * pThis; + if (nFunctionIndex & 0x80000000) { - pCallStack--; - nVtableCall &= 0x7fffffff; + nFunctionIndex &= 0x7FFFFFFF; + pThis=pCallStack[1]; } + else + { + pThis=pCallStack[0]; + } + pThis = static_cast< char *>(pThis) - nVtableOffset; + bridges::cpp_uno::shared::CppInterfaceProxy * pCppI + = bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy( + pThis); + typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr(); - typelib_InterfaceTypeDescription * pTypeDescr = pCppI->pTypeDescr; - - OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, + OSL_ENSURE( nFunctionIndex < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" ); - if (nVtableCall >= pTypeDescr->nMapFunctionIndexToMemberIndex) + if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex) { - throw RuntimeException( OUString::createFromAscii("illegal vtable index!"), (XInterface *)pCppI ); + throw RuntimeException( rtl::OUString::createFromAscii("illegal vtable index!"), (XInterface *)pCppI ); } - + // determine called method - OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" ); - sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nVtableCall]; + sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex]; OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" ); - TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] ); - -#if defined BRIDGES_DEBUG - OString cstr( OUStringToOString( aMemberDescr.get()->pTypeName, RTL_TEXTENCODING_ASCII_US ) ); - fprintf( stderr, "calling %s, nVtableCall=%d\n", cstr.getStr(), nVtableCall ); -#endif +//#if defined BRIDGES_DEBUG +// OString cstr( OUStringToOString( aMemberDescr.get()->pTypeName, RTL_TEXTENCODING_ASCII_US ) ); +// fprintf( stderr, "calling %s, nVtableCall=%d\n", cstr.getStr(), nVtableCall ); +//#endif typelib_TypeClass eRet; switch (aMemberDescr.get()->eTypeClass) { case typelib_TypeClass_INTERFACE_ATTRIBUTE: { - if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nVtableCall) + if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex) { // is GET method eRet = cpp2uno_call( @@ -360,7 +337,7 @@ case typelib_TypeClass_INTERFACE_METHOD: { // is METHOD - switch (nVtableCall) + switch (nFunctionIndex) { case 1: // acquire() pCppI->acquireProxy(); // non virtual call! @@ -377,9 +354,10 @@ if (pTD) { XInterface * pInterface = 0; - (*pCppI->pBridge->pCppEnv->getRegisteredInterface)( - pCppI->pBridge->pCppEnv, - (void **)&pInterface, pCppI->oid.pData, (typelib_InterfaceTypeDescription *)pTD ); + (*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)( + pCppI->getBridge()->getCppEnv(), + (void **)&pInterface, pCppI->getOid().pData, + (typelib_InterfaceTypeDescription *)pTD ); if (pInterface) { @@ -405,73 +383,18 @@ } break; } - default: - { - throw RuntimeException( OUString::createFromAscii("no member description found!"), (XInterface *)pCppI ); - // is here for dummy - eRet = typelib_TypeClass_VOID; - } +// default: +// { +// throw RuntimeException( +// rtl::OUString::createFromAscii("no member description found!"), +// (XInterface *)pThis ); +// // is here for dummy +// eRet = typelib_TypeClass_VOID; +// } } - return eRet; } -//================================================================================================== -class MediateClassData -{ -public: - struct ClassDataBuffer - { - void* m_pVTable; - - ~ClassDataBuffer(); - }; -private: - - map< OUString, ClassDataBuffer* > m_aClassData; - Mutex m_aMutex; - - void createVTable( ClassDataBuffer*, typelib_InterfaceTypeDescription* ); -public: - const ClassDataBuffer* getClassData( typelib_InterfaceTypeDescription* ); - - MediateClassData() {} - ~MediateClassData(); -}; -//__________________________________________________________________________________________________ -MediateClassData::ClassDataBuffer::~ClassDataBuffer() -{ - delete m_pVTable; -} - -//__________________________________________________________________________________________________ -MediateClassData::~MediateClassData() -{ - TRACE( "> calling ~MediateClassData(): freeing mediate vtables... <\n" ); - - // this MUST be the absolute last one which is called! - for ( map< OUString, ClassDataBuffer* >::iterator iPos( m_aClassData.begin() ); iPos != m_aClassData.end(); ++iPos ) - { - // todo -// delete (*iPos).second; - } -} - -//__________________________________________________________________________________________________ - -const MediateClassData::ClassDataBuffer* MediateClassData::getClassData( typelib_InterfaceTypeDescription* pType ) -{ - MutexGuard aGuard( m_aMutex ); - - map< OUString, ClassDataBuffer* >::iterator element = m_aClassData.find( pType->aBase.pTypeName ); - if( element != m_aClassData.end() ) - return (*element).second; - - ClassDataBuffer* pBuffer = new ClassDataBuffer(); - createVTable( pBuffer, pType ); - m_aClassData[ pType->aBase.pTypeName ] = pBuffer; - return pBuffer; -} //================================================================================================== @@ -479,29 +402,33 @@ * is called on incoming vtable calls * (called by asm snippets) */ -static void cpp_vtable_call() + static void cpp_vtable_call() { - int nTableEntry; - void** pCallStack; + + int functionIndex; + void** pCallStack; + int vtableOffset; volatile sal_Int64 nRegReturn; - // nTableEntry and pCallStack are delivered in registers as usual // but cpp_vtable_call is declared void. // the reason is that this way the compiler won't clobber the // call stack prepared by the assembler snippet to save its input // registers - // also restore %i2 here which was clobbered to jump here - __asm__( "st %%i0, %0\n\t" - "st %%i1, %1\n\t" - "ld [%%fp+68], %%i0\n\t" - "ld [%%fp+72], %%i1\n\t" - "ld [%%fp+76], %%i2\n\t" - : : "m"(nTableEntry), "m"(pCallStack) ); + // also restore %i3 here which was clobbered to jump here - sal_Bool bComplex = nTableEntry & 0x80000000 ? sal_True : sal_False; + __asm__("st %%i0, %0\n\t" + "st %%i1, %1\n\t" + "ld [%%fp+68], %%i0\n\t" + "ld [%%fp+72], %%i1\n\t" + "ld [%%fp+76], %%i2\n\t" + "ld [%%fp+80], %%i3\n\t" + : : "m"(functionIndex), "m"(pCallStack), "m"(vtableOffset)); + + + sal_Bool bComplex = functionIndex & 0x80000000 ? sal_True : sal_False; typelib_TypeClass aType = - cpp_mediate( nTableEntry, pCallStack+17, (sal_Int64*)&nRegReturn ); + cpp_mediate( functionIndex, pCallStack, vtableOffset, (sal_Int64*)&nRegReturn ); switch( aType ) { @@ -554,138 +481,122 @@ } } + //__________________________________________________________________________________________________ -void MediateClassData::createVTable( ClassDataBuffer* pBuffer, typelib_InterfaceTypeDescription* pType ) -{ - // get all member functions - list< sal_Bool > aComplexReturn; - - for( int n = 0; n < pType->nAllMembers; n++ ) - { - typelib_TypeDescription* pMember = NULL; - TYPELIB_DANGER_GET( &pMember, pType->ppAllMembers[n] ); - if( pMember->eTypeClass == typelib_TypeClass_INTERFACE_ATTRIBUTE ) - { - typelib_TypeDescription * pRetTD = 0; - TYPELIB_DANGER_GET( &pRetTD, ((typelib_InterfaceAttributeTypeDescription *)pMember)->pAttributeTypeRef ); - // get method - aComplexReturn.push_back( !cppu_isSimpleType( pRetTD ) ); - // set method - if( ! ((typelib_InterfaceAttributeTypeDescription*)pMember)->bReadOnly ) - aComplexReturn.push_back( sal_False ); - TYPELIB_DANGER_RELEASE( pRetTD ); - } - else - { - typelib_TypeDescription * pRetTD = 0; - TYPELIB_DANGER_GET( &pRetTD, ((typelib_InterfaceMethodTypeDescription *)pMember)->pReturnTypeRef ); - aComplexReturn.push_back( !cppu_isSimpleType( pRetTD ) ); - TYPELIB_DANGER_RELEASE( pRetTD ); - } - TYPELIB_DANGER_RELEASE( pMember ); - } - - int nSize = aComplexReturn.size(); - const int nSnippetSize = 64; - char * pSpace = (char *)rtl_allocateMemory( (2*(nSize+2)*sizeof(void *)) + (nSize*nSnippetSize) ); - pBuffer->m_pVTable = (void*)pSpace; - - char * pCode = pSpace + (2*(nSize+2)*sizeof(void *)); - void ** pvft = (void **)pSpace; - - // setup vft and code - for ( sal_Int32 nPos = 0; nPos < nSize; ++nPos ) - { - unsigned long * codeSnip = (unsigned long *)(pCode + (nPos*nSnippetSize)); - pvft[ nPos ] = codeSnip; - unsigned long nTablePos = nPos; - sal_Bool bComplex = aComplexReturn.front(); - if( bComplex ) - nTablePos |= 0x80000000; - aComplexReturn.pop_front(); - - /* - * generate this code - * - * st %o0, [%sp+68] save registers - * st %o1, [%sp+72] - * st %o2, [%sp+76] - * st %o3, [%sp+80] - * st %o4, [%sp+84] - * st %o5, [%sp+88] - * - * mov %sp, %o1 prepare stack ptr for cpp_vtable_call - * sethi %hi( nTablePos ), %o0 prepare table entry - * or %lo( nTablePos ), %o0 (on complex return set high bit - * - * sethi $hi( cpp_vtable_call ), %l0 - * or %l0, %lo( cpp_vtable_call ), %l0 - * jmp %l0 - * nop - * - * Note: %o0 should be restored by cpp_vtable_call if void returned - * %o1 should be restored if not hyper returned - * %o2 must be restored - * - */ - *codeSnip++ = 0xd023a044; - *codeSnip++ = 0xd223a048; - *codeSnip++ = 0xd423a04c; - *codeSnip++ = 0xd623a050; - *codeSnip++ = 0xd823a054; - *codeSnip++ = 0xda23a058; - - *codeSnip++ = 0x9210000e; - *codeSnip++ = 0x11000000 | ( nTablePos >> 10 ); - *codeSnip++ = 0x90122000 | ( nTablePos & 1023 ); - *codeSnip++ = 0x15000000 | ( ((unsigned long)cpp_vtable_call) >> 10 ); - *codeSnip++ = 0x9412a000 | ( ((unsigned long)cpp_vtable_call) & 1023 ); - *codeSnip++ = 0x81c28000; - *codeSnip++ = 0x01000000; - } -} +int const codeSnippetSize = 56; +unsigned char * codeSnippet( + unsigned char * code, sal_Int32 functionIndex, sal_Int32 vtableOffset, + bool simpleRetType) +{ + sal_uInt32 index = functionIndex; + if (!simpleRetType) { + index |= 0x80000000; + } + unsigned int * p = reinterpret_cast< unsigned int * >(code); + OSL_ASSERT(sizeof (unsigned int) == 4); + // st %o0, [%sp+68]: + *p++ = 0xD023A044; + // st %o1, [%sp+72]: + *p++ = 0xD223A048; + // st %o2, [%sp+76]: + *p++ = 0xD423A04C; + // st %o3, [%sp+80]: + *p++ = 0xD623A050; + // st %o4, [%sp+84]: + *p++ = 0xD823A054; + // st %o5, [%sp+88]: + *p++ = 0xDA23A058; + // sethi %hi(index), %o0: + *p++ = 0x11000000 | (index >> 10); + // or %o0, %lo(index), %o0: + *p++ = 0x90122000 | (index & 0x3FF); + // sethi %hi(vtableOffset), %o2: + *p++ = 0x15000000 | (vtableOffset >> 10); + // or %o2, %lo(vtableOffset), %o2: + *p++ = 0x9412A000 | (vtableOffset & 0x3FF); + // sethi %hi(cpp_vtable_call), %o3: + *p++ = 0x17000000 | (reinterpret_cast< unsigned int >(cpp_vtable_call) >> 10); + // or %o3, %lo(cpp_vtable_call), %o3: + *p++ = 0x9612E000 | (reinterpret_cast< unsigned int >(cpp_vtable_call) & 0x3FF); + // jmpl %o3, %g0: + *p++ = 0x81C2C000; + // mov %sp, %o1: + *p++ = 0x9210000E; + OSL_ASSERT( + reinterpret_cast< unsigned char * >(p) - code <= codeSnippetSize); + return code + codeSnippetSize; +} + +} + +void ** bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(char * block) +{ + return reinterpret_cast< void ** >(block) + 1; +} + +char * bridges::cpp_uno::shared::VtableFactory::createBlock( + sal_Int32 slotCount, void *** slots) +{ + char * block = new char[ + (slotCount + 3) * sizeof (void *) + slotCount * codeSnippetSize]; + *slots = mapBlockToVtable(block) + 2; + (*slots)[-3] = 0; //RTTI + (*slots)[-2] = 0; //null + (*slots)[-1] = 0; //destructor + return block; +} + +unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions( + void ** slots, unsigned char * code, + typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset, + sal_Int32 functionCount, sal_Int32 vtableOffset) +{ + for (sal_Int32 i = 0; i < type->nMembers; ++i) { + typelib_TypeDescription * member = 0; + TYPELIB_DANGER_GET(&member, type->ppMembers[i]); + OSL_ASSERT(member != 0); + switch (member->eTypeClass) { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + // Getter: + *slots++ = code; + code = codeSnippet( + code, functionOffset++, vtableOffset, + bridges::cpp_uno::shared::isSimpleType( + reinterpret_cast< + typelib_InterfaceAttributeTypeDescription * >( + member)->pAttributeTypeRef)); + // Setter: + if (!reinterpret_cast< + typelib_InterfaceAttributeTypeDescription * >( + member)->bReadOnly) + { + *slots++ = code; + code = codeSnippet(code, functionOffset++, vtableOffset, true); + } + break; -//================================================================================================== -void SAL_CALL cppu_cppInterfaceProxy_patchVtable( - XInterface * pCppI, typelib_InterfaceTypeDescription * pTypeDescr ) throw () -{ - static MediateClassData * s_pMediateClassData = 0; - if (! s_pMediateClassData) - { - MutexGuard aGuard( Mutex::getGlobalMutex() ); - if (! s_pMediateClassData) - { -#ifdef LEAK_STATIC_DATA - s_pMediateClassData = new MediateClassData(); -#else - static MediateClassData s_aMediateClassData; - s_pMediateClassData = &s_aMediateClassData; -#endif - } + case typelib_TypeClass_INTERFACE_METHOD: + *slots++ = code; + code = codeSnippet( + code, functionOffset++, vtableOffset, + bridges::cpp_uno::shared::isSimpleType( + reinterpret_cast< + typelib_InterfaceMethodTypeDescription * >( + member)->pReturnTypeRef)); + break; + + default: + OSL_ASSERT(false); + break; + } + TYPELIB_DANGER_RELEASE(member); + } + return code; +} + +void bridges::cpp_uno::shared::VtableFactory::flushCode( + unsigned char const *, unsigned char const *) + { + //TODO: IZ 25819 flush the instruction cache (there probably is OS support for this) } - *(const void **)pCppI = s_pMediateClassData->getClassData( pTypeDescr )->m_pVTable; -} - -} - -//################################################################################################## -extern "C" SAL_DLLEXPORT sal_Bool SAL_CALL component_canUnload( TimeValue * pTime ) - SAL_THROW_EXTERN_C() -{ - return CPPU_CURRENT_NAMESPACE::g_moduleCount.canUnload( &CPPU_CURRENT_NAMESPACE::g_moduleCount, pTime ); -} -//################################################################################################## -extern "C" SAL_DLLEXPORT void SAL_CALL uno_initEnvironment( uno_Environment * pCppEnv ) - SAL_THROW_EXTERN_C() -{ - CPPU_CURRENT_NAMESPACE::cppu_cppenv_initEnvironment( pCppEnv ); -} -//################################################################################################## -extern "C" SAL_DLLEXPORT void SAL_CALL uno_ext_getMapping( - uno_Mapping ** ppMapping, uno_Environment * pFrom, uno_Environment * pTo ) - SAL_THROW_EXTERN_C() -{ - CPPU_CURRENT_NAMESPACE::cppu_ext_getMapping( ppMapping, pFrom, pTo ); -} - Only in source/cpp_uno/gcc3_linux_sparc: cpp2uno.cxx~ Only in source/cpp_uno/gcc3_linux_sparc: .#cpp2uno.cxx.1.4 diff -ur /usr/local/src/112/bridges/source/cpp_uno/gcc3_linux_sparc/CVS/Entries source/cpp_uno/gcc3_linux_sparc/CVS/Entries --- /usr/local/src/112/bridges/source/cpp_uno/gcc3_linux_sparc/CVS/Entries 2004-05-09 19:32:18.000000000 +1000 +++ source/cpp_uno/gcc3_linux_sparc/CVS/Entries 2004-05-23 19:16:52.102590000 +1000 @@ -1,6 +1,6 @@ -/cpp2uno.cxx/1.2.34.1/Mon May 3 15:43:35 2004//Tcws_srx645_ooo112fix2 -/except.cxx/1.2/Mon Apr 28 16:28:48 2003//Tcws_srx645_ooo112fix2 -/makefile.mk/1.2/Mon Apr 28 16:28:55 2003//Tcws_srx645_ooo112fix2 -/share.hxx/1.2/Mon Apr 28 16:29:01 2003//Tcws_srx645_ooo112fix2 -/uno2cpp.cxx/1.2.34.2/Mon May 3 15:43:50 2004//Tcws_srx645_ooo112fix2 +/except.cxx/1.3/Wed Apr 21 13:41:00 2004//TSRC680_m39 +/makefile.mk/1.3/Wed Apr 21 13:41:21 2004//TSRC680_m39 +/share.hxx/1.3/Wed Apr 21 13:41:36 2004//TSRC680_m39 +/uno2cpp.cxx/1.4/Wed Apr 21 13:41:51 2004//TSRC680_m39 +/cpp2uno.cxx/1.4/Sun May 23 09:16:51 2004//TSRC680_m39 D diff -ur /usr/local/src/112/bridges/source/cpp_uno/gcc3_linux_sparc/CVS/Tag source/cpp_uno/gcc3_linux_sparc/CVS/Tag --- /usr/local/src/112/bridges/source/cpp_uno/gcc3_linux_sparc/CVS/Tag 2004-05-09 19:32:18.000000000 +1000 +++ source/cpp_uno/gcc3_linux_sparc/CVS/Tag 2004-05-18 18:40:30.000000000 +1000 @@ -1 +1 @@ -Tcws_srx645_ooo112fix2 +NSRC680_m39 diff -ur /usr/local/src/112/bridges/source/cpp_uno/gcc3_linux_sparc/except.cxx source/cpp_uno/gcc3_linux_sparc/except.cxx --- /usr/local/src/112/bridges/source/cpp_uno/gcc3_linux_sparc/except.cxx 2003-04-29 02:28:48.000000000 +1000 +++ source/cpp_uno/gcc3_linux_sparc/except.cxx 2004-04-21 23:41:00.000000000 +1000 @@ -2,9 +2,9 @@ * * $RCSfile: except.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: hr $ $Date: 2003/04/28 16:28:48 $ + * last change: $Author: svesik $ $Date: 2004/04/21 13:41:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -58,7 +58,6 @@ * * ************************************************************************/ - #include #include #include @@ -69,7 +68,7 @@ #include #include -#include +#include #include #include diff -ur /usr/local/src/112/bridges/source/cpp_uno/gcc3_linux_sparc/makefile.mk source/cpp_uno/gcc3_linux_sparc/makefile.mk --- /usr/local/src/112/bridges/source/cpp_uno/gcc3_linux_sparc/makefile.mk 2003-04-29 02:28:55.000000000 +1000 +++ source/cpp_uno/gcc3_linux_sparc/makefile.mk 2004-04-21 23:41:21.000000000 +1000 @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.2 $ +# $Revision: 1.3 $ # -# last change: $Author: hr $ $Date: 2003/04/28 16:28:55 $ +# last change: $Author: svesik $ $Date: 2004/04/21 13:41:21 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -59,7 +59,6 @@ # # #************************************************************************* - PRJ=..$/..$/.. PRJNAME=bridges @@ -78,11 +77,12 @@ .IF "$(COM)$(OS)$(CPU)" == "GCCLINUXS" -.IF "$(bridges_debug)" != "" -CFLAGS += -DBRIDGES_DEBUG +.IF "$(cppu_no_leak)" == "" +CFLAGS += -DLEAK_STATIC_DATA .ENDIF CFLAGSNOOPT=-O0 + NOOPTFILES = \ $(SLO)$/uno2cpp.obj \ $(SLO)$/cpp2uno.obj @@ -92,16 +92,15 @@ $(SLO)$/cpp2uno.obj \ $(SLO)$/uno2cpp.obj -SHL1TARGET= $(TARGET) -SHL1DEF= $(MISC)$/$(SHL1TARGET).def -SHL1IMPLIB= i$(TARGET) +SHL1TARGET=$(TARGET) + +SHL1DEF=$(MISC)$/$(SHL1TARGET).def +SHL1IMPLIB=i$(TARGET) SHL1VERSIONMAP=..$/..$/bridge_exports.map -SHL1OBJS= \ - $(SLO)$/except.obj \ - $(SLO)$/cpp2uno.obj \ - $(SLO)$/uno2cpp.obj +SHL1OBJS= $(SLOFILES) +SHL1LIBS =$(SLB)$/cpp_uno_shared.lib SHL1STDLIBS= \ $(CPPULIB) \ Only in source/cpp_uno/gcc3_linux_sparc: old.diff diff -ur /usr/local/src/112/bridges/source/cpp_uno/gcc3_linux_sparc/share.hxx source/cpp_uno/gcc3_linux_sparc/share.hxx --- /usr/local/src/112/bridges/source/cpp_uno/gcc3_linux_sparc/share.hxx 2003-04-29 02:29:01.000000000 +1000 +++ source/cpp_uno/gcc3_linux_sparc/share.hxx 2004-04-21 23:41:36.000000000 +1000 @@ -2,9 +2,9 @@ * * $RCSfile: share.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: hr $ $Date: 2003/04/28 16:29:01 $ + * last change: $Author: svesik $ $Date: 2004/04/21 13:41:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -58,14 +58,13 @@ * * ************************************************************************/ - +#include "uno/mapping.h" #include #include #include - namespace CPPU_CURRENT_NAMESPACE { - +void dummy_can_throw_anything( char const * ); // ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h struct _Unwind_Exception diff -ur /usr/local/src/112/bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx --- /usr/local/src/112/bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx 2004-05-04 01:43:50.000000000 +1000 +++ source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx 2004-04-21 23:41:51.000000000 +1000 @@ -2,9 +2,9 @@ * * $RCSfile: uno2cpp.cxx,v $ * - * $Revision: 1.2.34.2 $ + * $Revision: 1.4 $ * - * last change: $Author: vg $ $Date: 2004/05/03 15:43:50 $ + * last change: $Author: svesik $ $Date: 2004/04/21 13:41:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -58,34 +58,26 @@ * * ************************************************************************/ - #include -#ifndef _RTL_ALLOC_H_ -#include -#endif - +#include #ifndef _UNO_DATA_H_ #include #endif -#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_ -#include -#endif -#ifndef _BRIDGES_CPP_UNO_TYPE_MISC_HXX_ -#include -#endif + +#include "bridges/cpp_uno/shared/bridge.hxx" +#include "bridges/cpp_uno/shared/types.hxx" +#include "bridges/cpp_uno/shared/unointerfaceproxy.hxx" +#include "bridges/cpp_uno/shared/vtables.hxx" #include "share.hxx" using namespace rtl; using namespace com::sun::star::uno; -namespace CPPU_CURRENT_NAMESPACE +namespace { - -void dummy_can_throw_anything( char const * ); - //================================================================================================== -static void callVirtualMethod( void * pThis, +static void callVirtualMethod( void * pAdjustedThisPtr, sal_Int32 nVtableIndex, void * pRegisterReturn, typelib_TypeClass eReturnType, @@ -95,13 +87,13 @@ // parameter list is mixed list of * and values // reference parameters are pointers - OSL_ENSURE( pStackLongs && pThis, "### null ptr!" ); + OSL_ENSURE( pStackLongs && pAdjustedThisPtr, "### null ptr!" ); OSL_ENSURE( (sizeof(void *) == 4) && (sizeof(sal_Int32) == 4), "### unexpected size of int!" ); OSL_ENSURE( nStackLongs && pStackLongs, "### no stack in callVirtualMethod !" ); // never called - if (! pThis) dummy_can_throw_anything("xxx"); // address something + if (! pAdjustedThisPtr) CPPU_CURRENT_NAMESPACE::dummy_can_throw_anything("xxx"); // address something volatile long o0 = 0, o1 = 0; // for register returns volatile double f0d = 0; @@ -217,7 +209,7 @@ "ld [%%i0], %%l0\n\t" // get vtable ptr "sll %%i1, 2, %%l6\n\t" -// "add %%l6, 8, %%l6\n\t" +// "add %%l6, 8, %%l6\n\t" "add %%l6, %%l0, %%l0\n\t" // // vtable has 8byte wide entries, // // upper half contains 2 half words, of which the first @@ -299,19 +291,19 @@ } } -//================================================================================================== + +//================================================================================================== static void cpp_call( - cppu_unoInterfaceProxy * pThis, - sal_Int32 nVtableCall, + bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, + bridges::cpp_uno::shared::VtableSlot aVtableSlot, typelib_TypeDescriptionReference * pReturnTypeRef, sal_Int32 nParams, typelib_MethodParameter * pParams, void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc ) { // max space for: complex ret ptr, this, values|ptr ... - char * pCppStack = - (char *)alloca( (nParams+2) * sizeof(sal_Int64) ); + char * pCppStack = (char *)alloca( (nParams+3) * sizeof(sal_Int64) ); char * pCppStackStart = pCppStack; - + // return typelib_TypeDescription * pReturnTypeDescr = 0; TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef ); @@ -321,22 +313,25 @@ if (pReturnTypeDescr) { - if (cppu_isSimpleType( pReturnTypeDescr )) + if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr )) { pCppReturn = pUnoReturn; // direct way for simple types - *(void**)pCppStack = NULL; } else { // complex return via ptr - pCppReturn = *(void **)pCppStack = (cppu_relatesToInterface( pReturnTypeDescr ) - ? alloca( pReturnTypeDescr->nSize ) - : pUnoReturn); // direct way + pCppReturn = *(void **)pCppStack + = (bridges::cpp_uno::shared::relatesToInterfaceType( + pReturnTypeDescr ) + ? alloca( pReturnTypeDescr->nSize ) + : pUnoReturn); // direct way } pCppStack += sizeof(void*); } // push this - *(void**)pCppStack = pThis->pCppI; + void * pAdjustedThisPtr = reinterpret_cast< void ** >(pThis->getCppI()) + + aVtableSlot.offset; + *(void**)pCppStack = pAdjustedThisPtr; pCppStack += sizeof( void* ); // stack space @@ -355,16 +350,21 @@ const typelib_MethodParameter & rParam = pParams[nPos]; typelib_TypeDescription * pParamTypeDescr = 0; TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef ); - - if (!rParam.bOut && cppu_isSimpleType( pParamTypeDescr )) + if (!rParam.bOut + && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) { - pCppArgs[ nPos ] = adjustPointer( pCppStack, pParamTypeDescr ); + pCppArgs[ nPos ] = CPPU_CURRENT_NAMESPACE::adjustPointer( + pCppStack, pParamTypeDescr ); + uno_copyAndConvertData( pCppArgs[nPos], pUnoArgs[nPos], pParamTypeDescr, + pThis->getBridge()->getUno2Cpp() ); + switch (pParamTypeDescr->eTypeClass) { case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: case typelib_TypeClass_DOUBLE: - OSL_ASSERT( sizeof (double) == sizeof (sal_Int64) ); + + OSL_ASSERT( sizeof (double) == sizeof (sal_Int64) ); *reinterpret_cast< sal_Int32 * >(pCppStack) = *reinterpret_cast< sal_Int32 const * >(pUnoArgs[ nPos ]); pCppStack += sizeof (sal_Int32); @@ -374,7 +374,7 @@ default: uno_copyAndConvertData( pCppArgs[nPos], pUnoArgs[nPos], pParamTypeDescr, - &pThis->pBridge->aUno2Cpp ); + pThis->getBridge()->getUno2Cpp() ); break; } // no longer needed @@ -393,12 +393,14 @@ ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; } // is in/inout - else if (cppu_relatesToInterface( pParamTypeDescr )) + else if (bridges::cpp_uno::shared::relatesToInterfaceType( + pParamTypeDescr )) { uno_copyAndConvertData( *(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ), - pUnoArgs[nPos], pParamTypeDescr, &pThis->pBridge->aUno2Cpp ); - + pUnoArgs[nPos], pParamTypeDescr, + pThis->getBridge()->getUno2Cpp() ); + pTempIndizes[nTempIndizes] = nPos; // has to be reconverted // will be released at reconversion ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; @@ -415,18 +417,21 @@ try { - int nStackLongs = (pCppStack - pCppStackStart)/sizeof(sal_Int32); OSL_ENSURE( !( (pCppStack - pCppStackStart ) & 3), "UNALIGNED STACK !!! (Please DO panic" ); + int nStackLongs = (pCppStack - pCppStackStart)/sizeof(sal_Int32); + if( nStackLongs & 1 ) + // stack has to be 8 byte aligned + nStackLongs++; callVirtualMethod( - pThis->pCppI, - nVtableCall, + pAdjustedThisPtr, + aVtableSlot.index, pCppReturn, pReturnTypeDescr->eTypeClass, (sal_Int32 *)pCppStackStart, - nStackLongs); + nStackLongs); // NO exception occured... *ppUnoExc = 0; - + // reconvert temporary params for ( ; nTempIndizes--; ) { @@ -439,13 +444,13 @@ { uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr, - &pThis->pBridge->aCpp2Uno ); + pThis->getBridge()->getCpp2Uno() ); } } else // pure out { uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr, - &pThis->pBridge->aCpp2Uno ); + pThis->getBridge()->getCpp2Uno() ); } // destroy temp cpp param => cpp: every param was constructed uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release ); @@ -456,16 +461,16 @@ if (pCppReturn && pUnoReturn != pCppReturn) { uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr, - &pThis->pBridge->aCpp2Uno ); + pThis->getBridge()->getCpp2Uno() ); uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release ); } } catch( ... ) { - // get exception - fillUnoException( - __cxa_get_globals()->caughtExceptions, *ppUnoExc, &pThis->pBridge->aCpp2Uno ); - + printf("uno2cpp catch got exception!!!\n"); // why is the following __cxa ??? + // get exception + fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() ); + // temporary params for ( ; nTempIndizes--; ) { @@ -480,11 +485,12 @@ } } +} //================================================================================================== -void SAL_CALL cppu_unoInterfaceProxy_dispatch( +void bridges::cpp_uno::shared::UnoInterfaceProxy::dispatch( uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr, - void * pReturn, void * pArgs[], uno_Any ** ppException ) throw () +void * pReturn, void * pArgs[], uno_Any ** ppException ) SAL_THROW(()) { #if defined BRIDGES_DEBUG OString cstr( OUStringToOString( pMemberDescr->pTypeName, RTL_TEXTENCODING_ASCII_US ) ); @@ -492,25 +498,24 @@ #endif // is my surrogate - cppu_unoInterfaceProxy * pThis = (cppu_unoInterfaceProxy *)pUnoI; + bridges::cpp_uno::shared::UnoInterfaceProxy * pThis + = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy * >(pUnoI); typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr; - + switch (pMemberDescr->eTypeClass) { case typelib_TypeClass_INTERFACE_ATTRIBUTE: { - // determine vtable call index - sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition; - OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" ); - - sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos]; - OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" ); - + VtableSlot aVtableSlot( + getVtableSlot( + reinterpret_cast< + typelib_InterfaceAttributeTypeDescription const * >( + pMemberDescr))); if (pReturn) { // dependent dispatch cpp_call( - pThis, nVtableCall, + pThis, aVtableSlot, ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef, 0, 0, // no params pReturn, pArgs, ppException ); @@ -530,12 +535,13 @@ &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData ); // dependent dispatch + aVtableSlot.index += 1; // get, then set method cpp_call( - pThis, nVtableCall +1, // get, then set method + pThis, aVtableSlot, pReturnTypeRef, 1, &aParam, pReturn, pArgs, ppException ); - + typelib_typedescriptionreference_release( pReturnTypeRef ); } @@ -543,14 +549,12 @@ } case typelib_TypeClass_INTERFACE_METHOD: { - // determine vtable call index - sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition; - OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" ); - - sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos]; - OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" ); - - switch (nVtableCall) + VtableSlot aVtableSlot( + getVtableSlot( + reinterpret_cast< + typelib_InterfaceMethodTypeDescription const * >( + pMemberDescr))); + switch (aVtableSlot.index) { // standard calls case 1: // acquire uno interface @@ -568,9 +572,9 @@ if (pTD) { uno_Interface * pInterface = 0; - (*pThis->pBridge->pUnoEnv->getRegisteredInterface)( - pThis->pBridge->pUnoEnv, - (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD ); + (*pThis->pBridge->getUnoEnv()->getRegisteredInterface)( + pThis->pBridge->getUnoEnv(), + (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD ); if (pInterface) { @@ -588,7 +592,7 @@ default: // dependent dispatch cpp_call( - pThis, nVtableCall, + pThis, aVtableSlot, ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef, ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams, ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams, @@ -609,5 +613,3 @@ } } -} -