Fix #2746858 - C macro expression using floating point numbers

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11185 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-04-09 17:51:59 +00:00
commit bd46f03b6f
3 changed files with 20 additions and 1 deletions

View file

@ -1,6 +1,9 @@
Version 1.3.40 (in progress)
============================
2009-04-09: wsfulton
Fix #2746858 - C macro expression using floating point numbers
2009-03-30: olly
[PHP] The default out typemap for char[ANY] now returns the string up to a
zero byte, or the end of the array if there is no zero byte. This

View file

@ -313,6 +313,11 @@ int test(int defined)
#define MASK(shift, size) (((1 << (size)) - 1) <<(shift))
#define SOME_MASK_DEF (80*MASK(8, 10))
/* some constants */
#define BOLTZMANN (1.380658e-23)
#define AVOGADRO (6.0221367e23)
#define RGAS (BOLTZMANN*AVOGADRO)
#define RGASX (BOLTZMANN*AVOGADRO*BOLTZMANN)
%{
#define TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(TYPE) \

View file

@ -5492,7 +5492,18 @@ valexpr : exprnum { $$ = $1; }
| LPAREN expr RPAREN expr %prec CAST {
$$ = $4;
if ($4.type != T_STRING) {
$$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $4.val);
switch ($2.type) {
case T_FLOAT:
case T_DOUBLE:
case T_LONGDOUBLE:
case T_FLTCPLX:
case T_DBLCPLX:
$$.val = NewStringf("(%s)%s", $2.val, $4.val); /* SwigType_str and decimal points don't mix! */
break;
default:
$$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $4.val);
break;
}
}
}
| LPAREN expr pointer RPAREN expr %prec CAST {