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

Benjamin Otte company at kemper.freedesktop.org
Fri Jun 15 15:21:50 PDT 2007


 libswfdec/swfdec_as_strings.c         |    1 +
 libswfdec/swfdec_sprite_movie_as.c    |   22 ++++++++++++++++++++++
 test/trace/Makefile.am                |    7 +++++++
 test/trace/level-property-5.swf       |binary
 test/trace/level-property-5.swf.trace |    8 ++++++++
 test/trace/level-property-6.swf       |binary
 test/trace/level-property-6.swf.trace |    8 ++++++++
 test/trace/level-property-7.swf       |binary
 test/trace/level-property-7.swf.trace |    8 ++++++++
 test/trace/level-property.as          |   18 ++++++++++++++++++
 10 files changed, 72 insertions(+)

New commits:
diff-tree 987074e275ac77f8799e5fdf41890e8ef126b291 (from a5f1d561b1a24c77ba879af7d004729f6b0e7224)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jun 15 23:34:56 2007 +0200

    add a test that tests _level0

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 5adb037..9c66cbc 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -271,6 +271,13 @@ EXTRA_DIST = \
 	jump-out-of-with.as \
 	jump-out-of-with.swf \
 	jump-out-of-with.swf.trace \
+	level-property.as \
+	level-property-5.swf \
+	level-property-5.swf.trace \
+	level-property-6.swf \
+	level-property-6.swf.trace \
+	level-property-7.swf \
+	level-property-7.swf.trace \
 	lifetime1.swf \
 	lifetime1.swf.trace \
 	load-4.swf \
diff --git a/test/trace/level-property-5.swf b/test/trace/level-property-5.swf
new file mode 100644
index 0000000..a00b2cb
Binary files /dev/null and b/test/trace/level-property-5.swf differ
diff --git a/test/trace/level-property-5.swf.trace b/test/trace/level-property-5.swf.trace
new file mode 100644
index 0000000..d7155ea
--- /dev/null
+++ b/test/trace/level-property-5.swf.trace
@@ -0,0 +1,8 @@
+_level0
+hi
+_level0
+_level0
+hi
+_level0
+_level0
+undefined
diff --git a/test/trace/level-property-6.swf b/test/trace/level-property-6.swf
new file mode 100644
index 0000000..63aece7
Binary files /dev/null and b/test/trace/level-property-6.swf differ
diff --git a/test/trace/level-property-6.swf.trace b/test/trace/level-property-6.swf.trace
new file mode 100644
index 0000000..aa07ec5
--- /dev/null
+++ b/test/trace/level-property-6.swf.trace
@@ -0,0 +1,8 @@
+_level0
+hi
+_level0
+_level0
+hi
+_level0
+_level0
+_level0._level0
diff --git a/test/trace/level-property-7.swf b/test/trace/level-property-7.swf
new file mode 100644
index 0000000..c6496e4
Binary files /dev/null and b/test/trace/level-property-7.swf differ
diff --git a/test/trace/level-property-7.swf.trace b/test/trace/level-property-7.swf.trace
new file mode 100644
index 0000000..aa07ec5
--- /dev/null
+++ b/test/trace/level-property-7.swf.trace
@@ -0,0 +1,8 @@
+_level0
+hi
+_level0
+_level0
+hi
+_level0
+_level0
+_level0._level0
diff --git a/test/trace/level-property.as b/test/trace/level-property.as
new file mode 100644
index 0000000..d081665
--- /dev/null
+++ b/test/trace/level-property.as
@@ -0,0 +1,18 @@
+// makeswf -v 7 -s 200x150 -r 1 -o level-property.swf level-property.as
+
+trace (_level0);
+_level0 = "hi";
+trace (_level0);
+delete _level0;
+trace (_level0);
+_global._level0 = "hi";
+trace (_level0);
+this._level0 = "hi";
+trace (_level0);
+delete this._level0;
+trace (_level0);
+x = createEmptyMovieClip ("_level0", 0);
+trace (_level0);
+trace (x);
+
+loadMovie ("FSCommand:quit", "");
diff-tree a5f1d561b1a24c77ba879af7d004729f6b0e7224 (from 51bdd4e30a331ac9d4c21748097323187eed89f9)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jun 15 23:33:52 2007 +0200

    implement createEmptyMovieClip ()
    
    No idea how perfect it works, but it's good enough for the tests I'm about to
    commit. And it's only 12 loc. :)

diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index c4428cb..938d43a 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -207,6 +207,7 @@ const char swfdec_as_strings[] = 
   SWFDEC_AS_CONSTANT_STRING ("charCodeAt")
   SWFDEC_AS_CONSTANT_STRING ("NetConnection")
   SWFDEC_AS_CONSTANT_STRING ("connect")
+  SWFDEC_AS_CONSTANT_STRING ("createEmptyMovieClip")
   /* add more here */
 ;
 
diff --git a/libswfdec/swfdec_sprite_movie_as.c b/libswfdec/swfdec_sprite_movie_as.c
index c2e9a42..e173701 100644
--- a/libswfdec/swfdec_sprite_movie_as.c
+++ b/libswfdec/swfdec_sprite_movie_as.c
@@ -274,6 +274,24 @@ swfdec_sprite_movie_swapDepths (SwfdecAs
 }
 
 static void
+swfdec_sprite_movie_createEmptyMovieClip (SwfdecAsContext *cx, SwfdecAsObject *obj,
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+  SwfdecMovie *movie, *parent;
+  int depth;
+  const char *name;
+
+  parent = SWFDEC_MOVIE (obj);
+  name = swfdec_as_value_to_string (cx, &argv[0]);
+  depth = swfdec_as_value_to_number (cx, &argv[1]);
+  movie = swfdec_movie_find (parent, depth);
+  if (movie)
+    swfdec_movie_remove (movie);
+  movie = swfdec_movie_new (SWFDEC_PLAYER (cx), depth, parent, NULL, name);
+  SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (movie));
+}
+
+static void
 swfdec_sprite_movie_copy_props (SwfdecMovie *target, SwfdecMovie *src)
 {
   target->matrix = src->matrix;
@@ -421,6 +439,10 @@ swfdec_sprite_movie_init_context (Swfdec
   /* now add all the functions */
   swfdec_as_object_add_function (proto, SWFDEC_AS_STR_attachMovie, SWFDEC_TYPE_SPRITE_MOVIE,
       swfdec_sprite_movie_attachMovie, 3);
+  if (version >= 6) {
+    swfdec_as_object_add_function (proto, SWFDEC_AS_STR_createEmptyMovieClip, SWFDEC_TYPE_SPRITE_MOVIE,
+	swfdec_sprite_movie_createEmptyMovieClip, 2);
+  }
   swfdec_as_object_add_function (proto, SWFDEC_AS_STR_duplicateMovieClip, SWFDEC_TYPE_SPRITE_MOVIE, 
       swfdec_sprite_movie_duplicateMovieClip, 2);
   swfdec_as_object_add_function (proto, SWFDEC_AS_STR_getBytesLoaded, SWFDEC_TYPE_SPRITE_MOVIE, 


More information about the Swfdec mailing list