Michele De Stefano's C++ Utilities
sequence.i
1 // mds_utils/python/sequence.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 %header %{
10 
11 #include <mds_utils/python/sequence.hpp>
12 
13 %}
14 
15 %typemap(in) (mds_utils::python::Sequence) {
16  try {
17  if (!PySequence_Check($input)) {
18  throw std::invalid_argument("The sequence argument is not a sequence.");
19  }
20  $1 = $input;
21  } catch (std::exception& e) {
22  PyErr_SetString(PyExc_RuntimeError,e.what());
23  SWIG_fail;
24  }
25 }
26 
27 %typemap(out) mds_utils::python::Sequence = mds_utils::python::Obj;
28 
29 %typecheck(SWIG_TYPECHECK_POINTER) mds_utils::python::Sequence {
30  $1 = PySequence_Check($input);
31 }
32