[Swfdec] 6 commits - libswfdec/swfdec_as_interpret.c libswfdec/swfdec_movie.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Thu Oct 25 13:20:24 PDT 2007


 libswfdec/swfdec_as_interpret.c                |    2 
 libswfdec/swfdec_movie.c                       |    2 
 test/trace/Makefile.am                         |   18 +++++++
 test/trace/initaction-queue-5.swf              |binary
 test/trace/initaction-queue-5.swf.trace        |    1 
 test/trace/initaction-queue-6.swf              |binary
 test/trace/initaction-queue-6.swf.trace        |    2 
 test/trace/initaction-queue-7.swf              |binary
 test/trace/initaction-queue-7.swf.trace        |    2 
 test/trace/initaction-queue-8.swf              |binary
 test/trace/initaction-queue-8.swf.trace        |    2 
 test/trace/initaction-queue.c                  |   53 ++++++++++++++++++++++
 test/trace/movieclip-set-prototype-5.swf       |binary
 test/trace/movieclip-set-prototype-5.swf.trace |    2 
 test/trace/movieclip-set-prototype-6.swf       |binary
 test/trace/movieclip-set-prototype-6.swf.trace |    4 +
 test/trace/movieclip-set-prototype-7.swf       |binary
 test/trace/movieclip-set-prototype-7.swf.trace |    4 +
 test/trace/movieclip-set-prototype-8.swf       |binary
 test/trace/movieclip-set-prototype-8.swf.trace |    4 +
 test/trace/movieclip-set-prototype.c           |   59 +++++++++++++++++++++++++
 test/trace/trace.c                             |    8 ++-
 22 files changed, 159 insertions(+), 4 deletions(-)

New commits:
commit 58fb1b451a4facc2a998dd6fc18f84a7988a5c6b
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 25 22:17:27 2007 +0200

    add another test proing that init actions are queued

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 1b68d7d..4a86d75 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -757,6 +757,15 @@ EXTRA_DIST = \
 	if-6.swf.trace \
 	if-7.swf \
 	if-7.swf.trace \
+	initaction-queue.c \
+	initaction-queue-5.swf \
+	initaction-queue-5.swf.trace \
+	initaction-queue-6.swf \
+	initaction-queue-6.swf.trace \
+	initaction-queue-7.swf \
+	initaction-queue-7.swf.trace \
+	initaction-queue-8.swf \
+	initaction-queue-8.swf.trace \
 	initobject-stack.as \
 	initobject-stack-5.swf \
 	initobject-stack-5.swf.trace \
diff --git a/test/trace/initaction-queue-5.swf b/test/trace/initaction-queue-5.swf
new file mode 100644
index 0000000..a2d604a
Binary files /dev/null and b/test/trace/initaction-queue-5.swf differ
diff --git a/test/trace/initaction-queue-5.swf.trace b/test/trace/initaction-queue-5.swf.trace
new file mode 100644
index 0000000..417b7b5
--- /dev/null
+++ b/test/trace/initaction-queue-5.swf.trace
@@ -0,0 +1 @@
+undefined
diff --git a/test/trace/initaction-queue-6.swf b/test/trace/initaction-queue-6.swf
new file mode 100644
index 0000000..2ecaf6c
Binary files /dev/null and b/test/trace/initaction-queue-6.swf differ
diff --git a/test/trace/initaction-queue-6.swf.trace b/test/trace/initaction-queue-6.swf.trace
new file mode 100644
index 0000000..ef684a0
--- /dev/null
+++ b/test/trace/initaction-queue-6.swf.trace
@@ -0,0 +1,2 @@
+undefined
+42
diff --git a/test/trace/initaction-queue-7.swf b/test/trace/initaction-queue-7.swf
new file mode 100644
index 0000000..cb2b94a
Binary files /dev/null and b/test/trace/initaction-queue-7.swf differ
diff --git a/test/trace/initaction-queue-7.swf.trace b/test/trace/initaction-queue-7.swf.trace
new file mode 100644
index 0000000..ef684a0
--- /dev/null
+++ b/test/trace/initaction-queue-7.swf.trace
@@ -0,0 +1,2 @@
+undefined
+42
diff --git a/test/trace/initaction-queue-8.swf b/test/trace/initaction-queue-8.swf
new file mode 100644
index 0000000..4e53cd6
Binary files /dev/null and b/test/trace/initaction-queue-8.swf differ
diff --git a/test/trace/initaction-queue-8.swf.trace b/test/trace/initaction-queue-8.swf.trace
new file mode 100644
index 0000000..ef684a0
--- /dev/null
+++ b/test/trace/initaction-queue-8.swf.trace
@@ -0,0 +1,2 @@
+undefined
+42
diff --git a/test/trace/initaction-queue.c b/test/trace/initaction-queue.c
new file mode 100644
index 0000000..2c06d3f
--- /dev/null
+++ b/test/trace/initaction-queue.c
@@ -0,0 +1,53 @@
+/* gcc `pkg-config --libs --cflags libming glib-2.0` initaction-queue.c -o initaction-queue && ./initaction-queue
+ */
+
+#include <ming.h>
+#include <glib.h>
+
+static void
+do_movie (int version)
+{
+  SWFMovie movie;
+  SWFMovieClip clip;
+  SWFDisplayItem item;
+  char *real_name;
+
+  movie = newSWFMovieWithVersion (version);
+  movie = newSWFMovie();
+  SWFMovie_setRate (movie, 1);
+  SWFMovie_setDimension (movie, 200, 150);
+
+  clip = newSWFMovieClip ();
+  item = SWFMovie_add (movie, (SWFBlock) clip);
+  SWFMovieClip_addInitAction (clip, newSWFAction ("_root.x = 42;"));
+  SWFDisplayItem_addAction (item, newSWFAction ("trace (_root.x);"), SWFACTION_INIT);
+  SWFDisplayItem_addAction (item, newSWFAction ("trace (_root.x);"), SWFACTION_CONSTRUCT);
+  SWFDisplayItem_flush (item);
+  SWFMovie_nextFrame (movie);
+  
+  SWFMovie_add (movie, (SWFBlock) newSWFAction (""
+	"loadMovie (\"fscommand:quit\", \"\");"
+	));
+  SWFMovie_nextFrame (movie);
+
+  real_name = g_strdup_printf ("initaction-queue-%d.swf", version);
+  /* remove this after having understood that the generated code was modified to have
+   * the DoInitAction tag placed _after_ the PlaceObject tag */
+  g_assert (FALSE); 
+  SWFMovie_save (movie, real_name);
+  g_free (real_name);
+}
+
+int
+main (int argc, char **argv)
+{
+  int i;
+
+  if (Ming_init ())
+    return 1;
+
+  for (i = 8; i > 4; i--)
+    do_movie (i);
+
+  return 0;
+}
commit 9641151c8cfcf885c5809eb46da74ef8cc66e782
Merge: 2e7c3aa... 8b5bfc1...
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 25 21:52:24 2007 +0200

    Merge branch 'master' of ssh://company@git.freedesktop.org/git/swfdec/swfdec

commit 2e7c3aa2a1db36cb9c9f2a54351a73e451293be5
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 25 21:50:53 2007 +0200

    add an initialize test

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 5bde4df..72edcda 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -911,6 +911,15 @@ EXTRA_DIST = \
 	mouse-show-hide-6.swf.trace \
 	mouse-show-hide-7.swf \
 	mouse-show-hide-7.swf.trace \
+	movieclip-set-prototype.c \
+	movieclip-set-prototype-5.swf \
+	movieclip-set-prototype-5.swf.trace \
+	movieclip-set-prototype-6.swf \
+	movieclip-set-prototype-6.swf.trace \
+	movieclip-set-prototype-7.swf \
+	movieclip-set-prototype-7.swf.trace \
+	movieclip-set-prototype-8.swf \
+	movieclip-set-prototype-8.swf.trace \
 	movieclip-target.as \
 	movieclip-target-5.swf \
 	movieclip-target-5.swf.trace \
diff --git a/test/trace/movieclip-set-prototype-5.swf b/test/trace/movieclip-set-prototype-5.swf
new file mode 100644
index 0000000..23d6102
Binary files /dev/null and b/test/trace/movieclip-set-prototype-5.swf differ
diff --git a/test/trace/movieclip-set-prototype-5.swf.trace b/test/trace/movieclip-set-prototype-5.swf.trace
new file mode 100644
index 0000000..67a686e
--- /dev/null
+++ b/test/trace/movieclip-set-prototype-5.swf.trace
@@ -0,0 +1,2 @@
+running init
+true
diff --git a/test/trace/movieclip-set-prototype-6.swf b/test/trace/movieclip-set-prototype-6.swf
new file mode 100644
index 0000000..0c6653c
Binary files /dev/null and b/test/trace/movieclip-set-prototype-6.swf differ
diff --git a/test/trace/movieclip-set-prototype-6.swf.trace b/test/trace/movieclip-set-prototype-6.swf.trace
new file mode 100644
index 0000000..f687e42
--- /dev/null
+++ b/test/trace/movieclip-set-prototype-6.swf.trace
@@ -0,0 +1,4 @@
+running init
+true
+true
+hi
diff --git a/test/trace/movieclip-set-prototype-7.swf b/test/trace/movieclip-set-prototype-7.swf
new file mode 100644
index 0000000..130cc15
Binary files /dev/null and b/test/trace/movieclip-set-prototype-7.swf differ
diff --git a/test/trace/movieclip-set-prototype-7.swf.trace b/test/trace/movieclip-set-prototype-7.swf.trace
new file mode 100644
index 0000000..f687e42
--- /dev/null
+++ b/test/trace/movieclip-set-prototype-7.swf.trace
@@ -0,0 +1,4 @@
+running init
+true
+true
+hi
diff --git a/test/trace/movieclip-set-prototype-8.swf b/test/trace/movieclip-set-prototype-8.swf
new file mode 100644
index 0000000..d6890c8
Binary files /dev/null and b/test/trace/movieclip-set-prototype-8.swf differ
diff --git a/test/trace/movieclip-set-prototype-8.swf.trace b/test/trace/movieclip-set-prototype-8.swf.trace
new file mode 100644
index 0000000..f687e42
--- /dev/null
+++ b/test/trace/movieclip-set-prototype-8.swf.trace
@@ -0,0 +1,4 @@
+running init
+true
+true
+hi
diff --git a/test/trace/movieclip-set-prototype.c b/test/trace/movieclip-set-prototype.c
new file mode 100644
index 0000000..dc2088a
--- /dev/null
+++ b/test/trace/movieclip-set-prototype.c
@@ -0,0 +1,59 @@
+/* gcc `pkg-config --libs --cflags libming glib-2.0` movieclip-set-prototype.c -o movieclip-set-prototype && ./movieclip-set-prototype
+ */
+
+#include <ming.h>
+#include <glib.h>
+
+static void
+do_movie (int version)
+{
+  SWFMovie movie;
+  SWFMovieClip clip;
+  SWFDisplayItem item;
+  char *real_name;
+
+  movie = newSWFMovieWithVersion (version);
+  movie = newSWFMovie();
+  SWFMovie_setRate (movie, 1);
+  SWFMovie_setDimension (movie, 200, 150);
+
+  clip = newSWFMovieClip ();
+  SWFMovie_addExport (movie, (SWFBlock) clip, "export");
+  SWFMovie_writeExports (movie);
+  SWFMovieClip_addInitAction (clip, newSWFAction (
+	"_root.fun = function () { trace (\"hi\"); };"
+	"Object.registerClass (\"export\", fun);"
+	));
+  item = SWFMovie_add (movie, (SWFBlock) clip);
+  SWFDisplayItem_addAction (item, newSWFAction (
+	/* work around a bug in Flash and another one in Ming */
+	"asm { push \"__proto__\" getvariable pop };"
+	"trace (\"running init\");"
+	"trace (this.__proto__ == MovieClip.prototype);"
+	), SWFACTION_INIT);
+  SWFDisplayItem_addAction (item, newSWFAction ("trace (this.__proto__ == _root.fun.prototype);"), SWFACTION_CONSTRUCT);
+  SWFMovie_nextFrame (movie);
+  
+  SWFMovie_add (movie, (SWFBlock) newSWFAction (""
+	"loadMovie (\"fscommand:quit\", \"\");"
+	));
+  SWFMovie_nextFrame (movie);
+
+  real_name = g_strdup_printf ("movieclip-set-prototype-%d.swf", version);
+  SWFMovie_save (movie, real_name);
+  g_free (real_name);
+}
+
+int
+main (int argc, char **argv)
+{
+  int i;
+
+  if (Ming_init ())
+    return 1;
+
+  for (i = 8; i > 4; i--)
+    do_movie (i);
+
+  return 0;
+}
commit 7a6ec4e6cd00828d6c8a00c8c61425b3ca02f621
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 25 21:47:49 2007 +0200

    Flash 5 has no construct event

diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 1079fbf..a5ed52d 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -369,6 +369,8 @@ swfdec_movie_execute (SwfdecMovie *movie, SwfdecEventType condition)
 
   /* special cases */
   if (condition == SWFDEC_EVENT_CONSTRUCT) {
+    if (SWFDEC_AS_OBJECT (movie)->context->version <= 5)
+      return;
     swfdec_movie_set_constructor (SWFDEC_SPRITE_MOVIE (movie));
   } else if (condition == SWFDEC_EVENT_ENTER) {
     if (movie->will_be_removed)
commit bfa6f26c24fd761780d4de9db9cf5e1b5c417d5e
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 25 21:47:35 2007 +0200

    don't crash when we run on a .trace file

diff --git a/test/trace/trace.c b/test/trace/trace.c
index 92354e6..55276d7 100644
--- a/test/trace/trace.c
+++ b/test/trace/trace.c
@@ -133,13 +133,15 @@ run_test (gpointer testp, gpointer unused)
     /* FIXME: will not do 10 iterations if there's other stuff loaded */
     glong advance = swfdec_player_get_next_event (player);
 
-    g_assert (advance >= 0);
     if (inter) {
       int t = swfdec_interaction_get_next_event (inter);
       g_assert (t >= 0);
-      advance = MIN (advance, t);
+      if (advance < 0)
+	advance = t;
+      else
+	advance = MIN (advance, t);
     }
-    if ((guint) advance > time_left)
+    if (advance < 0 || (guint) advance > time_left)
       break;
     time_left -= advance;
     swfdec_player_advance (player, advance);
commit 358c093e809a5cb474f1aaa35663669940fe5922
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 25 21:11:57 2007 +0200

    fix brackets in commented out code
    
    stupid pmccabe

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index b30bde8..873f341 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -242,7 +242,7 @@ swfdec_action_wait_for_frame2 (SwfdecAsContext *cx, guint action, const guint8 *
   }
   val = cx->fp->sp[-1];
   cx->fp->sp--;
-  if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target))
+  if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
     SwfdecMovie *movie = SWFDEC_MOVIE (cx->frame->target);
     int frame = swfdec_value_to_frame (cx, movie, val);
     guint jump = data[2];


More information about the Swfdec mailing list