Base: remove some more deprecated Py2 code
and remove deprecated void from function signature and replace 0 or NULL with nullptr
This commit is contained in:
@@ -46,10 +46,6 @@ unsigned int format2_len = 1024;
|
||||
|
||||
using namespace Base;
|
||||
|
||||
#if PY_VERSION_HEX <= 0x02050000
|
||||
#error "Use Python2.5.x or higher"
|
||||
#endif
|
||||
|
||||
PyException::PyException(const Py::Object &obj) {
|
||||
_sErrMsg = obj.as_string();
|
||||
// WARNING: we are assuming that python type object will never be
|
||||
@@ -59,7 +55,7 @@ PyException::PyException(const Py::Object &obj) {
|
||||
_errorType = obj.ptr()->ob_type->tp_name;
|
||||
}
|
||||
|
||||
PyException::PyException(void)
|
||||
PyException::PyException()
|
||||
{
|
||||
PP_Fetch_Error_Text(); /* fetch (and clear) exception */
|
||||
|
||||
@@ -104,7 +100,7 @@ PyException::~PyException() throw()
|
||||
{
|
||||
}
|
||||
|
||||
void PyException::ThrowException(void)
|
||||
void PyException::ThrowException()
|
||||
{
|
||||
PyException myexcp;
|
||||
myexcp.ReportException();
|
||||
@@ -113,11 +109,10 @@ void PyException::ThrowException(void)
|
||||
|
||||
void PyException::raiseException() {
|
||||
PyGILStateLocker locker;
|
||||
|
||||
if (PP_PyDict_Object!=NULL) {
|
||||
if (PP_PyDict_Object!=nullptr) {
|
||||
// delete the Python dict upon destruction of edict
|
||||
Py::Dict edict(PP_PyDict_Object, true);
|
||||
PP_PyDict_Object = 0;
|
||||
PP_PyDict_Object = nullptr;
|
||||
|
||||
std::string exceptionname;
|
||||
if (_exceptionType == Base::BaseExceptionFreeCADAbort)
|
||||
@@ -137,7 +132,7 @@ void PyException::raiseException() {
|
||||
throw *this;
|
||||
}
|
||||
|
||||
void PyException::ReportException (void) const
|
||||
void PyException::ReportException () const
|
||||
{
|
||||
if (!_isReported) {
|
||||
_isReported = true;
|
||||
@@ -178,7 +173,7 @@ SystemExitException::SystemExitException()
|
||||
|
||||
if (value) {
|
||||
code = PyObject_GetAttrString(value, "code");
|
||||
if (code != NULL && value != Py_None) {
|
||||
if (code != nullptr && value != Py_None) {
|
||||
Py_DECREF(value);
|
||||
value = code;
|
||||
}
|
||||
@@ -203,7 +198,7 @@ SystemExitException::SystemExitException()
|
||||
class PythonStdOutput : public Py::PythonExtension<PythonStdOutput>
|
||||
{
|
||||
public:
|
||||
static void init_type(void)
|
||||
static void init_type()
|
||||
{
|
||||
behaviors().name("PythonStdOutput");
|
||||
behaviors().doc("Python standard output");
|
||||
@@ -232,7 +227,7 @@ public:
|
||||
|
||||
InterpreterSingleton::InterpreterSingleton()
|
||||
{
|
||||
this->_global = 0;
|
||||
this->_global = nullptr;
|
||||
}
|
||||
|
||||
InterpreterSingleton::~InterpreterSingleton()
|
||||
@@ -247,10 +242,10 @@ std::string InterpreterSingleton::runString(const char *sCmd)
|
||||
|
||||
PyGILStateLocker locker;
|
||||
module = PP_Load_Module("__main__"); /* get module, init python */
|
||||
if (module == NULL)
|
||||
if (module == nullptr)
|
||||
throw PyException(); /* not incref'd */
|
||||
dict = PyModule_GetDict(module); /* get dict namespace */
|
||||
if (dict == NULL)
|
||||
if (dict == nullptr)
|
||||
throw PyException(); /* not incref'd */
|
||||
|
||||
|
||||
@@ -324,10 +319,10 @@ Py::Object InterpreterSingleton::runStringObject(const char *sCmd)
|
||||
|
||||
PyGILStateLocker locker;
|
||||
module = PP_Load_Module("__main__"); /* get module, init python */
|
||||
if (module == NULL)
|
||||
if (module == nullptr)
|
||||
throw PyException(); /* not incref'd */
|
||||
dict = PyModule_GetDict(module); /* get dict namespace */
|
||||
if (dict == NULL)
|
||||
if (dict == nullptr)
|
||||
throw PyException(); /* not incref'd */
|
||||
|
||||
|
||||
@@ -342,7 +337,7 @@ Py::Object InterpreterSingleton::runStringObject(const char *sCmd)
|
||||
return Py::asObject(presult);
|
||||
}
|
||||
|
||||
void InterpreterSingleton::systemExit(void)
|
||||
void InterpreterSingleton::systemExit()
|
||||
{
|
||||
/* This code is taken from the original Python code */
|
||||
PyObject *exception, *value, *tb;
|
||||
@@ -350,7 +345,7 @@ void InterpreterSingleton::systemExit(void)
|
||||
|
||||
PyErr_Fetch(&exception, &value, &tb);
|
||||
fflush(stdout);
|
||||
if (value == NULL || value == Py_None)
|
||||
if (value == nullptr || value == Py_None)
|
||||
goto done;
|
||||
if (PyExceptionInstance_Check(value)) {
|
||||
/* The error code should be in the `code' attribute. */
|
||||
@@ -364,8 +359,9 @@ void InterpreterSingleton::systemExit(void)
|
||||
/* If we failed to dig out the 'code' attribute,
|
||||
just let the else clause below print the error. */
|
||||
}
|
||||
if (PyLong_Check(value))
|
||||
if (PyLong_Check(value)) {
|
||||
exitcode = (int)PyLong_AsLong(value);
|
||||
}
|
||||
else {
|
||||
PyObject_Print(value, stderr, Py_PRINT_RAW);
|
||||
PySys_WriteStderr("\n");
|
||||
@@ -389,10 +385,10 @@ void InterpreterSingleton::runInteractiveString(const char *sCmd)
|
||||
|
||||
PyGILStateLocker locker;
|
||||
module = PP_Load_Module("__main__"); /* get module, init python */
|
||||
if (module == NULL)
|
||||
if (module == nullptr)
|
||||
throw PyException(); /* not incref'd */
|
||||
dict = PyModule_GetDict(module); /* get dict namespace */
|
||||
if (dict == NULL)
|
||||
if (dict == nullptr)
|
||||
throw PyException(); /* not incref'd */
|
||||
|
||||
presult = PyRun_String(sCmd, Py_single_input, dict, dict); /* eval direct */
|
||||
@@ -442,9 +438,9 @@ void InterpreterSingleton::runFile(const char*pxFileName, bool local)
|
||||
Py_INCREF(dict); // avoid to further distinguish between local and global dict
|
||||
}
|
||||
|
||||
if (PyDict_GetItemString(dict, "__file__") == NULL) {
|
||||
if (PyDict_GetItemString(dict, "__file__") == nullptr) {
|
||||
PyObject *f = PyUnicode_FromString(pxFileName);
|
||||
if (f == NULL) {
|
||||
if (f == nullptr) {
|
||||
fclose(fp);
|
||||
Py_DECREF(dict);
|
||||
return;
|
||||
@@ -514,14 +510,10 @@ void InterpreterSingleton::addPythonPath(const char* Path)
|
||||
const char* InterpreterSingleton::init(int argc,char *argv[])
|
||||
{
|
||||
if (!Py_IsInitialized()) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
#if PY_MINOR_VERSION >= 5
|
||||
Py_SetProgramName(Py_DecodeLocale(argv[0],NULL));
|
||||
#if PY_VERSION_HEX >= 0x03050000
|
||||
Py_SetProgramName(Py_DecodeLocale(argv[0],nullptr));
|
||||
#else
|
||||
Py_SetProgramName(_Py_char2wchar(argv[0],NULL));
|
||||
#endif
|
||||
#else
|
||||
Py_SetProgramName(argv[0]);
|
||||
Py_SetProgramName(_Py_char2wchar(argv[0],nullptr));
|
||||
#endif
|
||||
// There is a serious bug in VS from 2010 until 2013 where the file descriptor for stdin, stdout or stderr
|
||||
// returns a valid value for GUI applications (i.e. subsystem = Windows) where it shouldn't.
|
||||
@@ -551,22 +543,15 @@ const char* InterpreterSingleton::init(int argc,char *argv[])
|
||||
size_t size = argc;
|
||||
static std::vector<wchar_t *> _argv(size);
|
||||
for (int i = 0; i < argc; i++) {
|
||||
#if PY_MINOR_VERSION >= 5
|
||||
_argv[i] = Py_DecodeLocale(argv[i],NULL);
|
||||
#else
|
||||
_argv[i] = _Py_char2wchar(argv[i],NULL);
|
||||
#endif
|
||||
_argv[i] = Py_DecodeLocale(argv[i],nullptr);
|
||||
}
|
||||
PySys_SetArgv(argc, _argv.data());
|
||||
PythonStdOutput::init_type();
|
||||
this->_global = PyEval_SaveThread();
|
||||
}
|
||||
|
||||
PyGILStateLocker lock;
|
||||
#if PY_MINOR_VERSION >= 5
|
||||
return Py_EncodeLocale(Py_GetPath(),NULL);
|
||||
#else
|
||||
return _Py_wchar2char(Py_GetPath(),NULL);
|
||||
#endif
|
||||
return Py_EncodeLocale(Py_GetPath(),nullptr);
|
||||
}
|
||||
|
||||
void InterpreterSingleton::replaceStdOutput()
|
||||
@@ -577,7 +562,7 @@ void InterpreterSingleton::replaceStdOutput()
|
||||
PySys_SetObject("stderr", out);
|
||||
}
|
||||
|
||||
int InterpreterSingleton::cleanup(void (*func)(void))
|
||||
int InterpreterSingleton::cleanup(void (*func)())
|
||||
{
|
||||
return Py_AtExit( func );
|
||||
}
|
||||
@@ -610,9 +595,9 @@ void InterpreterSingleton::runStringArg(const char * psCom,...)
|
||||
|
||||
// Singelton:
|
||||
|
||||
InterpreterSingleton * InterpreterSingleton::_pcSingelton = 0;
|
||||
InterpreterSingleton * InterpreterSingleton::_pcSingelton = nullptr;
|
||||
|
||||
InterpreterSingleton & InterpreterSingleton::Instance(void)
|
||||
InterpreterSingleton & InterpreterSingleton::Instance()
|
||||
{
|
||||
// not initialized!
|
||||
if (!_pcSingelton)
|
||||
@@ -620,12 +605,12 @@ InterpreterSingleton & InterpreterSingleton::Instance(void)
|
||||
return *_pcSingelton;
|
||||
}
|
||||
|
||||
void InterpreterSingleton::Destruct(void)
|
||||
void InterpreterSingleton::Destruct()
|
||||
{
|
||||
// not initialized or double destruct!
|
||||
assert(_pcSingelton);
|
||||
delete _pcSingelton;
|
||||
_pcSingelton = 0;
|
||||
_pcSingelton = nullptr;
|
||||
}
|
||||
|
||||
int InterpreterSingleton::runCommandLine(const char *prompt)
|
||||
@@ -643,8 +628,8 @@ void InterpreterSingleton::runMethodVoid(PyObject *pobject, const char *method)
|
||||
PyGILStateLocker locker;
|
||||
if (PP_Run_Method(pobject , // object
|
||||
method, // run method
|
||||
0, // no return type
|
||||
0, // so no return object
|
||||
nullptr, // no return type
|
||||
nullptr, // so no return object
|
||||
"()") // no arguments
|
||||
!= 0)
|
||||
throw PyException(/*"Error running InterpreterSingleton::RunMethodVoid()"*/);
|
||||
@@ -677,7 +662,7 @@ void InterpreterSingleton::runMethod(PyObject *pobject, const char *method,
|
||||
|
||||
PyGILStateLocker locker;
|
||||
pmeth = PyObject_GetAttrString(pobject, method);
|
||||
if (pmeth == NULL) { /* get callable object */
|
||||
if (pmeth == nullptr) { /* get callable object */
|
||||
va_end(argslist);
|
||||
throw AttributeError("Error running InterpreterSingleton::RunMethod() method not defined"); /* bound method? has self */
|
||||
}
|
||||
@@ -685,7 +670,7 @@ void InterpreterSingleton::runMethod(PyObject *pobject, const char *method,
|
||||
pargs = Py_VaBuildValue(argfmt, argslist); /* args: c->python */
|
||||
va_end(argslist);
|
||||
|
||||
if (pargs == NULL) {
|
||||
if (pargs == nullptr) {
|
||||
Py_DECREF(pmeth);
|
||||
throw TypeError("InterpreterSingleton::RunMethod() wrong arguments");
|
||||
}
|
||||
@@ -711,10 +696,10 @@ PyObject * InterpreterSingleton::getValue(const char * key, const char * result_
|
||||
|
||||
PyGILStateLocker locker;
|
||||
module = PP_Load_Module("__main__"); /* get module, init python */
|
||||
if (module == NULL)
|
||||
if (module == nullptr)
|
||||
throw PyException(); /* not incref'd */
|
||||
dict = PyModule_GetDict(module); /* get dict namespace */
|
||||
if (dict == NULL)
|
||||
if (dict == nullptr)
|
||||
throw PyException(); /* not incref'd */
|
||||
|
||||
|
||||
@@ -745,7 +730,7 @@ void InterpreterSingleton::dbgUnsetBreakPoint(unsigned int /*uiLineNumber*/)
|
||||
|
||||
}
|
||||
|
||||
void InterpreterSingleton::dbgStep(void)
|
||||
void InterpreterSingleton::dbgStep()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -832,7 +817,7 @@ namespace Swig_python { extern int createSWIGPointerObj_T(const char* TypeName,
|
||||
PyObject* InterpreterSingleton::createSWIGPointerObj(const char* Module, const char* TypeName, void* Pointer, int own)
|
||||
{
|
||||
int result = 0;
|
||||
PyObject* proxy=0;
|
||||
PyObject* proxy=nullptr;
|
||||
PyGILStateLocker locker;
|
||||
(void)Module;
|
||||
#if (defined(HAVE_SWIG) && (HAVE_SWIG == 1))
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
using namespace Base;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string MatrixPy::representation(void) const
|
||||
std::string MatrixPy::representation() const
|
||||
{
|
||||
const Base::Matrix4D& m = *(this->getMatrixPtr());
|
||||
std::stringstream str;
|
||||
@@ -95,11 +95,11 @@ PyObject* MatrixPy::number_add_handler(PyObject *self, PyObject *other)
|
||||
{
|
||||
if (!PyObject_TypeCheck(self, &(MatrixPy::Type))) {
|
||||
PyErr_SetString(PyExc_NotImplementedError, "");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
if (!PyObject_TypeCheck(other, &(MatrixPy::Type))) {
|
||||
PyErr_SetString(PyExc_TypeError, "Second arg must be Matrix");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
Base::Matrix4D a = static_cast<MatrixPy*>(self)->value();
|
||||
Base::Matrix4D b = static_cast<MatrixPy*>(other)->value();
|
||||
@@ -110,11 +110,11 @@ PyObject* MatrixPy::number_subtract_handler(PyObject *self, PyObject *other)
|
||||
{
|
||||
if (!PyObject_TypeCheck(self, &(MatrixPy::Type))) {
|
||||
PyErr_SetString(PyExc_NotImplementedError, "");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
if (!PyObject_TypeCheck(other, &(MatrixPy::Type))) {
|
||||
PyErr_SetString(PyExc_TypeError, "Second arg must be Matrix");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
Base::Matrix4D a = static_cast<MatrixPy*>(self)->value();
|
||||
Base::Matrix4D b = static_cast<MatrixPy*>(other)->value();
|
||||
@@ -156,7 +156,7 @@ PyObject* MatrixPy::number_multiply_handler(PyObject *self, PyObject *other)
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * MatrixPy::number_power_handler (PyObject* self, PyObject* other, PyObject* arg)
|
||||
@@ -168,7 +168,7 @@ PyObject * MatrixPy::number_power_handler (PyObject* self, PyObject* other, PyOb
|
||||
)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Base::Matrix4D a = static_cast<MatrixPy*>(self)->value();
|
||||
@@ -182,7 +182,7 @@ PyObject * MatrixPy::number_power_handler (PyObject* self, PyObject* other, PyOb
|
||||
a.inverseGauss();
|
||||
else {
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot invert singular matrix");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
b = -b;
|
||||
}
|
||||
@@ -200,11 +200,11 @@ PyObject* MatrixPy::richCompare(PyObject *v, PyObject *w, int op)
|
||||
Matrix4D m1 = static_cast<MatrixPy*>(v)->value();
|
||||
Matrix4D m2 = static_cast<MatrixPy*>(w)->value();
|
||||
|
||||
PyObject *res=0;
|
||||
PyObject *res=nullptr;
|
||||
if (op != Py_EQ && op != Py_NE) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"no ordering relation is defined for Matrix");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
else if (op == Py_EQ) {
|
||||
res = (m1 == m2) ? Py_True : Py_False;
|
||||
@@ -250,7 +250,7 @@ PyObject* MatrixPy::move(PyObject * args)
|
||||
PyErr_Clear();
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
PY_TRY {
|
||||
getMatrixPtr()->move(vec);
|
||||
@@ -286,7 +286,7 @@ PyObject* MatrixPy::scale(PyObject * args)
|
||||
PyErr_Clear();
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
PY_TRY {
|
||||
getMatrixPtr()->scale(vec);
|
||||
@@ -300,14 +300,14 @@ PyObject* MatrixPy::hasScale(PyObject * args)
|
||||
{
|
||||
double tol=0;
|
||||
if (!PyArg_ParseTuple(args, "|d", &tol))
|
||||
return 0;
|
||||
return nullptr;
|
||||
return Py::new_reference_to(Py::Int(getMatrixPtr()->hasScale(tol)));
|
||||
}
|
||||
|
||||
PyObject* MatrixPy::unity(PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
|
||||
return NULL; // NULL triggers exception
|
||||
return nullptr; // NULL triggers exception
|
||||
PY_TRY {
|
||||
getMatrixPtr()->setToUnity();
|
||||
}
|
||||
@@ -332,7 +332,7 @@ PyObject* MatrixPy::transform(PyObject * args)
|
||||
PyErr_Clear();
|
||||
}
|
||||
else
|
||||
return NULL; // NULL triggers exception
|
||||
return nullptr; // NULL triggers exception
|
||||
|
||||
PY_TRY {
|
||||
getMatrixPtr()->transform(vec,mat);
|
||||
@@ -361,7 +361,7 @@ PyObject* MatrixPy::rotateX(PyObject * args)
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "For angle either float or Quantity expected");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
while (false);
|
||||
|
||||
@@ -392,7 +392,7 @@ PyObject* MatrixPy::rotateY(PyObject * args)
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "For angle either float or Quantity expected");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
while (false);
|
||||
|
||||
@@ -423,7 +423,7 @@ PyObject* MatrixPy::rotateZ(PyObject * args)
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "For angle either float or Quantity expected");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
while (false);
|
||||
|
||||
@@ -450,14 +450,14 @@ PyObject* MatrixPy::multiply(PyObject * args)
|
||||
}
|
||||
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, "either vector or matrix expected");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* MatrixPy::multVec(PyObject * args)
|
||||
{
|
||||
PyObject *obj;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &obj))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
Base::Vector3d vec(static_cast<VectorPy*>(obj)->value());
|
||||
getMatrixPtr()->multVec(vec, vec);
|
||||
return new VectorPy(new Vector3d(vec));
|
||||
@@ -466,14 +466,14 @@ PyObject* MatrixPy::multVec(PyObject * args)
|
||||
PyObject* MatrixPy::invert(PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
PY_TRY {
|
||||
if (fabs(getMatrixPtr()->determinant()) > DBL_EPSILON)
|
||||
getMatrixPtr()->inverseGauss();
|
||||
else {
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot invert singular matrix");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
PY_CATCH;
|
||||
@@ -484,7 +484,7 @@ PyObject* MatrixPy::invert(PyObject * args)
|
||||
PyObject* MatrixPy::inverse(PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
PY_TRY {
|
||||
if (fabs(getMatrixPtr()->determinant()) > DBL_EPSILON) {
|
||||
@@ -494,7 +494,7 @@ PyObject* MatrixPy::inverse(PyObject * args)
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot invert singular matrix");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
PY_CATCH;
|
||||
@@ -505,7 +505,7 @@ PyObject* MatrixPy::inverse(PyObject * args)
|
||||
PyObject* MatrixPy::determinant(PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
return PyFloat_FromDouble(getMatrixPtr()->determinant());
|
||||
}
|
||||
|
||||
@@ -513,10 +513,10 @@ PyObject* MatrixPy::submatrix(PyObject * args)
|
||||
{
|
||||
int dim;
|
||||
if (!PyArg_ParseTuple(args, "i", &dim))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (dim < 1 || dim > 4) {
|
||||
PyErr_SetString(PyExc_IndexError, "Dimension out of range");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const Base::Matrix4D& mat = *getMatrixPtr();
|
||||
@@ -547,7 +547,7 @@ PyObject* MatrixPy::isOrthogonal(PyObject * args)
|
||||
{
|
||||
double eps=1.0e-06;
|
||||
if (!PyArg_ParseTuple(args, "|d",&eps))
|
||||
return 0;
|
||||
return nullptr;
|
||||
const Base::Matrix4D& mat = *getMatrixPtr();
|
||||
Base::Matrix4D trp = mat;
|
||||
trp.transpose();
|
||||
@@ -578,7 +578,7 @@ PyObject* MatrixPy::isOrthogonal(PyObject * args)
|
||||
PyObject* MatrixPy::transposed(PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
PY_TRY {
|
||||
Base::Matrix4D m = *getMatrixPtr();
|
||||
@@ -593,7 +593,7 @@ PyObject* MatrixPy::transposed(PyObject * args)
|
||||
PyObject* MatrixPy::transpose(PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
PY_TRY {
|
||||
getMatrixPtr()->transpose();
|
||||
@@ -605,7 +605,7 @@ PyObject* MatrixPy::transpose(PyObject * args)
|
||||
PyObject* MatrixPy::analyze(PyObject * args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
PY_TRY {
|
||||
std::string type = getMatrixPtr()->analyse();
|
||||
@@ -614,7 +614,7 @@ PyObject* MatrixPy::analyze(PyObject * args)
|
||||
PY_CATCH;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA11(void) const
|
||||
Py::Float MatrixPy::getA11() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[0][0];
|
||||
return Py::Float(val);
|
||||
@@ -625,7 +625,7 @@ void MatrixPy::setA11(Py::Float arg)
|
||||
(*this->getMatrixPtr())[0][0] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA12(void) const
|
||||
Py::Float MatrixPy::getA12() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[0][1];
|
||||
return Py::Float(val);
|
||||
@@ -636,7 +636,7 @@ void MatrixPy::setA12(Py::Float arg)
|
||||
(*this->getMatrixPtr())[0][1] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA13(void) const
|
||||
Py::Float MatrixPy::getA13() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[0][2];
|
||||
return Py::Float(val);
|
||||
@@ -647,7 +647,7 @@ void MatrixPy::setA13(Py::Float arg)
|
||||
(*this->getMatrixPtr())[0][2] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA14(void) const
|
||||
Py::Float MatrixPy::getA14() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[0][3];
|
||||
return Py::Float(val);
|
||||
@@ -658,7 +658,7 @@ void MatrixPy::setA14(Py::Float arg)
|
||||
(*this->getMatrixPtr())[0][3] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA21(void) const
|
||||
Py::Float MatrixPy::getA21() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[1][0];
|
||||
return Py::Float(val);
|
||||
@@ -669,7 +669,7 @@ void MatrixPy::setA21(Py::Float arg)
|
||||
(*this->getMatrixPtr())[1][0] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA22(void) const
|
||||
Py::Float MatrixPy::getA22() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[1][1];
|
||||
return Py::Float(val);
|
||||
@@ -680,7 +680,7 @@ void MatrixPy::setA22(Py::Float arg)
|
||||
(*this->getMatrixPtr())[1][1] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA23(void) const
|
||||
Py::Float MatrixPy::getA23() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[1][2];
|
||||
return Py::Float(val);
|
||||
@@ -691,7 +691,7 @@ void MatrixPy::setA23(Py::Float arg)
|
||||
(*this->getMatrixPtr())[1][2] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA24(void) const
|
||||
Py::Float MatrixPy::getA24() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[1][3];
|
||||
return Py::Float(val);
|
||||
@@ -702,7 +702,7 @@ void MatrixPy::setA24(Py::Float arg)
|
||||
(*this->getMatrixPtr())[1][3] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA31(void) const
|
||||
Py::Float MatrixPy::getA31() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[2][0];
|
||||
return Py::Float(val);
|
||||
@@ -713,7 +713,7 @@ void MatrixPy::setA31(Py::Float arg)
|
||||
(*this->getMatrixPtr())[2][0] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA32(void) const
|
||||
Py::Float MatrixPy::getA32() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[2][1];
|
||||
return Py::Float(val);
|
||||
@@ -724,7 +724,7 @@ void MatrixPy::setA32(Py::Float arg)
|
||||
(*this->getMatrixPtr())[2][1] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA33(void) const
|
||||
Py::Float MatrixPy::getA33() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[2][2];
|
||||
return Py::Float(val);
|
||||
@@ -735,7 +735,7 @@ void MatrixPy::setA33(Py::Float arg)
|
||||
(*this->getMatrixPtr())[2][2] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA34(void) const
|
||||
Py::Float MatrixPy::getA34() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[2][3];
|
||||
return Py::Float(val);
|
||||
@@ -746,7 +746,7 @@ void MatrixPy::setA34(Py::Float arg)
|
||||
(*this->getMatrixPtr())[2][3] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA41(void) const
|
||||
Py::Float MatrixPy::getA41() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[3][0];
|
||||
return Py::Float(val);
|
||||
@@ -757,7 +757,7 @@ void MatrixPy::setA41(Py::Float arg)
|
||||
(*this->getMatrixPtr())[3][0] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA42(void) const
|
||||
Py::Float MatrixPy::getA42() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[3][1];
|
||||
return Py::Float(val);
|
||||
@@ -768,7 +768,7 @@ void MatrixPy::setA42(Py::Float arg)
|
||||
(*this->getMatrixPtr())[3][1] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA43(void) const
|
||||
Py::Float MatrixPy::getA43() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[3][2];
|
||||
return Py::Float(val);
|
||||
@@ -779,7 +779,7 @@ void MatrixPy::setA43(Py::Float arg)
|
||||
(*this->getMatrixPtr())[3][2] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Float MatrixPy::getA44(void) const
|
||||
Py::Float MatrixPy::getA44() const
|
||||
{
|
||||
double val = (*this->getMatrixPtr())[3][3];
|
||||
return Py::Float(val);
|
||||
@@ -790,7 +790,7 @@ void MatrixPy::setA44(Py::Float arg)
|
||||
(*this->getMatrixPtr())[3][3] = (double)arg;
|
||||
}
|
||||
|
||||
Py::Sequence MatrixPy::getA(void) const
|
||||
Py::Sequence MatrixPy::getA() const
|
||||
{
|
||||
double mat[16];
|
||||
this->getMatrixPtr()->getMatrix(mat);
|
||||
@@ -816,7 +816,7 @@ void MatrixPy::setA(Py::Sequence arg)
|
||||
|
||||
PyObject *MatrixPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int MatrixPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
@@ -827,37 +827,37 @@ int MatrixPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
PyObject * MatrixPy::number_divide_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * MatrixPy::number_remainder_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * MatrixPy::number_divmod_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * MatrixPy::number_negative_handler (PyObject* /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * MatrixPy::number_positive_handler (PyObject* /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * MatrixPy::number_absolute_handler (PyObject* /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int MatrixPy::number_nonzero_handler (PyObject* /*self*/)
|
||||
@@ -868,47 +868,47 @@ int MatrixPy::number_nonzero_handler (PyObject* /*self*/)
|
||||
PyObject * MatrixPy::number_invert_handler (PyObject* /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * MatrixPy::number_lshift_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * MatrixPy::number_rshift_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * MatrixPy::number_and_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * MatrixPy::number_xor_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * MatrixPy::number_or_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * MatrixPy::number_int_handler (PyObject * /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * MatrixPy::number_float_handler (PyObject * /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <assert.h>
|
||||
# include <cassert>
|
||||
# include <fcntl.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
@@ -33,7 +33,7 @@
|
||||
# include <io.h>
|
||||
# include <xercesc/sax/SAXParseException.hpp>
|
||||
# endif
|
||||
# include <stdio.h>
|
||||
# include <cstdio>
|
||||
# include <sstream>
|
||||
# include <list>
|
||||
#endif
|
||||
@@ -99,7 +99,7 @@ typedef std::list<ParameterGrpObserver*> ParameterGrpObserverList;
|
||||
class ParameterGrpPy : public Py::PythonExtension<ParameterGrpPy>
|
||||
{
|
||||
public:
|
||||
static void init_type(void); // announce properties and methods
|
||||
static void init_type(); // announce properties and methods
|
||||
|
||||
ParameterGrpPy(const Base::Reference<ParameterGrp> &rcParamGrp);
|
||||
~ParameterGrpPy();
|
||||
@@ -320,7 +320,7 @@ Py::Object ParameterGrpPy::getBool(const Py::Tuple& args)
|
||||
|
||||
Py::Object ParameterGrpPy::getBools(const Py::Tuple& args)
|
||||
{
|
||||
char *filter=0;
|
||||
char *filter=nullptr;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "|s", &filter))
|
||||
throw Py::Exception();
|
||||
|
||||
@@ -355,7 +355,7 @@ Py::Object ParameterGrpPy::getInt(const Py::Tuple& args)
|
||||
|
||||
Py::Object ParameterGrpPy::getInts(const Py::Tuple& args)
|
||||
{
|
||||
char *filter=0;
|
||||
char *filter=nullptr;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "|s", &filter))
|
||||
throw Py::Exception();
|
||||
|
||||
@@ -390,7 +390,7 @@ Py::Object ParameterGrpPy::getUnsigned(const Py::Tuple& args)
|
||||
|
||||
Py::Object ParameterGrpPy::getUnsigneds(const Py::Tuple& args)
|
||||
{
|
||||
char *filter=0;
|
||||
char *filter=nullptr;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "|s", &filter))
|
||||
throw Py::Exception();
|
||||
|
||||
@@ -426,7 +426,7 @@ Py::Object ParameterGrpPy::getFloat(const Py::Tuple& args)
|
||||
|
||||
Py::Object ParameterGrpPy::getFloats(const Py::Tuple& args)
|
||||
{
|
||||
char *filter=0;
|
||||
char *filter=nullptr;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "|s", &filter))
|
||||
throw Py::Exception();
|
||||
|
||||
@@ -462,7 +462,7 @@ Py::Object ParameterGrpPy::getString(const Py::Tuple& args)
|
||||
|
||||
Py::Object ParameterGrpPy::getStrings(const Py::Tuple& args)
|
||||
{
|
||||
char *filter=0;
|
||||
char *filter=nullptr;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "|s", &filter))
|
||||
throw Py::Exception();
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
# include <stdlib.h>
|
||||
# include <cstdlib>
|
||||
#endif
|
||||
|
||||
#include "PyObjectBase.h"
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
using namespace Base;
|
||||
|
||||
PyObject* Base::BaseExceptionFreeCADError = 0;
|
||||
PyObject* Base::BaseExceptionFreeCADAbort = 0;
|
||||
PyObject* Base::BaseExceptionFreeCADError = nullptr;
|
||||
PyObject* Base::BaseExceptionFreeCADAbort = nullptr;
|
||||
|
||||
#ifdef ATTR_TRACKING
|
||||
typedef struct {
|
||||
@@ -107,49 +107,49 @@ static PyTypeObject PyBaseProxyType = {
|
||||
sizeof(PyBaseProxy), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
PyBaseProxy_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash*/
|
||||
0, /*tp_call */
|
||||
0, /*tp_str */
|
||||
0, /*tp_getattro*/
|
||||
0, /*tp_setattro*/
|
||||
0, /* tp_as_buffer */
|
||||
nullptr, /*tp_print*/
|
||||
nullptr, /*tp_getattr*/
|
||||
nullptr, /*tp_setattr*/
|
||||
nullptr, /*tp_compare*/
|
||||
nullptr, /*tp_repr*/
|
||||
nullptr, /*tp_as_number*/
|
||||
nullptr, /*tp_as_sequence*/
|
||||
nullptr, /*tp_as_mapping*/
|
||||
nullptr, /*tp_hash*/
|
||||
nullptr, /*tp_call */
|
||||
nullptr, /*tp_str */
|
||||
nullptr, /*tp_getattro*/
|
||||
nullptr, /*tp_setattro*/
|
||||
nullptr, /*tp_as_buffer*/
|
||||
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_DEFAULT, /*tp_flags */
|
||||
"Proxy class", /*tp_doc */
|
||||
0, /*tp_traverse */
|
||||
0, /*tp_clear */
|
||||
0, /*tp_richcompare */
|
||||
nullptr, /*tp_traverse */
|
||||
nullptr, /*tp_clear */
|
||||
nullptr, /*tp_richcompare */
|
||||
offsetof(PyBaseProxy, weakreflist), /*tp_weaklistoffset */
|
||||
0, /*tp_iter */
|
||||
0, /*tp_iternext */
|
||||
0, /*tp_methods */
|
||||
0, /*tp_members */
|
||||
0, /*tp_getset */
|
||||
0, /*tp_base */
|
||||
0, /*tp_dict */
|
||||
0, /*tp_descr_get */
|
||||
0, /*tp_descr_set */
|
||||
nullptr, /*tp_iter */
|
||||
nullptr, /*tp_iternext */
|
||||
nullptr, /*tp_methods */
|
||||
nullptr, /*tp_members */
|
||||
nullptr, /*tp_getset */
|
||||
nullptr, /*tp_base */
|
||||
nullptr, /*tp_dict */
|
||||
nullptr, /*tp_descr_get */
|
||||
nullptr, /*tp_descr_set */
|
||||
0, /*tp_dictoffset */
|
||||
0, /*tp_init */
|
||||
0, /*tp_alloc */
|
||||
0, /*tp_new */
|
||||
0, /*tp_free Low-level free-memory routine */
|
||||
0, /*tp_is_gc For PyObject_IS_GC */
|
||||
0, /*tp_bases */
|
||||
0, /*tp_mro method resolution order */
|
||||
0, /*tp_cache */
|
||||
0, /*tp_subclasses */
|
||||
0, /*tp_weaklist */
|
||||
0, /*tp_del */
|
||||
nullptr, /*tp_init */
|
||||
nullptr, /*tp_alloc */
|
||||
nullptr, /*tp_new */
|
||||
nullptr, /*tp_free Low-level free-memory routine */
|
||||
nullptr, /*tp_is_gc For PyObject_IS_GC */
|
||||
nullptr, /*tp_bases */
|
||||
nullptr, /*tp_mro method resolution order */
|
||||
nullptr, /*tp_cache */
|
||||
nullptr, /*tp_subclasses */
|
||||
nullptr, /*tp_weaklist */
|
||||
nullptr, /*tp_del */
|
||||
0, /*tp_version_tag */
|
||||
0 /*tp_finalize */
|
||||
nullptr /*tp_finalize */
|
||||
#if PY_VERSION_HEX >= 0x03090000
|
||||
,0 /*tp_vectorcall */
|
||||
#elif PY_VERSION_HEX >= 0x03080000
|
||||
@@ -166,51 +166,51 @@ PyTypeObject PyObjectBase::Type = {
|
||||
0, /*tp_itemsize*/
|
||||
/* --- methods ---------------------------------------------- */
|
||||
PyDestructor, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
nullptr, /*tp_print*/
|
||||
nullptr, /*tp_getattr*/
|
||||
nullptr, /*tp_setattr*/
|
||||
nullptr, /*tp_compare*/
|
||||
__repr, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash*/
|
||||
0, /*tp_call */
|
||||
0, /*tp_str */
|
||||
nullptr, /*tp_as_number*/
|
||||
nullptr, /*tp_as_sequence*/
|
||||
nullptr, /*tp_as_mapping*/
|
||||
nullptr, /*tp_hash*/
|
||||
nullptr, /*tp_call */
|
||||
nullptr, /*tp_str */
|
||||
__getattro, /*tp_getattro*/
|
||||
__setattro, /*tp_setattro*/
|
||||
/* --- Functions to access object as input/output buffer ---------*/
|
||||
0, /* tp_as_buffer */
|
||||
nullptr, /* tp_as_buffer */
|
||||
/* --- Flags to define presence of optional/expanded features */
|
||||
Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT, /*tp_flags */
|
||||
"The most base class for Python binding", /*tp_doc */
|
||||
0, /*tp_traverse */
|
||||
0, /*tp_clear */
|
||||
0, /*tp_richcompare */
|
||||
nullptr, /*tp_traverse */
|
||||
nullptr, /*tp_clear */
|
||||
nullptr, /*tp_richcompare */
|
||||
0, /*tp_weaklistoffset */
|
||||
0, /*tp_iter */
|
||||
0, /*tp_iternext */
|
||||
0, /*tp_methods */
|
||||
0, /*tp_members */
|
||||
0, /*tp_getset */
|
||||
0, /*tp_base */
|
||||
0, /*tp_dict */
|
||||
0, /*tp_descr_get */
|
||||
0, /*tp_descr_set */
|
||||
nullptr, /*tp_iter */
|
||||
nullptr, /*tp_iternext */
|
||||
nullptr, /*tp_methods */
|
||||
nullptr, /*tp_members */
|
||||
nullptr, /*tp_getset */
|
||||
nullptr, /*tp_base */
|
||||
nullptr, /*tp_dict */
|
||||
nullptr, /*tp_descr_get */
|
||||
nullptr, /*tp_descr_set */
|
||||
0, /*tp_dictoffset */
|
||||
0, /*tp_init */
|
||||
0, /*tp_alloc */
|
||||
0, /*tp_new */
|
||||
0, /*tp_free Low-level free-memory routine */
|
||||
0, /*tp_is_gc For PyObject_IS_GC */
|
||||
0, /*tp_bases */
|
||||
0, /*tp_mro method resolution order */
|
||||
0, /*tp_cache */
|
||||
0, /*tp_subclasses */
|
||||
0, /*tp_weaklist */
|
||||
0, /*tp_del */
|
||||
0, /*tp_version_tag */
|
||||
0 /*tp_finalize */
|
||||
nullptr, /*tp_init */
|
||||
nullptr, /*tp_alloc */
|
||||
nullptr, /*tp_new */
|
||||
nullptr, /*tp_free Low-level free-memory routine */
|
||||
nullptr, /*tp_is_gc For PyObject_IS_GC */
|
||||
nullptr, /*tp_bases */
|
||||
nullptr, /*tp_mro method resolution order */
|
||||
nullptr, /*tp_cache */
|
||||
nullptr, /*tp_subclasses */
|
||||
nullptr, /*tp_weaklist */
|
||||
nullptr, /*tp_del */
|
||||
0, /*tp_version_tag */
|
||||
nullptr /*tp_finalize */
|
||||
#if PY_VERSION_HEX >= 0x03090000
|
||||
,0 /*tp_vectorcall */
|
||||
#elif PY_VERSION_HEX >= 0x03080000
|
||||
@@ -261,7 +261,7 @@ PyObjectBase* getFromWeakRef(PyObject* ref)
|
||||
* PyObjectBase Methods -- Every class, even the abstract one should have a Methods
|
||||
------------------------------*/
|
||||
PyMethodDef PyObjectBase::Methods[] = {
|
||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, 0, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro)
|
||||
@@ -282,7 +282,7 @@ PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro)
|
||||
PyObjectBase* pyObj = static_cast<PyObjectBase*>(obj);
|
||||
if (!pyObj->isValid()){
|
||||
PyErr_Format(PyExc_ReferenceError, "Cannot access attribute '%s' of deleted object", attr);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef ATTR_TRACKING
|
||||
@@ -320,7 +320,7 @@ PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro)
|
||||
PyCFunctionObject* cfunc = reinterpret_cast<PyCFunctionObject*>(value);
|
||||
if (!cfunc->m_self) {
|
||||
Py_DECREF(cfunc);
|
||||
value = 0;
|
||||
value = nullptr;
|
||||
PyErr_Format(PyExc_AttributeError, "<no object bound to built-in method %s>", attr);
|
||||
}
|
||||
}
|
||||
@@ -335,7 +335,7 @@ int PyObjectBase::__setattro(PyObject *obj, PyObject *attro, PyObject *value)
|
||||
|
||||
//FIXME: In general we don't allow to delete attributes (i.e. value=0). However, if we want to allow
|
||||
//we must check then in _setattr() of all subclasses whether value is 0.
|
||||
if ( value==0 ) {
|
||||
if ( value==nullptr ) {
|
||||
PyErr_Format(PyExc_AttributeError, "Cannot delete attribute: '%s'", attr);
|
||||
return -1;
|
||||
}
|
||||
@@ -379,7 +379,7 @@ PyObject *PyObjectBase::_getattr(const char *attr)
|
||||
}
|
||||
else if (streq(attr, "__members__")) {
|
||||
// Use __dict__ instead as __members__ is deprecated
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
else if (streq(attr,"__dict__")) {
|
||||
// Return the default dict
|
||||
@@ -389,13 +389,13 @@ PyObject *PyObjectBase::_getattr(const char *attr)
|
||||
}
|
||||
else if (streq(attr,"softspace")) {
|
||||
// Internal Python stuff
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
// As fallback solution use Python's default method to get generic attributes
|
||||
PyObject *w, *res;
|
||||
w = PyUnicode_InternFromString(attr);
|
||||
if (w != NULL) {
|
||||
if (w != nullptr) {
|
||||
res = PyObject_GenericGetAttr(this, w);
|
||||
Py_XDECREF(w);
|
||||
return res;
|
||||
@@ -403,7 +403,7 @@ PyObject *PyObjectBase::_getattr(const char *attr)
|
||||
// Throw an exception for unknown attributes
|
||||
PyTypeObject *tp = Py_TYPE(this);
|
||||
PyErr_Format(PyExc_AttributeError, "%.50s instance has no attribute '%.400s'", tp->tp_name, attr);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -415,7 +415,7 @@ int PyObjectBase::_setattr(const char *attr, PyObject *value)
|
||||
PyObject *w;
|
||||
// As fallback solution use Python's default method to get generic attributes
|
||||
w = PyUnicode_InternFromString(attr); // new reference
|
||||
if (w != NULL) {
|
||||
if (w != nullptr) {
|
||||
// call methods from tp_getset if defined
|
||||
int res = PyObject_GenericSetAttr(this, w, value);
|
||||
Py_DECREF(w);
|
||||
@@ -431,7 +431,7 @@ int PyObjectBase::_setattr(const char *attr, PyObject *value)
|
||||
/*------------------------------
|
||||
* PyObjectBase repr representations
|
||||
------------------------------*/
|
||||
PyObject *PyObjectBase::_repr(void)
|
||||
PyObject *PyObjectBase::_repr()
|
||||
{
|
||||
std::stringstream a;
|
||||
a << "<base object at " << _pcTwinPointer << ">";
|
||||
@@ -478,6 +478,7 @@ void PyObjectBase::setAttributeOf(const char* attr, PyObject* par)
|
||||
Py_DECREF(key1);
|
||||
Py_DECREF(key2);
|
||||
}
|
||||
|
||||
void PyObjectBase::startNotify()
|
||||
{
|
||||
if (!shouldNotify())
|
||||
@@ -512,6 +513,7 @@ void PyObjectBase::startNotify()
|
||||
Py_DECREF(key2);
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* PyObjectBase::getTrackedAttribute(const char* attr)
|
||||
{
|
||||
PyObject* obj = nullptr;
|
||||
|
||||
@@ -50,10 +50,8 @@
|
||||
|
||||
#include <typeinfo>
|
||||
#include "Exception.h"
|
||||
#if PY_MAJOR_VERSION > 2
|
||||
# ifndef PYCXX_PYTHON_2TO3
|
||||
# define PYCXX_PYTHON_2TO3
|
||||
# endif
|
||||
#ifndef PYCXX_PYTHON_2TO3
|
||||
#define PYCXX_PYTHON_2TO3
|
||||
#endif
|
||||
#include <CXX/Objects.hxx>
|
||||
|
||||
@@ -91,8 +89,8 @@
|
||||
|
||||
/** Macro for initialization function of Python modules.
|
||||
*/
|
||||
# define PyMOD_INIT_FUNC(name) PyMODINIT_FUNC PyInit_##name(void)
|
||||
# define PyMOD_Return(name) return name
|
||||
#define PyMOD_INIT_FUNC(name) PyMODINIT_FUNC PyInit_##name(void)
|
||||
#define PyMOD_Return(name) return name
|
||||
|
||||
/**
|
||||
* Union to convert from PyTypeObject to PyObject pointer.
|
||||
@@ -218,9 +216,9 @@ public:
|
||||
static void PyDestructor(PyObject *P) // python wrapper
|
||||
{ delete ((PyObjectBase *) P); }
|
||||
/// incref method wrapper (see python extending manual)
|
||||
PyObjectBase* IncRef(void) {Py_INCREF(this);return this;}
|
||||
PyObjectBase* IncRef() {Py_INCREF(this);return this;}
|
||||
/// decref method wrapper (see python extending manual)
|
||||
PyObjectBase* DecRef(void) {Py_DECREF(this);return this;}
|
||||
PyObjectBase* DecRef() {Py_DECREF(this);return this;}
|
||||
|
||||
/** GetAttribute implementation
|
||||
* This method implements the retrieval of object attributes.
|
||||
@@ -259,12 +257,12 @@ public:
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
virtual PyObject *_repr(void);
|
||||
virtual PyObject *_repr();
|
||||
/// python wrapper for the _repr() function
|
||||
static PyObject *__repr(PyObject *PyObj) {
|
||||
if (!((PyObjectBase*) PyObj)->isValid()){
|
||||
PyErr_Format(PyExc_ReferenceError, "Cannot print representation of deleted object");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return ((PyObjectBase*) PyObj)->_repr();
|
||||
}
|
||||
@@ -287,7 +285,7 @@ public:
|
||||
// first bit is not set, i.e. invalid
|
||||
StatusBits.reset(Valid);
|
||||
clearAttributes();
|
||||
_pcTwinPointer = 0;
|
||||
_pcTwinPointer = nullptr;
|
||||
}
|
||||
|
||||
bool isValid() {
|
||||
|
||||
@@ -18,10 +18,6 @@ is provided on an as is basis, without warranties of any kind.
|
||||
#include <eval.h>
|
||||
#include <frameobject.h>
|
||||
|
||||
#if PY_VERSION_HEX <= 0x02050000
|
||||
#error "Use Python2.5.x or higher"
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* RUN EMBEDDED OBJECT METHODS, ACCESS OBJECT ATTRIBUTES
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
# include <cstdio>
|
||||
# include <cstring>
|
||||
#ifdef __GNUC__
|
||||
# include <stdint.h>
|
||||
# include <cstdint>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -582,6 +582,7 @@ PyStreambuf::int_type PyStreambuf::underflow()
|
||||
// wrong type
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
n = c.size();
|
||||
if (n == 0) {
|
||||
return traits_type::eof();
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
using namespace Base;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string UnitPy::representation(void) const
|
||||
std::string UnitPy::representation() const
|
||||
{
|
||||
const UnitSignature & Sig = getUnitPtr()->getSignature();
|
||||
std::stringstream ret;
|
||||
@@ -125,18 +125,18 @@ PyObject* UnitPy::number_add_handler(PyObject *self, PyObject *other)
|
||||
{
|
||||
if (!PyObject_TypeCheck(self, &(UnitPy::Type))) {
|
||||
PyErr_SetString(PyExc_TypeError, "First arg must be Unit");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
if (!PyObject_TypeCheck(other, &(UnitPy::Type))) {
|
||||
PyErr_SetString(PyExc_TypeError, "Second arg must be Unit");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
Base::Unit *a = static_cast<UnitPy*>(self)->getUnitPtr();
|
||||
Base::Unit *b = static_cast<UnitPy*>(other)->getUnitPtr();
|
||||
|
||||
if (*a != *b) {
|
||||
PyErr_SetString(PyExc_TypeError, "Units not matching!");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new UnitPy(new Unit(*a));
|
||||
@@ -146,18 +146,18 @@ PyObject* UnitPy::number_subtract_handler(PyObject *self, PyObject *other)
|
||||
{
|
||||
if (!PyObject_TypeCheck(self, &(UnitPy::Type))) {
|
||||
PyErr_SetString(PyExc_TypeError, "First arg must be Unit");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
if (!PyObject_TypeCheck(other, &(UnitPy::Type))) {
|
||||
PyErr_SetString(PyExc_TypeError, "Second arg must be Unit");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
Base::Unit *a = static_cast<UnitPy*>(self)->getUnitPtr();
|
||||
Base::Unit *b = static_cast<UnitPy*>(other)->getUnitPtr();
|
||||
|
||||
if (*a != *b) {
|
||||
PyErr_SetString(PyExc_TypeError, "Units not matching!");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new UnitPy(new Unit(*a));
|
||||
@@ -167,7 +167,7 @@ PyObject* UnitPy::number_multiply_handler(PyObject *self, PyObject *other)
|
||||
{
|
||||
if (!PyObject_TypeCheck(self, &(UnitPy::Type))) {
|
||||
PyErr_SetString(PyExc_TypeError, "First arg must be Unit");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (PyObject_TypeCheck(other, &(UnitPy::Type))) {
|
||||
@@ -178,7 +178,7 @@ PyObject* UnitPy::number_multiply_handler(PyObject *self, PyObject *other)
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "A Unit can only be multiplied by a Unit");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,11 +189,11 @@ PyObject* UnitPy::richCompare(PyObject *v, PyObject *w, int op)
|
||||
const Unit * u1 = static_cast<UnitPy*>(v)->getUnitPtr();
|
||||
const Unit * u2 = static_cast<UnitPy*>(w)->getUnitPtr();
|
||||
|
||||
PyObject *res=0;
|
||||
PyObject *res=nullptr;
|
||||
if (op != Py_EQ && op != Py_NE) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"no ordering relation is defined for Units");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
else if (op == Py_EQ) {
|
||||
res = (*u1 == *u2) ? Py_True : Py_False;
|
||||
@@ -213,12 +213,12 @@ PyObject* UnitPy::richCompare(PyObject *v, PyObject *w, int op)
|
||||
}
|
||||
}
|
||||
|
||||
Py::String UnitPy::getType(void) const
|
||||
Py::String UnitPy::getType() const
|
||||
{
|
||||
return Py::String(getUnitPtr()->getTypeString().toUtf8(),"utf-8");
|
||||
}
|
||||
|
||||
Py::Tuple UnitPy::getSignature(void) const
|
||||
Py::Tuple UnitPy::getSignature() const
|
||||
{
|
||||
const UnitSignature & Sig = getUnitPtr()->getSignature();
|
||||
Py::Tuple tuple(8);
|
||||
@@ -237,7 +237,7 @@ Py::Tuple UnitPy::getSignature(void) const
|
||||
|
||||
PyObject *UnitPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int UnitPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
@@ -248,43 +248,43 @@ int UnitPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
PyObject * UnitPy::number_divide_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * UnitPy::number_remainder_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * UnitPy::number_divmod_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * UnitPy::number_power_handler (PyObject* /*self*/, PyObject* /*other*/, PyObject* /*modulo*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * UnitPy::number_negative_handler (PyObject* /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * UnitPy::number_positive_handler (PyObject* /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * UnitPy::number_absolute_handler (PyObject* /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int UnitPy::number_nonzero_handler (PyObject* /*self*/)
|
||||
@@ -295,47 +295,47 @@ int UnitPy::number_nonzero_handler (PyObject* /*self*/)
|
||||
PyObject * UnitPy::number_invert_handler (PyObject* /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * UnitPy::number_lshift_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * UnitPy::number_rshift_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * UnitPy::number_and_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * UnitPy::number_xor_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * UnitPy::number_or_handler (PyObject* /*self*/, PyObject* /*other*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * UnitPy::number_int_handler (PyObject* /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject * UnitPy::number_float_handler (PyObject* /*self*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user