Updated SWIG patches and wxPython's SWIG runtime

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25319 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-01-22 22:31:34 +00:00
parent e20e6988ac
commit 1de47c7cb4
4 changed files with 210 additions and 43 deletions

View File

@@ -1,10 +1,10 @@
Index: Source/Modules/python.cxx Index: Source/Modules/python.cxx
=================================================================== ===================================================================
RCS file: /cvsroot/SWIG/Source/Modules/python.cxx,v RCS file: /cvsroot/SWIG/Source/Modules/python.cxx,v
retrieving revision 1.35 retrieving revision 1.38
diff -u -4 -r1.35 python.cxx diff -u -4 -r1.38 python.cxx
--- Source/Modules/python.cxx 13 Dec 2003 23:52:31 -0000 1.35 --- Source/Modules/python.cxx 21 Jan 2004 01:33:07 -0000 1.38
+++ Source/Modules/python.cxx 19 Dec 2003 02:04:45 -0000 +++ Source/Modules/python.cxx 22 Jan 2004 01:59:33 -0000
@@ -54,8 +54,17 @@ @@ -54,8 +54,17 @@
static int have_constructor; static int have_constructor;
static int have_repr; static int have_repr;
@@ -23,7 +23,7 @@ diff -u -4 -r1.35 python.cxx
Python Options (available with -python)\n\ Python Options (available with -python)\n\
-ldflags - Print runtime libraries to link with\n\ -ldflags - Print runtime libraries to link with\n\
-globals <name> - Set <name> used to access C global variable [default: 'cvar']\n\ -globals <name> - Set <name> used to access C global variable [default: 'cvar']\n\
@@ -417,17 +426,23 @@ @@ -421,17 +430,23 @@
* functions. * functions.
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */
@@ -52,7 +52,7 @@ diff -u -4 -r1.35 python.cxx
} }
@@ -441,8 +456,256 @@ @@ -445,8 +460,256 @@
} }
@@ -309,7 +309,7 @@ diff -u -4 -r1.35 python.cxx
* Check if there is a %addtofunc directive and it has text * Check if there is a %addtofunc directive and it has text
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */
@@ -1700,9 +1963,11 @@ @@ -1702,9 +1965,11 @@
Printf(f_shadow, modern ? "(object)" : "(_object)"); Printf(f_shadow, modern ? "(object)" : "(_object)");
} }
} }
@@ -322,7 +322,7 @@ diff -u -4 -r1.35 python.cxx
Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL); Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL);
if (Len(base_class)) { if (Len(base_class)) {
Printf(f_shadow,"%sfor _s in [%s]: __swig_setmethods__.update(_s.__swig_setmethods__)\n",tab4,base_class); Printf(f_shadow,"%sfor _s in [%s]: __swig_setmethods__.update(_s.__swig_setmethods__)\n",tab4,base_class);
@@ -1835,16 +2100,22 @@ @@ -1837,16 +2102,22 @@
Delete(pyaction); Delete(pyaction);
Printv(f_shadow,pycode,"\n",NIL); Printv(f_shadow,pycode,"\n",NIL);
} else { } else {
@@ -352,7 +352,7 @@ diff -u -4 -r1.35 python.cxx
} }
} }
@@ -1859,14 +2130,20 @@ @@ -1861,14 +2132,20 @@
virtual int staticmemberfunctionHandler(Node *n) { virtual int staticmemberfunctionHandler(Node *n) {
String *symname = Getattr(n,"sym:name"); String *symname = Getattr(n,"sym:name");
Language::staticmemberfunctionHandler(n); Language::staticmemberfunctionHandler(n);
@@ -377,7 +377,7 @@ diff -u -4 -r1.35 python.cxx
" = staticmethod(", symname, ")\n", NIL); " = staticmethod(", symname, ")\n", NIL);
if (!modern) { if (!modern) {
@@ -1951,8 +2228,10 @@ @@ -1953,8 +2230,10 @@
} }
Printv(f_shadow, tab4, "def __init__(self, *args", Printv(f_shadow, tab4, "def __init__(self, *args",
@@ -388,7 +388,7 @@ diff -u -4 -r1.35 python.cxx
if (!modern) { if (!modern) {
Printv(f_shadow, tab8, "_swig_setattr(self, ", rclassname, ", 'this', ", Printv(f_shadow, tab8, "_swig_setattr(self, ", rclassname, ", 'this', ",
funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL); funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL);
@@ -1966,9 +2245,9 @@ @@ -1968,9 +2247,9 @@
Printv(f_shadow, tab8, "self.thisown = 1\n", NIL); Printv(f_shadow, tab8, "self.thisown = 1\n", NIL);
Printv(f_shadow, tab8, "del newobj.thisown\n", NIL); Printv(f_shadow, tab8, "del newobj.thisown\n", NIL);
} }
@@ -399,7 +399,7 @@ diff -u -4 -r1.35 python.cxx
} }
have_constructor = 1; have_constructor = 1;
} else { } else {
@@ -1984,8 +2263,10 @@ @@ -1986,8 +2265,10 @@
} else { } else {
Printv(f_shadow_stubs, "\ndef ", symname, "(*args", Printv(f_shadow_stubs, "\ndef ", symname, "(*args",
@@ -410,7 +410,7 @@ diff -u -4 -r1.35 python.cxx
funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL); funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL);
Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL);
if ( have_addtofunc(n) ) if ( have_addtofunc(n) )
@@ -2017,13 +2298,15 @@ @@ -2019,13 +2300,15 @@
Delete(pyaction); Delete(pyaction);
Printv(f_shadow,pycode,"\n", NIL); Printv(f_shadow,pycode,"\n", NIL);
} else { } else {

View File

@@ -1,11 +1,11 @@
Index: Source/Swig/swig.h Index: Source/Swig/swig.h
=================================================================== ===================================================================
RCS file: /cvsroot/SWIG/Source/Swig/swig.h,v RCS file: /cvsroot/SWIG/Source/Swig/swig.h,v
retrieving revision 1.76 retrieving revision 1.79
diff -u -4 -r1.76 swig.h diff -u -4 -r1.79 swig.h
--- Source/Swig/swig.h 11 Nov 2003 20:16:35 -0000 1.76 --- Source/Swig/swig.h 15 Jan 2004 22:46:07 -0000 1.79
+++ Source/Swig/swig.h 18 Dec 2003 22:03:45 -0000 +++ Source/Swig/swig.h 22 Jan 2004 01:57:53 -0000
@@ -350,8 +350,10 @@ @@ -354,8 +354,10 @@
extern void Swig_print_tags(File *obj, Node *root); extern void Swig_print_tags(File *obj, Node *root);
extern void Swig_print_tree(Node *obj); extern void Swig_print_tree(Node *obj);
extern void Swig_print_node(Node *obj); extern void Swig_print_node(Node *obj);
@@ -19,15 +19,15 @@ diff -u -4 -r1.76 swig.h
Index: Source/Modules/main.cxx Index: Source/Modules/main.cxx
=================================================================== ===================================================================
RCS file: /cvsroot/SWIG/Source/Modules/main.cxx,v RCS file: /cvsroot/SWIG/Source/Modules/main.cxx,v
retrieving revision 1.27 retrieving revision 1.32
diff -u -4 -r1.27 main.cxx diff -u -4 -r1.32 main.cxx
--- Source/Modules/main.cxx 16 Dec 2003 03:43:51 -0000 1.27 --- Source/Modules/main.cxx 15 Jan 2004 22:46:05 -0000 1.32
+++ Source/Modules/main.cxx 18 Dec 2003 22:03:45 -0000 +++ Source/Modules/main.cxx 22 Jan 2004 01:57:53 -0000
@@ -87,15 +87,17 @@ @@ -94,15 +94,17 @@
-Wall - Enable all warning messages\n\ -w+321,401,-402 \n\
-Wallkw - Enable warning messages for all the languages keywords\n\ \n\
-Werror - Force to treat the warnings as errors\n\ where code 321(+) is added, and 401(no sign) and 402(-) \n\
-w<n> - Suppress warning number <n>\n\ are suppressed. See documentation for code meanings.\n\
+ -xmlout <file> - Write an XML version of the parse tree to file after normal processing\n\ + -xmlout <file> - Write an XML version of the parse tree to file after normal processing\n\
\n"; \n";
@@ -41,9 +41,9 @@ diff -u -4 -r1.27 main.cxx
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// check_suffix(char *name) // check_suffix(char *name)
// //
@@ -224,8 +226,9 @@ @@ -218,8 +220,9 @@
char *includefiles[256];
int includecount = 0; int includecount = 0;
extern int check_suffix(char *);
int dump_tags = 0; int dump_tags = 0;
int dump_tree = 0; int dump_tree = 0;
+ int dump_xml = 0; + int dump_xml = 0;
@@ -51,7 +51,7 @@ diff -u -4 -r1.27 main.cxx
int dump_typedef = 0; int dump_typedef = 0;
int dump_classes = 0; int dump_classes = 0;
int werror = 0; int werror = 0;
@@ -490,8 +493,20 @@ @@ -486,8 +489,20 @@
Swig_mark_arg(i); Swig_mark_arg(i);
} else if (strcmp(argv[i],"-dump_tree") == 0) { } else if (strcmp(argv[i],"-dump_tree") == 0) {
dump_tree = 1; dump_tree = 1;
@@ -72,7 +72,7 @@ diff -u -4 -r1.27 main.cxx
Swig_mark_arg(i); Swig_mark_arg(i);
Swig_contract_mode_set(0); Swig_contract_mode_set(0);
} else if (strcmp(argv[i],"-browse") == 0) { } else if (strcmp(argv[i],"-browse") == 0) {
@@ -736,8 +751,11 @@ @@ -737,8 +752,11 @@
} }
} }
if (dump_tree) { if (dump_tree) {
@@ -87,10 +87,10 @@ diff -u -4 -r1.27 main.cxx
Index: Source/Modules/xml.cxx Index: Source/Modules/xml.cxx
=================================================================== ===================================================================
RCS file: /cvsroot/SWIG/Source/Modules/xml.cxx,v RCS file: /cvsroot/SWIG/Source/Modules/xml.cxx,v
retrieving revision 1.8 retrieving revision 1.9
diff -u -4 -r1.8 xml.cxx diff -u -4 -r1.9 xml.cxx
--- Source/Modules/xml.cxx 31 Oct 2003 17:42:40 -0000 1.8 --- Source/Modules/xml.cxx 28 Dec 2003 21:47:58 -0000 1.9
+++ Source/Modules/xml.cxx 18 Dec 2003 22:03:45 -0000 +++ Source/Modules/xml.cxx 22 Jan 2004 01:57:53 -0000
@@ -109,9 +109,9 @@ @@ -109,9 +109,9 @@
Printf(stderr,"*** Can't open '%s'\n", outfile); Printf(stderr,"*** Can't open '%s'\n", outfile);
SWIG_exit(EXIT_FAILURE); SWIG_exit(EXIT_FAILURE);
@@ -137,11 +137,11 @@ diff -u -4 -r1.8 xml.cxx
} }
indent_level -= 4; indent_level -= 4;
print_indent(0); print_indent(0);
@@ -337,5 +337,36 @@ @@ -334,5 +334,36 @@
Language * swig_xml( void )
{ extern "C" Language *
swig_xml( void ) {
return new XML(); return new XML();
}
+} +}
+ +
+ +

View File

@@ -33,6 +33,7 @@
#define SWIG_PackData SWIG_Python_PackData #define SWIG_PackData SWIG_Python_PackData
#define SWIG_UnpackData SWIG_Python_UnpackData #define SWIG_UnpackData SWIG_Python_UnpackData
/*********************************************************************** /***********************************************************************
* common.swg * common.swg
* *

View File

@@ -10,6 +10,172 @@
#include "Python.h" #include "Python.h"
#include <limits.h>
#include <float.h>
#ifdef __cplusplus
#define SWIG_STATIC_INLINE static inline
#else
#define SWIG_STATIC_INLINE static
#endif
SWIG_STATIC_INLINE long
SPyObj_AsLong(PyObject * obj)
{
return PyInt_Check(obj) ? PyInt_AsLong(obj) : PyLong_AsLong(obj);
}
SWIG_STATIC_INLINE unsigned long
SPyObj_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;
}
}
SWIG_STATIC_INLINE PyObject*
SPyObj_FromLongLong(long long value)
{
return (value > (long)(LONG_MAX)) ?
PyLong_FromLongLong(value) : PyInt_FromLong((long)value);
}
SWIG_STATIC_INLINE PyObject*
SPyObj_FromUnsignedLong(unsigned long value)
{
return (value > (unsigned long)(LONG_MAX)) ?
PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)value);
}
SWIG_STATIC_INLINE PyObject*
SPyObj_FromUnsignedLongLong(unsigned long long value)
{
return (value > (unsigned long long)(LONG_MAX)) ?
PyLong_FromUnsignedLongLong(value) : PyInt_FromLong((long)value);
}
SWIG_STATIC_INLINE long
SPyObj_AsLongInRange(PyObject * obj, long min_value, long max_value)
{
long value = SPyObj_AsLong(obj);
if (!PyErr_Occurred()) {
if (value < min_value) {
PyErr_SetString(PyExc_OverflowError,"value is smaller than type minimum");
} else if (value > max_value) {
PyErr_SetString(PyExc_OverflowError,"value is greater than type maximum");
}
}
return value;
}
SWIG_STATIC_INLINE unsigned long
SPyObj_AsUnsignedLongInRange(PyObject *obj, unsigned long max_value)
{
unsigned long value = SPyObj_AsUnsignedLong(obj);
if (!PyErr_Occurred()) {
if (value > max_value) {
PyErr_SetString(PyExc_OverflowError,"value is greater than type maximum");
}
}
return value;
}
SWIG_STATIC_INLINE signed char
SPyObj_AsSignedChar(PyObject *obj) {
return SPyObj_AsLongInRange(obj, SCHAR_MIN, SCHAR_MAX);
}
SWIG_STATIC_INLINE short
SPyObj_AsShort(PyObject *obj) {
return SPyObj_AsLongInRange(obj, SHRT_MIN, SHRT_MAX);
}
SWIG_STATIC_INLINE int
SPyObj_AsInt(PyObject *obj) {
return SPyObj_AsLongInRange(obj, INT_MIN, INT_MAX);
}
SWIG_STATIC_INLINE unsigned char
SPyObj_AsUnsignedChar(PyObject *obj) {
return SPyObj_AsUnsignedLongInRange(obj, UCHAR_MAX);
}
SWIG_STATIC_INLINE unsigned short
SPyObj_AsUnsignedShort(PyObject *obj) {
return SPyObj_AsUnsignedLongInRange(obj, USHRT_MAX);
}
SWIG_STATIC_INLINE unsigned int
SPyObj_AsUnsignedInt(PyObject *obj) {
return SPyObj_AsUnsignedLongInRange(obj, UINT_MAX);
}
SWIG_STATIC_INLINE long long
SPyObj_AsLongLong(PyObject *obj) {
return PyInt_Check(obj) ?
PyInt_AsLong(obj) : PyLong_AsLongLong(obj);
}
SWIG_STATIC_INLINE unsigned long long
SPyObj_AsUnsignedLongLong(PyObject *obj) {
return PyLong_Check(obj) ?
PyLong_AsUnsignedLongLong(obj) : SPyObj_AsUnsignedLong(obj);
}
SWIG_STATIC_INLINE double
SPyObj_AsDouble(PyObject *obj) {
return (PyFloat_Check(obj)) ? PyFloat_AsDouble(obj) :
(double)((PyInt_Check(obj)) ? PyInt_AsLong(obj) : PyLong_AsLongLong(obj));
}
SWIG_STATIC_INLINE float
SPyObj_AsFloat(PyObject *obj) {
double value = SPyObj_AsDouble(obj);
if (!PyErr_Occurred()) {
if (value < FLT_MIN) {
PyErr_SetString(PyExc_OverflowError,"float is smaller than flt_min");
} else if (value > FLT_MAX) {
PyErr_SetString(PyExc_OverflowError,"float is greater than flt_max");
}
}
return (float) value;
}
SWIG_STATIC_INLINE char
SPyObj_AsChar(PyObject *obj) {
char c = (PyString_Check(obj) && PyString_Size(obj) == 1) ?
PyString_AsString(obj)[0]
: (char) SPyObj_AsLongInRange(obj, CHAR_MIN, CHAR_MAX);
if (PyErr_Occurred()) {
PyErr_Clear();
PyErr_SetString(PyExc_TypeError, "a char is required");
}
return c;
}
SWIG_STATIC_INLINE PyObject *
SPyObj_FromChar(char c) {
return PyString_FromStringAndSize(&c,1);
}
SWIG_STATIC_INLINE PyObject *
SPyObj_FromCharPtr(const char* cptr) {
return cptr ? PyString_FromString(cptr) : Py_BuildValue((char*)"");
}
SWIG_STATIC_INLINE int
SPyObj_AsBool(PyObject *obj) {
return SPyObj_AsLongLong(obj) ? 1 : 0;
}
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif