[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/as_value.cpp server/as_v...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/as_value.cpp server/as_v... |
Date: |
Mon, 06 Aug 2007 20:42:57 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/08/06 20:42:57
Modified files:
. : ChangeLog
server : as_value.cpp as_value.h
server/vm : ASHandlers.cpp
testsuite/swfdec: PASSING
Log message:
* server/as_value.{cpp,h}: add a to_int() method taking
care of compatible integer conversion. Add note about
deprecation of templated to_number<>.
* server/vm/ASHandlers.cpp: explicitly use to_int() in bitwise
ops. Fixes ops.as testcases built with newer Ming. Add TODO
lines about possible other uses.
* testsuite/swfdec/PASSING: bitwise-{5,6,7}.swf now pass.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3955&r2=1.3956
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.cpp?cvsroot=gnash&r1=1.63&r2=1.64
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.h?cvsroot=gnash&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.117&r2=1.118
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.24&r2=1.25
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3955
retrieving revision 1.3956
diff -u -b -r1.3955 -r1.3956
--- ChangeLog 6 Aug 2007 19:30:47 -0000 1.3955
+++ ChangeLog 6 Aug 2007 20:42:56 -0000 1.3956
@@ -1,5 +1,15 @@
2007-08-06 Sandro Santilli <address@hidden>
+ * server/as_value.{cpp,h}: add a to_int() method taking
+ care of compatible integer conversion. Add note about
+ deprecation of templated to_number<>.
+ * server/vm/ASHandlers.cpp: explicitly use to_int() in bitwise
+ ops. Fixes ops.as testcases built with newer Ming. Add TODO
+ lines about possible other uses.
+ * testsuite/swfdec/PASSING: bitwise-{5,6,7}.swf now pass.
+
+2007-08-06 Sandro Santilli <address@hidden>
+
* testsuite/actionscript.all/ops.as: add test for 0xffffffff
conversion to integer needing to be -1 (gnash fails, need Ming head
to reproduce)
Index: server/as_value.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.cpp,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -b -r1.63 -r1.64
--- server/as_value.cpp 2 Aug 2007 20:11:35 -0000 1.63
+++ server/as_value.cpp 6 Aug 2007 20:42:57 -0000 1.64
@@ -330,6 +330,26 @@
/* NOTREACHED */
}
+int32_t
+as_value::to_int(as_environment& env) const
+{
+ double d = to_number(&env);
+ int i=0;
+
+ if ( ! isfinite(d) ) return 0;
+
+ if (d < 0)
+ {
+ i = - (uint32_t) fmod (-d, 4294967296.0);
+ }
+ else
+ {
+ i = (uint32_t) fmod (d, 4294967296.0);
+ }
+
+ return i;
+}
+
// Conversion to boolean for SWF7 and up
bool
as_value::to_bool_v7() const
Index: server/as_value.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- server/as_value.h 2 Aug 2007 18:28:42 -0000 1.61
+++ server/as_value.h 6 Aug 2007 20:42:57 -0000 1.62
@@ -15,7 +15,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: as_value.h,v 1.61 2007/08/02 18:28:42 strk Exp $ */
+/* $Id: as_value.h,v 1.62 2007/08/06 20:42:57 strk Exp $ */
#ifndef GNASH_AS_VALUE_H
#define GNASH_AS_VALUE_H
@@ -330,7 +330,7 @@
///
const std::string& to_string_versioned(int version,
as_environment* env=NULL) const;
- /// Conversion to number
+ /// Conversion to number (double)
//
/// @param env
/// The environment to use for running the valueOf() method
@@ -338,10 +338,26 @@
///
double to_number(as_environment* env=NULL) const;
+ /// Conversion to 32bit integer
+ //
+ /// Use this conversion whenever an int is needed.
+ /// This is NOT the same as calling to_number<int32_t>().
+ ///
+ /// @param env
+ /// The environment to use for running the valueOf() method
+ /// for object values.
+ ///
+ int32_t to_int(as_environment& env) const;
+
/// Shorthand: casts the result of to_number() to the requested number
/// type.
//
/// Parameter identical to that of to_number().
+ ///
+ /// TODO: deprecate this function, it gets confusing as when an integer
+ /// is needed the caller should invoke to_int() rather then
to_number().
+ /// Implementing specializations for *all* integer types might be
tedious
+ ///
template <typename T>
T to_number (as_environment* env=NULL) const
{
Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -b -r1.117 -r1.118
--- server/vm/ASHandlers.cpp 6 Aug 2007 18:24:19 -0000 1.117
+++ server/vm/ASHandlers.cpp 6 Aug 2007 20:42:57 -0000 1.118
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: ASHandlers.cpp,v 1.117 2007/08/06 18:24:19 strk Exp $ */
+/* $Id: ASHandlers.cpp,v 1.118 2007/08/06 20:42:57 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -867,7 +867,7 @@
int size = unsigned(size_val.to_number(&env));
- int base = int(base_val.to_number(&env));
+ int base = int(base_val.to_number(&env)); // TODO: use to_int ?
int version = env.get_version();
const std::string& str = string_val.to_string_versioned(version);
@@ -950,7 +950,7 @@
// GNASH_REPORT_FUNCTION;
as_environment& env = thread.env;
thread.ensureStack(1);
- env.top(0).set_int(int(floor(env.top(0).to_number(&env))));
+ env.top(0).set_int(int(floor(env.top(0).to_number(&env)))); // TODO: use
to_int ?
}
void
@@ -1146,7 +1146,7 @@
thread.ensureStack(3);
- int depth =
int(env.top(0).to_number(&env))+character::staticDepthOffset;
+ int depth =
int(env.top(0).to_number(&env))+character::staticDepthOffset; // TODO: use
to_int ?
const std::string& newname = env.top(1).to_string(&env);
const std::string& path = env.top(2).to_string(&env);
@@ -1379,7 +1379,7 @@
thread.ensureStack(1); // max
- int max = int(env.top(0).to_number(&env));
+ int max = int(env.top(0).to_number(&env)); // TODO: use to_int ?
if (max < 1) max = 1;
env.top(0).set_int(tu_random::next_random() % max);
}
@@ -1416,7 +1416,7 @@
as_environment& env = thread.env;
thread.ensureStack(1);
char buf[2];
- buf[0] = int(env.top(0).to_number(&env));
+ buf[0] = int(env.top(0).to_number(&env)); // TODO: use to_int() ?
buf[1] = 0;
env.top(0).set_string(buf);
}
@@ -3072,14 +3072,10 @@
as_environment& env = thread.env;
thread.ensureStack(2);
- double operand1 = env.top(1).to_number(&env);
- double operand2 = env.top(0).to_number(&env);
-
- // TODO: have as_value::to_number<int> handle this ?
- if ( isnan(operand1) ) operand1 = 0;
- if ( isnan(operand2) ) operand2 = 0;
+ int operand1 = env.top(1).to_int(env);
+ int operand2 = env.top(0).to_int(env);
- env.top(1) = int(operand1) & int(operand2);
+ env.top(1) = operand1 & operand2;
env.drop(1);
}
@@ -3090,14 +3086,10 @@
as_environment& env = thread.env;
thread.ensureStack(2);
- double operand1 = env.top(1).to_number(&env);
- double operand2 = env.top(0).to_number(&env);
+ int operand1 = env.top(1).to_int(env);
+ int operand2 = env.top(0).to_int(env);
- // TODO: have as_value::to_number<int> handle this ?
- if ( isnan(operand1) ) operand1 = 0;
- if ( isnan(operand2) ) operand2 = 0;
-
- env.top(1) = int(operand1)|int(operand2);
+ env.top(1) = operand1|operand2;
env.drop(1);
}
@@ -3109,14 +3101,10 @@
as_environment& env = thread.env;
thread.ensureStack(2);
- double operand1 = env.top(1).to_number(&env);
- double operand2 = env.top(0).to_number(&env);
-
- // TODO: have as_value::to_number<int> handle this ?
- if ( isnan(operand1) ) operand1 = 0;
- if ( isnan(operand2) ) operand2 = 0;
+ int operand1 = env.top(1).to_int(env);
+ int operand2 = env.top(0).to_int(env);
- env.top(1) = int(operand1)^int(operand2);
+ env.top(1) = operand1^operand2;
env.drop(1);
}
@@ -3130,13 +3118,10 @@
as_environment& env = thread.env;
thread.ensureStack(2);
- double operand1 = env.top(1).to_number(&env);
- double operand2 = env.top(0).to_number(&env);
-
- // TODO: have as_value::to_number<int> handle this ?
- if ( isnan(operand1) ) operand1=0;
+ int16_t operand1 = env.top(1).to_int(env);
+ int16_t operand2 = env.top(0).to_int(env);
- env.top(1) = int16_t(operand1) << int(operand2);
+ env.top(1) = operand1 << operand2;
env.drop(1);
}
@@ -3150,13 +3135,10 @@
as_environment& env = thread.env;
thread.ensureStack(2);
- double operand1 = env.top(1).to_number(&env);
- double operand2 = env.top(0).to_number(&env);
+ int16_t operand1 = env.top(1).to_int(env);
+ int operand2 = env.top(0).to_int(env);
- // TODO: have as_value::to_number<int> handle this ?
- if ( isnan(operand1) ) operand1=0;
-
- env.top(1) = int16_t(operand1) >> int(operand2);
+ env.top(1) = operand1 >> operand2;
env.drop(1);
}
@@ -3169,13 +3151,10 @@
as_environment& env = thread.env;
thread.ensureStack(2);
- double operand1 = env.top(1).to_number(&env);
- double operand2 = env.top(0).to_number(&env);
-
- // TODO: have as_value::to_number<int> handle this ?
- if ( isnan(operand1) ) operand1=0;
+ uint32_t operand1 = env.top(1).to_int(env);
+ int operand2 = env.top(0).to_int(env);
- env.top(1) = uint32_t(operand1) >> int(operand2);
+ env.top(1) = operand1 >> operand2;
env.drop(1);
}
Index: testsuite/swfdec/PASSING
===================================================================
RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- testsuite/swfdec/PASSING 11 Jul 2007 00:33:57 -0000 1.24
+++ testsuite/swfdec/PASSING 6 Aug 2007 20:42:57 -0000 1.25
@@ -93,3 +93,6 @@
instance-name-loaded-5.swf
instance-name-loaded-6.swf
instance-name-loaded-7.swf
+bitwise-5.swf
+bitwise-6.swf
+bitwise-7.swf