summaryrefslogtreecommitdiff
path: root/pyuno/source/module
diff options
context:
space:
mode:
Diffstat (limited to 'pyuno/source/module')
-rw-r--r--pyuno/source/module/pyuno.cxx42
-rw-r--r--pyuno/source/module/pyuno_except.cxx10
-rw-r--r--pyuno/source/module/pyuno_module.cxx110
-rw-r--r--pyuno/source/module/pyuno_struct.cxx4
-rw-r--r--pyuno/source/module/pyuno_type.cxx4
-rw-r--r--pyuno/source/module/pyuno_util.cxx12
6 files changed, 74 insertions, 108 deletions
diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx
index d9c9dacbb3fd..d554f5ca769c 100644
--- a/pyuno/source/module/pyuno.cxx
+++ b/pyuno/source/module/pyuno.cxx
@@ -93,16 +93,14 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
return "void";
OUStringBuffer buf( 64 );
- buf.append( '(' );
- buf.append( pTypeRef->pTypeName );
- buf.append( ')' );
+ buf.append( "(" + OUString::unacquired(&pTypeRef->pTypeName) + ")" );
switch (pTypeRef->eTypeClass)
{
case typelib_TypeClass_INTERFACE:
{
- buf.append( "0x" );
- buf.append( reinterpret_cast< sal_IntPtr >(*static_cast<void * const *>(pVal)), 16 );
+ buf.append( "0x" +
+ OUString::number( reinterpret_cast< sal_IntPtr >(*static_cast<void * const *>(pVal)), 16 ));
if( VAL2STR_MODE_DEEP == mode )
{
buf.append( "{" ); Reference< XInterface > r = *static_cast<Reference< XInterface > const *>(pVal);
@@ -164,8 +162,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
for ( sal_Int32 nPos = 0; nPos < nDescr; ++nPos )
{
- buf.append( ppMemberNames[nPos] );
- buf.append( " = " );
+ buf.append( OUString::unacquired(&ppMemberNames[nPos]) + " = " );
typelib_TypeDescription * pMemberType = nullptr;
TYPELIB_DANGER_GET( &pMemberType, ppTypeRefs[nPos] );
buf.append( val2str( static_cast<char const *>(pVal) + pMemberOffsets[nPos], pMemberType->pWeakRef, mode ) );
@@ -222,9 +219,9 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
buf.append( (*static_cast<typelib_TypeDescriptionReference * const *>(pVal))->pTypeName );
break;
case typelib_TypeClass_STRING:
- buf.append( '\"' );
- buf.append( *static_cast<rtl_uString * const *>(pVal) );
- buf.append( '\"' );
+ buf.append( "\"" +
+ OUString::unacquired(&*static_cast<rtl_uString * const *>(pVal)) +
+ "\"" );
break;
case typelib_TypeClass_ENUM:
{
@@ -264,24 +261,24 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
buf.append( *static_cast<double const *>(pVal) );
break;
case typelib_TypeClass_BYTE:
- buf.append( "0x" );
- buf.append( static_cast<sal_Int32>(*static_cast<sal_Int8 const *>(pVal)), 16 );
+ buf.append( "0x" +
+ OUString::number( static_cast<sal_Int32>(*static_cast<sal_Int8 const *>(pVal)), 16 ));
break;
case typelib_TypeClass_SHORT:
- buf.append( "0x" );
- buf.append( static_cast<sal_Int32>(*static_cast<sal_Int16 const *>(pVal)), 16 );
+ buf.append( "0x" +
+ OUString::number( static_cast<sal_Int32>(*static_cast<sal_Int16 const *>(pVal)), 16 ));
break;
case typelib_TypeClass_UNSIGNED_SHORT:
- buf.append( "0x" );
- buf.append( static_cast<sal_Int32>(*static_cast<sal_uInt16 const *>(pVal)), 16 );
+ buf.append( "0x" +
+ OUString::number( static_cast<sal_Int32>(*static_cast<sal_uInt16 const *>(pVal)), 16 ));
break;
case typelib_TypeClass_LONG:
- buf.append( "0x" );
- buf.append( *static_cast<sal_Int32 const *>(pVal), 16 );
+ buf.append( "0x" +
+ OUString::number( *static_cast<sal_Int32 const *>(pVal), 16 ));
break;
case typelib_TypeClass_UNSIGNED_LONG:
- buf.append( "0x" );
- buf.append( static_cast<sal_Int64>(*static_cast<sal_uInt32 const *>(pVal)), 16 );
+ buf.append( "0x" +
+ OUString::number( static_cast<sal_Int64>(*static_cast<sal_uInt32 const *>(pVal)), 16 ));
break;
case typelib_TypeClass_HYPER:
case typelib_TypeClass_UNSIGNED_HYPER:
@@ -464,15 +461,14 @@ PyObject *PyUNO_str( PyObject * self )
{
PyUNO *me = reinterpret_cast<PyUNO *>(self);
- OStringBuffer buf;
+ OString buf;
{
PyThreadDetach antiguard;
- buf.append( "pyuno object " );
OUString s = val2str( me->members->wrappedObject.getValue(),
me->members->wrappedObject.getValueType().getTypeLibType() );
- buf.append( OUStringToOString(s,RTL_TEXTENCODING_ASCII_US) );
+ buf = "pyuno object " + OUStringToOString(s,RTL_TEXTENCODING_ASCII_US);
}
return PyStr_FromString( buf.getStr() );
diff --git a/pyuno/source/module/pyuno_except.cxx b/pyuno/source/module/pyuno_except.cxx
index 8b712400adf3..7cd879f0e81e 100644
--- a/pyuno/source/module/pyuno_except.cxx
+++ b/pyuno/source/module/pyuno_except.cxx
@@ -47,15 +47,11 @@ void raisePyExceptionWithAny( const css::uno::Any &anyExc )
css::uno::Exception e;
anyExc >>= e;
- OUStringBuffer buf;
- buf.append( "Couldn't convert uno exception to a python exception (" );
- buf.append(anyExc.getValueType().getTypeName());
- buf.append( ": " );
- buf.append(e.Message );
- buf.append( ")" );
+ OUString buf = "Couldn't convert uno exception to a python exception (" +
+ anyExc.getValueType().getTypeName() + ": " + e.Message + ")";
PyErr_SetString(
PyExc_SystemError,
- OUStringToOString(buf.makeStringAndClear(),RTL_TEXTENCODING_ASCII_US).getStr() );
+ OUStringToOString(buf,RTL_TEXTENCODING_ASCII_US).getStr() );
}
}
catch(const css::lang::IllegalArgumentException & e)
diff --git a/pyuno/source/module/pyuno_module.cxx b/pyuno/source/module/pyuno_module.cxx
index 715d5c6dbb27..184e7e4b6f9d 100644
--- a/pyuno/source/module/pyuno_module.cxx
+++ b/pyuno/source/module/pyuno_module.cxx
@@ -113,13 +113,10 @@ public:
if (initialised[key])
{
OUStringBuffer buf;
- buf.append( "pyuno._createUnoStructHelper: member '");
- buf.append(key);
- buf.append( "'");
+ buf.append( "pyuno._createUnoStructHelper: member '" + key + "'");
if ( pos >= 0 )
{
- buf.append( " at position ");
- buf.append(pos);
+ buf.append( " at position " + OUString::number(pos));
}
buf.append( " initialised multiple times.");
throw RuntimeException(buf.makeStringAndClear());
@@ -191,13 +188,12 @@ void fillStruct(
const OUString memberName (pCompType->ppMemberNames[i]);
if ( ! state.isInitialised( memberName ) )
{
- OUStringBuffer buf;
- buf.append( "pyuno._createUnoStructHelper: member '");
- buf.append(memberName);
- buf.append( "' of struct type '");
- buf.append(pCompType->aBase.pTypeName);
- buf.append( "' not given a value.");
- throw RuntimeException(buf.makeStringAndClear());
+ OUString buf = "pyuno._createUnoStructHelper: member '" +
+ memberName +
+ "' of struct type '" +
+ OUString::unacquired(&pCompType->aBase.pTypeName) +
+ "' not given a value.";
+ throw RuntimeException(buf);
}
}
}
@@ -223,12 +219,11 @@ OUString getLibDir()
void raisePySystemException( const char * exceptionType, const OUString & message )
{
- OStringBuffer buf;
- buf.append( "Error during bootstrapping uno (");
- buf.append( exceptionType );
- buf.append( "):" );
- buf.append( OUStringToOString( message, osl_getThreadTextEncoding() ) );
- PyErr_SetString( PyExc_SystemError, buf.makeStringAndClear().getStr() );
+ OString buf = OStringLiteral("Error during bootstrapping uno (") +
+ exceptionType +
+ "):" +
+ OUStringToOString( message, osl_getThreadTextEncoding() );
+ PyErr_SetString( PyExc_SystemError, buf.getStr() );
}
extern "C" {
@@ -250,7 +245,6 @@ static PyObject* getComponentContext(
}
else
{
- OUString iniFile;
if( path.isEmpty() )
{
PyErr_SetString(
@@ -259,14 +253,11 @@ static PyObject* getComponentContext(
return nullptr;
}
- OUStringBuffer iniFileName;
- iniFileName.append( path );
+ OUString iniFile = path +
#ifdef MACOSX
- iniFileName.append( "/../" LIBO_ETC_FOLDER );
+ "/../" LIBO_ETC_FOLDER
#endif
- iniFileName.append( "/" );
- iniFileName.append( SAL_CONFIGFILE( "pyuno" ) );
- iniFile = iniFileName.makeStringAndClear();
+ "/" SAL_CONFIGFILE( "pyuno" );
osl::DirectoryItem item;
if( osl::DirectoryItem::get( iniFile, item ) == osl::FileBase::E_None )
{
@@ -395,16 +386,14 @@ PyObject * extractOneStringArg( PyObject *args, char const *funcName )
{
if( !PyTuple_Check( args ) || PyTuple_Size( args) != 1 )
{
- OStringBuffer buf;
- buf.append( funcName ).append( ": expecting one string argument" );
+ OString buf = funcName + OStringLiteral(": expecting one string argument");
PyErr_SetString( PyExc_RuntimeError, buf.getStr() );
return nullptr;
}
PyObject *obj = PyTuple_GetItem( args, 0 );
if (!PyStr_Check(obj) && !PyUnicode_Check(obj))
{
- OStringBuffer buf;
- buf.append( funcName ).append( ": expecting one string argument" );
+ OString buf = funcName + OStringLiteral(": expecting one string argument");
PyErr_SetString( PyExc_TypeError, buf.getStr());
return nullptr;
}
@@ -515,8 +504,7 @@ static PyObject *getTypeByName(
}
else
{
- OStringBuffer buf;
- buf.append( "Type " ).append(name).append( " is unknown" );
+ OString buf = OStringLiteral("Type ") + name + " is unknown";
PyErr_SetString( PyExc_RuntimeError, buf.getStr() );
}
}
@@ -577,8 +565,7 @@ static PyObject *checkType( SAL_UNUSED_PARAMETER PyObject *, PyObject *args )
{
if( !PyTuple_Check( args ) || PyTuple_Size( args) != 1 )
{
- OStringBuffer buf;
- buf.append( "pyuno.checkType : expecting one uno.Type argument" );
+ OString buf = "pyuno.checkType : expecting one uno.Type argument";
PyErr_SetString( PyExc_RuntimeError, buf.getStr() );
return nullptr;
}
@@ -601,8 +588,7 @@ static PyObject *checkEnum( SAL_UNUSED_PARAMETER PyObject *, PyObject *args )
{
if( !PyTuple_Check( args ) || PyTuple_Size( args) != 1 )
{
- OStringBuffer buf;
- buf.append( "pyuno.checkType : expecting one uno.Type argument" );
+ OString buf = "pyuno.checkType : expecting one uno.Type argument";
PyErr_SetString( PyExc_RuntimeError, buf.getStr() );
return nullptr;
}
@@ -684,14 +670,13 @@ static PyObject *systemPathToFileUrl(
if( e != osl::FileBase::E_None )
{
- OUStringBuffer buf;
- buf.append( "Couldn't convert " );
- buf.append( sysPath );
- buf.append( " to a file url for reason (" );
- buf.append( static_cast<sal_Int32>(e) );
- buf.append( ")" );
+ OUString buf = "Couldn't convert " +
+ sysPath +
+ " to a file url for reason (" +
+ OUString::number( static_cast<sal_Int32>(e) ) +
+ ")";
raisePyExceptionWithAny(
- makeAny( RuntimeException( buf.makeStringAndClear() )));
+ makeAny( RuntimeException( buf )));
return nullptr;
}
return ustring2PyUnicode( url ).getAcquired();
@@ -710,14 +695,13 @@ static PyObject * fileUrlToSystemPath(
if( e != osl::FileBase::E_None )
{
- OUStringBuffer buf;
- buf.append( "Couldn't convert file url " );
- buf.append( sysPath );
- buf.append( " to a system path for reason (" );
- buf.append( static_cast<sal_Int32>(e) );
- buf.append( ")" );
+ OUString buf = "Couldn't convert file url " +
+ sysPath +
+ " to a system path for reason (" +
+ OUString::number( static_cast<sal_Int32>(e) ) +
+ ")";
raisePyExceptionWithAny(
- makeAny( RuntimeException( buf.makeStringAndClear() )));
+ makeAny( RuntimeException( buf )));
return nullptr;
}
return ustring2PyUnicode( sysPath ).getAcquired();
@@ -733,18 +717,18 @@ static PyObject * absolutize( SAL_UNUSED_PARAMETER PyObject *, PyObject * args )
oslFileError e = osl_getAbsoluteFileURL( ouPath.pData, ouRel.pData, &(ret.pData) );
if( e != osl_File_E_None )
{
- OUStringBuffer buf;
- buf.append( "Couldn't absolutize " );
- buf.append( ouRel );
- buf.append( " using root " );
- buf.append( ouPath );
- buf.append( " for reason (" );
- buf.append( static_cast<sal_Int32>(e) );
- buf.append( ")" );
+ OUString buf =
+ "Couldn't absolutize " +
+ ouRel +
+ " using root " +
+ ouPath +
+ " for reason (" +
+ OUString::number(static_cast<sal_Int32>(e) ) +
+ ")";
PyErr_SetString(
PyExc_OSError,
- OUStringToOString(buf.makeStringAndClear(),osl_getThreadTextEncoding()).getStr());
+ OUStringToOString(buf,osl_getThreadTextEncoding()).getStr());
return nullptr;
}
return ustring2PyUnicode( ret ).getAcquired();
@@ -787,9 +771,8 @@ static PyObject * invoke(SAL_UNUSED_PARAMETER PyObject *, PyObject *args)
}
else
{
- OStringBuffer buf;
- buf.append("uno.invoke expects object, name, (arg1, arg2, ... )\n");
- PyErr_SetString(PyExc_RuntimeError, buf.makeStringAndClear().getStr());
+ OString buf = "uno.invoke expects object, name, (arg1, arg2, ... )\n";
+ PyErr_SetString(PyExc_RuntimeError, buf.getStr());
}
return ret;
}
@@ -841,10 +824,9 @@ static PyObject *setCurrentContext(
}
else
{
- OStringBuffer buf;
- buf.append( "uno.setCurrentContext expects exactly one argument (the current Context)\n" );
+ OString buf = "uno.setCurrentContext expects exactly one argument (the current Context)\n";
PyErr_SetString(
- PyExc_RuntimeError, buf.makeStringAndClear().getStr() );
+ PyExc_RuntimeError, buf.getStr() );
}
}
catch( const css::uno::Exception & e )
diff --git a/pyuno/source/module/pyuno_struct.cxx b/pyuno/source/module/pyuno_struct.cxx
index 64dc11499f6b..50b74126bee9 100644
--- a/pyuno/source/module/pyuno_struct.cxx
+++ b/pyuno/source/module/pyuno_struct.cxx
@@ -57,7 +57,7 @@ static void PyUNOStruct_del( PyObject* self )
static PyObject *PyUNOStruct_str( PyObject *self )
{
PyUNO *me = reinterpret_cast<PyUNO*>( self );
- OStringBuffer buf;
+ OString buf;
Reference<XMaterialHolder> rHolder( me->members->xInvocation,UNO_QUERY );
if( rHolder.is() )
@@ -65,7 +65,7 @@ static PyObject *PyUNOStruct_str( PyObject *self )
PyThreadDetach antiguard;
Any a = rHolder->getMaterial();
OUString s = val2str( a.getValue(), a.getValueType().getTypeLibType() );
- buf.append( OUStringToOString( s, RTL_TEXTENCODING_ASCII_US ) );
+ buf = OUStringToOString( s, RTL_TEXTENCODING_ASCII_US );
}
return PyStr_FromString( buf.getStr());
diff --git a/pyuno/source/module/pyuno_type.cxx b/pyuno/source/module/pyuno_type.cxx
index 8cc41e8c0de1..de4a212e22bb 100644
--- a/pyuno/source/module/pyuno_type.cxx
+++ b/pyuno/source/module/pyuno_type.cxx
@@ -232,9 +232,7 @@ static PyObject* callCtor( const Runtime &r , const char * clazz, const PyRef &
PyRef code( PyDict_GetItemString( r.getImpl()->cargo->getUnoModule().get(), clazz ) );
if( ! code.is() )
{
- OStringBuffer buf;
- buf.append( "couldn't access uno." );
- buf.append( clazz );
+ OString buf = OStringLiteral("couldn't access uno.") + clazz;
PyErr_SetString( PyExc_RuntimeError, buf.getStr() );
return nullptr;
}
diff --git a/pyuno/source/module/pyuno_util.cxx b/pyuno/source/module/pyuno_util.cxx
index 3765dc7df356..f75533d47fdb 100644
--- a/pyuno/source/module/pyuno_util.cxx
+++ b/pyuno/source/module/pyuno_util.cxx
@@ -161,9 +161,7 @@ void logException( RuntimeCargo *cargo, const char *intro,
OUStringBuffer buf( 128 );
buf.appendAscii( intro );
appendPointer(buf, ptr);
- buf.append( "]." );
- buf.append( aFunctionName );
- buf.append( " = " );
+ buf.append( "]." + aFunctionName + " = " );
buf.append(
val2str( data, type.getTypeLibType(), VAL2STR_MODE_SHALLOW ) );
log( cargo,LogLevel::CALL, buf.makeStringAndClear() );
@@ -182,9 +180,7 @@ void logReply(
OUStringBuffer buf( 128 );
buf.appendAscii( intro );
appendPointer(buf, ptr);
- buf.append( "]." );
- buf.append( aFunctionName );
- buf.append( "()=" );
+ buf.append( "]." + aFunctionName + "()=" );
if( isLog( cargo, LogLevel::ARGS ) )
{
buf.append(
@@ -207,9 +203,7 @@ void logCall( RuntimeCargo *cargo, const char *intro,
OUStringBuffer buf( 128 );
buf.appendAscii( intro );
appendPointer(buf, ptr);
- buf.append( "]." );
- buf.append( aFunctionName );
- buf.append( "(" );
+ buf.append( "]." + aFunctionName + "(" );
if( isLog( cargo, LogLevel::ARGS ) )
{
for( int i = 0; i < aParams.getLength() ; i ++ )