1 /***********************************************************************
2 * pyrun.swg for wxPython
4 * Include only the function prototypes and such from SWIG's pyrun.swg,
5 * but not the runtime functions themselves. This helps keep the
6 * wrapper files clean of unnecessary stuff that is in the libpy.c file
9 ************************************************************************/
17 #define SWIG_STATIC_INLINE static inline
19 #define SWIG_STATIC_INLINE static
22 SWIG_STATIC_INLINE long
23 SPyObj_AsLong(PyObject * obj)
25 return PyInt_Check(obj) ? PyInt_AsLong(obj) : PyLong_AsLong(obj);
28 SWIG_STATIC_INLINE unsigned long
29 SPyObj_AsUnsignedLong(PyObject * obj)
31 if (PyLong_Check(obj)) {
32 return PyLong_AsUnsignedLong(obj);
34 long i = PyInt_AsLong(obj);
35 if ( !PyErr_Occurred() && (i < 0)) {
36 PyErr_SetString(PyExc_TypeError, "negative value for unsigned type");
42 #if !defined(_MSC_VER)
43 SWIG_STATIC_INLINE PyObject*
44 SPyObj_FromLongLong(long long value)
46 return (value > (long)(LONG_MAX)) ?
47 PyLong_FromLongLong(value) : PyInt_FromLong((long)value);
51 SWIG_STATIC_INLINE PyObject*
52 SPyObj_FromUnsignedLong(unsigned long value)
54 return (value > (unsigned long)(LONG_MAX)) ?
55 PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)value);
58 #if !defined(_MSC_VER)
59 SWIG_STATIC_INLINE PyObject*
60 SPyObj_FromUnsignedLongLong(unsigned long long value)
62 return (value > (unsigned long long)(LONG_MAX)) ?
63 PyLong_FromUnsignedLongLong(value) : PyInt_FromLong((long)value);
67 SWIG_STATIC_INLINE long
68 SPyObj_AsLongInRange(PyObject * obj, long min_value, long max_value)
70 long value = SPyObj_AsLong(obj);
71 if (!PyErr_Occurred()) {
72 if (value < min_value) {
73 PyErr_SetString(PyExc_OverflowError,"value is smaller than type minimum");
74 } else if (value > max_value) {
75 PyErr_SetString(PyExc_OverflowError,"value is greater than type maximum");
81 SWIG_STATIC_INLINE unsigned long
82 SPyObj_AsUnsignedLongInRange(PyObject *obj, unsigned long max_value)
84 unsigned long value = SPyObj_AsUnsignedLong(obj);
85 if (!PyErr_Occurred()) {
86 if (value > max_value) {
87 PyErr_SetString(PyExc_OverflowError,"value is greater than type maximum");
93 SWIG_STATIC_INLINE signed char
94 SPyObj_AsSignedChar(PyObject *obj) {
95 return (signed char)SPyObj_AsLongInRange(obj, SCHAR_MIN, SCHAR_MAX);
98 SWIG_STATIC_INLINE short
99 SPyObj_AsShort(PyObject *obj) {
100 return (short)SPyObj_AsLongInRange(obj, SHRT_MIN, SHRT_MAX);
103 SWIG_STATIC_INLINE int
104 SPyObj_AsInt(PyObject *obj) {
105 return SPyObj_AsLongInRange(obj, INT_MIN, INT_MAX);
108 SWIG_STATIC_INLINE unsigned char
109 SPyObj_AsUnsignedChar(PyObject *obj) {
110 return (unsigned char)SPyObj_AsUnsignedLongInRange(obj, UCHAR_MAX);
113 SWIG_STATIC_INLINE unsigned short
114 SPyObj_AsUnsignedShort(PyObject *obj) {
115 return (unsigned short)SPyObj_AsUnsignedLongInRange(obj, USHRT_MAX);
118 SWIG_STATIC_INLINE unsigned int
119 SPyObj_AsUnsignedInt(PyObject *obj) {
120 return SPyObj_AsUnsignedLongInRange(obj, UINT_MAX);
123 #if !defined(_MSC_VER)
124 SWIG_STATIC_INLINE long long
125 SPyObj_AsLongLong(PyObject *obj) {
126 return PyInt_Check(obj) ?
127 PyInt_AsLong(obj) : PyLong_AsLongLong(obj);
130 SWIG_STATIC_INLINE unsigned long long
131 SPyObj_AsUnsignedLongLong(PyObject *obj) {
132 return PyLong_Check(obj) ?
133 PyLong_AsUnsignedLongLong(obj) : SPyObj_AsUnsignedLong(obj);
137 SWIG_STATIC_INLINE double
138 SPyObj_AsDouble(PyObject *obj) {
139 return (PyFloat_Check(obj)) ? PyFloat_AsDouble(obj) :
140 (double)((PyInt_Check(obj)) ? PyInt_AsLong(obj) : PyLong_AsLongLong(obj));
143 SWIG_STATIC_INLINE float
144 SPyObj_AsFloat(PyObject *obj) {
145 double value = SPyObj_AsDouble(obj);
146 if (!PyErr_Occurred()) {
147 if (value < FLT_MIN) {
148 PyErr_SetString(PyExc_OverflowError,"float is smaller than flt_min");
149 } else if (value > FLT_MAX) {
150 PyErr_SetString(PyExc_OverflowError,"float is greater than flt_max");
153 return (float) value;
156 SWIG_STATIC_INLINE char
157 SPyObj_AsChar(PyObject *obj) {
158 char c = (PyString_Check(obj) && PyString_Size(obj) == 1) ?
159 PyString_AsString(obj)[0]
160 : (char) SPyObj_AsLongInRange(obj, CHAR_MIN, CHAR_MAX);
161 if (PyErr_Occurred()) {
163 PyErr_SetString(PyExc_TypeError, "a char is required");
168 SWIG_STATIC_INLINE PyObject *
169 SPyObj_FromChar(char c) {
170 return PyString_FromStringAndSize(&c,1);
173 SWIG_STATIC_INLINE PyObject *
174 SPyObj_FromCharPtr(const char* cptr) {
175 return cptr ? PyString_FromString(cptr) : Py_BuildValue((char*)"");
178 SWIG_STATIC_INLINE int
179 SPyObj_AsBool(PyObject *obj) {
180 return SPyObj_AsLong/*Long*/(obj) ? 1 : 0;
189 #define SWIG_PY_INT 1
190 #define SWIG_PY_FLOAT 2
191 #define SWIG_PY_STRING 3
192 #define SWIG_PY_POINTER 4
193 #define SWIG_PY_BINARY 5
195 /* Flags for pointer conversion */
197 #define SWIG_POINTER_EXCEPTION 0x1
198 #define SWIG_POINTER_DISOWN 0x2
200 /* Exception handling in wrappers */
201 #define SWIG_fail goto fail
203 /* Constant information structure */
204 typedef struct swig_const_info {
210 swig_type_info **ptype;
213 /* Common SWIG API */
214 #define SWIG_ConvertPtr(obj, pp, type, flags) \
215 SWIG_Python_ConvertPtr(obj, pp, type, flags)
216 #define SWIG_NewPointerObj(p, type, flags) \
217 SWIG_Python_NewPointerObj(p, type, flags)
218 #define SWIG_MustGetPtr(p, type, argnum, flags) \
219 SWIG_Python_MustGetPtr(p, type, argnum, flags)
221 /* Python-specific SWIG API */
222 #define SWIG_newvarlink() \
223 SWIG_Python_newvarlink()
224 #define SWIG_addvarlink(p, name, get_attr, set_attr) \
225 SWIG_Python_addvarlink(p, name, get_attr, set_attr)
226 #define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) \
227 SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
228 #define SWIG_NewPackedObj(ptr, sz, type) \
229 SWIG_Python_NewPackedObj(ptr, sz, type)
230 #define SWIG_InstallConstants(d, constants) \
231 SWIG_Python_InstallConstants(d, constants)
234 SWIGIMPORT(int) SWIG_Python_ConvertPtr(PyObject *, void **, swig_type_info *, int);
235 SWIGIMPORT(PyObject *) SWIG_Python_NewPointerObj(void *, swig_type_info *,int own);
236 SWIGIMPORT(void *) SWIG_Python_MustGetPtr(PyObject *, swig_type_info *, int, int);
237 SWIGIMPORT(PyObject *) SWIG_Python_newvarlink(void);
238 SWIGIMPORT(void) SWIG_Python_addvarlink(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *));
239 SWIGIMPORT(int) SWIG_Python_ConvertPacked(PyObject *, void *, int sz, swig_type_info *, int);
240 SWIGIMPORT(PyObject *) SWIG_Python_NewPackedObj(void *, int sz, swig_type_info *);
241 SWIGIMPORT(void) SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]);
245 /* Contract support */
247 #define SWIG_contract_assert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else