summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Lib/chicken/chicken.swg1
-rw-r--r--Lib/common.swg270
-rw-r--r--Lib/guile/guile_scm.swg1
-rw-r--r--Lib/linkruntime.c2
-rw-r--r--Lib/mzscheme/mzscheme.swg1
-rw-r--r--Lib/perl5/perl5.swg1
-rw-r--r--Lib/php4/php4.swg1
-rw-r--r--Lib/pike/pike.swg1
-rw-r--r--Lib/python/pyapi.swg27
-rw-r--r--Lib/python/pyinit.swg328
-rw-r--r--Lib/python/pyrun.swg368
-rw-r--r--Lib/python/pyrunalias.swg9
-rw-r--r--Lib/python/pyruntime.swg2
-rw-r--r--Lib/ruby/ruby.swg1
-rw-r--r--Lib/swigrun.swg332
-rw-r--r--Lib/tcl/tcl8.swg1
16 files changed, 759 insertions, 587 deletions
diff --git a/Lib/chicken/chicken.swg b/Lib/chicken/chicken.swg
index 53b1ae0e1..5a2294479 100644
--- a/Lib/chicken/chicken.swg
+++ b/Lib/chicken/chicken.swg
@@ -10,6 +10,7 @@
#include "chicken.h"
%}
+%insert(runtime) "swigrun.swg"; // Common C API type-checking code
%insert(runtime) "common.swg"; // Common type-checking code
%insert(runtime) "chickenrun.swg"; // CHICKEN run-time code
diff --git a/Lib/common.swg b/Lib/common.swg
index fe7f625a6..898d81114 100644
--- a/Lib/common.swg
+++ b/Lib/common.swg
@@ -13,7 +13,6 @@
* this copyright message remains intact.
************************************************************************/
-#include <string.h>
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# if !defined(STATIC_LINKED)
@@ -25,276 +24,36 @@
# define SWIGEXPORT(a) a
#endif
-#define SWIGRUNTIME(x) static x
-
-#ifndef SWIGINLINE
-#if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
-# define SWIGINLINE inline
-#else
-# define SWIGINLINE
-#endif
-#endif
-
-
-/* This should only be incremented when either the layout of swig_type_info changes,
- or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "1"
-
-/* 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)
-#else
-#define SWIG_TYPE_TABLE_NAME
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
-typedef void *(*swig_converter_func)(void *);
-typedef struct swig_type_info *(*swig_dycast_func)(void **);
-typedef struct swig_type_info {
- const char *name;
- swig_converter_func converter;
- const char *str;
- void *clientdata;
- swig_dycast_func dcast;
- struct swig_type_info *next;
- struct swig_type_info *prev;
-} swig_type_info;
+/*************************************************************************/
-static swig_type_info *swig_type_list = 0;
-static swig_type_info **swig_type_list_handle = &swig_type_list;
-
-/*
- Compare two type names skipping the space characters, therefore
- "char*" == "char *" and "Class<int>" == "Class<int >", etc.
- Return 0 when the two name types are equivalent, as in
- strncmp, but skipping ' '.
-*/
-static int
-SWIG_TypeNameComp(const char *f1, const char *l1,
- const char *f2, const char *l2) {
- for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
- while ((*f1 == ' ') && (f1 != l1)) ++f1;
- while ((*f2 == ' ') && (f2 != l2)) ++f2;
- if (*f1 != *f2) return *f1 - *f2;
- }
- return (l1 - f1) - (l2 - f2);
-}
+/* The static type info list */
-/*
- Check type equivalence in a name list like <name1>|<name2>|...
-*/
-static int
-SWIG_TypeEquiv(const char *nb, const char *tb) {
- int equiv = 0;
- const char* te = tb + strlen(tb);
- const char* ne = nb;
- while (!equiv && *ne) {
- for (nb = ne; *ne; ++ne) {
- if (*ne == '|') break;
- }
- equiv = SWIG_TypeNameComp(nb, ne, tb, te) == 0;
- if (*ne) ++ne;
- }
- return equiv;
-}
+static swig_type_info *swig_type_list = 0;
+static swig_type_info **swig_type_list_handle = &swig_type_list;
/* Register a type mapping with the type-checking */
static swig_type_info *
SWIG_TypeRegister(swig_type_info *ti) {
- swig_type_info *tc, *head, *ret, *next;
- /* Check to see if this type has already been registered */
- tc = *swig_type_list_handle;
- while (tc) {
- /* check simple type equivalence */
- int typeequiv = (strcmp(tc->name, ti->name) == 0);
- /* check full type equivalence, resolving typedefs */
- if (!typeequiv) {
- /* only if tc is not a typedef (no '|' on it) */
- if (tc->str && ti->str && !strstr(tc->str,"|")) {
- typeequiv = SWIG_TypeEquiv(ti->str,tc->str);
- }
- }
- if (typeequiv) {
- /* Already exists in the table. Just add additional types to the list */
- if (ti->clientdata) tc->clientdata = ti->clientdata;
- head = tc;
- next = tc->next;
- goto l1;
- }
- tc = tc->prev;
- }
- head = ti;
- next = 0;
-
- /* Place in list */
- ti->prev = *swig_type_list_handle;
- *swig_type_list_handle = ti;
-
- /* Build linked lists */
- l1:
- ret = head;
- tc = ti + 1;
- /* Patch up the rest of the links */
- while (tc->name) {
- head->next = tc;
- tc->prev = head;
- head = tc;
- tc++;
- }
- if (next) next->prev = head;
- head->next = next;
-
- return ret;
-}
-
-/* Check the typename */
-static swig_type_info *
-SWIG_TypeCheck(char *c, swig_type_info *ty) {
- swig_type_info *s;
- if (!ty) return 0; /* Void pointer */
- s = ty->next; /* First element always just a name */
- do {
- if (strcmp(s->name,c) == 0) {
- if (s == ty->next) return s;
- /* Move s to the top of the linked list */
- s->prev->next = s->next;
- if (s->next) {
- s->next->prev = s->prev;
- }
- /* Insert s as second element in the list */
- s->next = ty->next;
- if (ty->next) ty->next->prev = s;
- ty->next = s;
- s->prev = ty;
- return s;
- }
- s = s->next;
- } while (s && (s != ty->next));
- return 0;
-}
-
-/* Cast a pointer up an inheritance hierarchy */
-static SWIGINLINE void *
-SWIG_TypeCast(swig_type_info *ty, void *ptr) {
- if ((!ty) || (!ty->converter)) return ptr;
- return (*ty->converter)(ptr);
-}
-
-/* Dynamic pointer casting. Down an inheritance hierarchy */
-static swig_type_info *
-SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
- swig_type_info *lastty = ty;
- if (!ty || !ty->dcast) return ty;
- while (ty && (ty->dcast)) {
- ty = (*ty->dcast)(ptr);
- if (ty) lastty = ty;
- }
- return lastty;
-}
-
-/* Return the name associated with this type */
-static SWIGINLINE const char *
-SWIG_TypeName(const swig_type_info *ty) {
- return ty->name;
-}
-
-/* Return the pretty name associated with this type,
- that is an unmangled type name in a form presentable to the user.
-*/
-static const char *
-SWIG_TypePrettyName(const swig_type_info *type) {
- /* The "str" field contains the equivalent pretty names of the
- type, separated by vertical-bar characters. We choose
- to print the last name, as it is often (?) the most
- specific. */
- if (type->str != NULL) {
- const char *last_name = type->str;
- const char *s;
- for (s = type->str; *s; s++)
- if (*s == '|') last_name = s+1;
- return last_name;
- }
- else
- return type->name;
+ return SWIG_TypeRegisterTL(swig_type_list_handle, ti);
}
/* Search for a swig_type_info structure */
static swig_type_info *
SWIG_TypeQuery(const char *name) {
- swig_type_info *ty = *swig_type_list_handle;
- while (ty) {
- if (ty->str && (SWIG_TypeEquiv(ty->str,name))) return ty;
- if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
- ty = ty->prev;
- }
- return 0;
+ return SWIG_TypeQueryTL(*swig_type_list_handle, name);
}
/* Set the clientdata field for a type */
static void
SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
- swig_type_info *tc, *equiv;
- if (ti->clientdata) return;
- /* if (ti->clientdata == clientdata) return; */
- ti->clientdata = clientdata;
- equiv = ti->next;
- while (equiv) {
- if (!equiv->converter) {
- tc = *swig_type_list_handle;
- while (tc) {
- if ((strcmp(tc->name, equiv->name) == 0))
- SWIG_TypeClientData(tc,clientdata);
- tc = tc->prev;
- }
- }
- equiv = equiv->next;
- }
-}
-
-/* Pack binary data into a string */
-static char *
-SWIG_PackData(char *c, void *ptr, size_t sz) {
- static char hex[17] = "0123456789abcdef";
- unsigned char *u = (unsigned char *) ptr;
- const unsigned char *eu = u + sz;
- register unsigned char uu;
- for (; u != eu; ++u) {
- uu = *u;
- *(c++) = hex[(uu & 0xf0) >> 4];
- *(c++) = hex[uu & 0xf];
- }
- return c;
-}
-
-/* Unpack binary data from a string */
-static char *
-SWIG_UnpackData(char *c, void *ptr, size_t sz) {
- register unsigned char uu = 0;
- register int d;
- unsigned char *u = (unsigned char *) ptr;
- const unsigned char *eu = u + sz;
- for (; u != eu; ++u) {
- d = *(c++);
- if ((d >= '0') && (d <= '9'))
- uu = ((d - '0') << 4);
- else if ((d >= 'a') && (d <= 'f'))
- uu = ((d - ('a'-10)) << 4);
- d = *(c++);
- if ((d >= '0') && (d <= '9'))
- uu |= (d - '0');
- else if ((d >= 'a') && (d <= 'f'))
- uu |= (d - ('a'-10));
- *u = uu;
- }
- return c;
+ SWIG_TypeClientDataTL(*swig_type_list_handle, ti, clientdata);
}
/* This function will propagate the clientdata field of type to
@@ -304,20 +63,7 @@ SWIG_UnpackData(char *c, void *ptr, size_t sz) {
*/
static void
SWIG_PropagateClientData(swig_type_info *type) {
- swig_type_info *equiv = type->next;
- swig_type_info *tc;
- if (!type->clientdata) return;
- while (equiv) {
- if (!equiv->converter) {
- tc = *swig_type_list_handle;
- while (tc) {
- if ((strcmp(tc->name, equiv->name) == 0) && !tc->clientdata)
- SWIG_TypeClientData(tc, type->clientdata);
- tc = tc->prev;
- }
- }
- equiv = equiv->next;
- }
+ SWIG_PropagateClientDataTL(*swig_type_list_handle, type);
}
#ifdef __cplusplus
diff --git a/Lib/guile/guile_scm.swg b/Lib/guile/guile_scm.swg
index 60bd58519..2bac448b0 100644
--- a/Lib/guile/guile_scm.swg
+++ b/Lib/guile/guile_scm.swg
@@ -5,6 +5,7 @@
#define SWIGGUILE_SCM
+%runtime "swigrun.swg" // Common C API type-checking code
%runtime "common.swg"
%runtime "guile_scm_run.swg"
diff --git a/Lib/linkruntime.c b/Lib/linkruntime.c
index 89021fd2c..3204a1c13 100644
--- a/Lib/linkruntime.c
+++ b/Lib/linkruntime.c
@@ -19,6 +19,6 @@
static void *ptr = 0;
SWIGEXPORT(void *)
SWIG_ReturnGlobalTypeList(void *t) {
- if (!ptr) ptr = t;
+ if (!ptr && !t) ptr = t;
return ptr;
}
diff --git a/Lib/mzscheme/mzscheme.swg b/Lib/mzscheme/mzscheme.swg
index de325456d..ba3ff9812 100644
--- a/Lib/mzscheme/mzscheme.swg
+++ b/Lib/mzscheme/mzscheme.swg
@@ -3,6 +3,7 @@
file. */
/* Include headers */
+%runtime "swigrun.swg" // Common C API type-checking code
%runtime "common.swg"
%runtime "mzrun.swg"
diff --git a/Lib/perl5/perl5.swg b/Lib/perl5/perl5.swg
index 5b600e8e2..2a9077c83 100644
--- a/Lib/perl5/perl5.swg
+++ b/Lib/perl5/perl5.swg
@@ -4,6 +4,7 @@
* Perl 5 configuration file
* ----------------------------------------------------------------------------- */
+%runtime "swigrun.swg" // Common C API type-checking code
%runtime "common.swg" // common type checking code
%runtime "perlrun.swg" // Perl runtime functions
%runtime "noembed.h" // undefine Perl5 macros
diff --git a/Lib/php4/php4.swg b/Lib/php4/php4.swg
index 323dfe2f3..a66e4f1c5 100644
--- a/Lib/php4/php4.swg
+++ b/Lib/php4/php4.swg
@@ -5,6 +5,7 @@
*
*/
+%runtime "swigrun.swg" // Common C API type-checking code
%runtime "common.swg" // common type checking code
%runtime "php4run.swg" // Php4 runtime functions
%include "utils.i" // building blocks
diff --git a/Lib/pike/pike.swg b/Lib/pike/pike.swg
index 4a8fb986e..7ec2451fd 100644
--- a/Lib/pike/pike.swg
+++ b/Lib/pike/pike.swg
@@ -5,6 +5,7 @@
* ----------------------------------------------------------------------------- */
%insert(runtime) "precommon.swg"
+%insert(runtime) "swigrun.swg"; // Common C API type-checking code
%insert(runtime) "common.swg"; // Common type-checking code
%insert(runtime) "pikerun.swg"; // Pike run-time code
diff --git a/Lib/python/pyapi.swg b/Lib/python/pyapi.swg
index 45caf2130..1ed88ccb9 100644
--- a/Lib/python/pyapi.swg
+++ b/Lib/python/pyapi.swg
@@ -22,18 +22,6 @@ extern "C" {
#endif /* __cplusplus */
#endif
-
-/* Common SWIG API */
-#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags)
-#define SWIG_NewPointerObj(p, type, flags) 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()
-#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
-#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
-#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
-#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
/*
Exception handling in wrappers
@@ -72,21 +60,6 @@ typedef struct swig_const_info {
swig_type_info **ptype;
} swig_const_info;
-/* -----------------------------------------------------------------------------
- * Pointer declarations
- * ----------------------------------------------------------------------------- */
-/*
- Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent
- C/C++ pointers in the python side. Very useful for debugging, but
- not always safe.
-*/
-#if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES)
-# define SWIG_COBJECT_TYPES
-#endif
-
-/* Flags for pointer conversion */
-#define SWIG_POINTER_EXCEPTION 0x1
-#define SWIG_POINTER_DISOWN 0x2
/* -----------------------------------------------------------------------------
* Alloc. memory flags
diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg
index fde873c0a..406d5a031 100644
--- a/Lib/python/pyinit.swg
+++ b/Lib/python/pyinit.swg
@@ -4,20 +4,320 @@
%init %{
-#ifdef SWIG_LINK_RUNTIME
-#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# if defined(_MSC_VER) || defined(__GNUC__)
-# define SWIGIMPORT(a) extern a
-# else
-# if defined(__BORLANDC__)
-# define SWIGIMPORT(a) a _export
-# else
-# define SWIGIMPORT(a) a
-# endif
-# endif
-#else
-# define SWIGIMPORT(a) a
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Python-specific SWIG API */
+#define SWIG_newvarlink() SWIG_Python_newvarlink()
+#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
+#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
+
+/* -----------------------------------------------------------------------------
+ * global variable support code.
+ * ----------------------------------------------------------------------------- */
+
+typedef struct swig_globalvar {
+ char *name; /* Name of global variable */
+ PyObject *(*get_attr)(); /* Return the current value */
+ int (*set_attr)(PyObject *); /* Set the value */
+ struct swig_globalvar *next;
+} swig_globalvar;
+
+typedef struct swig_varlinkobject {
+ PyObject_HEAD
+ swig_globalvar *vars;
+} swig_varlinkobject;
+
+static PyObject *
+swig_varlink_repr(swig_varlinkobject *v) {
+ v = v;
+ return PyString_FromString("<Global variables>");
+}
+
+static int
+swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) {
+ swig_globalvar *var;
+ flags = flags;
+ fprintf(fp,"Global variables { ");
+ for (var = v->vars; var; var=var->next) {
+ fprintf(fp,"%s", var->name);
+ if (var->next) fprintf(fp,", ");
+ }
+ fprintf(fp," }\n");
+ return 0;
+}
+
+static PyObject *
+swig_varlink_getattr(swig_varlinkobject *v, char *n) {
+ swig_globalvar *var = v->vars;
+ while (var) {
+ if (strcmp(var->name,n) == 0) {
+ return (*var->get_attr)();
+ }
+ var = var->next;
+ }
+ PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+ return NULL;
+}
+
+static int
+swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
+ swig_globalvar *var = v->vars;
+ while (var) {
+ if (strcmp(var->name,n) == 0) {
+ return (*var->set_attr)(p);
+ }
+ var = var->next;
+ }
+ PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+ return 1;
+}
+
+static PyTypeObject varlinktype = {
+ PyObject_HEAD_INIT(0)
+ 0, /* Number of items in variable part (ob_size) */
+ (char *)"swigvarlink", /* Type name (tp_name) */
+ sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
+ 0, /* Itemsize (tp_itemsize) */
+ 0, /* Deallocator (tp_dealloc) */
+ (printfunc) swig_varlink_print, /* Print (tp_print) */
+ (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
+ (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
+ 0, /* tp_compare */
+ (reprfunc) swig_varlink_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ 0, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+ 0, /* tp_del */
#endif
+#ifdef COUNT_ALLOCS
+ /* these must be last */
+ 0, /* tp_alloc */
+ 0, /* tp_free */
+ 0, /* tp_maxalloc */
+ 0, /* tp_next */
+#endif
+};
+
+/* Create a variable linking object for use later */
+static 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);
+ return ((PyObject*) result);
+}
+
+static 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;
+ v->vars = gv;
+}
+
+/* -----------------------------------------------------------------------------
+ * constants/methods manipulation
+ * ----------------------------------------------------------------------------- */
+
+/* Install Constants */
+static void
+SWIG_Python_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:
+ if (constants[i].pvalue) {
+ obj = PyString_FromString((char *) constants[i].pvalue);
+ } else {
+ Py_INCREF(Py_None);
+ obj = Py_None;
+ }
+ break;
+ case SWIG_PY_POINTER:
+ obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
+ break;
+ case SWIG_PY_BINARY:
+ obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
+ break;
+ default:
+ obj = 0;
+ break;
+ }
+ if (obj) {
+ PyDict_SetItemString(d,constants[i].name,obj);
+ Py_DECREF(obj);
+ }
+ }
+}
+
+/* -----------------------------------------------------------------------------*/
+/* Fix SwigMethods to carry the callback ptrs when needed */
+/* -----------------------------------------------------------------------------*/
+
+static void
+SWIG_Python_FixMethods(PyMethodDef *methods,
+ swig_const_info *const_table,
+ swig_type_info **types,
+ swig_type_info **types_initial) {
+ int i;
+ for (i = 0; methods[i].ml_name; ++i) {
+ char *c = methods[i].ml_doc;
+ if (c && (c = strstr(c, "swig_ptr: "))) {
+ int j;
+ swig_const_info *ci = 0;
+ char *name = c + 10;
+ for (j = 0; const_table[j].type; j++) {
+ if (strncmp(const_table[j].name, name,
+ strlen(const_table[j].name)) == 0) {
+ ci = &(const_table[j]);
+ break;
+ }
+ }
+ if (ci) {
+ size_t shift = (ci->ptype) - types;
+ swig_type_info *ty = types_initial[shift];
+ size_t ldoc = (c - methods[i].ml_doc);
+ size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
+ char *ndoc = (char*)malloc(ldoc + lptr + 10);
+ char *buff = ndoc;
+ void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue: (void *)(ci->lvalue);
+ strncpy(buff, methods[i].ml_doc, ldoc);
+ buff += ldoc;
+ strncpy(buff, "swig_ptr: ", 10);
+ buff += 10;
+ SWIG_Python_PointerStr(buff, ptr, ty->name, lptr);
+ methods[i].ml_doc = ndoc;
+ }
+ }
+ }
+}
+
+/* -----------------------------------------------------------------------------*
+ * Initialize type list
+ * -----------------------------------------------------------------------------*/
+
+#if PY_MAJOR_VERSION < 2
+/* PyModule_AddObject function was introduced in Python 2.0. The following function
+is copied out of Python/modsupport.c in python version 2.3.4 */
+static int
+PyModule_AddObject(PyObject *m, char *name, PyObject *o)
+{
+ PyObject *dict;
+ if (!PyModule_Check(m)) {
+ PyErr_SetString(PyExc_TypeError,
+ "PyModule_AddObject() needs module as first arg");
+ return -1;
+ }
+ if (!o) {
+ PyErr_SetString(PyExc_TypeError,
+ "PyModule_AddObject() needs non-NULL value");
+ return -1;
+ }
+
+ dict = PyModule_GetDict(m);
+ if (dict == NULL) {
+ /* Internal error -- modules must have a dict! */
+ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
+ PyModule_GetName(m));
+ return -1;
+ }
+ if (PyDict_SetItemString(dict, name, o))
+ return -1;
+ Py_DECREF(o);
+ return 0;
+}
+#endif
+
+static swig_type_info **
+SWIG_Python_SetTypeListHandle(swig_type_info **type_list_handle) {
+ static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
+
+ PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+ swig_empty_runtime_method_table);
+ PyObject *pointer = PyCObject_FromVoidPtr((void *) type_list_handle, NULL);
+ if (pointer && module) {
+ PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
+ }
+ return type_list_handle;
+}
+
+static swig_type_info **
+SWIG_Python_LookupTypePointer(swig_type_info **type_list_handle) {
+ swig_type_info **type_pointer;
+
+ /* first check if module already created */
+ type_pointer = SWIG_Python_GetTypeListHandle();
+ if (type_pointer) {
+ return type_pointer;
+ } else {
+ /* create a new module and variable */
+ return SWIG_Python_SetTypeListHandle(type_list_handle);
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+/* -----------------------------------------------------------------------------*
+ * Partial Init method
+ * -----------------------------------------------------------------------------*/
+
+#ifdef SWIG_LINK_RUNTIME
#ifdef __cplusplus
extern "C"
#endif
@@ -45,7 +345,7 @@ SWIGEXPORT(void) SWIG_init(void) {
swig_type_list_handle = (swig_type_info **) SWIG_ReturnGlobalTypeList(swig_type_list_handle);
#else
# ifndef SWIG_STATIC_RUNTIME
- SWIG_Python_LookupTypePointer(&swig_type_list_handle);
+ swig_type_list_handle = SWIG_Python_LookupTypePointer(swig_type_list_handle);
# endif
#endif
for (i = 0; swig_types_initial[i]; i++) {
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
index 8a364706d..7dbad8170 100644
--- a/Lib/python/pyrun.swg
+++ b/Lib/python/pyrun.swg
@@ -8,164 +8,42 @@
* Author : David Beazley (beazley@cs.uchicago.edu)
************************************************************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
+/* Common SWIG API */
+#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags)
+#define SWIG_NewPointerObj(p, type, flags) SWIG_Python_NewPointerObj(p, type, flags)
+#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
+
-/* -----------------------------------------------------------------------------
- * global variable support code.
- * ----------------------------------------------------------------------------- */
+/* Python-specific SWIG API */
+#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
+#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
-typedef struct swig_globalvar {
- char *name; /* Name of global variable */
- PyObject *(*get_attr)(); /* Return the current value */
- int (*set_attr)(PyObject *); /* Set the value */
- struct swig_globalvar *next;
-} swig_globalvar;
-
-typedef struct swig_varlinkobject {
- PyObject_HEAD
- swig_globalvar *vars;
-} swig_varlinkobject;
-
-static PyObject *
-swig_varlink_repr(swig_varlinkobject *v) {
- v = v;
- return PyString_FromString("<Global variables>");
-}
-static int
-swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) {
- swig_globalvar *var;
- flags = flags;
- fprintf(fp,"Global variables { ");
- for (var = v->vars; var; var=var->next) {
- fprintf(fp,"%s", var->name);
- if (var->next) fprintf(fp,", ");
- }
- fprintf(fp," }\n");
- return 0;
-}
+/* -----------------------------------------------------------------------------
+ * Pointer declarations
+ * ----------------------------------------------------------------------------- */
+/*
+ Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent
+ C/C++ pointers in the python side. Very useful for debugging, but
+ not always safe.
+*/
+#if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES)
+# define SWIG_COBJECT_TYPES
+#endif
-static PyObject *
-swig_varlink_getattr(swig_varlinkobject *v, char *n) {
- swig_globalvar *var = v->vars;
- while (var) {
- if (strcmp(var->name,n) == 0) {
- return (*var->get_attr)();
- }
- var = var->next;
- }
- PyErr_SetString(PyExc_NameError,"Unknown C global variable");
- return NULL;
-}
+/* Flags for pointer conversion */
+#define SWIG_POINTER_EXCEPTION 0x1
+#define SWIG_POINTER_DISOWN 0x2
-static int
-swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
- swig_globalvar *var = v->vars;
- while (var) {
- if (strcmp(var->name,n) == 0) {
- return (*var->set_attr)(p);
- }
- var = var->next;
- }
- PyErr_SetString(PyExc_NameError,"Unknown C global variable");
- return 1;
-}
-static PyTypeObject varlinktype = {
- PyObject_HEAD_INIT(0)
- 0, /* Number of items in variable part (ob_size) */
- (char *)"swigvarlink", /* Type name (tp_name) */
- sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
- 0, /* Itemsize (tp_itemsize) */
- 0, /* Deallocator (tp_dealloc) */
- (printfunc) swig_varlink_print, /* Print (tp_print) */
- (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
- (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
- 0, /* tp_compare */
- (reprfunc) swig_varlink_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- 0, /* tp_flags */
- 0, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
-#if PY_VERSION_HEX >= 0x02020000
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
-#endif
-#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
-#endif
-#ifdef COUNT_ALLOCS
- /* these must be last */
- 0, /* tp_alloc */
- 0, /* tp_free */
- 0, /* tp_maxalloc */
- 0, /* tp_next */
+#ifdef __cplusplus
+extern "C" {
#endif
-};
-
-/* Create a variable linking object for use later */
-static 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);
- return ((PyObject*) result);
-}
-
-static 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;
- v->vars = gv;
-}
-
/* -----------------------------------------------------------------------------
* errors manipulation
* ----------------------------------------------------------------------------- */
-static void
+SWIGRUNTIME void
SWIG_Python_TypeError(const char *type, PyObject *obj)
{
if (type) {
@@ -199,7 +77,7 @@ SWIG_Python_TypeError(const char *type, PyObject *obj)
}
}
-static SWIGINLINE void
+SWIGRUNTIME void
SWIG_Python_NullRef(const char *type)
{
if (type) {
@@ -209,7 +87,7 @@ SWIG_Python_NullRef(const char *type)
}
}
-static int
+SWIGRUNTIME int
SWIG_Python_AddErrMesg(const char* mesg, int infront)
{
if (PyErr_Occurred()) {
@@ -234,7 +112,7 @@ SWIG_Python_AddErrMesg(const char* mesg, int infront)
}
}
-static int
+SWIGRUNTIME int
SWIG_Python_ArgFail(int argnum)
{
if (PyErr_Occurred()) {
@@ -253,7 +131,7 @@ SWIG_Python_ArgFail(int argnum)
* ----------------------------------------------------------------------------- */
/* Convert a pointer value */
-static int
+SWIGRUNTIME int
SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) {
swig_type_info *tc;
char *c = 0;
@@ -312,6 +190,7 @@ SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags)
}
c++;
c = SWIG_UnpackData(c,&vptr,sizeof(void *));
+ if (!c) goto type_error;
if (newref) { Py_DECREF(obj); }
#endif
@@ -341,6 +220,7 @@ type_error:
if (*c == '_') {
c++;
c = SWIG_UnpackData(c,&vptr,sizeof(void *));
+ if (!c) goto type_error;
goto type_check;
}
}
@@ -357,7 +237,7 @@ type_error:
}
/* Convert a pointer value, signal an exception on a type mismatch */
-static void *
+SWIGRUNTIME void *
SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
void *result;
if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
@@ -371,7 +251,7 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
}
/* Convert a packed value value */
-static int
+SWIGRUNTIME int
SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) {
swig_type_info *tc;
char *c = 0;
@@ -382,6 +262,7 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *t
if (*c != '_') goto type_error;
c++;
c = SWIG_UnpackData(c,ptr,sz);
+ if (!c) goto type_error;
if (ty) {
tc = SWIG_TypeCheck(c,ty);
if (!tc) goto type_error;
@@ -401,7 +282,7 @@ type_error:
}
/* Create a new pointer string */
-static char *
+SWIGRUNTIME char *
SWIG_Python_PointerStr(char *buff, void *ptr, const char *name, size_t bsz) {
char *r = buff;
if ((2*sizeof(void *) + 2) > bsz) return 0;
@@ -414,7 +295,7 @@ SWIG_Python_PointerStr(char *buff, void *ptr, const char *name, size_t bsz) {
/* Create a new pointer object */
-static PyObject *
+SWIGRUNTIME PyObject *
SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) {
PyObject *robj;
if (!ptr) {
@@ -447,7 +328,7 @@ SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) {
return robj;
}
-static PyObject *
+SWIGRUNTIME PyObject *
SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
char result[1024];
char *r = result;
@@ -458,145 +339,68 @@ SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
return PyString_FromString(result);
}
+/* -----------------------------------------------------------------------------*
+ * Get type list
+ * -----------------------------------------------------------------------------*/
-/* -----------------------------------------------------------------------------
- * constants/methods manipulation
- * ----------------------------------------------------------------------------- */
+#ifdef SWIG_LINK_RUNTIME
+void *SWIG_ReturnGlobalTypeList(void *);
+#endif
-/* Install Constants */
-static void
-SWIG_Python_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:
- if (constants[i].pvalue) {
- obj = PyString_FromString((char *) constants[i].pvalue);
- } else {
- Py_INCREF(Py_None);
- obj = Py_None;
- }
- break;
- case SWIG_PY_POINTER:
- obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
- break;
- case SWIG_PY_BINARY:
- obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
- break;
- default:
- obj = 0;
- break;
- }
- if (obj) {
- PyDict_SetItemString(d,constants[i].name,obj);
- Py_DECREF(obj);
+SWIGRUNTIME swig_type_info **
+SWIG_Python_GetTypeListHandle() {
+ static void *type_pointer = (void *)0;
+ /* first check if module already created */
+ if (!type_pointer) {
+#ifdef SWIG_LINK_RUNTIME
+ type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
+#else
+ type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+ (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ type_pointer = (void *)0;
}
}
+#endif
+ return (swig_type_info **) type_pointer;
}
-/* Fix SwigMethods to carry the callback ptrs when needed */
-static void
-SWIG_Python_FixMethods(PyMethodDef *methods,
- swig_const_info *const_table,
- swig_type_info **types,
- swig_type_info **types_initial) {
- int i;
- for (i = 0; methods[i].ml_name; ++i) {
- char *c = methods[i].ml_doc;
- if (c && (c = strstr(c, "swig_ptr: "))) {
- int j;
- swig_const_info *ci = 0;
- char *name = c + 10;
- for (j = 0; const_table[j].type; j++) {
- if (strncmp(const_table[j].name, name,
- strlen(const_table[j].name)) == 0) {
- ci = &(const_table[j]);
- break;
- }
- }
- if (ci) {
- size_t shift = (ci->ptype) - types;
- swig_type_info *ty = types_initial[shift];
- size_t ldoc = (c - methods[i].ml_doc);
- size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
- char *ndoc = (char*)malloc(ldoc + lptr + 10);
- char *buff = ndoc;
- void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue: (void *)(ci->lvalue);
- strncpy(buff, methods[i].ml_doc, ldoc);
- buff += ldoc;
- strncpy(buff, "swig_ptr: ", 10);
- buff += 10;
- SWIG_Python_PointerStr(buff, ptr, ty->name, lptr);
- methods[i].ml_doc = ndoc;
- }
- }
- }
+/*
+ Search for a swig_type_info structure
+ */
+SWIGRUNTIME swig_type_info *
+SWIG_Python_GetTypeList() {
+ swig_type_info **type_list_handle = SWIG_Python_GetTypeListHandle();
+ return type_list_handle ? *type_list_handle : (swig_type_info *)0;
}
+/* -----------------------------------------------------------------------------*
+ * Standard SWIG API
+ * -----------------------------------------------------------------------------*/
-/* -----------------------------------------------------------------------------
- * Lookup type pointer
- * ----------------------------------------------------------------------------- */
-#if PY_MAJOR_VERSION < 2
-/* PyModule_AddObject function was introduced in Python 2.0. The following function
-is copied out of Python/modsupport.c in python version 2.3.4 */
-static int
-PyModule_AddObject(PyObject *m, char *name, PyObject *o)
-{
- PyObject *dict;
- if (!PyModule_Check(m)) {
- PyErr_SetString(PyExc_TypeError,
- "PyModule_AddObject() needs module as first arg");
- return -1;
- }
- if (!o) {
- PyErr_SetString(PyExc_TypeError,
- "PyModule_AddObject() needs non-NULL value");
- return -1;
- }
+SWIGRUNTIME swig_type_info *
+SWIG_Python_TypeQuery(const char *name) {
+ swig_type_info *tl = SWIG_Python_GetTypeList();
+ return SWIG_TypeQueryTL(tl, name);
+}
- dict = PyModule_GetDict(m);
- if (dict == NULL) {
- /* Internal error -- modules must have a dict! */
- PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
- PyModule_GetName(m));
- return -1;
- }
- if (PyDict_SetItemString(dict, name, o))
- return -1;
- Py_DECREF(o);
- return 0;
+SWIGRUNTIME swig_type_info *
+SWIG_Python_TypeRegister(swig_type_info *ti) {
+ swig_type_info **tlh = SWIG_Python_GetTypeListHandle();
+ return SWIG_TypeRegisterTL(tlh, ti);
}
-#endif
-static PyMethodDef swig_empty_runtime_method_table[] = {
- {NULL, NULL, 0, NULL} /* Sentinel */
-};
-static void
-SWIG_Python_LookupTypePointer(swig_type_info ***type_list_handle) {
- PyObject *module, *pointer;
- void *type_pointer;
+SWIGRUNTIME void
+SWIG_Python_TypeClientData(swig_type_info *ti, void *clientdata) {
+ swig_type_info *tl = SWIG_Python_GetTypeList();
+ SWIG_TypeClientDataTL(tl, ti, clientdata);
+}
- /* first check if module already created */
- type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
- if (type_pointer) {
- *type_list_handle = (swig_type_info **) type_pointer;
- } else {
- PyErr_Clear();
- /* create a new module and variable */
- module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
- pointer = PyCObject_FromVoidPtr((void *) (*type_list_handle), NULL);
- if (pointer && module) {
- PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
- }
- }
+SWIGRUNTIME void
+SWIG_Python_PropagateClientData(swig_type_info *type) {
+ swig_type_info *tl = SWIG_Python_GetTypeList();
+ SWIG_PropagateClientDataTL(tl, type);
}
#ifdef __cplusplus
diff --git a/Lib/python/pyrunalias.swg b/Lib/python/pyrunalias.swg
new file mode 100644
index 000000000..2b50f3de1
--- /dev/null
+++ b/Lib/python/pyrunalias.swg
@@ -0,0 +1,9 @@
+/* -----------------------------------------------------------------------------*
+ * Standard SWIG API Alias
+ * -----------------------------------------------------------------------------*/
+
+
+#define SWIG_TypeQuery(name) SWIG_Python_TypeQuery(name)
+#define SWIG_TypeRegister(ti) SWIG_Python_TypeRegister(ti)
+#define SWIG_TypeClientData(ti, cd) SWIG_Python_TypeClientData(ti, cd)
+#define SWIG_PropagateClientData(ti) SWIG_Python_PropagateClientData(ti)
diff --git a/Lib/python/pyruntime.swg b/Lib/python/pyruntime.swg
index d0a3d8514..b22588d14 100644
--- a/Lib/python/pyruntime.swg
+++ b/Lib/python/pyruntime.swg
@@ -1,9 +1,9 @@
/* Python.h has to appear first */
-
%insert(runtime) %{
#include <Python.h>
%}
+%insert(runtime) "swigrun.swg"; /* Common C API type-checking code */
%insert(runtime) "common.swg"; /* Common type-checking code */
%insert(runtime) "pyapi.swg"; /* SWIG/Pyton API */
%insert(runtime) "pyrun.swg"; /* Python run-time code */
diff --git a/Lib/ruby/ruby.swg b/Lib/ruby/ruby.swg
index 0ceccd412..0cb84d6ad 100644
--- a/Lib/ruby/ruby.swg
+++ b/Lib/ruby/ruby.swg
@@ -5,6 +5,7 @@
* ---------------------------------------------------------------------- */
%runtime "rubyhead.swg"
+%runtime "swigrun.swg" // Common C API type-checking code
%runtime "common.swg"
%runtime "rubydef.swg"
diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg
new file mode 100644
index 000000000..1445c19ac
--- /dev/null
+++ b/Lib/swigrun.swg
@@ -0,0 +1,332 @@
+/***********************************************************************
+ * swigrun.swg
+ *
+ * This file contains generic CAPI SWIG runtime support for pointer
+ * type checking.
+ *
+ ************************************************************************/
+
+/* This should only be incremented when either the layout of swig_type_info changes,
+ or for whatever reason, the runtime changes incompatibly */
+#define SWIG_RUNTIME_VERSION "1"
+
+/* 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)
+#else
+#define SWIG_TYPE_TABLE_NAME
+#endif
+
+#include <string.h>
+
+#ifndef SWIGINLINE
+#if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+# define SWIGINLINE inline
+#else
+# define SWIGINLINE
+#endif
+#endif
+
+/*
+ You can use this macro for creating a static or dynamic library.
+ Swig just needs to use it as 'static'
+*/
+#ifndef SWIGRUNTIME
+#define SWIGRUNTIME static
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *(*swig_converter_func)(void *);
+typedef struct swig_type_info *(*swig_dycast_func)(void **);
+
+typedef struct swig_type_info {
+ const char *name;
+ swig_converter_func converter;
+ const char *str;
+ void *clientdata;
+ swig_dycast_func dcast;
+ struct swig_type_info *next;
+ struct swig_type_info *prev;
+} swig_type_info;
+
+/*
+ Compare two type names skipping the space characters, therefore
+ "char*" == "char *" and "Class<int>" == "Class<int >", etc.
+
+ Return 0 when the two name types are equivalent, as in
+ strncmp, but skipping ' '.
+*/
+SWIGRUNTIME int
+SWIG_TypeNameComp(const char *f1, const char *l1,
+ const char *f2, const char *l2) {
+ for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
+ while ((*f1 == ' ') && (f1 != l1)) ++f1;
+ while ((*f2 == ' ') && (f2 != l2)) ++f2;
+ if (*f1 != *f2) return *f1 - *f2;
+ }
+ return (l1 - f1) - (l2 - f2);
+}
+
+/*
+ Check type equivalence in a name list like <name1>|<name2>|...
+*/
+SWIGRUNTIME int
+SWIG_TypeEquiv(const char *nb, const char *tb) {
+ int equiv = 0;
+ const char* te = tb + strlen(tb);
+ const char* ne = nb;
+ while (!equiv && *ne) {
+ for (nb = ne; *ne; ++ne) {
+ if (*ne == '|') break;
+ }
+ equiv = SWIG_TypeNameComp(nb, ne, tb, te) == 0;
+ if (*ne) ++ne;
+ }
+ return equiv;
+}
+
+/*
+ Register a type mapping with the type-checking
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeRegisterTL(swig_type_info **tl, swig_type_info *ti) {
+ swig_type_info *tc, *head, *ret, *next;
+ /* Check to see if this type has already been registered */
+ tc = *tl;
+ while (tc) {
+ /* check simple type equivalence */
+ int typeequiv = (strcmp(tc->name, ti->name) == 0);
+ /* check full type equivalence, resolving typedefs */
+ if (!typeequiv) {
+ /* only if tc is not a typedef (no '|' on it) */
+ if (tc->str && ti->str && !strstr(tc->str,"|")) {
+ typeequiv = SWIG_TypeEquiv(ti->str,tc->str);
+ }
+ }
+ if (typeequiv) {
+ /* Already exists in the table. Just add additional types to the list */
+ if (ti->clientdata) tc->clientdata = ti->clientdata;
+ head = tc;
+ next = tc->next;
+ goto l1;
+ }
+ tc = tc->prev;
+ }
+ head = ti;
+ next = 0;
+
+ /* Place in list */
+ ti->prev = *tl;
+ *tl = ti;
+
+ /* Build linked lists */
+ l1:
+ ret = head;
+ tc = ti + 1;
+ /* Patch up the rest of the links */
+ while (tc->name) {
+ head->next = tc;
+ tc->prev = head;
+ head = tc;
+ tc++;
+ }
+ if (next) next->prev = head;
+ head->next = next;
+
+ return ret;
+}
+
+/*
+ Check the typename
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeCheck(char *c, swig_type_info *ty) {
+ swig_type_info *s;
+ if (!ty) return 0; /* Void pointer */
+ s = ty->next; /* First element always just a name */
+ do {
+ if (strcmp(s->name,c) == 0) {
+ if (s == ty->next) return s;
+ /* Move s to the top of the linked list */
+ s->prev->next = s->next;
+ if (s->next) {
+ s->next->prev = s->prev;
+ }
+ /* Insert s as second element in the list */
+ s->next = ty->next;
+ if (ty->next) ty->next->prev = s;
+ ty->next = s;
+ s->prev = ty;
+ return s;
+ }
+ s = s->next;
+ } while (s && (s != ty->next));
+ return 0;
+}
+
+/*
+ Cast a pointer up an inheritance hierarchy
+*/
+SWIGRUNTIME SWIGINLINE void *
+SWIG_TypeCast(swig_type_info *ty, void *ptr) {
+ if ((!ty) || (!ty->converter)) return ptr;
+ return (*ty->converter)(ptr);
+}
+
+/*
+ Dynamic pointer casting. Down an inheritance hierarchy
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
+ swig_type_info *lastty = ty;
+ if (!ty || !ty->dcast) return ty;
+ while (ty && (ty->dcast)) {
+ ty = (*ty->dcast)(ptr);
+ if (ty) lastty = ty;
+ }
+ return lastty;
+}
+
+/*
+ Return the name associated with this type
+*/
+SWIGRUNTIME SWIGINLINE const char *
+SWIG_TypeName(const swig_type_info *ty) {
+ return ty->name;
+}
+
+/*
+ Return the pretty name associated with this type,
+ that is an unmangled type name in a form presentable to the user.
+*/
+SWIGRUNTIME const char *
+SWIG_TypePrettyName(const swig_type_info *type) {
+ /* The "str" field contains the equivalent pretty names of the
+ type, separated by vertical-bar characters. We choose
+ to print the last name, as it is often (?) the most
+ specific. */
+ if (type->str != NULL) {
+ const char *last_name = type->str;
+ const char *s;
+ for (s = type->str; *s; s++)
+ if (*s == '|') last_name = s+1;
+ return last_name;
+ }
+ else
+ return type->name;
+}
+
+/*
+ Search for a swig_type_info structure
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeQueryTL(swig_type_info *tl, const char *name) {
+ swig_type_info *ty = tl;
+ while (ty) {
+ if (ty->str && (SWIG_TypeEquiv(ty->str,name))) return ty;
+ if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
+ ty = ty->prev;
+ }
+ return 0;
+}
+
+/*
+ Set the clientdata field for a type
+*/
+SWIGRUNTIME void
+SWIG_TypeClientDataTL(swig_type_info *tl, swig_type_info *ti, void *clientdata) {
+ swig_type_info *tc, *equiv;
+ if (ti->clientdata) return;
+ /* if (ti->clientdata == clientdata) return; */
+ ti->clientdata = clientdata;
+ equiv = ti->next;
+ while (equiv) {
+ if (!equiv->converter) {
+ tc = tl;
+ while (tc) {
+ if ((strcmp(tc->name, equiv->name) == 0))
+ SWIG_TypeClientDataTL(tl,tc,clientdata);
+ tc = tc->prev;
+ }
+ }
+ equiv = equiv->next;
+ }
+}
+
+/*
+ Pack binary data into a string
+*/
+SWIGRUNTIME char *
+SWIG_PackData(char *c, void *ptr, size_t sz) {
+ static char hex[17] = "0123456789abcdef";
+ unsigned char *u = (unsigned char *) ptr;
+ const unsigned char *eu = u + sz;
+ register unsigned char uu;
+ for (; u != eu; ++u) {
+ uu = *u;
+ *(c++) = hex[(uu & 0xf0) >> 4];
+ *(c++) = hex[uu & 0xf];
+ }
+ return c;
+}
+
+/*
+ Unpack binary data from a string
+*/
+SWIGRUNTIME char *
+SWIG_UnpackData(char *c, void *ptr, size_t sz) {
+ register unsigned char *u = (unsigned char *) ptr;
+ register const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ register int d = *(c++);
+ register unsigned char uu = 0;
+ if ((d >= '0') && (d <= '9'))
+ uu = ((d - '0') << 4);
+ else if ((d >= 'a') && (d <= 'f'))
+ uu = ((d - ('a'-10)) << 4);
+ else
+ return (char *) 0;
+ d = *(c++);
+ if ((d >= '0') && (d <= '9'))
+ uu |= (d - '0');
+ else if ((d >= 'a') && (d <= 'f'))
+ uu |= (d - ('a'-10));
+ else
+ return (char *) 0;
+ *u = uu;
+ }
+ return c;
+}
+
+/*
+ This function will propagate the clientdata field of type to any new
+ swig_type_info structures that have been added into the list of
+ equivalent types. It is like calling SWIG_TypeClientData(type,
+ clientdata) a second time.
+*/
+SWIGRUNTIME void
+SWIG_PropagateClientDataTL(swig_type_info *tl, swig_type_info *type) {
+ swig_type_info *equiv = type->next;
+ swig_type_info *tc;
+ if (!type->clientdata) return;
+ while (equiv) {
+ if (!equiv->converter) {
+ tc = tl;
+ while (tc) {
+ if ((strcmp(tc->name, equiv->name) == 0) && !tc->clientdata)
+ SWIG_TypeClientDataTL(tl,tc, type->clientdata);
+ tc = tc->prev;
+ }
+ }
+ equiv = equiv->next;
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/Lib/tcl/tcl8.swg b/Lib/tcl/tcl8.swg
index a0e03cbb1..f921409dc 100644
--- a/Lib/tcl/tcl8.swg
+++ b/Lib/tcl/tcl8.swg
@@ -4,6 +4,7 @@
* Tcl8 configuration module.
* ----------------------------------------------------------------------------- */
+%runtime "swigrun.swg" // Common C API type-checking code
%runtime "common.swg"
%runtime "swigtcl8.swg"