diff --git a/src/convert-dg-to-py.cc b/src/convert-dg-to-py.cc index 6a6fe8e8fbcf092ab3d49c017b05d0aa18a5cf3b..249e6a75707441605f8f2f9b1f2c52a6239c19d1 100644 --- a/src/convert-dg-to-py.cc +++ b/src/convert-dg-to-py.cc @@ -62,10 +62,10 @@ namespace dynamicgraph { std::string svalue; Vector v; Matrix m; - unsigned int nCols; - unsigned int size; + Py_ssize_t nCols; + Py_ssize_t size; PyObject* row; - unsigned int nRows; + Py_ssize_t nRows; switch (valueType) { case (Value::BOOL) : @@ -81,7 +81,7 @@ namespace dynamicgraph { throw ExceptionPython(ExceptionPython::VALUE_PARSING, "unsigned int"); } - uvalue = PyInt_AsUnsignedLongMask(pyObject); + uvalue = (unsigned int)PyInt_AsUnsignedLongMask(pyObject); return Value(uvalue); break; case (Value::INT) : @@ -109,7 +109,7 @@ namespace dynamicgraph { dvalue = PyFloat_AsDouble(pyObject); return Value(dvalue); } else if (PyInt_Check(pyObject)) { - dvalue = 0.0+PyInt_AS_LONG(pyObject); + dvalue = (double)PyInt_AS_LONG(pyObject); return Value(dvalue); } else { throw ExceptionPython(ExceptionPython::VALUE_PARSING, @@ -162,7 +162,7 @@ namespace dynamicgraph { } nCols = PyTuple_Size(row); - m.resize(nRows, nCols); + m.resize((unsigned int)nRows, (unsigned int)nCols); fillMatrixRow(m, 0, row); for (unsigned int iRow=1; iRow<nRows; iRow++) { diff --git a/src/entity-py.cc b/src/entity-py.cc index d114e30c0ca37feac4fd8f01fce3e88440dd133c..616b31224072cd49ba618455e95b55baf4712721 100644 --- a/src/entity-py.cc +++ b/src/entity-py.cc @@ -193,7 +193,7 @@ namespace dynamicgraph { PyErr_SetString(PyExc_TypeError, "third argument is not a tuple"); return NULL; } - unsigned int size = PyTuple_Size(argTuple); + Py_ssize_t size = PyTuple_Size(argTuple); std::map<const std::string, Command*> commandMap = entity->getNewStyleCommandMap(); @@ -208,13 +208,14 @@ namespace dynamicgraph { Command* command = commandMap[std::string(commandName)]; // Check that tuple size is equal to command number of arguments const std::vector<Value::Type> typeVector = command->valueTypes(); - if (size != typeVector.size()) { - std::stringstream ss; - ss << "command takes " << typeVector.size() - << " parameters, " << size << " given."; - PyErr_SetString(dgpyError, ss.str().c_str()); - return NULL; - } + if ((unsigned)size != typeVector.size()) + { + std::stringstream ss; + ss << "command takes " << typeVector.size() + << " parameters, " << size << " given."; + PyErr_SetString(dgpyError, ss.str().c_str()); + return NULL; + } std::vector<Value> valueVector; for (unsigned int iParam=0; iParam<size; iParam++) { @@ -257,9 +258,10 @@ namespace dynamicgraph { } void* pointer = PyCObject_AsVoidPtr(object); Entity* entity = (Entity*)pointer; - typedef std::map<const std::string, command::Command*> CommandMap; + typedef std::map<const std::string, command::Command*> + CommandMap; CommandMap map = entity->getNewStyleCommandMap(); - unsigned int nbCommands = map.size(); + Py_ssize_t nbCommands = (Py_ssize_t)map.size(); // Create a tuple of same size as the command map PyObject* result = PyTuple_New(nbCommands); unsigned int count = 0; diff --git a/src/factory-py.cc b/src/factory-py.cc index 65b8463e21291cde428f77e1d96b70687d452ccf..76c0f2f7a78d2b4f19b21988e2c3117b8ebf2d01 100644 --- a/src/factory-py.cc +++ b/src/factory-py.cc @@ -34,15 +34,20 @@ namespace dynamicgraph { return NULL; std::vector <std::string> classNames; - dynamicgraph::FactoryStorage::getInstance()->listEntities(classNames); - unsigned int classNumber = classNames.size(); + dynamicgraph::FactoryStorage::getInstance() + ->listEntities(classNames); + + Py_ssize_t classNumber = classNames.size(); // Build a tuple object PyObject* classTuple = PyTuple_New(classNumber); - for (unsigned int iEntity = 0; iEntity < classNames.size(); iEntity++) { - PyObject* className = Py_BuildValue("s", classNames[iEntity].c_str()); - PyTuple_SetItem(classTuple, iEntity, className); - } + for (Py_ssize_t iEntity = 0; + iEntity < (Py_ssize_t)classNames.size(); ++iEntity) + { + PyObject* className = + Py_BuildValue("s", classNames[iEntity].c_str()); + PyTuple_SetItem(classTuple, iEntity, className); + } return Py_BuildValue("O", classTuple); } diff --git a/src/interpreter.cc b/src/interpreter.cc index 7347399780d5dbc0be4e6f2b7aba6d74892ff538..2133b5046b12063c612f07fff1186163704e2f10 100644 --- a/src/interpreter.cc +++ b/src/interpreter.cc @@ -68,11 +68,12 @@ bool HandleErr(std::string & err, PyTuple_SET_ITEM(args, 2, ptraceback); pyerr = PyObject_CallObject(traceback_format_exception, args); assert(PyList_Check(pyerr)); - unsigned int size = PyList_GET_SIZE(pyerr); + Py_ssize_t size = PyList_GET_SIZE(pyerr); std::string stringRes; - for (unsigned int i=0; i<size; i++) { - stringRes += std::string(PyString_AsString(PyList_GET_ITEM(pyerr, i))); - } + for (Py_ssize_t i=0; i<size; ++i) + stringRes += std::string + (PyString_AsString(PyList_GET_ITEM(pyerr, i))); + pyerr = PyString_FromString(stringRes.c_str()); err = PyString_AsString(pyerr); dgDEBUG(15) << "err: " << err << std::endl; diff --git a/src/signal-caster-py.cc b/src/signal-caster-py.cc index fdc70de66847a4d9fd00ec428484f0f3664700e7..6631d5c2ceb64b3b7866c27e509dd46c4343c8eb 100644 --- a/src/signal-caster-py.cc +++ b/src/signal-caster-py.cc @@ -29,13 +29,15 @@ namespace dynamicgraph { return NULL; std::vector<std::string> typeList = dynamicgraph::SignalCaster::getInstance()->listTypenames(); - unsigned int typeNumber = typeList.size(); + Py_ssize_t typeNumber = typeList.size(); // Build a tuple object PyObject* typeTuple = PyTuple_New(typeNumber); - for (unsigned int iType = 0; iType < typeNumber; iType++) { - PyObject* className = Py_BuildValue("s", typeList[iType].c_str()); - PyTuple_SetItem(typeTuple, iType, className); + for (Py_ssize_t iType = 0; iType < typeNumber; ++iType) + { + PyObject* className = + Py_BuildValue("s", typeList[iType].c_str()); + PyTuple_SetItem(typeTuple, iType, className); } return Py_BuildValue("O", typeTuple);