1 // sequence_iterator_example.i
     3 // Copyright (c) 2012 - Michele De Stefano (micdestefano@users.sourceforge.net)
     5 // Distributed under the MIT License (See accompanying file LICENSE)
     8  * Instructions for generating and building the extension:
    10  * 1. swig -c++ -Wall -python -I../../../include -o sequence_iterator_example_wrap.cpp sequence_iterator_example.i
    12  * 2. python setup.py build
    17  * \example    sequence_iterator_example.i
    19  * A simple SWIG interface for a Python extension module that shows the
    20  * mds_utils::python::PySequenceIterator usage.
    22  * \remarks    Here I've used SWIG for convenience only. The
    23  *             mds_utils::python::PySequenceIterator does not impose you
    28 %module sequence_iterator_test
    30 // Include the following interface files for having the proper typemaps
    31 %include "mds_utils/python/common.i"
    34 #include <mds_utils/python/sequence_iterator.hpp>
    37  * The source code of the following two files is into the
    38  * "examples/python" directory.
    40 #include "print_seq.hpp"
    41 #include "incr_seq.hpp"
    43  using namespace mds_utils::python;
    47 void print_seq(InIt,InIt);
    50 void incr_seq(InIt,InIt);
    53 %typemap(in) (PySequenceIterator<double>,PySequenceIterator<double>) {
    55        $1 = PySequenceIterator<double>($input);
    56        $2 = PySequenceIterator<double>($input,true);
    57    } catch (std::exception& e) {
    58        PyErr_SetString(PyExc_RuntimeError,e.what());
    63 %typemap(in) (PySequenceIterator< std::complex<double> >,PySequenceIterator< std::complex<double> >) {
    65        $1 = PySequenceIterator< std::complex<double> >($input);
    66        $2 = PySequenceIterator< std::complex<double> >($input,true);
    67    } catch (std::exception& e) {
    68        PyErr_SetString(PyExc_RuntimeError,e.what());
    74 %template(print_seq_d) print_seq< PySequenceIterator<double> >;
    76 %template(print_seq_cplx) print_seq< PySequenceIterator< std::complex<double> > >;
    78 %template(incr_seq_d) incr_seq< PySequenceIterator<double> >;
    80 %template(incr_seq_cplx) incr_seq< PySequenceIterator< std::complex<double> > >;