Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1260 Bug in typemap search for SWIGTYPE const [ANY]

None
closed
5
2013-02-17
2012-07-17
Karl Wette
No

There seems to be a bug in SWIG's (v2.0.7) typemap search for SWIGTYPE const [ANY] typemaps. Given the following interface:

===== test.i =====
%module test;

%typemap(in) SWIGTYPE [ANY], SWIGTYPE const [ANY] {
/* mytypemap $1_dim0 */
}

typedef double myarray[7];

//%apply SWIGTYPE[ANY] { double[7] };

void myfunction(myarray a, myarray const b);
----- test.i -----

if I compile with

swig -python -debug-tmsearch test.i

(although this does not seem to be Python-specific), I get the following output:

test.i:11: Searching for a suitable 'in' typemap for: myarray a
Looking for: myarray a
Looking for: myarray
Looking for: double a[7]
Looking for: double [7]
Looking for: double a[ANY]
Looking for: double [ANY]
Looking for: SWIGTYPE a[ANY]
Looking for: SWIGTYPE [ANY]
Using: %typemap(in) SWIGTYPE [ANY]
test.i:11: Searching for a suitable 'in' typemap for: myarray const b
Looking for: myarray const b
Looking for: myarray const
Looking for: myarray b
Looking for: myarray
Looking for: double const b[7]
Looking for: double const [7]
Looking for: double b[7]
Looking for: double [7]
Looking for: double b[ANY]
Looking for: double [ANY]
Looking for: SWIGTYPE const b[ANY]
Looking for: SWIGTYPE const [ANY]
Looking for: SWIGTYPE const b[]
Looking for: SWIGTYPE const []
Looking for: SWIGTYPE *const b
Looking for: SWIGTYPE *const
Using: %apply SWIGTYPE * { SWIGTYPE *const }

i.e. the typemap is correctly found for type myarray, but not for myarray const. For some reason SWIGTYPE const [ANY] is being rejected.

If I manually apply the typemap by uncommenting the %apply line in test.i, however, it works:

test.i:11: Searching for a suitable 'in' typemap for: myarray a
Looking for: myarray a
Looking for: myarray
Looking for: double a[7]
Looking for: double [7]
Using: %apply SWIGTYPE [ANY] { double [7] }
test.i:11: Searching for a suitable 'in' typemap for: myarray const b
Looking for: myarray const b
Looking for: myarray const
Looking for: myarray b
Looking for: myarray
Looking for: double const b[7]
Looking for: double const [7]
Looking for: double b[7]
Looking for: double [7]
Using: %apply SWIGTYPE [ANY] { double [7] }

and $1_dim0 is given the correct value (7) in the wrapping code.

Discussion

  • Karl Wette
    Karl Wette
    2013-02-17

    • status: open --> closed
    • milestone: -->