[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ./ChangeLog server/action.cpp server/acti...
From: |
Michael Carlson |
Subject: |
[Gnash-commit] gnash ./ChangeLog server/action.cpp server/acti... |
Date: |
Mon, 23 Jan 2006 17:01:13 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Branch:
Changes by: Michael Carlson <address@hidden> 06/01/23 17:01:13
Modified files:
. : ChangeLog
server : action.cpp action.h array.cpp string.cpp
Log message:
Implement some basic NaN, +Infinity, -Infinity support into as_value
and related functions. NaN / Infinity pretty much happens automatically (and
correctly) with math on C doubles, we just need to use flash's standard strings
for these values, return nan's when returning a double (and no result is
found), and check for nan's in certain cases by using math.h's isnan().
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/ChangeLog.diff?tr1=1.33&tr2=1.34&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/action.cpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/action.h.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/array.cpp.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/string.cpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: gnash/ChangeLog
diff -u gnash/ChangeLog:1.33 gnash/ChangeLog:1.34
--- gnash/ChangeLog:1.33 Mon Jan 23 16:47:00 2006
+++ gnash/ChangeLog Mon Jan 23 17:01:13 2006
@@ -1,7 +1,26 @@
+2006-01-23 Michael Carlson <address@hidden>
+
+ * server/action.h: Create utility funcs as_value::is_inf, is_nan
+ * server/action.cpp: Let as_value String<->Number conversions
+ use NaN, +Infinity, -Infinity where appropriate
+ * server/string.cpp: Make charCodeAt() return a NaN value when
+ appropriate
+ * server/array.cpp: Array now checks for NaN after converting
+ index string to_number(), instead of the old hacked-up way
+
2006-01-23 Rob Savoye <address@hidden>
* configure.ac: Remove AM_MKINSTALLDIRS macro, it's now unneeded.
+2006-01-23 Michael Carlson <address@hidden>
+
+ * server/array.h: Move new array code into array.cpp, array.h
+ * server/array.cpp: Move new array code into array.cpp, array.h
+ * server/action.cpp: Move new array code into array.cpp, array.h
+ * server/Makefile.am: Move new array code into array.cpp, array.h
+ * server/font.cpp: Report an error and continue when we get two
+ of the same kerning pairs for a font, instead of crashing
+
2006-01-22 Rob Savoye <address@hidden>
* configure.ac: Make text at end of configure more detailed about
@@ -12,15 +31,6 @@
* backend/Makefile.am: Make MP3 support truly optional.
* plugin/Makefile.am: Make MP3 support truly optional.
-2006-01-23 Michael Carlson <address@hidden>
-
- * server/array.h: Move new array code into array.cpp, array.h
- * server/array.cpp: Move new array code into array.cpp, array.h
- * server/action.cpp: Move new array code into array.cpp, array.h
- * server/Makefile.am: Move new array code into array.cpp, array.h
- * server/font.cpp: Report an error and continue when we get two
- of the same kerning pairs for a font, instead of crashing
-
2006-01-21 Rob Savoye <address@hidden>
* configure.ac: Add tests for OGG and Vorbis.
Index: gnash/server/action.cpp
diff -u gnash/server/action.cpp:1.3 gnash/server/action.cpp:1.4
--- gnash/server/action.cpp:1.3 Mon Jan 23 16:04:19 2006
+++ gnash/server/action.cpp Mon Jan 23 17:01:13 2006
@@ -24,7 +24,6 @@
#include "xmlsocket.h"
#endif
-
#ifdef _WIN32
#define snprintf _snprintf
#endif // _WIN32
@@ -3184,9 +3183,18 @@
// @@ Moock says if value is a NAN, then result is "NaN"
// INF goes to "Infinity"
// -INF goes to "-Infinity"
- char buffer[50];
- snprintf(buffer, 50, "%.14g", m_number_value);
- m_string_value = buffer;
+ if (isnan(m_number_value)) m_string_value = "NaN";
+ else if (isinf(m_number_value))
+ {
+ if (m_number_value > 0.0) m_string_value =
"+Infinity";
+ else m_string_value = "-Infinity";
+ }
+ else
+ {
+ char buffer[50];
+ snprintf(buffer, 50, "%.14g", m_number_value);
+ m_string_value = buffer;
+ }
}
else if (m_type == UNDEFINED)
{
@@ -3293,7 +3301,8 @@
if (! string_to_number(&m_number_value,
m_string_value.c_str()))
{
// Failed conversion to Number.
- m_number_value = 0.0; // TODO should be NaN
+ double temp = 0.0; // avoid divide by zero
compiler warning by using a variable
+ m_number_value = temp / temp; // this
division by zero creates a NaN value in the double
}
return m_number_value;
}
@@ -3362,7 +3371,7 @@
}
else if (m_type == NUMBER)
{
- // @@ Moock says, NaN --> false
+ // If m_number_value is NaN, comparison will
automatically be false, as it should
return m_number_value != 0.0;
}
else if (m_type == BOOLEAN)
Index: gnash/server/action.h
diff -u gnash/server/action.h:1.1 gnash/server/action.h:1.2
--- gnash/server/action.h:1.1 Tue Dec 20 21:01:18 2005
+++ gnash/server/action.h Mon Jan 23 17:01:13 2006
@@ -357,6 +357,9 @@
else if (v.m_type == AS_FUNCTION)
set_as_as_function(v.m_as_function_value);
}
+ bool is_nan() const { return (m_type == NUMBER &&
isnan(m_number_value)); }
+ bool is_inf() const { return (m_type == NUMBER &&
isinf(m_number_value)); }
+
bool operator==(const as_value& v) const;
bool operator!=(const as_value& v) const;
bool operator<(const as_value& v) const { return to_number()
< v.to_number(); }
Index: gnash/server/array.cpp
diff -u gnash/server/array.cpp:1.1 gnash/server/array.cpp:1.2
--- gnash/server/array.cpp:1.1 Mon Jan 23 16:04:19 2006
+++ gnash/server/array.cpp Mon Jan 23 17:01:13 2006
@@ -37,26 +37,18 @@
int as_array_object::index_requested(const tu_stringi& name)
{
- // TODO: update this function when we add support for "NaN"
(not-a-number) values in as_value::NUMBER
- // (because then strings like "asdf" will convert to "NaN"
instead of simply 0.
-
- // so, instead of trusting the to_number function, let's see if
we have a literal "0", and if we do we can return 0
- if (strcmp(name.c_str(),"0") == 0)
- return 0;
- else
- // if not, we will assume that any zero string returned by the
conversion function was not really a number string
- {
- int index;
- as_value temp;
- temp.set_string((const char *)name);
- // TODO / WARNING: because to_number returns a double
and we're converting to an int,
- // maybe we should make sure we're above any "grey
area" when we we round down
- // by adding 0.01 or so to the number before we round
it. We don't want to accidentally be looking at index-1!
- // I'll leave it the intuitive (but possibly flawed
way) for now, but if off-by-one errors start showing up, this is a possibility!
- index = int(temp.to_number());
- // if the number we found converted to zero, we will
assume we weren't given an array index, since we already handled "0" above
- return (index == 0) ? -1 : index;
- }
+ double value;
+ as_value temp;
+ temp.set_string((const char *)name);
+ value = temp.to_number();
+
+ // if we were sent a string that can't convert like "asdf", it
returns as NaN. -1 means invalid index
+ if (isnan(value)) return -1;
+
+ // TODO / WARNING: because to_number returns a double and we're
converting to an int,
+ // I want to make sure we're above any "grey area" when we we
round down
+ // by adding a little to the number before we round it. We
don't want to accidentally look to index-1!
+ return int(value + 0.01);
}
void as_array_object::set_member(const tu_stringi& name, const
as_value& val )
@@ -205,8 +197,3 @@
fn.result->set_as_object_interface(ao.get_ptr());
}
};
-
-
-
-
-
Index: gnash/server/string.cpp
diff -u gnash/server/string.cpp:1.2 gnash/server/string.cpp:1.3
--- gnash/server/string.cpp:1.2 Thu Jan 19 23:50:11 2006
+++ gnash/server/string.cpp Mon Jan 23 17:01:13 2006
@@ -36,7 +36,8 @@
return;
}
- fn.result->set_double(0); // FIXME: according to
docs, we're supposed to return "NaN"
+ double temp = 0.0; // This variable will let us
divide by zero without a compiler warning
+ fn.result->set_double(temp/temp); // this
division by zero creates a NaN value
return;
}
else if (method_name == "charAt")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ./ChangeLog server/action.cpp server/acti...,
Michael Carlson <=