Commit ec8d47ea authored by Joseph Mirabel's avatar Joseph Mirabel Committed by olivier stasse
Browse files

Bind vector of Values from C++ to Python

At the moment, it is not possible to bind from Python to C++. See TODO
parent d48a3221
......@@ -215,6 +215,12 @@ command::Value pythonToValue(PyObject* pyObject, const command::Value::Type& val
return Value(m4);
case (Value::VALUES):
// TODO the vector of values cannot be built since
// - the value type inside the vector are not know
// - inferring the value type from the Python type is not implemented.
throw ExceptionPython(ExceptionPython::VALUE_PARSING, "not implemented: cannot create a vector of values");
std::cerr << "Only int, double and string are supported." << std::endl;
......@@ -256,6 +262,15 @@ PyObject* matrix4dToPython(const Eigen::Matrix4d& matrix) {
return tuple;
PyObject* valuesToPython(const dynamicgraph::command::Values& vector) {
PyObject* tuple = PyTuple_New(vector.size());
for (std::size_t index = 0; index < vector.size(); index++) {
PyObject* item = valueToPython(vector[index]);
PyTuple_SET_ITEM(tuple, index, item);
return tuple;
PyObject* valueToPython(const command::Value& value) {
using command::Value;
bool boolValue;
......@@ -298,6 +313,8 @@ PyObject* valueToPython(const command::Value& value) {
case (Value::MATRIX4D):
matrix4dValue = value.value();
return matrix4dToPython(matrix4dValue);
case (Value::VALUES):
return valuesToPython(value.constValuesValue());
return Py_BuildValue("");
Supports Markdown
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