X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/98fb9b71198a4850cc88fd00705645e4d37f9bf2..1b35fec738ef02e1d0a5419466c42ccbb13b6676:/wxPython/src/libpy.c diff --git a/wxPython/src/libpy.c b/wxPython/src/libpy.c index 520f4a8c08..9c0149bcff 100644 --- a/wxPython/src/libpy.c +++ b/wxPython/src/libpy.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.20 + * Version 1.3.22 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -30,8 +30,9 @@ #define SWIG_TypeName SWIG_Python_TypeName #define SWIG_TypeQuery SWIG_Python_TypeQuery #define SWIG_TypeClientData SWIG_Python_TypeClientData -#define SWIG_PackData SWIG_Python_PackData -#define SWIG_UnpackData SWIG_Python_UnpackData +#define SWIG_PackData SWIG_Python_PackData +#define SWIG_UnpackData SWIG_Python_UnpackData + /*********************************************************************** * common.swg @@ -278,6 +279,7 @@ SWIG_UnpackData(char *c, void *ptr, int sz) { } #endif + /*********************************************************************** * python.swg * @@ -325,7 +327,7 @@ typedef struct swig_const_info { SWIG_Python_NewPointerObj(p, type, flags) #define SWIG_MustGetPtr(p, type, argnum, flags) \ SWIG_Python_MustGetPtr(p, type, argnum, flags) - + /* Python-specific SWIG API */ #define SWIG_newvarlink() \ SWIG_Python_newvarlink() @@ -338,6 +340,8 @@ typedef struct swig_const_info { #define SWIG_InstallConstants(d, constants) \ SWIG_Python_InstallConstants(d, constants) +typedef double (*py_objasdbl_conv)(PyObject *obj); + #ifdef SWIG_NOINCLUDE SWIGIMPORT(int) SWIG_Python_ConvertPtr(PyObject *, void **, swig_type_info *, int); @@ -349,8 +353,31 @@ SWIGIMPORT(int) SWIG_Python_ConvertPacked(PyObject *, void *, int SWIGIMPORT(PyObject *) SWIG_Python_NewPackedObj(void *, int sz, swig_type_info *); SWIGIMPORT(void) SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]); +/* ----------------------------------------------------------------------------- + * the needed conversions between C++ and python + * ----------------------------------------------------------------------------- */ +/* basic types */ +/* + utilities +*/ +SWIGIMPORT(char* ) SWIG_PyObj_AsCharPtr(PyObject *obj, swig_type_info* pchar_info); +SWIGIMPORT(PyObject *) SWIG_PyObj_FromCharPtr(const char* cptr); +SWIGIMPORT(unsigned long) SWIG_PyObj_AsUnsignedLong(PyObject * obj); +SWIGIMPORT(long) SWIG_PyObj_AsLongInRange(PyObject * obj, const char* type, + long min_value, long max_value); +SWIGIMPORT(unsigned long) SWIG_PyObj_AsUnsignedLongInRange(PyObject *obj, const char* type, + unsigned long max_value); +SWIGIMPORT(char *) SWIG_PyObj_AsNewCharPtr(PyObject *obj, swig_type_info* pchar_info); +SWIGIMPORT(void) SWIG_PyObj_AsCharPtrAndSize(PyObject *obj, swig_type_info* pchar_info, + char** cptr, size_t* size); +SWIGIMPORT(void) SWIG_PyObj_AsCharArray(PyObject *obj, swig_type_info* pchar_info, + char* carray, size_t size); +SWIGIMPORT(PyObject *) SWIG_PyObj_FromCharArray(const char* carray, size_t size); +SWIGIMPORT(float) SWIG_PyObj_AsFloatConv(PyObject *obj, py_objasdbl_conv pyconv); + #else + /* ----------------------------------------------------------------------------- * global variable support code. * ----------------------------------------------------------------------------- */ @@ -639,6 +666,196 @@ SWIG_Python_NewPackedObj(void *ptr, int sz, swig_type_info *type) { return PyString_FromString(result); } +/* ----------------------------------------------------------------------------- + * the needed conversions between C++ and python + * ----------------------------------------------------------------------------- */ + +#include +#include +#include + +SWIGRUNTIME(unsigned long) +SWIG_PyObj_AsUnsignedLong(PyObject * obj) +{ + if (PyLong_Check(obj)) { + return PyLong_AsUnsignedLong(obj); + } else { + long i = PyInt_AsLong(obj); + if ( !PyErr_Occurred() && (i < 0)) { + PyErr_SetString(PyExc_TypeError, "negative value for unsigned type"); + } + return i; + } +} + +SWIGRUNTIME(long) +SWIG_PyObj_AsLongInRange(PyObject * obj, const char* type, + long min_value, long max_value) +{ + long value = PyInt_Check(obj) ? PyInt_AsLong(obj) : (long)PyLong_AsLongLong(obj); + if (!PyErr_Occurred()) { + if (value < min_value) { + PyObject *err = + PyString_FromFormat("value %ld is less than '%s' minimum %ld", + value, type, min_value); + + PyErr_SetObject(PyExc_OverflowError, err); + Py_XDECREF(err); + } else if (value > max_value) { + PyObject *err = + PyString_FromFormat("value %ld is greater than '%s' maximum %ld", + value, type, max_value); + PyErr_SetObject(PyExc_OverflowError, err); + Py_XDECREF(err); + } + } + return value; +} + +SWIGRUNTIME(unsigned long) +SWIG_PyObj_AsUnsignedLongInRange(PyObject *obj, const char* type, + unsigned long max_value) +{ + unsigned long value = SWIG_PyObj_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (value > max_value) { + PyObject *err = + PyString_FromFormat("value %ld is greater than '%s' minimum %ld", + value, type, max_value); + PyErr_SetObject(PyExc_OverflowError, err); + Py_XDECREF(err); + } + } + return value; +} + +SWIGRUNTIME(float) +SWIG_PyObj_AsFloatConv(PyObject *obj, py_objasdbl_conv pyconv) +{ + double value = pyconv(obj); + if (!PyErr_Occurred()) { + if (value < FLT_MIN) { + PyObject *err = + PyString_FromFormat("value %g is less than float minimum %g", + value, FLT_MIN); + PyErr_SetObject(PyExc_OverflowError, err); + Py_XDECREF(err); + } else if (value > FLT_MAX) { + PyObject *err = + PyString_FromFormat("value %g is greater than float maximum %g", + value, FLT_MAX); + PyErr_SetObject(PyExc_OverflowError, err); + Py_XDECREF(err); + } + } + return (float) value; +} + +SWIGRUNTIME(void) +SWIG_PyObj_AsCharPtrAndSize(PyObject *obj, swig_type_info* pchar_info, + char** cptr, size_t* size) +{ + int psize; + if ((!pchar_info) || SWIG_ConvertPtr(obj,(void **)cptr, pchar_info, 0) == -1) { + if (pchar_info && PyErr_Occurred()) PyErr_Clear(); + PyString_AsStringAndSize(obj, cptr, &psize); + *size = (size_t) psize; + } else { + /* don't like strlen, but ... */ + *size = (*cptr) ? (strlen(*cptr) + 1) : 0; + } +} + + +SWIGRUNTIME(char*) +SWIG_PyObj_AsNewCharPtr(PyObject *obj, swig_type_info* pchar_info) +{ + char *res = 0; + char* cptr; size_t csize; + SWIG_PyObj_AsCharPtrAndSize(obj, pchar_info, &cptr, &csize); + if (!PyErr_Occurred() && cptr) { + /* we add the '0' terminator if needed */ + size_t size = (csize && !(cptr[csize - 1])) ? csize : csize + 1; + if (size) { +#ifdef __cplusplus + res = new char[size]; +#else + res = malloc(size); +#endif + if (csize) memcpy(res, cptr, csize); + if (csize < size) res[csize] = 0; + } + } + return res; +} + +SWIGRUNTIME(PyObject *) +SWIG_PyObj_FromCharArray(const char* carray, size_t size) +{ + if (size > INT_MAX) { + PyObject *err = + PyString_FromFormat("a char array of size %d is not allowed in python", + size); + PyErr_SetObject(PyExc_TypeError, err); + Py_XDECREF(err); + Py_INCREF(Py_None); + return Py_None; + } else { + int psize = (int) size; + return PyString_FromStringAndSize(carray, psize); + } +} + +SWIGRUNTIME(void) +SWIG_PyObj_AsCharArray(PyObject *obj, swig_type_info* pchar_info, + char* carray, size_t size) +{ + char* cptr; size_t csize; + SWIG_PyObj_AsCharPtrAndSize(obj, pchar_info, &cptr, &csize); + if (!PyErr_Occurred()) { + /* in C (but not in C++) you can do: + + char x[5] = "hello"; + + ie, assing the array using an extra '0' char. Here, + we assume the C behavior... + */ + if ((csize == size + 1) && !(cptr[csize-1])) --csize; + if (csize > size) { + PyObject *err = + PyString_FromFormat("a char array of maximum size %d is expected", + size); + PyErr_SetObject(PyExc_TypeError, err); + Py_XDECREF(err); + } else { + if (csize) memcpy(carray, cptr, csize); + if (csize < size) memset(carray + csize, 0, size - csize); + } + } +} + +SWIGRUNTIME(PyObject *) +SWIG_PyObj_FromCharPtr(const char* cptr) +{ + if (cptr) { + return PyString_FromString(cptr); + } else { + Py_INCREF(Py_None); + return Py_None; + } +} + +SWIGRUNTIME(char* ) +SWIG_PyObj_AsCharPtr(PyObject *obj, swig_type_info* pchar_info) +{ + char* ptr; + if (SWIG_ConvertPtr(obj,(void **)&ptr, pchar_info, 0) == -1) { + if (PyErr_Occurred()) PyErr_Clear(); + ptr = PyString_AsString(obj); + } + return ptr; +} + /* Install Constants */ SWIGRUNTIME(void) SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { @@ -653,7 +870,7 @@ SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { obj = PyFloat_FromDouble(constants[i].dvalue); break; case SWIG_PY_STRING: - obj = PyString_FromString((char *) constants[i].pvalue); + obj = SWIG_PyObj_FromCharPtr((char *) constants[i].pvalue); break; case SWIG_PY_POINTER: obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); @@ -683,9 +900,11 @@ SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { #endif + /* -------- TYPES TABLE (BEGIN) -------- */ -static swig_type_info *swig_types[1]; +#define SWIGTYPE_p_char swig_types[0] +static swig_type_info *swig_types[2]; /* -------- TYPES TABLE (END) -------- */ @@ -696,6 +915,44 @@ static swig_type_info *swig_types[1]; #define SWIG_init init_swigrun #define SWIG_name "_swigrun" + +#include +#include +#include + +#ifndef SWIGSTATIC +#ifdef __cplusplus +#define SWIGSTATIC(a) static inline a +#else +#define SWIGSTATIC(a) static a +#endif +#endif + +#ifndef numeric_cast +#ifdef __cplusplus +#ifdef HAVE_NUMERIC_CAST +#define numeric_cast(type,a) numeric_cast(a) +#else +#define numeric_cast(type,a) static_cast(a) +#endif +#else +#define numeric_cast(type,a) (type)(a) +#endif +#endif + + + +#define SWIG_PyObj_FromSignedChar PyInt_FromLong +#define SWIG_PyObj_FromUnsignedChar PyInt_FromLong +#define SWIG_PyObj_FromShort PyInt_FromLong +#define SWIG_PyObj_FromUnsignedShort PyInt_FromLong +#define SWIG_PyObj_FromInt PyInt_FromLong +#define SWIG_PyObj_FromLong PyInt_FromLong +#define SWIG_PyObj_FromFloat PyFloat_FromDouble +#define SWIG_PyObj_FromDouble PyFloat_FromDouble +#define SWIG_PyObj_FromFloat PyFloat_FromDouble +#define SWIG_PyObj_FromDouble PyFloat_FromDouble + #ifdef __cplusplus extern "C" { #endif @@ -706,8 +963,10 @@ static PyMethodDef SwigMethods[] = { /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ +static swig_type_info _swigt__p_char[] = {{"_p_char", 0, "char *", 0},{"_p_char"},{0}}; static swig_type_info *swig_types_initial[] = { +_swigt__p_char, 0 };