Remove RTL_CONSTASCII_(U)STRINGPARAM in pyuno

and use append() instead of appendAscii()

Change-Id: Iaf29a2f18eff39db5d1b5cc298cce23442ac51a9
This commit is contained in:
Chr. Rossmanith
2013-03-28 21:22:54 +01:00
parent ac9c70b157
commit 8333cbf2a3
4 changed files with 48 additions and 50 deletions

View File

@@ -184,7 +184,7 @@ Reference< XInterface > CreateInstance( const Reference< XComponentContext > & c
{ {
OUString pythonPath; OUString pythonPath;
OUString pythonHome; OUString pythonHome;
OUString path( RTL_CONSTASCII_USTRINGPARAM( "$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("pythonloader.uno" ))); OUString path( "$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("pythonloader.uno" ));
rtl::Bootstrap::expandMacros(path); //TODO: detect failure rtl::Bootstrap::expandMacros(path); //TODO: detect failure
rtl::Bootstrap bootstrap(path); rtl::Bootstrap bootstrap(path);

View File

@@ -83,41 +83,41 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
{ {
case typelib_TypeClass_INTERFACE: case typelib_TypeClass_INTERFACE:
{ {
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); buf.append( "0x" );
buf.append( reinterpret_cast< sal_IntPtr >(*(void **)pVal), 16 ); buf.append( reinterpret_cast< sal_IntPtr >(*(void **)pVal), 16 );
if( VAL2STR_MODE_DEEP == mode ) if( VAL2STR_MODE_DEEP == mode )
{ {
buf.appendAscii( "{" ); Reference< XInterface > r = *( Reference< XInterface > * ) pVal; buf.append( "{" ); Reference< XInterface > r = *( Reference< XInterface > * ) pVal;
Reference< XServiceInfo > serviceInfo( r, UNO_QUERY); Reference< XServiceInfo > serviceInfo( r, UNO_QUERY);
Reference< XTypeProvider > typeProvider(r,UNO_QUERY); Reference< XTypeProvider > typeProvider(r,UNO_QUERY);
if( serviceInfo.is() ) if( serviceInfo.is() )
{ {
buf.appendAscii("implementationName=" ); buf.append("implementationName=" );
buf.append(serviceInfo->getImplementationName() ); buf.append(serviceInfo->getImplementationName() );
buf.appendAscii(", supportedServices={" ); buf.append(", supportedServices={" );
Sequence< OUString > seq = serviceInfo->getSupportedServiceNames(); Sequence< OUString > seq = serviceInfo->getSupportedServiceNames();
for( int i = 0 ; i < seq.getLength() ; i ++ ) for( int i = 0 ; i < seq.getLength() ; i ++ )
{ {
buf.append( seq[i] ); buf.append( seq[i] );
if( i +1 != seq.getLength() ) if( i +1 != seq.getLength() )
buf.appendAscii( "," ); buf.append( "," );
} }
buf.appendAscii("}"); buf.append("}");
} }
if( typeProvider.is() ) if( typeProvider.is() )
{ {
buf.appendAscii(", supportedInterfaces={" ); buf.append(", supportedInterfaces={" );
Sequence< Type > seq (typeProvider->getTypes()); Sequence< Type > seq (typeProvider->getTypes());
for( int i = 0 ; i < seq.getLength() ; i ++ ) for( int i = 0 ; i < seq.getLength() ; i ++ )
{ {
buf.append(seq[i].getTypeName()); buf.append(seq[i].getTypeName());
if( i +1 != seq.getLength() ) if( i +1 != seq.getLength() )
buf.appendAscii( "," ); buf.append( "," );
} }
buf.appendAscii("}"); buf.append("}");
} }
buf.appendAscii( "}" ); buf.append( "}" );
} }
break; break;
@@ -129,7 +129,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
case typelib_TypeClass_STRUCT: case typelib_TypeClass_STRUCT:
case typelib_TypeClass_EXCEPTION: case typelib_TypeClass_EXCEPTION:
{ {
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("{ ") ); buf.append( "{ " );
typelib_TypeDescription * pTypeDescr = 0; typelib_TypeDescription * pTypeDescr = 0;
TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
OSL_ASSERT( pTypeDescr ); OSL_ASSERT( pTypeDescr );
@@ -141,7 +141,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
{ {
buf.append( val2str( pVal, ((typelib_TypeDescription *)pCompType->pBaseTypeDescription)->pWeakRef,mode ) ); buf.append( val2str( pVal, ((typelib_TypeDescription *)pCompType->pBaseTypeDescription)->pWeakRef,mode ) );
if (nDescr) if (nDescr)
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", ") ); buf.append( ", " );
} }
typelib_TypeDescriptionReference ** ppTypeRefs = pCompType->ppTypeRefs; typelib_TypeDescriptionReference ** ppTypeRefs = pCompType->ppTypeRefs;
@@ -151,18 +151,18 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
for ( sal_Int32 nPos = 0; nPos < nDescr; ++nPos ) for ( sal_Int32 nPos = 0; nPos < nDescr; ++nPos )
{ {
buf.append( ppMemberNames[nPos] ); buf.append( ppMemberNames[nPos] );
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" = ") ); buf.append( " = " );
typelib_TypeDescription * pMemberType = 0; typelib_TypeDescription * pMemberType = 0;
TYPELIB_DANGER_GET( &pMemberType, ppTypeRefs[nPos] ); TYPELIB_DANGER_GET( &pMemberType, ppTypeRefs[nPos] );
buf.append( val2str( (char *)pVal + pMemberOffsets[nPos], pMemberType->pWeakRef, mode ) ); buf.append( val2str( (char *)pVal + pMemberOffsets[nPos], pMemberType->pWeakRef, mode ) );
TYPELIB_DANGER_RELEASE( pMemberType ); TYPELIB_DANGER_RELEASE( pMemberType );
if (nPos < (nDescr -1)) if (nPos < (nDescr -1))
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", ") ); buf.append( ", " );
} }
TYPELIB_DANGER_RELEASE( pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr );
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" }") ); buf.append( " }" );
break; break;
} }
case typelib_TypeClass_SEQUENCE: case typelib_TypeClass_SEQUENCE:
@@ -179,30 +179,30 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
if (nElements) if (nElements)
{ {
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("{ ") ); buf.append( "{ " );
char * pElements = pSequence->elements; char * pElements = pSequence->elements;
for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos )
{ {
buf.append( val2str( pElements + (nElementSize * nPos), pElementTypeDescr->pWeakRef, mode ) ); buf.append( val2str( pElements + (nElementSize * nPos), pElementTypeDescr->pWeakRef, mode ) );
if (nPos < (nElements -1)) if (nPos < (nElements -1))
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", ") ); buf.append( ", " );
} }
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" }") ); buf.append( " }" );
} }
else else
{ {
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("{}") ); buf.append( "{}" );
} }
TYPELIB_DANGER_RELEASE( pElementTypeDescr ); TYPELIB_DANGER_RELEASE( pElementTypeDescr );
TYPELIB_DANGER_RELEASE( pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr );
break; break;
} }
case typelib_TypeClass_ANY: case typelib_TypeClass_ANY:
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("{ ") ); buf.append( "{ " );
buf.append( val2str( ((uno_Any *)pVal)->pData, buf.append( val2str( ((uno_Any *)pVal)->pData,
((uno_Any *)pVal)->pType , ((uno_Any *)pVal)->pType ,
mode) ); mode) );
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" }") ); buf.append( " }" );
break; break;
case typelib_TypeClass_TYPE: case typelib_TypeClass_TYPE:
buf.append( (*(typelib_TypeDescriptionReference **)pVal)->pTypeName ); buf.append( (*(typelib_TypeDescriptionReference **)pVal)->pTypeName );
@@ -234,9 +234,9 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
} }
case typelib_TypeClass_BOOLEAN: case typelib_TypeClass_BOOLEAN:
if (*(sal_Bool *)pVal) if (*(sal_Bool *)pVal)
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("true") ); buf.append( "true" );
else else
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("false") ); buf.append( "false" );
break; break;
case typelib_TypeClass_CHAR: case typelib_TypeClass_CHAR:
buf.append( (sal_Unicode)'\'' ); buf.append( (sal_Unicode)'\'' );
@@ -250,28 +250,28 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
buf.append( *(double *)pVal ); buf.append( *(double *)pVal );
break; break;
case typelib_TypeClass_BYTE: case typelib_TypeClass_BYTE:
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); buf.append( "0x" );
buf.append( (sal_Int32)*(sal_Int8 *)pVal, 16 ); buf.append( (sal_Int32)*(sal_Int8 *)pVal, 16 );
break; break;
case typelib_TypeClass_SHORT: case typelib_TypeClass_SHORT:
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); buf.append( "0x" );
buf.append( (sal_Int32)*(sal_Int16 *)pVal, 16 ); buf.append( (sal_Int32)*(sal_Int16 *)pVal, 16 );
break; break;
case typelib_TypeClass_UNSIGNED_SHORT: case typelib_TypeClass_UNSIGNED_SHORT:
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); buf.append( "0x" );
buf.append( (sal_Int32)*(sal_uInt16 *)pVal, 16 ); buf.append( (sal_Int32)*(sal_uInt16 *)pVal, 16 );
break; break;
case typelib_TypeClass_LONG: case typelib_TypeClass_LONG:
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); buf.append( "0x" );
buf.append( *(sal_Int32 *)pVal, 16 ); buf.append( *(sal_Int32 *)pVal, 16 );
break; break;
case typelib_TypeClass_UNSIGNED_LONG: case typelib_TypeClass_UNSIGNED_LONG:
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); buf.append( "0x" );
buf.append( (sal_Int64)*(sal_uInt32 *)pVal, 16 ); buf.append( (sal_Int64)*(sal_uInt32 *)pVal, 16 );
break; break;
case typelib_TypeClass_HYPER: case typelib_TypeClass_HYPER:
case typelib_TypeClass_UNSIGNED_HYPER: case typelib_TypeClass_UNSIGNED_HYPER:
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); buf.append( "0x" );
#if defined(__GNUC__) && defined(SPARC) #if defined(__GNUC__) && defined(SPARC)
// I guess this really should check if there are strict alignment // I guess this really should check if there are strict alignment
// requirements, not just "GCC on SPARC". // requirements, not just "GCC on SPARC".
@@ -338,9 +338,9 @@ PyObject *PyUNO_invoke( PyObject *object, const char *name , PyObject *args )
if (! me->members->xInvocation->hasMethod (attrName)) if (! me->members->xInvocation->hasMethod (attrName))
{ {
OUStringBuffer buf; OUStringBuffer buf;
buf.appendAscii( "Attribute " ); buf.append( "Attribute " );
buf.append( attrName ); buf.append( attrName );
buf.appendAscii( " unknown" ); buf.append( " unknown" );
throw RuntimeException( buf.makeStringAndClear(), Reference< XInterface > () ); throw RuntimeException( buf.makeStringAndClear(), Reference< XInterface > () );
} }
callable = PyUNO_callable_new ( callable = PyUNO_callable_new (

View File

@@ -128,7 +128,7 @@ Sequence< sal_Int16 > Adapter::getOutIndexes( const OUString & functionName )
if( !introspection.is() ) if( !introspection.is() )
{ {
throw RuntimeException( throw RuntimeException(
OUString( RTL_CONSTASCII_USTRINGPARAM( "pyuno bridge: Couldn't inspect uno adapter ( the python class must implement com.sun.star.lang.XTypeProvider !)" ) ), OUString( "pyuno bridge: Couldn't inspect uno adapter ( the python class must implement com.sun.star.lang.XTypeProvider !)" ),
Reference< XInterface > () ); Reference< XInterface > () );
} }
@@ -270,10 +270,8 @@ Any Adapter::invoke( const OUString &aFunctionName,
if( ! ( ret >>= seq ) ) if( ! ( ret >>= seq ) )
{ {
throw RuntimeException( throw RuntimeException(
(OUString( (OUString("pyuno bridge: Couldn't extract out"
RTL_CONSTASCII_USTRINGPARAM( " parameters for method ")
"pyuno bridge: Couldn't extract out"
" parameters for method "))
+ aFunctionName), + aFunctionName),
Reference< XInterface > () ); Reference< XInterface > () );
} }
@@ -281,13 +279,13 @@ Any Adapter::invoke( const OUString &aFunctionName,
if( aOutParamIndex.getLength() +1 != seq.getLength() ) if( aOutParamIndex.getLength() +1 != seq.getLength() )
{ {
OUStringBuffer buf; OUStringBuffer buf;
buf.appendAscii( "pyuno bridge: expected for method " ); buf.append( "pyuno bridge: expected for method " );
buf.append( aFunctionName ); buf.append( aFunctionName );
buf.appendAscii( " one return value and " ); buf.append( " one return value and " );
buf.append( (sal_Int32) aOutParamIndex.getLength() ); buf.append( (sal_Int32) aOutParamIndex.getLength() );
buf.appendAscii( " out parameters, got a sequence of " ); buf.append( " out parameters, got a sequence of " );
buf.append( seq.getLength() ); buf.append( seq.getLength() );
buf.appendAscii( " elements as return value." ); buf.append( " elements as return value." );
throw RuntimeException(buf.makeStringAndClear(), *this ); throw RuntimeException(buf.makeStringAndClear(), *this );
} }

View File

@@ -183,9 +183,9 @@ void logException( RuntimeCargo *cargo, const char *intro,
rtl::OUStringBuffer buf( 128 ); rtl::OUStringBuffer buf( 128 );
buf.appendAscii( intro ); buf.appendAscii( intro );
appendPointer(buf, ptr); appendPointer(buf, ptr);
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("].") ); buf.append( "]." );
buf.append( aFunctionName ); buf.append( aFunctionName );
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " = " ) ); buf.append( " = " );
buf.append( buf.append(
val2str( data, type.getTypeLibType(), VAL2STR_MODE_SHALLOW ) ); val2str( data, type.getTypeLibType(), VAL2STR_MODE_SHALLOW ) );
log( cargo,LogLevel::CALL, buf.makeStringAndClear() ); log( cargo,LogLevel::CALL, buf.makeStringAndClear() );
@@ -204,16 +204,16 @@ void logReply(
rtl::OUStringBuffer buf( 128 ); rtl::OUStringBuffer buf( 128 );
buf.appendAscii( intro ); buf.appendAscii( intro );
appendPointer(buf, ptr); appendPointer(buf, ptr);
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("].") ); buf.append( "]." );
buf.append( aFunctionName ); buf.append( aFunctionName );
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("()=") ); buf.append( "()=" );
if( isLog( cargo, LogLevel::ARGS ) ) if( isLog( cargo, LogLevel::ARGS ) )
{ {
buf.append( buf.append(
val2str( returnValue.getValue(), returnValue.getValueTypeRef(), VAL2STR_MODE_SHALLOW) ); val2str( returnValue.getValue(), returnValue.getValueTypeRef(), VAL2STR_MODE_SHALLOW) );
for( int i = 0; i < aParams.getLength() ; i ++ ) for( int i = 0; i < aParams.getLength() ; i ++ )
{ {
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", " ) ); buf.append( ", " );
buf.append( buf.append(
val2str( aParams[i].getValue(), aParams[i].getValueTypeRef(), VAL2STR_MODE_SHALLOW) ); val2str( aParams[i].getValue(), aParams[i].getValueTypeRef(), VAL2STR_MODE_SHALLOW) );
} }
@@ -229,20 +229,20 @@ void logCall( RuntimeCargo *cargo, const char *intro,
rtl::OUStringBuffer buf( 128 ); rtl::OUStringBuffer buf( 128 );
buf.appendAscii( intro ); buf.appendAscii( intro );
appendPointer(buf, ptr); appendPointer(buf, ptr);
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("].") ); buf.append( "]." );
buf.append( aFunctionName ); buf.append( aFunctionName );
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("(") ); buf.append( "(" );
if( isLog( cargo, LogLevel::ARGS ) ) if( isLog( cargo, LogLevel::ARGS ) )
{ {
for( int i = 0; i < aParams.getLength() ; i ++ ) for( int i = 0; i < aParams.getLength() ; i ++ )
{ {
if( i > 0 ) if( i > 0 )
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", " ) ); buf.append( ", " );
buf.append( buf.append(
val2str( aParams[i].getValue(), aParams[i].getValueTypeRef(), VAL2STR_MODE_SHALLOW) ); val2str( aParams[i].getValue(), aParams[i].getValueTypeRef(), VAL2STR_MODE_SHALLOW) );
} }
} }
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(")") ); buf.append( ")" );
log( cargo,LogLevel::CALL, buf.makeStringAndClear() ); log( cargo,LogLevel::CALL, buf.makeStringAndClear() );
} }