Kaydet (Commit) fee419ae authored tarafından Stephan Bergmann's avatar Stephan Bergmann

clang-cl loplugin: bridges

Change-Id: I46bcc6eb1f34184626d2f584d7164d84f54c2cf8
Reviewed-on: https://gerrit.libreoffice.org/29879Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
Tested-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 29eb4f12
......@@ -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;
......
......@@ -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);
......
......@@ -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)
{
......
......@@ -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: */
......@@ -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 );
}
}
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment