[ swig-Bugs-1752597 ] Duplicate function with smart pointer + static overload
SourceForge.net <noreply <at> sourceforge.net>
2007-07-12 12:31:45 GMT
Bugs item #1752597, was opened at 2007-07-12 13:31
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=101645&aid=1752597&group_id=1645
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: code generation (general)
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Matt Bergin (mbergin)
Assigned to: David M. Beazley (beazley)
Summary: Duplicate function with smart pointer + static overload
Initial Comment:
The following code (test.i) run with:
swig -c++ -python
generates a duplicate _wrap_C_f function in test_wrap.cxx. I'm using
version 1.3.31 compiled with g++.
Swig prints a warning "Declaration of 'f' shadows
declaration accessible via operator->()" if static void f(int) is
removed. Adding %ignore C::operator->; fixes the problem but disables
the smart pointer functionality.
test.i
------------------------------
%module test
struct A
{
virtual void f();
};
struct B {};
struct C : public B
{
A* operator->();
static void f();
static void f(int);
};
------------------------------
The method table looks like this:
static PyMethodDef SwigMethods[] = {
{ (char *)"A_f", _wrap_A_f, METH_VARARGS, NULL},
{ (char *)"new_A", _wrap_new_A, METH_VARARGS, NULL},
{ (char *)"delete_A", _wrap_delete_A, METH_VARARGS, NULL},
{ (char *)"A_swigregister", A_swigregister, METH_VARARGS, NULL},
{ (char *)"new_B", _wrap_new_B, METH_VARARGS, NULL},
{ (char *)"delete_B", _wrap_delete_B, METH_VARARGS, NULL},
{ (char *)"B_swigregister", B_swigregister, METH_VARARGS, NULL},
{ (char *)"C___deref__", _wrap_C___deref__, METH_VARARGS, NULL},
{ (char *)"C_f", _wrap_C_f, METH_VARARGS, NULL},
{ (char *)"new_C", _wrap_new_C, METH_VARARGS, NULL},
{ (char *)"delete_C", _wrap_delete_C, METH_VARARGS, NULL},
{ (char *)"C_f", _wrap_C_f, METH_VARARGS, NULL},
{ (char *)"C_swigregister", C_swigregister, METH_VARARGS, NULL},
{ NULL, NULL, 0, NULL }
};
------------------------------
static void C::f and its overloads:
SWIGINTERN PyObject *_wrap_C_f__SWIG_0(PyObject *SWIGUNUSEDPARM(self),
PyObject *args) {
PyObject *resultobj = 0;
if (!PyArg_ParseTuple(args,(char *)":C_f")) SWIG_fail;
C::f();
resultobj = SWIG_Py_Void();
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_C_f__SWIG_1(PyObject *SWIGUNUSEDPARM(self),
PyObject *args) {
PyObject *resultobj = 0;
int arg1 ;
int val1 ;
int ecode1 = 0 ;
PyObject * obj0 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"O:C_f",&obj0)) SWIG_fail;
ecode1 = SWIG_AsVal_int(obj0, &val1);
if (!SWIG_IsOK(ecode1)) {
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "C_f" "',
argument " "1"" of type '" "int""'");
}
arg1 = static_cast< int >(val1);
C::f(arg1);
resultobj = SWIG_Py_Void();
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_C_f(PyObject *self, PyObject *args) {
int argc;
PyObject *argv[2];
int ii;
if (!PyTuple_Check(args)) SWIG_fail;
argc = PyObject_Length(args);
for (ii = 0; (ii < argc) && (ii < 1); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
if (argc == 0) {
return _wrap_C_f__SWIG_0(self, args);
}
if (argc == 1) {
int _v;
{
int res = SWIG_AsVal_int(argv[0], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
return _wrap_C_f__SWIG_1(self, args);
}
}
fail:
SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments
for overloaded function 'C_f'.\n Possible C/C++ prototypes are:\n
f()\n C::f(int)\n");
return NULL;
}
------------------------------
virtual void C::f:
SWIGINTERN PyObject *_wrap_C_f(PyObject *SWIGUNUSEDPARM(self), PyObject
*args) {
PyObject *resultobj = 0;
C *arg1 = (C *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"O:C_f",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_C, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "C_f" "',
argument " "1"" of type '" "C *""'");
}
arg1 = reinterpret_cast< C * >(argp1);
(*arg1)->f();
resultobj = SWIG_Py_Void();
return resultobj;
fail:
return NULL;
}
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=101645&aid=1752597&group_id=1645
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/