add more backward comp macros/fragments/methods

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8590 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2006-01-28 08:48:48 +00:00
commit 3de733ebc4
3 changed files with 103 additions and 12 deletions

View file

@ -1,13 +1,4 @@
%include <typemaps/swigmacros.swg>
/*
adding backward compatibility macros
please move to the macros names defined in
Lib/typemaps/swigmacros.swg
*/
#define SWIG_arg(x...) %arg(x)
#define SWIG_Mangle(x...) %mangle(x)

View file

@ -77,9 +77,6 @@
#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1)
/* For backward compatibility only */
#define SWIG_POINTER_EXCEPTION 0
#ifdef __cplusplus
extern "C" {
#if 0
@ -1211,6 +1208,104 @@ SWIG_Python_SetModule(swig_module_info *swig_module) {
}
}
/*
For backward compatibility only
*/
#define SWIG_POINTER_EXCEPTION 0
#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg)
#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
SWIGRUNTIME int
SWIG_Python_AddErrMesg(const char* mesg, int infront)
{
if (PyErr_Occurred()) {
PyObject *type = 0;
PyObject *value = 0;
PyObject *traceback = 0;
PyErr_Fetch(&type, &value, &traceback);
if (value) {
PyObject *old_str = PyObject_Str(value);
Py_XINCREF(type);
PyErr_Clear();
if (infront) {
PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
} else {
PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
}
Py_DECREF(old_str);
}
return 1;
} else {
return 0;
}
}
SWIGRUNTIME int
SWIG_Python_ArgFail(int argnum)
{
if (PyErr_Occurred()) {
/* add information about failing argument */
char mesg[256];
PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
return SWIG_Python_AddErrMesg(mesg, 1);
} else {
return 0;
}
}
SWIGRUNTIME void
SWIG_Python_TypeError(const char *type, PyObject *obj)
{
if (type) {
#if defined(SWIG_COBJECT_TYPES)
if (obj && PySwigObject_Check(obj)) {
const char *otype = (const char *) PySwigObject_GetDesc(obj);
if (otype) {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received",
type, otype);
return;
}
} else
#endif
{
const char *otype = (obj ? obj->ob_type->tp_name : 0);
if (otype) {
PyObject *str = PyObject_Str(obj);
const char *cstr = str ? PyString_AsString(str) : 0;
if (cstr) {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
type, otype, cstr);
} else {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
type, otype);
}
Py_XDECREF(str);
return;
}
}
PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
} else {
PyErr_Format(PyExc_TypeError, "unexpected type is received");
}
}
/* Convert a pointer value, signal an exception on a type mismatch */
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) {
PyErr_Clear();
if (flags & SWIG_POINTER_EXCEPTION) {
SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
SWIG_Python_ArgFail(argnum);
}
}
return result;
}
#ifdef __cplusplus
#if 0
{ /* cc-mode */

View file

@ -55,4 +55,9 @@
%include <pyinit.swg>
/* ------------------------------------------------------------
* For backward compatibility
* ------------------------------------------------------------ */
%include <pybackward.swg>