Menu

#964 Multi-argument typemaps without variable names do not work

open
nobody
5
2022-03-07
2008-11-19
No

I want to create a typemap for two sequential argument types but I don't want to specify the variable names. The documentation states that this should be possible, but multi-argument typemaps only seem to work when variable names are given:

-----------------------------
%module multi_test;

/*
// Does not work
%typemap(default) (int &, int &) {
// FOUND
}
*/

// Works
%typemap(default) (int &a, int &b) {
// FOUND
}

class Foobar {
public:
Foobar();
void test(int &a, int &b);
~Foobar();
};
-----------------------------

BTW, I saw this also reported at the following URL but did not find a bug submitted for it:
http://thread.gmane.org/gmane.comp.programming.swig/8527/focus=8536

Discussion

  • James Masters

    James Masters - 2008-11-19

    I forgot to mention that I'm using SWIG 1.3.36.

     
  • Olly Betts

    Olly Betts - 2022-03-07

    Reproduced with current git master.

    Interestingly %typemap(default) (int &a, int &) { also works, but %typemap(default) (int &, int &b) { doesn't.

    I don't see where in the docs it explicitly says that omitting the parameters should work though.

    I do see this text (which has been there since before 2002 it seems):

    Multi-argument typemaps are also more restrictive in the way that they are matched.
    Currently, the first argument follows the matching rules described in the previous section,
    but all subsequent arguments must match exactly.

    That actually suggests to me that %typemap(default) (int &, int &b) { would work but not %typemap(default) (int &a, int &) { (i.e. the opposite of the actual situation).

    The output with -debug-tmsearch shows the typemaps don't match when they don't match, but doesn't help me understand why not.

     

Log in to post a comment.