[Swfdec] Branch 'as' - 5 commits - libswfdec-gtk/swfdec_playback_alsa.c libswfdec/swfdec_as_interpret.c libswfdec/swfdec_movie.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Thu Jun 28 07:03:11 PDT 2007


 libswfdec-gtk/swfdec_playback_alsa.c       |    3 --
 libswfdec/swfdec_as_interpret.c            |   32 ++++++++++++++++++++++++++++-
 libswfdec/swfdec_movie.c                   |   11 +++++++++
 test/trace/Makefile.am                     |    7 ++++++
 test/trace/removesprite-depths-5.swf       |binary
 test/trace/removesprite-depths-5.swf.trace |   15 +++++++++++++
 test/trace/removesprite-depths-6.swf       |binary
 test/trace/removesprite-depths-6.swf.trace |   15 +++++++++++++
 test/trace/removesprite-depths-7.swf       |binary
 test/trace/removesprite-depths-7.swf.trace |   15 +++++++++++++
 test/trace/removesprite-depths.as          |   17 +++++++++++++++
 11 files changed, 110 insertions(+), 5 deletions(-)

New commits:
diff-tree 0a6d54d5df44db6ef9d1d81b2dc8add873f20787 (from 2c6cc23e77d61fbdccaa80b43dc1eaf5970297ab)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jun 28 16:02:42 2007 +0200

    add test for RemoveSprite action

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 4132702..e06d866 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -579,6 +579,13 @@ EXTRA_DIST = \
 	relational-6.swf.trace \
 	relational-7.swf \
 	relational-7.swf.trace \
+	removesprite-depths.as \
+	removesprite-depths-5.swf \
+	removesprite-depths-5.swf.trace \
+	removesprite-depths-6.swf \
+	removesprite-depths-6.swf.trace \
+	removesprite-depths-7.swf \
+	removesprite-depths-7.swf.trace \
 	rotation-5.swf \
 	rotation-5.swf.trace \
 	scope.swf \
diff --git a/test/trace/removesprite-depths-5.swf b/test/trace/removesprite-depths-5.swf
new file mode 100644
index 0000000..03d94e9
Binary files /dev/null and b/test/trace/removesprite-depths-5.swf differ
diff --git a/test/trace/removesprite-depths-5.swf.trace b/test/trace/removesprite-depths-5.swf.trace
new file mode 100644
index 0000000..c90dc78
--- /dev/null
+++ b/test/trace/removesprite-depths-5.swf.trace
@@ -0,0 +1,15 @@
+Check RemoveSprite action with various depths
+ @ 
+ @ 
+ @ 
+ @ 
+ @ 
+ @ 
+ @ 
+ @ 
+ @ 
+ @ 
+ @ 
+ @ 
+ @ 
+ @ 
diff --git a/test/trace/removesprite-depths-6.swf b/test/trace/removesprite-depths-6.swf
new file mode 100644
index 0000000..3b21061
Binary files /dev/null and b/test/trace/removesprite-depths-6.swf differ
diff --git a/test/trace/removesprite-depths-6.swf.trace b/test/trace/removesprite-depths-6.swf.trace
new file mode 100644
index 0000000..e433a6f
--- /dev/null
+++ b/test/trace/removesprite-depths-6.swf.trace
@@ -0,0 +1,15 @@
+Check RemoveSprite action with various depths
+_level0.movie-2000000 @ -2000000
+_level0.movie-2000000 @ -2000000
+_level0.movie-20000 @ -20000
+_level0.movie-20000 @ -20000
+_level0.movie-10000 @ -10000
+_level0.movie-10000 @ -10000
+_level0.movie-1 @ -1
+_level0.movie-1 @ -1
+_level0.movie0 @ 0
+ @ 
+_level0.movie1000000 @ 1000000
+ @ 
+_level0.movie2000000 @ 2000000
+_level0.movie2000000 @ 2000000
diff --git a/test/trace/removesprite-depths-7.swf b/test/trace/removesprite-depths-7.swf
new file mode 100644
index 0000000..96a4d2e
Binary files /dev/null and b/test/trace/removesprite-depths-7.swf differ
diff --git a/test/trace/removesprite-depths-7.swf.trace b/test/trace/removesprite-depths-7.swf.trace
new file mode 100644
index 0000000..f186853
--- /dev/null
+++ b/test/trace/removesprite-depths-7.swf.trace
@@ -0,0 +1,15 @@
+Check RemoveSprite action with various depths
+_level0.movie-2000000 @ -2000000
+_level0.movie-2000000 @ -2000000
+_level0.movie-20000 @ -20000
+_level0.movie-20000 @ -20000
+_level0.movie-10000 @ -10000
+_level0.movie-10000 @ -10000
+_level0.movie-1 @ -1
+_level0.movie-1 @ -1
+_level0.movie0 @ 0
+undefined @ undefined
+_level0.movie1000000 @ 1000000
+undefined @ undefined
+_level0.movie2000000 @ 2000000
+_level0.movie2000000 @ 2000000
diff --git a/test/trace/removesprite-depths.as b/test/trace/removesprite-depths.as
new file mode 100644
index 0000000..93bfa0f
--- /dev/null
+++ b/test/trace/removesprite-depths.as
@@ -0,0 +1,17 @@
+// makeswf -v 7 -s 200x150 -r 1 -o removesprite-depths.swf removesprite-depths.as
+
+trace ("Check RemoveSprite action with various depths");
+
+depths = [-2000000, -20000, -10000, -1, 0, 1000000, 2000000 ];
+for (i = 0; i < depths.length; i++) {
+  x = createEmptyMovieClip ("movie" + depths[i], depths[i]);
+  trace (this["movie" + depths[i]] + " @ " + x.getDepth ());
+  asm {
+    push "x"
+    getvariable
+    removemovieclip
+  };
+  trace (this["movie" + depths[i]] + " @ " + x.getDepth ());
+}
+
+loadMovie ("FSCommand:quit", "");
diff-tree 2c6cc23e77d61fbdccaa80b43dc1eaf5970297ab (from fd7044406415e0cea602c1ed36ef2992d4d12060)
Author: Nguyễn Thái Ngọc Duy <pclouds at gmail.com>
Date:   Thu Jun 28 16:01:45 2007 +0200

    add RemoveSprite action
    
    Signed-off-by: Benjamin Otte <otte at gnome.org>

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index 09578b8..e6f6c78 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -1998,6 +1998,35 @@ swfdec_action_with (SwfdecAsContext *cx,
   swfdec_as_with_new (object, data + len, GUINT16_FROM_LE (*(guint16 *) data));
 }
 
+static void
+swfdec_action_remove_sprite (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+  SwfdecAsValue *val = swfdec_as_stack_pop (cx->frame->stack);
+  SwfdecAsObject *sprite;
+  SwfdecMovie *movie;
+
+  if (SWFDEC_AS_VALUE_IS_STRING (val)) {
+    const char *name = SWFDEC_AS_VALUE_GET_STRING (val);
+
+    swfdec_as_context_eval (cx, NULL, name, val);
+  }
+  if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
+    sprite = SWFDEC_AS_VALUE_GET_OBJECT (val);
+  } else {
+    SWFDEC_FIXME ("unknown type in RemoveSprite");
+    return;
+  }
+  if (!SWFDEC_IS_MOVIE (sprite)) {
+    SWFDEC_FIXME ("cannot remove non movieclip objects");
+    return;
+  }
+  movie = SWFDEC_MOVIE (sprite);
+  if (swfdec_depth_classify (movie->depth) == SWFDEC_DEPTH_CLASS_DYNAMIC) {
+    SWFDEC_LOG ("removing clip %s", movie->name);
+    swfdec_movie_remove (movie);
+  }
+}
+
 /*** PRINT FUNCTIONS ***/
 
 static char *
@@ -2336,7 +2365,7 @@ const SwfdecActionSpec swfdec_as_actions
   [SWFDEC_AS_ACTION_GET_PROPERTY] = { "GetProperty", NULL, 2, 1, { NULL, swfdec_action_get_property, swfdec_action_get_property, swfdec_action_get_property, swfdec_action_get_property } },
   [SWFDEC_AS_ACTION_SET_PROPERTY] = { "SetProperty", NULL, 3, 0, { NULL, swfdec_action_set_property, swfdec_action_set_property, swfdec_action_set_property, swfdec_action_set_property } },
   [SWFDEC_AS_ACTION_CLONE_SPRITE] = { "CloneSprite", NULL },
-  [SWFDEC_AS_ACTION_REMOVE_SPRITE] = { "RemoveSprite", NULL },
+  [SWFDEC_AS_ACTION_REMOVE_SPRITE] = { "RemoveSprite", NULL, 1, 0, { NULL, swfdec_action_remove_sprite, swfdec_action_remove_sprite, swfdec_action_remove_sprite, swfdec_action_remove_sprite } },
   [SWFDEC_AS_ACTION_TRACE] = { "Trace", NULL, 1, 0, { NULL, swfdec_action_trace, swfdec_action_trace, swfdec_action_trace, swfdec_action_trace } },
   [SWFDEC_AS_ACTION_START_DRAG] = { "StartDrag", NULL, -1, 0, { NULL, swfdec_action_start_drag, swfdec_action_start_drag, swfdec_action_start_drag, swfdec_action_start_drag } },
   [SWFDEC_AS_ACTION_END_DRAG] = { "EndDrag", NULL, 0, 0, { NULL, swfdec_action_end_drag, swfdec_action_end_drag, swfdec_action_end_drag, swfdec_action_end_drag } },
diff-tree fd7044406415e0cea602c1ed36ef2992d4d12060 (from b08d7989bbd03e163af817e33e2bc9fe9c413f75)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jun 28 15:59:35 2007 +0200

    destroyed movies no longer have properties

diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index d7403c5..d428eb3 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -330,6 +330,8 @@ swfdec_movie_destroy (SwfdecMovie *movie
     klass->finish_movie (movie);
   player->movies = g_list_remove (player->movies, movie);
   movie->state = SWFDEC_MOVIE_STATE_DESTROYED;
+  /* unset prototype here, so we don't work in AS anymore */
+  SWFDEC_AS_OBJECT (movie)->prototype = NULL;
   g_object_unref (movie);
 }
 
@@ -788,6 +790,9 @@ swfdec_movie_class_get_variable (SwfdecA
 {
   SwfdecMovie *movie = SWFDEC_MOVIE (object);
 
+  if (movie->state == SWFDEC_MOVIE_STATE_DESTROYED)
+    return FALSE;
+
   if (swfdec_movie_get_asprop (movie, variable, val)) {
     *flags = 0;
     return TRUE;
@@ -816,7 +821,11 @@ static void
 swfdec_movie_class_set_variable (SwfdecAsObject *object, const char *variable, 
     const SwfdecAsValue *val)
 {
-  if (swfdec_movie_set_asprop (SWFDEC_MOVIE (object), variable, val))
+  SwfdecMovie *movie = SWFDEC_MOVIE (object);
+
+  if (movie->state == SWFDEC_MOVIE_STATE_DESTROYED)
+    return;
+  if (swfdec_movie_set_asprop (movie, variable, val))
     return;
   SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->set (object, variable, val);
 }
diff-tree b08d7989bbd03e163af817e33e2bc9fe9c413f75 (from 2966839c6ed4b0d33c7681654a80df45063f60dd)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jun 28 15:58:31 2007 +0200

    push an undefined return value in the error case

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index 376f41f..09578b8 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -592,6 +592,7 @@ error:
   if (n_args > swfdec_as_stack_get_size (frame->stack))
     n_args = swfdec_as_stack_get_size (frame->stack);
   swfdec_as_stack_pop_n (frame->stack, n_args);
+  SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_push (frame->stack));
   return FALSE;
 }
 
diff-tree 2966839c6ed4b0d33c7681654a80df45063f60dd (from 692c9a4cde349cc8c927e182c36de44a2e9c6a42)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jun 28 15:03:24 2007 +0200

    remove workaround for broken ALSA
    
    ALSA seems to be fixed now

diff --git a/libswfdec-gtk/swfdec_playback_alsa.c b/libswfdec-gtk/swfdec_playback_alsa.c
index f5f1836..ee4da3e 100644
--- a/libswfdec-gtk/swfdec_playback_alsa.c
+++ b/libswfdec-gtk/swfdec_playback_alsa.c
@@ -21,9 +21,6 @@
 #include "config.h"
 #endif
 
-/* HACK: ALSA headers don't compile with C99 otherwise */
-#define __need_timespec 1
-
 #include <alsa/asoundlib.h>
 #include "swfdec_playback.h"
 


More information about the Swfdec mailing list