Menu

#1329 %ignore discrepancy with quotes and fullname

None
open
nobody
%ignore (1)
5
2022-03-03
2013-07-17
Javi
No

This bug ticket refers to the problem described here.

Basically the problem is that when using the %rename("$ignore") directive with the quotes on an overloaded function it does not work, however if the function is not over loaded the directive works fine.

I think thebehaviour should be the same in both cases, with quotes or without them, but the same.

The full example consists of three clases SomeClass, ComplexData and SimpleData. At the end the .i file is included.

#ifndef SIMPLEDATA_H_
#define SIMPLEDATA_H_

namespace ns1 {

class SimpleData {
public:
    SimpleData(){}
    virtual ~SimpleData(){}
};

} /* namespace ns1 */
#endif /* SIMPLEDATA_H_ */

#ifndef COMPLEXDATA_H_
#define COMPLEXDATA_H_

namespace ns2 {

class ComplexData {
public:
    ComplexData(){}
    virtual ~ComplexData(){}
};

} /* namespace ns2 */
#endif /* COMPLEXDATA_H_ */

#ifndef SOMECLASS_H_
#define SOMECLASS_H_

#include "SimpleData.h"
#include "ComplexData.h"

namespace ns3 {

class SomeClass {
public:
    SomeClass(){}
    bool someMethod(const ns1::SimpleData & data){return true;}
    bool someMethod(const ns2::ComplexData & data){return true;}
    bool someMethod(const int & data){return true;}
    bool anotherMethod();
    virtual ~SomeClass(){}
};

} /* namespace ns3 */
#endif /* SOMECLASS_H_ */

The .i file:

%module libSomeClass

%{
    #include "../src/SomeClass.h"
%}

%pragma(java) jniclasscode=%{
    static {
        try {
            System.loadLibrary("SWIG_C++");
        } catch (UnsatisfiedLinkError e) {
            System.err.println("Native code library failed to load. \n" + e);
            System.exit(1);
        }
    }
%}

// SimpleData
%include "../src/SimpleData.h"

//removes too much
//%rename ("$ignore", fullname=1) "ns3::SomeClass::someMethod";

//does not work
%rename ("$ignore", fullname=1) "ns3::SomeClass::someMethod(const ns2::ComplexData &)";

%rename ("renamedMethod", fullname=1) "ns3::SomeClass::anotherMethod";

%include "../src/SomeClass.h"

Discussion

  • Olly Betts

    Olly Betts - 2022-03-03
    • Group: -->
     
  • Olly Betts

    Olly Betts - 2022-03-03

    Still the same with git master.

    Looks like there are 3 different %rename cases in Source/CParse/parser.y and the quotes mean it takes the last one rather than the second.

    I'm not sure this is a correct use of %rename though - none of the examples in the manual show a quoted target name except for regex rename cases.

    If it isn't valid, it ought to be flagged as an error.

     

Log in to post a comment.