OLD | NEW |
(Empty) | |
| 1 /* ------------------------------------------------------------ |
| 2 * Typemap specializations for Python |
| 3 * ------------------------------------------------------------ */ |
| 4 |
| 5 /* ------------------------------------------------------------ |
| 6 * Fragment section |
| 7 * ------------------------------------------------------------ */ |
| 8 /* bool is dangerous in Python, change precedence */ |
| 9 #undef SWIG_TYPECHECK_BOOL |
| 10 %define SWIG_TYPECHECK_BOOL 10000 %enddef |
| 11 |
| 12 /* Include fundamental fragemt definitions */ |
| 13 %include <typemaps/fragments.swg> |
| 14 |
| 15 /* Look for user fragments file. */ |
| 16 %include <pyfragments.swg> |
| 17 |
| 18 /* Python fragments for fundamental types */ |
| 19 %include <pyprimtypes.swg> |
| 20 |
| 21 /* Python fragments for char* strings */ |
| 22 %include <pystrings.swg> |
| 23 |
| 24 /* Backward compatibility output helper */ |
| 25 %fragment("t_output_helper","header") %{ |
| 26 #define t_output_helper SWIG_Python_AppendOutput |
| 27 %} |
| 28 |
| 29 |
| 30 /* ------------------------------------------------------------ |
| 31 * Unified typemap section |
| 32 * ------------------------------------------------------------ */ |
| 33 |
| 34 /* directors are supported in Python */ |
| 35 #ifndef SWIG_DIRECTOR_TYPEMAPS |
| 36 #define SWIG_DIRECTOR_TYPEMAPS |
| 37 #endif |
| 38 |
| 39 |
| 40 /* Python types */ |
| 41 #define SWIG_Object PyObject * |
| 42 #define VOID_Object SWIG_Py_Void() |
| 43 |
| 44 /* Python allows implicit conversion */ |
| 45 #define %implicitconv_flag $implicitconv |
| 46 |
| 47 |
| 48 /* Overload of the output/constant/exception/dirout handling */ |
| 49 |
| 50 /* append output */ |
| 51 #define SWIG_AppendOutput(result, obj) SWIG_Python_AppendOutput(result, obj) |
| 52 |
| 53 /* set constant */ |
| 54 #define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, name,obj) |
| 55 |
| 56 /* raise */ |
| 57 #define SWIG_Raise(obj, type, desc) SWIG_Python_Raise(obj, type, desc) |
| 58 |
| 59 /* Include the unified typemap library */ |
| 60 %include <typemaps/swigtypemaps.swg> |
| 61 |
| 62 |
| 63 /* ------------------------------------------------------------ |
| 64 * Python extra typemaps |
| 65 * ------------------------------------------------------------ */ |
| 66 |
| 67 /* Get the address of the 'python self' object */ |
| 68 |
| 69 %typemap(in,numinputs=0,noblock=1) PyObject **PYTHON_SELF { |
| 70 $1 = &$self; |
| 71 } |
| 72 |
| 73 |
| 74 /* Consttab, needed for callbacks, it should be removed later */ |
| 75 |
| 76 %typemap(consttab) SWIGTYPE ((*)(ANY)) |
| 77 { SWIG_PY_POINTER, (char*)"$symname", 0, 0, (void *)($value), &$descriptor } |
| 78 |
| 79 %typemap(constcode) SWIGTYPE ((*)(ANY)) ""; |
| 80 |
| 81 |
| 82 /* Smart Pointers */ |
| 83 %typemap(out,noblock=1) const SWIGTYPE & SMARTPOINTER { |
| 84 $result = SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTE
R_OWN | %newpointer_flags); |
| 85 } |
| 86 |
| 87 %typemap(ret,noblock=1) const SWIGTYPE & SMARTPOINTER, SWIGTYPE SMARTPOINTER { |
| 88 if ($result) { |
| 89 PyObject *robj = PyObject_CallMethod($result, (char *)"__deref__", NULL); |
| 90 if (robj && !PyErr_Occurred()) { |
| 91 SwigPyObject_append((PyObject *) SWIG_Python_GetSwigThis($result), |
| 92 (PyObject *) SWIG_Python_GetSwigThis(robj)); |
| 93 Py_DECREF(robj); |
| 94 } |
| 95 } |
| 96 } |
| 97 |
| 98 |
OLD | NEW |