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

loplugin:nullptr (automatic rewrite)

Change-Id: I7a5fda2606f42e2736ad0618f2d8bcc5ba4028fb
üst 1fc2fe74
......@@ -90,7 +90,7 @@ class PyRef
{
PyObject *m;
public:
PyRef () : m(0) {}
PyRef () : m(nullptr) {}
PyRef( PyObject * p ) : m( p ) { Py_XINCREF( m ); }
PyRef( PyObject * p, __sal_NoAcquire ) : m( p ) {}
......@@ -130,7 +130,7 @@ public:
only seldom needed ! */
void scratch()
{
m = 0;
m = nullptr;
}
/** returns 1 when the reference points to a python object python object,
......@@ -138,7 +138,7 @@ public:
*/
bool is() const
{
return m != 0;
return m != nullptr;
}
struct Hash
......
......@@ -264,9 +264,9 @@ static const struct cppu::ImplementationEntry g_entries[] =
{
pyuno_loader::CreateInstance, pyuno_loader::getImplementationName,
pyuno_loader::getSupportedServiceNames, cppu::createSingleComponentFactory,
0 , 0
nullptr , 0
},
{ 0, 0, 0, 0, 0, 0 }
{ nullptr, nullptr, nullptr, nullptr, nullptr, 0 }
};
extern "C"
......
This diff is collapsed.
......@@ -193,7 +193,7 @@ Any Adapter::invoke( const OUString &aFunctionName,
}
RuntimeCargo *cargo = 0;
RuntimeCargo *cargo = nullptr;
try
{
PyThreadAttach guard( mInterpreter );
......
......@@ -70,7 +70,7 @@ PyObject* PyUNO_callable_call(
Sequence<Any> aParams;
Any any_params;
Any ret_value;
RuntimeCargo *cargo = 0;
RuntimeCargo *cargo = nullptr;
me = reinterpret_cast<PyUNO_callable*>(self);
PyRef ret;
......@@ -191,30 +191,30 @@ static PyTypeObject PyUNO_callable_Type =
nullptr,
nullptr,
nullptr,
0,
nullptr,
0,
0,
0,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
::pyuno::PyUNO_callable_call,
nullptr,
nullptr,
nullptr,
NULL,
nullptr,
0,
NULL,
nullptr,
nullptr,
nullptr,
nullptr,
0,
nullptr,
nullptr,
NULL,
NULL,
NULL,
NULL,
NULL,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
0,
......@@ -223,17 +223,17 @@ static PyTypeObject PyUNO_callable_Type =
nullptr,
nullptr,
nullptr,
NULL,
NULL,
NULL,
NULL,
NULL,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr
#if PY_VERSION_HEX >= 0x02060000
, 0
#endif
#if PY_VERSION_HEX >= 0x03040000
, 0
, nullptr
#endif
};
......@@ -247,8 +247,8 @@ PyRef PyUNO_callable_new (
OSL_ENSURE (my_inv.is(), "XInvocation must be valid");
self = PyObject_New (PyUNO_callable, &PyUNO_callable_Type);
if (self == NULL)
return NULL; //NULL == Error!
if (self == nullptr)
return nullptr; //NULL == Error!
self->members = new PyUNO_callable_Internals;
self->members->xInvocation = my_inv;
......
......@@ -56,7 +56,7 @@ static void * load(void * address, char const * symbol) {
libname = malloc(
len + RTL_CONSTASCII_LENGTH(SAL_DLLPREFIX "pyuno" SAL_DLLEXTENSION)
+ 1);
if (libname == 0) {
if (libname == NULL) {
abort();
}
strncpy(libname, dl_info.dli_fname, len);
......
......@@ -86,7 +86,7 @@ PyObject* PyUNO_iterator_next( PyObject *self )
}
PyErr_SetString( PyExc_StopIteration, "" );
return NULL;
return nullptr;
}
catch( css::container::NoSuchElementException &e )
{
......@@ -109,7 +109,7 @@ PyObject* PyUNO_iterator_next( PyObject *self )
raisePyExceptionWithAny( css::uno::makeAny( e ) );
}
return NULL;
return nullptr;
}
......@@ -170,8 +170,8 @@ static PyTypeObject PyUNO_iterator_Type =
PyObject* PyUNO_iterator_new( const Reference< XEnumeration > xEnumeration )
{
PyUNO_iterator* self = PyObject_New( PyUNO_iterator, &PyUNO_iterator_Type );
if ( self == NULL )
return NULL; // == error
if ( self == nullptr )
return nullptr; // == error
self->members = new PyUNO_iterator_Internals();
self->members->xEnumeration = xEnumeration;
return reinterpret_cast<PyObject*>(self);
......@@ -215,7 +215,7 @@ PyObject* PyUNO_list_iterator_next( PyObject *self )
if ( noMoreElements )
{
PyErr_SetString( PyExc_StopIteration, "" );
return NULL;
return nullptr;
}
PyRef rRet = runtime.any2PyObject( aRet );
......@@ -239,7 +239,7 @@ PyObject* PyUNO_list_iterator_next( PyObject *self )
raisePyExceptionWithAny( css::uno::makeAny( e ) );
}
return NULL;
return nullptr;
}
......@@ -300,8 +300,8 @@ static PyTypeObject PyUNO_list_iterator_Type =
PyObject* PyUNO_list_iterator_new( const Reference<XIndexAccess> &xIndexAccess )
{
PyUNO_list_iterator* self = PyObject_New( PyUNO_list_iterator, &PyUNO_list_iterator_Type );
if ( self == NULL )
return NULL; // == error
if ( self == nullptr )
return nullptr; // == error
self->members = new PyUNO_list_iterator_Internals();
self->members->xIndexAccess = xIndexAccess;
self->members->index = 0;
......
......@@ -259,7 +259,7 @@ static PyObject* getComponentContext(
PyErr_SetString(
PyExc_RuntimeError, "osl_getUrlFromAddress fails, that's why I cannot find ini "
"file for bootstrapping python uno bridge\n" );
return NULL;
return nullptr;
}
OUStringBuffer iniFileName;
......@@ -327,7 +327,7 @@ static PyObject* initTestEnvironment(
// so load "test" library and invoke a function there to do the work
try
{
PyObject *const ctx(getComponentContext(0, 0));
PyObject *const ctx(getComponentContext(nullptr, nullptr));
if (!ctx) { abort(); }
Runtime const runtime;
Any const a(runtime.pyObject2Any(ctx));
......@@ -370,7 +370,7 @@ PyObject * extractOneStringArg( PyObject *args, char const *funcName )
OStringBuffer buf;
buf.append( funcName ).append( ": expecting one string argument" );
PyErr_SetString( PyExc_RuntimeError, buf.getStr() );
return NULL;
return nullptr;
}
PyObject *obj = PyTuple_GetItem( args, 0 );
if (!PyStr_Check(obj) && !PyUnicode_Check(obj))
......@@ -378,7 +378,7 @@ PyObject * extractOneStringArg( PyObject *args, char const *funcName )
OStringBuffer buf;
buf.append( funcName ).append( ": expecting one string argument" );
PyErr_SetString( PyExc_TypeError, buf.getStr());
return NULL;
return nullptr;
}
return obj;
}
......@@ -472,7 +472,7 @@ static PyObject *createUnoStructHelper(
static PyObject *getTypeByName(
SAL_UNUSED_PARAMETER PyObject *, PyObject *args )
{
PyObject * ret = NULL;
PyObject * ret = nullptr;
try
{
......@@ -506,7 +506,7 @@ static PyObject *getTypeByName(
static PyObject *getConstantByName(
SAL_UNUSED_PARAMETER PyObject *, PyObject *args )
{
PyObject *ret = 0;
PyObject *ret = nullptr;
try
{
char *name;
......@@ -558,7 +558,7 @@ static PyObject *checkType( SAL_UNUSED_PARAMETER PyObject *, PyObject *args )
OStringBuffer buf;
buf.append( "pyuno.checkType : expecting one uno.Type argument" );
PyErr_SetString( PyExc_RuntimeError, buf.getStr() );
return NULL;
return nullptr;
}
PyObject *obj = PyTuple_GetItem( args, 0 );
......@@ -569,7 +569,7 @@ static PyObject *checkType( SAL_UNUSED_PARAMETER PyObject *, PyObject *args )
catch(const RuntimeException & e)
{
raisePyExceptionWithAny( makeAny( e ) );
return NULL;
return nullptr;
}
Py_INCREF( Py_None );
return Py_None;
......@@ -582,7 +582,7 @@ static PyObject *checkEnum( SAL_UNUSED_PARAMETER PyObject *, PyObject *args )
OStringBuffer buf;
buf.append( "pyuno.checkType : expecting one uno.Type argument" );
PyErr_SetString( PyExc_RuntimeError, buf.getStr() );
return NULL;
return nullptr;
}
PyObject *obj = PyTuple_GetItem( args, 0 );
......@@ -593,7 +593,7 @@ static PyObject *checkEnum( SAL_UNUSED_PARAMETER PyObject *, PyObject *args )
catch(const RuntimeException & e)
{
raisePyExceptionWithAny( makeAny( e) );
return NULL;
return nullptr;
}
Py_INCREF( Py_None );
return Py_None;
......@@ -603,7 +603,7 @@ static PyObject *getClass( SAL_UNUSED_PARAMETER PyObject *, PyObject *args )
{
PyObject *obj = extractOneStringArg( args, "pyuno.getClass");
if( ! obj )
return NULL;
return nullptr;
try
{
......@@ -616,7 +616,7 @@ static PyObject *getClass( SAL_UNUSED_PARAMETER PyObject *, PyObject *args )
{
raisePyExceptionWithAny( makeAny(e) );
}
return NULL;
return nullptr;
}
static PyObject *isInterface( SAL_UNUSED_PARAMETER PyObject *, PyObject *args )
......@@ -635,7 +635,7 @@ static PyObject * generateUuid(
SAL_UNUSED_PARAMETER PyObject *, SAL_UNUSED_PARAMETER PyObject * )
{
Sequence< sal_Int8 > seq( 16 );
rtl_createUuid( reinterpret_cast<sal_uInt8*>(seq.getArray()) , 0 , sal_False );
rtl_createUuid( reinterpret_cast<sal_uInt8*>(seq.getArray()) , nullptr , sal_False );
PyRef ret;
try
{
......@@ -654,7 +654,7 @@ static PyObject *systemPathToFileUrl(
{
PyObject *obj = extractOneStringArg( args, "pyuno.systemPathToFileUrl" );
if( ! obj )
return NULL;
return nullptr;
OUString sysPath = pyString2ustring( obj );
OUString url;
......@@ -670,7 +670,7 @@ static PyObject *systemPathToFileUrl(
buf.append( ")" );
raisePyExceptionWithAny(
makeAny( RuntimeException( buf.makeStringAndClear() )));
return NULL;
return nullptr;
}
return ustring2PyUnicode( url ).getAcquired();
}
......@@ -680,7 +680,7 @@ static PyObject * fileUrlToSystemPath(
{
PyObject *obj = extractOneStringArg( args, "pyuno.fileUrlToSystemPath" );
if( ! obj )
return NULL;
return nullptr;
OUString url = pyString2ustring( obj );
OUString sysPath;
......@@ -696,7 +696,7 @@ static PyObject * fileUrlToSystemPath(
buf.append( ")" );
raisePyExceptionWithAny(
makeAny( RuntimeException( buf.makeStringAndClear() )));
return NULL;
return nullptr;
}
return ustring2PyUnicode( sysPath ).getAcquired();
}
......@@ -723,16 +723,16 @@ static PyObject * absolutize( SAL_UNUSED_PARAMETER PyObject *, PyObject * args )
PyErr_SetString(
PyExc_OSError,
OUStringToOString(buf.makeStringAndClear(),osl_getThreadTextEncoding()).getStr());
return 0;
return nullptr;
}
return ustring2PyUnicode( ret ).getAcquired();
}
return 0;
return nullptr;
}
static PyObject * invoke(SAL_UNUSED_PARAMETER PyObject *, PyObject *args)
{
PyObject *ret = 0;
PyObject *ret = nullptr;
if(PyTuple_Check(args) && PyTuple_Size(args) == 3)
{
PyObject *object = PyTuple_GetItem(args, 0);
......@@ -836,23 +836,23 @@ static PyObject *setCurrentContext(
struct PyMethodDef PyUNOModule_methods [] =
{
{"private_initTestEnvironment", initTestEnvironment, METH_VARARGS, NULL},
{"getComponentContext", getComponentContext, METH_VARARGS, NULL},
{"_createUnoStructHelper", reinterpret_cast<PyCFunction>(createUnoStructHelper), METH_VARARGS | METH_KEYWORDS, NULL},
{"getTypeByName", getTypeByName, METH_VARARGS, NULL},
{"getConstantByName", getConstantByName, METH_VARARGS, NULL},
{"getClass", getClass, METH_VARARGS, NULL},
{"checkEnum", checkEnum, METH_VARARGS, NULL},
{"checkType", checkType, METH_VARARGS, NULL},
{"generateUuid", generateUuid, METH_VARARGS, NULL},
{"systemPathToFileUrl", systemPathToFileUrl, METH_VARARGS, NULL},
{"fileUrlToSystemPath", fileUrlToSystemPath, METH_VARARGS, NULL},
{"absolutize", absolutize, METH_VARARGS | METH_KEYWORDS, NULL},
{"isInterface", isInterface, METH_VARARGS, NULL},
{"invoke", invoke, METH_VARARGS | METH_KEYWORDS, NULL},
{"setCurrentContext", setCurrentContext, METH_VARARGS, NULL},
{"getCurrentContext", getCurrentContext, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
{"private_initTestEnvironment", initTestEnvironment, METH_VARARGS, nullptr},
{"getComponentContext", getComponentContext, METH_VARARGS, nullptr},
{"_createUnoStructHelper", reinterpret_cast<PyCFunction>(createUnoStructHelper), METH_VARARGS | METH_KEYWORDS, nullptr},
{"getTypeByName", getTypeByName, METH_VARARGS, nullptr},
{"getConstantByName", getConstantByName, METH_VARARGS, nullptr},
{"getClass", getClass, METH_VARARGS, nullptr},
{"checkEnum", checkEnum, METH_VARARGS, nullptr},
{"checkType", checkType, METH_VARARGS, nullptr},
{"generateUuid", generateUuid, METH_VARARGS, nullptr},
{"systemPathToFileUrl", systemPathToFileUrl, METH_VARARGS, nullptr},
{"fileUrlToSystemPath", fileUrlToSystemPath, METH_VARARGS, nullptr},
{"absolutize", absolutize, METH_VARARGS | METH_KEYWORDS, nullptr},
{"isInterface", isInterface, METH_VARARGS, nullptr},
{"invoke", invoke, METH_VARARGS | METH_KEYWORDS, nullptr},
{"setCurrentContext", setCurrentContext, METH_VARARGS, nullptr},
{"getCurrentContext", getCurrentContext, METH_VARARGS, nullptr},
{nullptr, nullptr, 0, nullptr}
};
}
......@@ -869,13 +869,13 @@ PyObject* PyInit_pyuno()
{
PyModuleDef_HEAD_INIT,
"pyuno", // module name
0, // module documentation
nullptr, // module documentation
-1, // module keeps state in global variables,
PyUNOModule_methods, // modules methods
0, // m_reload (must be 0)
0, // m_traverse
0, // m_clear
0, // m_free
nullptr, // m_reload (must be 0)
nullptr, // m_traverse
nullptr, // m_clear
nullptr, // m_free
};
return PyModule_Create(&moduledef);
}
......
......@@ -80,30 +80,30 @@ static PyTypeObject RuntimeImpl_Type =
nullptr,
nullptr,
nullptr,
0,
nullptr,
0,
0,
0,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
NULL,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
0,
NULL,
nullptr,
nullptr,
nullptr,
nullptr,
0,
nullptr,
nullptr,
NULL,
NULL,
NULL,
NULL,
NULL,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
0,
......@@ -112,17 +112,17 @@ static PyTypeObject RuntimeImpl_Type =
nullptr,
nullptr,
nullptr,
NULL,
NULL,
NULL,
NULL,
NULL,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr
#if PY_VERSION_HEX >= 0x02060000
, 0
#endif
#if PY_VERSION_HEX >= 0x03040000
, 0
, nullptr
#endif
};
......@@ -182,7 +182,7 @@ static PyRef importUnoModule( ) throw ( RuntimeException )
static void readLoggingConfig( sal_Int32 *pLevel, FILE **ppFile )
{
*pLevel = LogLevel::NONE;
*ppFile = 0;
*ppFile = nullptr;
OUString fileName;
osl_getModuleURLFromFunctionAddress(
reinterpret_cast< oslGenericFunction >(readLoggingConfig),
......@@ -223,7 +223,7 @@ static void readLoggingConfig( sal_Int32 *pLevel, FILE **ppFile )
oslProcessInfo data;
data.Size = sizeof( data );
osl_getProcessInfo(
0 , osl_Process_IDENTIFIER , &data );
nullptr , osl_Process_IDENTIFIER , &data );
osl_getSystemPathFromFileURL( str.pData, &str.pData);
OString o = OUStringToOString( str, osl_getThreadTextEncoding() );
o += ".";
......@@ -233,7 +233,7 @@ static void readLoggingConfig( sal_Int32 *pLevel, FILE **ppFile )
if ( *ppFile )
{
// do not buffer (useful if e.g. analyzing a crash)
setvbuf( *ppFile, 0, _IONBF, 0 );
setvbuf( *ppFile, nullptr, _IONBF, 0 );
}
else
{
......@@ -255,7 +255,7 @@ PyRef stRuntimeImpl::create( const Reference< XComponentContext > &ctx )
RuntimeImpl *me = PyObject_New (RuntimeImpl, &RuntimeImpl_Type);
if( ! me )
throw RuntimeException( "cannot instantiate pyuno::RuntimeImpl" );
me->cargo = 0;
me->cargo = nullptr;
// must use a different struct here, as the PyObject_New
// makes C++ unusable
RuntimeCargo *c = new RuntimeCargo();
......@@ -327,7 +327,7 @@ bool Runtime::isInitialized() throw ( RuntimeException )
}
Runtime::Runtime() throw( RuntimeException )
: impl( 0 )
: impl( nullptr )
{
PyRef globalDict, runtime;
getRuntimeImpl( globalDict , runtime );
......@@ -576,7 +576,7 @@ static Sequence< Type > invokeGetTypes( const Runtime & r , PyObject * o )
raiseInvocationTargetExceptionWhenNeeded( r );
if( method.is() && PyCallable_Check( method.get() ) )
{
PyRef types( PyObject_CallObject( method.get(), 0 ) , SAL_NO_ACQUIRE );
PyRef types( PyObject_CallObject( method.get(), nullptr ) , SAL_NO_ACQUIRE );
raiseInvocationTargetExceptionWhenNeeded( r );
if( types.is() && PyTuple_Check( types.get() ) )
{
......@@ -899,7 +899,7 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con
}
else
{
OUString const msg(lcl_ExceptionMessage(o, 0));
OUString const msg(lcl_ExceptionMessage(o, nullptr));
throw RuntimeException(msg);
}
}
......
......@@ -80,7 +80,7 @@ PyObject *PyUNOStruct_str( PyObject *self )
PyObject *PyUNOStruct_repr( PyObject *self )
{
PyUNO *me = reinterpret_cast<PyUNO*>( self );
PyObject *ret = 0;
PyObject *ret = nullptr;
if( me->members->wrappedObject.getValueType().getTypeClass()
== css::uno::TypeClass_EXCEPTION )
......@@ -106,7 +106,7 @@ PyObject* PyUNOStruct_dir( PyObject *self )
{
PyUNO *me = reinterpret_cast<PyUNO*>( self );
PyObject* member_list = NULL;
PyObject* member_list = nullptr;
try
{
......@@ -188,7 +188,7 @@ PyObject* PyUNOStruct_getattr( PyObject* self, char* name )
raisePyExceptionWithAny( makeAny(e) );
}
return NULL;
return nullptr;
}
int PyUNOStruct_setattr (PyObject* self, char* name, PyObject* value)
......@@ -243,7 +243,7 @@ static PyObject* PyUNOStruct_cmp( PyObject *self, PyObject *that, int op )
if(op != Py_EQ && op != Py_NE)
{
PyErr_SetString( PyExc_TypeError, "only '==' and '!=' comparisons are defined" );
return 0;
return nullptr;
}
if( self == that )
{
......@@ -291,8 +291,8 @@ static PyObject* PyUNOStruct_cmp( PyObject *self, PyObject *that, int op )
static PyMethodDef PyUNOStructMethods[] =
{
{"__dir__", reinterpret_cast<PyCFunction>(PyUNOStruct_dir), METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
{"__dir__", reinterpret_cast<PyCFunction>(PyUNOStruct_dir), METH_NOARGS, nullptr},
{nullptr, nullptr, 0, nullptr}
};
static PyTypeObject PyUNOStructType =
......@@ -305,7 +305,7 @@ static PyTypeObject PyUNOStructType =
nullptr,
PyUNOStruct_getattr,
PyUNOStruct_setattr,
/* this type does not exist in Python 3: (cmpfunc) */ 0,
/* this type does not exist in Python 3: (cmpfunc) */ nullptr,
PyUNOStruct_repr,
nullptr,
nullptr,
......@@ -347,7 +347,7 @@ static PyTypeObject PyUNOStructType =
, 0
#endif
#if PY_VERSION_HEX >= 0x03040000
, 0
, nullptr
#endif
};
......@@ -379,7 +379,7 @@ PyRef PyUNOStruct_new (
throw RuntimeException();
PyUNO* self = PyObject_New (PyUNO, &PyUNOStructType);
if (self == NULL)
if (self == nullptr)
return PyRef(); // == error
self->members = new PyUNOInternals();
self->members->xInvocation = xInvocation;
......
......@@ -36,7 +36,7 @@ namespace pyuno
{
const char *typeClassToString( TypeClass t )
{
const char * ret = 0;
const char * ret = nullptr;
switch (t)
{
case css::uno::TypeClass_VOID:
......@@ -243,7 +243,7 @@ static PyObject* callCtor( const Runtime &r , const char * clazz, const PyRef &
buf.append( "couldn't access uno." );
buf.append( clazz );
PyErr_SetString( PyExc_RuntimeError, buf.getStr() );
return NULL;
return nullptr;
}
PyRef instance( PyObject_CallObject( code.get(), args.get() ), SAL_NO_ACQUIRE);
Py_XINCREF( instance.get() );
......@@ -270,7 +270,7 @@ PyObject* PyUNO_Type_new (const char *typeName , TypeClass t , const Runtime &r
PyTuple_SetItem( args.get() , 0 , PyStr_FromString( typeName ) );
PyObject *typeClass = PyUNO_Enum_new( "com.sun.star.uno.TypeClass" , typeClassToString(t), r );
if( ! typeClass )
return NULL;
return nullptr;
PyTuple_SetItem( args.get() , 1 , typeClass);
return callCtor( r, "Type" , args );
......
......@@ -57,7 +57,7 @@ PyRef ustring2PyUnicode( const OUString & str )
ret = PyRef( PyUnicode_FromUnicode( (const Py_UNICODE*)str.getStr(), str.getLength() ), SAL_NO_ACQUIRE );
#else
OString sUtf8(OUStringToOString(str, RTL_TEXTENCODING_UTF8));
ret = PyRef( PyUnicode_DecodeUTF8( sUtf8.getStr(), sUtf8.getLength(), NULL) , SAL_NO_ACQUIRE );
ret = PyRef( PyUnicode_DecodeUTF8( sUtf8.getStr(), sUtf8.getLength(), nullptr) , SAL_NO_ACQUIRE );
#endif
return ret;
}
......
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