more fixes for python 1.5 +gcc2.96

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7301 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-06-17 19:12:21 +00:00
commit 327bbc06ac
8 changed files with 54 additions and 37 deletions

View file

@ -1,6 +1,6 @@
%module friends
%{
#include <istream>
#include <iostream>
%}
%warnfilter(503);

View file

@ -4,7 +4,7 @@
#######################################################################
LANGUAGE = python
PYTHON = python
PYTHON = @PYTHON@
SCRIPTSUFFIX = _runme.py
srcdir = @srcdir@
top_srcdir = @top_srcdir@

View file

@ -254,38 +254,6 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
* 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 */
SWIGINTERN 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
#ifdef __cplusplus
}
#endif

View file

@ -70,7 +70,7 @@ PyString_FromFormat(const char *fmt, ...) {
#endif
#if PY_VERSION_HEX < 0x01060000
#define PyObject_Del(op) PyMem_Del((op))
#define PyObject_Del(op) PyMem_DEL((op))
#endif
#if defined(SWIG_COBJECT_TYPES)
@ -788,6 +788,38 @@ SWIG_Python_GetModule(void) {
return (swig_module_info *) 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 */
SWIGINTERN 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
SWIGRUNTIME void
SWIG_Python_SetModule(swig_module_info *swig_module) {
static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */

View file

@ -16,6 +16,14 @@
#define SWIG_STD_NOINSERT_TEMPLATE_STL
#endif
#if defined(__GNUC__)
# if __GNUC__ == 2 && __GNUC_MINOR <= 96
# define SWIG_STD_NOMODERN_STL
# endif
#endif
%}
//

View file

@ -2,7 +2,11 @@
%include <std_basic_string.i>
%include <std_except.i>
%{
#include <ios>
#ifndef SWIG_STD_NOMODERN_STL
# include <ios>
#else
# include <streambuf.h>
#endif
%}
namespace std {

View file

@ -1,6 +1,10 @@
%include <std_ios.i>
%{
#ifndef SWIG_STD_NOMODERN_STL
#include <streambuf>
#else
#include <streambuf.h>
#endif
%}
namespace std {

View file

@ -390,7 +390,8 @@ public:
// Try loading weakref.proxy, which is only available in Python 2.1 and higher
Printv(f_shadow,
"try:\n",
tab4, "from weakref import proxy as weakref_proxy\n",
tab4, "import weakref\n",
tab4, "weakref_proxy = weakref.proxy\n",
"except:\n",
tab4, "weakref_proxy = lambda x: x\n",
"\n\n",