add templatereduce option
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6543 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
fc2f54c647
commit
f15126aee3
4 changed files with 58 additions and 0 deletions
|
|
@ -1,6 +1,55 @@
|
|||
Version 1.3.23 (in progress)
|
||||
============================
|
||||
|
||||
|
||||
10/28/2004:mmatus
|
||||
- Added module and swig option "templatereduce" to force swig
|
||||
to reduce any type needed with templates, ie, in these cases
|
||||
|
||||
%module("templatereduce") test
|
||||
|
||||
template <class T> struct A { };
|
||||
|
||||
typedef int Int;
|
||||
%template(A_Int) A<Int> ==> %template(A_Int) A<int>
|
||||
|
||||
typedef B* Bp;
|
||||
%template(A_Bp) A<Bp> ==> %template(A_Bp) A<B*>
|
||||
|
||||
swig reduces the types Int and Bp to their primitives
|
||||
int and B*. This is closer to the usual compiler
|
||||
resolution mechanism, and it is really needed sometimes
|
||||
when you mix templates + typedefs + specializations.
|
||||
|
||||
Don't use it if you don't have any problem already,
|
||||
since the type reduction can interfere with some
|
||||
user typemaps, specially if you defined something like
|
||||
|
||||
typedef int Int;
|
||||
%typemap(in) Int ...;
|
||||
|
||||
in this case, when you use the "templatereduce" option,
|
||||
swig will ignore the user typemap, since the "typedef int Int"
|
||||
will take precedence, and the usual "int" typemap will be
|
||||
applied.
|
||||
|
||||
Note that the previous case is not common, and should be
|
||||
avoided, ie, is not recommended to use a typedef and a
|
||||
typemap at the same time, specially if you are going to
|
||||
use templates + specializations.
|
||||
|
||||
- Directors:
|
||||
|
||||
virtual destructor is always emitted now, this doesn't
|
||||
cause any harm, and could solve some nasty and
|
||||
mysterious errors, like the one mentioned by Scott.
|
||||
|
||||
also the destructor is not in-lined, so, that can solve
|
||||
some other mysterious errors when mixing directors +
|
||||
imports + embedded applications + some specific compilers.
|
||||
|
||||
|
||||
|
||||
10/27/2004: wsfulton
|
||||
[C#] typemaps.i library file with INPUT, OUTPUT and INOUT typemaps added.
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ extern SwigType *Swig_cparse_type(String *);
|
|||
extern Node *Swig_cparse(File *);
|
||||
extern Hash *Swig_cparse_features();
|
||||
extern void SWIG_cparse_set_compact_default_args(int defargs);
|
||||
extern void SWIG_cparse_template_reduce(int treduce);
|
||||
|
||||
/* util.c */
|
||||
extern void Swig_cparse_replace_descriptor(String *s);
|
||||
|
|
|
|||
|
|
@ -171,6 +171,10 @@ void SWIG_cparse_set_compact_default_args(int defargs) {
|
|||
compact_default_args = defargs;
|
||||
}
|
||||
|
||||
void SWIG_cparse_template_reduce(int treduce) {
|
||||
template_reduce = treduce;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Assist functions
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ static const char *usage2 = (const char*)"\
|
|||
-outdir <dir> - Set language specific files output directory\n\
|
||||
-small - Compile in virtual elimination & compact mode\n\
|
||||
-swiglib - Report location of SWIG library and exit\n\
|
||||
-templatereduce - Swig reduce all the typedefs in templates \n\
|
||||
-v - Run in verbose mode\n\
|
||||
-version - Print SWIG version number\n\
|
||||
-Wall - Enable all warning messages\n\
|
||||
|
|
@ -332,6 +333,9 @@ void SWIG_getoptions(int argc, char *argv[])
|
|||
} else if (strcmp(argv[i],"-show_templates") == 0) {
|
||||
Swig_cparse_debug_templates(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-templatereduce") == 0) {
|
||||
SWIG_cparse_template_reduce(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-swiglib") == 0) {
|
||||
printf("%s\n", LibDir);
|
||||
SWIG_exit (EXIT_SUCCESS);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue