clang-cl loplugin: bridges
Change-Id: I46bcc6eb1f34184626d2f584d7164d84f54c2cf8 Reviewed-on: https://gerrit.libreoffice.org/29879 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
parent
29eb4f122b
commit
fee419ae25
@ -32,6 +32,11 @@ namespace com { namespace sun { namespace star { namespace uno {
|
|||||||
class XInterface;
|
class XInterface;
|
||||||
} } } }
|
} } } }
|
||||||
|
|
||||||
|
#if !defined __GNUG__ || defined __MINGW32__
|
||||||
|
void dso_init();
|
||||||
|
void dso_exit();
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace bridges { namespace cpp_uno { namespace shared {
|
namespace bridges { namespace cpp_uno { namespace shared {
|
||||||
|
|
||||||
class Bridge;
|
class Bridge;
|
||||||
|
@ -43,7 +43,7 @@ static inline typelib_TypeClass cpp2uno_call(
|
|||||||
void ** pStack )
|
void ** pStack )
|
||||||
{
|
{
|
||||||
// Return type
|
// Return type
|
||||||
typelib_TypeDescription * pReturnTD = NULL;
|
typelib_TypeDescription * pReturnTD = nullptr;
|
||||||
if ( pReturnTypeRef )
|
if ( pReturnTypeRef )
|
||||||
TYPELIB_DANGER_GET( &pReturnTD, pReturnTypeRef );
|
TYPELIB_DANGER_GET( &pReturnTD, pReturnTypeRef );
|
||||||
|
|
||||||
@ -51,8 +51,8 @@ static inline typelib_TypeClass cpp2uno_call(
|
|||||||
// value, return address and 'this'
|
// value, return address and 'this'
|
||||||
// pointer.
|
// pointer.
|
||||||
|
|
||||||
void * pUnoReturn = NULL;
|
void * pUnoReturn = nullptr;
|
||||||
void * pCppReturn = NULL; // Complex return ptr: if != NULL && != pUnoReturn, reconversion need
|
void * pCppReturn = nullptr; // Complex return ptr: if != NULL && != pUnoReturn, reconversion need
|
||||||
|
|
||||||
if ( pReturnTD )
|
if ( pReturnTD )
|
||||||
{
|
{
|
||||||
@ -76,18 +76,18 @@ static inline typelib_TypeClass cpp2uno_call(
|
|||||||
// micro-optimization, and allocate these array separately
|
// micro-optimization, and allocate these array separately
|
||||||
|
|
||||||
// Parameters passed to the UNO function
|
// Parameters passed to the UNO function
|
||||||
void ** pUnoArgs = (void **)alloca( sizeof(void *) * nParams );
|
void ** pUnoArgs = static_cast<void **>(alloca( sizeof(void *) * nParams ));
|
||||||
|
|
||||||
// Parameters received from C++
|
// Parameters received from C++
|
||||||
void ** pCppArgs = (void **)alloca( sizeof(void *) * nParams );
|
void ** pCppArgs = static_cast<void **>(alloca( sizeof(void *) * nParams ));
|
||||||
|
|
||||||
// Indexes of values this have to be converted (interface conversion C++<=>UNO)
|
// Indexes of values this have to be converted (interface conversion C++<=>UNO)
|
||||||
int * pTempIndexes =
|
int * pTempIndexes =
|
||||||
(int *)alloca( sizeof(int) * nParams );
|
static_cast<int *>(alloca( sizeof(int) * nParams ));
|
||||||
|
|
||||||
// Type descriptions for reconversions
|
// Type descriptions for reconversions
|
||||||
typelib_TypeDescription ** ppTempParamTD =
|
typelib_TypeDescription ** ppTempParamTD =
|
||||||
(typelib_TypeDescription **)alloca( sizeof(void *) * nParams );
|
static_cast<typelib_TypeDescription **>(alloca( sizeof(void *) * nParams ));
|
||||||
|
|
||||||
int nTempIndexes = 0;
|
int nTempIndexes = 0;
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ static inline typelib_TypeClass cpp2uno_call(
|
|||||||
{
|
{
|
||||||
const typelib_MethodParameter & rParam = pParams[nPos];
|
const typelib_MethodParameter & rParam = pParams[nPos];
|
||||||
|
|
||||||
typelib_TypeDescription * pParamTD = NULL;
|
typelib_TypeDescription * pParamTD = nullptr;
|
||||||
TYPELIB_DANGER_GET( &pParamTD, rParam.pTypeRef );
|
TYPELIB_DANGER_GET( &pParamTD, rParam.pTypeRef );
|
||||||
|
|
||||||
if ( !rParam.bOut &&
|
if ( !rParam.bOut &&
|
||||||
@ -156,7 +156,7 @@ static inline typelib_TypeClass cpp2uno_call(
|
|||||||
|
|
||||||
if ( pParams[nIndex].bIn ) // Is in/inout => was constructed
|
if ( pParams[nIndex].bIn ) // Is in/inout => was constructed
|
||||||
{
|
{
|
||||||
::uno_destructData( pUnoArgs[nIndex], ppTempParamTD[nTempIndexes], 0 );
|
::uno_destructData( pUnoArgs[nIndex], ppTempParamTD[nTempIndexes], nullptr );
|
||||||
}
|
}
|
||||||
TYPELIB_DANGER_RELEASE( ppTempParamTD[nTempIndexes] );
|
TYPELIB_DANGER_RELEASE( ppTempParamTD[nTempIndexes] );
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ static inline typelib_TypeClass cpp2uno_call(
|
|||||||
pThis->getBridge()->getUno2Cpp() );
|
pThis->getBridge()->getUno2Cpp() );
|
||||||
}
|
}
|
||||||
// Destroy temp UNO param
|
// Destroy temp UNO param
|
||||||
::uno_destructData( pUnoArgs[nIndex], pParamTD, 0 );
|
::uno_destructData( pUnoArgs[nIndex], pParamTD, nullptr );
|
||||||
|
|
||||||
TYPELIB_DANGER_RELEASE( pParamTD );
|
TYPELIB_DANGER_RELEASE( pParamTD );
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ static inline typelib_TypeClass cpp2uno_call(
|
|||||||
pCppReturn, pUnoReturn, pReturnTD,
|
pCppReturn, pUnoReturn, pReturnTD,
|
||||||
pThis->getBridge()->getUno2Cpp() );
|
pThis->getBridge()->getUno2Cpp() );
|
||||||
// Destroy temp UNO return
|
// Destroy temp UNO return
|
||||||
::uno_destructData( pUnoReturn, pReturnTD, 0 );
|
::uno_destructData( pUnoReturn, pReturnTD, nullptr );
|
||||||
}
|
}
|
||||||
// Complex return ptr is set to eax
|
// Complex return ptr is set to eax
|
||||||
pStack[0] = pCppReturn;
|
pStack[0] = pCppReturn;
|
||||||
@ -272,7 +272,7 @@ extern "C" typelib_TypeClass cpp_vtable_call(
|
|||||||
{
|
{
|
||||||
// is GET method
|
// is GET method
|
||||||
eRet = cpp2uno_call( pCppI, aMemberDescr.get(), pAttrTypeRef,
|
eRet = cpp2uno_call( pCppI, aMemberDescr.get(), pAttrTypeRef,
|
||||||
0, NULL, // No params
|
0, nullptr, // No params
|
||||||
pStack );
|
pStack );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -280,11 +280,11 @@ extern "C" typelib_TypeClass cpp_vtable_call(
|
|||||||
// is SET method
|
// is SET method
|
||||||
typelib_MethodParameter aParam;
|
typelib_MethodParameter aParam;
|
||||||
aParam.pTypeRef = pAttrTypeRef;
|
aParam.pTypeRef = pAttrTypeRef;
|
||||||
aParam.bIn = sal_True;
|
aParam.bIn = true;
|
||||||
aParam.bOut = sal_False;
|
aParam.bOut = false;
|
||||||
|
|
||||||
eRet = cpp2uno_call( pCppI, aMemberDescr.get(),
|
eRet = cpp2uno_call( pCppI, aMemberDescr.get(),
|
||||||
NULL, // Indicates void return
|
nullptr, // Indicates void return
|
||||||
1, &aParam,
|
1, &aParam,
|
||||||
pStack );
|
pStack );
|
||||||
}
|
}
|
||||||
@ -305,28 +305,28 @@ extern "C" typelib_TypeClass cpp_vtable_call(
|
|||||||
break;
|
break;
|
||||||
case 0: // queryInterface() opt
|
case 0: // queryInterface() opt
|
||||||
{
|
{
|
||||||
typelib_TypeDescription * pTD2 = NULL;
|
typelib_TypeDescription * pTD2 = nullptr;
|
||||||
|
|
||||||
// the incoming C++ parameters are: The this
|
// the incoming C++ parameters are: The this
|
||||||
// pointer, the hidden return value pointer, and
|
// pointer, the hidden return value pointer, and
|
||||||
// then the actual queryInterface() only
|
// then the actual queryInterface() only
|
||||||
// parameter. Thus pStack[4]..
|
// parameter. Thus pStack[4]..
|
||||||
|
|
||||||
TYPELIB_DANGER_GET( &pTD2, reinterpret_cast<Type *>( pStack[4] )->getTypeLibType() );
|
TYPELIB_DANGER_GET( &pTD2, static_cast<Type *>( pStack[4] )->getTypeLibType() );
|
||||||
|
|
||||||
if ( pTD2 )
|
if ( pTD2 )
|
||||||
{
|
{
|
||||||
XInterface * pInterface = NULL;
|
XInterface * pInterface = nullptr;
|
||||||
(*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)
|
(*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)
|
||||||
( pCppI->getBridge()->getCppEnv(),
|
( pCppI->getBridge()->getCppEnv(),
|
||||||
(void **)&pInterface,
|
reinterpret_cast<void **>(&pInterface),
|
||||||
pCppI->getOid().pData,
|
pCppI->getOid().pData,
|
||||||
reinterpret_cast<typelib_InterfaceTypeDescription *>( pTD2 ) );
|
reinterpret_cast<typelib_InterfaceTypeDescription *>( pTD2 ) );
|
||||||
|
|
||||||
if ( pInterface )
|
if ( pInterface )
|
||||||
{
|
{
|
||||||
// pStack[3] = hidden return value pointer
|
// pStack[3] = hidden return value pointer
|
||||||
::uno_any_construct( reinterpret_cast<uno_Any *>( pStack[3] ),
|
::uno_any_construct( static_cast<uno_Any *>( pStack[3] ),
|
||||||
&pInterface, pTD2, cpp_acquire );
|
&pInterface, pTD2, cpp_acquire );
|
||||||
|
|
||||||
pInterface->release();
|
pInterface->release();
|
||||||
@ -427,11 +427,11 @@ unsigned char * codeSnippet(
|
|||||||
|
|
||||||
// mov rcx, nOffsetAndIndex
|
// mov rcx, nOffsetAndIndex
|
||||||
*p++ = 0x48; *p++ = 0xB9;
|
*p++ = 0x48; *p++ = 0xB9;
|
||||||
*((sal_uInt64 *)p) = nOffsetAndIndex; p += 8;
|
*reinterpret_cast<sal_uInt64 *>(p) = nOffsetAndIndex; p += 8;
|
||||||
|
|
||||||
// mov r11, privateSnippetExecutor
|
// mov r11, privateSnippetExecutor
|
||||||
*p++ = 0x49; *p++ = 0xBB;
|
*p++ = 0x49; *p++ = 0xBB;
|
||||||
*((void **)p) = &privateSnippetExecutor; p += 8;
|
*reinterpret_cast<void **>(p) = &privateSnippetExecutor; p += 8;
|
||||||
|
|
||||||
// jmp r11
|
// jmp r11
|
||||||
*p++ = 0x41; *p++ = 0xFF; *p++ = 0xE3;
|
*p++ = 0x41; *p++ = 0xFF; *p++ = 0xE3;
|
||||||
@ -468,8 +468,7 @@ bridges::cpp_uno::shared::VtableFactory::initializeBlock(
|
|||||||
Rtti():
|
Rtti():
|
||||||
n0(0), n1(0), n2(0),
|
n0(0), n1(0), n2(0),
|
||||||
rtti(CPPU_CURRENT_NAMESPACE::mscx_getRTTI(
|
rtti(CPPU_CURRENT_NAMESPACE::mscx_getRTTI(
|
||||||
OUString(
|
"com.sun.star.uno.XInterface"))
|
||||||
"com.sun.star.uno.XInterface")))
|
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
static Rtti rtti;
|
static Rtti rtti;
|
||||||
@ -491,7 +490,7 @@ unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
|
|||||||
Slot * s = *slots;
|
Slot * s = *slots;
|
||||||
|
|
||||||
for (int member = 0; member < type->nMembers; ++member) {
|
for (int member = 0; member < type->nMembers; ++member) {
|
||||||
typelib_TypeDescription * pTD = NULL;
|
typelib_TypeDescription * pTD = nullptr;
|
||||||
|
|
||||||
TYPELIB_DANGER_GET( &pTD, type->ppMembers[ member ] );
|
TYPELIB_DANGER_GET( &pTD, type->ppMembers[ member ] );
|
||||||
assert(pTD);
|
assert(pTD);
|
||||||
@ -516,7 +515,7 @@ unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
|
|||||||
code = codeSnippet( code, param_kind, nFunctionOffset++, nVtableOffset );
|
code = codeSnippet( code, param_kind, nFunctionOffset++, nVtableOffset );
|
||||||
if ( ! pIfaceAttrTD->bReadOnly )
|
if ( ! pIfaceAttrTD->bReadOnly )
|
||||||
{
|
{
|
||||||
typelib_TypeDescription * pAttrTD = NULL;
|
typelib_TypeDescription * pAttrTD = nullptr;
|
||||||
TYPELIB_DANGER_GET( &pAttrTD, pIfaceAttrTD->pAttributeTypeRef );
|
TYPELIB_DANGER_GET( &pAttrTD, pIfaceAttrTD->pAttributeTypeRef );
|
||||||
assert(pAttrTD);
|
assert(pAttrTD);
|
||||||
|
|
||||||
@ -536,7 +535,7 @@ unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
|
|||||||
typelib_InterfaceMethodTypeDescription * pMethodTD =
|
typelib_InterfaceMethodTypeDescription * pMethodTD =
|
||||||
reinterpret_cast<typelib_InterfaceMethodTypeDescription *>( pTD );
|
reinterpret_cast<typelib_InterfaceMethodTypeDescription *>( pTD );
|
||||||
|
|
||||||
typelib_TypeDescription * pReturnTD = NULL;
|
typelib_TypeDescription * pReturnTD = nullptr;
|
||||||
TYPELIB_DANGER_GET( &pReturnTD, pMethodTD->pReturnTypeRef );
|
TYPELIB_DANGER_GET( &pReturnTD, pMethodTD->pReturnTypeRef );
|
||||||
assert(pReturnTD);
|
assert(pReturnTD);
|
||||||
|
|
||||||
@ -548,7 +547,7 @@ unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
|
|||||||
|
|
||||||
for (int param = 0; nr < 4 && param < pMethodTD->nParams; ++param, ++nr)
|
for (int param = 0; nr < 4 && param < pMethodTD->nParams; ++param, ++nr)
|
||||||
{
|
{
|
||||||
typelib_TypeDescription * pParamTD = NULL;
|
typelib_TypeDescription * pParamTD = nullptr;
|
||||||
|
|
||||||
TYPELIB_DANGER_GET( &pParamTD, pMethodTD->pParams[param].pTypeRef );
|
TYPELIB_DANGER_GET( &pParamTD, pMethodTD->pParams[param].pTypeRef );
|
||||||
assert(pParamTD);
|
assert(pParamTD);
|
||||||
|
@ -22,10 +22,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
|
||||||
|
#include <cppinterfaceproxy.hxx>
|
||||||
void dso_init();
|
|
||||||
void dso_exit();
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved)
|
extern "C" BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved)
|
||||||
{
|
{
|
||||||
|
@ -252,12 +252,6 @@ void
|
|||||||
#include "mscx.hxx"
|
#include "mscx.hxx"
|
||||||
#include "except.hxx"
|
#include "except.hxx"
|
||||||
|
|
||||||
//TOOD: Work around missing __CxxDetectRethrow in clang-cl for now (predefined
|
|
||||||
// in cl, <www.geoffchappell.com/studies/msvc/language/predefined/index.html>):
|
|
||||||
#if defined __clang__
|
|
||||||
extern "C" int __cdecl __CxxDetectRethrow(void *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#pragma pack(push, 8)
|
#pragma pack(push, 8)
|
||||||
|
|
||||||
using namespace ::com::sun::star::uno;
|
using namespace ::com::sun::star::uno;
|
||||||
@ -310,32 +304,33 @@ static inline OUString toRTTIname(
|
|||||||
//RTTI simulation
|
//RTTI simulation
|
||||||
|
|
||||||
typedef std::unordered_map< OUString, void *, OUStringHash > t_string2PtrMap;
|
typedef std::unordered_map< OUString, void *, OUStringHash > t_string2PtrMap;
|
||||||
class __type_info_descriptor;
|
class type_info_descriptor;
|
||||||
|
|
||||||
class RTTInfos
|
class RTTInfos
|
||||||
{
|
{
|
||||||
Mutex _aMutex;
|
Mutex _aMutex;
|
||||||
t_string2PtrMap _allRTTI;
|
t_string2PtrMap _allRTTI;
|
||||||
|
|
||||||
static OUString toRawName( OUString const & rUNOname ) throw ();
|
|
||||||
public:
|
public:
|
||||||
type_info * getRTTI( OUString const & rUNOname ) throw ();
|
type_info * getRTTI( OUString const & rUNOname ) throw ();
|
||||||
int getRTTI_len(OUString const & rUNOname) throw ();
|
int getRTTI_len(OUString const & rUNOname) throw ();
|
||||||
__type_info_descriptor * insert_new_type_info_descriptor(OUString const & rUNOname);
|
type_info_descriptor * insert_new_type_info_descriptor(OUString const & rUNOname);
|
||||||
|
|
||||||
RTTInfos() throw ();
|
RTTInfos() throw ();
|
||||||
|
#if !defined LEAK_STATIC_DATA
|
||||||
~RTTInfos() throw ();
|
~RTTInfos() throw ();
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
class __type_info
|
class type_info_
|
||||||
{
|
{
|
||||||
friend type_info * RTTInfos::getRTTI( OUString const & ) throw ();
|
friend type_info * RTTInfos::getRTTI( OUString const & ) throw ();
|
||||||
friend int mscx_filterCppException(
|
friend int mscx_filterCppException(
|
||||||
LPEXCEPTION_POINTERS, uno_Any *, uno_Mapping * );
|
LPEXCEPTION_POINTERS, uno_Any *, uno_Mapping * );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~__type_info() throw ();
|
virtual ~type_info_() throw ();
|
||||||
|
|
||||||
inline __type_info( void * m_data, const char * m_d_name ) throw ()
|
inline type_info_( void * m_data, const char * m_d_name ) throw ()
|
||||||
: _m_data( m_data )
|
: _m_data( m_data )
|
||||||
{ ::strcpy( _m_d_name, m_d_name ); } // #100211# - checked
|
{ ::strcpy( _m_d_name, m_d_name ); } // #100211# - checked
|
||||||
|
|
||||||
@ -344,28 +339,28 @@ private:
|
|||||||
char _m_d_name[1];
|
char _m_d_name[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
__type_info::~__type_info() throw ()
|
type_info_::~type_info_() throw ()
|
||||||
{
|
{
|
||||||
(void)_m_data;
|
(void)_m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
class __type_info_descriptor
|
class type_info_descriptor
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int type_info_size;
|
int type_info_size;
|
||||||
__type_info info;
|
type_info_ info;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline __type_info_descriptor(void * m_data, const char * m_d_name) throw ()
|
inline type_info_descriptor(void * m_data, const char * m_d_name) throw ()
|
||||||
: info(m_data, m_d_name)
|
: info(m_data, m_d_name)
|
||||||
{
|
{
|
||||||
type_info_size = sizeof(__type_info) + strlen(m_d_name);
|
type_info_size = sizeof(type_info_) + strlen(m_d_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
type_info * get_type_info()
|
type_info * get_type_info()
|
||||||
{
|
{
|
||||||
return (type_info *)&info;
|
return reinterpret_cast<type_info *>(&info);
|
||||||
}
|
}
|
||||||
int get_type_info_size()
|
int get_type_info_size()
|
||||||
{
|
{
|
||||||
@ -373,12 +368,12 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
__type_info_descriptor * RTTInfos::insert_new_type_info_descriptor(OUString const & rUNOname) {
|
type_info_descriptor * RTTInfos::insert_new_type_info_descriptor(OUString const & rUNOname) {
|
||||||
|
|
||||||
// insert new type_info
|
// insert new type_info
|
||||||
OString aRawName(OUStringToOString(toRTTIname(rUNOname), RTL_TEXTENCODING_ASCII_US));
|
OString aRawName(OUStringToOString(toRTTIname(rUNOname), RTL_TEXTENCODING_ASCII_US));
|
||||||
__type_info_descriptor * pRTTI = new(::rtl_allocateMemory(sizeof(__type_info_descriptor) + aRawName.getLength()))
|
type_info_descriptor * pRTTI = new(::rtl_allocateMemory(sizeof(type_info_descriptor) + aRawName.getLength()))
|
||||||
__type_info_descriptor(NULL, aRawName.getStr());
|
type_info_descriptor(nullptr, aRawName.getStr());
|
||||||
|
|
||||||
// put into map
|
// put into map
|
||||||
pair< t_string2PtrMap::iterator, bool > insertion(
|
pair< t_string2PtrMap::iterator, bool > insertion(
|
||||||
@ -390,7 +385,7 @@ __type_info_descriptor * RTTInfos::insert_new_type_info_descriptor(OUString cons
|
|||||||
type_info * RTTInfos::getRTTI( OUString const & rUNOname ) throw ()
|
type_info * RTTInfos::getRTTI( OUString const & rUNOname ) throw ()
|
||||||
{
|
{
|
||||||
// a must be
|
// a must be
|
||||||
static_assert(sizeof(__type_info) == sizeof(type_info), "### type info structure size differ!");
|
static_assert(sizeof(type_info_) == sizeof(type_info), "### type info structure size differ!");
|
||||||
|
|
||||||
MutexGuard aGuard( _aMutex );
|
MutexGuard aGuard( _aMutex );
|
||||||
t_string2PtrMap::const_iterator const iFind( _allRTTI.find( rUNOname ) );
|
t_string2PtrMap::const_iterator const iFind( _allRTTI.find( rUNOname ) );
|
||||||
@ -398,13 +393,13 @@ type_info * RTTInfos::getRTTI( OUString const & rUNOname ) throw ()
|
|||||||
// check if type is already available
|
// check if type is already available
|
||||||
if (iFind == _allRTTI.end())
|
if (iFind == _allRTTI.end())
|
||||||
{
|
{
|
||||||
// Wrap new __type_info in __type_info_descriptor to preserve length info
|
// Wrap new type_info_ in type_info_descriptor to preserve length info
|
||||||
__type_info_descriptor * pRTTI = insert_new_type_info_descriptor(rUNOname);
|
type_info_descriptor * pRTTI = insert_new_type_info_descriptor(rUNOname);
|
||||||
return pRTTI->get_type_info();
|
return pRTTI->get_type_info();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ((__type_info_descriptor *)iFind->second)->get_type_info();
|
return static_cast<type_info_descriptor *>(iFind->second)->get_type_info();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,17 +408,17 @@ int RTTInfos::getRTTI_len(OUString const & rUNOname) throw ()
|
|||||||
MutexGuard aGuard(_aMutex);
|
MutexGuard aGuard(_aMutex);
|
||||||
t_string2PtrMap::const_iterator const iFind(_allRTTI.find(rUNOname));
|
t_string2PtrMap::const_iterator const iFind(_allRTTI.find(rUNOname));
|
||||||
|
|
||||||
// Wrap new __type_info in __type_info_descriptor to preserve length info
|
// Wrap new type_info_ in type_info_descriptor to preserve length info
|
||||||
// check if type is already available
|
// check if type is already available
|
||||||
if (iFind == _allRTTI.end())
|
if (iFind == _allRTTI.end())
|
||||||
{
|
{
|
||||||
// Wrap new __type_info in __type_info_descriptor to preserve length info
|
// Wrap new type_info_ in type_info_descriptor to preserve length info
|
||||||
__type_info_descriptor * pRTTI = insert_new_type_info_descriptor(rUNOname);
|
type_info_descriptor * pRTTI = insert_new_type_info_descriptor(rUNOname);
|
||||||
return pRTTI->get_type_info_size();
|
return pRTTI->get_type_info_size();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ((__type_info_descriptor *)iFind->second)->get_type_info_size();
|
return static_cast<type_info_descriptor *>(iFind->second)->get_type_info_size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,6 +426,7 @@ RTTInfos::RTTInfos() throw ()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined LEAK_STATIC_DATA
|
||||||
RTTInfos::~RTTInfos() throw ()
|
RTTInfos::~RTTInfos() throw ()
|
||||||
{
|
{
|
||||||
SAL_INFO("bridges", "> freeing generated RTTI infos... <");
|
SAL_INFO("bridges", "> freeing generated RTTI infos... <");
|
||||||
@ -439,11 +435,12 @@ RTTInfos::~RTTInfos() throw ()
|
|||||||
for ( t_string2PtrMap::const_iterator iPos( _allRTTI.begin() );
|
for ( t_string2PtrMap::const_iterator iPos( _allRTTI.begin() );
|
||||||
iPos != _allRTTI.end(); ++iPos )
|
iPos != _allRTTI.end(); ++iPos )
|
||||||
{
|
{
|
||||||
__type_info * pType = (__type_info *)iPos->second;
|
type_info_ * pType = static_cast<type_info_ *>(iPos->second);
|
||||||
pType->~__type_info(); // obsolete, but good style...
|
pType->~type_info_(); // obsolete, but good style...
|
||||||
::rtl_freeMemory( pType );
|
::rtl_freeMemory( pType );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void * __cdecl copyConstruct(
|
void * __cdecl copyConstruct(
|
||||||
void * pExcThis,
|
void * pExcThis,
|
||||||
@ -472,11 +469,11 @@ void GenerateConstructorTrampoline(
|
|||||||
|
|
||||||
// mov r8, pTD
|
// mov r8, pTD
|
||||||
*p++ = 0x49; *p++ = 0xB8;
|
*p++ = 0x49; *p++ = 0xB8;
|
||||||
*((void **)p) = pTD; p += 8;
|
*reinterpret_cast<void **>(p) = pTD; p += 8;
|
||||||
|
|
||||||
// mov r11, copyConstruct
|
// mov r11, copyConstruct
|
||||||
*p++ = 0x49; *p++ = 0xBB;
|
*p++ = 0x49; *p++ = 0xBB;
|
||||||
*((void **)p) = reinterpret_cast<void *>(©Construct); p += 8;
|
*reinterpret_cast<void **>(p) = reinterpret_cast<void *>(©Construct); p += 8;
|
||||||
|
|
||||||
// jmp r11
|
// jmp r11
|
||||||
*p++ = 0x41; *p++ = 0xFF; *p++ = 0xE3;
|
*p++ = 0x41; *p++ = 0xFF; *p++ = 0xE3;
|
||||||
@ -492,11 +489,11 @@ void GenerateDestructorTrampoline(
|
|||||||
|
|
||||||
// mov rdx, pTD
|
// mov rdx, pTD
|
||||||
*p++ = 0x48; *p++ = 0xBA;
|
*p++ = 0x48; *p++ = 0xBA;
|
||||||
*((void **)p) = pTD; p += 8;
|
*reinterpret_cast<void **>(p) = pTD; p += 8;
|
||||||
|
|
||||||
// mov r11, destruct
|
// mov r11, destruct
|
||||||
*p++ = 0x49; *p++ = 0xBB;
|
*p++ = 0x49; *p++ = 0xBB;
|
||||||
*((void **)p) = reinterpret_cast<void *>(&destruct); p += 8;
|
*reinterpret_cast<void **>(p) = reinterpret_cast<void *>(&destruct); p += 8;
|
||||||
|
|
||||||
// jmp r11
|
// jmp r11
|
||||||
*p++ = 0x41; *p++ = 0xFF; *p++ = 0xE3;
|
*p++ = 0x41; *p++ = 0xFF; *p++ = 0xE3;
|
||||||
@ -513,7 +510,7 @@ struct ExceptionType
|
|||||||
sal_Int32 _n1, _n2, _n3; // thiscast
|
sal_Int32 _n1, _n2, _n3; // thiscast
|
||||||
sal_Int32 _n4; // object_size
|
sal_Int32 _n4; // object_size
|
||||||
sal_uInt32 _pCopyCtor; // copyctor
|
sal_uInt32 _pCopyCtor; // copyctor
|
||||||
__type_info type_info;
|
type_info_ type_info;
|
||||||
|
|
||||||
|
|
||||||
inline ExceptionType(
|
inline ExceptionType(
|
||||||
@ -525,7 +522,7 @@ struct ExceptionType
|
|||||||
, _n2( -1 )
|
, _n2( -1 )
|
||||||
, _n3( 0 )
|
, _n3( 0 )
|
||||||
, _n4( pTD->nSize)
|
, _n4( pTD->nSize)
|
||||||
, type_info(NULL, "")
|
, type_info(nullptr, "")
|
||||||
{
|
{
|
||||||
// As _n0 is always initialized to zero, that means the
|
// As _n0 is always initialized to zero, that means the
|
||||||
// hasvirtbase flag (see the ONTL catchabletype struct) is
|
// hasvirtbase flag (see the ONTL catchabletype struct) is
|
||||||
@ -541,9 +538,6 @@ struct ExceptionType
|
|||||||
_pCopyCtor = static_cast<sal_uInt32>(
|
_pCopyCtor = static_cast<sal_uInt32>(
|
||||||
reinterpret_cast<sal_uInt64>(pCode) - pCodeBase);
|
reinterpret_cast<sal_uInt64>(pCode) - pCodeBase);
|
||||||
}
|
}
|
||||||
inline ~ExceptionType() throw ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RaiseInfo;
|
struct RaiseInfo;
|
||||||
@ -559,7 +553,9 @@ public:
|
|||||||
static DWORD allocationGranularity;
|
static DWORD allocationGranularity;
|
||||||
|
|
||||||
ExceptionInfos() throw ();
|
ExceptionInfos() throw ();
|
||||||
|
#if !defined LEAK_STATIC_DATA
|
||||||
~ExceptionInfos() throw ();
|
~ExceptionInfos() throw ();
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
DWORD ExceptionInfos::allocationGranularity = 0;
|
DWORD ExceptionInfos::allocationGranularity = 0;
|
||||||
@ -580,7 +576,9 @@ struct RaiseInfo
|
|||||||
|
|
||||||
explicit RaiseInfo(typelib_TypeDescription * pTD) throw ();
|
explicit RaiseInfo(typelib_TypeDescription * pTD) throw ();
|
||||||
|
|
||||||
|
#if !defined LEAK_STATIC_DATA
|
||||||
~RaiseInfo() throw ();
|
~RaiseInfo() throw ();
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Rewrite of 32-Bit-Code to work under 64 Bit:
|
/* Rewrite of 32-Bit-Code to work under 64 Bit:
|
||||||
@ -606,7 +604,7 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw ()
|
|||||||
int codeSize = codeSnippetSize;
|
int codeSize = codeSnippetSize;
|
||||||
// Info count
|
// Info count
|
||||||
int nLen = 0;
|
int nLen = 0;
|
||||||
for (pCompTD = (typelib_CompoundTypeDescription*)pTD;
|
for (pCompTD = reinterpret_cast<typelib_CompoundTypeDescription*>(pTD);
|
||||||
pCompTD; pCompTD = pCompTD->pBaseTypeDescription)
|
pCompTD; pCompTD = pCompTD->pBaseTypeDescription)
|
||||||
{
|
{
|
||||||
++nLen;
|
++nLen;
|
||||||
@ -622,7 +620,7 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw ()
|
|||||||
int *exceptionTypeSizeArray = new int[nLen];
|
int *exceptionTypeSizeArray = new int[nLen];
|
||||||
|
|
||||||
nLen = 0;
|
nLen = 0;
|
||||||
for (pCompTD = (typelib_CompoundTypeDescription*)pTD;
|
for (pCompTD = reinterpret_cast<typelib_CompoundTypeDescription*>(pTD);
|
||||||
pCompTD; pCompTD = pCompTD->pBaseTypeDescription)
|
pCompTD; pCompTD = pCompTD->pBaseTypeDescription)
|
||||||
{
|
{
|
||||||
int typeInfoLen = mscx_getRTTI_len(pCompTD->aBase.pTypeName);
|
int typeInfoLen = mscx_getRTTI_len(pCompTD->aBase.pTypeName);
|
||||||
@ -647,11 +645,11 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw ()
|
|||||||
// 32 bit offsets
|
// 32 bit offsets
|
||||||
const int totalSize = codeSize + typeInfoArraySize + excTypeAddLen;
|
const int totalSize = codeSize + typeInfoArraySize + excTypeAddLen;
|
||||||
unsigned char * pCode = _code =
|
unsigned char * pCode = _code =
|
||||||
(unsigned char *)::rtl_allocateMemory(totalSize);
|
static_cast<unsigned char *>(::rtl_allocateMemory(totalSize));
|
||||||
int pCodeOffset = 0;
|
int pCodeOffset = 0;
|
||||||
|
|
||||||
// New base of types array, starts after Trampoline D-Tor / C-Tors
|
// New base of types array, starts after Trampoline D-Tor / C-Tors
|
||||||
DWORD * types = (DWORD *)(pCode + codeSize);
|
DWORD * types = reinterpret_cast<DWORD *>(pCode + codeSize);
|
||||||
|
|
||||||
// New base of ExceptionType array, starts after types array
|
// New base of ExceptionType array, starts after types array
|
||||||
unsigned char *etMem = pCode + codeSize + typeInfoArraySize;
|
unsigned char *etMem = pCode + codeSize + typeInfoArraySize;
|
||||||
@ -670,7 +668,7 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw ()
|
|||||||
|
|
||||||
// Fill pCode with D-Tor code
|
// Fill pCode with D-Tor code
|
||||||
GenerateDestructorTrampoline(pCode, pTD);
|
GenerateDestructorTrampoline(pCode, pTD);
|
||||||
_pDtor = (sal_Int32)((sal_uInt64)pCode - _codeBase);
|
_pDtor = (sal_Int32)(reinterpret_cast<sal_uInt64>(pCode) - _codeBase);
|
||||||
pCodeOffset += codeSnippetSize;
|
pCodeOffset += codeSnippetSize;
|
||||||
|
|
||||||
// Info count accompanied by type info ptrs: type, base type, base base type, ...
|
// Info count accompanied by type info ptrs: type, base type, base base type, ...
|
||||||
@ -681,12 +679,12 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw ()
|
|||||||
types[0] = nLen;
|
types[0] = nLen;
|
||||||
|
|
||||||
int nPos = 1;
|
int nPos = 1;
|
||||||
for (pCompTD = (typelib_CompoundTypeDescription*)pTD;
|
for (pCompTD = reinterpret_cast<typelib_CompoundTypeDescription*>(pTD);
|
||||||
pCompTD; pCompTD = pCompTD->pBaseTypeDescription)
|
pCompTD; pCompTD = pCompTD->pBaseTypeDescription)
|
||||||
{
|
{
|
||||||
// Create instance in mem block with placement new
|
// Create instance in mem block with placement new
|
||||||
ExceptionType * et = new(etMem + etMemOffset)ExceptionType(
|
ExceptionType * et = new(etMem + etMemOffset)ExceptionType(
|
||||||
pCode + pCodeOffset, _codeBase, (typelib_TypeDescription *)pCompTD);
|
pCode + pCodeOffset, _codeBase, reinterpret_cast<typelib_TypeDescription *>(pCompTD));
|
||||||
|
|
||||||
// Next trampoline entry offset
|
// Next trampoline entry offset
|
||||||
pCodeOffset += codeSnippetSize;
|
pCodeOffset += codeSnippetSize;
|
||||||
@ -704,25 +702,28 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw ()
|
|||||||
delete[] exceptionTypeSizeArray;
|
delete[] exceptionTypeSizeArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined LEAK_STATIC_DATA
|
||||||
RaiseInfo::~RaiseInfo() throw ()
|
RaiseInfo::~RaiseInfo() throw ()
|
||||||
{
|
{
|
||||||
sal_uInt32 * pTypes = (sal_uInt32 *)(_codeBase + _types) + 1;
|
sal_uInt32 * pTypes = reinterpret_cast<sal_uInt32 *>(_codeBase + _types) + 1;
|
||||||
|
|
||||||
// Because of placement new we have to call D.-tor, not delete!
|
// Because of placement new we have to call D.-tor, not delete!
|
||||||
for ( int nTypes = *(sal_uInt32 *)(_codeBase + _types); nTypes--; )
|
for ( int nTypes = *reinterpret_cast<sal_uInt32 *>(_codeBase + _types); nTypes--; )
|
||||||
{
|
{
|
||||||
ExceptionType *et = (ExceptionType *)(_codeBase + pTypes[nTypes]);
|
ExceptionType *et = reinterpret_cast<ExceptionType *>(_codeBase + pTypes[nTypes]);
|
||||||
et->~ExceptionType();
|
et->~ExceptionType();
|
||||||
}
|
}
|
||||||
// free our single block
|
// free our single block
|
||||||
::rtl_freeMemory( _code );
|
::rtl_freeMemory( _code );
|
||||||
::typelib_typedescription_release( _pTD );
|
::typelib_typedescription_release( _pTD );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ExceptionInfos::ExceptionInfos() throw ()
|
ExceptionInfos::ExceptionInfos() throw ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined LEAK_STATIC_DATA
|
||||||
ExceptionInfos::~ExceptionInfos() throw ()
|
ExceptionInfos::~ExceptionInfos() throw ()
|
||||||
{
|
{
|
||||||
SAL_INFO("bridges", "> freeing exception infos... <");
|
SAL_INFO("bridges", "> freeing exception infos... <");
|
||||||
@ -731,13 +732,14 @@ ExceptionInfos::~ExceptionInfos() throw ()
|
|||||||
for ( t_string2PtrMap::const_iterator iPos( _allRaiseInfos.begin() );
|
for ( t_string2PtrMap::const_iterator iPos( _allRaiseInfos.begin() );
|
||||||
iPos != _allRaiseInfos.end(); ++iPos )
|
iPos != _allRaiseInfos.end(); ++iPos )
|
||||||
{
|
{
|
||||||
delete (RaiseInfo *)iPos->second;
|
delete static_cast<RaiseInfo *>(iPos->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
RaiseInfo * ExceptionInfos::getRaiseInfo( typelib_TypeDescription * pTD ) throw ()
|
RaiseInfo * ExceptionInfos::getRaiseInfo( typelib_TypeDescription * pTD ) throw ()
|
||||||
{
|
{
|
||||||
static ExceptionInfos * s_pInfos = 0;
|
static ExceptionInfos * s_pInfos = nullptr;
|
||||||
if (! s_pInfos)
|
if (! s_pInfos)
|
||||||
{
|
{
|
||||||
MutexGuard aGuard( Mutex::getGlobalMutex() );
|
MutexGuard aGuard( Mutex::getGlobalMutex() );
|
||||||
@ -772,13 +774,13 @@ RaiseInfo * ExceptionInfos::getRaiseInfo( typelib_TypeDescription * pTD ) throw
|
|||||||
|
|
||||||
// Put into map
|
// Put into map
|
||||||
pair< t_string2PtrMap::iterator, bool > insertion(
|
pair< t_string2PtrMap::iterator, bool > insertion(
|
||||||
s_pInfos->_allRaiseInfos.insert( t_string2PtrMap::value_type( rTypeName, (void *)pRaiseInfo ) ) );
|
s_pInfos->_allRaiseInfos.insert( t_string2PtrMap::value_type( rTypeName, static_cast<void *>(pRaiseInfo) ) ) );
|
||||||
assert(insertion.second && "### raise info insertion failed?!");
|
assert(insertion.second && "### raise info insertion failed?!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Reuse existing info
|
// Reuse existing info
|
||||||
pRaiseInfo = (RaiseInfo *)iFind->second;
|
pRaiseInfo = static_cast<RaiseInfo *>(iFind->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pRaiseInfo;
|
return pRaiseInfo;
|
||||||
@ -787,7 +789,7 @@ RaiseInfo * ExceptionInfos::getRaiseInfo( typelib_TypeDescription * pTD ) throw
|
|||||||
type_info * mscx_getRTTI(
|
type_info * mscx_getRTTI(
|
||||||
OUString const & rUNOname )
|
OUString const & rUNOname )
|
||||||
{
|
{
|
||||||
static RTTInfos * s_pRTTIs = 0;
|
static RTTInfos * s_pRTTIs = nullptr;
|
||||||
if (! s_pRTTIs)
|
if (! s_pRTTIs)
|
||||||
{
|
{
|
||||||
MutexGuard aGuard( Mutex::getGlobalMutex() );
|
MutexGuard aGuard( Mutex::getGlobalMutex() );
|
||||||
@ -806,7 +808,7 @@ type_info * mscx_getRTTI(
|
|||||||
int mscx_getRTTI_len(
|
int mscx_getRTTI_len(
|
||||||
OUString const & rUNOname)
|
OUString const & rUNOname)
|
||||||
{
|
{
|
||||||
static RTTInfos * s_pRTTIs = 0;
|
static RTTInfos * s_pRTTIs = nullptr;
|
||||||
if (!s_pRTTIs)
|
if (!s_pRTTIs)
|
||||||
{
|
{
|
||||||
MutexGuard aGuard(Mutex::getGlobalMutex());
|
MutexGuard aGuard(Mutex::getGlobalMutex());
|
||||||
@ -833,7 +835,7 @@ void mscx_raiseException(
|
|||||||
// ExceptionInfos::getRaiseInfo()
|
// ExceptionInfos::getRaiseInfo()
|
||||||
|
|
||||||
// construct cpp exception object
|
// construct cpp exception object
|
||||||
typelib_TypeDescription * pTD = NULL;
|
typelib_TypeDescription * pTD = nullptr;
|
||||||
TYPELIB_DANGER_GET( &pTD, pUnoExc->pType );
|
TYPELIB_DANGER_GET( &pTD, pUnoExc->pType );
|
||||||
|
|
||||||
void * pCppExc = alloca( pTD->nSize );
|
void * pCppExc = alloca( pTD->nSize );
|
||||||
@ -841,12 +843,12 @@ void mscx_raiseException(
|
|||||||
|
|
||||||
ULONG_PTR arFilterArgs[4];
|
ULONG_PTR arFilterArgs[4];
|
||||||
arFilterArgs[0] = MSVC_magic_number;
|
arFilterArgs[0] = MSVC_magic_number;
|
||||||
arFilterArgs[1] = (ULONG_PTR)pCppExc;
|
arFilterArgs[1] = reinterpret_cast<ULONG_PTR>(pCppExc);
|
||||||
arFilterArgs[2] = (ULONG_PTR)ExceptionInfos::getRaiseInfo( pTD );
|
arFilterArgs[2] = reinterpret_cast<ULONG_PTR>(ExceptionInfos::getRaiseInfo( pTD ));
|
||||||
arFilterArgs[3] = ((RaiseInfo *)arFilterArgs[2])->_codeBase;
|
arFilterArgs[3] = reinterpret_cast<RaiseInfo *>(arFilterArgs[2])->_codeBase;
|
||||||
|
|
||||||
// Destruct uno exception
|
// Destruct uno exception
|
||||||
::uno_any_destruct( pUnoExc, 0 );
|
::uno_any_destruct( pUnoExc, nullptr );
|
||||||
TYPELIB_DANGER_RELEASE( pTD );
|
TYPELIB_DANGER_RELEASE( pTD );
|
||||||
|
|
||||||
// last point to release anything not affected by stack unwinding
|
// last point to release anything not affected by stack unwinding
|
||||||
@ -858,13 +860,13 @@ int mscx_filterCppException(
|
|||||||
uno_Any * pUnoExc,
|
uno_Any * pUnoExc,
|
||||||
uno_Mapping * pCpp2Uno )
|
uno_Mapping * pCpp2Uno )
|
||||||
{
|
{
|
||||||
if (pPointers == 0)
|
if (pPointers == nullptr)
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
|
||||||
EXCEPTION_RECORD * pRecord = pPointers->ExceptionRecord;
|
EXCEPTION_RECORD * pRecord = pPointers->ExceptionRecord;
|
||||||
|
|
||||||
// Handle only C++ exceptions:
|
// Handle only C++ exceptions:
|
||||||
if (pRecord == 0 || pRecord->ExceptionCode != MSVC_ExceptionCode)
|
if (pRecord == nullptr || pRecord->ExceptionCode != MSVC_ExceptionCode)
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
|
||||||
bool rethrow = __CxxDetectRethrow( &pRecord );
|
bool rethrow = __CxxDetectRethrow( &pRecord );
|
||||||
@ -890,7 +892,7 @@ int mscx_filterCppException(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rethrow: handle only C++ exceptions:
|
// Rethrow: handle only C++ exceptions:
|
||||||
if (pRecord == 0 || pRecord->ExceptionCode != MSVC_ExceptionCode)
|
if (pRecord == nullptr || pRecord->ExceptionCode != MSVC_ExceptionCode)
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
|
||||||
if (pRecord->NumberParameters == 4 &&
|
if (pRecord->NumberParameters == 4 &&
|
||||||
@ -921,15 +923,15 @@ int mscx_filterCppException(
|
|||||||
{
|
{
|
||||||
OUString aRTTIname(
|
OUString aRTTIname(
|
||||||
OStringToOUString(
|
OStringToOUString(
|
||||||
(reinterpret_cast<__type_info *>(base + et->_pTypeInfo)
|
(reinterpret_cast<type_info_ *>(base + et->_pTypeInfo)
|
||||||
->_m_d_name),
|
->_m_d_name),
|
||||||
RTL_TEXTENCODING_ASCII_US));
|
RTL_TEXTENCODING_ASCII_US));
|
||||||
OUString aUNOname( toUNOname( aRTTIname ) );
|
OUString aUNOname( toUNOname( aRTTIname ) );
|
||||||
|
|
||||||
typelib_TypeDescription * pExcTD = 0;
|
typelib_TypeDescription * pExcTD = nullptr;
|
||||||
typelib_typedescription_getByName(
|
typelib_typedescription_getByName(
|
||||||
&pExcTD, aUNOname.pData );
|
&pExcTD, aUNOname.pData );
|
||||||
if (pExcTD == NULL)
|
if (pExcTD == nullptr)
|
||||||
{
|
{
|
||||||
OUStringBuffer buf;
|
OUStringBuffer buf;
|
||||||
buf.append(
|
buf.append(
|
||||||
@ -948,7 +950,7 @@ int mscx_filterCppException(
|
|||||||
{
|
{
|
||||||
// construct uno exception any
|
// construct uno exception any
|
||||||
uno_any_constructAndConvert(
|
uno_any_constructAndConvert(
|
||||||
pUnoExc, (void *) pRecord->ExceptionInformation[1],
|
pUnoExc, reinterpret_cast<void *>(pRecord->ExceptionInformation[1]),
|
||||||
pExcTD, pCpp2Uno );
|
pExcTD, pCpp2Uno );
|
||||||
typelib_typedescription_release( pExcTD );
|
typelib_typedescription_release( pExcTD );
|
||||||
}
|
}
|
||||||
|
@ -48,5 +48,11 @@ void mscx_raiseException(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TOOD: Work around missing __CxxDetectRethrow in clang-cl for now (predefined
|
||||||
|
// in cl, <www.geoffchappell.com/studies/msvc/language/predefined/index.html>):
|
||||||
|
#if defined __clang__
|
||||||
|
extern "C" int __cdecl __CxxDetectRethrow(void *);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@ -42,7 +42,7 @@ using namespace ::com::sun::star::uno;
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
static bool cpp_call(
|
bool cpp_call(
|
||||||
bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
|
bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
|
||||||
bridges::cpp_uno::shared::VtableSlot aVtableSlot,
|
bridges::cpp_uno::shared::VtableSlot aVtableSlot,
|
||||||
typelib_TypeDescriptionReference * pReturnTypeRef,
|
typelib_TypeDescriptionReference * pReturnTypeRef,
|
||||||
@ -72,12 +72,12 @@ static bool cpp_call(
|
|||||||
int nCppParamIndex = 0;
|
int nCppParamIndex = 0;
|
||||||
|
|
||||||
// Return type
|
// Return type
|
||||||
typelib_TypeDescription * pReturnTD = NULL;
|
typelib_TypeDescription * pReturnTD = nullptr;
|
||||||
TYPELIB_DANGER_GET( &pReturnTD, pReturnTypeRef );
|
TYPELIB_DANGER_GET( &pReturnTD, pReturnTypeRef );
|
||||||
assert(pReturnTD);
|
assert(pReturnTD);
|
||||||
|
|
||||||
// 'this'
|
// 'this'
|
||||||
void * pAdjustedThisPtr = (void **)( pThis->getCppI() ) + aVtableSlot.offset;
|
void * pAdjustedThisPtr = reinterpret_cast<void **>( pThis->getCppI() ) + aVtableSlot.offset;
|
||||||
aCppParams[nCppParamIndex++].p = pAdjustedThisPtr;
|
aCppParams[nCppParamIndex++].p = pAdjustedThisPtr;
|
||||||
|
|
||||||
enum class ReturnKind { Void, Simple, Complex, ComplexConvert };
|
enum class ReturnKind { Void, Simple, Complex, ComplexConvert };
|
||||||
@ -110,7 +110,7 @@ static bool cpp_call(
|
|||||||
{
|
{
|
||||||
const typelib_MethodParameter & rParam = pParams[nPos];
|
const typelib_MethodParameter & rParam = pParams[nPos];
|
||||||
|
|
||||||
typelib_TypeDescription * pParamTD = NULL;
|
typelib_TypeDescription * pParamTD = nullptr;
|
||||||
TYPELIB_DANGER_GET( &pParamTD, rParam.pTypeRef );
|
TYPELIB_DANGER_GET( &pParamTD, rParam.pTypeRef );
|
||||||
|
|
||||||
if ( !rParam.bOut &&
|
if ( !rParam.bOut &&
|
||||||
@ -186,12 +186,12 @@ static bool cpp_call(
|
|||||||
// expects. (The callee is not actually varargs, of course.)
|
// expects. (The callee is not actually varargs, of course.)
|
||||||
|
|
||||||
sal_Int64 (*pIMethod)(sal_Int64, ...) =
|
sal_Int64 (*pIMethod)(sal_Int64, ...) =
|
||||||
(sal_Int64 (*)(sal_Int64, ...))
|
reinterpret_cast<sal_Int64 (*)(sal_Int64, ...)>(
|
||||||
(*((sal_uInt64 **)pAdjustedThisPtr))[aVtableSlot.index];
|
(*static_cast<sal_uInt64 **>(pAdjustedThisPtr))[aVtableSlot.index]);
|
||||||
|
|
||||||
double (*pFMethod)(sal_Int64, ...) =
|
double (*pFMethod)(sal_Int64, ...) =
|
||||||
(double (*)(sal_Int64, ...))
|
reinterpret_cast<double (*)(sal_Int64, ...)>(
|
||||||
(*((sal_uInt64 **)pAdjustedThisPtr))[aVtableSlot.index];
|
(*static_cast<sal_uInt64 **>(pAdjustedThisPtr))[aVtableSlot.index]);
|
||||||
|
|
||||||
// Pass parameters 2..4 as if it was a floating-point value so
|
// Pass parameters 2..4 as if it was a floating-point value so
|
||||||
// that it gets put in both XMM and integer registers per the
|
// that it gets put in both XMM and integer registers per the
|
||||||
@ -245,7 +245,7 @@ static bool cpp_call(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// No exception occurred
|
// No exception occurred
|
||||||
*ppUnoExc = NULL;
|
*ppUnoExc = nullptr;
|
||||||
|
|
||||||
// Reconvert temporary params
|
// Reconvert temporary params
|
||||||
while ( nTempIndexes-- )
|
while ( nTempIndexes-- )
|
||||||
@ -260,7 +260,7 @@ static bool cpp_call(
|
|||||||
if ( pParams[nIndex].bOut ) // Inout
|
if ( pParams[nIndex].bOut ) // Inout
|
||||||
{
|
{
|
||||||
::uno_destructData(
|
::uno_destructData(
|
||||||
pUnoArgs[nIndex], pParamTD, 0 ); // Destroy UNO value
|
pUnoArgs[nIndex], pParamTD, nullptr ); // Destroy UNO value
|
||||||
::uno_copyAndConvertData(
|
::uno_copyAndConvertData(
|
||||||
pUnoArgs[nIndex], aCppParams[nCppIndex].p, pParamTD,
|
pUnoArgs[nIndex], aCppParams[nCppIndex].p, pParamTD,
|
||||||
pThis->getBridge()->getCpp2Uno() );
|
pThis->getBridge()->getCpp2Uno() );
|
||||||
@ -285,7 +285,7 @@ static bool cpp_call(
|
|||||||
case ReturnKind::Void:
|
case ReturnKind::Void:
|
||||||
break;
|
break;
|
||||||
case ReturnKind::Simple:
|
case ReturnKind::Simple:
|
||||||
*(sal_Int64*)pUnoReturn = uRetVal.i;
|
*static_cast<sal_Int64*>(pUnoReturn) = uRetVal.i;
|
||||||
break;
|
break;
|
||||||
case ReturnKind::Complex:
|
case ReturnKind::Complex:
|
||||||
assert(uRetVal.p == pUnoReturn);
|
assert(uRetVal.p == pUnoReturn);
|
||||||
@ -330,7 +330,7 @@ void unoInterfaceProxyDispatch(
|
|||||||
{
|
{
|
||||||
#if OSL_DEBUG_LEVEL > 0
|
#if OSL_DEBUG_LEVEL > 0
|
||||||
// determine vtable call index
|
// determine vtable call index
|
||||||
sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberTD)->nPosition;
|
sal_Int32 nMemberPos = reinterpret_cast<typelib_InterfaceMemberTypeDescription const *>(pMemberTD)->nPosition;
|
||||||
assert(nMemberPos < pTypeDescr->nAllMembers);
|
assert(nMemberPos < pTypeDescr->nAllMembers);
|
||||||
#endif
|
#endif
|
||||||
VtableSlot aVtableSlot(
|
VtableSlot aVtableSlot(
|
||||||
@ -343,8 +343,8 @@ void unoInterfaceProxyDispatch(
|
|||||||
// Is GET
|
// Is GET
|
||||||
cpp_call(
|
cpp_call(
|
||||||
pThis, aVtableSlot,
|
pThis, aVtableSlot,
|
||||||
((typelib_InterfaceAttributeTypeDescription *)pMemberTD)->pAttributeTypeRef,
|
reinterpret_cast<typelib_InterfaceAttributeTypeDescription const *>(pMemberTD)->pAttributeTypeRef,
|
||||||
0, NULL, // no params
|
0, nullptr, // no params
|
||||||
pReturn, pArgs, ppException );
|
pReturn, pArgs, ppException );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -352,11 +352,11 @@ void unoInterfaceProxyDispatch(
|
|||||||
// Is SET
|
// Is SET
|
||||||
typelib_MethodParameter aParam;
|
typelib_MethodParameter aParam;
|
||||||
aParam.pTypeRef =
|
aParam.pTypeRef =
|
||||||
((typelib_InterfaceAttributeTypeDescription *)pMemberTD)->pAttributeTypeRef;
|
reinterpret_cast<typelib_InterfaceAttributeTypeDescription const *>(pMemberTD)->pAttributeTypeRef;
|
||||||
aParam.bIn = sal_True;
|
aParam.bIn = true;
|
||||||
aParam.bOut = sal_False;
|
aParam.bOut = false;
|
||||||
|
|
||||||
typelib_TypeDescriptionReference * pReturnTypeRef = NULL;
|
typelib_TypeDescriptionReference * pReturnTypeRef = nullptr;
|
||||||
OUString aVoidName("void");
|
OUString aVoidName("void");
|
||||||
typelib_typedescriptionreference_new(
|
typelib_typedescriptionreference_new(
|
||||||
&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
|
&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
|
||||||
@ -377,7 +377,7 @@ void unoInterfaceProxyDispatch(
|
|||||||
{
|
{
|
||||||
#if OSL_DEBUG_LEVEL > 0
|
#if OSL_DEBUG_LEVEL > 0
|
||||||
// determine vtable call index
|
// determine vtable call index
|
||||||
sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberTD)->nPosition;
|
sal_Int32 nMemberPos = reinterpret_cast<typelib_InterfaceMemberTypeDescription const *>(pMemberTD)->nPosition;
|
||||||
assert(nMemberPos < pTypeDescr->nAllMembers);
|
assert(nMemberPos < pTypeDescr->nAllMembers);
|
||||||
#endif
|
#endif
|
||||||
VtableSlot aVtableSlot(
|
VtableSlot aVtableSlot(
|
||||||
@ -391,34 +391,34 @@ void unoInterfaceProxyDispatch(
|
|||||||
// Standard calls
|
// Standard calls
|
||||||
case 1: // Acquire UNO interface
|
case 1: // Acquire UNO interface
|
||||||
(*pUnoI->acquire)( pUnoI );
|
(*pUnoI->acquire)( pUnoI );
|
||||||
*ppException = 0;
|
*ppException = nullptr;
|
||||||
break;
|
break;
|
||||||
case 2: // Release UNO interface
|
case 2: // Release UNO interface
|
||||||
(*pUnoI->release)( pUnoI );
|
(*pUnoI->release)( pUnoI );
|
||||||
*ppException = 0;
|
*ppException = nullptr;
|
||||||
break;
|
break;
|
||||||
case 0: // queryInterface() opt
|
case 0: // queryInterface() opt
|
||||||
{
|
{
|
||||||
typelib_TypeDescription * pTD = NULL;
|
typelib_TypeDescription * pTD = nullptr;
|
||||||
TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
|
TYPELIB_DANGER_GET( &pTD, static_cast< Type * >( pArgs[0] )->getTypeLibType() );
|
||||||
|
|
||||||
if ( pTD )
|
if ( pTD )
|
||||||
{
|
{
|
||||||
uno_Interface * pInterface = NULL;
|
uno_Interface * pInterface = nullptr;
|
||||||
(*pThis->getBridge()->getUnoEnv()->getRegisteredInterface)(
|
(*pThis->getBridge()->getUnoEnv()->getRegisteredInterface)(
|
||||||
pThis->getBridge()->getUnoEnv(),
|
pThis->getBridge()->getUnoEnv(),
|
||||||
(void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
|
reinterpret_cast<void **>(&pInterface), pThis->oid.pData, reinterpret_cast<typelib_InterfaceTypeDescription *>(pTD) );
|
||||||
|
|
||||||
if ( pInterface )
|
if ( pInterface )
|
||||||
{
|
{
|
||||||
::uno_any_construct(
|
::uno_any_construct(
|
||||||
reinterpret_cast< uno_Any * >( pReturn ),
|
static_cast< uno_Any * >( pReturn ),
|
||||||
&pInterface, pTD, 0 );
|
&pInterface, pTD, nullptr );
|
||||||
(*pInterface->release)( pInterface );
|
(*pInterface->release)( pInterface );
|
||||||
|
|
||||||
TYPELIB_DANGER_RELEASE( pTD );
|
TYPELIB_DANGER_RELEASE( pTD );
|
||||||
|
|
||||||
*ppException = 0;
|
*ppException = nullptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TYPELIB_DANGER_RELEASE( pTD );
|
TYPELIB_DANGER_RELEASE( pTD );
|
||||||
@ -428,15 +428,15 @@ void unoInterfaceProxyDispatch(
|
|||||||
default:
|
default:
|
||||||
if ( ! cpp_call(
|
if ( ! cpp_call(
|
||||||
pThis, aVtableSlot,
|
pThis, aVtableSlot,
|
||||||
((typelib_InterfaceMethodTypeDescription *)pMemberTD)->pReturnTypeRef,
|
reinterpret_cast<typelib_InterfaceMethodTypeDescription const *>(pMemberTD)->pReturnTypeRef,
|
||||||
((typelib_InterfaceMethodTypeDescription *)pMemberTD)->nParams,
|
reinterpret_cast<typelib_InterfaceMethodTypeDescription const *>(pMemberTD)->nParams,
|
||||||
((typelib_InterfaceMethodTypeDescription *)pMemberTD)->pParams,
|
reinterpret_cast<typelib_InterfaceMethodTypeDescription const *>(pMemberTD)->pParams,
|
||||||
pReturn, pArgs, ppException ) )
|
pReturn, pArgs, ppException ) )
|
||||||
{
|
{
|
||||||
RuntimeException aExc( "Too many parameters!" );
|
RuntimeException aExc( "Too many parameters!" );
|
||||||
|
|
||||||
Type const & rExcType = cppu::UnoType<decltype(aExc)>::get();
|
Type const & rExcType = cppu::UnoType<decltype(aExc)>::get();
|
||||||
::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
|
::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), nullptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -447,7 +447,7 @@ void unoInterfaceProxyDispatch(
|
|||||||
|
|
||||||
Type const & rExcType = cppu::UnoType<decltype(aExc)>::get();
|
Type const & rExcType = cppu::UnoType<decltype(aExc)>::get();
|
||||||
// Binary identical null reference (whatever that comment means...)
|
// Binary identical null reference (whatever that comment means...)
|
||||||
::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
|
::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), nullptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ extern "C" void * SAL_CALL allocExec(
|
|||||||
p = nullptr;
|
p = nullptr;
|
||||||
}
|
}
|
||||||
#elif defined SAL_W32
|
#elif defined SAL_W32
|
||||||
p = VirtualAlloc(0, n, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
p = VirtualAlloc(nullptr, n, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||||
#endif
|
#endif
|
||||||
if (p != nullptr) {
|
if (p != nullptr) {
|
||||||
*size = n;
|
*size = n;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user