The documentation says "The %feature directive can be applied globally, to specific classes, and to specific methods." But it doesn't work as advertised, e.g.
%module(directors="1") DirectorBug
// generate a director for just Foo::bar()
%feature("director") Foo::bar;
struct Foo {
virtual void bar();
virtual void baz();
};
With C# as the target, SWIG doesn't appear to generate any director-related code. With Java as the target, SWIG does not generate a director class although it does generate separate "Foo_bar" and "Foo_barSwigExplicitFoo" functions. No warnings/errors are issued. Possibly related to bug 3529601.
My SWIG Version: 2.0.6
Compiled with i586-mingw32msvc-g++ [i586-pc-mingw32msvc]
Configured options: +pcre
I've got a class where with 23 virtual functions and I only want directors for 3 of them. At first I made a %nodirector statement for each of the 20 unwanted functions, but then I thought of an easier workaround. In my header file I do:
#ifdef SWIG
#define INTERNAL protected
#define VIRTUAL_IN_CPP
#else
#define INTERNAL public
#define VIRTUAL_IN_CPP virtual
#endif
Then instead of "virtual", I use "VIRTUAL_IN_CPP" on the functions for which I don't want directors (and INTERNAL for public members that I don't want wrapped at all). Of course, such a workaround only applies if you can modify the original header files.
The original example still doesn't do what you might hope with current git master.
Looks like https://sourceforge.net/p/swig/bugs/879/ is closely related and probably the same issue.