[Swfdec] Branch 'as' - 2 commits - libswfdec/Makefile.am libswfdec/swfdec_as_strings.c libswfdec/swfdec_as_types.c libswfdec/swfdec_interval.c libswfdec/swfdec_interval.h libswfdec/swfdec_player_as.c libswfdec/swfdec_player.c

Benjamin Otte company at kemper.freedesktop.org
Fri Jun 1 12:32:11 PDT 2007


 libswfdec/Makefile.am         |    2 
 libswfdec/swfdec_as_strings.c |    2 
 libswfdec/swfdec_as_types.c   |    6 +
 libswfdec/swfdec_interval.c   |  184 ++++++++++++++++++++++++++++++++++++++++++
 libswfdec/swfdec_interval.h   |   78 +++++++++++++++++
 libswfdec/swfdec_player.c     |    2 
 libswfdec/swfdec_player_as.c  |  178 ++++++++++------------------------------
 7 files changed, 320 insertions(+), 132 deletions(-)

New commits:
diff-tree 89c4d90d1c31e4bba4b15f8419f7ebd13cd6cbb8 (from 4576fa2edfba68cb8edc199287ecf773a09cc7df)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jun 1 21:32:43 2007 +0200

    reenable intervals
    
    setInterval and clearInterval should work now

diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am
index d9b7b68..d701d51 100644
--- a/libswfdec/Makefile.am
+++ b/libswfdec/Makefile.am
@@ -80,6 +80,7 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES
 	swfdec_graphic_movie.c \
 	swfdec_html_parser.c \
 	swfdec_image.c \
+	swfdec_interval.c \
 	swfdec_listener.c \
 	swfdec_loader.c \
 	swfdec_loadertarget.c \
@@ -177,6 +178,7 @@ noinst_HEADERS = \
 	swfdec_graphic.h \
 	swfdec_graphic_movie.h \
 	swfdec_image.h \
+	swfdec_interval.h \
 	swfdec_listener.h \
 	swfdec_loader_internal.h \
 	swfdec_loadertarget.h \
diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index a68b8e0..e59c69c 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -199,6 +199,8 @@ const char swfdec_as_strings[] = 
   SWFDEC_AS_CONSTANT_STRING ("toUpperCase")
   SWFDEC_AS_CONSTANT_STRING ("isFinite")
   SWFDEC_AS_CONSTANT_STRING ("isNaN")
+  SWFDEC_AS_CONSTANT_STRING ("setInterval")
+  SWFDEC_AS_CONSTANT_STRING ("clearInterval")
   /* add more here */
 ;
 
diff --git a/libswfdec/swfdec_interval.c b/libswfdec/swfdec_interval.c
new file mode 100644
index 0000000..ab79eb8
--- /dev/null
+++ b/libswfdec/swfdec_interval.c
@@ -0,0 +1,184 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "swfdec_interval.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_function.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+
+G_DEFINE_TYPE (SwfdecInterval, swfdec_interval, SWFDEC_TYPE_AS_OBJECT)
+
+static void
+swfdec_interval_mark (SwfdecAsObject *object)
+{
+  guint i;
+  SwfdecInterval *interval = SWFDEC_INTERVAL (object);
+
+  swfdec_as_object_mark (interval->object);
+  if (interval->fun_name)
+    swfdec_as_string_mark (interval->fun_name);
+  for (i = 0; i < interval->n_args; i++) {
+    swfdec_as_value_mark (&interval->args[i]);
+  }
+
+  SWFDEC_AS_OBJECT_CLASS (swfdec_interval_parent_class)->mark (object);
+}
+
+static void
+swfdec_interval_dispose (GObject *object)
+{
+  SwfdecInterval *interval = SWFDEC_INTERVAL (object);
+
+  g_free (interval->args);
+  interval->args = NULL;
+  /* needed here when GC'ed by closing the player */
+  if (interval->timeout.callback != NULL) {
+    swfdec_player_remove_timeout (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (object)->context), &interval->timeout);
+    interval->timeout.callback = NULL;
+  }
+
+  G_OBJECT_CLASS (swfdec_interval_parent_class)->dispose (object);
+}
+
+static void
+swfdec_interval_class_init (SwfdecIntervalClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+
+  object_class->dispose = swfdec_interval_dispose;
+
+  asobject_class->mark = swfdec_interval_mark;
+}
+
+static void
+swfdec_interval_init (SwfdecInterval *array)
+{
+}
+
+static void
+swfdec_interval_trigger (SwfdecTimeout *timeout)
+{
+  SwfdecAsValue ret;
+  SwfdecInterval *interval = SWFDEC_INTERVAL (((guchar *) timeout) 
+      - G_STRUCT_OFFSET (SwfdecInterval, timeout));
+  SwfdecAsContext *context = SWFDEC_AS_OBJECT (interval)->context;
+
+  if (interval->repeat) {
+    timeout->timestamp += SWFDEC_MSECS_TO_TICKS (interval->msecs);
+    swfdec_player_add_timeout (SWFDEC_PLAYER (context), timeout);
+  } else {
+    interval->timeout.callback = NULL;
+  }
+  if (interval->fun_name) {
+    swfdec_as_object_call (interval->object, interval->fun_name, 
+	interval->n_args, interval->args, &ret);
+  } else {
+    swfdec_as_function_call (SWFDEC_AS_FUNCTION (interval->object), NULL, 
+	interval->n_args, interval->args, &ret);
+    swfdec_as_context_run (context);
+  }
+}
+
+guint
+swfdec_interval_new (SwfdecPlayer *player, guint msecs, gboolean repeat, 
+    SwfdecAsObject *object, const char *fun_name,
+    guint n_args, const SwfdecAsValue *args)
+{
+  SwfdecAsContext *context;
+  SwfdecInterval *interval;
+  guint size;
+
+  context = SWFDEC_AS_CONTEXT (player);
+  size = sizeof (SwfdecInterval) + n_args * sizeof (SwfdecAsValue);
+  if (!swfdec_as_context_use_mem (context, size))
+    return 0;
+  interval = g_object_new (SWFDEC_TYPE_INTERVAL, NULL);
+  swfdec_as_object_add (SWFDEC_AS_OBJECT (interval), context, size);
+
+  interval->id = ++player->interval_id;
+  interval->msecs = msecs;
+  interval->repeat = repeat;
+  interval->object = object;
+  interval->fun_name = fun_name;
+  interval->n_args = n_args;
+  interval->args = g_memdup (args, n_args * sizeof (SwfdecAsValue));
+  interval->timeout.timestamp = player->time + SWFDEC_MSECS_TO_TICKS (interval->msecs);
+  interval->timeout.callback = swfdec_interval_trigger;
+  swfdec_player_add_timeout (player, &interval->timeout);
+
+  player->intervals = 
+    g_list_prepend (player->intervals, interval);
+
+  return interval->id;
+}
+
+guint
+swfdec_interval_new_function (SwfdecPlayer *player, guint msecs, gboolean repeat,
+    SwfdecAsFunction *fun, guint n_args, const SwfdecAsValue *args)
+{
+  g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0);
+  g_return_val_if_fail (msecs > 0, 0);
+  g_return_val_if_fail (SWFDEC_IS_AS_FUNCTION (fun), 0);
+  g_return_val_if_fail (n_args == 0 || args != NULL, 0);
+
+  return swfdec_interval_new (player, msecs, repeat, SWFDEC_AS_OBJECT (fun), NULL, n_args, args);
+}
+
+guint
+swfdec_interval_new_object (SwfdecPlayer *player, guint msecs, gboolean repeat,
+    SwfdecAsObject *thisp, const char *fun_name,
+    guint n_args, const SwfdecAsValue *args)
+{
+  g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0);
+  g_return_val_if_fail (msecs > 0, 0);
+  g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (thisp), 0);
+  g_return_val_if_fail (fun_name != NULL, 0);
+  g_return_val_if_fail (n_args == 0 || args != NULL, 0);
+
+  return swfdec_interval_new (player, msecs, repeat, thisp, fun_name, n_args, args);
+}
+
+void
+swfdec_interval_remove (SwfdecPlayer *player, guint id)
+{
+  GList *walk;
+
+  g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+  for (walk = player->intervals; walk; walk = walk->next) {
+    SwfdecInterval *interval = walk->data;
+    if (interval->id != id)
+      continue;
+
+    player->intervals = g_list_delete_link (player->intervals, walk);
+    swfdec_player_remove_timeout (player, &interval->timeout);
+    interval->timeout.callback = NULL;
+    return;
+  }
+}
+
diff --git a/libswfdec/swfdec_interval.h b/libswfdec/swfdec_interval.h
new file mode 100644
index 0000000..07da0c9
--- /dev/null
+++ b/libswfdec/swfdec_interval.h
@@ -0,0 +1,78 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifndef _SWFDEC_INTERVAL_H_
+#define _SWFDEC_INTERVAL_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_player_internal.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecInterval SwfdecInterval;
+typedef struct _SwfdecIntervalClass SwfdecIntervalClass;
+
+#define SWFDEC_TYPE_INTERVAL                    (swfdec_interval_get_type())
+#define SWFDEC_IS_INTERVAL(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_INTERVAL))
+#define SWFDEC_IS_INTERVAL_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_INTERVAL))
+#define SWFDEC_INTERVAL(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_INTERVAL, SwfdecInterval))
+#define SWFDEC_INTERVAL_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_INTERVAL, SwfdecIntervalClass))
+#define SWFDEC_INTERVAL_GET_CLASS(obj)          (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_INTERVAL, SwfdecIntervalClass))
+
+struct _SwfdecInterval {
+  SwfdecAsObject	asobject;
+
+  SwfdecTimeout		timeout;
+  guint			id;		/* id this interval is identified with */
+  guint			msecs;		/* interval in milliseconds */
+  gboolean		repeat;		/* TRUE for calling in intervals, FALSE for single-shot */
+  /* if calling named function */
+  SwfdecAsObject *	object;		/* this object or function to call (depending on fun_name) */
+  const char *		fun_name;	/* name of function or NULL if object is function */
+
+  guint			n_args;		/* number of arguments to call function with */
+  SwfdecAsValue *     	args;		/* arguments for function */
+};
+
+struct _SwfdecIntervalClass {
+  SwfdecAsObjectClass	asobject_class;
+};
+
+GType		swfdec_interval_get_type	(void);
+
+guint		swfdec_interval_new_function  	(SwfdecPlayer *		player,
+						 guint			msecs,
+						 gboolean		repeat,
+						 SwfdecAsFunction *	fun,
+						 guint			n_args,
+						 const SwfdecAsValue *	args);
+guint		swfdec_interval_new_object  	(SwfdecPlayer *		player,
+						 guint			msecs,
+						 gboolean		repeat,
+						 SwfdecAsObject *	thisp,
+						 const char *		fun_name,
+						 guint			n_args,
+						 const SwfdecAsValue *	args);
+void		swfdec_interval_remove		(SwfdecPlayer *		player,
+						 guint			id);
+
+
+G_END_DECLS
+#endif
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 965f021..54a2707 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -397,6 +397,8 @@ swfdec_player_dispose (GObject *object)
     swfdec_player_remove_timeout (player, &player->iterate_timeout);
   }
   g_assert (player->timeouts == NULL);
+  g_list_free (player->intervals);
+  player->intervals = NULL;
   g_assert (g_queue_is_empty (player->init_queue));
   g_assert (g_queue_is_empty (player->construct_queue));
   g_queue_free (player->init_queue);
diff --git a/libswfdec/swfdec_player_as.c b/libswfdec/swfdec_player_as.c
index 6a17cd0..565ed51 100644
--- a/libswfdec/swfdec_player_as.c
+++ b/libswfdec/swfdec_player_as.c
@@ -22,161 +22,73 @@
 #endif
 
 #include "swfdec_player_internal.h"
+#include "swfdec_as_function.h"
 #include "swfdec_as_object.h"
 #include "swfdec_debug.h"
+#include "swfdec_interval.h"
 
-#if 0
-/*** INTERVAL ***/
-
-typedef struct _SwfdecAsInterval SwfdecAsInterval;
-struct _SwfdecAsInterval {
-  SwfdecTimeout		timeout;
-  SwfdecPlayer *	player;		/* needed so it can be readded */
-  guint			id;		/* id this interval is identified with */
-  guint			msecs;		/* interval in milliseconds */
-  guint			n_args;		/* number of arguments to call function with */
-  SwfdecAsValue		vals[0];	/* values: 0 is function, 1 is object, 2-n are arguments */
-};
-
-void
-swfdec_js_interval_free (SwfdecAsInterval *interval)
-{
-  JSContext *cx = interval->player->jscx;
-  guint i;
-
-  swfdec_player_remove_timeout (interval->player, &interval->timeout);
-  interval->player->intervals = 
-    g_list_remove (interval->player->intervals, interval);
-  for (i = 0; i < interval->n_args + 2; i++) {
-    JS_RemoveRoot (cx, &interval->vals[i]);
-  }
-  g_free (interval);
-}
-
-static void
-swfdec_js_interval_trigger (SwfdecTimeout *timeout)
-{
-  SwfdecAsInterval *interval = (SwfdecAsInterval *) timeout;
-  JSContext *cx = interval->player->jscx;
-  SwfdecAsValue fun, rval;
-
-  timeout->timestamp += SWFDEC_MSECS_TO_TICKS (interval->msecs);
-  swfdec_player_add_timeout (interval->player, timeout);
-  g_assert (JSVAL_IS_OBJECT (interval->vals[1]));
-  if (JSVAL_IS_STRING (interval->vals[0])) {
-    JSAtom *atom = js_AtomizeString (cx, JSVAL_TO_STRING (interval->vals[0]), 0);
-    if (!atom)
-      return;
-    if (!js_GetProperty (cx, JSVAL_TO_OBJECT (interval->vals[1]),
-	  (jsid) atom, &fun))
-      return;
-  } else {
-    fun = interval->vals[0];
-  }
-  js_InternalCall (cx, JSVAL_TO_OBJECT (interval->vals[1]), fun,
-      interval->n_args, &interval->vals[2], &rval);
-}
-
-static SwfdecAsInterval *
-swfdec_js_interval_new (guint n_args)
-{
-  SwfdecAsInterval *ret = g_malloc (sizeof (SwfdecAsInterval) + sizeof (SwfdecAsValue) * (2 + n_args));
-
-  ret->timeout.callback = swfdec_js_interval_trigger;
-  ret->n_args = n_args;
-  return ret;
-}
+/*** INTERVALS ***/
 
 static void
-swfdec_js_global_setInterval (SwfdecAsObject *obj, uintN argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_player_do_set_interval (gboolean repeat, SwfdecAsObject *obj, guint argc, 
+    SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
-  SwfdecPlayer *player = JS_GetContextPrivate (cx);
+  SwfdecPlayer *player = SWFDEC_PLAYER (obj->context);
   SwfdecAsObject *object;
-  SwfdecAsValue fun;
-  guint i, n_args, first_arg, msecs;
-  SwfdecAsInterval *interval;
+  guint id, msecs;
+#define MIN_INTERVAL_TIME 10
 
-  if (!JSVAL_IS_OBJECT (argv[0])) {
+  if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0])) {
     SWFDEC_WARNING ("first argument to setInterval is not an object");
-    return JS_TRUE;
+    return;
   }
-  object = JSVAL_TO_OBJECT (argv[0]);
-  if (JS_GetClass (object) == &js_FunctionClass) {
-    fun = argv[0];
-    object = JS_GetParent (cx, object);
-    if (object == NULL) {
-      SWFDEC_WARNING ("function has no parent?!");
-      return JS_TRUE;
+  object = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
+  if (SWFDEC_IS_AS_FUNCTION (object)) {
+    msecs = swfdec_as_value_to_integer (obj->context, &argv[1]);
+    if (msecs < MIN_INTERVAL_TIME) {
+      SWFDEC_INFO ("interval duration is %u, making it %u msecs", msecs, MIN_INTERVAL_TIME);
+      msecs = MIN_INTERVAL_TIME;
     }
-    first_arg = 2;
+    id = swfdec_interval_new_function (player, msecs, TRUE, 
+	SWFDEC_AS_FUNCTION (object), argc - 2, &argv[2]);
   } else {
+    const char *name;
     if (argc < 3) {
       SWFDEC_WARNING ("setInterval needs 3 arguments when not called with function");
-      return JS_TRUE;
-    }
-    if (!JSVAL_IS_STRING (argv[1])) {
-      SWFDEC_WARNING ("function name passed to setInterval is not a string");
-      return JS_TRUE;
+      return;
     }
-    fun = argv[1];
-    first_arg = 3;
-  }
-  if (!JS_ValueToECMAUint32 (cx, argv[first_arg - 1], &msecs))
-    return JS_FALSE;
-#define MIN_INTERVAL_TIME 10
-  if (msecs < MIN_INTERVAL_TIME) {
-    SWFDEC_INFO ("interval duration is %u, making it %u msecs", msecs, MIN_INTERVAL_TIME);
-    msecs = MIN_INTERVAL_TIME;
-  }
-  n_args = argc - first_arg;
-  interval = swfdec_js_interval_new (n_args);
-  interval->player = player;
-  interval->id = ++player->interval_id;
-  interval->msecs = msecs;
-  interval->vals[0] = fun;
-  interval->vals[1] = OBJECT_TO_JSVAL (object);
-  memcpy (&interval->vals[2], &argv[first_arg], n_args * sizeof (SwfdecAsValue));
-  for (i = 0; i < n_args + 2; i++) {
-    if (!JS_AddRoot (cx, &interval->vals[i])) {
-      /* FIXME: is it save roots that weren't added before? */
-      swfdec_js_interval_free (interval);
-      return JS_FALSE;
+    name = swfdec_as_value_to_string (obj->context, &argv[1]);
+    msecs = swfdec_as_value_to_integer (obj->context, &argv[2]);
+    if (msecs < MIN_INTERVAL_TIME) {
+      SWFDEC_INFO ("interval duration is %u, making it %u msecs", msecs, MIN_INTERVAL_TIME);
+      msecs = MIN_INTERVAL_TIME;
     }
+    id = swfdec_interval_new_object (player, msecs, TRUE, object, name, argc - 2, &argv[2]);
   }
-  interval->timeout.timestamp = player->time + SWFDEC_MSECS_TO_TICKS (interval->msecs);
-  swfdec_player_add_timeout (player, &interval->timeout);
-  interval->player->intervals = 
-    g_list_prepend (interval->player->intervals, interval);
-  *rval = INT_TO_JSVAL (interval->id);
-  return JS_TRUE;
+  SWFDEC_AS_VALUE_SET_INT (rval, id);
 }
 
 static void
-swfdec_js_global_clearInterval (SwfdecAsObject *obj, uintN argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_player_setInterval (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
-  SwfdecPlayer *player = JS_GetContextPrivate (cx);
-  guint id;
-  GList *walk;
+  swfdec_player_do_set_interval (TRUE, obj, argc, argv, rval);
+}
 
-  if (!JSVAL_IS_INT (argv[0])) {
-    SWFDEC_WARNING ("argument is not an int");
-    return JS_TRUE;
-  }
-  id = JSVAL_TO_INT (argv[0]);
-  for (walk = player->intervals; walk; walk = walk->next) {
-    SwfdecAsInterval *interval = walk->data;
-    if (interval->id != id)
-      continue;
-    swfdec_js_interval_free (interval);
-    break;
-  }
-  return JS_TRUE;
+static void
+swfdec_player_clearInterval (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+  SwfdecPlayer *player = SWFDEC_PLAYER (obj->context);
+  guint id;
+  
+  id = swfdec_as_value_to_integer (obj->context, &argv[0]);
+  swfdec_interval_remove (player, id);
 }
 
 /*** VARIOUS ***/
 
+#if 0
 void
-swfdec_js_global_eval (SwfdecAsObject *obj, uintN argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_js_global_eval (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
   if (JSVAL_IS_STRING (argv[0])) {
     const char *bytes = swfdec_js_to_string (cx, argv[0]);
@@ -190,7 +102,7 @@ swfdec_js_global_eval (SwfdecAsObject *o
 }
 
 static void
-swfdec_js_trace (SwfdecAsObject *obj, uintN argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_js_trace (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
   SwfdecPlayer *player = JS_GetContextPrivate (cx);
   const char *bytes;
@@ -204,7 +116,7 @@ swfdec_js_trace (SwfdecAsObject *obj, ui
 }
 
 static void
-swfdec_js_random (SwfdecAsObject *obj, uintN argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_js_random (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
   gint32 max, result;
 
@@ -220,7 +132,7 @@ swfdec_js_random (SwfdecAsObject *obj, u
 }
 
 static void
-swfdec_js_stopAllSounds (SwfdecAsObject *obj, uintN argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_js_stopAllSounds (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
   SwfdecPlayer *player = JS_GetContextPrivate (cx);
 
@@ -263,5 +175,9 @@ swfdec_player_init_global (SwfdecPlayer 
 
   swfdec_as_object_add_function (context->Object, SWFDEC_AS_STR_registerClass, 
       0, swfdec_player_object_registerClass, 2);
+  swfdec_as_object_add_function (context->global, SWFDEC_AS_STR_setInterval, 
+      0, swfdec_player_setInterval, 2);
+  swfdec_as_object_add_function (context->global, SWFDEC_AS_STR_clearInterval, 
+      0, swfdec_player_clearInterval, 1);
 }
 
diff-tree 4576fa2edfba68cb8edc199287ecf773a09cc7df (from 3c0a7a24da1aa0e7f87c65deb3872b6e95dfa5e4)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jun 1 10:01:07 2007 +0200

    fix _value_to_integer() to not cast negative doubles to uints.
    
    It doesn't return the same result on PPC and x86.

diff --git a/libswfdec/swfdec_as_types.c b/libswfdec/swfdec_as_types.c
index 9105a96..61502a2 100644
--- a/libswfdec/swfdec_as_types.c
+++ b/libswfdec/swfdec_as_types.c
@@ -292,7 +292,11 @@ swfdec_as_value_to_integer (SwfdecAsCont
   d = swfdec_as_value_to_number (context, value);
   if (!isfinite (d))
     return 0;
-  return (guint) fmod (d, 4294967296);
+  if (d < 0) {
+    return - (guint) fmod (-d, 4294967296);
+  } else {
+    return (guint) fmod (d, 4294967296);
+  }
 }
 
 /**


More information about the Swfdec mailing list