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#if defined(SWIGPYTHON_BUILTIN)
55#define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, name,obj)
56#else
57#define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, name,obj)
58#endif
59
60/* raise */
61#define SWIG_Raise(obj, type, desc)     SWIG_Python_Raise(obj, type, desc)
62
63/* Include the unified typemap library */
64%include <typemaps/swigtypemaps.swg>
65
66
67/*  ------------------------------------------------------------
68 *  Python extra typemaps / typemap overrides
69 * ------------------------------------------------------------ */
70
71/* Get the address of the 'python self' object */
72
73%typemap(in,numinputs=0,noblock=1) PyObject **PYTHON_SELF {
74  $1 = &$self;
75}
76
77
78/* Consttab, needed for callbacks, it should be removed later */
79
80%typemap(consttab) SWIGTYPE ((*)(ANY))
81{ SWIG_PY_POINTER, (char*)"$symname", 0, 0, (void *)($value), &$descriptor }
82
83%typemap(constcode) SWIGTYPE ((*)(ANY)) "";
84
85
86/* Smart Pointers */
87%typemap(out,noblock=1) const SWIGTYPE & SMARTPOINTER  {
88  $result = SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags);
89}
90
91%typemap(ret,noblock=1) const SWIGTYPE & SMARTPOINTER, SWIGTYPE SMARTPOINTER {
92  if ($result) {
93    PyObject *robj = PyObject_CallMethod($result, (char *)"__deref__", NULL);
94    if (robj && !PyErr_Occurred()) {
95      SwigPyObject_append((PyObject *) SWIG_Python_GetSwigThis($result),
96			  (PyObject *) SWIG_Python_GetSwigThis(robj));
97      Py_DECREF(robj);
98    }
99  }
100}
101
102