Michele De Stefano's C++ Utilities
fileobj.i
1 // mds_utils/python/fileobj.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/fileobj.hpp>
12 
13 %}
14 
15 %typemap(in) (mds_utils::python::FileObj) {
16  try {
17  $1 = $input;
18  $1.incref();
19  } catch (std::exception& e) {
20  PyErr_SetString(PyExc_RuntimeError,e.what());
21  SWIG_fail;
22  }
23 }
24 
25 %typemap(out) mds_utils::python::FileObj = mds_utils::python::Obj;
26 
27 %typecheck(SWIG_TYPECHECK_POINTER) mds_utils::python::Sequence {
28  $1 = PyFile_Check($input);
29 }