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 $
|
* $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
|
* The Contents of this file are made available subject to the terms of
|
||||||
* either of the following licenses
|
* either of the following licenses
|
||||||
@@ -60,26 +60,26 @@
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <rtl/alloc.h>
|
|
||||||
|
|
||||||
|
#include <com/sun/star/uno/genfunc.hxx>
|
||||||
#include <uno/data.h>
|
#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"
|
#include "share.hxx"
|
||||||
|
|
||||||
|
|
||||||
using namespace ::rtl;
|
using namespace ::rtl;
|
||||||
using namespace ::com::sun::star::uno;
|
using namespace ::com::sun::star::uno;
|
||||||
|
|
||||||
namespace CPPU_CURRENT_NAMESPACE
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
void dummy_can_throw_anything( char const * );
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
static void callVirtualMethod(
|
static void callVirtualMethod(
|
||||||
void * pThis,
|
void * pAdjustedThisPtr,
|
||||||
sal_Int32 nVtableIndex,
|
sal_Int32 nVtableIndex,
|
||||||
void * pRegisterReturn,
|
void * pRegisterReturn,
|
||||||
typelib_TypeClass eReturnType,
|
typelib_TypeClass eReturnType,
|
||||||
@@ -89,12 +89,12 @@ static void callVirtualMethod(
|
|||||||
// parameter list is mixed list of * and values
|
// parameter list is mixed list of * and values
|
||||||
// reference parameters are pointers
|
// 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( (sizeof(void *) == 4) && (sizeof(sal_Int32) == 4), "### unexpected size of int!" );
|
||||||
OSL_ENSURE( nStackLongs && pStackLongs, "### no stack in callVirtualMethod !" );
|
OSL_ENSURE( nStackLongs && pStackLongs, "### no stack in callVirtualMethod !" );
|
||||||
|
|
||||||
// never called
|
// 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
|
volatile long edx = 0, eax = 0; // for register returns
|
||||||
void * stackptr;
|
void * stackptr;
|
||||||
@@ -125,8 +125,8 @@ static void callVirtualMethod(
|
|||||||
// cleanup stack
|
// cleanup stack
|
||||||
"mov %6, %%esp\n\t"
|
"mov %6, %%esp\n\t"
|
||||||
:
|
:
|
||||||
: "m"(nStackLongs), "m"(pStackLongs), "m"(pThis), "m"(nVtableIndex),
|
: "m"(nStackLongs), "m"(pStackLongs), "m"(pAdjustedThisPtr),
|
||||||
"m"(eax), "m"(edx), "m"(stackptr)
|
"m"(nVtableIndex), "m"(eax), "m"(edx), "m"(stackptr)
|
||||||
: "eax", "edx" );
|
: "eax", "edx" );
|
||||||
switch( eReturnType )
|
switch( eReturnType )
|
||||||
{
|
{
|
||||||
@@ -158,8 +158,8 @@ static void callVirtualMethod(
|
|||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
static void cpp_call(
|
static void cpp_call(
|
||||||
cppu_unoInterfaceProxy * pThis,
|
bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
|
||||||
sal_Int32 nVtableCall,
|
bridges::cpp_uno::shared::VtableSlot aVtableSlot,
|
||||||
typelib_TypeDescriptionReference * pReturnTypeRef,
|
typelib_TypeDescriptionReference * pReturnTypeRef,
|
||||||
sal_Int32 nParams, typelib_MethodParameter * pParams,
|
sal_Int32 nParams, typelib_MethodParameter * pParams,
|
||||||
void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
|
void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
|
||||||
@@ -178,21 +178,25 @@ static void cpp_call(
|
|||||||
|
|
||||||
if (pReturnTypeDescr)
|
if (pReturnTypeDescr)
|
||||||
{
|
{
|
||||||
if (cppu_isSimpleType( pReturnTypeDescr ))
|
if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
|
||||||
{
|
{
|
||||||
pCppReturn = pUnoReturn; // direct way for simple types
|
pCppReturn = pUnoReturn; // direct way for simple types
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// complex return via ptr
|
// complex return via ptr
|
||||||
pCppReturn = *(void **)pCppStack = (cppu_relatesToInterface( pReturnTypeDescr )
|
pCppReturn = *(void **)pCppStack
|
||||||
? alloca( pReturnTypeDescr->nSize )
|
= (bridges::cpp_uno::shared::relatesToInterfaceType(
|
||||||
: pUnoReturn); // direct way
|
pReturnTypeDescr )
|
||||||
|
? alloca( pReturnTypeDescr->nSize )
|
||||||
|
: pUnoReturn); // direct way
|
||||||
pCppStack += sizeof(void *);
|
pCppStack += sizeof(void *);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// push this
|
// push this
|
||||||
*(void**)pCppStack = pThis->pCppI;
|
void * pAdjustedThisPtr = reinterpret_cast< void ** >(pThis->getCppI())
|
||||||
|
+ aVtableSlot.offset;
|
||||||
|
*(void**)pCppStack = pAdjustedThisPtr;
|
||||||
pCppStack += sizeof( void* );
|
pCppStack += sizeof( void* );
|
||||||
|
|
||||||
// stack space
|
// stack space
|
||||||
@@ -212,10 +216,11 @@ static void cpp_call(
|
|||||||
typelib_TypeDescription * pParamTypeDescr = 0;
|
typelib_TypeDescription * pParamTypeDescr = 0;
|
||||||
TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
|
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,
|
uno_copyAndConvertData( pCppArgs[nPos] = pCppStack, pUnoArgs[nPos], pParamTypeDescr,
|
||||||
&pThis->pBridge->aUno2Cpp );
|
pThis->getBridge()->getUno2Cpp() );
|
||||||
|
|
||||||
switch (pParamTypeDescr->eTypeClass)
|
switch (pParamTypeDescr->eTypeClass)
|
||||||
{
|
{
|
||||||
@@ -240,11 +245,13 @@ static void cpp_call(
|
|||||||
ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
|
ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
|
||||||
}
|
}
|
||||||
// is in/inout
|
// is in/inout
|
||||||
else if (cppu_relatesToInterface( pParamTypeDescr ))
|
else if (bridges::cpp_uno::shared::relatesToInterfaceType(
|
||||||
|
pParamTypeDescr ))
|
||||||
{
|
{
|
||||||
uno_copyAndConvertData(
|
uno_copyAndConvertData(
|
||||||
*(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
|
*(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
|
pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
|
||||||
// will be released at reconversion
|
// will be released at reconversion
|
||||||
@@ -264,7 +271,7 @@ static void cpp_call(
|
|||||||
{
|
{
|
||||||
OSL_ENSURE( !( (pCppStack - pCppStackStart ) & 3), "UNALIGNED STACK !!! (Please DO panic)" );
|
OSL_ENSURE( !( (pCppStack - pCppStackStart ) & 3), "UNALIGNED STACK !!! (Please DO panic)" );
|
||||||
callVirtualMethod(
|
callVirtualMethod(
|
||||||
pThis->pCppI, nVtableCall,
|
pAdjustedThisPtr, aVtableSlot.index,
|
||||||
pCppReturn, pReturnTypeDescr->eTypeClass,
|
pCppReturn, pReturnTypeDescr->eTypeClass,
|
||||||
(sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
|
(sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
|
||||||
// NO exception occured...
|
// NO exception occured...
|
||||||
@@ -282,13 +289,13 @@ static void cpp_call(
|
|||||||
{
|
{
|
||||||
uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
|
uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
|
||||||
uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
|
uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
|
||||||
&pThis->pBridge->aCpp2Uno );
|
pThis->getBridge()->getCpp2Uno() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // pure out
|
else // pure out
|
||||||
{
|
{
|
||||||
uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
|
uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
|
||||||
&pThis->pBridge->aCpp2Uno );
|
pThis->getBridge()->getCpp2Uno() );
|
||||||
}
|
}
|
||||||
// destroy temp cpp param => cpp: every param was constructed
|
// destroy temp cpp param => cpp: every param was constructed
|
||||||
uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
|
uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
|
||||||
@@ -299,14 +306,14 @@ static void cpp_call(
|
|||||||
if (pCppReturn && pUnoReturn != pCppReturn)
|
if (pCppReturn && pUnoReturn != pCppReturn)
|
||||||
{
|
{
|
||||||
uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
|
uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
|
||||||
&pThis->pBridge->aCpp2Uno );
|
pThis->getBridge()->getCpp2Uno() );
|
||||||
uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
|
uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
// fill uno exception
|
// 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
|
// temporary params
|
||||||
for ( ; nTempIndizes--; )
|
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,
|
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
|
// 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;
|
typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
|
||||||
|
|
||||||
switch (pMemberDescr->eTypeClass)
|
switch (pMemberDescr->eTypeClass)
|
||||||
{
|
{
|
||||||
case typelib_TypeClass_INTERFACE_ATTRIBUTE:
|
case typelib_TypeClass_INTERFACE_ATTRIBUTE:
|
||||||
{
|
{
|
||||||
// determine vtable call index
|
VtableSlot aVtableSlot(
|
||||||
sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
|
getVtableSlot(
|
||||||
OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
|
reinterpret_cast<
|
||||||
|
typelib_InterfaceAttributeTypeDescription const * >(
|
||||||
sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos];
|
pMemberDescr)));
|
||||||
OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
|
|
||||||
|
|
||||||
if (pReturn)
|
if (pReturn)
|
||||||
{
|
{
|
||||||
// dependent dispatch
|
// dependent dispatch
|
||||||
cpp_call(
|
cpp_call(
|
||||||
pThis, nVtableCall,
|
pThis, aVtableSlot,
|
||||||
((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
|
((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
|
||||||
0, 0, // no params
|
0, 0, // no params
|
||||||
pReturn, pArgs, ppException );
|
pReturn, pArgs, ppException );
|
||||||
@@ -367,8 +374,9 @@ void SAL_CALL cppu_unoInterfaceProxy_dispatch(
|
|||||||
&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
|
&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
|
||||||
|
|
||||||
// dependent dispatch
|
// dependent dispatch
|
||||||
|
aVtableSlot.index += 1; // get, then set method
|
||||||
cpp_call(
|
cpp_call(
|
||||||
pThis, nVtableCall +1, // get, then set method
|
pThis, aVtableSlot,
|
||||||
pReturnTypeRef,
|
pReturnTypeRef,
|
||||||
1, &aParam,
|
1, &aParam,
|
||||||
pReturn, pArgs, ppException );
|
pReturn, pArgs, ppException );
|
||||||
@@ -380,14 +388,12 @@ void SAL_CALL cppu_unoInterfaceProxy_dispatch(
|
|||||||
}
|
}
|
||||||
case typelib_TypeClass_INTERFACE_METHOD:
|
case typelib_TypeClass_INTERFACE_METHOD:
|
||||||
{
|
{
|
||||||
// determine vtable call index
|
VtableSlot aVtableSlot(
|
||||||
sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
|
getVtableSlot(
|
||||||
OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
|
reinterpret_cast<
|
||||||
|
typelib_InterfaceMethodTypeDescription const * >(
|
||||||
sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos];
|
pMemberDescr)));
|
||||||
OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
|
switch (aVtableSlot.index)
|
||||||
|
|
||||||
switch (nVtableCall)
|
|
||||||
{
|
{
|
||||||
// standard calls
|
// standard calls
|
||||||
case 1: // acquire uno interface
|
case 1: // acquire uno interface
|
||||||
@@ -405,8 +411,8 @@ void SAL_CALL cppu_unoInterfaceProxy_dispatch(
|
|||||||
if (pTD)
|
if (pTD)
|
||||||
{
|
{
|
||||||
uno_Interface * pInterface = 0;
|
uno_Interface * pInterface = 0;
|
||||||
(*pThis->pBridge->pUnoEnv->getRegisteredInterface)(
|
(*pThis->pBridge->getUnoEnv()->getRegisteredInterface)(
|
||||||
pThis->pBridge->pUnoEnv,
|
pThis->pBridge->getUnoEnv(),
|
||||||
(void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
|
(void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
|
||||||
|
|
||||||
if (pInterface)
|
if (pInterface)
|
||||||
@@ -425,7 +431,7 @@ void SAL_CALL cppu_unoInterfaceProxy_dispatch(
|
|||||||
default:
|
default:
|
||||||
// dependent dispatch
|
// dependent dispatch
|
||||||
cpp_call(
|
cpp_call(
|
||||||
pThis, nVtableCall,
|
pThis, aVtableSlot,
|
||||||
((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
|
((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
|
||||||
((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
|
((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
|
||||||
((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
|
((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
|
||||||
@@ -445,6 +451,3 @@ void SAL_CALL cppu_unoInterfaceProxy_dispatch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user