c++swig

SWIG how to opt out whole interface and wrap just one function


Lets assume that I got class A looking like that:

class A {
public:
 A() = default;
 ~A() = default;

 void foo();
 void bar();
 void baz();
 void qux();
};

I want to create wrapper of that class, but I just need to use function foo. I know that I can use

%ignore A::bar;
%ignore A::baz;
%ignore A::qux;

to avoid wrapping rest of the functions, but it take a look writing and If someone will add new function he'll have to add new ignore.

Is there in SWIG options to opt out whole interface of class and just tell which function I want to wrap ?


Solution

  • Look at this: https://github.com/mmomtchev/magickwand.js/blob/05a84af7f11164ad947528743947d4dc650f77f2/src/MagickCore.i#L6

    In your case:

    %rename("$ignore", regextarget=1, fullname=1) "^A::.+";
    %rename("%s", regextarget=1) "foo$";