INTEGRATION: CWS sb10 (1.4.60); FILE MERGED
2004/01/08 15:42:08 sb 1.4.60.4: #114000# Cleaned up. 2004/01/08 13:45:44 sb 1.4.60.3: #114000# Factored out more shared code. 2003/12/19 16:15:52 sb 1.4.60.2: #114000# Factored out even more shared behaviour. 2003/12/10 10:00:21 sb 1.4.60.1: #114000# Adapted to multiple-inheritance interface types.
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: uno2cpp.cxx,v $
|
||||
*
|
||||
* $Revision: 1.4 $
|
||||
* $Revision: 1.5 $
|
||||
*
|
||||
* last change: $Author: obo $ $Date: 2003-04-01 10:40:19 $
|
||||
* last change: $Author: hr $ $Date: 2004-02-03 12:38:54 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -60,26 +60,26 @@
|
||||
************************************************************************/
|
||||
|
||||
#include <malloc.h>
|
||||
#include <rtl/alloc.h>
|
||||
|
||||
#include <com/sun/star/uno/genfunc.hxx>
|
||||
#include <uno/data.h>
|
||||
#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/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,
|
||||
void * pAdjustedThisPtr,
|
||||
sal_Int32 nVtableIndex,
|
||||
void * pRegisterReturn,
|
||||
typelib_TypeClass eReturnType,
|
||||
@@ -89,12 +89,12 @@ static void callVirtualMethod(
|
||||
// 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 edx = 0, eax = 0; // for register returns
|
||||
void * stackptr;
|
||||
@@ -125,8 +125,8 @@ static void callVirtualMethod(
|
||||
// cleanup stack
|
||||
"mov %6, %%esp\n\t"
|
||||
:
|
||||
: "m"(nStackLongs), "m"(pStackLongs), "m"(pThis), "m"(nVtableIndex),
|
||||
"m"(eax), "m"(edx), "m"(stackptr)
|
||||
: "m"(nStackLongs), "m"(pStackLongs), "m"(pAdjustedThisPtr),
|
||||
"m"(nVtableIndex), "m"(eax), "m"(edx), "m"(stackptr)
|
||||
: "eax", "edx" );
|
||||
switch( eReturnType )
|
||||
{
|
||||
@@ -158,8 +158,8 @@ static void callVirtualMethod(
|
||||
|
||||
//==================================================================================================
|
||||
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 )
|
||||
@@ -178,21 +178,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
|
||||
}
|
||||
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
|
||||
@@ -212,10 +216,11 @@ static void cpp_call(
|
||||
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 ))
|
||||
{
|
||||
uno_copyAndConvertData( pCppArgs[nPos] = pCppStack, pUnoArgs[nPos], pParamTypeDescr,
|
||||
&pThis->pBridge->aUno2Cpp );
|
||||
pThis->getBridge()->getUno2Cpp() );
|
||||
|
||||
switch (pParamTypeDescr->eTypeClass)
|
||||
{
|
||||
@@ -240,11 +245,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
|
||||
@@ -264,7 +271,7 @@ static void cpp_call(
|
||||
{
|
||||
OSL_ENSURE( !( (pCppStack - pCppStackStart ) & 3), "UNALIGNED STACK !!! (Please DO panic)" );
|
||||
callVirtualMethod(
|
||||
pThis->pCppI, nVtableCall,
|
||||
pAdjustedThisPtr, aVtableSlot.index,
|
||||
pCppReturn, pReturnTypeDescr->eTypeClass,
|
||||
(sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
|
||||
// NO exception occured...
|
||||
@@ -282,13 +289,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 );
|
||||
@@ -299,14 +306,14 @@ 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 (...)
|
||||
{
|
||||
// fill uno exception
|
||||
fillUnoException( __cxa_get_globals()->caughtExceptions, *ppUnoExc, &pThis->pBridge->aCpp2Uno );
|
||||
fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() );
|
||||
|
||||
// temporary params
|
||||
for ( ; nTempIndizes--; )
|
||||
@@ -322,32 +329,32 @@ 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(())
|
||||
{
|
||||
// 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 );
|
||||
@@ -367,8 +374,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 );
|
||||
@@ -380,14 +388,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
|
||||
@@ -405,8 +411,8 @@ void SAL_CALL cppu_unoInterfaceProxy_dispatch(
|
||||
if (pTD)
|
||||
{
|
||||
uno_Interface * pInterface = 0;
|
||||
(*pThis->pBridge->pUnoEnv->getRegisteredInterface)(
|
||||
pThis->pBridge->pUnoEnv,
|
||||
(*pThis->pBridge->getUnoEnv()->getRegisteredInterface)(
|
||||
pThis->pBridge->getUnoEnv(),
|
||||
(void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
|
||||
|
||||
if (pInterface)
|
||||
@@ -425,7 +431,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,
|
||||
@@ -445,6 +451,3 @@ void SAL_CALL cppu_unoInterfaceProxy_dispatch(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user