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 SWIG_STATIC_INLINE PyObject*
43 SPyObj_FromLongLong(long long value)
45 return (value > (long)(LONG_MAX)) ?
46 PyLong_FromLongLong(value) : PyInt_FromLong((long)value);
49 SWIG_STATIC_INLINE PyObject*
50 SPyObj_FromUnsignedLong(unsigned long value)
52 return (value > (unsigned long)(LONG_MAX)) ?
53 PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)value);
56 SWIG_STATIC_INLINE PyObject*
57 SPyObj_FromUnsignedLongLong(unsigned long long value)
59 return (value > (unsigned long long)(LONG_MAX)) ?
60 PyLong_FromUnsignedLongLong(value) : PyInt_FromLong((long)value);
63 SWIG_STATIC_INLINE long
64 SPyObj_AsLongInRange(PyObject * obj, long min_value, long max_value)
66 long value = SPyObj_AsLong(obj);
67 if (!PyErr_Occurred()) {
68 if (value < min_value) {
69 PyErr_SetString(PyExc_OverflowError,"value is smaller than type minimum");
70 } else if (value > max_value) {
71 PyErr_SetString(PyExc_OverflowError,"value is greater than type maximum");
77 SWIG_STATIC_INLINE unsigned long
78 SPyObj_AsUnsignedLongInRange(PyObject *obj, unsigned long max_value)
80 unsigned long value = SPyObj_AsUnsignedLong(obj);
81 if (!PyErr_Occurred()) {
82 if (value > max_value) {
83 PyErr_SetString(PyExc_OverflowError,"value is greater than type maximum");
89 SWIG_STATIC_INLINE signed char
90 SPyObj_AsSignedChar(PyObject *obj) {
91 return SPyObj_AsLongInRange(obj, SCHAR_MIN, SCHAR_MAX);
94 SWIG_STATIC_INLINE short
95 SPyObj_AsShort(PyObject *obj) {
96 return SPyObj_AsLongInRange(obj, SHRT_MIN, SHRT_MAX);
99 SWIG_STATIC_INLINE int
100 SPyObj_AsInt(PyObject *obj) {
101 return SPyObj_AsLongInRange(obj, INT_MIN, INT_MAX);
104 SWIG_STATIC_INLINE unsigned char
105 SPyObj_AsUnsignedChar(PyObject *obj) {
106 return SPyObj_AsUnsignedLongInRange(obj, UCHAR_MAX);
109 SWIG_STATIC_INLINE unsigned short
110 SPyObj_AsUnsignedShort(PyObject *obj) {
111 return SPyObj_AsUnsignedLongInRange(obj, USHRT_MAX);
114 SWIG_STATIC_INLINE unsigned int
115 SPyObj_AsUnsignedInt(PyObject *obj) {
116 return SPyObj_AsUnsignedLongInRange(obj, UINT_MAX);
119 SWIG_STATIC_INLINE long long
120 SPyObj_AsLongLong(PyObject *obj) {
121 return PyInt_Check(obj) ?
122 PyInt_AsLong(obj) : PyLong_AsLongLong(obj);
125 SWIG_STATIC_INLINE unsigned long long
126 SPyObj_AsUnsignedLongLong(PyObject *obj) {
127 return PyLong_Check(obj) ?
128 PyLong_AsUnsignedLongLong(obj) : SPyObj_AsUnsignedLong(obj);
131 SWIG_STATIC_INLINE double
132 SPyObj_AsDouble(PyObject *obj) {
133 return (PyFloat_Check(obj)) ? PyFloat_AsDouble(obj) :
134 (double)((PyInt_Check(obj)) ? PyInt_AsLong(obj) : PyLong_AsLongLong(obj));
137 SWIG_STATIC_INLINE float
138 SPyObj_AsFloat(PyObject *obj) {
139 double value = SPyObj_AsDouble(obj);
140 if (!PyErr_Occurred()) {
141 if (value < FLT_MIN) {
142 PyErr_SetString(PyExc_OverflowError,"float is smaller than flt_min");
143 } else if (value > FLT_MAX) {
144 PyErr_SetString(PyExc_OverflowError,"float is greater than flt_max");
147 return (float) value;
150 SWIG_STATIC_INLINE char
151 SPyObj_AsChar(PyObject *obj) {
152 char c = (PyString_Check(obj) && PyString_Size(obj) == 1) ?
153 PyString_AsString(obj)[0]
154 : (char) SPyObj_AsLongInRange(obj, CHAR_MIN, CHAR_MAX);
155 if (PyErr_Occurred()) {
157 PyErr_SetString(PyExc_TypeError, "a char is required");
162 SWIG_STATIC_INLINE PyObject *
163 SPyObj_FromChar(char c) {
164 return PyString_FromStringAndSize(&c,1);
167 SWIG_STATIC_INLINE PyObject *
168 SPyObj_FromCharPtr(const char* cptr) {
169 return cptr ? PyString_FromString(cptr) : Py_BuildValue((char*)"");
172 SWIG_STATIC_INLINE int
173 SPyObj_AsBool(PyObject *obj) {
174 return SPyObj_AsLongLong(obj) ? 1 : 0;
183 #define SWIG_PY_INT 1
184 #define SWIG_PY_FLOAT 2
185 #define SWIG_PY_STRING 3
186 #define SWIG_PY_POINTER 4
187 #define SWIG_PY_BINARY 5
189 /* Flags for pointer conversion */
191 #define SWIG_POINTER_EXCEPTION 0x1
192 #define SWIG_POINTER_DISOWN 0x2
194 /* Exception handling in wrappers */
195 #define SWIG_fail goto fail
197 /* Constant information structure */
198 typedef struct swig_const_info {
204 swig_type_info **ptype;
207 /* Common SWIG API */
208 #define SWIG_ConvertPtr(obj, pp, type, flags) \
209 SWIG_Python_ConvertPtr(obj, pp, type, flags)
210 #define SWIG_NewPointerObj(p, type, flags) \
211 SWIG_Python_NewPointerObj(p, type, flags)
212 #define SWIG_MustGetPtr(p, type, argnum, flags) \
213 SWIG_Python_MustGetPtr(p, type, argnum, flags)
215 /* Python-specific SWIG API */
216 #define SWIG_newvarlink() \
217 SWIG_Python_newvarlink()
218 #define SWIG_addvarlink(p, name, get_attr, set_attr) \
219 SWIG_Python_addvarlink(p, name, get_attr, set_attr)
220 #define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) \
221 SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
222 #define SWIG_NewPackedObj(ptr, sz, type) \
223 SWIG_Python_NewPackedObj(ptr, sz, type)
224 #define SWIG_InstallConstants(d, constants) \
225 SWIG_Python_InstallConstants(d, constants)
228 SWIGIMPORT(int) SWIG_Python_ConvertPtr(PyObject *, void **, swig_type_info *, int);
229 SWIGIMPORT(PyObject *) SWIG_Python_NewPointerObj(void *, swig_type_info *,int own);
230 SWIGIMPORT(void *) SWIG_Python_MustGetPtr(PyObject *, swig_type_info *, int, int);
231 SWIGIMPORT(PyObject *) SWIG_Python_newvarlink(void);
232 SWIGIMPORT(void) SWIG_Python_addvarlink(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *));
233 SWIGIMPORT(int) SWIG_Python_ConvertPacked(PyObject *, void *, int sz, swig_type_info *, int);
234 SWIGIMPORT(PyObject *) SWIG_Python_NewPackedObj(void *, int sz, swig_type_info *);
235 SWIGIMPORT(void) SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]);
239 /* Contract support */
241 #define SWIG_contract_assert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else