[Swfdec-commits] 4 commits - swfdec/Makefile.am swfdec/swfdec_actor.c swfdec/swfdec_as_context.c swfdec/swfdec_as_context.h swfdec/swfdec_as_internal.h swfdec/swfdec_as_interpret.c swfdec/swfdec_as_movie_value.c swfdec/swfdec_as_movie_value.h swfdec/swfdec_as_object.c swfdec/swfdec_movie_asprops.c swfdec/swfdec_movie.c swfdec/swfdec_movie.h swfdec/swfdec_player.c swfdec/swfdec_resource.c swfdec/swfdec_resource.h swfdec/swfdec_sprite_movie_as.c swfdec/swfdec_sprite_movie.c vivified/ui
Benjamin Otte
company at kemper.freedesktop.org
Mon Nov 3 04:26:19 PST 2008
swfdec/Makefile.am | 2
swfdec/swfdec_actor.c | 2
swfdec/swfdec_as_context.c | 16 ++++
swfdec/swfdec_as_context.h | 1
swfdec/swfdec_as_internal.h | 18 +++--
swfdec/swfdec_as_interpret.c | 15 ++--
swfdec/swfdec_as_movie_value.c | 106 ++++++++++++++++++++++++++++++++
swfdec/swfdec_as_movie_value.h | 50 +++++++++++++++
swfdec/swfdec_as_object.c | 4 -
swfdec/swfdec_movie.c | 129 +++++++++++++++++++---------------------
swfdec/swfdec_movie.h | 8 +-
swfdec/swfdec_movie_asprops.c | 6 -
swfdec/swfdec_player.c | 12 +--
swfdec/swfdec_resource.c | 120 ++++++++++++++++++++-----------------
swfdec/swfdec_resource.h | 2
swfdec/swfdec_sprite_movie.c | 6 -
swfdec/swfdec_sprite_movie_as.c | 6 -
vivified/ui/vivi_movie_list.c | 5 -
18 files changed, 344 insertions(+), 164 deletions(-)
New commits:
commit 3aaf27d69c786e99dba54f9cd6a14fad0ac20cf8
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Nov 3 13:20:51 2008 +0100
give movies their own Gcable
diff --git a/swfdec/Makefile.am b/swfdec/Makefile.am
index a73cea0..47bfcfc 100644
--- a/swfdec/Makefile.am
+++ b/swfdec/Makefile.am
@@ -24,6 +24,7 @@ libswfdec_source_files = \
swfdec_as_gcable.c \
swfdec_as_interpret.c \
swfdec_as_math.c \
+ swfdec_as_movie_value.c \
swfdec_as_native_function.c \
swfdec_as_number.c \
swfdec_as_object.c \
@@ -245,6 +246,7 @@ noinst_HEADERS = \
swfdec_as_date.h \
swfdec_as_gcable.h \
swfdec_as_interpret.h \
+ swfdec_as_movie_value.h \
swfdec_as_number.h \
swfdec_as_script_function.h \
swfdec_as_stack.h \
diff --git a/swfdec/swfdec_actor.c b/swfdec/swfdec_actor.c
index a35b7bf..27c1628 100644
--- a/swfdec/swfdec_actor.c
+++ b/swfdec/swfdec_actor.c
@@ -304,7 +304,7 @@ swfdec_actor_queue_script_with_key (SwfdecActor *actor,
return;
/* can happen for mouse/keyboard events on the initial movie */
if (SWFDEC_MOVIE (actor)->resource->sandbox == NULL) {
- SWFDEC_INFO ("movie %s not yet initialized, skipping event", SWFDEC_MOVIE (actor)->name);
+ SWFDEC_INFO ("movie %s not yet initialized, skipping event", SWFDEC_MOVIE (actor)->nameasdf);
return;
}
diff --git a/swfdec/swfdec_as_context.c b/swfdec/swfdec_as_context.c
index 31b3678..6a12693 100644
--- a/swfdec/swfdec_as_context.c
+++ b/swfdec/swfdec_as_context.c
@@ -32,6 +32,7 @@
#include "swfdec_as_initialize.h"
#include "swfdec_as_internal.h"
#include "swfdec_as_interpret.h"
+#include "swfdec_as_movie_value.h"
#include "swfdec_as_native_function.h"
#include "swfdec_as_object.h"
#include "swfdec_as_stack.h"
@@ -287,6 +288,12 @@ swfdec_as_context_collect_double (SwfdecAsContext *context, gpointer gc)
}
static void
+swfdec_as_context_collect_movie (SwfdecAsContext *context, gpointer gc)
+{
+ swfdec_as_movie_value_free ((SwfdecAsMovieValue *) gc);
+}
+
+static void
swfdec_as_context_collect (SwfdecAsContext *context)
{
/* NB: This functions is called without GC from swfdec_as_context_dispose */
@@ -299,6 +306,8 @@ swfdec_as_context_collect (SwfdecAsContext *context)
swfdec_as_context_collect_string);
context->numbers = swfdec_as_gcable_collect (context, context->numbers,
swfdec_as_context_collect_double);
+ context->movies = swfdec_as_gcable_collect (context, context->movies,
+ swfdec_as_context_collect_movie);
SWFDEC_INFO (">> done collecting garbage");
}
@@ -335,11 +344,14 @@ swfdec_as_value_mark (SwfdecAsValue *value)
{
g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
- if (SWFDEC_AS_VALUE_IS_COMPOSITE (value)) {
+ if (SWFDEC_AS_VALUE_IS_OBJECT (value)) {
swfdec_gc_object_mark (value->value.object);
+ } else if (SWFDEC_AS_VALUE_IS_MOVIE (value)) {
+ if (!SWFDEC_AS_GCABLE_FLAG_IS_SET (value->value.gcable, SWFDEC_AS_GC_MARK))
+ swfdec_as_movie_value_mark ((SwfdecAsMovieValue *) value->value.gcable);
} else if (SWFDEC_AS_VALUE_IS_STRING (value) ||
SWFDEC_AS_VALUE_IS_NUMBER (value)) {
- if (!SWFDEC_AS_GCABLE_FLAG_IS_SET (value->value.gcable, SWFDEC_AS_GC_ROOT))
+ if (!SWFDEC_AS_GCABLE_FLAG_IS_SET (value->value.gcable, SWFDEC_AS_GC_ROOT | SWFDEC_AS_GC_MARK))
SWFDEC_AS_GCABLE_SET_FLAG (value->value.gcable, SWFDEC_AS_GC_MARK);
}
}
diff --git a/swfdec/swfdec_as_context.h b/swfdec/swfdec_as_context.h
index 2726625..38f6981 100644
--- a/swfdec/swfdec_as_context.h
+++ b/swfdec/swfdec_as_context.h
@@ -60,6 +60,7 @@ struct _SwfdecAsContext {
GHashTable * objects; /* all objects the context manages */
gpointer strings; /* all numbers the context manages */
gpointer numbers; /* all numbers the context manages */
+ gpointer movies; /* all movies the context manages */
GHashTable * constant_pools; /* memory address => SwfdecConstantPool for all gc'ed pools */
/* execution state */
diff --git a/swfdec/swfdec_as_internal.h b/swfdec/swfdec_as_internal.h
index 3601d6d..6cf0d7a 100644
--- a/swfdec/swfdec_as_internal.h
+++ b/swfdec/swfdec_as_internal.h
@@ -21,6 +21,7 @@
#define _SWFDEC_AS_INTERNAL_H_
#include <swfdec/swfdec_as_gcable.h>
+#include <swfdec/swfdec_as_movie_value.h>
#include <swfdec/swfdec_as_object.h>
#include <swfdec/swfdec_as_types.h>
#include <swfdec/swfdec_movie.h>
@@ -50,13 +51,15 @@ G_BEGIN_DECLS
} G_STMT_END
#define SWFDEC_AS_VALUE_IS_MOVIE(val) (SWFDEC_AS_VALUE_GET_TYPE (val) == SWFDEC_AS_TYPE_MOVIE)
-#define SWFDEC_AS_VALUE_GET_MOVIE(val) (swfdec_movie_resolve (SWFDEC_MOVIE ((val)->value.object)))
+#define SWFDEC_AS_VALUE_GET_MOVIE(val) (((SwfdecAsMovieValue *) (val)->value.gcable)->movie ? \
+ ((SwfdecAsMovieValue *) (val)->value.gcable)->movie : swfdec_as_movie_value_get ((SwfdecAsMovieValue *) (val)->value.gcable))
#define SWFDEC_AS_VALUE_SET_MOVIE(val,m) G_STMT_START { \
SwfdecAsValue *__val = (val); \
SwfdecMovie *__m = (m); \
g_assert (SWFDEC_IS_MOVIE (__m)); \
+ g_assert (__m->as_value); \
(__val)->type = SWFDEC_AS_TYPE_MOVIE; \
- (__val)->value.object = (SwfdecAsObject *) __m; \
+ (__val)->value.gcable = (SwfdecAsGcable *) __m->as_value; \
} G_STMT_END
/* swfdec_as_context.c */
diff --git a/swfdec/swfdec_as_interpret.c b/swfdec/swfdec_as_interpret.c
index 6ae6384..41bf69b 100644
--- a/swfdec/swfdec_as_interpret.c
+++ b/swfdec/swfdec_as_interpret.c
@@ -2770,7 +2770,7 @@ swfdec_action_remove_sprite (SwfdecAsContext *cx, guint action, const guint8 *da
SwfdecMovie *movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx),
swfdec_as_stack_peek (cx, 1));
if (movie && swfdec_depth_classify (movie->depth) == SWFDEC_DEPTH_CLASS_DYNAMIC) {
- SWFDEC_LOG ("removing clip %s", movie->name);
+ SWFDEC_LOG ("removing clip %s", movie->nameasdf);
swfdec_movie_remove (movie);
} else {
SWFDEC_INFO ("cannot remove movie");
@@ -2803,7 +2803,7 @@ swfdec_action_clone_sprite (SwfdecAsContext *cx, guint action, const guint8 *dat
}
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);
+ SWFDEC_LOG ("duplicated %s as %s to depth %u", movie->nameasdf, new_movie->nameasdf, new_movie->depth);
}
}
swfdec_as_stack_pop_n (cx, 3);
diff --git a/swfdec/swfdec_as_movie_value.c b/swfdec/swfdec_as_movie_value.c
new file mode 100644
index 0000000..776b395
--- /dev/null
+++ b/swfdec/swfdec_as_movie_value.c
@@ -0,0 +1,106 @@
+/* Swfdec
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_movie_value.h"
+
+#include <string.h>
+
+#include "swfdec_as_gcable.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_movie.h"
+#include "swfdec_player_internal.h"
+
+SwfdecAsMovieValue *
+swfdec_as_movie_value_new (SwfdecMovie *movie, const char *name)
+{
+ SwfdecAsMovieValue *val, *parent;
+ SwfdecAsContext *context;
+ guint n_names;
+
+ g_assert (SWFDEC_IS_MOVIE (movie));
+ g_assert (name != NULL);
+ g_assert (name != SWFDEC_AS_STR_EMPTY);
+
+ context = swfdec_gc_object_get_context (movie);
+ parent = movie->parent ? movie->parent->as_value : NULL;
+ n_names = parent ? parent->n_names + 1 : 1;
+
+ val = swfdec_as_gcable_alloc (context, sizeof (SwfdecAsMovieValue) + n_names * sizeof (const char *));
+ val->player = SWFDEC_PLAYER (context);
+ val->movie = movie;
+ val->n_names = n_names;
+ if (parent)
+ memcpy (val->names, parent->names, sizeof (const char *) * parent->n_names);
+ val->names[n_names - 1] = name;
+
+ SWFDEC_AS_GCABLE_SET_NEXT (val, context->movies);
+ context->movies = val;
+
+ return val;
+}
+
+void
+swfdec_as_movie_value_mark (SwfdecAsMovieValue *value)
+{
+ guint i;
+
+ g_assert (value != NULL);
+
+ SWFDEC_AS_GCABLE_SET_FLAG ((SwfdecAsGcable *) value, SWFDEC_AS_GC_MARK);
+
+ if (value->movie)
+ swfdec_gc_object_mark (value->movie);
+ for (i = 0; i < value->n_names; i++) {
+ swfdec_as_string_mark (value->names[i]);
+ }
+}
+
+static SwfdecMovie *
+swfdec_player_get_movie_by_name (SwfdecPlayer *player, const char *name)
+{
+ GList *walk;
+
+ for (walk = player->priv->roots; walk; walk = walk->next) {
+ SwfdecMovie *cur = walk->data;
+ if (cur->as_value->names[0] == name)
+ return cur;
+ }
+ return NULL;
+}
+
+SwfdecMovie *
+swfdec_as_movie_value_get (SwfdecAsMovieValue *value)
+{
+ SwfdecMovie *movie;
+ guint i;
+
+ g_assert (value != NULL);
+ g_assert (value->movie == NULL); /* checked by macros */
+
+ /* FIXME: getting a root movie by name should be simpler */
+ movie = swfdec_player_get_movie_by_name (value->player, value->names[0]);
+ for (i = 1; i < value->n_names && movie; i++) {
+ movie = swfdec_movie_get_by_name (movie, value->names[i], TRUE);
+ }
+ return movie;
+}
diff --git a/swfdec/swfdec_as_movie_value.h b/swfdec/swfdec_as_movie_value.h
new file mode 100644
index 0000000..29f0f20
--- /dev/null
+++ b/swfdec/swfdec_as_movie_value.h
@@ -0,0 +1,50 @@
+/* Swfdec
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_MOVIE_VALUE_H_
+#define _SWFDEC_AS_MOVIE_VALUE_H_
+
+#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_types.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAsMovieValue SwfdecAsMovieValue;
+struct _SwfdecAsMovieValue {
+ SwfdecAsMovieValue * next; /* required for GC'd stuff */
+ /* FIXME: I'd like to get rid of this */
+ SwfdecPlayer * player; /* current player instance */
+ SwfdecMovie * movie; /* reference to the movie while it isn't destroyed */
+ guint n_names; /* number of names */
+ const char * names[]; /* gc'd strings of the names of all movies */
+};
+
+SwfdecAsMovieValue *
+ swfdec_as_movie_value_new (SwfdecMovie * movie,
+ const char * name);
+#define swfdec_as_movie_value_free(value) swfdec_as_gcable_free (SWFDEC_AS_CONTEXT ((value)->player), \
+ (value), sizeof (SwfdecAsMovieValue) + (value)->n_names * sizeof (const char *))
+
+void swfdec_as_movie_value_mark (SwfdecAsMovieValue * value);
+
+SwfdecMovie * swfdec_as_movie_value_get (SwfdecAsMovieValue * value);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_object.c b/swfdec/swfdec_as_object.c
index 256157b..0f83536 100644
--- a/swfdec/swfdec_as_object.c
+++ b/swfdec/swfdec_as_object.c
@@ -1160,10 +1160,10 @@ swfdec_as_object_foreach (SwfdecAsObject *object, SwfdecAsVariableForeach func,
for (walk = movie->list; walk; walk = walk->next) {
SwfdecMovie *cur = walk->data;
- if (cur->original_name == SWFDEC_AS_STR_EMPTY)
+ if (cur->nameasdf == SWFDEC_AS_STR_EMPTY)
continue;
SWFDEC_AS_VALUE_SET_MOVIE (&val, cur);
- if (!func (object, cur->name, &val, 0, data))
+ if (!func (object, cur->nameasdf, &val, 0, data))
return FALSE;
}
}
diff --git a/swfdec/swfdec_movie.c b/swfdec/swfdec_movie.c
index f3c0129..d5202ca 100644
--- a/swfdec/swfdec_movie.c
+++ b/swfdec/swfdec_movie.c
@@ -123,7 +123,7 @@ swfdec_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *parent_to_glo
}
g_assert (movie->cache_state <= SWFDEC_MOVIE_INVALID_CHILDREN);
SWFDEC_LOG ("invalidating %s %s at %s", G_OBJECT_TYPE_NAME (movie),
- movie->name, new_contents ? "end" : "start");
+ movie->nameasdf, new_contents ? "end" : "start");
cairo_matrix_multiply (&matrix, &movie->matrix, parent_to_global);
klass = SWFDEC_MOVIE_GET_CLASS (movie);
klass->invalidate (movie, &matrix, new_contents);
@@ -354,7 +354,7 @@ swfdec_movie_do_remove (SwfdecMovie *movie, gboolean destroy)
{
SwfdecPlayer *player;
- SWFDEC_LOG ("removing %s %s", G_OBJECT_TYPE_NAME (movie), movie->name);
+ SWFDEC_LOG ("removing %s %s", G_OBJECT_TYPE_NAME (movie), movie->nameasdf);
player = SWFDEC_PLAYER (swfdec_gc_object_get_context (movie));
while (movie->list) {
@@ -420,7 +420,7 @@ swfdec_movie_destroy (SwfdecMovie *movie)
SwfdecPlayer *player = SWFDEC_PLAYER (swfdec_gc_object_get_context (movie));
g_assert (movie->state < SWFDEC_MOVIE_STATE_DESTROYED);
- SWFDEC_LOG ("destroying movie %s", movie->name);
+ SWFDEC_LOG ("destroying movie %s", movie->nameasdf);
while (movie->list) {
swfdec_movie_destroy (movie->list->data);
}
@@ -446,41 +446,13 @@ swfdec_movie_destroy (SwfdecMovie *movie)
if (movie->invalidate_last)
player->priv->invalid_pending = g_slist_remove (player->priv->invalid_pending, 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);
-}
-
-/**
- * swfdec_movie_resolve:
- * @movie: movie to resolve
- *
- * Resolves a movie clip to its real version. Since movie clips can be
- * explicitly destroyed, they have problems with references to them. In the
- * case of destruction, these references will remain as "dangling pointers".
- * However, if a movie with the same name is later created again, the reference
- * will point to that movie. This function does this resolving.
- *
- * Returns: The movie clip @movie resolves to or %NULL if none.
- **/
-SwfdecMovie *
-swfdec_movie_resolve (SwfdecMovie *movie)
-{
- SwfdecMovie *parent;
-
- g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
-
- if (movie->state != SWFDEC_MOVIE_STATE_DESTROYED)
- return movie;
- if (movie->parent == NULL) {
- SWFDEC_FIXME ("figure out how to resolve root movies");
- return NULL;
+ /* remove as value, so we can't be scripted anymore */
+ if (movie->as_value) {
+ movie->as_value->movie = NULL;
+ movie->as_value = NULL;
+ SWFDEC_AS_OBJECT (movie)->prototype = NULL;
}
- parent = swfdec_movie_resolve (movie->parent);
- if (parent == NULL)
- return NULL;
- /* FIXME: include unnamed ones? */
- return swfdec_movie_get_by_name (parent, movie->original_name, FALSE);
+ g_object_unref (movie);
}
guint
@@ -645,7 +617,7 @@ swfdec_movie_do_contains (SwfdecMovie *movie, double x, double y, gboolean event
SwfdecMovie *child = walk->data;
if (!child->visible) {
- SWFDEC_LOG ("%s %s (depth %d) is invisible, ignoring", G_OBJECT_TYPE_NAME (movie), movie->name, movie->depth);
+ SWFDEC_LOG ("%s %s (depth %d) is invisible, ignoring", G_OBJECT_TYPE_NAME (movie), movie->nameasdf, movie->depth);
continue;
}
got = swfdec_movie_get_movie_at (child, x, y, events);
@@ -820,7 +792,7 @@ swfdec_movie_render (SwfdecMovie *movie, cairo_t *cr,
if (movie->mask_of != NULL && !swfdec_color_transform_is_mask (color_transform)) {
SWFDEC_LOG ("not rendering %s %p, movie is a mask",
- G_OBJECT_TYPE_NAME (movie), movie->name);
+ G_OBJECT_TYPE_NAME (movie), movie->nameasdf);
return;
}
@@ -958,18 +930,11 @@ swfdec_movie_set_property (GObject *object, guint param_id, const GValue *value,
g_object_ref (movie->graphic);
break;
case PROP_NAME:
- movie->name = g_value_get_string (value);
- if (movie->name) {
- movie->name = swfdec_as_context_get_string (cx, movie->name);
- movie->original_name = movie->name;
+ movie->nameasdf = g_value_get_string (value);
+ if (movie->nameasdf) {
+ movie->nameasdf = swfdec_as_context_get_string (cx, movie->nameasdf);
} else {
- movie->original_name = SWFDEC_AS_STR_EMPTY;
- if (SWFDEC_IS_SPRITE_MOVIE (movie) || SWFDEC_IS_BUTTON_MOVIE (movie)) {
- movie->name = swfdec_as_context_give_string (cx,
- g_strdup_printf ("instance%u", ++SWFDEC_PLAYER (cx)->priv->unnamed_count));
- } else {
- movie->name = SWFDEC_AS_STR_EMPTY;
- }
+ movie->nameasdf = SWFDEC_AS_STR_EMPTY;
}
break;
case PROP_PARENT:
@@ -992,11 +957,6 @@ swfdec_movie_set_property (GObject *object, guint param_id, const GValue *value,
break;
case PROP_RESOURCE:
movie->resource = g_value_get_object (value);
- /* NB: the resource assumes it can access the player via the movie */
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&movie->resource->movie)) {
- g_assert (SWFDEC_IS_SPRITE_MOVIE (movie));
- SWFDEC_AS_VALUE_SET_MOVIE (&movie->resource->movie, movie);
- }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -1012,7 +972,7 @@ swfdec_movie_dispose (GObject *object)
g_assert (movie->list == NULL);
- SWFDEC_LOG ("disposing movie %s (depth %d)", movie->name, movie->depth);
+ SWFDEC_LOG ("disposing movie %s (depth %d)", movie->nameasdf, movie->depth);
if (movie->graphic) {
g_object_unref (movie->graphic);
movie->graphic = NULL;
@@ -1042,8 +1002,9 @@ swfdec_movie_mark (SwfdecGcObject *object)
if (movie->parent)
swfdec_gc_object_mark (movie->parent);
- swfdec_as_string_mark (movie->original_name);
- swfdec_as_string_mark (movie->name);
+ if (movie->as_value)
+ swfdec_as_movie_value_mark (movie->as_value);
+ swfdec_as_string_mark (movie->nameasdf);
g_list_foreach (movie->list, (GFunc) swfdec_gc_object_mark, NULL);
g_slist_foreach (movie->filters, (GFunc) swfdec_gc_object_mark, NULL);
@@ -1084,20 +1045,27 @@ swfdec_movie_get_by_name (SwfdecMovie *movie, const char *name, gboolean unnamed
guint version = swfdec_gc_object_get_context (movie)->version;
SwfdecPlayer *player = SWFDEC_PLAYER (swfdec_gc_object_get_context (movie));
+ if (name[0] == '\0')
+ return NULL;
+
i = swfdec_player_get_level (player, name, version);
if (i >= 0)
return SWFDEC_MOVIE (swfdec_player_get_movie_at_level (player, i));
for (walk = movie->list; walk; walk = walk->next) {
SwfdecMovie *cur = walk->data;
- if (cur->original_name == SWFDEC_AS_STR_EMPTY && !unnamed)
- continue;
- if (swfdec_strcmp (version, cur->name, name) == 0) {
+ if (swfdec_strcmp (version, cur->nameasdf, name) == 0) {
if (swfdec_movie_is_scriptable (cur))
return cur;
else
return movie;
}
+ if (unnamed && cur->nameasdf == SWFDEC_AS_STR_EMPTY) {
+ if (swfdec_strcmp (version, cur->as_value->names[cur->as_value->n_names - 1], name) == 0) {
+ /* unnamed movies are always scriptable */
+ return cur;
+ }
+ }
}
return NULL;
}
@@ -1273,7 +1241,7 @@ swfdec_movie_do_render (SwfdecMovie *movie, cairo_t *cr,
clip->movie = child;
clip->depth = child->clip_depth;
SWFDEC_INFO ("clipping up to depth %d by using %s with depth %d", child->clip_depth,
- child->name, child->depth);
+ child->nameasdf, child->depth);
cairo_push_group (cr);
continue;
}
@@ -1324,16 +1292,37 @@ static GObject *
swfdec_movie_constructor (GType type, guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
- GObject *object;
SwfdecPlayerPrivate *priv;
+ SwfdecAsContext *cx;
+ SwfdecMovie *movie;
+ GObject *object;
+ const char *name;
object = G_OBJECT_CLASS (swfdec_movie_parent_class)->constructor (type,
n_construct_properties, construct_properties);
+ movie = SWFDEC_MOVIE (object);
- priv = SWFDEC_PLAYER (swfdec_gc_object_get_context (object))->priv;
+ cx = swfdec_gc_object_get_context (object);
+ priv = SWFDEC_PLAYER (cx)->priv;
/* the movie is created invalid */
priv->invalid_pending = g_slist_prepend (priv->invalid_pending, object);
+ if (movie->nameasdf == SWFDEC_AS_STR_EMPTY &&
+ (swfdec_movie_is_scriptable (movie) || SWFDEC_IS_ACTOR (movie))) {
+ name = swfdec_as_context_give_string (cx,
+ g_strdup_printf ("instance%u", ++priv->unnamed_count));
+ } else {
+ name = movie->nameasdf;
+ }
+ if (name != SWFDEC_AS_STR_EMPTY)
+ movie->as_value = swfdec_as_movie_value_new (movie, name);
+
+ /* make the resource ours if it doesn't belong to anyone yet */
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&movie->resource->movie)) {
+ g_assert (SWFDEC_IS_SPRITE_MOVIE (movie));
+ SWFDEC_AS_VALUE_SET_MOVIE (&movie->resource->movie, movie);
+ }
+
return object;
}
@@ -1469,7 +1458,7 @@ swfdec_movie_set_static_properties (SwfdecMovie *movie, const cairo_matrix_t *tr
g_return_if_fail (ratio >= -1);
if (movie->modified) {
- SWFDEC_LOG ("%s has already been modified by scripts, ignoring updates", movie->name);
+ SWFDEC_LOG ("%s has already been modified by scripts, ignoring updates", movie->nameasdf);
return;
}
if (transform) {
@@ -1597,7 +1586,13 @@ swfdec_movie_get_path (SwfdecMovie *movie, gboolean dot)
s = g_string_new ("");
do {
if (movie->parent) {
- g_string_prepend (s, movie->name);
+ if (movie->nameasdf != SWFDEC_AS_STR_EMPTY) {
+ g_string_prepend (s, movie->nameasdf);
+ } else if (movie->as_value) {
+ g_string_prepend (s, movie->as_value->names[movie->as_value->n_names - 1]);
+ } else {
+ g_assert_not_reached ();
+ }
g_string_prepend_c (s, (dot ? '.' : '/'));
} else {
char *ret;
diff --git a/swfdec/swfdec_movie.h b/swfdec/swfdec_movie.h
index 747e912..8ca92f5 100644
--- a/swfdec/swfdec_movie.h
+++ b/swfdec/swfdec_movie.h
@@ -22,6 +22,7 @@
#include <glib-object.h>
#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_movie_value.h>
#include <swfdec/swfdec_color.h>
#include <swfdec/swfdec.h>
#include <swfdec/swfdec_event.h>
@@ -121,7 +122,7 @@ struct _SwfdecMovie {
SwfdecAsObject object;
SwfdecGraphic * graphic; /* graphic represented by this movie or NULL if script-created */
- const char * name; /* name of movie - GC'd */
+ const char * nameasdf; /* name of movie - GC'd */
GList * list; /* our contained movie clips (ordered by depth) */
int depth; /* depth of movie (equals content->depth unless explicitly set) */
SwfdecMovieCacheState cache_state; /* whether we are up to date */
@@ -129,11 +130,13 @@ struct _SwfdecMovie {
GSList *variable_listeners; /* textfield's listening to changes in variables - SwfdecMovieVariableListener */
/* static properties (set by PlaceObject tags) */
- const char * original_name; /* the original name - GC'd and static */
cairo_matrix_t original_transform; /* initial transform used */
guint original_ratio; /* ratio used in this movie */
int clip_depth; /* up to which movie this movie clips */
+ /* scripting stuff */
+ SwfdecAsMovieValue * as_value; /* This movie's value in the script engine or %NULL if not accessible by scripts */
+
/* parenting information */
SwfdecMovie * parent; /* movie that contains us or NULL for root movies */
gboolean lockroot; /* when looking for _root we should use this movie, even if it has a parent */
@@ -290,7 +293,6 @@ void swfdec_movie_render (SwfdecMovie * movie,
cairo_t * cr,
const SwfdecColorTransform *trans);
gboolean swfdec_movie_is_scriptable (SwfdecMovie * movie);
-SwfdecMovie * swfdec_movie_resolve (SwfdecMovie * movie);
guint swfdec_movie_get_version (SwfdecMovie * movie);
int swfdec_movie_compare_depths (gconstpointer a,
diff --git a/swfdec/swfdec_movie_asprops.c b/swfdec/swfdec_movie_asprops.c
index 2009e85..1961a1f 100644
--- a/swfdec/swfdec_movie_asprops.c
+++ b/swfdec/swfdec_movie_asprops.c
@@ -138,13 +138,13 @@ mc_yscale_set (SwfdecMovie *movie, const SwfdecAsValue *val)
static void
mc_name_get (SwfdecMovie *movie, SwfdecAsValue *rval)
{
- SWFDEC_AS_VALUE_SET_STRING (rval, movie->name);
+ SWFDEC_AS_VALUE_SET_STRING (rval, movie->nameasdf);
}
static void
mc_name_set (SwfdecMovie *movie, const SwfdecAsValue *val)
{
- movie->name = swfdec_as_value_to_string (swfdec_gc_object_get_context (movie), val);
+ movie->nameasdf = swfdec_as_value_to_string (swfdec_gc_object_get_context (movie), val);
}
static void
@@ -353,7 +353,7 @@ mc_target_get (SwfdecMovie *movie, SwfdecAsValue *rval)
s = g_string_new ("");
while (movie->parent) {
- g_string_prepend (s, movie->name);
+ g_string_prepend (s, movie->nameasdf);
g_string_prepend_c (s, '/');
movie = movie->parent;
}
diff --git a/swfdec/swfdec_player.c b/swfdec/swfdec_player.c
index 7241673..80bfa84 100644
--- a/swfdec/swfdec_player.c
+++ b/swfdec/swfdec_player.c
@@ -453,7 +453,7 @@ swfdec_player_add_action (SwfdecPlayer *player, SwfdecActor *actor,
g_return_if_fail (SWFDEC_IS_ACTOR (actor));
g_return_if_fail (importance < SWFDEC_PLAYER_N_ACTION_QUEUES);
- SWFDEC_LOG ("adding action %s %u", SWFDEC_MOVIE (actor)->name, type);
+ SWFDEC_LOG ("adding action %s %u", SWFDEC_MOVIE (actor)->nameasdf, type);
swfdec_player_do_add_action (player, importance, &action);
}
@@ -468,7 +468,7 @@ swfdec_player_add_action_script (SwfdecPlayer *player, SwfdecActor *actor,
g_return_if_fail (script != NULL);
g_return_if_fail (importance < SWFDEC_PLAYER_N_ACTION_QUEUES);
- SWFDEC_LOG ("adding action script %s %s", SWFDEC_MOVIE (actor)->name, script->name);
+ SWFDEC_LOG ("adding action script %s %s", SWFDEC_MOVIE (actor)->nameasdf, script->name);
swfdec_player_do_add_action (player, importance, &action);
}
@@ -1189,7 +1189,7 @@ swfdec_player_grab_focus (SwfdecPlayer *player, SwfdecActor *actor)
priv = player->priv;
if (actor == priv->focus) {
SWFDEC_DEBUG ("nothing to do, focus change request from movie %s to itself",
- actor ? SWFDEC_MOVIE (actor)->name : "---");
+ actor ? SWFDEC_MOVIE (actor)->nameasdf : "---");
return;
}
prev = priv->focus;
@@ -2615,9 +2615,7 @@ swfdec_player_create_movie_at_level (SwfdecPlayer *player, SwfdecResource *resou
/* create new root movie */
s = swfdec_as_context_give_string (SWFDEC_AS_CONTEXT (player), g_strdup_printf ("_level%d", level));
movie = swfdec_movie_new (player, level - 16384, NULL, resource, NULL, s);
- if (movie == NULL)
- return NULL;
- movie->name = SWFDEC_AS_STR_EMPTY;
+ movie->nameasdf = SWFDEC_AS_STR_EMPTY;
return SWFDEC_SPRITE_MOVIE (movie);
}
@@ -3800,7 +3798,7 @@ swfdec_player_set_url (SwfdecPlayer *player, const SwfdecURL *url)
priv->resource = swfdec_resource_new (player, loader, priv->variables);
movie = swfdec_movie_new (player, -16384, NULL, priv->resource, NULL, SWFDEC_AS_STR__level0);
SWFDEC_ACTOR (movie)->focusrect = SWFDEC_FLASH_YES;
- movie->name = SWFDEC_AS_STR_EMPTY;
+ movie->nameasdf = SWFDEC_AS_STR_EMPTY;
g_object_unref (loader);
g_object_notify (G_OBJECT (player), "url");
g_object_thaw_notify (G_OBJECT (player));
diff --git a/swfdec/swfdec_resource.c b/swfdec/swfdec_resource.c
index 8fced03..ad974d4 100644
--- a/swfdec/swfdec_resource.c
+++ b/swfdec/swfdec_resource.c
@@ -131,7 +131,7 @@ swfdec_resource_emit_signal (SwfdecResource *resource, const char *name, gboolea
return;
}
if (name == SWFDEC_AS_STR_onLoadInit &&
- SWFDEC_AS_OBJECT (movie) != resource->movie.value.object) {
+ (SwfdecAsGcable *) movie->as_value != resource->movie.value.gcable) {
SWFDEC_INFO ("not emitting onLoadInit - the movie is different");
return;
}
@@ -184,12 +184,11 @@ swfdec_resource_replace_movie (SwfdecSpriteMovie *movie, SwfdecResource *resourc
SwfdecMovie *copy;
copy = swfdec_movie_new (SWFDEC_PLAYER (swfdec_gc_object_get_context (movie)),
- mov->depth, mov->parent, resource, NULL, mov->name);
+ mov->depth, mov->parent, resource, NULL, mov->nameasdf);
if (copy == NULL)
return FALSE;
swfdec_movie_begin_update_matrix (copy);
copy->matrix = mov->matrix;
- copy->original_name = mov->original_name;
copy->modified = mov->modified;
copy->xscale = mov->xscale;
copy->yscale = mov->yscale;
diff --git a/swfdec/swfdec_sprite_movie.c b/swfdec/swfdec_sprite_movie.c
index 2dfbc42..8f338a0 100644
--- a/swfdec/swfdec_sprite_movie.c
+++ b/swfdec/swfdec_sprite_movie.c
@@ -79,7 +79,7 @@ swfdec_sprite_movie_perform_old_place (SwfdecSpriteMovie *movie,
dec = SWFDEC_SWF_DECODER (mov->resource->decoder);
- SWFDEC_LOG ("performing PlaceObject on movie %s", mov->name);
+ SWFDEC_LOG ("performing PlaceObject on movie %s", mov->nameasdf);
id = swfdec_bits_get_u16 (bits);
SWFDEC_LOG (" id = %d", id);
@@ -175,7 +175,7 @@ swfdec_sprite_movie_perform_place (SwfdecSpriteMovie *movie, SwfdecBits *bits, g
has_character = swfdec_bits_getbit (bits);
move = swfdec_bits_getbit (bits);
- SWFDEC_LOG ("performing PlaceObject%d on movie %s", tag == SWFDEC_TAG_PLACEOBJECT2 ? 2 : 3, mov->name);
+ SWFDEC_LOG ("performing PlaceObject%d on movie %s", tag == SWFDEC_TAG_PLACEOBJECT2 ? 2 : 3, mov->nameasdf);
SWFDEC_LOG (" has_clip_actions = %d", has_clip_actions);
SWFDEC_LOG (" has_clip_depth = %d", has_clip_depth);
SWFDEC_LOG (" has_name = %d", has_name);
@@ -323,7 +323,7 @@ swfdec_sprite_movie_perform_place (SwfdecSpriteMovie *movie, SwfdecBits *bits, g
has_ctrans ? &ctrans : NULL, ratio, clip_depth, blend_mode, events);
} else {
if (cur != NULL && version > 5) {
- SWFDEC_INFO ("depth %d is already occupied by movie %s, not placing", depth, cur->name);
+ SWFDEC_INFO ("depth %d is already occupied by movie %s, not placing", depth, cur->nameasdf);
goto out;
}
if (!SWFDEC_IS_GRAPHIC (graphic)) {
diff --git a/swfdec/swfdec_sprite_movie_as.c b/swfdec/swfdec_sprite_movie_as.c
index cff5246..2e667e0 100644
--- a/swfdec/swfdec_sprite_movie_as.c
+++ b/swfdec/swfdec_sprite_movie_as.c
@@ -398,7 +398,7 @@ swfdec_sprite_movie_attachBitmap (SwfdecAsContext *cx, SwfdecAsObject *object,
swfdec_bitmap_movie_new (parent, SWFDEC_BITMAP_DATA (bitmap->relay), depth);
SWFDEC_LOG ("created new BitmapMovie to parent %s at depth %d",
- parent->name, depth);
+ parent->nameasdf, depth);
}
SWFDEC_AS_NATIVE (900, 26, swfdec_sprite_movie_getRect)
@@ -822,7 +822,7 @@ swfdec_sprite_movie_attachMovie (SwfdecAsContext *cx, SwfdecAsObject *object,
ret = swfdec_movie_new (SWFDEC_PLAYER (swfdec_gc_object_get_context (object)),
depth, movie, movie->resource, sprite, name);
SWFDEC_LOG ("attached %s (%u) as %s to depth %u", export, SWFDEC_CHARACTER (sprite)->id,
- ret->name, ret->depth);
+ ret->nameasdf, ret->depth);
/* run init and construct */
constructor = swfdec_player_get_export_class (SWFDEC_PLAYER (cx), export);
if (constructor == NULL) {
@@ -854,7 +854,7 @@ swfdec_sprite_movie_duplicateMovieClip (SwfdecAsContext *cx, SwfdecAsObject *obj
if (new == NULL)
return;
swfdec_sprite_movie_copy_props (new, movie);
- SWFDEC_LOG ("duplicated %s as %s to depth %u", movie->name, new->name, new->depth);
+ SWFDEC_LOG ("duplicated %s as %s to depth %u", movie->nameasdf, new->nameasdf, new->depth);
SWFDEC_AS_VALUE_SET_MOVIE (rval, new);
}
diff --git a/vivified/ui/vivi_movie_list.c b/vivified/ui/vivi_movie_list.c
index 61a471f..01a88cd 100644
--- a/vivified/ui/vivi_movie_list.c
+++ b/vivified/ui/vivi_movie_list.c
@@ -125,10 +125,7 @@ vivi_movie_list_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter,
return;
case VIVI_MOVIE_LIST_COLUMN_NAME:
g_value_init (value, G_TYPE_STRING);
- if (movie->name[0])
- g_value_set_string (value, movie->name);
- else
- g_value_set_string (value, movie->original_name);
+ g_value_set_string (value, movie->nameasdf);
return;
case VIVI_MOVIE_LIST_COLUMN_DEPTH:
g_value_init (value, G_TYPE_INT);
commit 8acbaa1e17ba2c8e464078cf5a20ff597e57038d
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Nov 3 12:28:03 2008 +0100
make resource->movie a SwfdecAsValue, too
diff --git a/swfdec/swfdec_movie.c b/swfdec/swfdec_movie.c
index f4a91f7..f3c0129 100644
--- a/swfdec/swfdec_movie.c
+++ b/swfdec/swfdec_movie.c
@@ -993,9 +993,9 @@ swfdec_movie_set_property (GObject *object, guint param_id, const GValue *value,
case PROP_RESOURCE:
movie->resource = g_value_get_object (value);
/* NB: the resource assumes it can access the player via the movie */
- if (movie->resource->movie == NULL) {
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&movie->resource->movie)) {
g_assert (SWFDEC_IS_SPRITE_MOVIE (movie));
- movie->resource->movie = SWFDEC_SPRITE_MOVIE (movie);
+ SWFDEC_AS_VALUE_SET_MOVIE (&movie->resource->movie, movie);
}
break;
default:
@@ -1670,7 +1670,7 @@ swfdec_movie_get_own_resource (SwfdecMovie *movie)
if (!SWFDEC_IS_SPRITE_MOVIE (movie))
return NULL;
- if (movie->resource->movie != SWFDEC_SPRITE_MOVIE (movie))
+ if (SWFDEC_AS_VALUE_GET_MOVIE (&movie->resource->movie) != movie)
return NULL;
return movie->resource;
diff --git a/swfdec/swfdec_resource.c b/swfdec/swfdec_resource.c
index 1d51d61..8fced03 100644
--- a/swfdec/swfdec_resource.c
+++ b/swfdec/swfdec_resource.c
@@ -57,7 +57,7 @@ swfdec_resource_is_root (SwfdecResource *resource)
g_return_val_if_fail (SWFDEC_IS_RESOURCE (resource), FALSE);
return
- resource->movie == SWFDEC_PLAYER (swfdec_gc_object_get_context (resource))->priv->roots->data;
+ resource == SWFDEC_MOVIE (SWFDEC_PLAYER (swfdec_gc_object_get_context (resource))->priv->roots->data)->resource;
}
static SwfdecPlayer *
@@ -70,9 +70,9 @@ static void
swfdec_resource_stream_target_image (SwfdecResource *instance)
{
SwfdecPlayer *player = SWFDEC_PLAYER (swfdec_gc_object_get_context (instance));
- SwfdecSpriteMovie *movie = instance->movie;
+ SwfdecSpriteMovie *movie = (SwfdecSpriteMovie *) SWFDEC_AS_VALUE_GET_MOVIE (&instance->movie);
- if (movie->sprite != NULL)
+ if (!SWFDEC_IS_SPRITE_MOVIE (movie) || movie->sprite != NULL)
return;
if (SWFDEC_IS_SWF_DECODER (instance->decoder)) {
@@ -124,14 +124,14 @@ swfdec_resource_emit_signal (SwfdecResource *resource, const char *name, gboolea
cx = swfdec_gc_object_get_context (resource->clip_loader);
SWFDEC_AS_VALUE_SET_STRING (&vals[0], name);
- if (resource->movie) {
- movie = swfdec_movie_resolve (SWFDEC_MOVIE (resource->movie));
+ if (SWFDEC_AS_VALUE_IS_MOVIE (&resource->movie)) {
+ movie = SWFDEC_AS_VALUE_GET_MOVIE (&resource->movie);
if (movie == NULL) {
SWFDEC_DEBUG ("no movie, not emitting signal");
return;
}
if (name == SWFDEC_AS_STR_onLoadInit &&
- movie != SWFDEC_MOVIE (resource->movie)) {
+ SWFDEC_AS_OBJECT (movie) != resource->movie.value.object) {
SWFDEC_INFO ("not emitting onLoadInit - the movie is different");
return;
}
@@ -209,17 +209,20 @@ swfdec_resource_stream_target_open (SwfdecStreamTarget *target, SwfdecStream *st
{
SwfdecLoader *loader = SWFDEC_LOADER (stream);
SwfdecResource *instance = SWFDEC_RESOURCE (target);
+ SwfdecMovie *movie;
const char *query;
- g_assert (instance->movie);
+ g_assert (SWFDEC_AS_VALUE_IS_MOVIE (&instance->movie));
+ movie = SWFDEC_AS_VALUE_GET_MOVIE (&instance->movie);
+ g_assert (movie);
query = swfdec_url_get_query (swfdec_loader_get_url (loader));
if (query) {
SWFDEC_INFO ("set url query movie variables: %s", query);
- swfdec_as_object_decode (SWFDEC_AS_OBJECT (instance->movie), query);
+ swfdec_as_object_decode (SWFDEC_AS_OBJECT (movie), query);
}
if (instance->variables) {
SWFDEC_INFO ("set manual movie variables: %s", instance->variables);
- swfdec_as_object_decode (SWFDEC_AS_OBJECT (instance->movie), instance->variables);
+ swfdec_as_object_decode (SWFDEC_AS_OBJECT (movie), instance->variables);
}
swfdec_resource_emit_signal (instance, SWFDEC_AS_STR_onLoadStart, FALSE, NULL, 0);
instance->state = SWFDEC_RESOURCE_OPENED;
@@ -329,8 +332,11 @@ swfdec_resource_stream_target_close (SwfdecStreamTarget *target, SwfdecStream *s
if (swfdec_resource_abort_if_not_initialized (resource))
return;
- if (resource->movie != NULL)
- swfdec_actor_queue_script (SWFDEC_ACTOR (resource->movie), SWFDEC_EVENT_LOAD);
+ if (SWFDEC_AS_VALUE_IS_MOVIE (&resource->movie)) {
+ SwfdecMovie *movie = SWFDEC_AS_VALUE_GET_MOVIE (&resource->movie);
+ if (movie)
+ swfdec_actor_queue_script (SWFDEC_ACTOR (movie), SWFDEC_EVENT_LOAD);
+ }
}
static void
@@ -524,7 +530,7 @@ swfdec_resource_create_movie (SwfdecResource *resource, SwfdecResourceLoad *load
SwfdecPlayer *player;
SwfdecSpriteMovie *movie;
- if (resource->movie)
+ if (SWFDEC_AS_VALUE_IS_MOVIE (&resource->movie))
return TRUE;
player = SWFDEC_PLAYER (swfdec_gc_object_get_context (resource));
if (SWFDEC_AS_VALUE_IS_MOVIE (&load->target)) {
@@ -575,9 +581,9 @@ swfdec_resource_do_load (SwfdecPlayer *player, gboolean allowed, gpointer loadp)
load->url, swfdec_url_get_url (load->sandbox->url));
/* FIXME: is replacing correct? */
if (SWFDEC_AS_VALUE_IS_MOVIE (&load->target)) {
- resource->movie = (SwfdecSpriteMovie *) SWFDEC_AS_VALUE_GET_MOVIE (&load->target);
- if (!SWFDEC_IS_SPRITE_MOVIE (resource->movie))
- resource->movie = NULL;
+ if (SWFDEC_AS_VALUE_IS_MOVIE (&load->target) &&
+ SWFDEC_IS_SPRITE_MOVIE (SWFDEC_AS_VALUE_GET_MOVIE (&load->target)))
+ resource->movie = load->target;
swfdec_resource_emit_error (resource, SWFDEC_AS_STR_IllegalRequest);
}
swfdec_player_unroot (player, load);
@@ -750,12 +756,13 @@ swfdec_resource_emit_on_load_init (SwfdecResource *resource)
if (resource->state != SWFDEC_RESOURCE_COMPLETE)
return FALSE;
- if (resource->movie && SWFDEC_IS_IMAGE_DECODER (resource->decoder)) {
+ if (SWFDEC_AS_VALUE_IS_MOVIE (&resource->movie) && SWFDEC_IS_IMAGE_DECODER (resource->decoder)) {
SwfdecImage *image = SWFDEC_IMAGE_DECODER (resource->decoder)->image;
- if (image) {
- swfdec_movie_invalidate_next (SWFDEC_MOVIE (resource->movie));
- swfdec_movie_queue_update (SWFDEC_MOVIE (resource->movie), SWFDEC_MOVIE_INVALID_EXTENTS);
- SWFDEC_MOVIE (resource->movie)->image = g_object_ref (image);
+ SwfdecMovie *movie = SWFDEC_AS_VALUE_GET_MOVIE (&resource->movie);
+ if (image && movie) {
+ swfdec_movie_invalidate_next (movie);
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_EXTENTS);
+ movie->image = g_object_ref (image);
}
}
swfdec_resource_emit_signal (resource, SWFDEC_AS_STR_onLoadInit, FALSE, NULL, 0);
diff --git a/swfdec/swfdec_resource.h b/swfdec/swfdec_resource.h
index 2b88d83..a5428cd 100644
--- a/swfdec/swfdec_resource.h
+++ b/swfdec/swfdec_resource.h
@@ -49,7 +49,7 @@ struct _SwfdecResource
guint version; /* version of this resource */
SwfdecSandbox * sandbox; /* sandbox this resource belongs to (only NULL for a short time on very first loader) */
- SwfdecSpriteMovie * movie; /* the movie responsible for creating this instance */
+ SwfdecAsValue movie; /* the movie responsible for creating this instance or undefined if none */
SwfdecLoader * loader; /* the loader providing data for the decoder */
SwfdecDecoder * decoder; /* decoder in use or NULL if broken file */
commit 646595bbc73855205346c4018a6b0a14017f73d9
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Nov 3 11:56:25 2008 +0100
make the loader keep a SwfdecAsValue, not target_movie/target_string
props
diff --git a/swfdec/swfdec_as_interpret.c b/swfdec/swfdec_as_interpret.c
index d4ae07b..6ae6384 100644
--- a/swfdec/swfdec_as_interpret.c
+++ b/swfdec/swfdec_as_interpret.c
@@ -1117,17 +1117,19 @@ static void
swfdec_action_get_url (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
{
SwfdecBits bits;
- char *url, *target;
+ char *url, *t;
+ const char *target;
swfdec_bits_init_data (&bits, data, len);
url = swfdec_bits_get_string (&bits, cx->version);
- target = swfdec_bits_get_string (&bits, cx->version);
- if (url == NULL || target == NULL) {
+ t = swfdec_bits_get_string (&bits, cx->version);
+ if (url == NULL || t == NULL) {
SWFDEC_ERROR ("not enough data in GetURL");
g_free (url);
- g_free (target);
+ g_free (t);
return;
}
+ target = swfdec_as_context_give_string (cx, t);
if (swfdec_bits_left (&bits)) {
SWFDEC_WARNING ("leftover bytes in GetURL action");
}
@@ -1137,7 +1139,6 @@ swfdec_action_get_url (SwfdecAsContext *cx, guint action, const guint8 *data, gu
swfdec_resource_load (SWFDEC_PLAYER (cx), target, url, NULL);
}
g_free (url);
- g_free (target);
}
static void
diff --git a/swfdec/swfdec_resource.c b/swfdec/swfdec_resource.c
index d5dee5a..1d51d61 100644
--- a/swfdec/swfdec_resource.c
+++ b/swfdec/swfdec_resource.c
@@ -490,8 +490,7 @@ swfdec_resource_add_export (SwfdecResource *instance, SwfdecCharacter *character
typedef struct _SwfdecResourceLoad SwfdecResourceLoad;
struct _SwfdecResourceLoad {
SwfdecSandbox * sandbox;
- char * target_string;
- SwfdecSpriteMovie * target_movie;
+ SwfdecAsValue target;
char * url;
SwfdecBuffer * buffer;
SwfdecMovieClipLoader * loader;
@@ -503,7 +502,6 @@ swfdec_resource_load_free (gpointer loadp)
SwfdecResourceLoad *load = loadp;
g_free (load->url);
- g_free (load->target_string);
if (load->buffer)
swfdec_buffer_unref (load->buffer);
g_slice_free (SwfdecResourceLoad, load);
@@ -517,8 +515,7 @@ swfdec_resource_load_mark (gpointer loadp, gpointer playerp)
swfdec_gc_object_mark (load->sandbox);
if (load->loader)
swfdec_gc_object_mark (load->loader);
- if (load->target_movie)
- swfdec_gc_object_mark (load->target_movie);
+ swfdec_as_value_mark (&load->target);
}
static gboolean
@@ -530,14 +527,14 @@ swfdec_resource_create_movie (SwfdecResource *resource, SwfdecResourceLoad *load
if (resource->movie)
return TRUE;
player = SWFDEC_PLAYER (swfdec_gc_object_get_context (resource));
- if (load->target_movie) {
- movie = (SwfdecSpriteMovie *) swfdec_movie_resolve (SWFDEC_MOVIE (load->target_movie));
+ if (SWFDEC_AS_VALUE_IS_MOVIE (&load->target)) {
+ movie = (SwfdecSpriteMovie *) SWFDEC_AS_VALUE_GET_MOVIE (&load->target);
if (SWFDEC_IS_SPRITE_MOVIE (movie))
movie = swfdec_resource_replace_movie (movie, resource);
else
movie = NULL;
- } else {
- int level = swfdec_player_get_level (player, load->target_string, 7);
+ } else if (SWFDEC_AS_VALUE_IS_STRING (&load->target)) {
+ int level = swfdec_player_get_level (player, SWFDEC_AS_VALUE_GET_STRING (&load->target), 7);
if (level >= 0) {
movie = swfdec_player_get_movie_at_level (player, level);
if (movie)
@@ -546,6 +543,9 @@ swfdec_resource_create_movie (SwfdecResource *resource, SwfdecResourceLoad *load
} else {
movie = NULL;
}
+ } else {
+ /* we only set target to string or movie values */
+ g_assert_not_reached ();
}
if (movie == NULL) {
SWFDEC_WARNING ("target does not reference a movie, not loading %s", load->url);
@@ -574,8 +574,10 @@ swfdec_resource_do_load (SwfdecPlayer *player, gboolean allowed, gpointer loadp)
SWFDEC_WARNING ("SECURITY: no access to %s from %s",
load->url, swfdec_url_get_url (load->sandbox->url));
/* FIXME: is replacing correct? */
- if (load->target_movie) {
- resource->movie = SWFDEC_SPRITE_MOVIE (swfdec_movie_resolve (SWFDEC_MOVIE (load->target_movie)));
+ if (SWFDEC_AS_VALUE_IS_MOVIE (&load->target)) {
+ resource->movie = (SwfdecSpriteMovie *) SWFDEC_AS_VALUE_GET_MOVIE (&load->target);
+ if (!SWFDEC_IS_SPRITE_MOVIE (resource->movie))
+ resource->movie = NULL;
swfdec_resource_emit_error (resource, SWFDEC_AS_STR_IllegalRequest);
}
swfdec_player_unroot (player, load);
@@ -609,7 +611,11 @@ swfdec_resource_load_request (gpointer loadp, gpointer playerp)
if (load->url[0] == '\0') {
SwfdecSpriteMovie *movie;
- movie = load->target_movie ? (SwfdecSpriteMovie *) swfdec_movie_resolve (SWFDEC_MOVIE (load->target_movie)) : NULL;
+ if (SWFDEC_AS_VALUE_IS_MOVIE (&load->target)) {
+ movie = (SwfdecSpriteMovie *) SWFDEC_AS_VALUE_GET_MOVIE (&load->target);
+ } else {
+ movie = NULL;
+ }
if (SWFDEC_IS_SPRITE_MOVIE (movie)) {
swfdec_resource_replace_movie (movie, SWFDEC_MOVIE (movie)->resource);
} else {
@@ -622,22 +628,20 @@ swfdec_resource_load_request (gpointer loadp, gpointer playerp)
/* fscommand? */
if (g_ascii_strncasecmp (load->url, "FSCommand:", 10) == 0) {
char *command = load->url + 10;
- if (load->target_movie) {
- char *target = swfdec_movie_get_path (SWFDEC_MOVIE (load->target_movie), TRUE);
+ const char *target = swfdec_as_value_to_string (SWFDEC_AS_CONTEXT (player), &load->target);
+ if (SWFDEC_AS_VALUE_IS_MOVIE (&load->target)) {
SWFDEC_FIXME ("Adobe 9.0.124.0 and later don't emit fscommands here. "
"We just do for compatibility reasons with the testsuite.");
- g_signal_emit_by_name (player, "fscommand", command, target);
- g_free (target);
- } else {
- g_signal_emit_by_name (player, "fscommand", command, load->target_string);
}
+ g_signal_emit_by_name (player, "fscommand", command, target);
swfdec_player_unroot (player, load);
return;
}
/* LAUNCH command (aka getURL) */
- if (load->target_string && swfdec_player_get_level (player, load->target_string, 7) < 0) {
- swfdec_player_launch (player, load->url, load->target_string, load->buffer);
+ if (SWFDEC_AS_VALUE_IS_STRING (&load->target) && swfdec_player_get_level (player,
+ SWFDEC_AS_VALUE_GET_STRING (&load->target), 7) < 0) {
+ swfdec_player_launch (player, load->url, SWFDEC_AS_VALUE_GET_STRING (&load->target), load->buffer);
swfdec_player_unroot (player, load);
return;
}
@@ -647,10 +651,9 @@ swfdec_resource_load_request (gpointer loadp, gpointer playerp)
}
/* NB: must be called from a script */
-/* FIXME: 6 arguments?! */
+/* FIXME: 5 arguments?! */
static void
-swfdec_resource_load_internal (SwfdecPlayer *player,
- SwfdecSpriteMovie *target_movie, const char *target_string,
+swfdec_resource_load_internal (SwfdecPlayer *player, const SwfdecAsValue *val,
const char *url, SwfdecBuffer *buffer, SwfdecMovieClipLoader *loader)
{
SwfdecResourceLoad *load;
@@ -660,8 +663,7 @@ swfdec_resource_load_internal (SwfdecPlayer *player,
load->sandbox = swfdec_sandbox_get (player);
load->url = g_strdup (url);
- load->target_movie = target_movie;
- load->target_string = g_strdup (target_string);
+ load->target = *val;
load->buffer = buffer;
load->loader = loader;
@@ -674,6 +676,7 @@ swfdec_resource_load_movie (SwfdecPlayer *player, const SwfdecAsValue *target,
const char *url, SwfdecBuffer *buffer, SwfdecMovieClipLoader *loader)
{
SwfdecMovie *movie;
+ SwfdecAsValue val;
const char *s;
g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
@@ -684,8 +687,7 @@ swfdec_resource_load_movie (SwfdecPlayer *player, const SwfdecAsValue *target,
if (SWFDEC_AS_VALUE_IS_MOVIE (target)) {
movie = SWFDEC_AS_VALUE_GET_MOVIE (target);
if (SWFDEC_IS_SPRITE_MOVIE (movie)) {
- swfdec_resource_load_internal (player, SWFDEC_SPRITE_MOVIE (movie),
- NULL, url, buffer, loader);
+ swfdec_resource_load_internal (player, target, url, buffer, loader);
return TRUE;
}
}
@@ -695,9 +697,9 @@ swfdec_resource_load_movie (SwfdecPlayer *player, const SwfdecAsValue *target,
int i = swfdec_as_double_to_integer (SWFDEC_AS_VALUE_GET_NUMBER (target));
if (i < 0)
return FALSE;
- s = swfdec_as_context_give_string (swfdec_gc_object_get_context (loader),
- g_strdup_printf ("_level%d", i));
- swfdec_resource_load_internal (player, NULL, s, url, buffer, loader);
+ SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_give_string (
+ SWFDEC_AS_CONTEXT (player), g_strdup_printf ("_level%d", i)));
+ swfdec_resource_load_internal (player, &val, url, buffer, loader);
return TRUE;
} else if (SWFDEC_AS_VALUE_IS_STRING (target) || SWFDEC_AS_VALUE_IS_MOVIE(target)) {
s = swfdec_as_value_to_string (SWFDEC_AS_CONTEXT (player), target);
@@ -711,14 +713,15 @@ swfdec_resource_load_movie (SwfdecPlayer *player, const SwfdecAsValue *target,
if (swfdec_player_get_level (player, s, SWFDEC_AS_CONTEXT (player)->version) >= 0) {
/* lowercase the string, so we can do case insensitive level lookups later on */
char *tmp = g_ascii_strdown (s, -1);
- swfdec_resource_load_internal (player, NULL, tmp, url, buffer, NULL);
- g_free (tmp);
+ SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_give_string (
+ SWFDEC_AS_CONTEXT (player), tmp));
+ swfdec_resource_load_internal (player, &val, url, buffer, NULL);
return TRUE;
}
movie = swfdec_player_get_movie_from_string (player, s);
if (SWFDEC_IS_SPRITE_MOVIE (movie)) {
- swfdec_resource_load_internal (player, SWFDEC_SPRITE_MOVIE (movie),
- NULL, url, buffer, loader);
+ SWFDEC_AS_VALUE_SET_MOVIE (&val, movie);
+ swfdec_resource_load_internal (player, &val, url, buffer, loader);
return TRUE;
}
SWFDEC_WARNING ("%s does not reference a movie, not loading %s", s, url);
@@ -729,11 +732,14 @@ void
swfdec_resource_load (SwfdecPlayer *player, const char *target,
const char *url, SwfdecBuffer *buffer)
{
+ SwfdecAsValue val;
+
g_return_if_fail (SWFDEC_IS_PLAYER (player));
g_return_if_fail (target != NULL);
g_return_if_fail (url != NULL);
- swfdec_resource_load_internal (player, NULL, target, url, buffer, NULL);
+ SWFDEC_AS_VALUE_SET_STRING (&val, target);
+ swfdec_resource_load_internal (player, &val, url, buffer, NULL);
}
gboolean
commit 21f92c3936a237ee2f67152254d3112e5d755aac
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Nov 2 18:51:33 2008 +0100
make SWFDEC_AS_VALUE_SET_COMPOSITE use SET_MOVIE/OBJECT
diff --git a/swfdec/swfdec_as_internal.h b/swfdec/swfdec_as_internal.h
index a7e1632..3601d6d 100644
--- a/swfdec/swfdec_as_internal.h
+++ b/swfdec/swfdec_as_internal.h
@@ -41,11 +41,12 @@ G_BEGIN_DECLS
#define SWFDEC_AS_VALUE_GET_COMPOSITE(val) (SWFDEC_AS_VALUE_IS_OBJECT (val) ? \
SWFDEC_AS_VALUE_GET_OBJECT (val) : SWFDEC_AS_OBJECT (SWFDEC_AS_VALUE_GET_MOVIE (val)))
#define SWFDEC_AS_VALUE_SET_COMPOSITE(val,o) G_STMT_START { \
- SwfdecAsValue *__val = (val); \
- SwfdecAsObject *__o = (o); \
- g_assert (__o != NULL); \
- (__val)->type = __o->movie ? SWFDEC_AS_TYPE_MOVIE : SWFDEC_AS_TYPE_OBJECT; \
- (__val)->value.object = __o; \
+ SwfdecAsObject *_o = (o); \
+ if (_o->movie) { \
+ SWFDEC_AS_VALUE_SET_MOVIE ((val), SWFDEC_MOVIE (_o)); \
+ } else { \
+ SWFDEC_AS_VALUE_SET_OBJECT ((val), _o); \
+ } \
} G_STMT_END
#define SWFDEC_AS_VALUE_IS_MOVIE(val) (SWFDEC_AS_VALUE_GET_TYPE (val) == SWFDEC_AS_TYPE_MOVIE)
More information about the Swfdec-commits
mailing list