summaryrefslogtreecommitdiff
path: root/pyuno
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-05-10 09:54:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-05-10 13:16:45 +0200
commit79f4f724b9fed2fce6039049e60baaa19dc61a9e (patch)
tree2307ef5971cb77e3821e0ea94c245b9e876bd4dd /pyuno
parent166f81f38e78d85202c3880e4656759ff0d5fda1 (diff)
loplugin:ostr in pyuno
Change-Id: I54555110b5c66ea92f2675edc50dccd252558e28 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167435 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
Diffstat (limited to 'pyuno')
-rw-r--r--pyuno/source/loader/pyuno_loader.cxx10
-rw-r--r--pyuno/source/module/pyuno.cxx16
-rw-r--r--pyuno/source/module/pyuno_adapter.cxx2
-rw-r--r--pyuno/source/module/pyuno_module.cxx4
-rw-r--r--pyuno/source/module/pyuno_runtime.cxx38
-rw-r--r--pyuno/source/module/pyuno_type.cxx8
6 files changed, 39 insertions, 39 deletions
diff --git a/pyuno/source/loader/pyuno_loader.cxx b/pyuno/source/loader/pyuno_loader.cxx
index 1e00773761e7..3b5f5df7f531 100644
--- a/pyuno/source/loader/pyuno_loader.cxx
+++ b/pyuno/source/loader/pyuno_loader.cxx
@@ -97,7 +97,7 @@ static PyRef getLoaderModule()
raiseRuntimeExceptionWhenNeeded();
if( !module.is() )
{
- throw RuntimeException( "pythonloader: Couldn't load pythonloader module" );
+ throw RuntimeException( u"pythonloader: Couldn't load pythonloader module"_ustr );
}
return PyRef( PyModule_GetDict( module.get() ));
}
@@ -187,7 +187,7 @@ static void prependPythonPath( std::u16string_view pythonPathBootstrap )
bufPYTHONPATH.append( OUString(oldEnv, strlen(oldEnv), osl_getThreadTextEncoding()) );
}
- OUString envVar("PYTHONPATH");
+ OUString envVar(u"PYTHONPATH"_ustr);
OUString envValue(bufPYTHONPATH.makeStringAndClear());
osl_setEnvironment(envVar.pData, envValue.pData);
}
@@ -203,7 +203,7 @@ void pythonInit() {
#endif
OUString pythonPath;
OUString pythonHome;
- OUString path( "$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("pythonloader.uno" ));
+ OUString path( u"$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("pythonloader.uno" ) ""_ustr);
rtl::Bootstrap::expandMacros(path); //TODO: detect failure
rtl::Bootstrap bootstrap(path);
#if PY_VERSION_HEX >= 0x03080000
@@ -211,8 +211,8 @@ void pythonInit() {
#endif
// look for pythonhome
- bootstrap.getFrom( "PYUNO_LOADER_PYTHONHOME", pythonHome );
- bootstrap.getFrom( "PYUNO_LOADER_PYTHONPATH", pythonPath );
+ bootstrap.getFrom( u"PYUNO_LOADER_PYTHONHOME"_ustr, pythonHome );
+ bootstrap.getFrom( u"PYUNO_LOADER_PYTHONPATH"_ustr, pythonPath );
// pythonhome+pythonpath must be set before Py_Initialize(), otherwise there appear warning on the console
// sadly, there is no api for setting the pythonpath, we have to use the environment variable
diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx
index 52e8b003fb18..af35283e6139 100644
--- a/pyuno/source/module/pyuno.cxx
+++ b/pyuno/source/module/pyuno.cxx
@@ -88,7 +88,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
{
assert( pVal );
if (pTypeRef->eTypeClass == typelib_TypeClass_VOID)
- return "void";
+ return u"void"_ustr;
OUStringBuffer buf( 64 );
buf.append( "(" + OUString::unacquired(&pTypeRef->pTypeName) + ")" );
@@ -559,10 +559,10 @@ static void lcl_getRowsColumns( PyUNO const * me, sal_Int32& nRows, sal_Int32& n
Sequence<short> aOutParamIndex;
Sequence<Any> aOutParam;
Sequence<Any> aParams;
- Any aRet = me->members->xInvocation->invoke ( "getRows", aParams, aOutParamIndex, aOutParam );
+ Any aRet = me->members->xInvocation->invoke ( u"getRows"_ustr, aParams, aOutParamIndex, aOutParam );
Reference< XIndexAccess > xIndexAccessRows( aRet, UNO_QUERY );
nRows = xIndexAccessRows->getCount();
- aRet = me->members->xInvocation->invoke ( "getColumns", aParams, aOutParamIndex, aOutParam );
+ aRet = me->members->xInvocation->invoke ( u"getColumns"_ustr, aParams, aOutParamIndex, aOutParam );
Reference< XIndexAccess > xIndexAccessCols( aRet, UNO_QUERY );
nColumns = xIndexAccessCols->getCount();
}
@@ -596,7 +596,7 @@ static PyObject* lcl_getitem_XCellRange( PyUNO const * me, PyObject* pKey )
{
PyThreadDetach antiguard;
aRet = me->members->xInvocation->invoke (
- "getCellRangeByName", aParams, aOutParamIndex, aOutParam );
+ u"getCellRangeByName"_ustr, aParams, aOutParamIndex, aOutParam );
}
PyRef rRet = runtime.any2PyObject ( aRet );
return rRet.getAcquired();
@@ -634,7 +634,7 @@ static PyObject* lcl_getitem_XCellRange( PyUNO const * me, PyObject* pKey )
{
PyThreadDetach antiguard;
aRet = me->members->xInvocation->invoke (
- "getCellByPosition", aParams, aOutParamIndex, aOutParam );
+ u"getCellByPosition"_ustr, aParams, aOutParamIndex, aOutParam );
}
PyRef rRet = runtime.any2PyObject( aRet );
return rRet.getAcquired();
@@ -657,7 +657,7 @@ static PyObject* lcl_getitem_XCellRange( PyUNO const * me, PyObject* pKey )
{
PyThreadDetach antiguard;
- if ( lcl_hasInterfaceByName( me->members->wrappedObject, "com.sun.star.table.XColumnRowRange" ) )
+ if ( lcl_hasInterfaceByName( me->members->wrappedObject, u"com.sun.star.table.XColumnRowRange"_ustr ) )
{
lcl_getRowsColumns (me, nLen0, nLen1);
}
@@ -680,7 +680,7 @@ static PyObject* lcl_getitem_XCellRange( PyUNO const * me, PyObject* pKey )
{
PyThreadDetach antiguard;
aRet = me->members->xInvocation->invoke (
- "getCellRangeByPosition", aParams, aOutParamIndex, aOutParam );
+ u"getCellRangeByPosition"_ustr, aParams, aOutParamIndex, aOutParam );
}
PyRef rRet = runtime.any2PyObject( aRet );
return rRet.getAcquired();
@@ -825,7 +825,7 @@ static PyObject* PyUNO_getitem( PyObject *self, PyObject *pKey )
{
PyThreadDetach antiguard;
- hasXCellRange = lcl_hasInterfaceByName( me->members->wrappedObject, "com.sun.star.table.XCellRange" );
+ hasXCellRange = lcl_hasInterfaceByName( me->members->wrappedObject, u"com.sun.star.table.XCellRange"_ustr );
}
if ( hasXCellRange )
{
diff --git a/pyuno/source/module/pyuno_adapter.cxx b/pyuno/source/module/pyuno_adapter.cxx
index 7ed527dfe3c0..a9502d34abd9 100644
--- a/pyuno/source/module/pyuno_adapter.cxx
+++ b/pyuno/source/module/pyuno_adapter.cxx
@@ -124,7 +124,7 @@ Sequence< sal_Int16 > Adapter::getOutIndexes( const OUString & functionName )
if( !introspection.is() )
{
throw RuntimeException(
- "pyuno bridge: Couldn't inspect uno adapter ( the python class must implement com.sun.star.lang.XTypeProvider !)" );
+ u"pyuno bridge: Couldn't inspect uno adapter ( the python class must implement com.sun.star.lang.XTypeProvider !)"_ustr );
}
Reference< XIdlMethod > method = introspection->getMethod(
diff --git a/pyuno/source/module/pyuno_module.cxx b/pyuno/source/module/pyuno_module.cxx
index fc0e9939506e..2a70e80285fe 100644
--- a/pyuno/source/module/pyuno_module.cxx
+++ b/pyuno/source/module/pyuno_module.cxx
@@ -96,7 +96,7 @@ public:
, nPosConsumed (0)
{
if ( ! used )
- throw RuntimeException("pyuno._createUnoStructHelper failed to create new dictionary");
+ throw RuntimeException(u"pyuno._createUnoStructHelper failed to create new dictionary"_ustr);
}
~fillStructState()
{
@@ -205,7 +205,7 @@ OUString getLibDir()
if (Module::getUrlFromAddress(reinterpret_cast<oslGenericFunction>(getLibDir), libDir))
{
libDir = libDir.copy(0, libDir.lastIndexOf('/'));
- OUString name("PYUNOLIBDIR");
+ OUString name(u"PYUNOLIBDIR"_ustr);
rtl_bootstrap_set(name.pData, libDir.pData);
}
return libDir;
diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx
index 91e971fdd582..471121a8bf6d 100644
--- a/pyuno/source/module/pyuno_runtime.cxx
+++ b/pyuno/source/module/pyuno_runtime.cxx
@@ -155,21 +155,21 @@ static void getRuntimeImpl( PyRef & globalDict, PyRef &runtimeImpl )
PyThreadState * state = PyThreadState_Get();
if( ! state )
{
- throw RuntimeException( "python global interpreter must be held (thread must be attached)" );
+ throw RuntimeException( u"python global interpreter must be held (thread must be attached)"_ustr );
}
PyObject* pModule = PyImport_AddModule("__main__");
if (!pModule)
{
- throw RuntimeException("can't import __main__ module");
+ throw RuntimeException(u"can't import __main__ module"_ustr);
}
globalDict = PyRef( PyModule_GetDict(pModule));
if( ! globalDict.is() ) // FATAL !
{
- throw RuntimeException("can't find __main__ module");
+ throw RuntimeException(u"can't find __main__ module"_ustr);
}
runtimeImpl = PyDict_GetItemString( globalDict.get() , "pyuno_runtime" );
}
@@ -216,7 +216,7 @@ static void readLoggingConfig( sal_Int32 *pLevel, FILE **ppFile )
rtl::Bootstrap bootstrapHandle( fileName );
OUString str;
- if( bootstrapHandle.getFrom( "PYUNO_LOGLEVEL", str ) )
+ if( bootstrapHandle.getFrom( u"PYUNO_LOGLEVEL"_ustr, str ) )
{
if ( str == "NONE" )
*pLevel = LogLevel::NONE;
@@ -234,7 +234,7 @@ static void readLoggingConfig( sal_Int32 *pLevel, FILE **ppFile )
return;
*ppFile = stdout;
- if( !bootstrapHandle.getFrom( "PYUNO_LOGTARGET", str ) )
+ if( !bootstrapHandle.getFrom( u"PYUNO_LOGTARGET"_ustr, str ) )
return;
if ( str == "stdout" )
@@ -277,7 +277,7 @@ PyRef stRuntimeImpl::create( const Reference< XComponentContext > &ctx )
{
RuntimeImpl *me = PyObject_New (RuntimeImpl, &RuntimeImpl_Type);
if( ! me )
- throw RuntimeException( "cannot instantiate pyuno::RuntimeImpl" );
+ throw RuntimeException( u"cannot instantiate pyuno::RuntimeImpl"_ustr );
me->cargo = nullptr;
// must use a different struct here, as the PyObject_New
// makes C++ unusable
@@ -289,13 +289,13 @@ PyRef stRuntimeImpl::create( const Reference< XComponentContext > &ctx )
c->xContext = ctx;
c->xInvocation = Reference< XSingleServiceFactory > (
ctx->getServiceManager()->createInstanceWithContext(
- "com.sun.star.script.Invocation",
+ u"com.sun.star.script.Invocation"_ustr,
ctx ),
css::uno::UNO_QUERY_THROW );
c->xTypeConverter = Converter::create(ctx);
if( ! c->xTypeConverter.is() )
- throw RuntimeException( "pyuno: couldn't instantiate typeconverter service" );
+ throw RuntimeException( u"pyuno: couldn't instantiate typeconverter service"_ustr );
c->xCoreReflection = theCoreReflection::get(ctx);
@@ -303,10 +303,10 @@ PyRef stRuntimeImpl::create( const Reference< XComponentContext > &ctx )
c->xIntrospection = theIntrospection::get(ctx);
- Any a = ctx->getValueByName("/singletons/com.sun.star.reflection.theTypeDescriptionManager");
+ Any a = ctx->getValueByName(u"/singletons/com.sun.star.reflection.theTypeDescriptionManager"_ustr);
a >>= c->xTdMgr;
if( ! c->xTdMgr.is() )
- throw RuntimeException( "pyuno: couldn't retrieve typedescriptionmanager" );
+ throw RuntimeException( u"pyuno: couldn't retrieve typedescriptionmanager"_ustr );
me->cargo =c;
return PyRef( reinterpret_cast< PyObject * > ( me ), SAL_NO_ACQUIRE );
@@ -330,7 +330,7 @@ void Runtime::initialize( const Reference< XComponentContext > & ctx )
if( runtime.is() && impl->cargo->valid )
{
- throw RuntimeException("pyuno runtime has already been initialized before" );
+ throw RuntimeException(u"pyuno runtime has already been initialized before"_ustr );
}
PyRef keep( RuntimeImpl::create( ctx ) );
PyDict_SetItemString( globalDict.get(), "pyuno_runtime" , keep.get() );
@@ -354,8 +354,8 @@ Runtime::Runtime()
if( ! runtime.is() )
{
throw RuntimeException(
- "pyuno runtime is not initialized, "
- "(the pyuno.bootstrap needs to be called before using any uno classes)" );
+ u"pyuno runtime is not initialized, "
+ "(the pyuno.bootstrap needs to be called before using any uno classes)"_ustr );
}
impl = reinterpret_cast< RuntimeImpl * > (runtime.get());
Py_XINCREF( runtime.get() );
@@ -385,7 +385,7 @@ PyRef Runtime::any2PyObject (const Any &a ) const
{
if( ! impl->cargo->valid )
{
- throw RuntimeException("pyuno runtime must be initialized before calling any2PyObject" );
+ throw RuntimeException(u"pyuno runtime must be initialized before calling any2PyObject"_ustr );
}
switch (a.getValueTypeClass ())
@@ -650,7 +650,7 @@ Any Runtime::pyObject2Any(const PyRef & source, enum ConversionMode mode) const
{
if (!impl || !impl->cargo->valid)
{
- throw RuntimeException("pyuno runtime must be initialized before calling any2PyObject" );
+ throw RuntimeException(u"pyuno runtime must be initialized before calling any2PyObject"_ustr );
}
Any a;
@@ -758,7 +758,7 @@ Any Runtime::pyObject2Any(const PyRef & source, enum ConversionMode mode) const
if( !holder.is( ) )
{
throw RuntimeException(
- "struct or exception wrapper does not support XMaterialHolder" );
+ u"struct or exception wrapper does not support XMaterialHolder"_ustr );
}
a = holder->getMaterial();
@@ -784,8 +784,8 @@ Any Runtime::pyObject2Any(const PyRef & source, enum ConversionMode mode) const
if( ACCEPT_UNO_ANY != mode )
{
throw RuntimeException(
- "uno.Any instance not accepted during method call, "
- "use uno.invoke instead" );
+ u"uno.Any instance not accepted during method call, "
+ "use uno.invoke instead"_ustr );
}
a = pyObject2Any( PyRef( PyObject_GetAttrString( o , "value" ), SAL_NO_ACQUIRE) );
@@ -967,7 +967,7 @@ PyThreadAttach::PyThreadAttach( PyInterpreterState *interp)
tstate = PyThreadState_New( interp );
}
if( !tstate )
- throw RuntimeException( "Couldn't create a pythreadstate" );
+ throw RuntimeException( u"Couldn't create a pythreadstate"_ustr );
PyEval_AcquireThread( tstate);
}
diff --git a/pyuno/source/module/pyuno_type.cxx b/pyuno/source/module/pyuno_type.cxx
index a04b4e26d78c..ee44b466e519 100644
--- a/pyuno/source/module/pyuno_type.cxx
+++ b/pyuno/source/module/pyuno_type.cxx
@@ -129,13 +129,13 @@ sal_Unicode PyChar2Unicode( PyObject *obj )
if( ! PyUnicode_Check( value.get() ) )
{
throw RuntimeException(
- "attribute value of uno.Char is not a unicode string" );
+ u"attribute value of uno.Char is not a unicode string"_ustr );
}
if( PyUnicode_GetLength( value.get() ) < 1 )
{
throw RuntimeException(
- "uno.Char contains an empty unicode string");
+ u"uno.Char contains an empty unicode string"_ustr);
}
sal_Unicode c = static_cast<sal_Unicode>(PyUnicode_ReadChar( value.get(), 0));
@@ -150,7 +150,7 @@ Any PyEnum2Enum( PyObject *obj )
if( !PyUnicode_Check( typeName.get() ) || ! PyUnicode_Check( value.get() ) )
{
throw RuntimeException(
- "attributes typeName and/or value of uno.Enum are not strings" );
+ u"attributes typeName and/or value of uno.Enum are not strings"_ustr );
}
OUString strTypeName( OUString::createFromAscii( PyUnicode_AsUTF8( typeName.get() ) ) );
@@ -198,7 +198,7 @@ Type PyType2Type( PyObject * o )
if( !PyUnicode_Check( pyName.get() ) )
{
throw RuntimeException(
- "type object does not have typeName property" );
+ u"type object does not have typeName property"_ustr );
}
PyRef pyTC( PyObject_GetAttrString( o, "typeClass" ), SAL_NO_ACQUIRE );