[Swfdec-commits] 11 commits - swfdec/swfdec_as_context.c swfdec/swfdec_as_frame.c swfdec/swfdec_as_internal.h swfdec/swfdec_as_object.c swfdec/swfdec_as_object.h swfdec/swfdec_as_types.h swfdec/swfdec_audio_decoder_uncompressed.c swfdec/swfdec_bitmap_data.c swfdec/swfdec_bots.c swfdec/swfdec_image.c swfdec/swfdec_movie.c swfdec/swfdec_movie.h swfdec/swfdec_net_stream.c swfdec/swfdec_renderer.c swfdec/swfdec_types.h swfdec/swfdec_video_movie_as.c swfdec/swfdec_video_movie.c swfdec/swfdec_video_movie.h test/swfdec_test_image.c

Benjamin Otte company at kemper.freedesktop.org
Thu Oct 30 15:34:08 PDT 2008


 swfdec/swfdec_as_context.c                 |    2 
 swfdec/swfdec_as_frame.c                   |    1 
 swfdec/swfdec_as_internal.h                |   12 
 swfdec/swfdec_as_object.c                  |  413 ++++++++++++++---------------
 swfdec/swfdec_as_object.h                  |   16 -
 swfdec/swfdec_as_types.h                   |   11 
 swfdec/swfdec_audio_decoder_uncompressed.c |   16 -
 swfdec/swfdec_bitmap_data.c                |    4 
 swfdec/swfdec_bots.c                       |   11 
 swfdec/swfdec_image.c                      |    3 
 swfdec/swfdec_movie.c                      |   92 ------
 swfdec/swfdec_movie.h                      |    4 
 swfdec/swfdec_net_stream.c                 |    1 
 swfdec/swfdec_renderer.c                   |    4 
 swfdec/swfdec_types.h                      |    2 
 swfdec/swfdec_video_movie.c                |   83 -----
 swfdec/swfdec_video_movie.h                |    3 
 swfdec/swfdec_video_movie_as.c             |   97 ++++++
 test/swfdec_test_image.c                   |    3 
 19 files changed, 360 insertions(+), 418 deletions(-)

New commits:
commit a76ccebbb049fd8a55c170429be97967e73685ab
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 23:33:33 2008 +0100

    make the set vfunc go away, too
    
    Now SwfdecAsObject has no more vfuncs, go us!

diff --git a/swfdec/swfdec_as_object.c b/swfdec/swfdec_as_object.c
index 62a5ec5..3ecc739 100644
--- a/swfdec/swfdec_as_object.c
+++ b/swfdec/swfdec_as_object.c
@@ -428,150 +428,6 @@ swfdec_as_object_hash_lookup_with_prototype (SwfdecAsObject *object,
   return var;
 }
 
-#if 0
-static void
-swfdec_as_array_set (SwfdecAsObject *object, const char *variable,
-    const SwfdecAsValue *val, guint flags)
-{
-}
-#endif
-
-static void
-swfdec_as_object_do_set (SwfdecAsObject *object, const char *variable, 
-    const SwfdecAsValue *val, guint flags)
-{
-  SwfdecAsVariable *var;
-  SwfdecAsWatch *watch;
-  SwfdecAsObject *proto;
-  SwfdecAsContext *context;
-
-  if (!swfdec_as_variable_name_is_valid (variable) ||
-      object->super)
-    return;
-
-  context = swfdec_gc_object_get_context (object);
-  var = swfdec_as_object_hash_lookup_with_prototype (object, variable, &proto);
-  if (swfdec_as_context_is_aborted (context))
-    return;
-
-  // if variable is disabled in this version
-  if (var != NULL && !swfdec_as_object_variable_enabled_in_version (var, context->version)) {
-    if (proto == NULL) {
-      // it's at the top level, remove getter and setter plus overwrite
-      var->get = NULL;
-      var->set = NULL;
-    } else {
-      // it's in proto, we create a new one at the top level
-      var = NULL;
-    }
-  }
-
-  if (var == NULL) {
-    var = swfdec_as_object_hash_create (object, variable, flags);
-    if (var == NULL)
-      return;
-  } else {
-    if (var->flags & SWFDEC_AS_VARIABLE_CONSTANT)
-      return;
-    // remove the flags that could make this variable hidden
-    if (context->version == 6) {
-      // version 6, so let's forget SWFDEC_AS_VARIABLE_VERSION_7_UP flag, oops!
-      // we will still set the value though, even if that flag is set
-      var->flags &= ~(SWFDEC_AS_VARIABLE_VERSION_6_UP |
-	  SWFDEC_AS_VARIABLE_VERSION_NOT_6 | SWFDEC_AS_VARIABLE_VERSION_8_UP |
-	  SWFDEC_AS_VARIABLE_VERSION_9_UP);
-    } else {
-      var->flags &= ~(SWFDEC_AS_VARIABLE_VERSION_6_UP |
-	  SWFDEC_AS_VARIABLE_VERSION_NOT_6 | SWFDEC_AS_VARIABLE_VERSION_7_UP |
-	  SWFDEC_AS_VARIABLE_VERSION_8_UP | SWFDEC_AS_VARIABLE_VERSION_9_UP);
-    }
-  }
-  if (object->watches) {
-    SwfdecAsValue ret = *val;
-    watch = g_hash_table_lookup (object->watches, variable);
-    /* FIXME: figure out if this limit here is correct. Add a watch in Flash 7 
-     * and set a variable using Flash 6 */
-    if (watch && swfdec_as_watch_can_recurse (watch)) {
-      SwfdecAsValue args[4];
-      SWFDEC_AS_VALUE_SET_STRING (&args[0], variable);
-      args[1] = var->value;
-      args[2] = *val;
-      args[3] = watch->watch_data;
-      swfdec_as_watch_ref (watch);
-      swfdec_as_function_call (watch->watch, object, 4, args, &ret);
-      swfdec_as_watch_unref (watch);
-      var = swfdec_as_object_hash_lookup_with_prototype (object, variable,
-	  NULL);
-      if (swfdec_as_context_is_aborted (context))
-	return;
-      if (var == NULL) {
-	SWFDEC_INFO ("watch removed variable %s", variable);
-	return;
-      }
-    }
-
-    var->value = ret;
-  } else {
-    watch = NULL;
-  }
-
-  if (object->array) {
-    /* if we changed to smaller length, destroy all values that are outside it */
-    if (!swfdec_strcmp (context->version, variable,
-	  SWFDEC_AS_STR_length))
-    {
-      gint32 length_old = swfdec_as_array_get_length (object);
-      gint32 length_new = swfdec_as_value_to_integer (context, val);
-      length_new = MAX (0, length_new);
-      if (length_old > length_new) {
-	swfdec_as_array_remove_range (object, length_new,
-	    length_old - length_new);
-      }
-    }
-  }
-
-  if (var->get) {
-    if (var->set) {
-      SwfdecAsValue tmp;
-      swfdec_as_function_call (var->set, object, 1, val, &tmp);
-    }
-  } else if (watch == NULL) {
-    var->value = *val;
-  }
-
-  if (variable == SWFDEC_AS_STR___proto__) {
-    if (SWFDEC_AS_VALUE_IS_OBJECT(val)) {
-      object->prototype = SWFDEC_AS_VALUE_GET_OBJECT (val);
-      object->prototype_flags = var->flags;
-    } else {
-      object->prototype = NULL;
-      object->prototype_flags = 0;
-    }
-  }
-
-  /* If we are an array, do the special magic now */
-  if (object->array) {
-    char *end;
-    gint32 l;
-
-    /* if we added new value outside the current length, set a bigger length */
-    l = strtoul (variable, &end, 10);
-    if (*end == '\0') {
-      SwfdecAsValue tmp;
-      gint32 length;
-      swfdec_as_object_get_variable (object, SWFDEC_AS_STR_length, &tmp);
-      length = swfdec_as_value_to_integer (context, &tmp);
-      if (l >= length) {
-	object->array = FALSE;
-	swfdec_as_value_set_integer (swfdec_gc_object_get_context (object), &tmp, l + 1);
-	swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_length, &tmp,
-	    SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
-	object->array = TRUE;
-      }
-    }
-  }
-}
-
 typedef struct {
   SwfdecAsObject *		object;
   SwfdecAsVariableForeach	func;
@@ -713,8 +569,6 @@ swfdec_as_object_class_init (SwfdecAsObjectClass *klass)
   object_class->dispose = swfdec_as_object_dispose;
 
   gc_class->mark = swfdec_as_object_mark;
-
-  klass->set = swfdec_as_object_do_set;
 }
 
 static void
@@ -808,20 +662,157 @@ void
 swfdec_as_object_set_variable_and_flags (SwfdecAsObject *object,
     const char *variable, const SwfdecAsValue *value, guint default_flags)
 {
-  SwfdecAsObjectClass *klass;
+  SwfdecAsVariable *var;
+  SwfdecAsWatch *watch;
+  SwfdecAsObject *proto;
+  SwfdecAsContext *context;
 
   g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
   g_return_if_fail (variable != NULL);
   g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
 
+  context = swfdec_gc_object_get_context (object);
+
+  /* FIXME: in front of or after debugger check? */
+  if (!swfdec_as_variable_name_is_valid (variable) ||
+      swfdec_as_context_is_aborted (context) ||
+      object->super)
+    return;
+
   if (swfdec_gc_object_get_context (object)->debugger) {
     SwfdecAsDebugger *debugger = swfdec_gc_object_get_context (object)->debugger;
     SwfdecAsDebuggerClass *dklass = SWFDEC_AS_DEBUGGER_GET_CLASS (debugger);
     if (dklass->set_variable)
       dklass->set_variable (debugger, swfdec_gc_object_get_context (object), object, variable, value);
   }
-  klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
-  klass->set (object, variable, value, default_flags);
+
+  if (object->movie) {
+    SwfdecMovie *movie = SWFDEC_MOVIE (object);
+
+    guint prop_id = swfdec_movie_property_lookup (variable);
+    if (prop_id != G_MAXUINT) {
+      swfdec_movie_property_set (movie, prop_id, value);
+      return;
+    }
+
+    swfdec_movie_call_variable_listeners (movie, variable, value);
+  }
+
+  var = swfdec_as_object_hash_lookup_with_prototype (object, variable, &proto);
+
+  // if variable is disabled in this version
+  if (var != NULL && !swfdec_as_object_variable_enabled_in_version (var, context->version)) {
+    if (proto == NULL) {
+      // it's at the top level, remove getter and setter plus overwrite
+      var->get = NULL;
+      var->set = NULL;
+    } else {
+      // it's in proto, we create a new one at the top level
+      var = NULL;
+    }
+  }
+
+  if (var == NULL) {
+    var = swfdec_as_object_hash_create (object, variable, default_flags);
+    if (var == NULL)
+      return;
+  } else {
+    if (var->flags & SWFDEC_AS_VARIABLE_CONSTANT)
+      return;
+    // remove the flags that could make this variable hidden
+    if (context->version == 6) {
+      // version 6, so let's forget SWFDEC_AS_VARIABLE_VERSION_7_UP flag, oops!
+      // we will still set the value though, even if that flag is set
+      var->flags &= ~(SWFDEC_AS_VARIABLE_VERSION_6_UP |
+	  SWFDEC_AS_VARIABLE_VERSION_NOT_6 | SWFDEC_AS_VARIABLE_VERSION_8_UP |
+	  SWFDEC_AS_VARIABLE_VERSION_9_UP);
+    } else {
+      var->flags &= ~(SWFDEC_AS_VARIABLE_VERSION_6_UP |
+	  SWFDEC_AS_VARIABLE_VERSION_NOT_6 | SWFDEC_AS_VARIABLE_VERSION_7_UP |
+	  SWFDEC_AS_VARIABLE_VERSION_8_UP | SWFDEC_AS_VARIABLE_VERSION_9_UP);
+    }
+  }
+  if (object->watches) {
+    SwfdecAsValue ret = *value;
+    watch = g_hash_table_lookup (object->watches, variable);
+    /* FIXME: figure out if this limit here is correct. Add a watch in Flash 7 
+     * and set a variable using Flash 6 */
+    if (watch && swfdec_as_watch_can_recurse (watch)) {
+      SwfdecAsValue args[4];
+      SWFDEC_AS_VALUE_SET_STRING (&args[0], variable);
+      args[1] = var->value;
+      args[2] = *value;
+      args[3] = watch->watch_data;
+      swfdec_as_watch_ref (watch);
+      swfdec_as_function_call (watch->watch, object, 4, args, &ret);
+      swfdec_as_watch_unref (watch);
+      var = swfdec_as_object_hash_lookup_with_prototype (object, variable, NULL);
+      if (var == NULL) {
+	SWFDEC_INFO ("watch removed variable %s", variable);
+	return;
+      }
+    }
+
+    var->value = ret;
+  } else {
+    watch = NULL;
+  }
+
+  if (object->array) {
+    /* if we changed to smaller length, destroy all values that are outside it */
+    if (!swfdec_strcmp (context->version, variable,
+	  SWFDEC_AS_STR_length))
+    {
+      gint32 length_old = swfdec_as_array_get_length (object);
+      gint32 length_new = swfdec_as_value_to_integer (context, value);
+      length_new = MAX (0, length_new);
+      if (length_old > length_new) {
+	swfdec_as_array_remove_range (object, length_new,
+	    length_old - length_new);
+      }
+    }
+  }
+
+  if (var->get) {
+    if (var->set) {
+      SwfdecAsValue tmp;
+      swfdec_as_function_call (var->set, object, 1, value, &tmp);
+    }
+  } else if (watch == NULL) {
+    var->value = *value;
+  }
+
+  if (variable == SWFDEC_AS_STR___proto__) {
+    if (SWFDEC_AS_VALUE_IS_OBJECT(value)) {
+      object->prototype = SWFDEC_AS_VALUE_GET_OBJECT (value);
+      object->prototype_flags = var->flags;
+    } else {
+      object->prototype = NULL;
+      object->prototype_flags = 0;
+    }
+  }
+
+  /* If we are an array, do the special magic now */
+  if (object->array) {
+    char *end;
+    gint32 l;
+
+    /* if we added new value outside the current length, set a bigger length */
+    l = strtoul (variable, &end, 10);
+    if (*end == '\0') {
+      SwfdecAsValue tmp;
+      gint32 length;
+      swfdec_as_object_get_variable (object, SWFDEC_AS_STR_length, &tmp);
+      length = swfdec_as_value_to_integer (context, &tmp);
+      if (l >= length) {
+	object->array = FALSE;
+	swfdec_as_value_set_integer (swfdec_gc_object_get_context (object), &tmp, l + 1);
+	swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_length, &tmp,
+	    SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+	object->array = TRUE;
+      }
+    }
+  }
 }
 
 /**
diff --git a/swfdec/swfdec_as_object.h b/swfdec/swfdec_as_object.h
index 8e9670c..b388d9e 100644
--- a/swfdec/swfdec_as_object.h
+++ b/swfdec/swfdec_as_object.h
@@ -73,12 +73,6 @@ struct _SwfdecAsObject {
 
 struct _SwfdecAsObjectClass {
   SwfdecGcObjectClass	object_class;
-
-  /* set the variable - and return it (or NULL on error) */
-  void			(* set)			(SwfdecAsObject *	object,
-						 const char *		variable,
-						 const SwfdecAsValue *	val,
-						 guint			default_flags);
 };
 
 GType		swfdec_as_object_get_type	(void);
diff --git a/swfdec/swfdec_movie.c b/swfdec/swfdec_movie.c
index cbdc89a..f4a91f7 100644
--- a/swfdec/swfdec_movie.c
+++ b/swfdec/swfdec_movie.c
@@ -1170,7 +1170,7 @@ swfdec_movie_remove_variable_listener (SwfdecMovie *movie,
     g_slist_remove (movie->variable_listeners, iter->data);
 }
 
-static void
+void
 swfdec_movie_call_variable_listeners (SwfdecMovie *movie, const char *name,
     const SwfdecAsValue *val)
 {
@@ -1188,29 +1188,6 @@ swfdec_movie_call_variable_listeners (SwfdecMovie *movie, const char *name,
   }
 }
 
-static void
-swfdec_movie_set_variable (SwfdecAsObject *object, const char *variable, 
-    const SwfdecAsValue *val, guint flags)
-{
-  SwfdecMovie *movie = SWFDEC_MOVIE (object);
-  guint prop_id;
-
-  movie = swfdec_movie_resolve (movie);
-  if (movie == NULL)
-    return;
-  object = SWFDEC_AS_OBJECT (movie);
-
-  prop_id = swfdec_movie_property_lookup (variable);
-  if (prop_id != G_MAXUINT) {
-    swfdec_movie_property_set (movie, prop_id, val);
-    return;
-  }
-
-  swfdec_movie_call_variable_listeners (movie, variable, val);
-
-  SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->set (object, variable, val, flags);
-}
-
 typedef struct {
   SwfdecMovie *		movie;
   int			depth;
@@ -1365,7 +1342,6 @@ swfdec_movie_class_init (SwfdecMovieClass * movie_class)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (movie_class);
   SwfdecGcObjectClass *gc_class = SWFDEC_GC_OBJECT_CLASS (movie_class);
-  SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (movie_class);
 
   object_class->constructor = swfdec_movie_constructor;
   object_class->dispose = swfdec_movie_dispose;
@@ -1374,8 +1350,6 @@ swfdec_movie_class_init (SwfdecMovieClass * movie_class)
 
   gc_class->mark = swfdec_movie_mark;
 
-  asobject_class->set = swfdec_movie_set_variable;
-
   signals[MATRIX_CHANGED] = g_signal_new ("matrix-changed", G_TYPE_FROM_CLASS (movie_class),
       G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
       G_TYPE_NONE, 0);
diff --git a/swfdec/swfdec_movie.h b/swfdec/swfdec_movie.h
index f00098a..747e912 100644
--- a/swfdec/swfdec_movie.h
+++ b/swfdec/swfdec_movie.h
@@ -232,6 +232,10 @@ void		swfdec_movie_property_set	(SwfdecMovie *		movie,
 void		swfdec_movie_property_get	(SwfdecMovie *		movie,
 						 guint			id, 
 						 SwfdecAsValue *	val);
+void		swfdec_movie_call_variable_listeners 
+						(SwfdecMovie *		movie,
+						 const char *		name,
+						 const SwfdecAsValue *	val);
 void		swfdec_movie_remove		(SwfdecMovie *		movie);
 void		swfdec_movie_destroy		(SwfdecMovie *		movie);
 void		swfdec_movie_set_static_properties 
commit bec58d0485705dcffa0b1e5a9294b97e9b3686ad
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 22:52:36 2008 +0100

    make foreach vfunc go away

diff --git a/swfdec/swfdec_as_object.c b/swfdec/swfdec_as_object.c
index 6ae6283..62a5ec5 100644
--- a/swfdec/swfdec_as_object.c
+++ b/swfdec/swfdec_as_object.c
@@ -591,16 +591,6 @@ swfdec_as_object_hash_foreach (gpointer key, gpointer value, gpointer data)
   fdata->retval = fdata->func (fdata->object, key, &var->value, var->flags, fdata->data);
 }
 
-/* FIXME: does not do Adobe Flash's order for Enumerate actions */
-static gboolean
-swfdec_as_object_do_foreach (SwfdecAsObject *object, SwfdecAsVariableForeach func, gpointer data)
-{
-  ForeachData fdata = { object, func, data, TRUE };
-
-  g_hash_table_foreach (object->properties, swfdec_as_object_hash_foreach, &fdata);
-  return fdata.retval;
-}
-
 typedef struct {
   SwfdecAsObject *		object;
   SwfdecAsVariableForeachRemove	func;
@@ -725,7 +715,6 @@ swfdec_as_object_class_init (SwfdecAsObjectClass *klass)
   gc_class->mark = swfdec_as_object_mark;
 
   klass->set = swfdec_as_object_do_set;
-  klass->foreach = swfdec_as_object_do_foreach;
 }
 
 static void
@@ -1163,14 +1152,32 @@ gboolean
 swfdec_as_object_foreach (SwfdecAsObject *object, SwfdecAsVariableForeach func,
     gpointer data)
 {
-  SwfdecAsObjectClass *klass;
+  ForeachData fdata = { object, func, data, TRUE };
 
   g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
   g_return_val_if_fail (func != NULL, FALSE);
 
-  klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
-  g_return_val_if_fail (klass->foreach != NULL, FALSE);
-  return klass->foreach (object, func, data);
+  /* FIXME: does not do Adobe Flash's order for Enumerate actions */
+  g_hash_table_foreach (object->properties, swfdec_as_object_hash_foreach, &fdata);
+  if (!fdata.retval)
+    return FALSE;
+
+  if (object->movie) {
+    SwfdecMovie *movie = SWFDEC_MOVIE (object);
+    SwfdecAsValue val;
+    GList *walk;
+
+    for (walk = movie->list; walk; walk = walk->next) {
+      SwfdecMovie *cur = walk->data;
+      if (cur->original_name == SWFDEC_AS_STR_EMPTY)
+	continue;
+      SWFDEC_AS_VALUE_SET_MOVIE (&val, cur);
+      if (!func (object, cur->name, &val, 0, data))
+	return FALSE;
+    }
+  }
+
+  return TRUE;
 }
 
 /*** SIMPLIFICATIONS ***/
diff --git a/swfdec/swfdec_as_object.h b/swfdec/swfdec_as_object.h
index bef06f7..8e9670c 100644
--- a/swfdec/swfdec_as_object.h
+++ b/swfdec/swfdec_as_object.h
@@ -79,10 +79,6 @@ struct _SwfdecAsObjectClass {
 						 const char *		variable,
 						 const SwfdecAsValue *	val,
 						 guint			default_flags);
-  /* call with every variable until func returns FALSE */
-  gboolean		(* foreach)		(SwfdecAsObject *	object,
-						 SwfdecAsVariableForeach func,
-						 gpointer		data);
 };
 
 GType		swfdec_as_object_get_type	(void);
diff --git a/swfdec/swfdec_movie.c b/swfdec/swfdec_movie.c
index f008b70..cbdc89a 100644
--- a/swfdec/swfdec_movie.c
+++ b/swfdec/swfdec_movie.c
@@ -1211,27 +1211,6 @@ swfdec_movie_set_variable (SwfdecAsObject *object, const char *variable,
   SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->set (object, variable, val, flags);
 }
 
-static gboolean
-swfdec_movie_foreach_variable (SwfdecAsObject *object, SwfdecAsVariableForeach func, gpointer data)
-{
-  SwfdecMovie *movie = SWFDEC_MOVIE (object);
-  SwfdecAsValue val;
-  GList *walk;
-  gboolean ret;
-
-  ret = SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->foreach (object, func, data);
-
-  for (walk = movie->list; walk && ret; walk = walk->next) {
-    SwfdecMovie *cur = walk->data;
-    if (cur->original_name == SWFDEC_AS_STR_EMPTY)
-      continue;
-    SWFDEC_AS_VALUE_SET_MOVIE (&val, walk->data);
-    ret &= func (object, cur->name, &val, 0, data);
-  }
-
-  return ret;
-}
-
 typedef struct {
   SwfdecMovie *		movie;
   int			depth;
@@ -1396,7 +1375,6 @@ swfdec_movie_class_init (SwfdecMovieClass * movie_class)
   gc_class->mark = swfdec_movie_mark;
 
   asobject_class->set = swfdec_movie_set_variable;
-  asobject_class->foreach = swfdec_movie_foreach_variable;
 
   signals[MATRIX_CHANGED] = g_signal_new ("matrix-changed", G_TYPE_FROM_CLASS (movie_class),
       G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
commit 474eddad61c9c2b620b069265f62491c33f7a58a
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 22:09:37 2008 +0100

    remove the vfunc for swfdec_as_object_get_variable

diff --git a/swfdec/swfdec_as_object.c b/swfdec/swfdec_as_object.c
index 1de27e3..6ae6283 100644
--- a/swfdec/swfdec_as_object.c
+++ b/swfdec/swfdec_as_object.c
@@ -38,6 +38,7 @@
 #include "swfdec_as_super.h"
 #include "swfdec_debug.h"
 #include "swfdec_movie.h"
+#include "swfdec_resource.h"
 #include "swfdec_utils.h"
 
 /**
@@ -306,31 +307,6 @@ swfdec_as_object_variable_enabled_in_version (SwfdecAsVariable *var,
   return TRUE;
 }
 
-static gboolean
-swfdec_as_object_do_get (SwfdecAsObject *object, SwfdecAsObject *orig,
-    const char *variable, SwfdecAsValue *val, guint *flags)
-{
-  SwfdecAsVariable *var;
-  
-  var = swfdec_as_object_hash_lookup (object, variable);
-  if (var == NULL)
-    return FALSE;
-
-  /* variable flag checks */
-  if (!swfdec_as_object_variable_enabled_in_version (var,
-	swfdec_gc_object_get_context (object)->version))
-    return FALSE;
-
-  if (var->get) {
-    swfdec_as_function_call (var->get, orig, 0, NULL, val);
-    *flags = var->flags;
-  } else {
-    *val = var->value;
-    *flags = var->flags;
-  }
-  return TRUE;
-}
-
 static SwfdecAsWatch *
 swfdec_as_watch_new (SwfdecAsFunction *function)
 {
@@ -748,7 +724,6 @@ swfdec_as_object_class_init (SwfdecAsObjectClass *klass)
 
   gc_class->mark = swfdec_as_object_mark;
 
-  klass->get = swfdec_as_object_do_get;
   klass->set = swfdec_as_object_do_set;
   klass->foreach = swfdec_as_object_do_foreach;
 }
@@ -920,7 +895,7 @@ gboolean
 swfdec_as_object_get_variable_and_flags (SwfdecAsObject *object, 
     const char *variable, SwfdecAsValue *value, guint *flags, SwfdecAsObject **pobject)
 {
-  SwfdecAsObjectClass *klass;
+  SwfdecAsContext *context;
   guint i;
   SwfdecAsValue tmp_val;
   guint tmp_flags;
@@ -929,6 +904,7 @@ swfdec_as_object_get_variable_and_flags (SwfdecAsObject *object,
   g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
   g_return_val_if_fail (variable != NULL, FALSE);
 
+  context = swfdec_gc_object_get_context (object);
   if (value == NULL)
     value = &tmp_val;
   if (flags == NULL)
@@ -946,23 +922,64 @@ swfdec_as_object_get_variable_and_flags (SwfdecAsObject *object,
 
   resolve = NULL;
   for (i = 0; i <= SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT && cur != NULL; i++) {
-    klass = SWFDEC_AS_OBJECT_GET_CLASS (cur);
-    if (klass->get (cur, object, variable, value, flags)) {
+    SwfdecAsVariable *var;
+    
+    var = swfdec_as_object_hash_lookup (cur, variable);
+    if (var != NULL &&
+	swfdec_as_object_variable_enabled_in_version (var, context->version)) {
+      if (var->get) {
+	swfdec_as_function_call (var->get, object, 0, NULL, value);
+	*flags = var->flags;
+      } else {
+	*value = var->value;
+	*flags = var->flags;
+      }
       *pobject = cur;
       return TRUE;
     }
+
+    if (cur->movie) {
+      SwfdecMovie *movie, *ret;
+      guint prop_id;
+  
+      movie = SWFDEC_MOVIE (cur);
+
+      if (context->version > 5 && variable == SWFDEC_AS_STR__global) {
+	/* FIXME: current global or movie's global? */
+	SWFDEC_AS_VALUE_SET_OBJECT (value, swfdec_as_relay_get_as_object (
+	      SWFDEC_AS_RELAY (movie->resource->sandbox)));
+	*flags = 0;
+	*pobject = cur;
+	return TRUE;
+      }
+  
+      ret = swfdec_movie_get_by_name (movie, variable, FALSE);
+      if (ret) {
+	SWFDEC_AS_VALUE_SET_MOVIE (value, ret);
+	*flags = 0;
+	*pobject = cur;
+	return TRUE;
+      }
+
+      prop_id = swfdec_movie_property_lookup (variable);
+      if (prop_id != G_MAXUINT) {
+	swfdec_movie_property_get (movie, prop_id, value);
+	*flags = 0;
+	*pobject = cur;
+	return TRUE;
+      }
+    }
+
     if (resolve == NULL) {
-      SwfdecAsVariable *var =
-	swfdec_as_object_hash_lookup (cur, SWFDEC_AS_STR___resolve);
+      var = swfdec_as_object_hash_lookup (cur, SWFDEC_AS_STR___resolve);
 
-      if (var != NULL && (swfdec_gc_object_get_context (object)->version <= 6 ||
-	    SWFDEC_AS_VALUE_IS_COMPOSITE (&var->value)))
+      if (var != NULL && (context->version <= 6 || SWFDEC_AS_VALUE_IS_COMPOSITE (&var->value)))
 	resolve = cur;
     }
     cur = swfdec_as_object_get_prototype_internal (cur);
   }
   if (i > SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT) {
-    swfdec_as_context_abort (swfdec_gc_object_get_context (object), "Prototype recursion limit exceeded");
+    swfdec_as_context_abort (context, "Prototype recursion limit exceeded");
     SWFDEC_AS_VALUE_SET_UNDEFINED (value);
     *flags = 0;
     *pobject = NULL;
@@ -972,12 +989,10 @@ swfdec_as_object_get_variable_and_flags (SwfdecAsObject *object,
     SwfdecAsValue argv;
     SwfdecAsVariable *var;
     SwfdecAsFunction *fun;
-    SwfdecAsContext *context;
 
     *flags = 0;
     *pobject = resolve;
     SWFDEC_AS_VALUE_SET_UNDEFINED (value);
-    context = swfdec_gc_object_get_context (resolve);
 
     var = swfdec_as_object_hash_lookup (resolve, SWFDEC_AS_STR___resolve);
     g_assert (var != NULL);
diff --git a/swfdec/swfdec_as_object.h b/swfdec/swfdec_as_object.h
index addf1de..bef06f7 100644
--- a/swfdec/swfdec_as_object.h
+++ b/swfdec/swfdec_as_object.h
@@ -74,12 +74,6 @@ struct _SwfdecAsObject {
 struct _SwfdecAsObjectClass {
   SwfdecGcObjectClass	object_class;
 
-  /* get the value and flags for a variables */
-  gboolean	      	(* get)			(SwfdecAsObject *       object,
-						 SwfdecAsObject *	orig,
-						 const char *		variable,
-						 SwfdecAsValue *	val,
-						 guint *      		flags);
   /* set the variable - and return it (or NULL on error) */
   void			(* set)			(SwfdecAsObject *	object,
 						 const char *		variable,
diff --git a/swfdec/swfdec_movie.c b/swfdec/swfdec_movie.c
index ed62220..f008b70 100644
--- a/swfdec/swfdec_movie.c
+++ b/swfdec/swfdec_movie.c
@@ -1122,47 +1122,6 @@ swfdec_movie_get_root (SwfdecMovie *movie)
   return movie;
 }
 
-static gboolean
-swfdec_movie_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig,
-    const char *variable, SwfdecAsValue *val, guint *flags)
-{
-  SwfdecMovie *movie, *ret;
-  guint prop_id;
-  
-  movie = SWFDEC_MOVIE (object);
-  movie = swfdec_movie_resolve (movie);
-  if (movie == NULL)
-    return FALSE;
-  object = SWFDEC_AS_OBJECT (movie);
-
-  if (SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->get (object, orig, variable, val, flags))
-    return TRUE;
-
-  /* FIXME: check that this is correct */
-  if (swfdec_gc_object_get_context (object)->version > 5 && variable == SWFDEC_AS_STR__global) {
-    SWFDEC_AS_VALUE_SET_OBJECT (val, swfdec_as_relay_get_as_object (
-	  SWFDEC_AS_RELAY (movie->resource->sandbox)));
-    *flags = 0;
-    return TRUE;
-  }
-  
-  ret = swfdec_movie_get_by_name (movie, variable, FALSE);
-  if (ret) {
-    SWFDEC_AS_VALUE_SET_MOVIE (val, ret);
-    *flags = 0;
-    return TRUE;
-  }
-
-  prop_id = swfdec_movie_property_lookup (variable);
-  if (prop_id != G_MAXUINT) {
-    swfdec_movie_property_get (movie, prop_id, val);
-    *flags = 0;
-    return TRUE;
-  }
-
-  return FALSE;
-}
-
 void
 swfdec_movie_add_variable_listener (SwfdecMovie *movie, SwfdecAsObject *object,
     const char *name, const SwfdecMovieVariableListenerFunction function)
@@ -1436,7 +1395,6 @@ swfdec_movie_class_init (SwfdecMovieClass * movie_class)
 
   gc_class->mark = swfdec_movie_mark;
 
-  asobject_class->get = swfdec_movie_get_variable;
   asobject_class->set = swfdec_movie_set_variable;
   asobject_class->foreach = swfdec_movie_foreach_variable;
 
commit 5bdab2f08494764ddbe79b0ee9e351d1118a4c42
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 21:58:48 2008 +0100

    resolve movies when getting them
    
    also move the COMPOSITE macros to the private header

diff --git a/swfdec/swfdec_as_context.c b/swfdec/swfdec_as_context.c
index 2e7cfe2..b0516f5 100644
--- a/swfdec/swfdec_as_context.c
+++ b/swfdec/swfdec_as_context.c
@@ -336,7 +336,7 @@ swfdec_as_value_mark (SwfdecAsValue *value)
   g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
 
   if (SWFDEC_AS_VALUE_IS_COMPOSITE (value)) {
-    swfdec_gc_object_mark (SWFDEC_AS_VALUE_GET_COMPOSITE (value));
+    swfdec_gc_object_mark (value->value.object);
   } 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))
diff --git a/swfdec/swfdec_as_frame.c b/swfdec/swfdec_as_frame.c
index 08de247..be4452a 100644
--- a/swfdec/swfdec_as_frame.c
+++ b/swfdec/swfdec_as_frame.c
@@ -25,6 +25,7 @@
 #include "swfdec_as_frame.h"
 #include "swfdec_as_array.h"
 #include "swfdec_as_context.h"
+#include "swfdec_as_internal.h"
 #include "swfdec_as_stack.h"
 #include "swfdec_as_strings.h"
 #include "swfdec_as_super.h"
diff --git a/swfdec/swfdec_as_internal.h b/swfdec/swfdec_as_internal.h
index de49a9d..108f191 100644
--- a/swfdec/swfdec_as_internal.h
+++ b/swfdec/swfdec_as_internal.h
@@ -36,6 +36,18 @@ G_BEGIN_DECLS
 #define SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT 256
 
 /* swfdec_as_types.h */
+#define SWFDEC_AS_VALUE_IS_COMPOSITE(val) (SWFDEC_AS_VALUE_GET_TYPE (val) >= SWFDEC_AS_TYPE_OBJECT)
+#define SWFDEC_AS_VALUE_IS_PRIMITIVE(val) (!SWFDEC_AS_VALUE_IS_COMPOSITE(val))
+#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; \
+} 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_SET_MOVIE(val,m) G_STMT_START { \
diff --git a/swfdec/swfdec_as_types.h b/swfdec/swfdec_as_types.h
index d9b0bf8..4818542 100644
--- a/swfdec/swfdec_as_types.h
+++ b/swfdec/swfdec_as_types.h
@@ -103,17 +103,6 @@ struct _SwfdecAsDoubleValue {
 #define SWFDEC_AS_VALUE_IS_NULL(val) (SWFDEC_AS_VALUE_GET_TYPE (val) == SWFDEC_AS_TYPE_NULL)
 #define SWFDEC_AS_VALUE_SET_NULL(val) (val)->type = SWFDEC_AS_TYPE_NULL
 
-#define SWFDEC_AS_VALUE_IS_COMPOSITE(val) (SWFDEC_AS_VALUE_GET_TYPE (val) >= SWFDEC_AS_TYPE_OBJECT)
-#define SWFDEC_AS_VALUE_IS_PRIMITIVE(val) (!SWFDEC_AS_VALUE_IS_COMPOSITE(val))
-#define SWFDEC_AS_VALUE_GET_COMPOSITE(val) ((val)->value.object)
-#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; \
-} G_STMT_END
-
 #define SWFDEC_AS_VALUE_IS_OBJECT(val) (SWFDEC_AS_VALUE_GET_TYPE (val) == SWFDEC_AS_TYPE_OBJECT)
 #define SWFDEC_AS_VALUE_GET_OBJECT(val) ((val)->value.object)
 #define SWFDEC_AS_VALUE_SET_OBJECT(val,o) G_STMT_START { \
diff --git a/swfdec/swfdec_net_stream.c b/swfdec/swfdec_net_stream.c
index 8f7e8d4..16ba238 100644
--- a/swfdec/swfdec_net_stream.c
+++ b/swfdec/swfdec_net_stream.c
@@ -26,6 +26,7 @@
 #include "swfdec_access.h"
 #include "swfdec_amf.h"
 #include "swfdec_as_frame_internal.h"
+#include "swfdec_as_internal.h"
 #include "swfdec_as_strings.h"
 #include "swfdec_audio_flv.h"
 #include "swfdec_cached_video.h"
commit 42707ce91b515d932516b242524c12c038cb7f52
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 21:16:12 2008 +0100

    fix an uncaught relay conversion

diff --git a/test/swfdec_test_image.c b/test/swfdec_test_image.c
index a988194..7cea961 100644
--- a/test/swfdec_test_image.c
+++ b/test/swfdec_test_image.c
@@ -174,7 +174,8 @@ swfdec_test_image_compare (SwfdecAsContext *cx, SwfdecAsObject *object, guint ar
 	cairo_image_surface_get_stride (image->surface),
 	cairo_image_surface_get_stride (compare->surface),
 	cairo_image_surface_get_stride (diff->surface)) != 0) {
-    SWFDEC_AS_VALUE_SET_OBJECT (retval, SWFDEC_AS_OBJECT (diff));
+    SWFDEC_AS_VALUE_SET_OBJECT (retval, 
+	swfdec_as_relay_get_as_object (SWFDEC_AS_RELAY (diff)));
   } else {
     SWFDEC_AS_VALUE_SET_NULL (retval);
   }
commit bd251dbe3c3ae70dabee72918e56967c23347496
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 19:44:58 2008 +0100

    make the Video properties initialized like XML

diff --git a/swfdec/swfdec_video_movie.c b/swfdec/swfdec_video_movie.c
index 8a996bb..8ef6693 100644
--- a/swfdec/swfdec_video_movie.c
+++ b/swfdec/swfdec_video_movie.c
@@ -102,83 +102,6 @@ swfdec_video_movie_set_ratio (SwfdecMovie *movie)
     swfdec_video_provider_set_ratio (video->provider, movie->original_ratio);
 }
 
-static gboolean
-swfdec_video_movie_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig,
-    const char *variable, SwfdecAsValue *val, guint *flags)
-{
-  guint version = swfdec_gc_object_get_context (object)->version;
-  SwfdecVideoMovie *video;
-  SwfdecAsContext *cx;
-
-  video = SWFDEC_VIDEO_MOVIE (object);
-  cx = swfdec_gc_object_get_context (video);
-
-  if (swfdec_strcmp (version, variable, SWFDEC_AS_STR_width) == 0) {
-    guint w;
-    if (video->provider) {
-      w = swfdec_video_provider_get_width (video->provider);
-    } else {
-      w = 0;
-    }
-    swfdec_as_value_set_integer (cx, val, w);
-    return TRUE;
-  } else if (swfdec_strcmp (version, variable, SWFDEC_AS_STR_height) == 0) {
-    guint h;
-    if (video->provider) {
-      h = swfdec_video_provider_get_height (video->provider);
-    } else {
-      h = 0;
-    }
-    swfdec_as_value_set_integer (cx, val, h);
-    return TRUE;
-  } else if (swfdec_strcmp (version, variable, SWFDEC_AS_STR_deblocking) == 0) {
-    SWFDEC_STUB ("Video.deblocking (get)");
-    swfdec_as_value_set_number (cx, val, 0);
-    return TRUE;
-  } else if (swfdec_strcmp (version, variable, SWFDEC_AS_STR_smoothing) == 0) {
-    SWFDEC_STUB ("Video.smoothing (get)");
-    SWFDEC_AS_VALUE_SET_BOOLEAN (val, FALSE);
-    return TRUE;
-  } else {
-    return SWFDEC_AS_OBJECT_CLASS (swfdec_video_movie_parent_class)->get (
-	object, orig, variable, val, flags);
-  }
-}
-
-static void
-swfdec_video_movie_set_variable (SwfdecAsObject *object, const char *variable,
-    const SwfdecAsValue *val, guint flags)
-{
-  guint version = swfdec_gc_object_get_context (object)->version;
-
-  if (swfdec_strcmp (version, variable, SWFDEC_AS_STR_deblocking) == 0) {
-    SWFDEC_STUB ("Video.deblocking (set)");
-  } else if (swfdec_strcmp (version, variable, SWFDEC_AS_STR_smoothing) == 0) {
-    SWFDEC_STUB ("Video.smoothing (set)");
-  } else {
-    SWFDEC_AS_OBJECT_CLASS (swfdec_video_movie_parent_class)->set (object,
-	variable, val, flags);
-  }
-}
-
-static gboolean
-swfdec_video_movie_foreach_variable (SwfdecAsObject *object, SwfdecAsVariableForeach func, gpointer data)
-{
-  const char *native_variables[] = { SWFDEC_AS_STR_width, SWFDEC_AS_STR_height,
-    SWFDEC_AS_STR_smoothing, SWFDEC_AS_STR_deblocking, NULL };
-  int i;
-
-  for (i = 0; native_variables[i] != NULL; i++) {
-    SwfdecAsValue val;
-    swfdec_as_object_get_variable (object, native_variables[i], &val);
-    if (!func (object, native_variables[i], &val, 0, data))
-      return FALSE;
-  }
-
-  return SWFDEC_AS_OBJECT_CLASS (swfdec_video_movie_parent_class)->foreach (
-      object, func, data);
-}
-
 static void
 swfdec_video_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
 {
@@ -205,6 +128,7 @@ swfdec_video_movie_constructor (GType type, guint n_construct_properties,
 
   movie = SWFDEC_MOVIE (object);
   swfdec_sandbox_use (movie->resource->sandbox);
+  swfdec_video_movie_init_properties (swfdec_gc_object_get_context (movie));
   swfdec_as_object_set_constructor_by_name (SWFDEC_AS_OBJECT (movie), 
       SWFDEC_AS_STR_Video, NULL);
   swfdec_sandbox_unuse (movie->resource->sandbox);
@@ -224,16 +148,11 @@ static void
 swfdec_video_movie_class_init (SwfdecVideoMovieClass * g_class)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (g_class);
-  SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (g_class);
   SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
 
   object_class->constructor = swfdec_video_movie_constructor;
   object_class->dispose = swfdec_video_movie_dispose;
 
-  asobject_class->get = swfdec_video_movie_get_variable;
-  asobject_class->set = swfdec_video_movie_set_variable;
-  asobject_class->foreach = swfdec_video_movie_foreach_variable;
-
   movie_class->update_extents = swfdec_video_movie_update_extents;
   movie_class->render = swfdec_video_movie_render;
   movie_class->invalidate = swfdec_video_movie_invalidate;
diff --git a/swfdec/swfdec_video_movie.h b/swfdec/swfdec_video_movie.h
index 36ea820..3bdc52a 100644
--- a/swfdec/swfdec_video_movie.h
+++ b/swfdec/swfdec_video_movie.h
@@ -55,5 +55,8 @@ void		swfdec_video_movie_set_provider		(SwfdecVideoMovie *	movie,
 							 SwfdecVideoProvider *	provider);
 void		swfdec_video_movie_clear	      	(SwfdecVideoMovie *	movie);
 
+/* in swfdec_video_movie_as.c */
+void		swfdec_video_movie_init_properties	(SwfdecAsContext *	context);
+
 G_END_DECLS
 #endif
diff --git a/swfdec/swfdec_video_movie_as.c b/swfdec/swfdec_video_movie_as.c
index 345cb2b..fccb24e 100644
--- a/swfdec/swfdec_video_movie_as.c
+++ b/swfdec/swfdec_video_movie_as.c
@@ -60,3 +60,100 @@ swfdec_video_clear (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
   swfdec_video_movie_clear (video);
 }
 
+static void
+swfdec_video_get_width (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+    SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+  SwfdecVideoMovie *video;
+  guint w;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_VIDEO_MOVIE, &video, "");
+
+  if (video->provider) {
+    w = swfdec_video_provider_get_width (video->provider);
+  } else {
+    w = 0;
+  }
+  swfdec_as_value_set_integer (cx, rval, w);
+}
+
+static void
+swfdec_video_get_height (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+    SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+  SwfdecVideoMovie *video;
+  guint h;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_VIDEO_MOVIE, &video, "");
+
+  if (video->provider) {
+    h = swfdec_video_provider_get_height (video->provider);
+  } else {
+    h = 0;
+  }
+  swfdec_as_value_set_integer (cx, rval, h);
+}
+
+static void
+swfdec_video_get_deblocking (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+    SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+  SWFDEC_STUB ("Video.deblocking (get)");
+  swfdec_as_value_set_integer (cx, rval, 0);
+}
+
+static void
+swfdec_video_set_deblocking (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+    SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+  SWFDEC_STUB ("Video.deblocking (set)");
+}
+
+static void
+swfdec_video_get_smoothing (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+    SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+  SWFDEC_STUB ("Video.smoothing (get)");
+  SWFDEC_AS_VALUE_SET_BOOLEAN (rval, TRUE);
+}
+
+static void
+swfdec_video_set_smoothing (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+    SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+  SWFDEC_STUB ("Video.smoothing (set)");
+}
+
+void
+swfdec_video_movie_init_properties (SwfdecAsContext *cx)
+{
+  SwfdecAsValue val;
+  SwfdecAsObject *video, *proto;
+
+  // FIXME: We should only initialize if the prototype Object has not been
+  // initialized by any object's constructor with native properties
+  // (TextField, TextFormat, XML, XMLNode at least)
+
+  g_return_if_fail (SWFDEC_IS_AS_CONTEXT (cx));
+
+  swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_Video, &val);
+  if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+    return;
+  video = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+
+  swfdec_as_object_get_variable (video, SWFDEC_AS_STR_prototype, &val);
+  if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+    return;
+  proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+
+  swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_width, 
+      swfdec_video_get_width, NULL);
+  swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_height, 
+      swfdec_video_get_height, NULL);
+  swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_deblocking, 
+      swfdec_video_get_deblocking, swfdec_video_set_deblocking);
+  swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_smoothing, 
+      swfdec_video_get_smoothing, swfdec_video_set_smoothing);
+}
+
+
commit 652c0c899a2bf5178efb5b9eb4d0b8ac1914c1a5
Merge: 596a84e... f935532...
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 18:08:22 2008 +0100

    Merge branch '0.8'
    
    Conflicts:
    
    	swfdec/swfdec_bitmap_data.c
    	swfdec/swfdec_renderer.c

diff --cc swfdec/swfdec_bitmap_data.c
index fe30e0a,a7b1728..2d21725
--- a/swfdec/swfdec_bitmap_data.c
+++ b/swfdec/swfdec_bitmap_data.c
@@@ -795,88 -770,4 +795,88 @@@ swfdec_bitmap_data_construct (SwfdecAsC
      cairo_paint (cr);
      cairo_destroy (cr);
    }
 +  swfdec_as_object_set_relay (object, SWFDEC_AS_RELAY (bitmap));
 +  SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
 +}
 +
 +/*** PUBLIC API ***/
 +
 +guint
 +swfdec_bitmap_data_get_width (SwfdecBitmapData *bitmap)
 +{
 +  g_return_val_if_fail (SWFDEC_IS_BITMAP_DATA (bitmap), 0);
 +
 +  return bitmap->surface ? bitmap->width : 0;
 +}
 +
 +guint
 +swfdec_bitmap_data_get_height (SwfdecBitmapData *bitmap)
 +{
 +  g_return_val_if_fail (SWFDEC_IS_BITMAP_DATA (bitmap), 0);
 +
 +  return bitmap->surface ? bitmap->height : 0;
 +}
 +
 +cairo_pattern_t *
 +swfdec_bitmap_data_get_pattern (SwfdecBitmapData *bitmap, SwfdecRenderer *renderer,
 +    const SwfdecColorTransform *ctrans)
 +{
 +  cairo_pattern_t *pattern;
 +
 +  g_return_val_if_fail (SWFDEC_IS_BITMAP_DATA (bitmap), NULL);
 +  g_return_val_if_fail (SWFDEC_IS_RENDERER (renderer), NULL);
 +  g_return_val_if_fail (ctrans != NULL, NULL);
 +  g_return_val_if_fail (!swfdec_color_transform_is_mask (ctrans), NULL);
 +
 +  /* FIXME: Is this correct for the case where the surface is NULL?
 +   * Do we want a red surface */
 +  if (bitmap->surface == NULL)
 +    return NULL;
 +
 +  if (swfdec_color_transform_is_identity (ctrans)) {
 +    pattern = cairo_pattern_create_for_surface (bitmap->surface);
 +  } else {
 +    /* FIXME: do caching? */
 +    SwfdecRectangle area = { 0, 0, bitmap->width, bitmap->height };
 +    cairo_surface_t *surface = swfdec_renderer_transform (renderer,
 +	bitmap->surface, ctrans, &area);
 +    SWFDEC_FIXME ("unmodified pixels will be treated as -1, not as 0 as in our "
 +	"transform code, but we don't know if a pixel is unmodified.");
 +    pattern = cairo_pattern_create_for_surface (surface);
 +    cairo_surface_destroy (surface);
 +  }
 +
 +  return pattern;
 +}
 +
 +SwfdecColor
 +swfdec_bitmap_data_get_pixel (SwfdecBitmapData *bitmap, guint x, guint y)
 +{
 +  guint8 *addr;
 +
 +  g_return_val_if_fail (SWFDEC_IS_BITMAP_DATA (bitmap), 0);
 +  g_return_val_if_fail (x < bitmap->width, 0);
 +  g_return_val_if_fail (y < bitmap->height, 0);
 +
 +  addr = cairo_image_surface_get_data (bitmap->surface);
 +  addr += cairo_image_surface_get_stride (bitmap->surface) * y;
 +  addr += 4 * x;
-   return *(guint32 *) addr;
++  return *(guint32 *) (gpointer) addr;
  }
 +
 +void
 +swfdec_bitmap_data_set_pixel (SwfdecBitmapData *bitmap, guint x, guint y, SwfdecColor color)
 +{
 +  guint8 *addr;
 +
 +  g_return_if_fail (SWFDEC_IS_BITMAP_DATA (bitmap));
 +  g_return_if_fail (x < bitmap->width);
 +  g_return_if_fail (y < bitmap->height);
 +
 +  addr = cairo_image_surface_get_data (bitmap->surface);
 +  addr += cairo_image_surface_get_stride (bitmap->surface) * y;
 +  addr += 4 * x;
-   *(guint32 *) addr = color;
++  *(guint32 *) (gpointer) addr = color;
 +  swfdec_bitmap_data_invalidate (bitmap, x, y, 1, 1);
 +}
 +
diff --cc swfdec/swfdec_renderer.c
index 48b0bbb,39faa60..3c9b252
--- a/swfdec/swfdec_renderer.c
+++ b/swfdec/swfdec_renderer.c
@@@ -424,30 -417,25 +424,30 @@@ swfdec_renderer_transform (SwfdecRender
  
    /* FIXME: This function should likely be a vfunc. 
     * Or better: it should compile to a shader */
 -  w = cairo_image_surface_get_width (surface);
 -  h = cairo_image_surface_get_height (surface);
 -  sdata = cairo_image_surface_get_data (surface);
 -  sstride = cairo_image_surface_get_stride (surface);
 -  mask = cairo_surface_get_content (surface) | CAIRO_CONTENT_ALPHA ? 
 -    0 : SWFDEC_COLOR_COMBINE (0, 0, 0, 0xFF);
 -
 -  target = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w, h);
 -  tdata = cairo_image_surface_get_data (target);
 -  tstride = cairo_image_surface_get_stride (target);
 -  for (y = 0; y < h; y++) {
 -    for (x = 0; x < w; x++) {
 -      color = ((guint32 *) (gpointer) sdata)[x];
 +  if (cairo_surface_get_content (surface) & CAIRO_CONTENT_ALPHA) {
 +    target = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, rect->width, rect->height);
 +    mask = 0;
 +  } else {
 +    target = cairo_image_surface_create (CAIRO_FORMAT_RGB24, rect->width, rect->height);
 +    mask = SWFDEC_COLOR_COMBINE (0, 0, 0, 0xFF);
 +  }
 +  cairo_surface_set_device_offset (target, -rect->x, -rect->y);
 +
 +  cr = cairo_create (target);
 +  cairo_set_source_surface (cr, surface, 0, 0);
 +  cairo_paint (cr);
 +  cairo_destroy (cr);
 +
 +  data = cairo_image_surface_get_data (target);
 +  stride = cairo_image_surface_get_stride (target);
 +  for (y = 0; y < rect->height; y++) {
 +    for (x = 0; x < rect->width; x++) {
-       color = ((guint32 *) data)[x];
++      color = ((guint32 *) (gpointer) data)[x];
        color |= mask;
        color = swfdec_color_apply_transform_premultiplied (color, trans);
-       ((guint32 *) data)[x] = color;
 -      ((guint32 *) (gpointer) tdata)[x] = color;
++      ((guint32 *) (gpointer) data)[x] = color;
      }
 -    sdata += sstride;
 -    tdata += tstride;
 +    data += stride;
    }
  
    return target;
commit f935532759ade1a3b06bcc94f9a88da7bb5e797a
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 17:11:27 2008 +0100

    fix potential alignmnt problems

diff --git a/swfdec/swfdec_audio_decoder_uncompressed.c b/swfdec/swfdec_audio_decoder_uncompressed.c
index 5371d9f..6a4caf6 100644
--- a/swfdec/swfdec_audio_decoder_uncompressed.c
+++ b/swfdec/swfdec_audio_decoder_uncompressed.c
@@ -59,8 +59,10 @@ swfdec_audio_decoder_uncompressed_upscale (SwfdecBuffer *buffer, SwfdecAudioForm
 	buffer->length - n_samples * 2 * channels);
   }
   ret = swfdec_buffer_new (n_samples * 4 * granularity);
-  src = (gint16 *) buffer->data;
-  dest = (gint16 *) ret->data;
+  /* can be upscaled, because the input buffer and the newly allocated buffer 
+   * are aligned properly */
+  src = (gint16 *) (gpointer) buffer->data;
+  dest = (gint16 *) (gpointer) ret->data;
   for (i = 0; i < n_samples; i++) {
     for (j = 0; j < granularity; j++) {
       *dest++ = src[0];
@@ -96,19 +98,19 @@ static SwfdecBuffer *
 swfdec_audio_decoder_uncompressed_decode_16bit (SwfdecBuffer *buffer)
 {
   SwfdecBuffer *ret;
-  gint16 *src, *dest;
+  SwfdecBits bits;
+  gint16 *dest;
   guint i;
 
   if (buffer->length & 2) {
     SWFDEC_ERROR ("buffer length not a multiple of 16bit");
   }
   ret = swfdec_buffer_new (buffer->length & ~1);
-  src = (gint16 *) buffer->data;
-  dest = (gint16 *) ret->data;
+  swfdec_bits_init (&bits, buffer);
+  dest = (gint16 *) (gpointer) ret->data;
   for (i = 0; i < ret->length; i += 2) {
-    *dest = GINT16_FROM_LE (*src);
+    *dest = swfdec_bits_get_u16 (&bits);
     dest++;
-    src++;
   }
 
   return ret;
commit 3fa1c067d996b1414f2023c6866cecf44eac284f
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 17:11:19 2008 +0100

    fix alignment problems

diff --git a/swfdec/swfdec_bots.c b/swfdec/swfdec_bots.c
index b5d8177..eda1b7a 100644
--- a/swfdec/swfdec_bots.c
+++ b/swfdec/swfdec_bots.c
@@ -178,7 +178,8 @@ swfdec_bots_put_u16 (SwfdecBots *bots, guint i)
   g_return_if_fail (i <= G_MAXUINT16);
 
   swfdec_bots_prepare_bytes (bots, 2);
-  *(guint16 *)bots->ptr = GUINT16_TO_LE (i);
+  bots->ptr[0] = i;
+  bots->ptr[1] = i >> 8;
   bots->ptr += 2;
 }
 
@@ -188,7 +189,8 @@ swfdec_bots_put_s16 (SwfdecBots *bots, int i)
   g_return_if_fail (i >= G_MININT16 && i <= G_MAXINT16);
 
   swfdec_bots_prepare_bytes (bots, 2);
-  *(guint16 *)bots->ptr = GINT16_TO_LE (i);
+  bots->ptr[0] = i;
+  bots->ptr[1] = i >> 8;
   bots->ptr += 2;
 }
 
@@ -198,7 +200,10 @@ swfdec_bots_put_u32 (SwfdecBots *bots, guint i)
   g_return_if_fail (i <= G_MAXUINT32);
 
   swfdec_bots_prepare_bytes (bots, 4);
-  *(guint32 *)bots->ptr = GUINT32_TO_LE (i);
+  bots->ptr[0] = i;
+  bots->ptr[1] = i >> 8;
+  bots->ptr[2] = i >> 16;
+  bots->ptr[3] = i >> 24;
   bots->ptr += 4;
 }
 
commit bdf0e901332300d7da7c589d772d29e97929a92a
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 17:10:10 2008 +0100

    fix bogus alignment warnings on ARM

diff --git a/swfdec/swfdec_bitmap_data.c b/swfdec/swfdec_bitmap_data.c
index dac1dd1..a7b1728 100644
--- a/swfdec/swfdec_bitmap_data.c
+++ b/swfdec/swfdec_bitmap_data.c
@@ -316,7 +316,7 @@ swfdec_bitmap_data_getPixel (SwfdecAsContext *cx, SwfdecAsObject *object,
   addr = cairo_image_surface_get_data (bitmap->surface);
   addr += cairo_image_surface_get_stride (bitmap->surface) * y;
   addr += 4 * x;
-  color = *(SwfdecColor *) addr;
+  color = *(SwfdecColor *) (gpointer) addr;
   color = SWFDEC_COLOR_UNMULTIPLY (color);
   color &= SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0);
   SWFDEC_AS_VALUE_SET_INT (ret, color);
@@ -342,10 +342,10 @@ swfdec_bitmap_data_setPixel (SwfdecAsContext *cx, SwfdecAsObject *object,
   addr = cairo_image_surface_get_data (bitmap->surface);
   addr += cairo_image_surface_get_stride (bitmap->surface) * y;
   addr += 4 * x;
-  old = *(SwfdecColor *) addr;
+  old = *(SwfdecColor *) (gpointer) addr;
   old |= SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0);
   color = old & SWFDEC_COLOR_OPAQUE (color);
-  *(SwfdecColor *) addr = SWFDEC_COLOR_MULTIPLY (color);
+  *(SwfdecColor *) (gpointer) addr = SWFDEC_COLOR_MULTIPLY (color);
   cairo_surface_mark_dirty_rectangle (bitmap->surface, x, y, 1, 1);
   swfdec_bitmap_data_invalidate (bitmap, x, y, 1, 1);
 }
@@ -575,7 +575,7 @@ swfdec_bitmap_data_getPixel32 (SwfdecAsContext *cx, SwfdecAsObject *object,
   addr = cairo_image_surface_get_data (bitmap->surface);
   addr += cairo_image_surface_get_stride (bitmap->surface) * y;
   addr += 4 * x;
-  color = *(SwfdecColor *) addr;
+  color = *(SwfdecColor *) (gpointer) addr;
   color = SWFDEC_COLOR_UNMULTIPLY (color);
   SWFDEC_AS_VALUE_SET_INT (ret, color);
 }
@@ -600,9 +600,9 @@ swfdec_bitmap_data_setPixel32 (SwfdecAsContext *cx, SwfdecAsObject *object,
   addr += cairo_image_surface_get_stride (bitmap->surface) * y;
   addr += 4 * x;
   if (swfdec_surface_has_alpha (bitmap->surface)) {
-    *(SwfdecColor *) addr = SWFDEC_COLOR_MULTIPLY ((SwfdecColor) color);
+    *(SwfdecColor *) (gpointer) addr = SWFDEC_COLOR_MULTIPLY ((SwfdecColor) color);
   } else {
-    *(SwfdecColor *) addr = SWFDEC_COLOR_OPAQUE ((SwfdecColor) color);
+    *(SwfdecColor *) (gpointer) addr = SWFDEC_COLOR_OPAQUE ((SwfdecColor) color);
   }
   cairo_surface_mark_dirty_rectangle (bitmap->surface, x, y, 1, 1);
   swfdec_bitmap_data_invalidate (bitmap, x, y, 1, 1);
diff --git a/swfdec/swfdec_image.c b/swfdec/swfdec_image.c
index 23a6845..328d19b 100644
--- a/swfdec/swfdec_image.c
+++ b/swfdec/swfdec_image.c
@@ -402,7 +402,8 @@ swfdec_image_lossless_load (SwfdecImage *image, SwfdecRenderer *renderer)
     if (palette_size < 256)
       memset (palette + palette_size, 0, (256 - palette_size) * 4);
 
-    pixels = (guint32 *) data;
+    /* cast is safe, we malloc'd the memory above */
+    pixels = (guint32 *) (gpointer) data;
     for (j = 0; j < (guint) image->height; j++) {
       for (i = 0; i < (guint) image->width; i++) {
 	*pixels = palette[indexed_data[i]];
diff --git a/swfdec/swfdec_renderer.c b/swfdec/swfdec_renderer.c
index 259f28a..39faa60 100644
--- a/swfdec/swfdec_renderer.c
+++ b/swfdec/swfdec_renderer.c
@@ -429,10 +429,10 @@ swfdec_renderer_transform (SwfdecRenderer *renderer, cairo_surface_t *surface,
   tstride = cairo_image_surface_get_stride (target);
   for (y = 0; y < h; y++) {
     for (x = 0; x < w; x++) {
-      color = ((guint32 *) sdata)[x];
+      color = ((guint32 *) (gpointer) sdata)[x];
       color |= mask;
       color = swfdec_color_apply_transform_premultiplied (color, trans);
-      ((guint32 *) tdata)[x] = color;
+      ((guint32 *) (gpointer) tdata)[x] = color;
     }
     sdata += sstride;
     tdata += tstride;
commit a6d2d12f1195e45932b980584e99d421c1a45de2
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 17:09:35 2008 +0100

    portability fix: make sure SwfdecColor is 32bit

diff --git a/swfdec/swfdec_types.h b/swfdec/swfdec_types.h
index d8281c9..0bc9bdf 100644
--- a/swfdec/swfdec_types.h
+++ b/swfdec/swfdec_types.h
@@ -9,7 +9,7 @@ G_BEGIN_DECLS
 
 /* Pixel value in the same colorspace as cairo - endian-dependant ARGB.
  * The alpha pixel must be present */
-typedef guint SwfdecColor;
+typedef guint32 SwfdecColor;
 
 /* audio is 44100Hz, framerate is multiple of 256Hz, FLV timestamps are 1000Hz
  * This is a multiple of all these numbers, so we can be always accurate


More information about the Swfdec-commits mailing list