diff --git a/Lib/guile/guile_gh_run.swg b/Lib/guile/guile_gh_run.swg index 42196417a..d79d45446 100644 --- a/Lib/guile/guile_gh_run.swg +++ b/Lib/guile/guile_gh_run.swg @@ -41,22 +41,24 @@ typedef SCM (*swig_guile_proc)(); (char *) FUNC_NAME, (char *) msg, \ SCM_EOL, SCM_BOOL_F); else -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(_MSC_VER) || defined(__GNUC__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT(a) a -# else -# define SWIGEXPORT(a) __declspec(dllexport) a -# endif -# else -# if defined(__BORLANDC__) -# define SWIGEXPORT(a) a _export -# else -# define SWIGEXPORT(a) a -# endif -# endif -#else -# define SWIGEXPORT(a) a +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(_MSC_VER) || defined(__GNUC__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT(a) a +# else +# define SWIGEXPORT(a) __declspec(dllexport) a +# endif +# else +# if defined(__BORLANDC__) +# define SWIGEXPORT(a) a _export +# else +# define SWIGEXPORT(a) a +# endif +# endif +# else +# define SWIGEXPORT(a) a +# endif #endif /* SCM_CHAR and SCM_CHARP were introduced in Guile 1.4; the following is for diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 56f9e6eea..c057cb5a7 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -121,27 +121,28 @@ SWIGINTERN PyTypeObject varlinktype = { /* Create a variable linking object for use later */ SWIGINTERN PyObject * SWIG_Python_newvarlink(void) { - swig_varlinkobject *result = 0; - result = PyMem_NEW(swig_varlinkobject,1); - varlinktype.ob_type = &PyType_Type; /* Patch varlinktype into a PyType */ - result->ob_type = &varlinktype; - result->vars = 0; - result->ob_refcnt = 0; - Py_XINCREF((PyObject *) result); + swig_varlinkobject *result = PyMem_NEW(swig_varlinkobject,1); + if (result) { + varlinktype.ob_type = &PyType_Type; /* Patch varlinktype into a PyType */ + result->ob_type = &varlinktype; + result->vars = 0; + result->ob_refcnt = 0; + Py_INCREF((PyObject *) result); + } return ((PyObject*) result); } SWIGINTERN void SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { - swig_varlinkobject *v; - swig_globalvar *gv; - v= (swig_varlinkobject *) p; - gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); - gv->name = (char *) malloc(strlen(name)+1); - strcpy(gv->name,name); - gv->get_attr = get_attr; - gv->set_attr = set_attr; - gv->next = v->vars; + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + gv->name = (char *) malloc(strlen(name)+1); + strcpy(gv->name,name); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } v->vars = gv; } diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index b69a5159b..c7684a98d 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -201,7 +201,7 @@ PySwigObject_GetType() { (ternaryfunc)0, /*tp_call*/ (reprfunc)PySwigObject_str, /*tp_str*/ /* Space for future expansion */ - 0L,0L,0L,0L, + 0,0,0,0, PySwigObject_Type__doc__, /* Documentation string */ #if PY_VERSION_HEX >= 0x02000000 0, /* tp_traverse */ @@ -354,7 +354,7 @@ PySwigPacked_GetType() { (ternaryfunc)0, /*tp_call*/ (reprfunc)PySwigPacked_str, /*tp_str*/ /* Space for future expansion */ - 0L,0L,0L,0L, + 0,0,0,0, PySwigPacked_Type__doc__, /* Documentation string */ #if PY_VERSION_HEX >= 0x02000000 0, /* tp_traverse */ @@ -605,7 +605,7 @@ type_error: char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); c = doc ? strstr(doc, "swig_ptr: ") : 0; if (c) { - c = SWIG_UnpackVoidPtr(c + 10, &vptr, ty->name); + c = ty ? SWIG_UnpackVoidPtr(c + 10, &vptr, ty->name) : 0; if (!c) goto type_error; goto type_check; } @@ -748,7 +748,7 @@ SWIG_Python_GetModule() { return (swig_module_info *) type_pointer; } -SWIGINTERN void +SWIGRUNTIME void SWIG_Python_SetModule(swig_module_info *swig_module) { static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ @@ -758,8 +758,7 @@ SWIG_Python_SetModule(swig_module_info *swig_module) { if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); } -} - +} #ifdef __cplusplus } diff --git a/Lib/swig.swg b/Lib/swig.swg index 545e87d91..9815c6593 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -473,37 +473,57 @@ static int NAME(TYPE x) { #endif %} - -/* Common labels and attributes for the internal SWIG methods */ +/* + Common labels and attributes +*/ %insert("runtime") %{ /* inline attribute */ #ifndef SWIGINLINE -#if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -#else -# define SWIGINLINE -#endif +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif #endif -/* attritbute passed for some compilers to avoid unused method warnings */ +/* attritbute passed for some compilers to avoid 'unused' warnings */ #ifndef SWIGUNUSED -#ifdef __GNUC__ -#define SWIGUNUSED __attribute__ ((unused)) -#else -#define SWIGUNUSED -#endif +# if defined(__GNUC__) || defined(__ICC) +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif #endif /* internal SWIG method */ #ifndef SWIGINTERN -#define SWIGINTERN static SWIGUNUSED +# define SWIGINTERN static SWIGUNUSED #endif - /* internal inline SWIG method */ #ifndef SWIGINTERNINLINE -#define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE #endif +/* how we export a method such that it can go in to a shared or dll library */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(_MSC_VER) || defined(__GNUC__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT(a) a +# else +# define SWIGEXPORT(a) __declspec(dllexport) a +# endif +# else +# if defined(__BORLANDC__) +# define SWIGEXPORT(a) a _export +# else +# define SWIGEXPORT(a) a +# endif +# endif +# else +# define SWIGEXPORT(a) a +# endif +#endif %} diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index 6fb33fa2a..3c4e7646d 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -12,30 +12,34 @@ /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE -#define SWIG_QUOTE_STRING(x) #x -#define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) -#define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) #else -#define SWIG_TYPE_TABLE_NAME +# define SWIG_TYPE_TABLE_NAME #endif -#include +/* + We need to define the compiler attributes here again since swigrun.swg + can be exported using -runtime. +*/ +/* inline attribute */ #ifndef SWIGINLINE -#if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -#else -# define SWIGINLINE -#endif +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif #endif -/* attritbute passed for some compilers to avoid unused method warnings */ +/* attritbute passed for some compilers to avoid 'unused' warnings */ #ifndef SWIGUNUSED -#ifdef __GNUC__ -#define SWIGUNUSED __attribute__ ((unused)) -#else -#define SWIGUNUSED -#endif +# ifdef __GNUC__ +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif #endif /* @@ -48,23 +52,14 @@ */ #ifndef SWIGRUNTIME -#define SWIGRUNTIME static SWIGUNUSED +# define SWIGRUNTIME static SWIGUNUSED #endif #ifndef SWIGRUNTIMEINLINE -#define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE -#endif - -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if !defined(STATIC_LINKED) -# define SWIGEXPORT(a) __declspec(dllexport) a -# else -# define SWIGEXPORT(a) a -# endif -#else -# define SWIGEXPORT(a) a +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE #endif +#include #ifdef __cplusplus extern "C" { @@ -116,7 +111,7 @@ SWIG_TypeNameComp(const char *f1, const char *l1, for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { while ((*f1 == ' ') && (f1 != l1)) ++f1; while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return *f1 - *f2; + if (*f1 != *f2) return (int)(*f1 - *f2); } return (l1 - f1) - (l2 - f2); } @@ -134,7 +129,7 @@ SWIG_TypeEquiv(const char *nb, const char *tb) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } - equiv = SWIG_TypeNameComp(nb, ne, tb, te) == 0; + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; if (*ne) ++ne; } return equiv; @@ -153,7 +148,7 @@ SWIG_TypeCompare(const char *nb, const char *tb) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } - equiv = SWIG_TypeNameComp(nb, ne, tb, te) == 0; + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; if (*ne) ++ne; } return equiv; @@ -183,8 +178,8 @@ SWIG_TypeCompare(const char *nb, const char *tb) { } \ iter = iter->next; \ } \ - return 0; \ - } while(0) + } while(0); \ + return 0 /* Check the typename @@ -368,9 +363,9 @@ SWIG_PackData(char *c, void *ptr, size_t sz) { SWIGRUNTIME const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; + register const unsigned char *eu = u + sz; for (; u != eu; ++u) { - register int d = *(c++); + register char d = *(c++); register unsigned char uu = 0; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4);