[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r9609: Fix isnan conflict by renamin
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r9609: Fix isnan conflict by renaming rather than undefining it. Drop other |
Date: |
Sat, 16 Aug 2008 14:48:19 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9609
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Sat 2008-08-16 14:48:19 +0200
message:
Fix isnan conflict by renaming rather than undefining it. Drop other
reliance on macros that may or may not exist and use our own methods
everywhere.
modified:
libcore/array.cpp
libcore/as_value.cpp
libcore/as_value.h
libcore/asobj/Date.cpp
libcore/asobj/Global.cpp
libcore/asobj/Number.cpp
libcore/asobj/flash/geom/Point_as.cpp
libcore/character.cpp
libcore/sprite_instance.cpp
libcore/vm/ASHandlers.cpp
libcore/vm/Machine.cpp
------------------------------------------------------------
revno: 9595.2.4
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2008-08-15 22:34:44 +0200
message:
Use numeric_limits<>::infinity directly and even when INFINITY is defined,
as it's standard. INFINITY isn't.
modified:
libcore/asobj/Number.cpp
------------------------------------------------------------
revno: 9595.2.5
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Sat 2008-08-16 13:33:05 +0200
message:
Rename isnan to isNaN so some compilers don't mix it up with built in
extensions (yes, OpenBSD, this means you). Make NaN a const rather than
a macro because compilers are cleverer than preprocessors.
modified:
libcore/array.cpp
libcore/as_value.cpp
libcore/as_value.h
libcore/asobj/Date.cpp
libcore/asobj/Global.cpp
libcore/asobj/flash/geom/Point_as.cpp
libcore/character.cpp
libcore/sprite_instance.cpp
libcore/vm/ASHandlers.cpp
libcore/vm/Machine.cpp
=== modified file 'libcore/array.cpp'
--- a/libcore/array.cpp 2008-07-28 15:26:17 +0000
+++ b/libcore/array.cpp 2008-08-16 11:33:05 +0000
@@ -94,8 +94,8 @@
if (b.is_null()) return true;
double aval = a.to_number();
double bval = b.to_number();
- if (isnan(aval)) return false;
- if (isnan(bval)) return true;
+ if (isNaN(aval)) return false;
+ if (isNaN(bval)) return true;
return aval < bval;
}
@@ -107,8 +107,8 @@
if (a.is_null()) return true;
double aval = a.to_number();
double bval = b.to_number();
- if (isnan(bval)) return false;
- if (isnan(aval)) return true;
+ if (isNaN(bval)) return false;
+ if (isNaN(aval)) return true;
return aval > bval;
}
@@ -118,7 +118,7 @@
if (a.is_null() && b.is_null()) return true;
double aval = a.to_number();
double bval = b.to_number();
- if (isnan(aval) && isnan(bval)) return true;
+ if (isNaN(aval) && isNaN(bval)) return true;
return aval == bval;
}
=== modified file 'libcore/as_value.cpp'
--- a/libcore/as_value.cpp 2008-07-21 09:56:09 +0000
+++ b/libcore/as_value.cpp 2008-08-16 11:33:05 +0000
@@ -303,7 +303,7 @@
#if 1
if ( m_type == MOVIECLIP )
{
- return as_value(NAN);
+ return as_value(NaN);
}
#endif
if ( m_type == OBJECT ) obj = getObj().get();
@@ -413,7 +413,7 @@
{
if ( m_type == MOVIECLIP )
{
- set_double(NAN);
+ set_double(NaN);
return *this;
}
if ( m_type == OBJECT ) obj = getObj().get();
@@ -553,7 +553,7 @@
// just like for any other non-numerical text. This is correct
// behaviour.
{
- return static_cast<double>(NAN);
+ return static_cast<double>(NaN);
}
}
@@ -562,7 +562,7 @@
{
// Evan: from my tests
// Martin: FlashPlayer6 gives 0; FP9 gives NaN.
- return ( swfversion >= 7 ? NAN : 0 );
+ return ( swfversion >= 7 ? NaN : 0 );
}
case BOOLEAN:
@@ -600,7 +600,7 @@
}
else
{
- return NAN;
+ return NaN;
}
}
}
@@ -609,13 +609,13 @@
{
// This is tested, no valueOf is going
// to be invoked for movieclips.
- return NAN;
+ return NaN;
}
default:
// Other object types should return NaN, but if we implement that,
// every GUI's movie canvas shrinks to size 0x0. No idea why.
- return NAN; // 0.0;
+ return NaN; // 0.0;
}
/* NOTREACHED */
}
@@ -655,7 +655,7 @@
case NUMBER:
{
double d = getNum();
- return d && ! isnan(d);
+ return d && ! isNaN(d);
}
case BOOLEAN:
return getBool();
@@ -681,13 +681,13 @@
case STRING:
{
double num = to_number();
- bool ret = num && ! isnan(num);
+ bool ret = num && ! isNaN(num);
return ret;
}
case NUMBER:
{
double d = getNum();
- return ! isnan(d) && d;
+ return ! isNaN(d) && d;
}
case BOOLEAN:
return getBool();
@@ -713,7 +713,7 @@
case STRING:
{
double num = to_number();
- bool ret = num && ! isnan(num);
+ bool ret = num && ! isNaN(num);
return ret;
}
case NUMBER:
@@ -1204,9 +1204,9 @@
double b = v.getNum();
// Nan != NaN
- //if ( isnan(a) || isnan(b) ) return false;
+ //if ( isNaN(a) || isNaN(b) ) return false;
- if ( isnan(a) && isnan(b) ) return true;
+ if ( isNaN(a) && isNaN(b) ) return true;
// -0.0 == 0.0
if ( (a == -0 && b == 0) || (a == 0 && b == -0) )
return true;
@@ -1401,7 +1401,7 @@
// Handle non-numeric values.
// "printf" gives "nan", "inf", "-inf", so we check explicitly
- if(isnan(val))
+ if(isNaN(val))
{
return "NaN";
}
@@ -1733,7 +1733,7 @@
const double op1 = operand1.to_number();
const double op2 = operand2.to_number();
- if ( isnan(op1) || isnan(op2) )
+ if ( isNaN(op1) || isNaN(op2) )
{
ret.set_undefined();
}
=== modified file 'libcore/as_value.h'
--- a/libcore/as_value.h 2008-08-15 17:04:43 +0000
+++ b/libcore/as_value.h 2008-08-16 12:48:19 +0000
@@ -49,29 +49,20 @@
class asNamespace;
class asName;
-#ifndef NAN
-# define NAN (std::numeric_limits<double>::quiet_NaN())
-#endif
-
-#ifndef INFINITY
-# define INFINITY (std::numeric_limits<double>::infinity())
-#endif
-
-// NetBSD has issues with isnan, and tries to force us to use
-// the macro even when we want to use our own type safe version.
-#undef isnan
+// NaN constant for use in as_value implementation
+static const double NaN = std::numeric_limits<double>::quiet_NaN();
// The following template works just like its C counterpart, with added
// type safety (i.e., they will only compile for floating point arguments).
template <typename T>
inline bool
-isnan(const T& num, typename boost::enable_if<boost::is_floating_point<T>
>::type* dummy = 0)
+isNaN(const T& num, typename boost::enable_if<boost::is_floating_point<T>
>::type* dummy = 0)
{
UNUSED(dummy);
return num != num;
}
-#define isinf(x) (isnan(x - x))
+#define isinf(x) (isNaN(x - x))
/// Use this methods to obtain a properly-formatted property name
/// The methods will convert the name to lowercase if the current VM target
@@ -482,7 +473,7 @@
void set_int(int val) { set_double(val); }
- void set_nan() { set_double(NAN); }
+ void set_nan() { set_double(NaN); }
/// Make this value a NULL, OBJECT, MOVIECLIP or AS_FUNCTION value
//
=== modified file 'libcore/asobj/Date.cpp'
--- a/libcore/asobj/Date.cpp 2008-04-20 16:53:57 +0000
+++ b/libcore/asobj/Date.cpp 2008-08-16 11:33:05 +0000
@@ -349,8 +349,8 @@
const char* dayweekname[7] = { "Sun", "Mon", "Tue", "Wed",
"Thu", "Fri", "Sat" };
- /// NAN and infinities all print as "Invalid Date"
- if (isnan(_value) || isinf(_value)) {
+ /// NaN and infinities all print as "Invalid Date"
+ if (isNaN(_value) || isinf(_value)) {
return as_value("Invalid Date");
}
@@ -487,7 +487,7 @@
#define date_get_proto(function, timefn, element) \
static as_value function(const fn_call& fn) { \
boost::intrusive_ptr<Date> date = ensureType<Date>(fn.this_ptr); \
- if (isnan(date->getTimeValue()) || isinf(date->getTimeValue())) { as_value
rv; rv.set_nan(); return rv; } \
+ if (isNaN(date->getTimeValue()) || isinf(date->getTimeValue())) { as_value
rv; rv.set_nan(); return rv; } \
GnashTime gt; \
timefn(date->getTimeValue(), gt); \
return as_value(gt.element); \
@@ -692,9 +692,9 @@
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Date.setFullYear needs one argument"));
)
- date->setTimeValue(NAN);
+ date->setTimeValue(NaN);
} else if (rogue_date_args(fn, 3) != 0.0) {
- date->setTimeValue(NAN);
+ date->setTimeValue(NaN);
} else {
GnashTime gt;
@@ -738,10 +738,10 @@
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Date.setYear needs one argument"));
)
- date->setTimeValue(NAN);
+ date->setTimeValue(NaN);
}
else if (rogue_date_args(fn, 3) != 0.0) {
- date->setTimeValue(NAN);
+ date->setTimeValue(NaN);
}
else {
GnashTime gt;
@@ -772,7 +772,7 @@
// If no arguments are given or if an invalid type is given,
// the commercial player sets the month to January in the same year.
// Only if the second parameter is present and has a non-numeric value,
-// the result is NAN.
+// the result is NaN.
// We do not do the same because it's a bugger to code.
static as_value
_date_setmonth(const fn_call& fn, bool utc)
@@ -784,10 +784,10 @@
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Date.setMonth needs one argument"));
)
- date->setTimeValue(NAN);
+ date->setTimeValue(NaN);
}
else if (rogue_date_args(fn, 2) != 0.0) {
- date->setTimeValue(NAN);
+ date->setTimeValue(NaN);
}
else {
@@ -798,14 +798,14 @@
// It seems odd, but FlashPlayer takes all bad month values to mean
// January
double monthvalue = fn.arg(0).to_number();
- if (isnan(monthvalue) || isinf(monthvalue)) monthvalue = 0.0;
+ if (isNaN(monthvalue) || isinf(monthvalue)) monthvalue = 0.0;
gt.month = static_cast<int>(monthvalue);
- // If the day-of-month value is invalid instead, the result is NAN.
+ // If the day-of-month value is invalid instead, the result is NaN.
if (fn.nargs >= 2) {
double mdayvalue = fn.arg(1).to_number();
- if (isnan(mdayvalue) || isinf(mdayvalue)) {
- date->setTimeValue(NAN);
+ if (isNaN(mdayvalue) || isinf(mdayvalue)) {
+ date->setTimeValue(NaN);
return as_value(date->getTimeValue());
}
else {
@@ -835,9 +835,9 @@
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Date.setDate needs one argument"));
)
- date->setTimeValue(NAN); // Is what FlashPlayer sets
+ date->setTimeValue(NaN); // Is what FlashPlayer sets
} else if (rogue_date_args(fn, 1) != 0.0) {
- date->setTimeValue(NAN);
+ date->setTimeValue(NaN);
} else {
GnashTime gt;
@@ -874,10 +874,10 @@
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Date.setHours needs one argument"));
)
- date->setTimeValue(NAN); // Is what FlashPlayer sets
+ date->setTimeValue(NaN); // Is what FlashPlayer sets
}
else if (rogue_date_args(fn, 4) != 0.0) {
- date->setTimeValue(NAN);
+ date->setTimeValue(NaN);
}
else {
@@ -917,11 +917,11 @@
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Date.setMinutes needs one argument"));
)
- date->setTimeValue(NAN); // FlashPlayer instead leaves the date set to
+ date->setTimeValue(NaN); // FlashPlayer instead leaves the date set to
// a random value such as 9th December 2077 BC
}
else if (rogue_date_args(fn, 3) != 0.0) {
- date->setTimeValue(NAN);
+ date->setTimeValue(NaN);
}
else {
GnashTime gt;
@@ -955,10 +955,10 @@
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Date.setSeconds needs one argument"));
)
- date->setTimeValue(NAN); // Same as commercial player
+ date->setTimeValue(NaN); // Same as commercial player
}
else if (rogue_date_args(fn, 2) != 0.0) {
- date->setTimeValue(NAN);
+ date->setTimeValue(NaN);
}
else {
// We *could* set seconds [and milliseconds] without breaking the
@@ -993,10 +993,10 @@
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Date.setMilliseconds needs one argument"));
)
- date->setTimeValue(NAN);
+ date->setTimeValue(NaN);
}
else if (rogue_date_args(fn, 1) != 0.0) {
- date->setTimeValue(NAN);
+ date->setTimeValue(NaN);
}
else {
@@ -1086,11 +1086,11 @@
// - if both +Infinity and -Infinity are present in the optional args,
// or if one of the first two arguments is not numeric (including Inf),
// the result is NaN.
-// Actually, given a first parameter of Infinity,-Infinity or NAN,
+// Actually, given a first parameter of Infinity,-Infinity or NaN,
// it returns -6.77681005679712e+19 but that's just crazy.
//
// We test for < 2 parameters and return undefined, but given any other
-// non-numeric arguments we give NAN.
+// non-numeric arguments we give NaN.
static as_value
@@ -1110,7 +1110,7 @@
// Check for presence of NaNs and Infinities in the arguments
// and return the appropriate value if so.
if ( (result = rogue_date_args(fn, 7)) != 0.0) {
- return as_value(NAN);
+ return as_value(NaN);
}
// Preset default values
@@ -1153,7 +1153,7 @@
// Auxillary function checks for Infinities and NaN in a function's args and
// returns 0.0 if there are none,
// plus (or minus) infinity if positive (or negative) infinites are present,
-// NAN is there are NANs present, or a mixture of positive and negative infs.
+// NaN is there are NaNs present, or a mixture of positive and negative infs.
static double
rogue_date_args(const fn_call& fn, unsigned maxargs)
{
@@ -1171,7 +1171,7 @@
for (unsigned int i = 0; i < maxargs; i++) {
double arg = fn.arg(i).to_number();
- if (isnan(arg)) return(NAN);
+ if (isNaN(arg)) return(NaN);
if (isinf(arg)) {
if (arg > 0) { // Plus infinity
@@ -1186,7 +1186,7 @@
}
// If both kinds of infinity were present in the args,
// the result is NaN.
- if (plusinf && minusinf) return(NAN);
+ if (plusinf && minusinf) return(NaN);
// If only one kind of infinity was in the args, return that.
if (plusinf || minusinf) return(infinity);
=== modified file 'libcore/asobj/Global.cpp'
--- a/libcore/asobj/Global.cpp 2008-07-21 09:56:09 +0000
+++ b/libcore/asobj/Global.cpp 2008-08-16 11:33:05 +0000
@@ -96,7 +96,7 @@
// Forward declarations
static as_value as_global_trace(const fn_call& fn);
-static as_value as_global_isnan(const fn_call& fn);
+static as_value as_global_isNaN(const fn_call& fn);
static as_value as_global_isfinite(const fn_call& fn);
static as_value as_global_unescape(const fn_call& fn);
static as_value as_global_escape(const fn_call& fn);
@@ -215,7 +215,7 @@
vm.registerNative(as_global_unescape, 100, 1);
vm.registerNative(as_global_parseint, 100, 2);
vm.registerNative(as_global_parsefloat, 100, 3);
- vm.registerNative(as_global_isnan, 200, 18);
+ vm.registerNative(as_global_isNaN, 200, 18);
vm.registerNative(as_global_isfinite, 200, 19);
init_member("escape", vm.getNative(100, 0));
@@ -275,11 +275,11 @@
as_value
-as_global_isnan(const fn_call& fn)
+as_global_isNaN(const fn_call& fn)
{
ASSERT_FN_ARGS_IS_1
- return as_value( static_cast<bool>(isnan(fn.arg(0).to_number()) ));
+ return as_value( static_cast<bool>(isNaN(fn.arg(0).to_number()) ));
}
=== modified file 'libcore/asobj/Number.cpp'
--- a/libcore/asobj/Number.cpp 2008-05-25 09:05:18 +0000
+++ b/libcore/asobj/Number.cpp 2008-08-15 20:34:44 +0000
@@ -31,23 +31,6 @@
#include <sstream>
#include <cmath>
-// Why ?
-//#undef fpclassify
-//#define fpclassify(x) _fpclassify(x)
-
-/* C99: 7.12 6 defines for floating point classification */
-
-#undef FP_ZERO
-#define FP_ZERO 1
-#undef FP_SUBNORMAL
-#define FP_SUBNORMAL 2
-#undef FP_NORMAL
-#define FP_NORMAL 4
-#undef FP_INFINITE
-#define FP_INFINITE 8
-#undef FP_NAN
-#define FP_NAN 16
-
namespace gnash {
// Forward declarations
@@ -168,8 +151,8 @@
cl->init_member("MAX_VALUE",
std::numeric_limits<double>::max(), cflags);
cl->init_member("MIN_VALUE",
std::numeric_limits<double>::denorm_min(), cflags);
cl->init_member("NaN", as_value(NAN), cflags);
- cl->init_member("POSITIVE_INFINITY", as_value(INFINITY),
cflags);
- cl->init_member("NEGATIVE_INFINITY", as_value(-INFINITY),
cflags);
+ cl->init_member("POSITIVE_INFINITY",
as_value(std::numeric_limits<double>::infinity()), cflags);
+ cl->init_member("NEGATIVE_INFINITY",
as_value(-std::numeric_limits<double>::infinity()), cflags);
}
=== modified file 'libcore/asobj/flash/geom/Point_as.cpp'
--- a/libcore/asobj/flash/geom/Point_as.cpp 2008-06-19 10:49:15 +0000
+++ b/libcore/asobj/flash/geom/Point_as.cpp 2008-08-16 11:33:05 +0000
@@ -462,22 +462,22 @@
as_value x1val;
o1->get_member(NSV::PROP_X, &x1val);
double x1 = x1val.to_number();
- //if ( ! utility::isFinite(x1) ) return as_value(NAN);
+ //if ( ! utility::isFinite(x1) ) return as_value(NaN);
as_value y1val;
o1->get_member(NSV::PROP_Y, &y1val);
double y1 = y1val.to_number();
- //if ( ! utility::isFinite(y1) ) return as_value(NAN);
+ //if ( ! utility::isFinite(y1) ) return as_value(NaN);
as_value x2val;
o2->get_member(NSV::PROP_X, &x2val);
double x2 = x2val.to_number();
- //if ( ! utility::isFinite(x2) ) return as_value(NAN);
+ //if ( ! utility::isFinite(x2) ) return as_value(NaN);
as_value y2val;
o2->get_member(NSV::PROP_Y, &y2val);
double y2 = y2val.to_number();
- //if ( ! utility::isFinite(y2) ) return as_value(NAN);
+ //if ( ! utility::isFinite(y2) ) return as_value(NaN);
double hside = x2 - x1; // p1.x - p0.x;
double vside = y2 - y1; // p1.y - p0.y;
=== modified file 'libcore/character.cpp'
--- a/libcore/character.cpp 2008-08-15 11:48:04 +0000
+++ b/libcore/character.cpp 2008-08-16 12:48:19 +0000
@@ -302,7 +302,7 @@
const double scale_percent = fn.arg(0).to_number();
// Handle bogus values
- if (isnan(scale_percent))
+ if (isNaN(scale_percent))
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Attempt to set _xscale to %g, refused"),
@@ -333,7 +333,7 @@
const double scale_percent = fn.arg(0).to_number();
// Handle bogus values
- if (isnan(scale_percent))
+ if (isNaN(scale_percent))
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Attempt to set _yscale to %g, refused"),
@@ -542,7 +542,7 @@
double rotation_val = fn.arg(0).to_number();
// Handle bogus values
- if (isnan(rotation_val))
+ if (isNaN(rotation_val))
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Attempt to set _rotation to %g,
refused"),
=== modified file 'libcore/sprite_instance.cpp'
--- a/libcore/sprite_instance.cpp 2008-08-14 21:51:05 +0000
+++ b/libcore/sprite_instance.cpp 2008-08-16 11:33:05 +0000
@@ -469,7 +469,7 @@
else
{
double td = fn.arg(0).to_number();
- if ( isnan(td) )
+ if ( isNaN(td) )
{
IF_VERBOSE_ASCODING_ERRORS(
std::stringstream ss; fn.dump_args(ss);
=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2008-07-23 12:07:52 +0000
+++ b/libcore/vm/ASHandlers.cpp 2008-08-16 11:33:05 +0000
@@ -3235,7 +3235,7 @@
const double op1 = operand1.to_number();
const double op2 = operand2.to_number();
- if ( isnan(op1) || isnan(op2) )
+ if ( isNaN(op1) || isNaN(op2) )
{
env.top(1).set_undefined();
}
@@ -3872,7 +3872,7 @@
const double op1 = operand1.to_number();
const double op2 = operand2.to_number();
- if ( isnan(op1) || isnan(op2) )
+ if ( isNaN(op1) || isNaN(op2) )
{
env.top(1).set_undefined();
}
=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp 2008-05-29 08:21:59 +0000
+++ b/libcore/vm/Machine.cpp 2008-08-16 11:33:05 +0000
@@ -174,7 +174,7 @@
ENSURE_NUMBER(a);
\
ENSURE_NUMBER(b);
\
double ad = a.to_number(); double bd = b.to_number();
\
- if (isnan(ad) || isnan(bd))
\
+ if (isNaN(ad) || isNaN(bd))
\
store = truth_of_undefined;
\
else if (isinf(ad) && ad > 0)
\
store = false;
\
@@ -209,7 +209,7 @@
else if (a.is_number())
\
{
\
double ad = a.to_number(); double bd = b.to_number();
\
- if (isnan(ad) || isnan(bd))
\
+ if (isNaN(ad) || isNaN(bd))
\
*store = false;
\
else if (isinf(ad) && ad > 0)
\
*store = (isinf(bd) && bd > 0);
\
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r9609: Fix isnan conflict by renaming rather than undefining it. Drop other,
Benjamin Wolsey <=