recover the %import(module=name) option,lost in previous fix
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7558 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
d1663ed6ed
commit
30cf3657c6
2 changed files with 46 additions and 1 deletions
|
|
@ -12,6 +12,31 @@
|
|||
#include "imports_b.h"
|
||||
%}
|
||||
|
||||
%import(module="imports_a") "imports_a.i"
|
||||
|
||||
/*
|
||||
To import, you can use either
|
||||
|
||||
%import "imports_a.i"
|
||||
|
||||
or
|
||||
|
||||
%import(module="imports_a") "imports_a.h"
|
||||
|
||||
|
||||
In the first case, imports_a.i should declare the module name using
|
||||
the %module directive.
|
||||
|
||||
In the second case, the file could be either a .h file, where no
|
||||
%module directive will be found, or a swig interface file, where
|
||||
the module option will take priority over any %module directive
|
||||
inside the imported file.
|
||||
|
||||
*/
|
||||
|
||||
#if 0
|
||||
%import "imports_a.i"
|
||||
#else
|
||||
%import(module="imports_a") "imports_a.h"
|
||||
#endif
|
||||
|
||||
%include "imports_b.h"
|
||||
|
|
|
|||
|
|
@ -1748,11 +1748,13 @@ include_directive: includetype options string LBRACKET {
|
|||
cparse_file = Swig_copy_string($3);
|
||||
cparse_line = 0;
|
||||
} interface RBRACKET {
|
||||
String *mname = 0;
|
||||
$$ = $6;
|
||||
cparse_file = $1.filename;
|
||||
cparse_line = $1.line;
|
||||
if (strcmp($1.type,"include") == 0) set_nodeType($$,"include");
|
||||
if (strcmp($1.type,"import") == 0) {
|
||||
mname = $2 ? Getattr($2,"module") : 0;
|
||||
set_nodeType($$,"import");
|
||||
if (import_mode) --import_mode;
|
||||
}
|
||||
|
|
@ -1763,11 +1765,29 @@ include_directive: includetype options string LBRACKET {
|
|||
Node *n = firstChild($$);
|
||||
while (n) {
|
||||
if (Strcmp(nodeType(n),"module") == 0) {
|
||||
if (mname) {
|
||||
Setattr(n,"name", mname);
|
||||
mname = 0;
|
||||
}
|
||||
Setattr($$,"module",Getattr(n,"name"));
|
||||
break;
|
||||
}
|
||||
n = nextSibling(n);
|
||||
}
|
||||
if (mname) {
|
||||
/* There is no module node in the import
|
||||
node, ie, you imported a .h file
|
||||
directly. We are forced then to create
|
||||
a new import node with a module node.
|
||||
*/
|
||||
Node *nint = new_node("import");
|
||||
Node *mnode = new_node("module");
|
||||
Setattr(mnode,"name", mname);
|
||||
appendChild(nint,mnode);
|
||||
appendChild(nint,firstChild($$));
|
||||
$$ = nint;
|
||||
Setattr($$,"module",mname);
|
||||
}
|
||||
}
|
||||
Setattr($$,"options",$2);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue