#1224 namespace + operator in default argument parsed uncorrectly

open
Marcelo Matus
parsing (147)
5
2012-12-21
2012-02-19
Martin Fiers
No

I got this error while trying to compile python-meep (https://launchpad.net/python-meep) with kwargs on. The following function is wrapped incorrectly:

in meep.hpp:

namespace meep {

class custom_src_time {
custom_src_time(complex<double> (*func)(double t, void *), void *data,
double st = -infinity, double et = infinity)

}
}

In the wrapped file meep_wrap.cpp, the following definition is found:

SWIGINTERN PyObject *_wrap_new_custom_src_time(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
std::complex< double > (*arg1)(double,void *) = (std::complex< double > (*)(double,void *)) 0 ;
void *arg2 = (void *) 0 ;
double arg3 = (double) -infinity;
double arg4 = (double) meep::infinity ;

So the minus sign causes the meep:: namespace to dissapear. I tried putting brackets around infinity in meep.hpp, but the resulting line in the wrapped file is then
double arg3 = (double) -(infinity);

As a consequence I cannot compile python-meep:
meep_wrap.cpp:26456:28: error: ‘infinity’ was not declared in this scope
meep_wrap.cpp:26456:28: note: suggested alternative:
/usr/include/meep.hpp:46:14: note: ‘meep::infinity’

Regards,
Martin Fiers

Discussion

  • William Fulton
    William Fulton
    2012-05-14

    The full qualification of the symbol is currently done in normalize_parms() in typepass.cxx. The fix should go in here where the expression will need to be decomposed for qualification - rather tricky for all types of expressions, particularly if involving templates. Otherwise the fix might have to be in the parser.