python: Add std::vector<std::string> support (Fix #2453)
This commit is contained in:
@@ -218,6 +218,14 @@ inline int SwigPyIntOrLong_Check(PyObject* o) {
|
||||
); // NOLINT
|
||||
}
|
||||
|
||||
inline int SwigString_Check(PyObject* o) {
|
||||
#if PY_VERSION_HEX >= 0x03030000
|
||||
return PyUnicode_Check(o);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline PyObject* SwigString_FromString(const std::string& s) {
|
||||
return PyString_FromStringAndSize(s.data(), s.size());
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@
|
||||
PY_LIST_INPUT_OUTPUT_TYPEMAP(int, PyInt_Check, PyInt_FromLong);
|
||||
PY_LIST_INPUT_OUTPUT_TYPEMAP(int64, SwigPyIntOrLong_Check, PyLong_FromLongLong);
|
||||
PY_LIST_INPUT_OUTPUT_TYPEMAP(double, PyFloat_Check, PyFloat_FromDouble);
|
||||
PY_LIST_INPUT_OUTPUT_TYPEMAP(std::string, SwigString_Check, SwigString_FromString);
|
||||
|
||||
// Add conversion list(tuple(int)) -> std::vector<std::vector>.
|
||||
// TODO(user): see if we can also get rid of this and utilize already
|
||||
|
||||
Reference in New Issue
Block a user