The -relativeimport option works when a using the import directive as documented:
%import (package="pkg1.pkg2") "mod3.i"
However, if a user use the single file import:
%import (module="pkg1.pkg2.mod3") "Foo.h";
relative import directive has no effect. See simple attached example to reproduce the error.
I traced the bug down to the function importDirective in python.cxx.
Here module name of the incoming node is "mod3" for the correct example and "pkg1.pkg2.mod3" for the not working example. For the correct example the option "package" is also provided.
Not sure how it should be fixed. Either just keep the present syntax and try to manually split "pkg1.pkg2.mod3" in the importDirective function into package = "pkg1.pkg2" and module = "mod3", or extend the present import directive syntax with:
%import (package="pkg1.pkg2", module="mod3") "Foo.h";
I would prefer the latter as it is more explicit. Atm the package information is just discarded as the parser create a new module node, which does not get the option propagated to it. I attach a online patch that propagate the option child to the newly create module node in the parse tree. I can barely read yacc and barely write swig parser code, so please check that what I am doing this correct.
Log in to post a comment.