[Swfdec] 13 commits - libswfdec/Makefile.am
libswfdec/swfdec_js_global.c libswfdec/swfdec_js_movie.c
libswfdec/swfdec_root_movie.c libswfdec/swfdec_root_movie.h
libswfdec/swfdec_script.c libswfdec/swfdec_sprite.h
libswfdec/swfdec_sprite_movie.c
libswfdec/swfdec_swf_decoder.c libswfdec/swfdec_swf_decoder.h
libswfdec/swfdec_tag.c libswfdec/swfdec_types.h test/trace
Benjamin Otte
company at kemper.freedesktop.org
Wed Mar 7 12:23:48 PST 2007
libswfdec/Makefile.am | 2
libswfdec/swfdec_js_global.c | 11 +++-
libswfdec/swfdec_js_movie.c | 52 +++++++++++++++++++
libswfdec/swfdec_root_movie.c | 86 +++++++++++++++------------------
libswfdec/swfdec_root_movie.h | 10 +--
libswfdec/swfdec_script.c | 4 -
libswfdec/swfdec_sprite.h | 2
libswfdec/swfdec_sprite_movie.c | 41 ---------------
libswfdec/swfdec_swf_decoder.c | 18 ------
libswfdec/swfdec_swf_decoder.h | 4 -
libswfdec/swfdec_tag.c | 52 -------------------
libswfdec/swfdec_types.h | 1
test/trace/DoInitAction-once.swf |binary
test/trace/DoInitAction-once.swf.trace | 12 ++++
test/trace/DoInitAction-this.swf |binary
test/trace/DoInitAction-this.swf.trace | 4 +
test/trace/ExportAssets.swf |binary
test/trace/ExportAssets.swf.trace | 9 +++
test/trace/Makefile.am | 2
test/trace/classes.swf |binary
test/trace/classes.swf.trace | 3 +
test/trace/event-order.swf |binary
test/trace/event-order.swf.trace | 26 +++++++++
23 files changed, 171 insertions(+), 168 deletions(-)
New commits:
diff-tree 079beedc71d1fc60cf29451ba622c1d576b6a019 (from 9257bc0640a582b887816bdc7bd96ca3ec8b724f)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Mar 7 21:23:11 2007 +0100
add 2 testcases
classes.swf tests importing a simple class and the associated DoInitAction
ExportAssets.swf tests that assets aren't exported too early
diff --git a/test/trace/ExportAssets.swf b/test/trace/ExportAssets.swf
new file mode 100755
index 0000000..7b1897a
Binary files /dev/null and b/test/trace/ExportAssets.swf differ
diff --git a/test/trace/ExportAssets.swf.trace b/test/trace/ExportAssets.swf.trace
new file mode 100755
index 0000000..2bdcdde
--- /dev/null
+++ b/test/trace/ExportAssets.swf.trace
@@ -0,0 +1,9 @@
+Test ExportAssets only works after passing the frame with the ExportAssets Tag
+Frame 1
+undefined
+init
+Frame 4
+Test ExportAssets only works after passing the frame with the ExportAssets Tag
+Frame 1
+_level0.foo
+Frame 4
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index a0fa2ca..19a1340 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -17,6 +17,8 @@ EXTRA_DIST = \
case1-7.swf.trace \
children.swf \
children.swf.trace \
+ classes.swf \
+ classes.swf.trace \
color-getters.swf \
color-getters.swf.trace \
color-new.swf \
diff --git a/test/trace/classes.swf b/test/trace/classes.swf
new file mode 100755
index 0000000..49fa5be
Binary files /dev/null and b/test/trace/classes.swf differ
diff --git a/test/trace/classes.swf.trace b/test/trace/classes.swf.trace
new file mode 100755
index 0000000..e45cc82
--- /dev/null
+++ b/test/trace/classes.swf.trace
@@ -0,0 +1,3 @@
+test simple classes
+constructed a Simple
+called Simple.trace
diff-tree 9257bc0640a582b887816bdc7bd96ca3ec8b724f (from 31292f06096109f9428e93036b37c4ff4fe40dd2)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Mar 7 21:07:15 2007 +0100
implement attachMovie
diff --git a/libswfdec/swfdec_js_movie.c b/libswfdec/swfdec_js_movie.c
index 2a860a4..3d04d92 100644
--- a/libswfdec/swfdec_js_movie.c
+++ b/libswfdec/swfdec_js_movie.c
@@ -382,6 +382,57 @@ swfdec_js_copy_props (SwfdecMovie *targe
}
static JSBool
+swfdec_js_movie_attachMovie (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+ SwfdecMovie *movie, *ret;
+ const char *name, *export;
+ int depth;
+ SwfdecContent *content;
+ SwfdecGraphic *sprite;
+
+ movie = JS_GetPrivate (cx, obj);
+ g_assert (movie);
+
+ export = swfdec_js_to_string (cx, argv[0]);
+ name = swfdec_js_to_string (cx, argv[1]);
+ if (export == NULL || name == NULL)
+ return JS_FALSE;
+ sprite = swfdec_root_movie_get_export (SWFDEC_ROOT_MOVIE (movie->root), export);
+ if (!SWFDEC_IS_SPRITE (sprite)) {
+ if (sprite == NULL) {
+ SWFDEC_WARNING ("no symbol with name %s exported", export);
+ } else {
+ SWFDEC_WARNING ("can only use attachMovie with sprites");
+ }
+ return JS_TRUE;
+ }
+ if (!JS_ValueToECMAInt32 (cx, argv[1], &depth))
+ return JS_FALSE;
+ if (swfdec_depth_classify (depth) == SWFDEC_DEPTH_CLASS_EMPTY)
+ return JS_TRUE;
+ ret = swfdec_movie_find (movie, depth);
+ if (ret)
+ swfdec_movie_remove (ret);
+ content = swfdec_content_new (depth);
+ content->graphic = sprite;
+ content->depth = depth;
+ content->clip_depth = 0; /* FIXME: check this */
+ content->name = g_strdup (name);
+ content->sequence = content;
+ content->start = 0;
+ content->end = G_MAXUINT;
+ ret = swfdec_movie_new (movie, content);
+ g_object_weak_ref (G_OBJECT (ret), (GWeakNotify) swfdec_content_free, content);
+ /* must be set by now, the movie has a name */
+ if (SWFDEC_SCRIPTABLE (ret)->jsobj == NULL)
+ return JS_FALSE;
+ SWFDEC_LOG ("attached %s (%u) as %s to depth %u", export, SWFDEC_CHARACTER (sprite)->id,
+ ret->name, ret->depth);
+ *rval = OBJECT_TO_JSVAL (SWFDEC_SCRIPTABLE (ret)->jsobj);
+ return JS_TRUE;
+}
+
+static JSBool
swfdec_js_movie_duplicateMovieClip (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
SwfdecMovie *movie, *ret;
@@ -501,6 +552,7 @@ swfdec_js_movie_to_string (JSContext *cx
}
static JSFunctionSpec movieclip_methods[] = {
+ { "attachMovie", swfdec_js_movie_attachMovie, 3, 0, 0 },
{ "duplicateMovieClip", swfdec_js_movie_duplicateMovieClip, 2, 0, 0 },
{ "eval", swfdec_js_global_eval, 1, 0, 0 },
{ "getBytesLoaded", mc_getBytesLoaded, 0, 0, 0 },
diff-tree 31292f06096109f9428e93036b37c4ff4fe40dd2 (from 7e360bf529767e33970858e3a79e8b54569a2cc7)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Mar 7 21:06:36 2007 +0100
implement ExportAssets functionality
diff --git a/libswfdec/swfdec_root_movie.c b/libswfdec/swfdec_root_movie.c
index 6d12de1..e7a97f4 100644
--- a/libswfdec/swfdec_root_movie.c
+++ b/libswfdec/swfdec_root_movie.c
@@ -129,6 +129,7 @@ swfdec_root_movie_dispose (GObject *obje
g_object_unref (root->decoder);
root->decoder = NULL;
}
+ g_hash_table_destroy (root->exports);
G_OBJECT_CLASS (swfdec_root_movie_parent_class)->dispose (object);
}
@@ -168,8 +169,9 @@ swfdec_root_movie_class_init (SwfdecRoot
}
static void
-swfdec_root_movie_init (SwfdecRootMovie *decoder)
+swfdec_root_movie_init (SwfdecRootMovie *root)
{
+ root->exports = g_hash_table_new (g_str_hash, g_str_equal);
}
void
@@ -240,9 +242,22 @@ swfdec_root_movie_perform_root_actions (
swfdec_script_execute (action->data, SWFDEC_SCRIPTABLE (root));
break;
case SWFDEC_ROOT_ACTION_EXPORT:
+ {
+ SwfdecRootExportData *data = action->data;
+ g_hash_table_insert (root->exports, data->name, data->character);
+ }
break;
default:
g_assert_not_reached ();
}
}
}
+
+gpointer
+swfdec_root_movie_get_export (SwfdecRootMovie *root, const char *name)
+{
+ g_return_val_if_fail (SWFDEC_IS_ROOT_MOVIE (root), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ return g_hash_table_lookup (root->exports, name);
+}
diff-tree 7e360bf529767e33970858e3a79e8b54569a2cc7 (from 5300ffc82f575563dd81f7213db86b55facc83b6)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Mar 7 19:39:00 2007 +0100
implement the DoInitAction part of root actions
diff --git a/libswfdec/swfdec_root_movie.c b/libswfdec/swfdec_root_movie.c
index aeaa529..6d12de1 100644
--- a/libswfdec/swfdec_root_movie.c
+++ b/libswfdec/swfdec_root_movie.c
@@ -32,6 +32,8 @@
#include "swfdec_loader_internal.h"
#include "swfdec_loadertarget.h"
#include "swfdec_player_internal.h"
+#include "swfdec_root_sprite.h"
+#include "swfdec_script.h"
#include "swfdec_swf_decoder.h"
#include "js/jsapi.h"
@@ -213,12 +215,34 @@ swfdec_root_movie_load (SwfdecRootMovie
void
swfdec_root_movie_perform_root_actions (SwfdecRootMovie *root, guint frame)
{
+ SwfdecRootSprite *sprite;
+ GArray *array;
+ guint i;
+
g_return_if_fail (SWFDEC_IS_ROOT_MOVIE (root));
g_return_if_fail (frame <= root->root_actions_performed);
if (frame < root->root_actions_performed)
return;
- g_print ("performing root actions for frame %u\n", root->root_actions_performed);
+ sprite = SWFDEC_ROOT_SPRITE (SWFDEC_SPRITE_MOVIE (root)->sprite);
+ SWFDEC_LOG ("performing root actions for frame %u", root->root_actions_performed);
root->root_actions_performed++;
+ if (!sprite->root_actions)
+ return;
+ array = sprite->root_actions[frame];
+ if (array == NULL)
+ return;
+ for (i = 0; i < array->len; i++) {
+ SwfdecSpriteAction *action = &g_array_index (array, SwfdecSpriteAction, i);
+ switch (action->type) {
+ case SWFDEC_ROOT_ACTION_INIT_SCRIPT:
+ swfdec_script_execute (action->data, SWFDEC_SCRIPTABLE (root));
+ break;
+ case SWFDEC_ROOT_ACTION_EXPORT:
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ }
}
diff-tree 5300ffc82f575563dd81f7213db86b55facc83b6 (from b5f4d15eb14eb32cc526ec0817d85bfba5f59ede)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Mar 7 19:30:05 2007 +0100
support _global variable
diff --git a/libswfdec/swfdec_js_global.c b/libswfdec/swfdec_js_global.c
index 06e83e1..0a3b6f3 100644
--- a/libswfdec/swfdec_js_global.c
+++ b/libswfdec/swfdec_js_global.c
@@ -245,8 +245,15 @@ static JSFunctionSpec global_methods[] =
void
swfdec_js_add_globals (SwfdecPlayer *player)
{
- if (!JS_DefineFunctions (player->jscx, player->jsobj, global_methods)) {
- SWFDEC_ERROR ("failed to initialize global methods");
+ JSBool found = JS_FALSE;
+ jsval val = OBJECT_TO_JSVAL (player->jsobj);
+
+ if (!JS_DefineFunctions (player->jscx, player->jsobj, global_methods) ||
+ !JS_SetProperty (player->jscx, player->jsobj, "_global", &val) ||
+ !JS_SetPropertyAttributes (player->jscx, player->jsobj, "_global",
+ JSPROP_READONLY | JSPROP_PERMANENT, &found) ||
+ found != JS_TRUE) {
+ SWFDEC_ERROR ("failed to initialize global object");
}
}
diff-tree b5f4d15eb14eb32cc526ec0817d85bfba5f59ede (from 05d20a38550a904965e3152708991d2b62d89f24)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Mar 7 19:29:41 2007 +0100
omit object name for missing functions instead of always printing "global"
diff --git a/libswfdec/swfdec_script.c b/libswfdec/swfdec_script.c
index 7d93740..927aa67 100644
--- a/libswfdec/swfdec_script.c
+++ b/libswfdec/swfdec_script.c
@@ -653,8 +653,8 @@ swfdec_action_call_function (JSContext *
if (!JS_GetProperty (cx, obj, s, &fun))
return JS_FALSE;
if (!JSVAL_IS_OBJECT (fun)) {
- SWFDEC_WARNING ("%s:%s is not a function",
- JS_GetClass (obj)->name, s);
+ /* FIXME: figure out what class we operate on */
+ SWFDEC_WARNING ("%s is not a function", s);
}
fp->sp[-1] = fun;
fp->sp[-2] = OBJECT_TO_JSVAL (obj);
diff-tree 05d20a38550a904965e3152708991d2b62d89f24 (from c9453f8b81e8e7ccde2e98f1ec922f6634f3bfda)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Mar 7 18:15:44 2007 +0100
use the right variable here
diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
index 91e27f6..74d2160 100644
--- a/libswfdec/swfdec_sprite_movie.c
+++ b/libswfdec/swfdec_sprite_movie.c
@@ -150,10 +150,8 @@ swfdec_sprite_movie_do_goto_frame (gpoin
start, goto_frame, SWFDEC_CHARACTER (movie->sprite)->id);
for (i = start; i <= movie->current_frame; i++) {
SwfdecSpriteFrame *frame = &movie->sprite->frames[i];
- if (SWFDEC_IS_ROOT_MOVIE (movie)) {
- swfdec_root_movie_perform_root_actions (SWFDEC_ROOT_MOVIE (movie),
- movie->current_frame);
- }
+ if (SWFDEC_IS_ROOT_MOVIE (movie))
+ swfdec_root_movie_perform_root_actions (SWFDEC_ROOT_MOVIE (movie), i);
if (frame->actions == NULL)
continue;
for (j = 0; j < frame->actions->len; j++) {
diff-tree c9453f8b81e8e7ccde2e98f1ec922f6634f3bfda (from b168c2c784a6b4e3f5ddb800f8b9d47c32f71fbc)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Mar 7 17:45:33 2007 +0100
remove any mention of character data and SwfdecSpriteInfo
I didn't like that concept anyway and it was only used for init actions.
And init actions are going to use root actions now.
diff --git a/libswfdec/swfdec_root_movie.c b/libswfdec/swfdec_root_movie.c
index d01b8e4..aeaa529 100644
--- a/libswfdec/swfdec_root_movie.c
+++ b/libswfdec/swfdec_root_movie.c
@@ -127,10 +127,6 @@ swfdec_root_movie_dispose (GObject *obje
g_object_unref (root->decoder);
root->decoder = NULL;
}
- if (root->character_data != NULL) {
- g_hash_table_destroy (root->character_data);
- root->character_data = NULL;
- }
G_OBJECT_CLASS (swfdec_root_movie_parent_class)->dispose (object);
}
@@ -214,60 +210,6 @@ swfdec_root_movie_load (SwfdecRootMovie
swfdec_player_launch (root->player, url, target);
}
-typedef struct {
- gpointer data;
- GDestroyNotify free;
-} CharacterData;
-
-static void
-character_data_free (gpointer datap)
-{
- CharacterData *data = datap;
-
- if (data->free)
- data->free (data->data);
-
- g_free (data);
-}
-
-void
-swfdec_root_movie_set_character_data (SwfdecRootMovie *movie,
- SwfdecCharacter *character, gpointer data, GDestroyNotify destroy)
-{
- CharacterData *cdata;
-
- g_return_if_fail (SWFDEC_IS_ROOT_MOVIE (movie));
- g_return_if_fail (SWFDEC_IS_CHARACTER (character));
- g_return_if_fail (data != NULL);
-
- cdata = g_new (CharacterData, 1);
- cdata->data = data;
- cdata->free = destroy;
-
- if (movie->character_data == NULL) {
- movie->character_data = g_hash_table_new_full (g_direct_hash,
- g_direct_equal, NULL, character_data_free);
- }
- g_hash_table_insert (movie->character_data, character, cdata);
-}
-
-gpointer
-swfdec_root_movie_get_character_data (SwfdecRootMovie *movie,
- SwfdecCharacter *character)
-{
- CharacterData *data;
-
- g_return_val_if_fail (SWFDEC_IS_ROOT_MOVIE (movie), NULL);
- g_return_val_if_fail (SWFDEC_IS_CHARACTER (character), NULL);
-
- if (movie->character_data == NULL)
- return NULL;
- data = g_hash_table_lookup (movie->character_data, character);
- if (!data)
- return NULL;
- return data->data;
-}
-
void
swfdec_root_movie_perform_root_actions (SwfdecRootMovie *root, guint frame)
{
diff --git a/libswfdec/swfdec_root_movie.h b/libswfdec/swfdec_root_movie.h
index a7b981a..f1ae02b 100644
--- a/libswfdec/swfdec_root_movie.h
+++ b/libswfdec/swfdec_root_movie.h
@@ -45,7 +45,6 @@ struct _SwfdecRootMovie
guint unnamed_count; /* variable used for naming unnamed movies */
guint root_actions_performed; /* root actions been performed in all frames < this*/
- GHashTable * character_data; /* custom data per character to be set by the movie using them */
};
struct _SwfdecRootMovieClass
@@ -59,13 +58,6 @@ void swfdec_root_movie_load (SwfdecRo
const char * url,
const char * target);
-void swfdec_root_movie_set_character_data (SwfdecRootMovie * movie,
- SwfdecCharacter * character,
- gpointer data,
- GDestroyNotify destroy);
-gpointer swfdec_root_movie_get_character_data (SwfdecRootMovie * movie,
- SwfdecCharacter * character);
-
void swfdec_root_movie_perform_root_actions (SwfdecRootMovie * root,
guint frame);
diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
index a7f728c..91e27f6 100644
--- a/libswfdec/swfdec_sprite_movie.c
+++ b/libswfdec/swfdec_sprite_movie.c
@@ -32,36 +32,6 @@
#include "swfdec_script.h"
#include "swfdec_sprite.h"
-/*** SWFDEC_SPRITE_INFO ***/
-
-typedef struct _SwfdecSpriteInfo SwfdecSpriteInfo;
-struct _SwfdecSpriteInfo {
- gboolean init_action_has_run; /* TRUE if init actions have been run */
-};
-
-static void
-swfdec_sprite_info_free (gpointer infop)
-{
- SwfdecSpriteInfo *info = infop;
-
- g_free (info);
-}
-
-static SwfdecSpriteInfo *
-swfdec_sprite_info_get (SwfdecMovie *movie, SwfdecSprite *sprite)
-{
- SwfdecRootMovie *root = SWFDEC_ROOT_MOVIE (movie->root);
- SwfdecSpriteInfo *info;
-
- info = swfdec_root_movie_get_character_data (root, SWFDEC_CHARACTER (sprite));
- if (info == NULL) {
- info = g_new0 (SwfdecSpriteInfo, 1);
- swfdec_root_movie_set_character_data (root, SWFDEC_CHARACTER (sprite),
- info, swfdec_sprite_info_free);
- }
- return info;
-}
-
/*** SWFDEC_SPRITE_MOVIE ***/
static SwfdecMovie *
@@ -347,15 +317,6 @@ swfdec_sprite_movie_init_movie (SwfdecMo
SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
mov->n_frames = movie->sprite->n_frames;
- if (movie->sprite->init_action) {
- SwfdecSpriteInfo *info = swfdec_sprite_info_get (mov, movie->sprite);
-
- if (!info->init_action_has_run) {
- swfdec_script_execute (movie->sprite->init_action,
- SWFDEC_SCRIPTABLE (mov->root));
- info->init_action_has_run = TRUE;
- }
- }
swfdec_sprite_movie_do_goto_frame (mov, GUINT_TO_POINTER (0));
if (!swfdec_sprite_movie_iterate_end (mov)) {
g_assert_not_reached ();
diff-tree b168c2c784a6b4e3f5ddb800f8b9d47c32f71fbc (from 2a49deac251c3b7d956508e80fa7da73956977c2)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Mar 7 17:37:10 2007 +0100
exports are no longer handled in the SwfDecoder
diff --git a/libswfdec/swfdec_swf_decoder.c b/libswfdec/swfdec_swf_decoder.c
index c1629bc..f205eed 100644
--- a/libswfdec/swfdec_swf_decoder.c
+++ b/libswfdec/swfdec_swf_decoder.c
@@ -54,7 +54,6 @@ swfdec_decoder_dispose (GObject *object)
g_hash_table_destroy (s->characters);
g_object_unref (s->main_sprite);
- g_hash_table_destroy (s->exports);
if (s->uncompressed_buffer) {
inflateEnd (&s->z);
@@ -347,19 +346,6 @@ swfdec_swf_decoder_init (SwfdecSwfDecode
s->characters = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, g_object_unref);
s->input_queue = swfdec_buffer_queue_new ();
- s->exports = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
-}
-
-gpointer
-swfdec_swf_decoder_get_export (SwfdecSwfDecoder * s, const char *name)
-{
- gpointer result;
-
- g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (s), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- result = g_hash_table_lookup (s->exports, name);
- return result;
}
gpointer
diff --git a/libswfdec/swfdec_swf_decoder.h b/libswfdec/swfdec_swf_decoder.h
index 48541eb..6000e24 100644
--- a/libswfdec/swfdec_swf_decoder.h
+++ b/libswfdec/swfdec_swf_decoder.h
@@ -68,8 +68,6 @@ struct _SwfdecSwfDecoder
SwfdecBuffer *jpegtables;
char *url;
-
- GHashTable * exports; /* string->character mapping of exported characters */
};
struct _SwfdecSwfDecoderClass {
@@ -83,8 +81,6 @@ gpointer swfdec_swf_decoder_get_characte
gpointer swfdec_swf_decoder_create_character (SwfdecSwfDecoder * s,
unsigned int id,
GType type);
-gpointer swfdec_swf_decoder_get_export (SwfdecSwfDecoder * s,
- const char * name);
SwfdecTagFunc *swfdec_swf_decoder_get_tag_func (int tag);
const char *swfdec_swf_decoder_get_tag_name (int tag);
diff-tree 2a49deac251c3b7d956508e80fa7da73956977c2 (from c89b368b4dc42d581d8461242c471de9d67c9487)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Mar 7 17:30:32 2007 +0100
add SwfdecRootSprite - a sprite that manages "root actions"
"root actions" are actions that are only executed once when the root movie
instance first arrives at the given frame.
diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am
index cce0bbc..ecd16aa 100644
--- a/libswfdec/Makefile.am
+++ b/libswfdec/Makefile.am
@@ -69,6 +69,7 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES
swfdec_rect.c \
swfdec_ringbuffer.c \
swfdec_root_movie.c \
+ swfdec_root_sprite.c \
swfdec_script.c \
swfdec_scriptable.c \
swfdec_shape.c \
@@ -142,6 +143,7 @@ noinst_HEADERS = \
swfdec_rect.h \
swfdec_ringbuffer.h \
swfdec_root_movie.h \
+ swfdec_root_sprite.h \
swfdec_script.h \
swfdec_scriptable.h \
swfdec_shape.h \
diff --git a/libswfdec/swfdec_root_movie.c b/libswfdec/swfdec_root_movie.c
index c21d32d..d01b8e4 100644
--- a/libswfdec/swfdec_root_movie.c
+++ b/libswfdec/swfdec_root_movie.c
@@ -267,3 +267,16 @@ swfdec_root_movie_get_character_data (Sw
return NULL;
return data->data;
}
+
+void
+swfdec_root_movie_perform_root_actions (SwfdecRootMovie *root, guint frame)
+{
+ g_return_if_fail (SWFDEC_IS_ROOT_MOVIE (root));
+ g_return_if_fail (frame <= root->root_actions_performed);
+
+ if (frame < root->root_actions_performed)
+ return;
+
+ g_print ("performing root actions for frame %u\n", root->root_actions_performed);
+ root->root_actions_performed++;
+}
diff --git a/libswfdec/swfdec_root_movie.h b/libswfdec/swfdec_root_movie.h
index 22fa503..a7b981a 100644
--- a/libswfdec/swfdec_root_movie.h
+++ b/libswfdec/swfdec_root_movie.h
@@ -44,6 +44,7 @@ struct _SwfdecRootMovie
SwfdecDecoder * decoder; /* decoder that decoded all the stuff used by us */
guint unnamed_count; /* variable used for naming unnamed movies */
+ guint root_actions_performed; /* root actions been performed in all frames < this*/
GHashTable * character_data; /* custom data per character to be set by the movie using them */
};
@@ -65,5 +66,8 @@ void swfdec_root_movie_set_character_da
gpointer swfdec_root_movie_get_character_data (SwfdecRootMovie * movie,
SwfdecCharacter * character);
+void swfdec_root_movie_perform_root_actions (SwfdecRootMovie * root,
+ guint frame);
+
G_END_DECLS
#endif
diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
index 22e0458..a7f728c 100644
--- a/libswfdec/swfdec_sprite_movie.c
+++ b/libswfdec/swfdec_sprite_movie.c
@@ -180,6 +180,10 @@ swfdec_sprite_movie_do_goto_frame (gpoin
start, goto_frame, SWFDEC_CHARACTER (movie->sprite)->id);
for (i = start; i <= movie->current_frame; i++) {
SwfdecSpriteFrame *frame = &movie->sprite->frames[i];
+ if (SWFDEC_IS_ROOT_MOVIE (movie)) {
+ swfdec_root_movie_perform_root_actions (SWFDEC_ROOT_MOVIE (movie),
+ movie->current_frame);
+ }
if (frame->actions == NULL)
continue;
for (j = 0; j < frame->actions->len; j++) {
diff --git a/libswfdec/swfdec_swf_decoder.c b/libswfdec/swfdec_swf_decoder.c
index 5ceb57b..c1629bc 100644
--- a/libswfdec/swfdec_swf_decoder.c
+++ b/libswfdec/swfdec_swf_decoder.c
@@ -36,7 +36,7 @@
#include "swfdec_debug.h"
#include "swfdec_js.h"
#include "swfdec_player_internal.h"
-#include "swfdec_sprite.h"
+#include "swfdec_root_sprite.h"
enum {
SWFDEC_STATE_INIT1 = 0,
@@ -342,7 +342,7 @@ swfdec_swf_decoder_class_init (SwfdecSwf
static void
swfdec_swf_decoder_init (SwfdecSwfDecoder *s)
{
- s->main_sprite = g_object_new (SWFDEC_TYPE_SPRITE, NULL);
+ s->main_sprite = g_object_new (SWFDEC_TYPE_ROOT_SPRITE, NULL);
s->characters = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, g_object_unref);
diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c
index c356852..d2649b1 100644
--- a/libswfdec/swfdec_tag.c
+++ b/libswfdec/swfdec_tag.c
@@ -38,6 +38,7 @@
#include "swfdec_morphshape.h"
#include "swfdec_movie.h" /* for SwfdecContent */
#include "swfdec_pattern.h"
+#include "swfdec_root_sprite.h"
#include "swfdec_script.h"
#include "swfdec_shape.h"
#include "swfdec_sound.h"
@@ -281,30 +282,6 @@ tag_func_do_action (SwfdecSwfDecoder * s
return SWFDEC_STATUS_OK;
}
-int
-tag_func_do_init_action (SwfdecSwfDecoder * s)
-{
- SwfdecBits *bits = &s->b;
- guint id;
- SwfdecSprite *sprite;
-
- id = swfdec_bits_get_u16 (bits);
- SWFDEC_LOG (" id = %u", id);
- sprite = swfdec_swf_decoder_get_character (s, id);
- if (!SWFDEC_IS_SPRITE (sprite)) {
- SWFDEC_ERROR ("character %u is not a sprite", id);
- return SWFDEC_STATUS_OK;
- }
- if (sprite->init_action != NULL) {
- SWFDEC_ERROR ("sprite %u already has an init action", id);
- return SWFDEC_STATUS_OK;
- }
- sprite->init_action = swfdec_script_new_for_player (SWFDEC_DECODER (s)->player,
- bits, "InitAction", s->version);
-
- return SWFDEC_STATUS_OK;
-}
-
static void
swfdec_button_append_content (SwfdecButton *button, guint states, SwfdecContent *content)
{
@@ -492,34 +469,6 @@ tag_func_define_button (SwfdecSwfDecoder
}
static int
-tag_func_export_assets (SwfdecSwfDecoder * s)
-{
- SwfdecBits *bits = &s->b;
- unsigned int count, i;
-
- count = swfdec_bits_get_u16 (bits);
- SWFDEC_LOG ("exporting %u assets", count);
- for (i = 0; i < count; i++) {
- guint id;
- SwfdecCharacter *object;
- char *name;
- id = swfdec_bits_get_u16 (bits);
- object = swfdec_swf_decoder_get_character (s, id);
- name = swfdec_bits_get_string (bits);
- if (object == NULL) {
- SWFDEC_ERROR ("cannot export id %u as %s, id wasn't found", id, name);
- g_free (name);
- } else {
- SWFDEC_LOG ("exporting %s %u as %s", G_OBJECT_TYPE_NAME (object), id, name);
- g_object_ref (object);
- g_hash_table_insert (s->exports, name, object);
- }
- }
-
- return SWFDEC_STATUS_OK;
-}
-
-static int
tag_func_define_font_info_1 (SwfdecSwfDecoder *s)
{
return tag_func_define_font_info (s, 1);
diff --git a/libswfdec/swfdec_types.h b/libswfdec/swfdec_types.h
index f601dff..0603754 100644
--- a/libswfdec/swfdec_types.h
+++ b/libswfdec/swfdec_types.h
@@ -49,6 +49,7 @@ typedef struct _SwfdecShape SwfdecShape;
typedef struct _SwfdecShapeVec SwfdecShapeVec;
typedef struct _SwfdecRect SwfdecRect;
typedef struct _SwfdecRootMovie SwfdecRootMovie;
+typedef struct _SwfdecRootSprite SwfdecRootSprite;
typedef struct _SwfdecScript SwfdecScript;
typedef struct _SwfdecScriptable SwfdecScriptable;
typedef struct _SwfdecSound SwfdecSound;
diff-tree c89b368b4dc42d581d8461242c471de9d67c9487 (from 939761e1986fec8be37dd6b41bee8def46bba3a8)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Mar 7 16:57:37 2007 +0100
make SwfdecSpriteAction type be a uint so we can use different enums
diff --git a/libswfdec/swfdec_sprite.h b/libswfdec/swfdec_sprite.h
index f2e7be5..779cd43 100644
--- a/libswfdec/swfdec_sprite.h
+++ b/libswfdec/swfdec_sprite.h
@@ -41,7 +41,7 @@ typedef enum {
} SwfdecSpriteActionType;
struct _SwfdecSpriteAction {
- SwfdecSpriteActionType type;
+ guint type;
gpointer data;
};
diff-tree 939761e1986fec8be37dd6b41bee8def46bba3a8 (from c10f7ebd804d3331f00b0076fe28c41c9b421219)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Mar 7 15:04:38 2007 +0100
add debugging output
diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c
index c81d3b9..c356852 100644
--- a/libswfdec/swfdec_tag.c
+++ b/libswfdec/swfdec_tag.c
@@ -289,6 +289,7 @@ tag_func_do_init_action (SwfdecSwfDecode
SwfdecSprite *sprite;
id = swfdec_bits_get_u16 (bits);
+ SWFDEC_LOG (" id = %u", id);
sprite = swfdec_swf_decoder_get_character (s, id);
if (!SWFDEC_IS_SPRITE (sprite)) {
SWFDEC_ERROR ("character %u is not a sprite", id);
diff-tree c10f7ebd804d3331f00b0076fe28c41c9b421219 (from 12348410a3509928a6e8e4c8ca00292a58ff542c)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Mar 7 15:01:29 2007 +0100
seems I'm too stupid to really add files
diff --git a/test/trace/DoInitAction-once.swf b/test/trace/DoInitAction-once.swf
new file mode 100755
index 0000000..19bcfb7
Binary files /dev/null and b/test/trace/DoInitAction-once.swf differ
diff --git a/test/trace/DoInitAction-once.swf.trace b/test/trace/DoInitAction-once.swf.trace
new file mode 100755
index 0000000..2cb5c39
--- /dev/null
+++ b/test/trace/DoInitAction-once.swf.trace
@@ -0,0 +1,12 @@
+Check that init actions are only executed once
+1
+2
+1
+2
+1
+2
+1
+2
+1
+2
+1
diff --git a/test/trace/DoInitAction-this.swf b/test/trace/DoInitAction-this.swf
new file mode 100755
index 0000000..4b8b17b
Binary files /dev/null and b/test/trace/DoInitAction-this.swf differ
diff --git a/test/trace/DoInitAction-this.swf.trace b/test/trace/DoInitAction-this.swf.trace
new file mode 100755
index 0000000..63fd536
--- /dev/null
+++ b/test/trace/DoInitAction-this.swf.trace
@@ -0,0 +1,4 @@
+Check this in init actions
+_level0
+internal
+_level0
diff --git a/test/trace/event-order.swf b/test/trace/event-order.swf
new file mode 100755
index 0000000..656ac72
Binary files /dev/null and b/test/trace/event-order.swf differ
diff --git a/test/trace/event-order.swf.trace b/test/trace/event-order.swf.trace
new file mode 100755
index 0000000..896b194
--- /dev/null
+++ b/test/trace/event-order.swf.trace
@@ -0,0 +1,26 @@
+Check event order with on$Foo and $foo clipevents
+load
+onLoad
+enterFrame
+onEnterFrame
+unload
+onUnload
+Check event order with on$Foo and $foo clipevents
+load
+onLoad
+enterFrame
+onEnterFrame
+unload
+onUnload
+Check event order with on$Foo and $foo clipevents
+load
+onLoad
+enterFrame
+onEnterFrame
+unload
+onUnload
+Check event order with on$Foo and $foo clipevents
+load
+onLoad
+enterFrame
+onEnterFrame
More information about the Swfdec
mailing list