Michele De Stefano's C++ Utilities
tuple.i
1 // mds_utils/python/tuple.i
2 //
3 // Copyright (c) 2014 - Michele De Stefano (micdestefano@users.sourceforge.net)
4 //
5 // Distributed under the MIT License (See accompanying file LICENSE)
6 
7 %include "mds_utils/python/obj.i"
8 
9 %typemap(in) (mds_utils::python::Tuple) {
10  try {
11  if (!PyTuple_Check($input)) {
12  throw std::invalid_argument("The tuple argument is not a tuple.");
13  }
14  $1 = $input;
15  } catch (std::exception& e) {
16  PyErr_SetString(PyExc_RuntimeError,e.what());
17  SWIG_fail;
18  }
19 }
20 
21 %typemap(out) mds_utils::python::Tuple = mds_utils::python::Obj;
22 
23 %typecheck(SWIG_TYPECHECK_POINTER) mds_utils::python::Sequence {
24  $1 = PyTuple_Check($input);
25 }