summaryrefslogtreecommitdiff
path: root/bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx
diff options
context:
space:
mode:
authorSander Vesik <svesik@openoffice.org>2004-04-21 12:41:51 +0000
committerSander Vesik <svesik@openoffice.org>2004-04-21 12:41:51 +0000
commitfdbe1066fd5e803d8ea242faa2960537f61ea45a (patch)
tree7f8f585176c4e3d7bef1a891245e46dc2a7d05be /bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx
parent243c16805cc117c1a6df91faaab98711291eecc7 (diff)
INTEGRATION: CWS ooo20040329 (1.3.40); FILE MERGED
2004/03/18 11:26:27 sparcmoz 1.3.40.1: #i24507# linux sparc new code for multi-inherit bridges
Diffstat (limited to 'bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx')
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx160
1 files changed, 87 insertions, 73 deletions
diff --git a/bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx
index 30bc7055e58e..7d1a799d4849 100644
--- a/bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: uno2cpp.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: hjs $ $Date: 2003-08-18 14:56:11 $
+ * 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 <malloc.h>
-#ifndef _RTL_ALLOC_H_
-#include <rtl/alloc.h>
-#endif
-
+#include <com/sun/star/uno/genfunc.hxx>
#ifndef _UNO_DATA_H_
#include <uno/data.h>
#endif
-#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_
-#include <bridges/cpp_uno/bridge.hxx>
-#endif
-#ifndef _BRIDGES_CPP_UNO_TYPE_MISC_HXX_
-#include <bridges/cpp_uno/type_misc.hxx>
-#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 @@ static void callVirtualMethod( void * pThis,
// 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;
@@ -299,17 +291,17 @@ static void callVirtualMethod( void * pThis,
}
}
+
//==================================================================================================
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
@@ -321,22 +313,25 @@ static void cpp_call(
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,20 +350,33 @@ static void cpp_call(
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->pBridge->aUno2Cpp );
+ pThis->getBridge()->getUno2Cpp() );
switch (pParamTypeDescr->eTypeClass)
{
case typelib_TypeClass_HYPER:
case typelib_TypeClass_UNSIGNED_HYPER:
case typelib_TypeClass_DOUBLE:
- pCppStack += sizeof(sal_Int32); // extra long
- }
+
+ OSL_ASSERT( sizeof (double) == sizeof (sal_Int64) );
+ *reinterpret_cast< sal_Int32 * >(pCppStack) =
+ *reinterpret_cast< sal_Int32 const * >(pUnoArgs[ nPos ]);
+ pCppStack += sizeof (sal_Int32);
+ *reinterpret_cast< sal_Int32 * >(pCppStack) =
+ *(reinterpret_cast< sal_Int32 const * >(pUnoArgs[ nPos ] ) + 1);
+ break;
+ default:
+ uno_copyAndConvertData(
+ pCppArgs[nPos], pUnoArgs[nPos], pParamTypeDescr,
+ pThis->getBridge()->getUno2Cpp() );
+ break;
+ }
// no longer needed
TYPELIB_DANGER_RELEASE( pParamTypeDescr );
}
@@ -385,11 +393,13 @@ static void cpp_call(
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
@@ -408,10 +418,17 @@ static void cpp_call(
try
{
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,
- pCppReturn, pReturnTypeDescr->eTypeClass,
- (sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
+ pAdjustedThisPtr,
+ aVtableSlot.index,
+ pCppReturn,
+ pReturnTypeDescr->eTypeClass,
+ (sal_Int32 *)pCppStackStart,
+ nStackLongs);
// NO exception occured...
*ppUnoExc = 0;
@@ -427,13 +444,13 @@ static void cpp_call(
{
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 );
@@ -444,15 +461,15 @@ static void cpp_call(
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--; )
@@ -468,11 +485,12 @@ static void cpp_call(
}
}
+}
//==================================================================================================
-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 ) );
@@ -480,25 +498,24 @@ void SAL_CALL cppu_unoInterfaceProxy_dispatch(
#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 );
@@ -518,8 +535,9 @@ void SAL_CALL cppu_unoInterfaceProxy_dispatch(
&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 );
@@ -531,14 +549,12 @@ void SAL_CALL cppu_unoInterfaceProxy_dispatch(
}
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
@@ -556,9 +572,9 @@ void SAL_CALL cppu_unoInterfaceProxy_dispatch(
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)
{
@@ -576,7 +592,7 @@ void SAL_CALL cppu_unoInterfaceProxy_dispatch(
default:
// dependent dispatch
cpp_call(
- pThis, nVtableCall,
+ pThis, aVtableSlot,
((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
@@ -597,5 +613,3 @@ void SAL_CALL cppu_unoInterfaceProxy_dispatch(
}
}
-}
-