[Swfdec] Branch 'as' - 2 commits - libswfdec/swfdec_as_math.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Fri Jul 6 03:37:48 PDT 2007


 libswfdec/swfdec_as_math.c             |   10 +++++++++-
 test/trace/Makefile.am                 |    9 +++++++++
 test/trace/round-direction-5.swf       |binary
 test/trace/round-direction-5.swf.trace |    5 +++++
 test/trace/round-direction-6.swf       |binary
 test/trace/round-direction-6.swf.trace |    5 +++++
 test/trace/round-direction-7.swf       |binary
 test/trace/round-direction-7.swf.trace |    5 +++++
 test/trace/round-direction-8.swf       |binary
 test/trace/round-direction-8.swf.trace |    5 +++++
 test/trace/round-direction.as          |   10 ++++++++++
 11 files changed, 48 insertions(+), 1 deletion(-)

New commits:
diff-tree 1ae03b097c0fb14a0ed89e955bfd016a02247eef (from 4e3d40276024ca6504884f00a94a930c65cb52ca)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jul 6 11:37:55 2007 +0100

    add test for round direction

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 423a732..447b109 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -620,6 +620,15 @@ EXTRA_DIST = \
 	removesprite-depths-7.swf.trace \
 	rotation-5.swf \
 	rotation-5.swf.trace \
+	round-direction.as \
+	round-direction-5.swf \
+	round-direction-5.swf.trace \
+	round-direction-6.swf \
+	round-direction-6.swf.trace \
+	round-direction-7.swf \
+	round-direction-7.swf.trace \
+	round-direction-8.swf \
+	round-direction-8.swf.trace \
 	scope.swf \
 	scope.swf.trace \
 	scope2.swf \
diff --git a/test/trace/round-direction-5.swf b/test/trace/round-direction-5.swf
new file mode 100644
index 0000000..7d23dfb
Binary files /dev/null and b/test/trace/round-direction-5.swf differ
diff --git a/test/trace/round-direction-5.swf.trace b/test/trace/round-direction-5.swf.trace
new file mode 100644
index 0000000..39ef339
--- /dev/null
+++ b/test/trace/round-direction-5.swf.trace
@@ -0,0 +1,5 @@
+Check rounding direction
+0
+-1
+1
+2
diff --git a/test/trace/round-direction-6.swf b/test/trace/round-direction-6.swf
new file mode 100644
index 0000000..75cbbf9
Binary files /dev/null and b/test/trace/round-direction-6.swf differ
diff --git a/test/trace/round-direction-6.swf.trace b/test/trace/round-direction-6.swf.trace
new file mode 100644
index 0000000..39ef339
--- /dev/null
+++ b/test/trace/round-direction-6.swf.trace
@@ -0,0 +1,5 @@
+Check rounding direction
+0
+-1
+1
+2
diff --git a/test/trace/round-direction-7.swf b/test/trace/round-direction-7.swf
new file mode 100644
index 0000000..1fbb4d9
Binary files /dev/null and b/test/trace/round-direction-7.swf differ
diff --git a/test/trace/round-direction-7.swf.trace b/test/trace/round-direction-7.swf.trace
new file mode 100644
index 0000000..39ef339
--- /dev/null
+++ b/test/trace/round-direction-7.swf.trace
@@ -0,0 +1,5 @@
+Check rounding direction
+0
+-1
+1
+2
diff --git a/test/trace/round-direction-8.swf b/test/trace/round-direction-8.swf
new file mode 100644
index 0000000..e14a959
Binary files /dev/null and b/test/trace/round-direction-8.swf differ
diff --git a/test/trace/round-direction-8.swf.trace b/test/trace/round-direction-8.swf.trace
new file mode 100644
index 0000000..39ef339
--- /dev/null
+++ b/test/trace/round-direction-8.swf.trace
@@ -0,0 +1,5 @@
+Check rounding direction
+0
+-1
+1
+2
diff --git a/test/trace/round-direction.as b/test/trace/round-direction.as
new file mode 100644
index 0000000..3d2ccc1
--- /dev/null
+++ b/test/trace/round-direction.as
@@ -0,0 +1,10 @@
+// makeswf -v 7 -s 200x150 -r 1 -o round-direction.swf round-direction.as
+
+trace ("Check rounding direction");
+
+trace (Math.round (-0.5));
+trace (Math.round (-1.5));
+trace (Math.round (0.5));
+trace (Math.round (1.5));
+
+loadMovie ("FSCommand:quit", "");
diff-tree 4e3d40276024ca6504884f00a94a930c65cb52ca (from 6982d35c8223c70e0e2644710ac6ebc42f96901d)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jul 6 11:36:31 2007 +0100

    round direction is up

diff --git a/libswfdec/swfdec_as_math.c b/libswfdec/swfdec_as_math.c
index ad2468a..dff7c7d 100644
--- a/libswfdec/swfdec_as_math.c
+++ b/libswfdec/swfdec_as_math.c
@@ -50,7 +50,6 @@ MATH_FUN (cos)
 MATH_FUN (exp)
 MATH_FUN (floor)
 MATH_FUN (log)
-MATH_FUN (round)
 MATH_FUN (sin)
 MATH_FUN (sqrt)
 MATH_FUN (tan)
@@ -110,6 +109,15 @@ swfdec_as_math_random (SwfdecAsContext *
   SWFDEC_AS_VALUE_SET_NUMBER (ret, g_rand_double (cx->rand));
 }
 
+static void
+swfdec_as_math_round (SwfdecAsContext *cx, SwfdecAsObject *object, 
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+  double d = swfdec_as_value_to_number (cx, &argv[0]);
+
+  SWFDEC_AS_VALUE_SET_NUMBER (ret, trunc (d + 0.5));
+}
+
 /* define some math constants if glib doesn't have them */
 #ifndef G_LOG10E
 #define G_LOG10E 0.43429448190325182765


More information about the Swfdec mailing list