Use SWIG_GE, SWIG_LE, etc instead of >=, <= since the latter cause

problems when used as template parameters.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9366 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2006-09-26 07:52:24 +00:00
commit cf52954bbb
3 changed files with 17 additions and 5 deletions

View file

@ -43,7 +43,8 @@ class X {};
template<int foo> class X994301 {};
%}
%template(X994301_ternary) X<(7 != 4) ? 1 + 1 : 1>;
%template(X994301_ternary) X<(7 >= 4) ? 1 + 1 : 1>;
%template(X994301_ternary2) X<(7 <= 4) ? 1 + 1 : 1>;
// bug #1338527 (still broken)

View file

@ -94,3 +94,11 @@
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE
#endif
/* Putting > and < into constant expressions causes problems with code which
* tries to parse template types, so we use SWIG_GT, etc instead until such
* code gets enhanced. */
#define SWIG_GT >
#define SWIG_LT <
#define SWIG_GE >=
#define SWIG_LE <=

View file

@ -5469,20 +5469,23 @@ exprcompound : expr PLUS expr {
}
/* Sadly this causes 2 reduce-reduce conflicts with templates. FIXME resolve these.
| expr GREATERTHAN expr {
$$.val = NewStringf("%s>%s",$1.val,$3.val);
$$.val = NewStringf("%s SWIG_LT %s", $1.val, $3.val);
$$.type = T_INT;
}
| expr LESSTHAN expr {
$$.val = NewStringf("%s<%s",$1.val,$3.val);
$$.val = NewStringf("%s SWIG_GT %s", $1.val, $3.val);
$$.type = T_INT;
}
*/
| expr GREATERTHANOREQUALTO expr {
$$.val = NewStringf("%s>=%s",$1.val,$3.val);
/* Putting >= in the expression literally causes an infinite
* loop somewhere in the type system. Just workaround for now
* - SWIG_GE is defined in swiglabels.swg. */
$$.val = NewStringf("%s SWIG_GE %s", $1.val, $3.val);
$$.type = T_INT;
}
| expr LESSTHANOREQUALTO expr {
$$.val = NewStringf("%s<=%s",$1.val,$3.val);
$$.val = NewStringf("%s SWIG_LE %s", $1.val, $3.val);
$$.type = T_INT;
}
| expr QUESTIONMARK expr COLON expr %prec QUESTIONMARK {