add module option to import
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7429 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
1c6a2a2cfb
commit
635677c450
3 changed files with 64 additions and 14 deletions
|
|
@ -1750,24 +1750,33 @@ include_directive: includetype options string LBRACKET {
|
|||
cparse_file = Swig_copy_string($3);
|
||||
cparse_line = 0;
|
||||
} interface RBRACKET {
|
||||
String *modulename = 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) set_nodeType($$,"import");
|
||||
Setattr($$,"name",$3);
|
||||
/* Search for the module (if any) */
|
||||
{
|
||||
Node *n = firstChild($$);
|
||||
while (n) {
|
||||
if (Strcmp(nodeType(n),"module") == 0) {
|
||||
Setattr($$,"module",Getattr(n,"name"));
|
||||
break;
|
||||
}
|
||||
n = nextSibling(n);
|
||||
}
|
||||
if (strcmp($1.type,"include") == 0) {
|
||||
set_nodeType($$,"include");
|
||||
} else if (strcmp($1.type,"import") == 0) {
|
||||
set_nodeType($$,"import");
|
||||
/* try to get the modulename from the options */
|
||||
modulename = $2 ? Getattr($2,"module") : 0;
|
||||
}
|
||||
|
||||
Setattr($$,"name",$3);
|
||||
Setattr($$,"options",$2);
|
||||
if (!modulename) {
|
||||
/* Search for the first module node (if any) */
|
||||
Node *n = firstChild($$);
|
||||
while (n) {
|
||||
if (Strcmp(nodeType(n),"module") == 0) {
|
||||
modulename = Getattr(n,"name");
|
||||
break;
|
||||
}
|
||||
n = nextSibling(n);
|
||||
}
|
||||
}
|
||||
Setattr($$,"module",Copy(modulename));
|
||||
|
||||
}
|
||||
;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue