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
|
|
@ -1,6 +1,47 @@
|
|||
Version 1.3.26 (in progress)
|
||||
============================
|
||||
|
||||
09/11/2005: mmatus
|
||||
Adding the module option to the %import directive. Now you
|
||||
can use it as
|
||||
|
||||
%import(module="BigModule") foo.i
|
||||
|
||||
where subfile could (or not) define the module name via
|
||||
the %module directive. The module option take precedence
|
||||
and it has the same effects than having the directive
|
||||
|
||||
%module BigModule
|
||||
|
||||
inside the imported file foo.i.
|
||||
|
||||
You can use the option in mainly two cases:
|
||||
|
||||
1.- You used the -module option when you generated the
|
||||
module to be imported, and hence the module name in
|
||||
the imported %module directive is not really useful.
|
||||
|
||||
2.- The module you want to import is very large, and it
|
||||
has several .i/.h files. Then, if you just one to
|
||||
import a class or so from the module, says 'foo', and
|
||||
not the entire module via importing the main
|
||||
BigModule.i file, then you just do:
|
||||
|
||||
%import(module="BigModule") foo.h
|
||||
|
||||
or
|
||||
|
||||
%import(module="BigModule") foo.i
|
||||
|
||||
where foo.i contains the 'foo' declaration and maybe a
|
||||
couple of extra %include directives, as needed.
|
||||
|
||||
|
||||
09/11/2005: mmatus
|
||||
Fix bug #1282637, about the -module option not having effect
|
||||
in places where it was needed.
|
||||
|
||||
|
||||
09/11/2005: wsfulton
|
||||
When wrapping variables, ensure that none of the typemaps used for the
|
||||
set wrappers are used when generating the get wrappers. I doubt this was a
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@
|
|||
#include "imports_b.h"
|
||||
%}
|
||||
|
||||
%import "imports_a.i"
|
||||
%import(module="imports_a") "imports_a.i"
|
||||
|
||||
%include "imports_b.h"
|
||||
|
|
|
|||
|
|
@ -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