[Swfdec] Branch 'as' - 11 commits - libswfdec/swfdec_as_array.c libswfdec/swfdec_as_context.c libswfdec/swfdec_as_function.c libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_native_function.c libswfdec/swfdec_as_number.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_object.h libswfdec/swfdec_as_script_function.c libswfdec/swfdec_as_super.c libswfdec/swfdec_as_types.c libswfdec/swfdec_as_types.h libswfdec/swfdec_player.c libswfdec/swfdec_sprite_movie.c

Benjamin Otte company at kemper.freedesktop.org
Thu May 24 15:31:42 PDT 2007


 libswfdec/swfdec_as_array.c           |    2 -
 libswfdec/swfdec_as_context.c         |    1 
 libswfdec/swfdec_as_function.c        |   13 ++----
 libswfdec/swfdec_as_interpret.c       |    5 +-
 libswfdec/swfdec_as_native_function.c |    1 
 libswfdec/swfdec_as_number.c          |    2 -
 libswfdec/swfdec_as_object.c          |   20 +++++++---
 libswfdec/swfdec_as_object.h          |    6 ++-
 libswfdec/swfdec_as_script_function.c |    1 
 libswfdec/swfdec_as_super.c           |   67 +++++++++++++++++++++++++++++++---
 libswfdec/swfdec_as_types.c           |   46 ++++++++++++++++-------
 libswfdec/swfdec_as_types.h           |    1 
 libswfdec/swfdec_player.c             |    2 -
 libswfdec/swfdec_sprite_movie.c       |    2 -
 14 files changed, 129 insertions(+), 40 deletions(-)

New commits:
diff-tree b0c6f9795a20bb5e9f98e3f1afe286d81bbef7a2 (from 8e153b97a76a8fa425210bf62dadfcf1aa1e979a)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 24 19:05:05 2007 +0200

    really delete a variable

diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index bee692a..451d5bc 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -150,6 +150,9 @@ swfdec_as_object_do_delete (SwfdecAsObje
   var = g_hash_table_lookup (object->properties, variable);
   g_assert (var);
   swfdec_as_object_free_property (NULL, var, object);
+  if (!g_hash_table_remove (object->properties, variable)) {
+    g_assert_not_reached ();
+  }
 }
 
 typedef struct {
diff-tree 8e153b97a76a8fa425210bf62dadfcf1aa1e979a (from 9750fc7b351d4971b5027d7e7317955c2de4322a)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 24 18:43:33 2007 +0200

    add swfdec_as_value_to_primitive

diff --git a/libswfdec/swfdec_as_types.c b/libswfdec/swfdec_as_types.c
index 07aa538..2004e71 100644
--- a/libswfdec/swfdec_as_types.c
+++ b/libswfdec/swfdec_as_types.c
@@ -230,24 +230,29 @@ swfdec_as_value_to_printable (SwfdecAsCo
 double
 swfdec_as_value_to_number (SwfdecAsContext *context, const SwfdecAsValue *value)
 {
+  SwfdecAsValue tmp;
+
   g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), 0.0);
   g_return_val_if_fail (SWFDEC_IS_AS_VALUE (value), 0.0);
 
-  switch (value->type) {
+  tmp = *value;
+  swfdec_as_value_to_primitive (&tmp);
+
+  switch (tmp.type) {
     case SWFDEC_AS_TYPE_UNDEFINED:
     case SWFDEC_AS_TYPE_NULL:
       return (context->version >= 7) ? NAN : 0.0;
     case SWFDEC_AS_TYPE_BOOLEAN:
-      return SWFDEC_AS_VALUE_GET_BOOLEAN (value) ? 1 : 0;
+      return SWFDEC_AS_VALUE_GET_BOOLEAN (&tmp) ? 1 : 0;
     case SWFDEC_AS_TYPE_NUMBER:
-      return SWFDEC_AS_VALUE_GET_NUMBER (value);
+      return SWFDEC_AS_VALUE_GET_NUMBER (&tmp);
     case SWFDEC_AS_TYPE_STRING:
       {
 	const char *s;
 	char *end;
 	double d;
 	
-	s = SWFDEC_AS_VALUE_GET_STRING (value);
+	s = SWFDEC_AS_VALUE_GET_STRING (&tmp);
 	if (s == SWFDEC_AS_STR_EMPTY)
 	  return NAN;
 	d = g_ascii_strtod (s, &end);
@@ -257,15 +262,6 @@ swfdec_as_value_to_number (SwfdecAsConte
 	  return NAN;
       }
     case SWFDEC_AS_TYPE_OBJECT:
-      {
-	SwfdecAsValue ret;
-	swfdec_as_object_call (SWFDEC_AS_VALUE_GET_OBJECT (value), SWFDEC_AS_STR_valueOf,
-	    0, NULL, &ret);
-	if (SWFDEC_AS_VALUE_IS_OBJECT (&ret))
-	  return NAN;
-	else
-	  return swfdec_as_value_to_number (context, &ret);
-      }
     default:
       g_assert_not_reached ();
       return NAN;
@@ -359,3 +355,27 @@ swfdec_as_value_to_boolean (SwfdecAsCont
   }
 }
 
+/**
+ * swfdec_as_value_to_primitive:
+ * @context: a #SwfdecAsContext
+ * @value: value to convert
+ *
+ * Converts the given @value inline to its primitive value. Primitive values
+ * are values that are not objects. If the value is an object, the object's
+ * valueOf function is called. If the result of that function is still an 
+ * object, @value is set to undefined.
+ **/
+void
+swfdec_as_value_to_primitive (SwfdecAsValue *value)
+{
+  g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
+
+  if (SWFDEC_AS_VALUE_IS_OBJECT (value)) {
+    swfdec_as_object_call (SWFDEC_AS_VALUE_GET_OBJECT (value), SWFDEC_AS_STR_valueOf,
+	0, NULL, value);
+    if (SWFDEC_AS_VALUE_IS_OBJECT (value)) {
+      SWFDEC_AS_VALUE_SET_UNDEFINED (value);
+    }
+  }
+}
+
diff --git a/libswfdec/swfdec_as_types.h b/libswfdec/swfdec_as_types.h
index e89a656..2d02b48 100644
--- a/libswfdec/swfdec_as_types.h
+++ b/libswfdec/swfdec_as_types.h
@@ -215,6 +215,7 @@ double		swfdec_as_value_to_number	(Swfde
 						 const SwfdecAsValue *	value);
 SwfdecAsObject *swfdec_as_value_to_object	(SwfdecAsContext *	context,
 						 const SwfdecAsValue *	value);
+void		swfdec_as_value_to_primitive	(SwfdecAsValue *	value);
 const char *	swfdec_as_value_to_printable	(SwfdecAsContext *	context,
 						 const SwfdecAsValue *	value);
 const char *	swfdec_as_value_to_string	(SwfdecAsContext *	context,
diff-tree 9750fc7b351d4971b5027d7e7317955c2de4322a (from cb168347a7ab95b8918e3d4d737e37bd693fda10)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 24 17:13:15 2007 +0200

    Flash <= 5 has no Function object

diff --git a/libswfdec/swfdec_as_function.c b/libswfdec/swfdec_as_function.c
index 2f0f0e7..1f174fb 100644
--- a/libswfdec/swfdec_as_function.c
+++ b/libswfdec/swfdec_as_function.c
@@ -101,12 +101,6 @@ swfdec_as_function_call (SwfdecAsFunctio
 
 /*** AS CODE ***/
 
-static void
-swfdec_as_function_construct (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
-
-}
-
 void
 swfdec_as_function_init_context (SwfdecAsContext *context, guint version)
 {
@@ -116,9 +110,13 @@ swfdec_as_function_init_context (SwfdecA
   g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
 
   function = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context->global,
-      SWFDEC_AS_STR_Function, 0, swfdec_as_function_construct, 0));
+      SWFDEC_AS_STR_Function, 0, NULL, 0));
   if (!function)
     return;
+  if (version < 6) {
+    /* deleting it later on is easier than duplicating swfdec_as_object_add_function() */
+    swfdec_as_object_delete_variable (context->global, SWFDEC_AS_STR_Function);
+  }
   context->Function = function;
   SWFDEC_AS_VALUE_SET_OBJECT (&val, function);
   swfdec_as_object_set_variable (function, SWFDEC_AS_STR_constructor, &val);
diff-tree cb168347a7ab95b8918e3d4d737e37bd693fda10 (from 12a24b52a62b851c41bc2393312ff5a5f18dc2df)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 24 17:11:28 2007 +0200

    cosmetic fix

diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index 1cd8c89..bee692a 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -353,8 +353,7 @@ swfdec_as_object_get_variable (SwfdecAsO
 }
 
 void
-swfdec_as_object_delete_variable (SwfdecAsObject *object, 
-    const char *variable)
+swfdec_as_object_delete_variable (SwfdecAsObject *object, const char *variable)
 {
   SwfdecAsObjectClass *klass;
   guint i, flags;
diff-tree 12a24b52a62b851c41bc2393312ff5a5f18dc2df (from 88aa562b59d1b3193b06d3bdcf4b8a167a72152d)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 24 16:37:09 2007 +0200

    fix ActionExtends to set __constructor__, not constructor

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index f0d27ce..70f5f78 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -1675,7 +1675,7 @@ swfdec_action_extends (SwfdecAsContext *
   swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (super),
       SWFDEC_AS_STR_prototype, &proto);
   swfdec_as_object_set_variable (prototype, SWFDEC_AS_STR___proto__, &proto);
-  swfdec_as_object_set_variable (prototype, SWFDEC_AS_STR_constructor,
+  swfdec_as_object_set_variable (prototype, SWFDEC_AS_STR___constructor__,
       superclass);
   SWFDEC_AS_VALUE_SET_OBJECT (&proto, prototype);
   swfdec_as_object_set_variable (SWFDEC_AS_VALUE_GET_OBJECT (subclass),
diff-tree 88aa562b59d1b3193b06d3bdcf4b8a167a72152d (from dd221847f7a93e4f7815b967a11d356f3603709d)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 24 16:36:43 2007 +0200

    fix Super to look at the right variables

diff --git a/libswfdec/swfdec_as_super.c b/libswfdec/swfdec_as_super.c
index 5665e1a..6f5902f 100644
--- a/libswfdec/swfdec_as_super.c
+++ b/libswfdec/swfdec_as_super.c
@@ -35,20 +35,29 @@ static SwfdecAsFrame *
 swfdec_as_super_call (SwfdecAsFunction *function)
 {
   SwfdecAsSuper *super = SWFDEC_AS_SUPER (function);
+  SwfdecAsValue val;
+  SwfdecAsFunction *fun;
   SwfdecAsFunctionClass *klass;
   SwfdecAsFrame *frame;
 
-  if (super->constructor == NULL) {
-    SWFDEC_FIXME ("figure out what happens when super doesn't have a constructor");
+  if (super->object == NULL) {
+    SWFDEC_WARNING ("super () called without a this object.");
     return NULL;
   }
-  klass = SWFDEC_AS_FUNCTION_GET_CLASS (super->constructor);
-  frame = klass->call (super->constructor);
+  if (super->object->prototype == NULL)
+    return NULL;
+  swfdec_as_object_get_variable (super->object->prototype, SWFDEC_AS_STR___constructor__, &val);
+  if (!SWFDEC_AS_VALUE_IS_OBJECT (&val) ||
+      !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val)))
+    return NULL;
+
+  klass = SWFDEC_AS_FUNCTION_GET_CLASS (fun);
+  frame = klass->call (fun);
   /* We set the real function here. 1) swfdec_as_context_run() requires it. 
    * And b) it makes more sense reading the constructor's name than reading "super" 
    * in a debugger
    */
-  frame->function = super->constructor;
+  frame->function = fun;
   /* FIXME: this is ugly */
   swfdec_as_frame_set_this (frame, super->object);
   return frame;
@@ -58,18 +67,16 @@ static gboolean
 swfdec_as_super_get (SwfdecAsObject *object, const char *variable,
     SwfdecAsValue *val, guint *flags)
 {
-  SwfdecAsValue value;
   SwfdecAsSuper *super = SWFDEC_AS_SUPER (object);
 
-  if (super->object == NULL)
+  if (super->object == NULL) {
+    SWFDEC_WARNING ("super () called without a this object.");
     return FALSE;
-  swfdec_as_object_get_variable (super->object, SWFDEC_AS_STR___proto__, &value);
-  if (!SWFDEC_AS_VALUE_IS_OBJECT (&value))
-    return FALSE;
-  swfdec_as_object_get_variable (SWFDEC_AS_VALUE_GET_OBJECT (&value), SWFDEC_AS_STR___proto__, &value);
-  if (!SWFDEC_AS_VALUE_IS_OBJECT (&value))
+  }
+  if (super->object->prototype == NULL ||
+      super->object->prototype->prototype == NULL)
     return FALSE;
-  if (!swfdec_as_object_get_variable (SWFDEC_AS_VALUE_GET_OBJECT (&value), variable, val))
+  if (!swfdec_as_object_get_variable (super->object->prototype->prototype, variable, val))
     return FALSE;
   *flags = 0;
   return TRUE;
diff-tree dd221847f7a93e4f7815b967a11d356f3603709d (from 68121d108e78a7fc7ebb1d0b73cf91bae255af09)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 24 16:25:39 2007 +0200

    handle constructor variable sometimes being called __constructor__

diff --git a/libswfdec/swfdec_as_array.c b/libswfdec/swfdec_as_array.c
index 74caec5..b47faac 100644
--- a/libswfdec/swfdec_as_array.c
+++ b/libswfdec/swfdec_as_array.c
@@ -129,7 +129,7 @@ swfdec_as_array_new (SwfdecAsContext *co
   g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
   g_return_val_if_fail (context->Array != NULL, NULL);
   
-  ret = swfdec_as_object_create (SWFDEC_AS_FUNCTION (context->Array), 0, NULL);
+  ret = swfdec_as_object_create (SWFDEC_AS_FUNCTION (context->Array), 0, NULL, FALSE);
   swfdec_as_object_root (ret);
   swfdec_as_context_run (context);
   swfdec_as_object_unroot (ret);
diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index a1a3625..f0d27ce 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -1112,7 +1112,7 @@ swfdec_action_create (SwfdecAsFunction *
   }
   if (n_args)
     swfdec_as_stack_pop_n (stack, n_args);
-  object = swfdec_as_object_create (fun, n_args, swfdec_as_stack_peek (stack, 0));
+  object = swfdec_as_object_create (fun, n_args, swfdec_as_stack_peek (stack, 0), TRUE);
   g_assert (object);
   SWFDEC_AS_VALUE_SET_OBJECT (swfdec_as_stack_peek (stack, 1), object);
 }
diff --git a/libswfdec/swfdec_as_number.c b/libswfdec/swfdec_as_number.c
index 7fff37b..9aed973 100644
--- a/libswfdec/swfdec_as_number.c
+++ b/libswfdec/swfdec_as_number.c
@@ -61,7 +61,7 @@ swfdec_as_number_new (SwfdecAsContext *c
   g_return_val_if_fail (context->Number != NULL, NULL);
   
   SWFDEC_AS_VALUE_SET_NUMBER (&val, number);
-  ret = swfdec_as_object_create (SWFDEC_AS_FUNCTION (context->Number), 1, &val);
+  ret = swfdec_as_object_create (SWFDEC_AS_FUNCTION (context->Number), 1, &val, FALSE);
   swfdec_as_object_root (ret);
   swfdec_as_context_run (context);
   swfdec_as_object_unroot (ret);
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index a6dd6cd..1cd8c89 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -588,6 +588,7 @@ swfdec_as_object_has_function (SwfdecAsO
  * @construct: constructor
  * @n_args: number of arguments
  * @args: arguments to pass to constructor
+ * @scripted: If this variable is %TRUE, the variable "constructor" will be named "__constructor__"
  *
  * Creates a new object for the given constructor and pushes the constructor on
  * top of the stack. To actually run the constructor, you need to call 
@@ -597,7 +598,7 @@ swfdec_as_object_has_function (SwfdecAsO
  *          so the returned object will always be valid.
  **/
 SwfdecAsObject *
-swfdec_as_object_create (SwfdecAsFunction *construct, guint n_args, SwfdecAsValue *args)
+swfdec_as_object_create (SwfdecAsFunction *construct, guint n_args, SwfdecAsValue *args, gboolean scripted)
 {
   SwfdecAsValue val;
   SwfdecAsObject *new;
@@ -620,6 +621,8 @@ swfdec_as_object_create (SwfdecAsFunctio
 	break;
       }
     }
+#if 0
+    This doesn't work. It's supposed to figure out the last native object in the inheritance chain.
     swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (cur), SWFDEC_AS_STR___constructor__, &val);
     if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
       cur = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val);
@@ -628,6 +631,9 @@ swfdec_as_object_create (SwfdecAsFunctio
     } else {
       cur = NULL;
     }
+#else
+    cur = NULL;
+#endif
   }
   if (type == 0) {
     type = SWFDEC_TYPE_AS_OBJECT;
@@ -645,14 +651,14 @@ swfdec_as_object_create (SwfdecAsFunctio
   }
   new = g_object_new (type, NULL);
   swfdec_as_object_add (new, context, size);
-  swfdec_as_object_set_constructor (new, SWFDEC_AS_OBJECT (construct));
+  swfdec_as_object_set_constructor (new, SWFDEC_AS_OBJECT (construct), FALSE);
   swfdec_as_function_call (construct, new, n_args, args, &val);
   context->frame->construct = TRUE;
   return new;
 }
 
 void
-swfdec_as_object_set_constructor (SwfdecAsObject *object, SwfdecAsObject *construct)
+swfdec_as_object_set_constructor (SwfdecAsObject *object, SwfdecAsObject *construct, gboolean scripted)
 {
   SwfdecAsValue val;
   SwfdecAsObject *proto;
@@ -670,7 +676,7 @@ swfdec_as_object_set_constructor (Swfdec
   SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
   swfdec_as_object_set_variable (object, SWFDEC_AS_STR___proto__, &val);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, construct);
-  swfdec_as_object_set_variable (object, SWFDEC_AS_STR_constructor, &val);
+  swfdec_as_object_set_variable (object, scripted ? SWFDEC_AS_STR_constructor : SWFDEC_AS_STR___constructor__, &val);
 }
 
 /*** AS CODE ***/
diff --git a/libswfdec/swfdec_as_object.h b/libswfdec/swfdec_as_object.h
index c834310..6f17010 100644
--- a/libswfdec/swfdec_as_object.h
+++ b/libswfdec/swfdec_as_object.h
@@ -94,9 +94,11 @@ GType		swfdec_as_object_get_type	(void);
 SwfdecAsObject *swfdec_as_object_new		(SwfdecAsContext *    	context);
 SwfdecAsObject *swfdec_as_object_create		(SwfdecAsFunction *	construct,
 						 guint			n_args,
-						 SwfdecAsValue *	args);
+						 SwfdecAsValue *	args,
+						 gboolean		scripted);
 void		swfdec_as_object_set_constructor(SwfdecAsObject *	object,
-						 SwfdecAsObject *	construct);
+						 SwfdecAsObject *	construct,
+						 gboolean		scripted);
 
 void		swfdec_as_object_add		(SwfdecAsObject *     	object,
 						 SwfdecAsContext *    	context,
diff --git a/libswfdec/swfdec_as_super.c b/libswfdec/swfdec_as_super.c
index f4c09a6..5665e1a 100644
--- a/libswfdec/swfdec_as_super.c
+++ b/libswfdec/swfdec_as_super.c
@@ -54,11 +54,56 @@ swfdec_as_super_call (SwfdecAsFunction *
   return frame;
 }
 
+static gboolean
+swfdec_as_super_get (SwfdecAsObject *object, const char *variable,
+    SwfdecAsValue *val, guint *flags)
+{
+  SwfdecAsValue value;
+  SwfdecAsSuper *super = SWFDEC_AS_SUPER (object);
+
+  if (super->object == NULL)
+    return FALSE;
+  swfdec_as_object_get_variable (super->object, SWFDEC_AS_STR___proto__, &value);
+  if (!SWFDEC_AS_VALUE_IS_OBJECT (&value))
+    return FALSE;
+  swfdec_as_object_get_variable (SWFDEC_AS_VALUE_GET_OBJECT (&value), SWFDEC_AS_STR___proto__, &value);
+  if (!SWFDEC_AS_VALUE_IS_OBJECT (&value))
+    return FALSE;
+  if (!swfdec_as_object_get_variable (SWFDEC_AS_VALUE_GET_OBJECT (&value), variable, val))
+    return FALSE;
+  *flags = 0;
+  return TRUE;
+}
+
+static void
+swfdec_as_super_set (SwfdecAsObject *object, const char *variable, const SwfdecAsValue *val)
+{
+  /* This seems to be ignored completely */
+}
+
+static void
+swfdec_as_super_set_flags (SwfdecAsObject *object, const char *variable, guint flags, guint mask)
+{
+  /* if we have no variables, we also can't set its flags... */
+}
+
+static void
+swfdec_as_super_delete (SwfdecAsObject *object, const char *variable)
+{
+  /* if we have no variables... */
+}
+
 static void
 swfdec_as_super_class_init (SwfdecAsSuperClass *klass)
 {
+  SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
   SwfdecAsFunctionClass *function_class = SWFDEC_AS_FUNCTION_CLASS (klass);
 
+  asobject_class->get = swfdec_as_super_get;
+  asobject_class->set = swfdec_as_super_set;
+  asobject_class->set_flags = swfdec_as_super_set_flags;
+  asobject_class->delete = swfdec_as_super_delete;
+
   function_class->call = swfdec_as_super_call;
 }
 
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 74a8e7c..965f021 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -1056,7 +1056,7 @@ swfdec_player_initialize (SwfdecPlayer *
     swfdec_movie_color_init_context (player, version);
     if (context->state == SWFDEC_AS_CONTEXT_NEW) {
       context->state = SWFDEC_AS_CONTEXT_RUNNING;
-      swfdec_as_object_set_constructor (player->roots->data, player->MovieClip);
+      swfdec_as_object_set_constructor (player->roots->data, player->MovieClip, FALSE);
     }
   }
   SWFDEC_INFO ("initializing player to size %ux%u", width, height);
diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
index 5643222..319c878 100644
--- a/libswfdec/swfdec_sprite_movie.c
+++ b/libswfdec/swfdec_sprite_movie.c
@@ -349,7 +349,7 @@ swfdec_sprite_movie_add (SwfdecAsObject 
   } else {
     constructor = SWFDEC_PLAYER (object->context)->MovieClip;
   }
-  swfdec_as_object_set_constructor (object, constructor);
+  swfdec_as_object_set_constructor (object, constructor, FALSE);
   SWFDEC_AS_OBJECT_CLASS (swfdec_sprite_movie_parent_class)->add (object);
 }
 
diff-tree 68121d108e78a7fc7ebb1d0b73cf91bae255af09 (from 014141b47e8d4f0cd3be137a6d2af1cd5efdf356)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 24 14:44:26 2007 +0200

    Super now calls the parent constructor properly

diff --git a/libswfdec/swfdec_as_super.c b/libswfdec/swfdec_as_super.c
index ffbc0b5..f4c09a6 100644
--- a/libswfdec/swfdec_as_super.c
+++ b/libswfdec/swfdec_as_super.c
@@ -44,6 +44,11 @@ swfdec_as_super_call (SwfdecAsFunction *
   }
   klass = SWFDEC_AS_FUNCTION_GET_CLASS (super->constructor);
   frame = klass->call (super->constructor);
+  /* We set the real function here. 1) swfdec_as_context_run() requires it. 
+   * And b) it makes more sense reading the constructor's name than reading "super" 
+   * in a debugger
+   */
+  frame->function = super->constructor;
   /* FIXME: this is ugly */
   swfdec_as_frame_set_this (frame, super->object);
   return frame;
@@ -82,7 +87,7 @@ swfdec_as_super_new (SwfdecAsFrame *fram
     swfdec_as_object_get_variable (frame->thisp, SWFDEC_AS_STR___proto__, &val);
     if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
       SwfdecAsObject *proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
-      swfdec_as_object_get_variable (proto, SWFDEC_AS_STR___constructor__, &val);
+      swfdec_as_object_get_variable (proto, SWFDEC_AS_STR_constructor, &val);
       if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
 	super->constructor = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val);
 	if (!SWFDEC_IS_AS_FUNCTION (super->constructor))
diff-tree 014141b47e8d4f0cd3be137a6d2af1cd5efdf356 (from e62297aa4f0430285e9350049bf06cd4163a831f)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 24 14:44:03 2007 +0200

    set the frame's function in the call vfunc
    
    This is needed to get the riht function in super's implementation

diff --git a/libswfdec/swfdec_as_function.c b/libswfdec/swfdec_as_function.c
index 8a27b9f..2f0f0e7 100644
--- a/libswfdec/swfdec_as_function.c
+++ b/libswfdec/swfdec_as_function.c
@@ -93,7 +93,6 @@ swfdec_as_function_call (SwfdecAsFunctio
   frame->argc = n_args;
   frame->argv = args;
   frame->return_value = return_value;
-  frame->function = function;
   swfdec_as_frame_preload (frame);
   /* FIXME: make this a seperate function? */
   frame->next = context->frame;
diff --git a/libswfdec/swfdec_as_native_function.c b/libswfdec/swfdec_as_native_function.c
index 626a380..4b8d40e 100644
--- a/libswfdec/swfdec_as_native_function.c
+++ b/libswfdec/swfdec_as_native_function.c
@@ -38,6 +38,7 @@ swfdec_as_native_function_call (SwfdecAs
   frame = swfdec_as_frame_new_native (SWFDEC_AS_OBJECT (function)->context);
   g_assert (native->name);
   frame->function_name = native->name;
+  frame->function = function;
   return frame;
 }
 
diff --git a/libswfdec/swfdec_as_script_function.c b/libswfdec/swfdec_as_script_function.c
index 9278ffe..14873d1 100644
--- a/libswfdec/swfdec_as_script_function.c
+++ b/libswfdec/swfdec_as_script_function.c
@@ -38,6 +38,7 @@ swfdec_as_script_function_call (SwfdecAs
   frame = swfdec_as_frame_new (SWFDEC_AS_OBJECT (function)->context, script->script);
   SWFDEC_AS_SCOPE (frame)->next = script->scope;
   frame->scope = SWFDEC_AS_SCOPE (frame);
+  frame->function = function;
   return frame;
 }
 
diff-tree e62297aa4f0430285e9350049bf06cd4163a831f (from eff27731c8ce11922acc4c925c98188d9049296c)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 24 14:43:25 2007 +0200

    fix up ActionExtends to actually do the right thing

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index f5503fb..a1a3625 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -1675,10 +1675,11 @@ swfdec_action_extends (SwfdecAsContext *
   swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (super),
       SWFDEC_AS_STR_prototype, &proto);
   swfdec_as_object_set_variable (prototype, SWFDEC_AS_STR___proto__, &proto);
-  swfdec_as_object_set_variable (prototype, SWFDEC_AS_STR___constructor__,
+  swfdec_as_object_set_variable (prototype, SWFDEC_AS_STR_constructor,
       superclass);
+  SWFDEC_AS_VALUE_SET_OBJECT (&proto, prototype);
   swfdec_as_object_set_variable (SWFDEC_AS_VALUE_GET_OBJECT (subclass),
-      SWFDEC_AS_STR_prototype, superclass);
+      SWFDEC_AS_STR_prototype, &proto);
 }
 
 static gboolean
diff-tree eff27731c8ce11922acc4c925c98188d9049296c (from 37f9a4467fe9e82fdc7fe6d6e73aaf9291cbbe7d)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 24 13:05:12 2007 +0200

    assert we have a script before we start executing it
    
    SwfdecAsSuper being a function broke the IS_NATIVE check above, I wanna have
    that blow up faster next time

diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c
index c88c66a..d44024d 100644
--- a/libswfdec/swfdec_as_context.c
+++ b/libswfdec/swfdec_as_context.c
@@ -426,6 +426,7 @@ start:
     swfdec_as_context_return (context);
     goto start;
   }
+  g_assert (frame->script);
   script = frame->script;
   stack = frame->stack;
   version = SWFDEC_AS_EXTRACT_SCRIPT_VERSION (script->version);


More information about the Swfdec mailing list