summaryrefslogtreecommitdiff
path: root/bridges
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2004-02-03 11:39:40 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2004-02-03 11:39:40 +0000
commit11e1a58c7c8aefabaebb6124980b68951dbedd20 (patch)
tree73997cd9489dfd4ebd3990f2eba2cb031116f835 /bridges
parentd8835d0c6e3085224bfc8a08130d9854838b657d (diff)
INTEGRATION: CWS sb10 (1.4.44); FILE MERGED
2004/01/17 18:40:44 khendricks 1.4.44.1: Stephan, I am adding in the new ppc linux bridge code to your branch in the hopes it will get merged in when your branch tag is merged in it passes the multinherit tests in all forms I will try to fix the MacOSX stuff next.
Diffstat (limited to 'bridges')
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_powerpc/cpp2uno.cxx451
1 files changed, 201 insertions, 250 deletions
diff --git a/bridges/source/cpp_uno/gcc3_linux_powerpc/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_powerpc/cpp2uno.cxx
index 408f0fb9e12f..ee9b301cbe47 100644
--- a/bridges/source/cpp_uno/gcc3_linux_powerpc/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_powerpc/cpp2uno.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: cpp2uno.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: vg $ $Date: 2003-06-12 11:12:30 $
+ * last change: $Author: hr $ $Date: 2004-02-03 12:39:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,34 +59,27 @@
*
************************************************************************/
-#include <malloc.h>
-#include <hash_map>
-
-#include <rtl/alloc.h>
-#include <osl/mutex.hxx>
-
+#include <com/sun/star/uno/genfunc.hxx>
#include <uno/data.h>
#include <typelib/typedescription.hxx>
-#include <bridges/cpp_uno/bridge.hxx>
-#include <bridges/cpp_uno/type_misc.hxx>
+#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"
+// #include <stdio.h>
-using namespace ::osl;
-using namespace ::rtl;
using namespace ::com::sun::star::uno;
-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,
@@ -111,7 +104,7 @@ static typelib_TypeClass cpp2uno_call(
if (pReturnTypeDescr)
{
- if (cppu_isSimpleType( pReturnTypeDescr ))
+ if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
{
pUnoReturn = pRegisterReturn; // direct way for simple types
}
@@ -121,7 +114,7 @@ static typelib_TypeClass cpp2uno_call(
gpreg++;
ng++;
- pUnoReturn = (cppu_relatesToInterface( pReturnTypeDescr )
+ pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
? alloca( pReturnTypeDescr->nSize )
: pCppReturn); // direct way
}
@@ -148,7 +141,8 @@ static typelib_TypeClass cpp2uno_call(
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
{
switch (pParamTypeDescr->eTypeClass)
@@ -284,11 +278,11 @@ static typelib_TypeClass cpp2uno_call(
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;
@@ -307,7 +301,7 @@ static typelib_TypeClass cpp2uno_call(
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)
@@ -324,7 +318,8 @@ static typelib_TypeClass cpp2uno_call(
if (pReturnTypeDescr)
TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
- raiseException( &aUnoExc, &pThis->pBridge->aUno2Cpp ); // has to destruct the any
+ CPPU_CURRENT_NAMESPACE::raiseException( &aUnoExc, pThis->getBridge()->getUno2Cpp() );
+ // has to destruct the any
// is here for dummy
return typelib_TypeClass_VOID;
}
@@ -341,7 +336,7 @@ static typelib_TypeClass cpp2uno_call(
// 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 );
@@ -354,7 +349,7 @@ static typelib_TypeClass cpp2uno_call(
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 );
}
@@ -375,7 +370,8 @@ static typelib_TypeClass cpp2uno_call(
//==================================================================================================
static typelib_TypeClass cpp_mediate(
- sal_Int32 nVtableCall,
+ sal_Int32 nFunctionIndex,
+ sal_Int32 nVtableOffset,
void ** gpreg, void ** fpreg, void ** ovrflw,
sal_Int64 * pRegisterReturn /* space for register return */ )
{
@@ -385,31 +381,34 @@ static typelib_TypeClass cpp_mediate(
// fpreg: [fpr params]
// ovrflw: [gpr or fpr params (properly aligned)]
- // _this_ ptr is patched cppu_XInterfaceProxy object
- cppu_cppInterfaceProxy * pCppI = NULL;
- if( nVtableCall & 0x80000000 )
+ void * pThis;
+ if (nFunctionIndex & 0x80000000 )
{
- nVtableCall &= 0x7fffffff;
- pCppI = (cppu_cppInterfaceProxy *)(XInterface *)*(gpreg +1);
+ nFunctionIndex &= 0x7fffffff;
+ pThis = gpreg[1];
}
else
- {
- pCppI = (cppu_cppInterfaceProxy *)(XInterface *)*(gpreg);
- }
+ {
+ pThis = gpreg[0];
+ }
+
+ pThis = static_cast< char * >(pThis) - nVtableOffset;
+ bridges::cpp_uno::shared::CppInterfaceProxy * pCppI
+ = bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy(
+ pThis);
- typelib_InterfaceTypeDescription * pTypeDescr = pCppI->pTypeDescr;
+ typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr();
- OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
- if (nVtableCall >= pTypeDescr->nMapFunctionIndexToMemberIndex)
+ OSL_ENSURE( nFunctionIndex < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
+ if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex)
{
throw RuntimeException(
- OUString::createFromAscii("illegal vtable index!"),
- (XInterface *)pCppI );
+ rtl::OUString::createFromAscii("illegal vtable index!"),
+ (XInterface *)pThis );
}
// 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] );
@@ -419,7 +418,7 @@ static typelib_TypeClass cpp_mediate(
{
case typelib_TypeClass_INTERFACE_ATTRIBUTE:
{
- if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nVtableCall)
+ if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex)
{
// is GET method
eRet = cpp2uno_call(
@@ -448,7 +447,7 @@ static typelib_TypeClass cpp_mediate(
case typelib_TypeClass_INTERFACE_METHOD:
{
// is METHOD
- switch (nVtableCall)
+ switch (nFunctionIndex)
{
case 1: // acquire()
pCppI->acquireProxy(); // non virtual call!
@@ -465,9 +464,10 @@ static typelib_TypeClass cpp_mediate(
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)
{
@@ -496,8 +496,8 @@ static typelib_TypeClass cpp_mediate(
default:
{
throw RuntimeException(
- OUString::createFromAscii("no member description found!"),
- (XInterface *)pCppI );
+ rtl::OUString::createFromAscii("no member description found!"),
+ (XInterface *)pThis );
// is here for dummy
eRet = typelib_TypeClass_VOID;
}
@@ -511,7 +511,7 @@ static typelib_TypeClass cpp_mediate(
* is called on incoming vtable calls
* (called by asm snippets)
*/
-static void cpp_vtable_call( int nTableEntry, void** gpregptr, void** fpregptr, void** ovrflw)
+static void cpp_vtable_call( int nFunctionIndex, int nVtableOffset, void** gpregptr, void** fpregptr, void** ovrflw)
{
sal_Int32 gpreg[8];
double fpreg[8];
@@ -521,10 +521,14 @@ static void cpp_vtable_call( int nTableEntry, void** gpregptr, void** fpregptr,
volatile long nRegReturn[2];
- sal_Bool bComplex = nTableEntry & 0x80000000 ? sal_True : sal_False;
+ // fprintf(stderr,"in cpp_vtable_call nFunctionIndex is %x\n",nFunctionIndex);
+ // fprintf(stderr,"in cpp_vtable_call nVtableOffset is %x\n",nVtableOffset);
+ // fflush(stderr);
+
+ sal_Bool bComplex = nFunctionIndex & 0x80000000 ? sal_True : sal_False;
typelib_TypeClass aType =
- cpp_mediate( nTableEntry, (void**)gpreg, (void**)fpreg, ovrflw, (sal_Int64*)nRegReturn );
+ cpp_mediate( nFunctionIndex, nVtableOffset, (void**)gpreg, (void**)fpreg, ovrflw, (sal_Int64*)nRegReturn );
switch( aType )
{
@@ -569,7 +573,7 @@ static void cpp_vtable_call( int nTableEntry, void** gpregptr, void** fpregptr,
//__________________________________________________________________________________________________
-void flush_icache(char *addr)
+void flush_icache(unsigned char *addr)
{
__asm__ volatile (
"dcbf 0,%0;"
@@ -581,7 +585,7 @@ void flush_icache(char *addr)
}
-void flush_range(char * addr1, int size)
+void flush_range(unsigned char * addr1, int size)
{
#define MIN_LINE_SIZE 16
int i;
@@ -591,232 +595,179 @@ void flush_range(char * addr1, int size)
}
-//==================================================================================================
-class MediateClassData
+int const codeSnippetSize = 108;
+
+unsigned char * codeSnippet( unsigned char * code, sal_Int32 functionIndex, sal_Int32 vtableOffset,
+ bool simpleRetType)
{
- typedef ::std::hash_map< OUString, void *, OUStringHash > t_classdata_map;
- t_classdata_map m_map;
- Mutex m_mutex;
-public:
- void const * get_vtable( typelib_InterfaceTypeDescription * pTD ) SAL_THROW( () );
+ // fprintf(stderr,"in codeSnippet functionIndex is %x\n", functionIndex);
+ // fprintf(stderr,"in codeSnippet vtableOffset is %x\n", vtableOffset);
+ // fflush(stderr);
- inline MediateClassData() SAL_THROW( () )
- {}
- ~MediateClassData() SAL_THROW( () );
-};
-//__________________________________________________________________________________________________
-MediateClassData::~MediateClassData() SAL_THROW( () )
-{
- OSL_TRACE( "> calling ~MediateClassData(): freeing mediate vtables." );
+ if (! simpleRetType )
+ functionIndex |= 0x80000000;
+
+ unsigned long * p = (unsigned long *) code;
- for ( t_classdata_map::const_iterator iPos( m_map.begin() ); iPos != m_map.end(); ++iPos )
- {
- ::rtl_freeMemory( iPos->second );
- }
-}
-//--------------------------------------------------------------------------------------------------
-static inline void codeSnippet( long * code, sal_uInt32 vtable_pos, bool simple_ret_type ) SAL_THROW( () )
-{
- if (! simple_ret_type)
- vtable_pos |= 0x80000000;
// OSL_ASSERT( sizeof (long) == 4 );
+ OSL_ASSERT((((unsigned long)code) & 0x3) == 0 ); //aligned to 4 otherwise a mistake
/* generate this code */
// # so first save gpr 3 to gpr 10 (aligned to 4)
- // 9061f800 stw r3,-2048(r1)
- // 9081f804 stw r4,-2044(r1)
- // 90a1f808 stw r5,-2040(r1)
- // 90c1f80c stw r6,-2036(r1)
- // 90e1f810 stw r7,-2032(r1)
- // 9101f814 stw r8,-2028(r1)
- // 9121f818 stw r9,-2024(r1)
- // 9141f81c stw r10,-2020(r1)
+ // stw r3,-2048(r1)
+ // stw r4,-2044(r1)
+ // stw r5,-2040(r1)
+ // stw r6,-2036(r1)
+ // stw r7,-2032(r1)
+ // stw r8,-2028(r1)
+ // stw r9,-2024(r1)
+ // stw r10,-2020(r1)
// # next save fpr 1 to fpr 8 (aligned to 8)
- // d821f820 stfd f1,-2016(r1)
- // d841f828 stfd f2,-2008(r1)
- // d861f830 stfd f3,-2000(r1)
- // d881f838 stfd f4,-1992(r1)
- // d8a1f840 stfd f5,-1984(r1)
- // d8c1f848 stfd f6,-1976(r1)
- // d8e1f850 stfd f7,-1968(r1)
- // d901f858 stfd f8,-1960(r1)
+ // stfd f1,-2016(r1)
+ // stfd f2,-2008(r1)
+ // stfd f3,-2000(r1)
+ // stfd f4,-1992(r1)
+ // stfd f5,-1984(r1)
+ // stfd f6,-1976(r1)
+ // stfd f7,-1968(r1)
+ // stfd f8,-1960(r1)
// # now here is where cpp_vtable_call must go
- // 3c600000 lis r3,-8531
- // 60630000 ori r3,r3,48879
- // 7c6903a6 mtctr r3
+ // lis r3,-8531
+ // ori r3,r3,48879
+ // mtctr r3
- // # now load up the the table entry number
- // 3c600000 lis r3,-8531
- // 60630000 ori r3,r3,48879
+ // # now load up the functionIndex
+ // lis r3,-8531
+ // ori r3,r3,48879
+
+ // # now load up the vtableOffset
+ // lis r4,-8531
+ // ori r4,r4,48879
// #now load up the pointer to the saved gpr registers
- // 3881f800 addi r4,r1,-2048
+ // addi r5,r1,-2048
// #now load up the pointer to the saved fpr registers
- // 38a1f820 addi r5,r1,-2016
+ // addi r6,r1,-2016
// #now load up the pointer to the overflow call stack
- // 38c10008 addi r6,r1,8
- // 4e800420 bctr
-
-
- * code++ = 0x9061f800;
- * code++ = 0x9081f804;
- * code++ = 0x90a1f808;
- * code++ = 0x90c1f80c;
- * code++ = 0x90e1f810;
- * code++ = 0x9101f814;
- * code++ = 0x9121f818;
- * code++ = 0x9141f81c;
- * code++ = 0xd821f820;
- * code++ = 0xd841f828;
- * code++ = 0xd861f830;
- * code++ = 0xd881f838;
- * code++ = 0xd8a1f840;
- * code++ = 0xd8c1f848;
- * code++ = 0xd8e1f850;
- * code++ = 0xd901f858;
- * code++ = 0x3c600000 | (((unsigned long)cpp_vtable_call) >> 16);
- * code++ = 0x60630000 | (((unsigned long)cpp_vtable_call) & 0x0000FFFF);
- * code++ = 0x7c6903a6;
- * code++ = 0x3c600000 | (vtable_pos >> 16);
- * code++ = 0x60630000 | (vtable_pos & 0x0000FFFF);
- * code++ = 0x3881f800;
- * code++ = 0x38a1f820;
- * code++ = 0x38c10008;
- * code++ = 0x4e800420;
-
- // don't forget to flush the data and instruction caches after calling this routine
- // otherwise the self-modifying code we wrote will not be processed properly
- // remove any possible stale instruction cache data
+ // addi r7,r1,8
+ // bctr
+
+ * p++ = 0x9061f800;
+ * p++ = 0x9081f804;
+ * p++ = 0x90a1f808;
+ * p++ = 0x90c1f80c;
+ * p++ = 0x90e1f810;
+ * p++ = 0x9101f814;
+ * p++ = 0x9121f818;
+ * p++ = 0x9141f81c;
+ * p++ = 0xd821f820;
+ * p++ = 0xd841f828;
+ * p++ = 0xd861f830;
+ * p++ = 0xd881f838;
+ * p++ = 0xd8a1f840;
+ * p++ = 0xd8c1f848;
+ * p++ = 0xd8e1f850;
+ * p++ = 0xd901f858;
+ * p++ = 0x3c600000 | (((unsigned long)cpp_vtable_call) >> 16);
+ * p++ = 0x60630000 | (((unsigned long)cpp_vtable_call) & 0x0000FFFF);
+ * p++ = 0x7c6903a6;
+ * p++ = 0x3c600000 | (((unsigned long)functionIndex) >> 16);
+ * p++ = 0x60630000 | (((unsigned long)functionIndex) & 0x0000FFFF);
+ * p++ = 0x3c800000 | (((unsigned long)vtableOffset) >> 16);
+ * p++ = 0x60840000 | (((unsigned long)vtableOffset) & 0x0000FFFF);
+ * p++ = 0x38a1f800;
+ * p++ = 0x38c1f820;
+ * p++ = 0x38e10008;
+ * p++ = 0x4e800420;
+ return (code + codeSnippetSize);
}
-//__________________________________________________________________________________________________
-void const * MediateClassData::get_vtable( typelib_InterfaceTypeDescription * pTD ) SAL_THROW( () )
-{
- void * buffer;
- const int nSnippetSize = 100;
- // avoiding locked counts
- OUString const & unoName = *(OUString const *)&((typelib_TypeDescription *)pTD)->pTypeName;
- {
- MutexGuard aGuard( m_mutex );
- t_classdata_map::const_iterator iFind( m_map.find( unoName ) );
- if (iFind == m_map.end())
- {
- // create new vtable
- sal_Int32 nSlots = pTD->nMapFunctionIndexToMemberIndex;
- buffer = ::rtl_allocateMemory( ((2+ nSlots) * sizeof (void *)) + (nSlots *nSnippetSize) );
-
- ::std::pair< t_classdata_map::iterator, bool > insertion(
- m_map.insert( t_classdata_map::value_type( unoName, buffer ) ) );
- OSL_ENSURE( insertion.second, "### inserting new vtable buffer failed?!" );
-
- void ** slots = (void **)buffer;
- *slots++ = 0;
- *slots++ = 0; // rtti
- char * code = (char *)(slots + nSlots);
-
- sal_uInt32 vtable_pos = 0;
- sal_Int32 nAllMembers = pTD->nAllMembers;
- typelib_TypeDescriptionReference ** ppAllMembers = pTD->ppAllMembers;
- for ( sal_Int32 nPos = 0; nPos < nAllMembers; ++nPos )
- {
- typelib_TypeDescription * pTD = 0;
- TYPELIB_DANGER_GET( &pTD, ppAllMembers[ nPos ] );
- OSL_ASSERT( pTD );
- if (typelib_TypeClass_INTERFACE_ATTRIBUTE == pTD->eTypeClass)
- {
- bool simple_ret = cppu_isSimpleType(
- ((typelib_InterfaceAttributeTypeDescription *)pTD)->pAttributeTypeRef->eTypeClass );
- // get method
- *slots = code;
- codeSnippet( (long *)code, vtable_pos++, simple_ret );
- flush_range( code, nSnippetSize );
- code += nSnippetSize;
- slots++;
- if (! ((typelib_InterfaceAttributeTypeDescription *)pTD)->bReadOnly)
- {
- // set method
- *slots = code;
- codeSnippet( (long *)code, vtable_pos++, true );
- flush_range( code, nSnippetSize );
- code += nSnippetSize;
- slots++;
- }
- }
- else
- {
- bool simple_ret = cppu_isSimpleType(
- ((typelib_InterfaceMethodTypeDescription *)pTD)->pReturnTypeRef->eTypeClass );
- *slots = code;
- codeSnippet( (long *)code, vtable_pos++, simple_ret );
- flush_range( code, nSnippetSize );
- code += nSnippetSize;
- slots++;
- }
- TYPELIB_DANGER_RELEASE( pTD );
- }
- OSL_ASSERT( vtable_pos == nSlots );
- }
- else
- {
- buffer = iFind->second;
- }
- }
-
- return ((void **)buffer +2);
-}
-//==================================================================================================
-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
- }
- }
- *(void const **)pCppI = s_pMediateClassData->get_vtable( pTypeDescr );
}
-}
-extern "C"
+void ** bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(char * block)
{
-//##################################################################################################
-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 );
+ return reinterpret_cast< void ** >(block) + 2;
}
-//##################################################################################################
-void SAL_CALL uno_initEnvironment( uno_Environment * pCppEnv )
- SAL_THROW_EXTERN_C()
+
+char * bridges::cpp_uno::shared::VtableFactory::createBlock(
+ sal_Int32 slotCount, void *** slots)
{
- CPPU_CURRENT_NAMESPACE::cppu_cppenv_initEnvironment(
- pCppEnv );
+ char * block = new char[
+ (slotCount + 2) * sizeof (void *) + slotCount * codeSnippetSize];
+ *slots = mapBlockToVtable(block);
+ (*slots)[-2] = 0;
+ (*slots)[-1] = 0;
+ return block;
}
-//##################################################################################################
-void SAL_CALL uno_ext_getMapping(
- uno_Mapping ** ppMapping, uno_Environment * pFrom, uno_Environment * pTo )
- SAL_THROW_EXTERN_C()
+
+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)
{
- CPPU_CURRENT_NAMESPACE::cppu_ext_getMapping(
- ppMapping, pFrom, pTo );
-}
+
+ // fprintf(stderr, "in addLocalFunctions functionOffset is %x\n",functionOffset);
+ // fprintf(stderr, "in addLocalFunctions vtableOffset is %x\n",vtableOffset);
+ // fflush(stderr);
+
+ unsigned char * ncode;
+ 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;
+ ncode = codeSnippet(
+ code, functionOffset++, vtableOffset,
+ bridges::cpp_uno::shared::isSimpleType(
+ reinterpret_cast<
+ typelib_InterfaceAttributeTypeDescription * >(
+ member)->pAttributeTypeRef));
+ flush_range(code,codeSnippetSize);
+ code = ncode;
+
+
+ // Setter:
+ if (!reinterpret_cast<
+ typelib_InterfaceAttributeTypeDescription * >(
+ member)->bReadOnly)
+ {
+ *slots++ = code;
+ ncode = codeSnippet(code, functionOffset++, vtableOffset, true);
+ flush_range(code,codeSnippetSize);
+ code = ncode;
+ }
+ break;
+
+ case typelib_TypeClass_INTERFACE_METHOD:
+ *slots++ = code;
+ ncode = codeSnippet(
+ code, functionOffset++, vtableOffset,
+ bridges::cpp_uno::shared::isSimpleType(
+ reinterpret_cast<
+ typelib_InterfaceMethodTypeDescription * >(
+ member)->pReturnTypeRef));
+ flush_range(code,codeSnippetSize);
+ code = ncode;
+ break;
+
+ default:
+ OSL_ASSERT(false);
+ break;
+ }
+ TYPELIB_DANGER_RELEASE(member);
+ }
+ return code;
}
+