From 79368f81028a05f1d3685f0052806d3f93cd2da8 Mon Sep 17 00:00:00 2001 From: Philipp Hofer Date: Thu, 12 Nov 2020 12:49:31 +0100 Subject: tdf#123936 Formatting files in module bridges with clang-format Change-Id: Ice8b5ff4ddde1b0eca19cf29c418e3281389926d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105648 Tested-by: Jenkins Reviewed-by: Christian Lohmaier --- bridges/inc/types.hxx | 11 +-- bridges/inc/vtables.hxx | 18 ++-- bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.hxx | 7 +- .../source/cpp_uno/msvc_win32_x86-64/except.cxx | 105 ++++++++++----------- 4 files changed, 68 insertions(+), 73 deletions(-) (limited to 'bridges') diff --git a/bridges/inc/types.hxx b/bridges/inc/types.hxx index d35529342672..597d55909d09 100644 --- a/bridges/inc/types.hxx +++ b/bridges/inc/types.hxx @@ -22,8 +22,8 @@ #include #include -namespace bridges::cpp_uno::shared { - +namespace bridges::cpp_uno::shared +{ /** * Determines whether a type is a "simple" type (VOID, BOOLEAN, BYTE, SHORT, * UNSIGNED SHORT, LONG, UNSIGNED LONG, HYPER, UNSIGNED HYPER, FLOAT, DOUBLE, @@ -42,7 +42,7 @@ bool isSimpleType(typelib_TypeClass typeClass); * @param type a non-null pointer to a type description reference * @return true if the given type is "simple" */ -bool isSimpleType(typelib_TypeDescriptionReference const * type); +bool isSimpleType(typelib_TypeDescriptionReference const* type); /** * Determines whether a type is a "simple" type (VOID, BOOLEAN, BYTE, SHORT, @@ -52,7 +52,7 @@ bool isSimpleType(typelib_TypeDescriptionReference const * type); * @param type a non-null pointer to a type description * @return true if the given type is "simple" */ -bool isSimpleType(typelib_TypeDescription const * type); +bool isSimpleType(typelib_TypeDescription const* type); /** * Determines whether a type relates to an interface type (is itself an @@ -61,8 +61,7 @@ bool isSimpleType(typelib_TypeDescription const * type); * @param type a non-null pointer to a type description * @return true if the given type relates to an interface type */ -bool relatesToInterfaceType(typelib_TypeDescription const * type); - +bool relatesToInterfaceType(typelib_TypeDescription const* type); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/inc/vtables.hxx b/bridges/inc/vtables.hxx index 2dc604f0a64f..57ee58f53a85 100644 --- a/bridges/inc/vtables.hxx +++ b/bridges/inc/vtables.hxx @@ -22,8 +22,8 @@ #include #include -namespace bridges::cpp_uno::shared { - +namespace bridges::cpp_uno::shared +{ /** * Calculate the number of local functions of an interface type. * @@ -37,7 +37,7 @@ namespace bridges::cpp_uno::shared { * executed * @return the number of local functions of the given interface type */ -sal_Int32 getLocalFunctions(typelib_InterfaceTypeDescription const * type); +sal_Int32 getLocalFunctions(typelib_InterfaceTypeDescription const* type); /** * Calculate the number of primary functions of an interface type. @@ -51,12 +51,13 @@ sal_Int32 getLocalFunctions(typelib_InterfaceTypeDescription const * type); * @return the number of primary functions of the given interface type, or zero * if the given interface type is null */ -sal_Int32 getPrimaryFunctions(typelib_InterfaceTypeDescription * type); +sal_Int32 getPrimaryFunctions(typelib_InterfaceTypeDescription* type); /** * Represents a vtable slot of a C++ class. */ -struct VtableSlot { +struct VtableSlot +{ /** * The offset of the vtable. * @@ -82,8 +83,7 @@ struct VtableSlot { * description * @return the vtable slot associated with the given interface member */ -VtableSlot getVtableSlot( - typelib_InterfaceAttributeTypeDescription const * ifcMember); +VtableSlot getVtableSlot(typelib_InterfaceAttributeTypeDescription const* ifcMember); /** * Calculates the vtable slot associated with an interface method member. @@ -91,9 +91,7 @@ VtableSlot getVtableSlot( * @param ifcMember a non-null pointer to an interface method member description * @return the vtable slot associated with the given interface member */ -VtableSlot getVtableSlot( - typelib_InterfaceMethodTypeDescription const * ifcMember); - +VtableSlot getVtableSlot(typelib_InterfaceMethodTypeDescription const* ifcMember); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.hxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.hxx index f861e52f728c..b056f2e64006 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.hxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.hxx @@ -25,10 +25,9 @@ #include -namespace x86_64 { - -std::type_info * getRtti(typelib_TypeDescription const & type); - +namespace x86_64 +{ +std::type_info* getRtti(typelib_TypeDescription const& type); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 24c3716333aa..ec874621baf8 100644 --- a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx +++ b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx @@ -233,7 +233,6 @@ void #endif // 0 - #include #include @@ -256,18 +255,14 @@ void using namespace ::com::sun::star; -static void * __cdecl copyConstruct( - void * pExcThis, - void * pSource, - typelib_TypeDescription * pTD ) throw () +static void* __cdecl copyConstruct(void* pExcThis, void* pSource, + typelib_TypeDescription* pTD) throw() { ::uno_copyData(pExcThis, pSource, pTD, uno::cpp_acquire); return pExcThis; } -static void * __cdecl destruct( - void * pExcThis, - typelib_TypeDescription * pTD ) throw () +static void* __cdecl destruct(void* pExcThis, typelib_TypeDescription* pTD) throw() { ::uno_destructData(pExcThis, pTD, uno::cpp_release); return pExcThis; @@ -275,48 +270,56 @@ static void * __cdecl destruct( const int codeSnippetSize = 40; -static void GenerateConstructorTrampoline( - unsigned char * code, - typelib_TypeDescription * pTD ) throw () +static void GenerateConstructorTrampoline(unsigned char* code, typelib_TypeDescription* pTD) throw() { - unsigned char *p = code; + unsigned char* p = code; // mov r8, pTD - *p++ = 0x49; *p++ = 0xB8; - *reinterpret_cast(p) = pTD; p += 8; + *p++ = 0x49; + *p++ = 0xB8; + *reinterpret_cast(p) = pTD; + p += 8; // mov r11, copyConstruct - *p++ = 0x49; *p++ = 0xBB; - *reinterpret_cast(p) = reinterpret_cast(©Construct); p += 8; + *p++ = 0x49; + *p++ = 0xBB; + *reinterpret_cast(p) = reinterpret_cast(©Construct); + p += 8; // jmp r11 - *p++ = 0x41; *p++ = 0xFF; *p++ = 0xE3; + *p++ = 0x41; + *p++ = 0xFF; + *p++ = 0xE3; - assert( p < code + codeSnippetSize ); + assert(p < code + codeSnippetSize); } -static void GenerateDestructorTrampoline( - unsigned char * code, - typelib_TypeDescription * pTD ) throw () +static void GenerateDestructorTrampoline(unsigned char* code, typelib_TypeDescription* pTD) throw() { - unsigned char *p = code; + unsigned char* p = code; // mov rdx, pTD - *p++ = 0x48; *p++ = 0xBA; - *reinterpret_cast(p) = pTD; p += 8; + *p++ = 0x48; + *p++ = 0xBA; + *reinterpret_cast(p) = pTD; + p += 8; // mov r11, destruct - *p++ = 0x49; *p++ = 0xBB; - *reinterpret_cast(p) = reinterpret_cast(&destruct); p += 8; + *p++ = 0x49; + *p++ = 0xBB; + *reinterpret_cast(p) = reinterpret_cast(&destruct); + p += 8; // jmp r11 - *p++ = 0x41; *p++ = 0xFF; *p++ = 0xE3; + *p++ = 0x41; + *p++ = 0xFF; + *p++ = 0xE3; - assert( p < code + codeSnippetSize ); + assert(p < code + codeSnippetSize); } -ExceptionType::ExceptionType(unsigned char * pCode, sal_uInt64 pCodeBase, - typelib_TypeDescription * pTD) throw () +ExceptionType::ExceptionType(unsigned char* pCode, sal_uInt64 pCodeBase, + typelib_TypeDescription* pTD) throw() : _n0(0) , _n1(0) , _n2(-1) @@ -352,20 +355,20 @@ ExceptionType::ExceptionType(unsigned char * pCode, sal_uInt64 pCodeBase, * is also member of ExceptionType and can be referenced via 32 bit offset. */ -RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw () +RaiseInfo::RaiseInfo(typelib_TypeDescription* pTD) throw() : _n0(0) , _n2(0) , _pTD(pTD) { - typelib_CompoundTypeDescription * pCompTD; + typelib_CompoundTypeDescription* pCompTD; // Count how many trampolines we need int codeSize = codeSnippetSize; // Info count int nLen = 0; - for (pCompTD = reinterpret_cast(pTD); - pCompTD; pCompTD = pCompTD->pBaseTypeDescription) + for (pCompTD = reinterpret_cast(pTD); pCompTD; + pCompTD = pCompTD->pBaseTypeDescription) { ++nLen; codeSize += codeSnippetSize; @@ -380,8 +383,8 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw () auto exceptionTypeSizeArray = std::make_unique(nLen); nLen = 0; - for (pCompTD = reinterpret_cast(pTD); - pCompTD; pCompTD = pCompTD->pBaseTypeDescription) + for (pCompTD = reinterpret_cast(pTD); pCompTD; + pCompTD = pCompTD->pBaseTypeDescription) { int typeInfoLen; RTTInfos::get(pCompTD->aBase.pTypeName, &typeInfoLen); @@ -390,7 +393,7 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw () { int n = typeInfoLen / 4; n++; - typeInfoLen = n*4; + typeInfoLen = n * 4; } exceptionTypeSizeArray[nLen++] = typeInfoLen + sizeof(ExceptionType); } @@ -405,24 +408,22 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw () // Allocate mem for code and all dynamic data in one chunk to guarantee // 32 bit offsets const int totalSize = codeSize + typeInfoArraySize + excTypeAddLen; - unsigned char * pCode = _code = - static_cast(std::malloc(totalSize)); + unsigned char* pCode = _code = static_cast(std::malloc(totalSize)); int pCodeOffset = 0; // New base of types array, starts after Trampoline D-Tor / C-Tors - DWORD * types = reinterpret_cast(pCode + codeSize); + DWORD* types = reinterpret_cast(pCode + codeSize); // New base of ExceptionType array, starts after types array - unsigned char *etMem = pCode + codeSize + typeInfoArraySize; + unsigned char* etMem = pCode + codeSize + typeInfoArraySize; int etMemOffset = 0; _codeBase = reinterpret_cast(pCode) - & ~static_cast(ExceptionInfos::allocationGranularity - 1); + & ~static_cast(ExceptionInfos::allocationGranularity - 1); DWORD old_protect; - bool success = - VirtualProtect(pCode, codeSize, PAGE_EXECUTE_READWRITE, &old_protect); - (void) success; + bool success = VirtualProtect(pCode, codeSize, PAGE_EXECUTE_READWRITE, &old_protect); + (void)success; assert(success && "VirtualProtect() failed!"); ::typelib_typedescription_acquire(pTD); @@ -434,18 +435,17 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw () // Info count accompanied by type info ptrs: type, base type, base base type, ... // Keep offset of types_array - _types = static_cast( - reinterpret_cast(types)-_codeBase); + _types = static_cast(reinterpret_cast(types) - _codeBase); // Fill types: (nLen, _offset to ExceptionType1, ...ExceptionType2, ...) types[0] = nLen; int nPos = 1; - for (pCompTD = reinterpret_cast(pTD); - pCompTD; pCompTD = pCompTD->pBaseTypeDescription) + for (pCompTD = reinterpret_cast(pTD); pCompTD; + pCompTD = pCompTD->pBaseTypeDescription) { // Create instance in mem block with placement new - ExceptionType * et = new(etMem + etMemOffset)ExceptionType( - pCode + pCodeOffset, _codeBase, reinterpret_cast(pCompTD)); + ExceptionType* et = new (etMem + etMemOffset) ExceptionType( + pCode + pCodeOffset, _codeBase, reinterpret_cast(pCompTD)); // Next trampoline entry offset pCodeOffset += codeSnippetSize; @@ -453,8 +453,7 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw () etMemOffset += exceptionTypeSizeArray[nPos - 1]; // Keep offset of addresses of ET for D-Tor call in ~RaiseInfo - types[nPos++] - = static_cast(reinterpret_cast(et)-_codeBase); + types[nPos++] = static_cast(reinterpret_cast(et) - _codeBase); } // Final check: end of address calculation must be end of mem assert(etMem + etMemOffset == pCode + totalSize); -- cgit