summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-10-14 16:59:08 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-10-16 14:19:31 +0000
commitfee419ae25f15d8f001a1cba1fc1d1704038c94b (patch)
tree705b1ae20d7e7b8bea239c89d6f24fad7927fe33
parent29eb4f122bab9ba7280945d0c8a15588b1d46895 (diff)
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>
-rw-r--r--bridges/inc/cppinterfaceproxy.hxx5
-rw-r--r--bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx55
-rw-r--r--bridges/source/cpp_uno/msvc_win32_x86-64/dllinit.cxx5
-rw-r--r--bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx138
-rw-r--r--bridges/source/cpp_uno/msvc_win32_x86-64/mscx.hxx6
-rw-r--r--bridges/source/cpp_uno/msvc_win32_x86-64/uno2cpp.cxx66
-rw-r--r--bridges/source/cpp_uno/shared/vtablefactory.cxx2
7 files changed, 143 insertions, 134 deletions
diff --git a/bridges/inc/cppinterfaceproxy.hxx b/bridges/inc/cppinterfaceproxy.hxx
index 13a2b2235f02..069e2521b6c2 100644
--- a/bridges/inc/cppinterfaceproxy.hxx
+++ b/bridges/inc/cppinterfaceproxy.hxx
@@ -32,6 +32,11 @@ namespace com { namespace sun { namespace star { namespace uno {
class XInterface;
} } } }
+#if !defined __GNUG__ || defined __MINGW32__
+void dso_init();
+void dso_exit();
+#endif
+
namespace bridges { namespace cpp_uno { namespace shared {
class Bridge;
diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx
index dfa18c4992b7..fee1483180cf 100644
--- a/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx
@@ -43,7 +43,7 @@ static inline typelib_TypeClass cpp2uno_call(
void ** pStack )
{
// Return type
- typelib_TypeDescription * pReturnTD = NULL;
+ typelib_TypeDescription * pReturnTD = nullptr;
if ( pReturnTypeRef )
TYPELIB_DANGER_GET( &pReturnTD, pReturnTypeRef );
@@ -51,8 +51,8 @@ static inline typelib_TypeClass cpp2uno_call(
// value, return address and 'this'
// pointer.
- void * pUnoReturn = NULL;
- void * pCppReturn = NULL; // Complex return ptr: if != NULL && != pUnoReturn, reconversion need
+ void * pUnoReturn = nullptr;
+ void * pCppReturn = nullptr; // Complex return ptr: if != NULL && != pUnoReturn, reconversion need
if ( pReturnTD )
{
@@ -76,18 +76,18 @@ static inline typelib_TypeClass cpp2uno_call(
// micro-optimization, and allocate these array separately
// 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++
- 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)
int * pTempIndexes =
- (int *)alloca( sizeof(int) * nParams );
+ static_cast<int *>(alloca( sizeof(int) * nParams ));
// Type descriptions for reconversions
typelib_TypeDescription ** ppTempParamTD =
- (typelib_TypeDescription **)alloca( sizeof(void *) * nParams );
+ static_cast<typelib_TypeDescription **>(alloca( sizeof(void *) * nParams ));
int nTempIndexes = 0;
@@ -95,7 +95,7 @@ static inline typelib_TypeClass cpp2uno_call(
{
const typelib_MethodParameter & rParam = pParams[nPos];
- typelib_TypeDescription * pParamTD = NULL;
+ typelib_TypeDescription * pParamTD = nullptr;
TYPELIB_DANGER_GET( &pParamTD, rParam.pTypeRef );
if ( !rParam.bOut &&
@@ -156,7 +156,7 @@ static inline typelib_TypeClass cpp2uno_call(
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] );
}
@@ -187,7 +187,7 @@ static inline typelib_TypeClass cpp2uno_call(
pThis->getBridge()->getUno2Cpp() );
}
// Destroy temp UNO param
- ::uno_destructData( pUnoArgs[nIndex], pParamTD, 0 );
+ ::uno_destructData( pUnoArgs[nIndex], pParamTD, nullptr );
TYPELIB_DANGER_RELEASE( pParamTD );
}
@@ -200,7 +200,7 @@ static inline typelib_TypeClass cpp2uno_call(
pCppReturn, pUnoReturn, pReturnTD,
pThis->getBridge()->getUno2Cpp() );
// Destroy temp UNO return
- ::uno_destructData( pUnoReturn, pReturnTD, 0 );
+ ::uno_destructData( pUnoReturn, pReturnTD, nullptr );
}
// Complex return ptr is set to eax
pStack[0] = pCppReturn;
@@ -272,7 +272,7 @@ extern "C" typelib_TypeClass cpp_vtable_call(
{
// is GET method
eRet = cpp2uno_call( pCppI, aMemberDescr.get(), pAttrTypeRef,
- 0, NULL, // No params
+ 0, nullptr, // No params
pStack );
}
else
@@ -280,11 +280,11 @@ extern "C" typelib_TypeClass cpp_vtable_call(
// is SET method
typelib_MethodParameter aParam;
aParam.pTypeRef = pAttrTypeRef;
- aParam.bIn = sal_True;
- aParam.bOut = sal_False;
+ aParam.bIn = true;
+ aParam.bOut = false;
eRet = cpp2uno_call( pCppI, aMemberDescr.get(),
- NULL, // Indicates void return
+ nullptr, // Indicates void return
1, &aParam,
pStack );
}
@@ -305,28 +305,28 @@ extern "C" typelib_TypeClass cpp_vtable_call(
break;
case 0: // queryInterface() opt
{
- typelib_TypeDescription * pTD2 = NULL;
+ typelib_TypeDescription * pTD2 = nullptr;
// the incoming C++ parameters are: The this
// pointer, the hidden return value pointer, and
// then the actual queryInterface() only
// 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 )
{
- XInterface * pInterface = NULL;
+ XInterface * pInterface = nullptr;
(*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)
( pCppI->getBridge()->getCppEnv(),
- (void **)&pInterface,
+ reinterpret_cast<void **>(&pInterface),
pCppI->getOid().pData,
reinterpret_cast<typelib_InterfaceTypeDescription *>( pTD2 ) );
if ( pInterface )
{
// 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->release();
@@ -427,11 +427,11 @@ unsigned char * codeSnippet(
// mov rcx, nOffsetAndIndex
*p++ = 0x48; *p++ = 0xB9;
- *((sal_uInt64 *)p) = nOffsetAndIndex; p += 8;
+ *reinterpret_cast<sal_uInt64 *>(p) = nOffsetAndIndex; p += 8;
// mov r11, privateSnippetExecutor
*p++ = 0x49; *p++ = 0xBB;
- *((void **)p) = &privateSnippetExecutor; p += 8;
+ *reinterpret_cast<void **>(p) = &privateSnippetExecutor; p += 8;
// jmp r11
*p++ = 0x41; *p++ = 0xFF; *p++ = 0xE3;
@@ -468,8 +468,7 @@ bridges::cpp_uno::shared::VtableFactory::initializeBlock(
Rtti():
n0(0), n1(0), n2(0),
rtti(CPPU_CURRENT_NAMESPACE::mscx_getRTTI(
- OUString(
- "com.sun.star.uno.XInterface")))
+ "com.sun.star.uno.XInterface"))
{}
};
static Rtti rtti;
@@ -491,7 +490,7 @@ unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
Slot * s = *slots;
for (int member = 0; member < type->nMembers; ++member) {
- typelib_TypeDescription * pTD = NULL;
+ typelib_TypeDescription * pTD = nullptr;
TYPELIB_DANGER_GET( &pTD, type->ppMembers[ member ] );
assert(pTD);
@@ -516,7 +515,7 @@ unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
code = codeSnippet( code, param_kind, nFunctionOffset++, nVtableOffset );
if ( ! pIfaceAttrTD->bReadOnly )
{
- typelib_TypeDescription * pAttrTD = NULL;
+ typelib_TypeDescription * pAttrTD = nullptr;
TYPELIB_DANGER_GET( &pAttrTD, pIfaceAttrTD->pAttributeTypeRef );
assert(pAttrTD);
@@ -536,7 +535,7 @@ unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
typelib_InterfaceMethodTypeDescription * pMethodTD =
reinterpret_cast<typelib_InterfaceMethodTypeDescription *>( pTD );
- typelib_TypeDescription * pReturnTD = NULL;
+ typelib_TypeDescription * pReturnTD = nullptr;
TYPELIB_DANGER_GET( &pReturnTD, pMethodTD->pReturnTypeRef );
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)
{
- typelib_TypeDescription * pParamTD = NULL;
+ typelib_TypeDescription * pParamTD = nullptr;
TYPELIB_DANGER_GET( &pParamTD, pMethodTD->pParams[param].pTypeRef );
assert(pParamTD);
diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/dllinit.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/dllinit.cxx
index 356f36092e31..e71238cce721 100644
--- a/bridges/source/cpp_uno/msvc_win32_x86-64/dllinit.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_x86-64/dllinit.cxx
@@ -22,10 +22,7 @@
#include <windows.h>
#pragma warning(pop)
-
-void dso_init();
-void dso_exit();
-
+#include <cppinterfaceproxy.hxx>
extern "C" BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved)
{
diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx
index f66e9b15b6cc..15a12d58fc77 100644
--- a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx
@@ -252,12 +252,6 @@ void
#include "mscx.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)
using namespace ::com::sun::star::uno;
@@ -310,32 +304,33 @@ static inline OUString toRTTIname(
//RTTI simulation
typedef std::unordered_map< OUString, void *, OUStringHash > t_string2PtrMap;
-class __type_info_descriptor;
+class type_info_descriptor;
class RTTInfos
{
Mutex _aMutex;
t_string2PtrMap _allRTTI;
- static OUString toRawName( OUString const & rUNOname ) throw ();
public:
type_info * getRTTI( 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 ();
+#if !defined LEAK_STATIC_DATA
~RTTInfos() throw ();
+#endif
};
-class __type_info
+class type_info_
{
friend type_info * RTTInfos::getRTTI( OUString const & ) throw ();
friend int mscx_filterCppException(
LPEXCEPTION_POINTERS, uno_Any *, uno_Mapping * );
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 )
{ ::strcpy( _m_d_name, m_d_name ); } // #100211# - checked
@@ -344,28 +339,28 @@ private:
char _m_d_name[1];
};
-__type_info::~__type_info() throw ()
+type_info_::~type_info_() throw ()
{
(void)_m_data;
}
-class __type_info_descriptor
+class type_info_descriptor
{
private:
int type_info_size;
- __type_info info;
+ type_info_ info;
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)
{
- 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()
{
- return (type_info *)&info;
+ return reinterpret_cast<type_info *>(&info);
}
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
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(NULL, aRawName.getStr());
+ type_info_descriptor * pRTTI = new(::rtl_allocateMemory(sizeof(type_info_descriptor) + aRawName.getLength()))
+ type_info_descriptor(nullptr, aRawName.getStr());
// put into map
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 ()
{
// 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 );
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
if (iFind == _allRTTI.end())
{
- // Wrap new __type_info in __type_info_descriptor to preserve length info
- __type_info_descriptor * pRTTI = insert_new_type_info_descriptor(rUNOname);
+ // Wrap new type_info_ in type_info_descriptor to preserve length info
+ type_info_descriptor * pRTTI = insert_new_type_info_descriptor(rUNOname);
return pRTTI->get_type_info();
}
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);
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
if (iFind == _allRTTI.end())
{
- // Wrap new __type_info in __type_info_descriptor to preserve length info
- __type_info_descriptor * pRTTI = insert_new_type_info_descriptor(rUNOname);
+ // Wrap new type_info_ in type_info_descriptor to preserve length info
+ type_info_descriptor * pRTTI = insert_new_type_info_descriptor(rUNOname);
return pRTTI->get_type_info_size();
}
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 ()
{
SAL_INFO("bridges", "> freeing generated RTTI infos... <");
@@ -439,11 +435,12 @@ RTTInfos::~RTTInfos() throw ()
for ( t_string2PtrMap::const_iterator iPos( _allRTTI.begin() );
iPos != _allRTTI.end(); ++iPos )
{
- __type_info * pType = (__type_info *)iPos->second;
- pType->~__type_info(); // obsolete, but good style...
+ type_info_ * pType = static_cast<type_info_ *>(iPos->second);
+ pType->~type_info_(); // obsolete, but good style...
::rtl_freeMemory( pType );
}
}
+#endif
void * __cdecl copyConstruct(
void * pExcThis,
@@ -472,11 +469,11 @@ void GenerateConstructorTrampoline(
// mov r8, pTD
*p++ = 0x49; *p++ = 0xB8;
- *((void **)p) = pTD; p += 8;
+ *reinterpret_cast<void **>(p) = pTD; p += 8;
// mov r11, copyConstruct
*p++ = 0x49; *p++ = 0xBB;
- *((void **)p) = reinterpret_cast<void *>(&copyConstruct); p += 8;
+ *reinterpret_cast<void **>(p) = reinterpret_cast<void *>(&copyConstruct); p += 8;
// jmp r11
*p++ = 0x41; *p++ = 0xFF; *p++ = 0xE3;
@@ -492,11 +489,11 @@ void GenerateDestructorTrampoline(
// mov rdx, pTD
*p++ = 0x48; *p++ = 0xBA;
- *((void **)p) = pTD; p += 8;
+ *reinterpret_cast<void **>(p) = pTD; p += 8;
// mov r11, destruct
*p++ = 0x49; *p++ = 0xBB;
- *((void **)p) = reinterpret_cast<void *>(&destruct); p += 8;
+ *reinterpret_cast<void **>(p) = reinterpret_cast<void *>(&destruct); p += 8;
// jmp r11
*p++ = 0x41; *p++ = 0xFF; *p++ = 0xE3;
@@ -513,7 +510,7 @@ struct ExceptionType
sal_Int32 _n1, _n2, _n3; // thiscast
sal_Int32 _n4; // object_size
sal_uInt32 _pCopyCtor; // copyctor
- __type_info type_info;
+ type_info_ type_info;
inline ExceptionType(
@@ -525,7 +522,7 @@ struct ExceptionType
, _n2( -1 )
, _n3( 0 )
, _n4( pTD->nSize)
- , type_info(NULL, "")
+ , type_info(nullptr, "")
{
// As _n0 is always initialized to zero, that means the
// hasvirtbase flag (see the ONTL catchabletype struct) is
@@ -541,9 +538,6 @@ struct ExceptionType
_pCopyCtor = static_cast<sal_uInt32>(
reinterpret_cast<sal_uInt64>(pCode) - pCodeBase);
}
- inline ~ExceptionType() throw ()
- {
- }
};
struct RaiseInfo;
@@ -559,7 +553,9 @@ public:
static DWORD allocationGranularity;
ExceptionInfos() throw ();
+#if !defined LEAK_STATIC_DATA
~ExceptionInfos() throw ();
+#endif
};
DWORD ExceptionInfos::allocationGranularity = 0;
@@ -580,7 +576,9 @@ struct RaiseInfo
explicit RaiseInfo(typelib_TypeDescription * pTD) throw ();
+#if !defined LEAK_STATIC_DATA
~RaiseInfo() throw ();
+#endif
};
/* Rewrite of 32-Bit-Code to work under 64 Bit:
@@ -606,7 +604,7 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw ()
int codeSize = codeSnippetSize;
// Info count
int nLen = 0;
- for (pCompTD = (typelib_CompoundTypeDescription*)pTD;
+ for (pCompTD = reinterpret_cast<typelib_CompoundTypeDescription*>(pTD);
pCompTD; pCompTD = pCompTD->pBaseTypeDescription)
{
++nLen;
@@ -622,7 +620,7 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw ()
int *exceptionTypeSizeArray = new int[nLen];
nLen = 0;
- for (pCompTD = (typelib_CompoundTypeDescription*)pTD;
+ for (pCompTD = reinterpret_cast<typelib_CompoundTypeDescription*>(pTD);
pCompTD; pCompTD = pCompTD->pBaseTypeDescription)
{
int typeInfoLen = mscx_getRTTI_len(pCompTD->aBase.pTypeName);
@@ -647,11 +645,11 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw ()
// 32 bit offsets
const int totalSize = codeSize + typeInfoArraySize + excTypeAddLen;
unsigned char * pCode = _code =
- (unsigned char *)::rtl_allocateMemory(totalSize);
+ static_cast<unsigned char *>(::rtl_allocateMemory(totalSize));
int pCodeOffset = 0;
// 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
unsigned char *etMem = pCode + codeSize + typeInfoArraySize;
@@ -670,7 +668,7 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw ()
// Fill pCode with D-Tor code
GenerateDestructorTrampoline(pCode, pTD);
- _pDtor = (sal_Int32)((sal_uInt64)pCode - _codeBase);
+ _pDtor = (sal_Int32)(reinterpret_cast<sal_uInt64>(pCode) - _codeBase);
pCodeOffset += codeSnippetSize;
// 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;
int nPos = 1;
- for (pCompTD = (typelib_CompoundTypeDescription*)pTD;
+ for (pCompTD = reinterpret_cast<typelib_CompoundTypeDescription*>(pTD);
pCompTD; pCompTD = pCompTD->pBaseTypeDescription)
{
// Create instance in mem block with placement new
ExceptionType * et = new(etMem + etMemOffset)ExceptionType(
- pCode + pCodeOffset, _codeBase, (typelib_TypeDescription *)pCompTD);
+ pCode + pCodeOffset, _codeBase, reinterpret_cast<typelib_TypeDescription *>(pCompTD));
// Next trampoline entry offset
pCodeOffset += codeSnippetSize;
@@ -704,25 +702,28 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw ()
delete[] exceptionTypeSizeArray;
}
+#if !defined LEAK_STATIC_DATA
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!
- 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();
}
// free our single block
::rtl_freeMemory( _code );
::typelib_typedescription_release( _pTD );
}
+#endif
ExceptionInfos::ExceptionInfos() throw ()
{
}
+#if !defined LEAK_STATIC_DATA
ExceptionInfos::~ExceptionInfos() throw ()
{
SAL_INFO("bridges", "> freeing exception infos... <");
@@ -731,13 +732,14 @@ ExceptionInfos::~ExceptionInfos() throw ()
for ( t_string2PtrMap::const_iterator iPos( _allRaiseInfos.begin() );
iPos != _allRaiseInfos.end(); ++iPos )
{
- delete (RaiseInfo *)iPos->second;
+ delete static_cast<RaiseInfo *>(iPos->second);
}
}
+#endif
RaiseInfo * ExceptionInfos::getRaiseInfo( typelib_TypeDescription * pTD ) throw ()
{
- static ExceptionInfos * s_pInfos = 0;
+ static ExceptionInfos * s_pInfos = nullptr;
if (! s_pInfos)
{
MutexGuard aGuard( Mutex::getGlobalMutex() );
@@ -772,13 +774,13 @@ RaiseInfo * ExceptionInfos::getRaiseInfo( typelib_TypeDescription * pTD ) throw
// Put into map
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?!");
}
else
{
// Reuse existing info
- pRaiseInfo = (RaiseInfo *)iFind->second;
+ pRaiseInfo = static_cast<RaiseInfo *>(iFind->second);
}
return pRaiseInfo;
@@ -787,7 +789,7 @@ RaiseInfo * ExceptionInfos::getRaiseInfo( typelib_TypeDescription * pTD ) throw
type_info * mscx_getRTTI(
OUString const & rUNOname )
{
- static RTTInfos * s_pRTTIs = 0;
+ static RTTInfos * s_pRTTIs = nullptr;
if (! s_pRTTIs)
{
MutexGuard aGuard( Mutex::getGlobalMutex() );
@@ -806,7 +808,7 @@ type_info * mscx_getRTTI(
int mscx_getRTTI_len(
OUString const & rUNOname)
{
- static RTTInfos * s_pRTTIs = 0;
+ static RTTInfos * s_pRTTIs = nullptr;
if (!s_pRTTIs)
{
MutexGuard aGuard(Mutex::getGlobalMutex());
@@ -833,7 +835,7 @@ void mscx_raiseException(
// ExceptionInfos::getRaiseInfo()
// construct cpp exception object
- typelib_TypeDescription * pTD = NULL;
+ typelib_TypeDescription * pTD = nullptr;
TYPELIB_DANGER_GET( &pTD, pUnoExc->pType );
void * pCppExc = alloca( pTD->nSize );
@@ -841,12 +843,12 @@ void mscx_raiseException(
ULONG_PTR arFilterArgs[4];
arFilterArgs[0] = MSVC_magic_number;
- arFilterArgs[1] = (ULONG_PTR)pCppExc;
- arFilterArgs[2] = (ULONG_PTR)ExceptionInfos::getRaiseInfo( pTD );
- arFilterArgs[3] = ((RaiseInfo *)arFilterArgs[2])->_codeBase;
+ arFilterArgs[1] = reinterpret_cast<ULONG_PTR>(pCppExc);
+ arFilterArgs[2] = reinterpret_cast<ULONG_PTR>(ExceptionInfos::getRaiseInfo( pTD ));
+ arFilterArgs[3] = reinterpret_cast<RaiseInfo *>(arFilterArgs[2])->_codeBase;
// Destruct uno exception
- ::uno_any_destruct( pUnoExc, 0 );
+ ::uno_any_destruct( pUnoExc, nullptr );
TYPELIB_DANGER_RELEASE( pTD );
// last point to release anything not affected by stack unwinding
@@ -858,13 +860,13 @@ int mscx_filterCppException(
uno_Any * pUnoExc,
uno_Mapping * pCpp2Uno )
{
- if (pPointers == 0)
+ if (pPointers == nullptr)
return EXCEPTION_CONTINUE_SEARCH;
EXCEPTION_RECORD * pRecord = pPointers->ExceptionRecord;
// Handle only C++ exceptions:
- if (pRecord == 0 || pRecord->ExceptionCode != MSVC_ExceptionCode)
+ if (pRecord == nullptr || pRecord->ExceptionCode != MSVC_ExceptionCode)
return EXCEPTION_CONTINUE_SEARCH;
bool rethrow = __CxxDetectRethrow( &pRecord );
@@ -890,7 +892,7 @@ int mscx_filterCppException(
}
// Rethrow: handle only C++ exceptions:
- if (pRecord == 0 || pRecord->ExceptionCode != MSVC_ExceptionCode)
+ if (pRecord == nullptr || pRecord->ExceptionCode != MSVC_ExceptionCode)
return EXCEPTION_CONTINUE_SEARCH;
if (pRecord->NumberParameters == 4 &&
@@ -921,15 +923,15 @@ int mscx_filterCppException(
{
OUString aRTTIname(
OStringToOUString(
- (reinterpret_cast<__type_info *>(base + et->_pTypeInfo)
+ (reinterpret_cast<type_info_ *>(base + et->_pTypeInfo)
->_m_d_name),
RTL_TEXTENCODING_ASCII_US));
OUString aUNOname( toUNOname( aRTTIname ) );
- typelib_TypeDescription * pExcTD = 0;
+ typelib_TypeDescription * pExcTD = nullptr;
typelib_typedescription_getByName(
&pExcTD, aUNOname.pData );
- if (pExcTD == NULL)
+ if (pExcTD == nullptr)
{
OUStringBuffer buf;
buf.append(
@@ -948,7 +950,7 @@ int mscx_filterCppException(
{
// construct uno exception any
uno_any_constructAndConvert(
- pUnoExc, (void *) pRecord->ExceptionInformation[1],
+ pUnoExc, reinterpret_cast<void *>(pRecord->ExceptionInformation[1]),
pExcTD, pCpp2Uno );
typelib_typedescription_release( pExcTD );
}
diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/mscx.hxx b/bridges/source/cpp_uno/msvc_win32_x86-64/mscx.hxx
index 297afba07bc9..6bfada394477 100644
--- a/bridges/source/cpp_uno/msvc_win32_x86-64/mscx.hxx
+++ b/bridges/source/cpp_uno/msvc_win32_x86-64/mscx.hxx
@@ -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
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/uno2cpp.cxx
index 4e455f9d4a44..2a6bcb8733dd 100644
--- a/bridges/source/cpp_uno/msvc_win32_x86-64/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_x86-64/uno2cpp.cxx
@@ -42,7 +42,7 @@ using namespace ::com::sun::star::uno;
namespace
{
-static bool cpp_call(
+bool cpp_call(
bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
bridges::cpp_uno::shared::VtableSlot aVtableSlot,
typelib_TypeDescriptionReference * pReturnTypeRef,
@@ -72,12 +72,12 @@ static bool cpp_call(
int nCppParamIndex = 0;
// Return type
- typelib_TypeDescription * pReturnTD = NULL;
+ typelib_TypeDescription * pReturnTD = nullptr;
TYPELIB_DANGER_GET( &pReturnTD, pReturnTypeRef );
assert(pReturnTD);
// 'this'
- void * pAdjustedThisPtr = (void **)( pThis->getCppI() ) + aVtableSlot.offset;
+ void * pAdjustedThisPtr = reinterpret_cast<void **>( pThis->getCppI() ) + aVtableSlot.offset;
aCppParams[nCppParamIndex++].p = pAdjustedThisPtr;
enum class ReturnKind { Void, Simple, Complex, ComplexConvert };
@@ -110,7 +110,7 @@ static bool cpp_call(
{
const typelib_MethodParameter & rParam = pParams[nPos];
- typelib_TypeDescription * pParamTD = NULL;
+ typelib_TypeDescription * pParamTD = nullptr;
TYPELIB_DANGER_GET( &pParamTD, rParam.pTypeRef );
if ( !rParam.bOut &&
@@ -186,12 +186,12 @@ static bool cpp_call(
// expects. (The callee is not actually varargs, of course.)
sal_Int64 (*pIMethod)(sal_Int64, ...) =
- (sal_Int64 (*)(sal_Int64, ...))
- (*((sal_uInt64 **)pAdjustedThisPtr))[aVtableSlot.index];
+ reinterpret_cast<sal_Int64 (*)(sal_Int64, ...)>(
+ (*static_cast<sal_uInt64 **>(pAdjustedThisPtr))[aVtableSlot.index]);
double (*pFMethod)(sal_Int64, ...) =
- (double (*)(sal_Int64, ...))
- (*((sal_uInt64 **)pAdjustedThisPtr))[aVtableSlot.index];
+ reinterpret_cast<double (*)(sal_Int64, ...)>(
+ (*static_cast<sal_uInt64 **>(pAdjustedThisPtr))[aVtableSlot.index]);
// 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
@@ -245,7 +245,7 @@ static bool cpp_call(
}
// No exception occurred
- *ppUnoExc = NULL;
+ *ppUnoExc = nullptr;
// Reconvert temporary params
while ( nTempIndexes-- )
@@ -260,7 +260,7 @@ static bool cpp_call(
if ( pParams[nIndex].bOut ) // Inout
{
::uno_destructData(
- pUnoArgs[nIndex], pParamTD, 0 ); // Destroy UNO value
+ pUnoArgs[nIndex], pParamTD, nullptr ); // Destroy UNO value
::uno_copyAndConvertData(
pUnoArgs[nIndex], aCppParams[nCppIndex].p, pParamTD,
pThis->getBridge()->getCpp2Uno() );
@@ -285,7 +285,7 @@ static bool cpp_call(
case ReturnKind::Void:
break;
case ReturnKind::Simple:
- *(sal_Int64*)pUnoReturn = uRetVal.i;
+ *static_cast<sal_Int64*>(pUnoReturn) = uRetVal.i;
break;
case ReturnKind::Complex:
assert(uRetVal.p == pUnoReturn);
@@ -330,7 +330,7 @@ void unoInterfaceProxyDispatch(
{
#if OSL_DEBUG_LEVEL > 0
// 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);
#endif
VtableSlot aVtableSlot(
@@ -343,8 +343,8 @@ void unoInterfaceProxyDispatch(
// Is GET
cpp_call(
pThis, aVtableSlot,
- ((typelib_InterfaceAttributeTypeDescription *)pMemberTD)->pAttributeTypeRef,
- 0, NULL, // no params
+ reinterpret_cast<typelib_InterfaceAttributeTypeDescription const *>(pMemberTD)->pAttributeTypeRef,
+ 0, nullptr, // no params
pReturn, pArgs, ppException );
}
else
@@ -352,11 +352,11 @@ void unoInterfaceProxyDispatch(
// Is SET
typelib_MethodParameter aParam;
aParam.pTypeRef =
- ((typelib_InterfaceAttributeTypeDescription *)pMemberTD)->pAttributeTypeRef;
- aParam.bIn = sal_True;
- aParam.bOut = sal_False;
+ reinterpret_cast<typelib_InterfaceAttributeTypeDescription const *>(pMemberTD)->pAttributeTypeRef;
+ aParam.bIn = true;
+ aParam.bOut = false;
- typelib_TypeDescriptionReference * pReturnTypeRef = NULL;
+ typelib_TypeDescriptionReference * pReturnTypeRef = nullptr;
OUString aVoidName("void");
typelib_typedescriptionreference_new(
&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
@@ -377,7 +377,7 @@ void unoInterfaceProxyDispatch(
{
#if OSL_DEBUG_LEVEL > 0
// 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);
#endif
VtableSlot aVtableSlot(
@@ -391,34 +391,34 @@ void unoInterfaceProxyDispatch(
// Standard calls
case 1: // Acquire UNO interface
(*pUnoI->acquire)( pUnoI );
- *ppException = 0;
+ *ppException = nullptr;
break;
case 2: // Release UNO interface
(*pUnoI->release)( pUnoI );
- *ppException = 0;
+ *ppException = nullptr;
break;
case 0: // queryInterface() opt
{
- typelib_TypeDescription * pTD = NULL;
- TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
+ typelib_TypeDescription * pTD = nullptr;
+ TYPELIB_DANGER_GET( &pTD, static_cast< Type * >( pArgs[0] )->getTypeLibType() );
if ( pTD )
{
- uno_Interface * pInterface = NULL;
+ uno_Interface * pInterface = nullptr;
(*pThis->getBridge()->getUnoEnv()->getRegisteredInterface)(
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 )
{
::uno_any_construct(
- reinterpret_cast< uno_Any * >( pReturn ),
- &pInterface, pTD, 0 );
+ static_cast< uno_Any * >( pReturn ),
+ &pInterface, pTD, nullptr );
(*pInterface->release)( pInterface );
TYPELIB_DANGER_RELEASE( pTD );
- *ppException = 0;
+ *ppException = nullptr;
break;
}
TYPELIB_DANGER_RELEASE( pTD );
@@ -428,15 +428,15 @@ void unoInterfaceProxyDispatch(
default:
if ( ! cpp_call(
pThis, aVtableSlot,
- ((typelib_InterfaceMethodTypeDescription *)pMemberTD)->pReturnTypeRef,
- ((typelib_InterfaceMethodTypeDescription *)pMemberTD)->nParams,
- ((typelib_InterfaceMethodTypeDescription *)pMemberTD)->pParams,
+ reinterpret_cast<typelib_InterfaceMethodTypeDescription const *>(pMemberTD)->pReturnTypeRef,
+ reinterpret_cast<typelib_InterfaceMethodTypeDescription const *>(pMemberTD)->nParams,
+ reinterpret_cast<typelib_InterfaceMethodTypeDescription const *>(pMemberTD)->pParams,
pReturn, pArgs, ppException ) )
{
RuntimeException aExc( "Too many parameters!" );
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;
@@ -447,7 +447,7 @@ void unoInterfaceProxyDispatch(
Type const & rExcType = cppu::UnoType<decltype(aExc)>::get();
// 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 );
}
}
}
diff --git a/bridges/source/cpp_uno/shared/vtablefactory.cxx b/bridges/source/cpp_uno/shared/vtablefactory.cxx
index 15e24178a442..eecedbbb61cb 100644
--- a/bridges/source/cpp_uno/shared/vtablefactory.cxx
+++ b/bridges/source/cpp_uno/shared/vtablefactory.cxx
@@ -96,7 +96,7 @@ extern "C" void * SAL_CALL allocExec(
p = nullptr;
}
#elif defined SAL_W32
- p = VirtualAlloc(0, n, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ p = VirtualAlloc(nullptr, n, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#endif
if (p != nullptr) {
*size = n;