[Swfdec] Branch 'as' - 6 commits - libswfdec/swfdec_as_interpret.c libswfdec/swfdec_movie.c libswfdec/swfdec_sprite_movie_as.c test/trace
Benjamin Otte
company at kemper.freedesktop.org
Thu Jul 12 06:36:33 PDT 2007
libswfdec/swfdec_as_interpret.c | 5 +
libswfdec/swfdec_movie.c | 21 +++++---
libswfdec/swfdec_sprite_movie_as.c | 19 ++++---
test/trace/Makefile.am | 18 +++++++
test/trace/clonesprite-events-5.swf |binary
test/trace/clonesprite-events-5.swf.trace | 4 +
test/trace/clonesprite-events-6.swf |binary
test/trace/clonesprite-events-6.swf.trace | 8 +++
test/trace/clonesprite-events-7.swf |binary
test/trace/clonesprite-events-7.swf.trace | 8 +++
test/trace/clonesprite-events-8.swf |binary
test/trace/clonesprite-events-8.swf.trace | 8 +++
test/trace/clonesprite-events.c | 58 +++++++++++++++++++++++
test/trace/duplicateMovieClip-events-5.swf |binary
test/trace/duplicateMovieClip-events-5.swf.trace | 4 +
test/trace/duplicateMovieClip-events-6.swf |binary
test/trace/duplicateMovieClip-events-6.swf.trace | 8 +++
test/trace/duplicateMovieClip-events-7.swf |binary
test/trace/duplicateMovieClip-events-7.swf.trace | 8 +++
test/trace/duplicateMovieClip-events-8.swf |binary
test/trace/duplicateMovieClip-events-8.swf.trace | 8 +++
test/trace/duplicateMovieClip-events.c | 53 +++++++++++++++++++++
22 files changed, 217 insertions(+), 13 deletions(-)
New commits:
diff-tree a2cf4afefe143cf37e570b7570cf11b3c8975467 (from fab49ea40c543dbda12db379c5b439f0b4487f24)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 12 15:28:36 2007 +0200
add tests for CloneSprite event handling
It's the same as duplicateMovieClip(), maybe that bytecode really is just
calling that function internally
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 493004f..fc32e6a 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -116,6 +116,15 @@ EXTRA_DIST = \
chr-7.swf.trace \
classes.swf \
classes.swf.trace \
+ clonesprite-events.c \
+ clonesprite-events-5.swf \
+ clonesprite-events-5.swf.trace \
+ clonesprite-events-6.swf \
+ clonesprite-events-6.swf.trace \
+ clonesprite-events-7.swf \
+ clonesprite-events-7.swf.trace \
+ clonesprite-events-8.swf \
+ clonesprite-events-8.swf.trace \
color-getters.swf \
color-getters.swf.trace \
color-new.swf \
diff --git a/test/trace/clonesprite-events-5.swf b/test/trace/clonesprite-events-5.swf
new file mode 100644
index 0000000..09034ee
Binary files /dev/null and b/test/trace/clonesprite-events-5.swf differ
diff --git a/test/trace/clonesprite-events-5.swf.trace b/test/trace/clonesprite-events-5.swf.trace
new file mode 100644
index 0000000..ac9f23e
--- /dev/null
+++ b/test/trace/clonesprite-events-5.swf.trace
@@ -0,0 +1,4 @@
+_level0.movie: init
+duplicating...
+...done
+_level0.foo: init
diff --git a/test/trace/clonesprite-events-6.swf b/test/trace/clonesprite-events-6.swf
new file mode 100644
index 0000000..9ab7119
Binary files /dev/null and b/test/trace/clonesprite-events-6.swf differ
diff --git a/test/trace/clonesprite-events-6.swf.trace b/test/trace/clonesprite-events-6.swf.trace
new file mode 100644
index 0000000..50d9531
--- /dev/null
+++ b/test/trace/clonesprite-events-6.swf.trace
@@ -0,0 +1,8 @@
+_level0.movie: init
+_level0.movie: construct
+duplicating...
+_level0.foo: construct
+...done
+_level0.foo: init
+_level0.movie: load
+_level0.foo: load
diff --git a/test/trace/clonesprite-events-7.swf b/test/trace/clonesprite-events-7.swf
new file mode 100644
index 0000000..c54ef7e
Binary files /dev/null and b/test/trace/clonesprite-events-7.swf differ
diff --git a/test/trace/clonesprite-events-7.swf.trace b/test/trace/clonesprite-events-7.swf.trace
new file mode 100644
index 0000000..50d9531
--- /dev/null
+++ b/test/trace/clonesprite-events-7.swf.trace
@@ -0,0 +1,8 @@
+_level0.movie: init
+_level0.movie: construct
+duplicating...
+_level0.foo: construct
+...done
+_level0.foo: init
+_level0.movie: load
+_level0.foo: load
diff --git a/test/trace/clonesprite-events-8.swf b/test/trace/clonesprite-events-8.swf
new file mode 100644
index 0000000..225b74e
Binary files /dev/null and b/test/trace/clonesprite-events-8.swf differ
diff --git a/test/trace/clonesprite-events-8.swf.trace b/test/trace/clonesprite-events-8.swf.trace
new file mode 100644
index 0000000..50d9531
--- /dev/null
+++ b/test/trace/clonesprite-events-8.swf.trace
@@ -0,0 +1,8 @@
+_level0.movie: init
+_level0.movie: construct
+duplicating...
+_level0.foo: construct
+...done
+_level0.foo: init
+_level0.movie: load
+_level0.foo: load
diff --git a/test/trace/clonesprite-events.c b/test/trace/clonesprite-events.c
new file mode 100644
index 0000000..42c09e5
--- /dev/null
+++ b/test/trace/clonesprite-events.c
@@ -0,0 +1,58 @@
+/* gcc `pkg-config --libs --cflags libming` clonesprite-events.c -o clonesprite-events && ./clonesprite-events
+ */
+
+#include <ming.h>
+
+static void
+do_movie (int version)
+{
+ SWFMovie movie;
+ SWFMovieClip clip;
+ SWFDisplayItem item;
+ char name[100];
+
+ movie = newSWFMovieWithVersion (version);
+ movie = newSWFMovie();
+ SWFMovie_setRate (movie, 1);
+ SWFMovie_setDimension (movie, 200, 150);
+
+ clip = newSWFMovieClip ();
+ item = SWFMovie_add (movie, (SWFBlock) clip);
+ SWFDisplayItem_setName (item, "movie");
+ SWFDisplayItem_addAction (item, newSWFAction ("trace (this + \": init\");"), SWFACTION_INIT);
+ SWFDisplayItem_addAction (item, newSWFAction ("trace (this + \": construct\");"), SWFACTION_CONSTRUCT);
+ SWFDisplayItem_addAction (item, newSWFAction ("trace (this + \": load\");"), SWFACTION_ONLOAD);
+ SWFDisplayItem_addAction (item, newSWFAction ("trace (this + \": unload\");"), SWFACTION_UNLOAD);
+ SWFMovie_add (movie, (SWFBlock) newSWFAction (""
+ "trace (\"duplicating...\");"
+ "asm {"
+ " push \"movie\""
+ " getvariable"
+ " push \"foo\", 10"
+ " duplicatemovieclip"
+ "};"
+ "trace (\"...done\");"
+ ""));
+ SWFMovie_nextFrame (movie);
+ SWFMovie_add (movie, (SWFBlock) newSWFAction (""
+ "loadMovie (\"FSCommand:quit\", \"\");"
+ ""));
+ SWFMovie_nextFrame (movie);
+
+ sprintf (name, "clonesprite-events-%d.swf", version);
+ SWFMovie_save (movie, name);
+}
+
+int
+main (int argc, char **argv)
+{
+ int i;
+
+ if (Ming_init ())
+ return 1;
+
+ for (i = 5; i < 9; i++)
+ do_movie (i);
+
+ return 0;
+}
diff-tree fab49ea40c543dbda12db379c5b439f0b4487f24 (from 5a0de2944bba30fd70804ba25412e589ef62e666)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 12 15:26:06 2007 +0200
queue the same events for CloneSprite
diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index ae14f4f..938165e 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -2113,6 +2113,11 @@ swfdec_action_clone_sprite (SwfdecAsCont
new_movie = swfdec_movie_duplicate (movie, new_name, depth);
if (new_movie) {
SWFDEC_LOG ("duplicated %s as %s to depth %u", movie->name, new_movie->name, new_movie->depth);
+ if (SWFDEC_IS_SPRITE_MOVIE (new_movie)) {
+ g_queue_push_tail (SWFDEC_PLAYER (cx)->init_queue, new_movie);
+ swfdec_movie_queue_script (new_movie, SWFDEC_EVENT_LOAD);
+ swfdec_movie_run_construct (new_movie);
+ }
swfdec_movie_initialize (new_movie);
}
swfdec_as_stack_pop_n (cx, 3);
diff-tree 5a0de2944bba30fd70804ba25412e589ef62e666 (from b7672f1e4e0ee0a598397080589d6a2a156bf2cf)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 12 15:16:34 2007 +0200
return the path of the movie as debug string
diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index ce3abc2..7ae2a67 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -837,6 +837,14 @@ swfdec_movie_set_variable (SwfdecAsObjec
SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->set (object, variable, val);
}
+static char *
+swfdec_movie_get_debug (SwfdecAsObject *object)
+{
+ SwfdecMovie *movie = SWFDEC_MOVIE (object);
+
+ return swfdec_movie_get_path (movie);
+}
+
static gboolean
swfdec_movie_iterate_end (SwfdecMovie *movie)
{
@@ -855,6 +863,7 @@ swfdec_movie_class_init (SwfdecMovieClas
asobject_class->mark = swfdec_movie_mark;
asobject_class->get = swfdec_movie_get_variable;
asobject_class->set = swfdec_movie_set_variable;
+ asobject_class->debug = swfdec_movie_get_debug;
movie_class->iterate_end = swfdec_movie_iterate_end;
}
diff-tree b7672f1e4e0ee0a598397080589d6a2a156bf2cf (from f1abcd7d6b8131f774fd41152091a759d64a2d10)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 12 15:16:05 2007 +0200
queue the right events for duplicateMovieClip
diff --git a/libswfdec/swfdec_sprite_movie_as.c b/libswfdec/swfdec_sprite_movie_as.c
index 58e40f0..e5b9954 100644
--- a/libswfdec/swfdec_sprite_movie_as.c
+++ b/libswfdec/swfdec_sprite_movie_as.c
@@ -348,7 +348,7 @@ swfdec_sprite_movie_duplicateMovieClip (
guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
- SwfdecMovie *ret;
+ SwfdecMovie *new;
const char *name;
int depth;
@@ -356,13 +356,18 @@ swfdec_sprite_movie_duplicateMovieClip (
depth = swfdec_as_value_to_integer (cx, &argv[1]);
if (swfdec_depth_classify (depth) == SWFDEC_DEPTH_CLASS_EMPTY)
return;
- ret = swfdec_movie_duplicate (movie, name, depth);
- if (ret == NULL)
+ new = swfdec_movie_duplicate (movie, name, depth);
+ if (new == NULL)
return;
- swfdec_sprite_movie_copy_props (ret, movie);
- swfdec_movie_initialize (ret);
- SWFDEC_LOG ("duplicated %s as %s to depth %u", movie->name, ret->name, ret->depth);
- SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (ret));
+ swfdec_sprite_movie_copy_props (new, movie);
+ if (SWFDEC_IS_SPRITE_MOVIE (new)) {
+ g_queue_push_tail (SWFDEC_PLAYER (cx)->init_queue, new);
+ swfdec_movie_queue_script (new, SWFDEC_EVENT_LOAD);
+ swfdec_movie_run_construct (new);
+ }
+ swfdec_movie_initialize (new);
+ SWFDEC_LOG ("duplicated %s as %s to depth %u", movie->name, new->name, new->depth);
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (new));
}
static void
diff-tree f1abcd7d6b8131f774fd41152091a759d64a2d10 (from 40c7abd66881409f3ee95b84704f4ff6f187e478)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 12 15:15:40 2007 +0200
add a test that checks duplicateMovieClip events are dispatched properly
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index f15f8e7..493004f 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -195,6 +195,15 @@ EXTRA_DIST = \
double-to-string-7.swf \
double-to-string-7.swf.trace \
double-to-string-7.swf.trace.org \
+ duplicateMovieClip-events.c \
+ duplicateMovieClip-events-5.swf \
+ duplicateMovieClip-events-5.swf.trace \
+ duplicateMovieClip-events-6.swf \
+ duplicateMovieClip-events-6.swf.trace \
+ duplicateMovieClip-events-7.swf \
+ duplicateMovieClip-events-7.swf.trace \
+ duplicateMovieClip-events-8.swf \
+ duplicateMovieClip-events-8.swf.trace \
duplicate-names.as \
duplicate-names-5.swf \
duplicate-names-5.swf.trace \
diff --git a/test/trace/duplicateMovieClip-events-5.swf b/test/trace/duplicateMovieClip-events-5.swf
new file mode 100644
index 0000000..95d87b0
Binary files /dev/null and b/test/trace/duplicateMovieClip-events-5.swf differ
diff --git a/test/trace/duplicateMovieClip-events-5.swf.trace b/test/trace/duplicateMovieClip-events-5.swf.trace
new file mode 100644
index 0000000..ac9f23e
--- /dev/null
+++ b/test/trace/duplicateMovieClip-events-5.swf.trace
@@ -0,0 +1,4 @@
+_level0.movie: init
+duplicating...
+...done
+_level0.foo: init
diff --git a/test/trace/duplicateMovieClip-events-6.swf b/test/trace/duplicateMovieClip-events-6.swf
new file mode 100644
index 0000000..ffbc8e1
Binary files /dev/null and b/test/trace/duplicateMovieClip-events-6.swf differ
diff --git a/test/trace/duplicateMovieClip-events-6.swf.trace b/test/trace/duplicateMovieClip-events-6.swf.trace
new file mode 100644
index 0000000..50d9531
--- /dev/null
+++ b/test/trace/duplicateMovieClip-events-6.swf.trace
@@ -0,0 +1,8 @@
+_level0.movie: init
+_level0.movie: construct
+duplicating...
+_level0.foo: construct
+...done
+_level0.foo: init
+_level0.movie: load
+_level0.foo: load
diff --git a/test/trace/duplicateMovieClip-events-7.swf b/test/trace/duplicateMovieClip-events-7.swf
new file mode 100644
index 0000000..d0d2c01
Binary files /dev/null and b/test/trace/duplicateMovieClip-events-7.swf differ
diff --git a/test/trace/duplicateMovieClip-events-7.swf.trace b/test/trace/duplicateMovieClip-events-7.swf.trace
new file mode 100644
index 0000000..50d9531
--- /dev/null
+++ b/test/trace/duplicateMovieClip-events-7.swf.trace
@@ -0,0 +1,8 @@
+_level0.movie: init
+_level0.movie: construct
+duplicating...
+_level0.foo: construct
+...done
+_level0.foo: init
+_level0.movie: load
+_level0.foo: load
diff --git a/test/trace/duplicateMovieClip-events-8.swf b/test/trace/duplicateMovieClip-events-8.swf
new file mode 100644
index 0000000..c375ce3
Binary files /dev/null and b/test/trace/duplicateMovieClip-events-8.swf differ
diff --git a/test/trace/duplicateMovieClip-events-8.swf.trace b/test/trace/duplicateMovieClip-events-8.swf.trace
new file mode 100644
index 0000000..50d9531
--- /dev/null
+++ b/test/trace/duplicateMovieClip-events-8.swf.trace
@@ -0,0 +1,8 @@
+_level0.movie: init
+_level0.movie: construct
+duplicating...
+_level0.foo: construct
+...done
+_level0.foo: init
+_level0.movie: load
+_level0.foo: load
diff --git a/test/trace/duplicateMovieClip-events.c b/test/trace/duplicateMovieClip-events.c
new file mode 100644
index 0000000..5e1f904
--- /dev/null
+++ b/test/trace/duplicateMovieClip-events.c
@@ -0,0 +1,53 @@
+/* gcc `pkg-config --libs --cflags libming` duplicateMovieClip-events.c -o duplicateMovieClip-events && ./duplicateMovieClip-events
+ */
+
+#include <ming.h>
+
+static void
+do_movie (int version)
+{
+ SWFMovie movie;
+ SWFMovieClip clip;
+ SWFDisplayItem item;
+ char name[100];
+
+ movie = newSWFMovieWithVersion (version);
+ movie = newSWFMovie();
+ SWFMovie_setRate (movie, 1);
+ SWFMovie_setDimension (movie, 200, 150);
+
+ clip = newSWFMovieClip ();
+ item = SWFMovie_add (movie, (SWFBlock) clip);
+ SWFDisplayItem_setName (item, "movie");
+ SWFDisplayItem_addAction (item, newSWFAction ("trace (this + \": init\");"), SWFACTION_INIT);
+ SWFDisplayItem_addAction (item, newSWFAction ("trace (this + \": construct\");"), SWFACTION_CONSTRUCT);
+ SWFDisplayItem_addAction (item, newSWFAction ("trace (this + \": load\");"), SWFACTION_ONLOAD);
+ SWFDisplayItem_addAction (item, newSWFAction ("trace (this + \": unload\");"), SWFACTION_UNLOAD);
+ SWFMovie_add (movie, (SWFBlock) newSWFAction (""
+ "trace (\"duplicating...\");"
+ "movie.duplicateMovieClip (\"foo\", 0);"
+ "trace (\"...done\");"
+ ""));
+ SWFMovie_nextFrame (movie);
+ SWFMovie_add (movie, (SWFBlock) newSWFAction (""
+ "loadMovie (\"FSCommand:quit\", \"\");"
+ ""));
+ SWFMovie_nextFrame (movie);
+
+ sprintf (name, "duplicateMovieClip-events-%d.swf", version);
+ SWFMovie_save (movie, name);
+}
+
+int
+main (int argc, char **argv)
+{
+ int i;
+
+ if (Ming_init ())
+ return 1;
+
+ for (i = 5; i < 9; i++)
+ do_movie (i);
+
+ return 0;
+}
diff-tree 40c7abd66881409f3ee95b84704f4ff6f187e478 (from d5f8ba68c26452741aba41ffc48e697e0aafe4b4)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 12 11:30:29 2007 +0200
fix function names
diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 3c2462f..ce3abc2 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -749,7 +749,7 @@ swfdec_movie_dispose (GObject *object)
}
static void
-swfdec_movie_class_mark (SwfdecAsObject *object)
+swfdec_movie_mark (SwfdecAsObject *object)
{
SwfdecMovie *movie = SWFDEC_MOVIE (object);
GList *walk;
@@ -792,7 +792,7 @@ swfdec_movie_get_by_name (SwfdecPlayer *
}
static gboolean
-swfdec_movie_class_get_variable (SwfdecAsObject *object, const char *variable,
+swfdec_movie_get_variable (SwfdecAsObject *object, const char *variable,
SwfdecAsValue *val, guint *flags)
{
SwfdecMovie *movie = SWFDEC_MOVIE (object);
@@ -825,7 +825,7 @@ swfdec_movie_class_get_variable (SwfdecA
}
static void
-swfdec_movie_class_set_variable (SwfdecAsObject *object, const char *variable,
+swfdec_movie_set_variable (SwfdecAsObject *object, const char *variable,
const SwfdecAsValue *val)
{
SwfdecMovie *movie = SWFDEC_MOVIE (object);
@@ -852,9 +852,9 @@ swfdec_movie_class_init (SwfdecMovieClas
object_class->dispose = swfdec_movie_dispose;
- asobject_class->mark = swfdec_movie_class_mark;
- asobject_class->get = swfdec_movie_class_get_variable;
- asobject_class->set = swfdec_movie_class_set_variable;
+ asobject_class->mark = swfdec_movie_mark;
+ asobject_class->get = swfdec_movie_get_variable;
+ asobject_class->set = swfdec_movie_set_variable;
movie_class->iterate_end = swfdec_movie_iterate_end;
}
More information about the Swfdec
mailing list