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

More loplugin:cstylecast: pyuno

auto-rewrite with <https://gerrit.libreoffice.org/#/c/47798/> "Enable
loplugin:cstylecast for some more cases" plus
solenv/clang-format/reformat-formatted-files

Change-Id: I11e4fde47c5da601e4ffeada31083c3bdb4286f9
üst fe3924a3
...@@ -126,7 +126,7 @@ static void setPythonHome ( const OUString & pythonHome ) ...@@ -126,7 +126,7 @@ static void setPythonHome ( const OUString & pythonHome )
// static because Py_SetPythonHome just copies the "wide" pointer // static because Py_SetPythonHome just copies the "wide" pointer
static wchar_t wide[PATH_MAX + 1]; static wchar_t wide[PATH_MAX + 1];
size_t len = mbstowcs(wide, o.pData->buffer, PATH_MAX + 1); size_t len = mbstowcs(wide, o.pData->buffer, PATH_MAX + 1);
if(len == (size_t)-1) if(len == size_t(-1))
{ {
PyErr_SetString(PyExc_SystemError, "invalid multibyte sequence in python home path"); PyErr_SetString(PyExc_SystemError, "invalid multibyte sequence in python home path");
return; return;
......
...@@ -263,15 +263,15 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef ...@@ -263,15 +263,15 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
break; break;
case typelib_TypeClass_BYTE: case typelib_TypeClass_BYTE:
buf.append( "0x" ); buf.append( "0x" );
buf.append( (sal_Int32)*static_cast<sal_Int8 const *>(pVal), 16 ); buf.append( static_cast<sal_Int32>(*static_cast<sal_Int8 const *>(pVal)), 16 );
break; break;
case typelib_TypeClass_SHORT: case typelib_TypeClass_SHORT:
buf.append( "0x" ); buf.append( "0x" );
buf.append( (sal_Int32)*static_cast<sal_Int16 const *>(pVal), 16 ); buf.append( static_cast<sal_Int32>(*static_cast<sal_Int16 const *>(pVal)), 16 );
break; break;
case typelib_TypeClass_UNSIGNED_SHORT: case typelib_TypeClass_UNSIGNED_SHORT:
buf.append( "0x" ); buf.append( "0x" );
buf.append( (sal_Int32)*static_cast<sal_uInt16 const *>(pVal), 16 ); buf.append( static_cast<sal_Int32>(*static_cast<sal_uInt16 const *>(pVal)), 16 );
break; break;
case typelib_TypeClass_LONG: case typelib_TypeClass_LONG:
buf.append( "0x" ); buf.append( "0x" );
...@@ -279,7 +279,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef ...@@ -279,7 +279,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
break; break;
case typelib_TypeClass_UNSIGNED_LONG: case typelib_TypeClass_UNSIGNED_LONG:
buf.append( "0x" ); buf.append( "0x" );
buf.append( (sal_Int64)*static_cast<sal_uInt32 const *>(pVal), 16 ); buf.append( static_cast<sal_Int64>(*static_cast<sal_uInt32 const *>(pVal)), 16 );
break; break;
case typelib_TypeClass_HYPER: case typelib_TypeClass_HYPER:
case typelib_TypeClass_UNSIGNED_HYPER: case typelib_TypeClass_UNSIGNED_HYPER:
...@@ -356,10 +356,10 @@ int lcl_PySlice_GetIndicesEx( PyObject *pObject, sal_Int32 nLen, sal_Int32 *nSta ...@@ -356,10 +356,10 @@ int lcl_PySlice_GetIndicesEx( PyObject *pObject, sal_Int32 nLen, sal_Int32 *nSta
return -1; return -1;
} }
*nStart = (sal_Int32)nStart_ssize; *nStart = static_cast<sal_Int32>(nStart_ssize);
*nStop = (sal_Int32)nStop_ssize; *nStop = static_cast<sal_Int32>(nStop_ssize);
*nStep = (sal_Int32)nStep_ssize; *nStep = static_cast<sal_Int32>(nStep_ssize);
*nSliceLength = (sal_Int32)nSliceLength_ssize; *nSliceLength = static_cast<sal_Int32>(nSliceLength_ssize);
return 0; return 0;
} }
...@@ -1013,7 +1013,7 @@ int lcl_setitem_slice( PyUNO const *me, PyObject *pKey, PyObject *pValue ) ...@@ -1013,7 +1013,7 @@ int lcl_setitem_slice( PyUNO const *me, PyObject *pKey, PyObject *pValue )
PyErr_SetString( PyExc_ValueError, "tuple too large" ); PyErr_SetString( PyExc_ValueError, "tuple too large" );
return 1; return 1;
} }
sal_Int32 nTupleLength = (sal_Int32)nTupleLength_ssize; sal_Int32 nTupleLength = static_cast<sal_Int32>(nTupleLength_ssize);
if ( (nTupleLength != nSliceLength) && (nStep != 1) ) if ( (nTupleLength != nSliceLength) && (nStep != 1) )
{ {
......
...@@ -158,7 +158,7 @@ Sequence< sal_Int16 > Adapter::getOutIndexes( const OUString & functionName ) ...@@ -158,7 +158,7 @@ Sequence< sal_Int16 > Adapter::getOutIndexes( const OUString & functionName )
if( seqInfo[i].aMode == css::reflection::ParamMode_OUT || if( seqInfo[i].aMode == css::reflection::ParamMode_OUT ||
seqInfo[i].aMode == css::reflection::ParamMode_INOUT ) seqInfo[i].aMode == css::reflection::ParamMode_INOUT )
{ {
ret[nOutsAssigned] = (sal_Int16) i; ret[nOutsAssigned] = static_cast<sal_Int16>(i);
nOutsAssigned ++; nOutsAssigned ++;
} }
} }
......
...@@ -658,7 +658,7 @@ static PyObject *systemPathToFileUrl( ...@@ -658,7 +658,7 @@ static PyObject *systemPathToFileUrl(
buf.append( "Couldn't convert " ); buf.append( "Couldn't convert " );
buf.append( sysPath ); buf.append( sysPath );
buf.append( " to a file url for reason (" ); buf.append( " to a file url for reason (" );
buf.append( (sal_Int32) e ); buf.append( static_cast<sal_Int32>(e) );
buf.append( ")" ); buf.append( ")" );
raisePyExceptionWithAny( raisePyExceptionWithAny(
makeAny( RuntimeException( buf.makeStringAndClear() ))); makeAny( RuntimeException( buf.makeStringAndClear() )));
...@@ -684,7 +684,7 @@ static PyObject * fileUrlToSystemPath( ...@@ -684,7 +684,7 @@ static PyObject * fileUrlToSystemPath(
buf.append( "Couldn't convert file url " ); buf.append( "Couldn't convert file url " );
buf.append( sysPath ); buf.append( sysPath );
buf.append( " to a system path for reason (" ); buf.append( " to a system path for reason (" );
buf.append( (sal_Int32) e ); buf.append( static_cast<sal_Int32>(e) );
buf.append( ")" ); buf.append( ")" );
raisePyExceptionWithAny( raisePyExceptionWithAny(
makeAny( RuntimeException( buf.makeStringAndClear() ))); makeAny( RuntimeException( buf.makeStringAndClear() )));
...@@ -709,7 +709,7 @@ static PyObject * absolutize( SAL_UNUSED_PARAMETER PyObject *, PyObject * args ) ...@@ -709,7 +709,7 @@ static PyObject * absolutize( SAL_UNUSED_PARAMETER PyObject *, PyObject * args )
buf.append( " using root " ); buf.append( " using root " );
buf.append( ouPath ); buf.append( ouPath );
buf.append( " for reason (" ); buf.append( " for reason (" );
buf.append( (sal_Int32) e ); buf.append( static_cast<sal_Int32>(e) );
buf.append( ")" ); buf.append( ")" );
PyErr_SetString( PyErr_SetString(
......
...@@ -680,21 +680,21 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con ...@@ -680,21 +680,21 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con
else else
{ {
#endif /* PY_MAJOR_VERSION >= 3 */ #endif /* PY_MAJOR_VERSION >= 3 */
sal_Int64 l = (sal_Int64)PyLong_AsLong (o); sal_Int64 l = static_cast<sal_Int64>(PyLong_AsLong (o));
if( l < 128 && l >= -128 ) if( l < 128 && l >= -128 )
{ {
sal_Int8 b = (sal_Int8 ) l; sal_Int8 b = static_cast<sal_Int8>(l);
a <<= b; a <<= b;
} }
else if( l <= 0x7fff && l >= -0x8000 ) else if( l <= 0x7fff && l >= -0x8000 )
{ {
sal_Int16 s = (sal_Int16) l; sal_Int16 s = static_cast<sal_Int16>(l);
a <<= s; a <<= s;
} }
else if( l <= SAL_CONST_INT64(0x7fffffff) && else if( l <= SAL_CONST_INT64(0x7fffffff) &&
l >= -SAL_CONST_INT64(0x80000000) ) l >= -SAL_CONST_INT64(0x80000000) )
{ {
sal_Int32 l32 = (sal_Int32) l; sal_Int32 l32 = static_cast<sal_Int32>(l);
a <<= l32; a <<= l32;
} }
else else
......
...@@ -141,7 +141,7 @@ sal_Unicode PyChar2Unicode( PyObject *obj ) ...@@ -141,7 +141,7 @@ sal_Unicode PyChar2Unicode( PyObject *obj )
"uno.Char contains an empty unicode string"); "uno.Char contains an empty unicode string");
} }
sal_Unicode c = (sal_Unicode)PyUnicode_AsUnicode( value.get() )[0]; sal_Unicode c = static_cast<sal_Unicode>(PyUnicode_AsUnicode( value.get() )[0]);
return c; return c;
} }
......
...@@ -140,7 +140,7 @@ void log( RuntimeCargo * cargo, sal_Int32 level, const char *str ) ...@@ -140,7 +140,7 @@ void log( RuntimeCargo * cargo, sal_Int32 level, const char *str )
localDateTime.NanoSeconds/1000000), localDateTime.NanoSeconds/1000000),
strLevel[level], strLevel[level],
sal::static_int_cast< long >( sal::static_int_cast< long >(
(sal_Int32) osl::Thread::getCurrentIdentifier()), static_cast<sal_Int32>(osl::Thread::getCurrentIdentifier())),
str ); str );
} }
} }
......
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