From 7aa677bec30bf9531b1835f1061e597dc4da3418 Mon Sep 17 00:00:00 2001 From: Dave Beazley Date: Wed, 16 Feb 2000 17:46:23 +0000 Subject: [PATCH] cleanup git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@244 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/python.swg | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Lib/python/python.swg b/Lib/python/python.swg index b91ec874a..10218dccd 100644 --- a/Lib/python/python.swg +++ b/Lib/python/python.swg @@ -54,6 +54,21 @@ typedef struct _swig_type_info { struct _swig_type_info *prev; } _swig_type_info; +/* Constant information structure */ +typedef struct _swig_const_info { + int type; + char *name; + long lvalue; + double dvalue; + void *pvalue; + _swig_type_info **ptype; +} _swig_const_info; + +#define SWIG_PY_INT 1 +#define SWIG_PY_FLOAT 2 +#define SWIG_PY_STRING 3 +#define SWIG_PY_POINTER 4 + #ifdef SWIG_NOINCLUDE SWIGEXPORT(PyObject *) SWIG_newvarlink(); @@ -63,6 +78,7 @@ SWIGEXPORT(_swig_type_info *) SWIG_TypeCheck(char *, _swig_type_info *); SWIGEXPORT(int) SWIG_ConvertPtr(PyObject *, void **, _swig_type_info *, int); SWIGEXPORT(void) SWIG_MakePtr(char *c, void *, _swig_type_info *); SWIGEXPORT(PyObject *) SWIG_NewPointerObj(void *, _swig_type_info *); +SWIGEXPORT(void) SWIG_InstallConstants(PyObject *d, _swig_const_info constants[]); /* External declarations when using runtime libraries */ @@ -362,6 +378,36 @@ SWIG_NewPointerObj(void *ptr, _swig_type_info *type) { return robj; } +/* Install Constants */ +SWIGSTATICRUNTIME(void) +SWIG_InstallConstants(PyObject *d, _swig_const_info constants[]) { + int i; + PyObject *obj; + for (i = 0; constants[i].type; i++) { + switch(constants[i].type) { + case SWIG_PY_INT: + obj = PyInt_FromLong(constants[i].lvalue); + break; + case SWIG_PY_FLOAT: + obj = PyFloat_FromDouble(constants[i].dvalue); + break; + case SWIG_PY_STRING: + obj = PyString_FromString((char *) constants[i].pvalue); + break; + case SWIG_PY_POINTER: + obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d,constants[i].name,obj); + Py_DECREF(obj); + } + } +} + #endif #ifdef __cplusplus