[Swfdec-commits] 33 commits - doc/swfdec.types swfdec-gtk/swfdec_gtk_widget.c swfdec/swfdec_as_array.c swfdec/swfdec_as_context.c swfdec/swfdec_as_context.h swfdec/swfdec_as_frame.c swfdec/swfdec_as_frame.h swfdec/swfdec_as_frame_internal.h swfdec/swfdec_as_function.c swfdec/swfdec_as_function.h swfdec/swfdec_as_internal.h swfdec/swfdec_as_interpret.c swfdec/swfdec_as_native_function.c swfdec/swfdec_as_native_function.h swfdec/swfdec_as_number.c swfdec/swfdec_as_object.c swfdec/swfdec_as_object.h swfdec/swfdec_as_script_function.c swfdec/swfdec_as_strings.c swfdec/swfdec_as_super.c swfdec/swfdec_as_super.h swfdec/swfdec_as_types.c swfdec/swfdec_bitmap_data.c swfdec/swfdec_interval.c swfdec/swfdec_load_object_as.c swfdec/swfdec_loadvars_as.c swfdec/swfdec_movie_as_drawing.c swfdec/swfdec_net_stream_as.c swfdec/swfdec_player_as.c swfdec/swfdec_sound_object.c swfdec/swfdec_sprite_movie_as.c swfdec/swfdec_text_field_movie_as.c swfdec/swfdec_text_format.c swfdec/swfdec_video_movie_as.c test/swfdec_test_buffer.c test/swfdec_test_function.c test/swfdec_test_image.c test/swfdec_test_socket.c test/swfdec_test_test.c vivified/core

Benjamin Otte company at kemper.freedesktop.org
Thu Aug 21 05:19:34 PDT 2008


 doc/swfdec.types                    |    1 
 swfdec-gtk/swfdec_gtk_widget.c      |    9 -
 swfdec/swfdec_as_array.c            |    1 
 swfdec/swfdec_as_context.c          |   72 ++++-------
 swfdec/swfdec_as_context.h          |    1 
 swfdec/swfdec_as_frame.c            |  227 ++++++++----------------------------
 swfdec/swfdec_as_frame.h            |   10 -
 swfdec/swfdec_as_frame_internal.h   |   21 +--
 swfdec/swfdec_as_function.c         |   86 ++++---------
 swfdec/swfdec_as_function.h         |   21 ++-
 swfdec/swfdec_as_internal.h         |    5 
 swfdec/swfdec_as_interpret.c        |   80 +++++-------
 swfdec/swfdec_as_native_function.c  |  138 ++++++++++-----------
 swfdec/swfdec_as_native_function.h  |    7 -
 swfdec/swfdec_as_number.c           |    2 
 swfdec/swfdec_as_object.c           |   58 ++-------
 swfdec/swfdec_as_object.h           |    6 
 swfdec/swfdec_as_script_function.c  |   49 +++++--
 swfdec/swfdec_as_strings.c          |    1 
 swfdec/swfdec_as_super.c            |   73 ++++-------
 swfdec/swfdec_as_super.h            |    6 
 swfdec/swfdec_as_types.c            |    1 
 swfdec/swfdec_bitmap_data.c         |   15 --
 swfdec/swfdec_interval.c            |    1 
 swfdec/swfdec_load_object_as.c      |    4 
 swfdec/swfdec_loadvars_as.c         |    4 
 swfdec/swfdec_movie_as_drawing.c    |   21 ---
 swfdec/swfdec_net_stream_as.c       |   42 +++---
 swfdec/swfdec_player_as.c           |   13 --
 swfdec/swfdec_sound_object.c        |   10 -
 swfdec/swfdec_sprite_movie_as.c     |    6 
 swfdec/swfdec_text_field_movie_as.c |    6 
 swfdec/swfdec_text_format.c         |    4 
 swfdec/swfdec_video_movie_as.c      |    2 
 test/swfdec_test_buffer.c           |    4 
 test/swfdec_test_function.c         |    2 
 test/swfdec_test_image.c            |    5 
 test/swfdec_test_socket.c           |    2 
 test/swfdec_test_test.c             |   12 -
 vivified/core/vivi_debugger.c       |    4 
 vivified/core/vivi_function.c       |    4 
 vivified/core/vivi_wrap.c           |    8 -
 vivified/core/vivi_wrap_as.c        |   17 +-
 43 files changed, 414 insertions(+), 647 deletions(-)

New commits:
commit f7d7245c7307b8ef3f14c21fdc2c7232a83c67ff
Merge: 21f94c3... bff97ca...
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Aug 21 13:12:57 2008 +0100

    Merge branch 'master' of ssh://company@git.freedesktop.org/git/swfdec/swfdec

commit 21f94c3e40711897be3eab2a033d5d1420b48ea0
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Aug 5 02:18:14 2008 +0100

    make SwfdecAsFrame a stack-allocated object

diff --git a/swfdec/swfdec_as_frame.c b/swfdec/swfdec_as_frame.c
index 851d7ca..cca50a7 100644
--- a/swfdec/swfdec_as_frame.c
+++ b/swfdec/swfdec_as_frame.c
@@ -286,15 +286,14 @@ swfdec_as_frame_free (SwfdecAsFrame *frame)
   }
 }
 
-SwfdecAsFrame *
-swfdec_as_frame_new (SwfdecAsContext *context, SwfdecScript *script)
+void
+swfdec_as_frame_init (SwfdecAsFrame *frame, SwfdecAsContext *context, SwfdecScript *script)
 {
-  SwfdecAsFrame *frame;
-
-  g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
-  g_return_val_if_fail (script != NULL, NULL);
+  g_return_if_fail (frame != NULL);
+  g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+  g_return_if_fail (script != NULL);
   
-  frame = swfdec_as_frame_new_native (context);
+  swfdec_as_frame_init_native (frame, context);
   frame->script = swfdec_script_ref (script);
   SWFDEC_DEBUG ("new frame for function %s", script->name);
   frame->pc = script->main;
@@ -307,18 +306,14 @@ swfdec_as_frame_new (SwfdecAsContext *context, SwfdecScript *script)
       SWFDEC_ERROR ("couldn't create constant pool");
     }
   }
-  return frame;
 }
 
-SwfdecAsFrame *
-swfdec_as_frame_new_native (SwfdecAsContext *context)
+void
+swfdec_as_frame_init_native (SwfdecAsFrame *frame, SwfdecAsContext *context)
 {
-  SwfdecAsFrame *frame;
-
-  g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+  g_return_if_fail (frame != NULL);
+  g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
   
-  frame = g_new0 (SwfdecAsFrame, 1);
-
   frame->blocks = g_array_new (FALSE, FALSE, sizeof (SwfdecAsFrameBlock));
   frame->block_end = (gpointer) -1;
   frame->stack_begin = context->cur;
@@ -326,8 +321,6 @@ swfdec_as_frame_new_native (SwfdecAsContext *context)
   frame->next = context->frame;
   context->frame = frame;
   context->call_depth++;
-
-  return frame;
 }
 
 /**
diff --git a/swfdec/swfdec_as_frame_internal.h b/swfdec/swfdec_as_frame_internal.h
index 402e051..61c09e9 100644
--- a/swfdec/swfdec_as_frame_internal.h
+++ b/swfdec/swfdec_as_frame_internal.h
@@ -53,9 +53,11 @@ struct _SwfdecAsFrame {
   /* native function */
 };
 
-SwfdecAsFrame *	swfdec_as_frame_new		(SwfdecAsContext *	context,
+void		swfdec_as_frame_init		(SwfdecAsFrame *	frame,
+						 SwfdecAsContext *	context,
 						 SwfdecScript *		script);
-SwfdecAsFrame *	swfdec_as_frame_new_native	(SwfdecAsContext *	context);
+void		swfdec_as_frame_init_native	(SwfdecAsFrame *	frame,
+						 SwfdecAsContext *	context);
 void		swfdec_as_frame_return		(SwfdecAsFrame *	frame,
 						 SwfdecAsValue *	return_value);
 
diff --git a/swfdec/swfdec_as_native_function.c b/swfdec/swfdec_as_native_function.c
index efde7a0..7fbe5b2 100644
--- a/swfdec/swfdec_as_native_function.c
+++ b/swfdec/swfdec_as_native_function.c
@@ -59,8 +59,8 @@ swfdec_as_native_function_call (SwfdecAsFunction *function, SwfdecAsObject *this
 {
   SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (function);
   SwfdecAsContext *cx = swfdec_gc_object_get_context (function);
+  SwfdecAsFrame frame = { NULL, };
   SwfdecAsValue rval = { 0, };
-  SwfdecAsFrame *frame;
   SwfdecAsValue *argv;
 
   if (construct && native->construct_type != 0 &&
@@ -69,42 +69,43 @@ swfdec_as_native_function_call (SwfdecAsFunction *function, SwfdecAsObject *this
     return;
   }
 
-  frame = swfdec_as_frame_new_native (cx);
   g_assert (native->name);
-  frame->construct = construct;
-  frame->function = function;
+
+  swfdec_as_frame_init_native (&frame, cx);
+  frame.construct = construct;
+  frame.function = function;
   /* We copy the target here so we have a proper SwfdecMovie reference inside native 
    * functions. This is for example necessary for swfdec_player_get_movie_by_value()
    * and probably other stuff that does variable lookups inside native functions.
    */
   /* FIXME: copy target or original target? */
-  if (frame->next) {
-    frame->target = frame->next->original_target;
-    frame->original_target = frame->target;
+  if (frame.next) {
+    frame.target = frame.next->original_target;
+    frame.original_target = frame.target;
   }
   if (thisp)
-    swfdec_as_frame_set_this (frame, swfdec_as_object_resolve (thisp));
-  frame->argc = n_args;
-  frame->argv = args;
-  frame->return_value = return_value;
-  frame->construct = construct;
+    swfdec_as_frame_set_this (&frame, swfdec_as_object_resolve (thisp));
+  frame.argc = n_args;
+  frame.argv = args;
+  frame.return_value = return_value;
+  frame.construct = construct;
 
-  if (frame->argc == 0 || frame->argv != NULL) {
+  if (frame.argc == 0 || frame.argv != NULL) {
     /* FIXME FIXME FIXME: no casting here please! */
-    argv = (SwfdecAsValue *) frame->argv;
+    argv = (SwfdecAsValue *) frame.argv;
   } else {
     SwfdecAsStack *stack;
     SwfdecAsValue *cur;
     guint i;
-    if (frame->argc > 128) {
+    if (frame.argc > 128) {
       SWFDEC_FIXME ("allow calling native functions with more than 128 args (this one has %u)",
-	  frame->argc);
-      frame->argc = 128;
+	  frame.argc);
+      frame.argc = 128;
     }
-    argv = g_new (SwfdecAsValue, frame->argc);
+    argv = g_new (SwfdecAsValue, frame.argc);
     stack = cx->stack;
     cur = cx->cur;
-    for (i = 0; i < frame->argc; i++) {
+    for (i = 0; i < frame.argc; i++) {
       if (cur <= &stack->elements[0]) {
 	stack = stack->next;
 	cur = &stack->elements[stack->used_elements];
@@ -113,10 +114,10 @@ swfdec_as_native_function_call (SwfdecAsFunction *function, SwfdecAsObject *this
       argv[i] = *cur;
     }
   }
-  native->native (cx, frame->thisp, frame->argc, argv, &rval);
-  if (argv != frame->argv)
+  native->native (cx, frame.thisp, frame.argc, argv, &rval);
+  if (argv != frame.argv)
     g_free (argv);
-  swfdec_as_frame_return (frame, &rval);
+  swfdec_as_frame_return (&frame, &rval);
 }
 
 static char *
diff --git a/swfdec/swfdec_as_object.c b/swfdec/swfdec_as_object.c
index f2fe821..82c936e 100644
--- a/swfdec/swfdec_as_object.c
+++ b/swfdec/swfdec_as_object.c
@@ -1187,20 +1187,18 @@ swfdec_as_object_add_constructor (SwfdecAsObject *object, const char *name,
 void
 swfdec_as_object_run (SwfdecAsObject *object, SwfdecScript *script)
 {
+  SwfdecAsFrame frame = { NULL, };
   SwfdecAsContext *context;
-  SwfdecAsFrame *frame;
 
   g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
   g_return_if_fail (script != NULL);
 
   context = swfdec_gc_object_get_context (object);
-  frame = swfdec_as_frame_new (context, script);
-  if (frame == NULL)
-    return;
-  swfdec_as_frame_set_this (frame, object);
-  swfdec_as_frame_preload (frame);
+  swfdec_as_frame_init (&frame, context, script);
+  swfdec_as_frame_set_this (&frame, object);
+  swfdec_as_frame_preload (&frame);
   /* we take no prisoners */
-  frame->activation = NULL;
+  frame.activation = NULL;
   swfdec_as_context_run (context);
   swfdec_as_stack_pop (context);
 }
diff --git a/swfdec/swfdec_as_script_function.c b/swfdec/swfdec_as_script_function.c
index d8b0abf..03bfd17 100644
--- a/swfdec/swfdec_as_script_function.c
+++ b/swfdec/swfdec_as_script_function.c
@@ -38,37 +38,37 @@ swfdec_as_script_function_call (SwfdecAsFunction *function, SwfdecAsObject *this
     const SwfdecAsValue *args, SwfdecAsValue *return_value)
 {
   SwfdecAsScriptFunction *script = SWFDEC_AS_SCRIPT_FUNCTION (function);
-  SwfdecAsFrame *frame;
+  SwfdecAsFrame frame = { NULL, };
 
   /* just to be sure... */
   if (return_value)
     SWFDEC_AS_VALUE_SET_UNDEFINED (return_value);
 
-  frame = swfdec_as_frame_new (swfdec_gc_object_get_context (function), script->script);
-  frame->scope_chain = g_slist_concat (frame->scope_chain, g_slist_copy (script->scope_chain));
-  frame->function = function;
-  frame->target = script->target;
-  frame->original_target = script->target;
+  swfdec_as_frame_init (&frame, swfdec_gc_object_get_context (function), script->script);
+  frame.scope_chain = g_slist_concat (frame.scope_chain, g_slist_copy (script->scope_chain));
+  frame.function = function;
+  frame.target = script->target;
+  frame.original_target = script->target;
   /* FIXME: figure out what to do in these situations?
    * It's a problem when called inside swfdec_as_function_call () as the
    * user of that function expects success, but super may fail here */
   /* second check especially for super object */
-  if (thisp != NULL && frame->thisp == NULL) {
-    swfdec_as_frame_set_this (frame, swfdec_as_object_resolve (thisp));
+  if (thisp != NULL && frame.thisp == NULL) {
+    swfdec_as_frame_set_this (&frame, swfdec_as_object_resolve (thisp));
   }
-  frame->argc = n_args;
-  frame->argv = args;
-  frame->return_value = return_value;
-  frame->construct = construct;
+  frame.argc = n_args;
+  frame.argv = args;
+  frame.return_value = return_value;
+  frame.construct = construct;
   if (super_reference == NULL) {
     /* don't create a super object */
   } else if (thisp != NULL) {
-    swfdec_as_super_new (frame, thisp, super_reference);
+    swfdec_as_super_new (&frame, thisp, super_reference);
   } else {
     // FIXME: Does the super object really reference the function when thisp is NULL?
-    swfdec_as_super_new (frame, SWFDEC_AS_OBJECT (function), super_reference);
+    swfdec_as_super_new (&frame, SWFDEC_AS_OBJECT (function), super_reference);
   }
-  swfdec_as_frame_preload (frame);
+  swfdec_as_frame_preload (&frame);
   swfdec_as_context_run (swfdec_gc_object_get_context (function));
 }
 
commit 29fd13932696f1072ae899c74674069e90a66105
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Aug 5 01:57:46 2008 +0100

    move script function specific code to the right file

diff --git a/swfdec/swfdec_as_function.c b/swfdec/swfdec_as_function.c
index 2db0435..1cb573d 100644
--- a/swfdec/swfdec_as_function.c
+++ b/swfdec/swfdec_as_function.c
@@ -23,10 +23,8 @@
 
 #include "swfdec_as_function.h"
 #include "swfdec_as_context.h"
-#include "swfdec_as_frame_internal.h"
 #include "swfdec_as_internal.h"
-#include "swfdec_as_stack.h"
-#include "swfdec_as_super.h"
+#include "swfdec_as_native_function.h"
 #include "swfdec_as_strings.h"
 #include "swfdec_debug.h"
 
@@ -58,32 +56,8 @@ G_DEFINE_ABSTRACT_TYPE (SwfdecAsFunction, swfdec_as_function, SWFDEC_TYPE_AS_OBJ
  */
 
 static void
-swfdec_as_function_do_call_full (SwfdecAsFunction *function, SwfdecAsObject *thisp, 
-    gboolean construct, SwfdecAsObject *super_reference, guint n_args, 
-    const SwfdecAsValue *args, SwfdecAsValue *return_value)
-{
-  SwfdecAsFrame *frame;
-
-  frame = swfdec_as_function_call_no_preload (function, thisp, n_args, args, return_value);
-  if (frame == NULL)
-    return;
-  frame->construct = construct;
-  if (super_reference == NULL) {
-    /* don't create a super object */
-  } else if (thisp != NULL) {
-    swfdec_as_super_new (frame, thisp, super_reference);
-  } else {
-    // FIXME: Does the super object really reference the function when thisp is NULL?
-    swfdec_as_super_new (frame, SWFDEC_AS_OBJECT (function), super_reference);
-  }
-  swfdec_as_frame_preload (frame);
-  swfdec_as_context_run (swfdec_gc_object_get_context (function));
-}
-
-static void
 swfdec_as_function_class_init (SwfdecAsFunctionClass *klass)
 {
-  klass->call = swfdec_as_function_do_call_full;
 }
 
 static void
@@ -122,39 +96,6 @@ swfdec_as_function_set_constructor (SwfdecAsFunction *fun)
       SWFDEC_AS_VARIABLE_VERSION_6_UP);
 }
 
-SwfdecAsFrame *
-swfdec_as_function_call_no_preload (SwfdecAsFunction *function, 
-    SwfdecAsObject *thisp, guint n_args, const SwfdecAsValue *args, 
-    SwfdecAsValue *return_value)
-{
-  SwfdecAsFrame *frame;
-  SwfdecAsFunctionClass *klass;
-
-  g_return_val_if_fail (SWFDEC_IS_AS_FUNCTION (function), NULL);
-  g_return_val_if_fail (thisp == NULL || SWFDEC_IS_AS_OBJECT (thisp), NULL);
-
-  /* just to be sure... */
-  if (return_value)
-    SWFDEC_AS_VALUE_SET_UNDEFINED (return_value);
-
-  klass = SWFDEC_AS_FUNCTION_GET_CLASS (function);
-  g_assert (klass->old_call);
-  frame = klass->old_call (function);
-  /* FIXME: figure out what to do in these situations?
-   * It's a problem when called inside swfdec_as_function_call () as the
-   * user of that function expects success, but super may fail here */
-  if (frame == NULL)
-    return NULL;
-  /* second check especially for super object */
-  if (thisp != NULL && frame->thisp == NULL) {
-    swfdec_as_frame_set_this (frame, swfdec_as_object_resolve (thisp));
-  }
-  frame->argc = n_args;
-  frame->argv = args;
-  frame->return_value = return_value;
-  return frame;
-}
-
 /**
  * swfdec_as_function_call:
  * @function: the #SwfdecAsFunction to call
diff --git a/swfdec/swfdec_as_function.h b/swfdec/swfdec_as_function.h
index 9a0e069..3a45793 100644
--- a/swfdec/swfdec_as_function.h
+++ b/swfdec/swfdec_as_function.h
@@ -44,8 +44,6 @@ struct _SwfdecAsFunction {
 struct _SwfdecAsFunctionClass {
   SwfdecAsObjectClass	object_class;
 
-  /* return a frame that calls this function or NULL if uncallable */
-  SwfdecAsFrame *	(* old_call)			(SwfdecAsFunction *	function);
   /* call this function - see swfdec_as_function_call_full() for meaning of arguments */
   void			(* call)			(SwfdecAsFunction *	function,
 							 SwfdecAsObject *	thisp,
diff --git a/swfdec/swfdec_as_internal.h b/swfdec/swfdec_as_internal.h
index 798f442..eaa9b33 100644
--- a/swfdec/swfdec_as_internal.h
+++ b/swfdec/swfdec_as_internal.h
@@ -39,11 +39,6 @@ G_BEGIN_DECLS
 
 void		swfdec_as_function_set_constructor	(SwfdecAsFunction *	fun);
 void		swfdec_as_function_init_context		(SwfdecAsContext *	context);
-SwfdecAsFrame *	swfdec_as_function_call_no_preload	(SwfdecAsFunction *	function, 
-							 SwfdecAsObject *	thisp,
-							 guint			n_args,
-							 const SwfdecAsValue *	args, 
-							 SwfdecAsValue *	return_value);
 
 /* swfdec_as_context.c */
 gboolean	swfdec_as_context_check_continue (SwfdecAsContext *	context);
diff --git a/swfdec/swfdec_as_script_function.c b/swfdec/swfdec_as_script_function.c
index 552224e..d8b0abf 100644
--- a/swfdec/swfdec_as_script_function.c
+++ b/swfdec/swfdec_as_script_function.c
@@ -27,24 +27,49 @@
 #include "swfdec_as_internal.h"
 #include "swfdec_as_stack.h"
 #include "swfdec_as_strings.h"
+#include "swfdec_as_super.h"
 #include "swfdec_debug.h"
 
 G_DEFINE_TYPE (SwfdecAsScriptFunction, swfdec_as_script_function, SWFDEC_TYPE_AS_FUNCTION)
 
-static SwfdecAsFrame *
-swfdec_as_script_function_old_call (SwfdecAsFunction *function)
+static void
+swfdec_as_script_function_call (SwfdecAsFunction *function, SwfdecAsObject *thisp, 
+    gboolean construct, SwfdecAsObject *super_reference, guint n_args, 
+    const SwfdecAsValue *args, SwfdecAsValue *return_value)
 {
   SwfdecAsScriptFunction *script = SWFDEC_AS_SCRIPT_FUNCTION (function);
   SwfdecAsFrame *frame;
 
+  /* just to be sure... */
+  if (return_value)
+    SWFDEC_AS_VALUE_SET_UNDEFINED (return_value);
+
   frame = swfdec_as_frame_new (swfdec_gc_object_get_context (function), script->script);
-  if (frame == NULL)
-    return NULL;
   frame->scope_chain = g_slist_concat (frame->scope_chain, g_slist_copy (script->scope_chain));
   frame->function = function;
   frame->target = script->target;
   frame->original_target = script->target;
-  return frame;
+  /* FIXME: figure out what to do in these situations?
+   * It's a problem when called inside swfdec_as_function_call () as the
+   * user of that function expects success, but super may fail here */
+  /* second check especially for super object */
+  if (thisp != NULL && frame->thisp == NULL) {
+    swfdec_as_frame_set_this (frame, swfdec_as_object_resolve (thisp));
+  }
+  frame->argc = n_args;
+  frame->argv = args;
+  frame->return_value = return_value;
+  frame->construct = construct;
+  if (super_reference == NULL) {
+    /* don't create a super object */
+  } else if (thisp != NULL) {
+    swfdec_as_super_new (frame, thisp, super_reference);
+  } else {
+    // FIXME: Does the super object really reference the function when thisp is NULL?
+    swfdec_as_super_new (frame, SWFDEC_AS_OBJECT (function), super_reference);
+  }
+  swfdec_as_frame_preload (frame);
+  swfdec_as_context_run (swfdec_gc_object_get_context (function));
 }
 
 static void
@@ -106,7 +131,7 @@ swfdec_as_script_function_class_init (SwfdecAsScriptFunctionClass *klass)
 
   asobject_class->debug = swfdec_as_script_function_debug;
 
-  function_class->old_call = swfdec_as_script_function_old_call;
+  function_class->call = swfdec_as_script_function_call;
 }
 
 static void
commit 4a662af56f83afc852220a5fa83487f022d9d4f2
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Aug 5 01:45:01 2008 +0100

    remove swfdec_as_function_old_call()

diff --git a/swfdec/swfdec_as_function.c b/swfdec/swfdec_as_function.c
index d91b8be..2db0435 100644
--- a/swfdec/swfdec_as_function.c
+++ b/swfdec/swfdec_as_function.c
@@ -156,42 +156,6 @@ swfdec_as_function_call_no_preload (SwfdecAsFunction *function,
 }
 
 /**
- * swfdec_as_function_old_call:
- * @function: the #SwfdecAsFunction to call
- * @thisp: this argument to use for the call or %NULL for none
- * @n_args: number of arguments to pass to the function
- * @args: the arguments to pass or %NULL to read the last @n_args stack elements.
- *        The memory must be unchanged until the function call has completed.
- *        This is after the call to swfdec_as_context_run () has finished.
- * @return_value: pointer for return value or %NULL to push the return value to 
- *                the stack
- *
- * Calls the given function. This means a #SwfdecAsFrame is created for the 
- * function and pushed on top of the execution stack. The function is however
- * not executed. Call swfdec_as_context_run () to execute it.
- **/
-void
-swfdec_as_function_old_call (SwfdecAsFunction *function, SwfdecAsObject *thisp, guint n_args,
-    const SwfdecAsValue *args, SwfdecAsValue *return_value)
-{
-  SwfdecAsFrame *frame;
-
-  g_return_if_fail (SWFDEC_IS_AS_FUNCTION (function));
-  g_return_if_fail (thisp == NULL || SWFDEC_IS_AS_OBJECT (thisp));
-
-  frame = swfdec_as_function_call_no_preload (function, thisp, n_args, args, return_value);
-  if (frame == NULL)
-    return;
-  if (thisp != NULL) {
-    swfdec_as_super_new (frame, thisp, thisp->prototype);
-  } else {
-    // FIXME: Does the super object really reference the function when thisp is NULL?
-    swfdec_as_super_new (frame, SWFDEC_AS_OBJECT (function), SWFDEC_AS_OBJECT (function)->prototype);
-  }
-  swfdec_as_frame_preload (frame);
-}
-
-/**
  * swfdec_as_function_call:
  * @function: the #SwfdecAsFunction to call
  * @thisp: this argument to use for the call or %NULL for none
diff --git a/swfdec/swfdec_as_function.h b/swfdec/swfdec_as_function.h
index 7e47b5f..9a0e069 100644
--- a/swfdec/swfdec_as_function.h
+++ b/swfdec/swfdec_as_function.h
@@ -58,11 +58,6 @@ struct _SwfdecAsFunctionClass {
 
 GType			swfdec_as_function_get_type	(void);
 
-void			swfdec_as_function_old_call	(SwfdecAsFunction *	function,
-							 SwfdecAsObject *	thisp,
-							 guint			n_args,
-							 const SwfdecAsValue *	args,
-							 SwfdecAsValue *	return_value);
 void			swfdec_as_function_call_full	(SwfdecAsFunction *	function,
 							 SwfdecAsObject *	thisp,
 							 gboolean		construct,
commit 84e3fd093e5b055f66dcdc26cb8e969448973d43
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Aug 5 01:04:07 2008 +0100

    remove debugging print

diff --git a/swfdec/swfdec_loadvars_as.c b/swfdec/swfdec_loadvars_as.c
index cd510ae..75febf7 100644
--- a/swfdec/swfdec_loadvars_as.c
+++ b/swfdec/swfdec_loadvars_as.c
@@ -39,10 +39,8 @@ void
 swfdec_loadvars_decode (SwfdecAsContext *cx, SwfdecAsObject *obj,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
-  if (obj == NULL) {
-    g_printerr ("heer\n");
+  if (obj == NULL)
     return;
-  }
 
   if (argc < 1) {
     SWFDEC_AS_VALUE_SET_BOOLEAN (rval, FALSE);
commit ce905c3580766e178573d4665e7bc01b80dae722
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 23:35:55 2008 +0100

    make native functions implement call() instead of old_call()

diff --git a/swfdec/swfdec_as_native_function.c b/swfdec/swfdec_as_native_function.c
index 7c4a3a0..efde7a0 100644
--- a/swfdec/swfdec_as_native_function.c
+++ b/swfdec/swfdec_as_native_function.c
@@ -52,18 +52,26 @@
 
 G_DEFINE_TYPE (SwfdecAsNativeFunction, swfdec_as_native_function, SWFDEC_TYPE_AS_FUNCTION)
 
-static SwfdecAsFrame *
-swfdec_as_native_function_old_call (SwfdecAsFunction *function)
+static void
+swfdec_as_native_function_call (SwfdecAsFunction *function, SwfdecAsObject *thisp, 
+    gboolean construct, SwfdecAsObject *super_reference, guint n_args, 
+    const SwfdecAsValue *args, SwfdecAsValue *return_value)
 {
   SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (function);
+  SwfdecAsContext *cx = swfdec_gc_object_get_context (function);
+  SwfdecAsValue rval = { 0, };
   SwfdecAsFrame *frame;
-  SwfdecAsContext *cx;
+  SwfdecAsValue *argv;
+
+  if (construct && native->construct_type != 0 &&
+      !g_type_is_a (G_OBJECT_TYPE (thisp), native->construct_type)) {
+    SWFDEC_FIXME ("Swfdec can't handle call to native constructor with invalid type");
+    return;
+  }
 
-  cx = swfdec_gc_object_get_context (function);
   frame = swfdec_as_frame_new_native (cx);
-  if (frame == NULL)
-    return NULL;
   g_assert (native->name);
+  frame->construct = construct;
   frame->function = function;
   /* We copy the target here so we have a proper SwfdecMovie reference inside native 
    * functions. This is for example necessary for swfdec_player_get_movie_by_value()
@@ -74,7 +82,41 @@ swfdec_as_native_function_old_call (SwfdecAsFunction *function)
     frame->target = frame->next->original_target;
     frame->original_target = frame->target;
   }
-  return frame;
+  if (thisp)
+    swfdec_as_frame_set_this (frame, swfdec_as_object_resolve (thisp));
+  frame->argc = n_args;
+  frame->argv = args;
+  frame->return_value = return_value;
+  frame->construct = construct;
+
+  if (frame->argc == 0 || frame->argv != NULL) {
+    /* FIXME FIXME FIXME: no casting here please! */
+    argv = (SwfdecAsValue *) frame->argv;
+  } else {
+    SwfdecAsStack *stack;
+    SwfdecAsValue *cur;
+    guint i;
+    if (frame->argc > 128) {
+      SWFDEC_FIXME ("allow calling native functions with more than 128 args (this one has %u)",
+	  frame->argc);
+      frame->argc = 128;
+    }
+    argv = g_new (SwfdecAsValue, frame->argc);
+    stack = cx->stack;
+    cur = cx->cur;
+    for (i = 0; i < frame->argc; i++) {
+      if (cur <= &stack->elements[0]) {
+	stack = stack->next;
+	cur = &stack->elements[stack->used_elements];
+      }
+      cur--;
+      argv[i] = *cur;
+    }
+  }
+  native->native (cx, frame->thisp, frame->argc, argv, &rval);
+  if (argv != frame->argv)
+    g_free (argv);
+  swfdec_as_frame_return (frame, &rval);
 }
 
 static char *
@@ -107,7 +149,7 @@ swfdec_as_native_function_class_init (SwfdecAsNativeFunctionClass *klass)
 
   asobject_class->debug = swfdec_as_native_function_debug;
 
-  function_class->old_call = swfdec_as_native_function_old_call;
+  function_class->call = swfdec_as_native_function_call;
 }
 
 static void
commit 88cf38607b66737ddea221fad133a06dda0013c9
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 23:26:32 2008 +0100

    make super implement call instead of old_call

diff --git a/swfdec/swfdec_as_super.c b/swfdec/swfdec_as_super.c
index 96b31b1..6975bc1 100644
--- a/swfdec/swfdec_as_super.c
+++ b/swfdec/swfdec_as_super.c
@@ -34,37 +34,31 @@
 
 G_DEFINE_TYPE (SwfdecAsSuper, swfdec_as_super, SWFDEC_TYPE_AS_FUNCTION)
 
-static SwfdecAsFrame *
-swfdec_as_super_old_call (SwfdecAsFunction *function)
+static void
+swfdec_as_super_call (SwfdecAsFunction *function, SwfdecAsObject *thisp, 
+    gboolean construct, SwfdecAsObject *super_reference, guint n_args, 
+    const SwfdecAsValue *args, SwfdecAsValue *return_value)
 {
   SwfdecAsSuper *super = SWFDEC_AS_SUPER (function);
-  SwfdecAsValue val;
   SwfdecAsFunction *fun;
-  SwfdecAsFunctionClass *klass;
-  SwfdecAsFrame *frame;
+  SwfdecAsValue val;
 
   if (super->object == NULL) {
     SWFDEC_WARNING ("super () called without an object.");
-    return NULL;
+    return;
   }
 
   swfdec_as_object_get_variable (super->object, 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;
+    return;
 
-  klass = SWFDEC_AS_FUNCTION_GET_CLASS (fun);
-  frame = klass->old_call (fun);
-  if (frame == NULL)
-    return NULL;
-  /* 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 = fun;
-  frame->construct = frame->next->construct;
-  swfdec_as_frame_set_this (frame, super->thisp);
-  return frame;
+  if (construct) {
+    SWFDEC_FIXME ("What happens with \"new super()\"?");
+  }
+  swfdec_as_function_call_full (fun, super->thisp, construct || 
+      swfdec_as_context_is_constructing (swfdec_gc_object_get_context (super)),
+      super->object->prototype, n_args, args, return_value);
 }
 
 static gboolean
@@ -137,7 +131,7 @@ swfdec_as_super_class_init (SwfdecAsSuperClass *klass)
   asobject_class->del = swfdec_as_super_delete;
   asobject_class->resolve = swfdec_as_super_resolve;
 
-  function_class->old_call = swfdec_as_super_old_call;
+  function_class->call = swfdec_as_super_call;
 }
 
 static void
commit cfb972b66dfa1692550bd16ea45cc91ef5895432
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 22:51:31 2008 +0100

    make call a function vfunc

diff --git a/swfdec/swfdec_as_function.c b/swfdec/swfdec_as_function.c
index 0765564..d91b8be 100644
--- a/swfdec/swfdec_as_function.c
+++ b/swfdec/swfdec_as_function.c
@@ -58,8 +58,32 @@ G_DEFINE_ABSTRACT_TYPE (SwfdecAsFunction, swfdec_as_function, SWFDEC_TYPE_AS_OBJ
  */
 
 static void
+swfdec_as_function_do_call_full (SwfdecAsFunction *function, SwfdecAsObject *thisp, 
+    gboolean construct, SwfdecAsObject *super_reference, guint n_args, 
+    const SwfdecAsValue *args, SwfdecAsValue *return_value)
+{
+  SwfdecAsFrame *frame;
+
+  frame = swfdec_as_function_call_no_preload (function, thisp, n_args, args, return_value);
+  if (frame == NULL)
+    return;
+  frame->construct = construct;
+  if (super_reference == NULL) {
+    /* don't create a super object */
+  } else if (thisp != NULL) {
+    swfdec_as_super_new (frame, thisp, super_reference);
+  } else {
+    // FIXME: Does the super object really reference the function when thisp is NULL?
+    swfdec_as_super_new (frame, SWFDEC_AS_OBJECT (function), super_reference);
+  }
+  swfdec_as_frame_preload (frame);
+  swfdec_as_context_run (swfdec_gc_object_get_context (function));
+}
+
+static void
 swfdec_as_function_class_init (SwfdecAsFunctionClass *klass)
 {
+  klass->call = swfdec_as_function_do_call_full;
 }
 
 static void
@@ -199,26 +223,14 @@ swfdec_as_function_call_full (SwfdecAsFunction *function, SwfdecAsObject *thisp,
     gboolean construct, SwfdecAsObject *super_reference, guint n_args, 
     const SwfdecAsValue *args, SwfdecAsValue *return_value)
 {
-  SwfdecAsFrame *frame;
+  SwfdecAsFunctionClass *klass;
 
   g_return_if_fail (SWFDEC_IS_AS_FUNCTION (function));
   g_return_if_fail (thisp == NULL || SWFDEC_IS_AS_OBJECT (thisp));
   g_return_if_fail (super_reference == NULL || SWFDEC_IS_AS_OBJECT (super_reference));
 
-  frame = swfdec_as_function_call_no_preload (function, thisp, n_args, args, return_value);
-  if (frame == NULL)
-    return;
-  frame->construct = construct;
-  if (super_reference == NULL) {
-    /* don't create a super object */
-  } else if (thisp != NULL) {
-    swfdec_as_super_new (frame, thisp, super_reference);
-  } else {
-    // FIXME: Does the super object really reference the function when thisp is NULL?
-    swfdec_as_super_new (frame, SWFDEC_AS_OBJECT (function), super_reference);
-  }
-  swfdec_as_frame_preload (frame);
-  swfdec_as_context_run (swfdec_gc_object_get_context (function));
+  klass = SWFDEC_AS_FUNCTION_GET_CLASS (function);
+  klass->call (function, thisp, construct, super_reference, n_args, args, return_value);
 }
 
 /*** AS CODE ***/
diff --git a/swfdec/swfdec_as_function.h b/swfdec/swfdec_as_function.h
index 4e78d8d..7e47b5f 100644
--- a/swfdec/swfdec_as_function.h
+++ b/swfdec/swfdec_as_function.h
@@ -46,6 +46,14 @@ struct _SwfdecAsFunctionClass {
 
   /* return a frame that calls this function or NULL if uncallable */
   SwfdecAsFrame *	(* old_call)			(SwfdecAsFunction *	function);
+  /* call this function - see swfdec_as_function_call_full() for meaning of arguments */
+  void			(* call)			(SwfdecAsFunction *	function,
+							 SwfdecAsObject *	thisp,
+							 gboolean		construct,
+							 SwfdecAsObject *	super_reference,
+							 guint			n_args,
+							 const SwfdecAsValue *	args,
+							 SwfdecAsValue *	return_value);
 };
 
 GType			swfdec_as_function_get_type	(void);
commit e917deed3023d2df654b723c1d714aebd402aa2d
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 22:39:29 2008 +0100

    rewrite super handling so that swfdec_as_interpret.c can use the new call API

diff --git a/swfdec/swfdec_as_function.c b/swfdec/swfdec_as_function.c
index 75ca424..0765564 100644
--- a/swfdec/swfdec_as_function.c
+++ b/swfdec/swfdec_as_function.c
@@ -209,12 +209,13 @@ swfdec_as_function_call_full (SwfdecAsFunction *function, SwfdecAsObject *thisp,
   if (frame == NULL)
     return;
   frame->construct = construct;
-  if (thisp != NULL) {
-    swfdec_as_super_new (frame, thisp, super_reference ? super_reference : thisp->prototype);
+  if (super_reference == NULL) {
+    /* don't create a super object */
+  } else if (thisp != NULL) {
+    swfdec_as_super_new (frame, thisp, super_reference);
   } else {
     // FIXME: Does the super object really reference the function when thisp is NULL?
-    swfdec_as_super_new (frame, SWFDEC_AS_OBJECT (function), 
-	super_reference ? super_reference : SWFDEC_AS_OBJECT (function)->prototype);
+    swfdec_as_super_new (frame, SWFDEC_AS_OBJECT (function), super_reference);
   }
   swfdec_as_frame_preload (frame);
   swfdec_as_context_run (swfdec_gc_object_get_context (function));
diff --git a/swfdec/swfdec_as_function.h b/swfdec/swfdec_as_function.h
index fe14d4e..4e78d8d 100644
--- a/swfdec/swfdec_as_function.h
+++ b/swfdec/swfdec_as_function.h
@@ -55,8 +55,6 @@ void			swfdec_as_function_old_call	(SwfdecAsFunction *	function,
 							 guint			n_args,
 							 const SwfdecAsValue *	args,
 							 SwfdecAsValue *	return_value);
-#define swfdec_as_function_call(function, thisp, n_args, args, return_value) \
-  swfdec_as_function_call_full (function, thisp, FALSE, NULL, n_args, args, return_value)
 void			swfdec_as_function_call_full	(SwfdecAsFunction *	function,
 							 SwfdecAsObject *	thisp,
 							 gboolean		construct,
@@ -64,6 +62,13 @@ void			swfdec_as_function_call_full	(SwfdecAsFunction *	function,
 							 guint			n_args,
 							 const SwfdecAsValue *	args,
 							 SwfdecAsValue *	return_value);
+static inline void
+swfdec_as_function_call (SwfdecAsFunction *function, SwfdecAsObject *thisp, guint n_args, 
+    const SwfdecAsValue *args, SwfdecAsValue *return_value)
+{
+  swfdec_as_function_call_full (function, thisp, FALSE, 
+      thisp ? thisp->prototype : SWFDEC_AS_OBJECT (function)->prototype, n_args, args, return_value);
+}
 
 
 G_END_DECLS
diff --git a/swfdec/swfdec_as_interpret.c b/swfdec/swfdec_as_interpret.c
index 423959b..5df3d67 100644
--- a/swfdec/swfdec_as_interpret.c
+++ b/swfdec/swfdec_as_interpret.c
@@ -764,10 +764,9 @@ swfdec_action_trace (SwfdecAsContext *cx, guint action, const guint8 *data, guin
 
 /* stack looks like this: [ function, this, arg1, arg2, ... ] */
 /* stack must be at least 2 elements big */
-static SwfdecAsFrame *
-swfdec_action_call (SwfdecAsContext *cx, guint n_args)
+static gboolean
+swfdec_action_call (SwfdecAsContext *cx, guint n_args, SwfdecAsObject *super)
 {
-  SwfdecAsFrame *frame;
   SwfdecAsFunction *fun;
   SwfdecAsObject *thisp;
 
@@ -785,14 +784,12 @@ swfdec_action_call (SwfdecAsContext *cx, guint n_args)
   /* sanitize argument count */
   if (n_args >= swfdec_as_stack_get_size (cx))
     n_args = swfdec_as_stack_get_size (cx);
-  frame = swfdec_as_function_call_no_preload (fun, thisp, n_args, NULL, NULL);
-  if (frame == NULL)
-    return NULL;
-  if (SWFDEC_IS_AS_SUPER (fun)) {
+  if (super == NULL && SWFDEC_IS_AS_SUPER (fun)) {
     SWFDEC_LOG ("replacing super object on frame");
-    swfdec_as_super_new_chain (frame, SWFDEC_AS_SUPER (fun), NULL);
+    super = swfdec_as_super_resolve_property (SWFDEC_AS_SUPER (fun), NULL);
   }
-  return frame;
+  swfdec_as_function_call_full (fun, thisp, FALSE, super, n_args, NULL, NULL);
+  return TRUE;
 
 error:
   n_args += 2;
@@ -800,7 +797,7 @@ error:
     n_args = swfdec_as_stack_get_size (cx);
   swfdec_as_stack_pop_n (cx, n_args);
   SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_push (cx));
-  return NULL;
+  return FALSE;
 }
 
 static void
@@ -824,11 +821,7 @@ swfdec_action_call_function (SwfdecAsContext *cx, guint action, const guint8 *da
     SWFDEC_AS_VALUE_SET_NULL (thisp);
     SWFDEC_AS_VALUE_SET_UNDEFINED (fun);
   }
-  frame = swfdec_action_call (cx, n_args);
-  if (frame) {
-    swfdec_as_frame_preload (frame);
-    swfdec_as_context_run (cx);
-  } else {
+  if (!swfdec_action_call (cx, n_args, NULL)) {
     SWFDEC_WARNING ("no function named %s", name);
   }
 }
@@ -836,9 +829,8 @@ swfdec_action_call_function (SwfdecAsContext *cx, guint action, const guint8 *da
 static void
 swfdec_action_call_method (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
 {
-  SwfdecAsFrame *frame = cx->frame;
   SwfdecAsValue *val;
-  SwfdecAsObject *obj;
+  SwfdecAsObject *obj, *super;
   SwfdecAsObject *pobj = NULL;
   guint n_args;
   const char *name;
@@ -868,20 +860,19 @@ swfdec_action_call_method (SwfdecAsContext *cx, guint action, const guint8 *data
     SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 2));
   }
   swfdec_as_stack_pop (cx);
-  frame = swfdec_action_call (cx, n_args);
-  if (frame) {
-    /* setup super to point to the right prototype */
-    if (SWFDEC_IS_AS_SUPER (obj)) {
-      swfdec_as_super_new_chain (frame, SWFDEC_AS_SUPER (obj), name);
-    } else if (cx->version > 6) {
-      swfdec_as_super_new (frame, obj, pobj == obj ? obj->prototype : pobj);
-    } else {
-      swfdec_as_super_new (frame, obj, obj->prototype);
-    }
-    swfdec_as_frame_preload (frame);
-    swfdec_as_context_run (cx);
+  /* setup super to point to the right prototype */
+  if (SWFDEC_IS_AS_SUPER (obj)) {
+    super = swfdec_as_super_resolve_property (SWFDEC_AS_SUPER (obj), name);
+  } else if (cx->version > 6 && pobj != obj) {
+    super = pobj;
+  } else if (obj) {
+    super = obj->prototype;
   } else {
-    SWFDEC_WARNING ("no function named \"%s\" on object %s", name, obj ? G_OBJECT_TYPE_NAME(obj) : "unknown");
+    super = NULL;
+  }
+  if (!swfdec_action_call (cx, n_args, super)) {
+    SWFDEC_WARNING ("no function named \"%s\" on object %s", name, 
+	obj ? G_OBJECT_TYPE_NAME(obj) : "unknown");
   }
 }
 
diff --git a/swfdec/swfdec_as_object.c b/swfdec/swfdec_as_object.c
index 3dbe899..f2fe821 100644
--- a/swfdec/swfdec_as_object.c
+++ b/swfdec/swfdec_as_object.c
@@ -1319,7 +1319,7 @@ swfdec_as_object_create (SwfdecAsFunction *fun, guint n_args,
   swfdec_as_object_set_variable_and_flags (new, SWFDEC_AS_STR___constructor__, 
       &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_VERSION_6_UP);
 
-  swfdec_as_function_call_full (fun, new, TRUE, NULL, n_args, args, return_value);
+  swfdec_as_function_call_full (fun, new, TRUE, new->prototype, n_args, args, return_value);
 }
 
 /**
diff --git a/swfdec/swfdec_as_super.c b/swfdec/swfdec_as_super.c
index 9099c84..96b31b1 100644
--- a/swfdec/swfdec_as_super.c
+++ b/swfdec/swfdec_as_super.c
@@ -163,7 +163,7 @@ swfdec_as_super_new (SwfdecAsFrame *frame, SwfdecAsObject *thisp, SwfdecAsObject
 
   super = g_object_new (SWFDEC_TYPE_AS_SUPER, "context", context, NULL);
   frame->super = SWFDEC_AS_OBJECT (super);
-  super->thisp = thisp;
+  super->thisp = swfdec_as_object_resolve (thisp);
   if (context->version <= 5) {
     super->object = NULL;
   } else {
@@ -171,46 +171,31 @@ swfdec_as_super_new (SwfdecAsFrame *frame, SwfdecAsObject *thisp, SwfdecAsObject
   }
 }
 
-/**
- * swfdec_as_super_new_chain:
- * @frame: the frame that is called
- * @super: the super object to chain from
- * @chain_to: object to chain to. Must be in the prototype chain of @super. Or
- *            %NULL to just use the super object's prototype
- *
- * This function creates a super object relative to the given @super object. It
- * is only needed when calling functions on the @super object.
- **/
-void
-swfdec_as_super_new_chain (SwfdecAsFrame *frame, SwfdecAsSuper *super,
-    const char *function_name)
+SwfdecAsObject *
+swfdec_as_super_resolve_property (SwfdecAsSuper *super, const char *name)
 {
   SwfdecAsObject *ref;
   SwfdecAsContext *context;
 	  
-  g_return_if_fail (frame != NULL);
-  g_return_if_fail (SWFDEC_IS_AS_SUPER (super));
+  g_return_val_if_fail (SWFDEC_IS_AS_SUPER (super), NULL);
 
-  if (frame->super != NULL)
-    return;
-  
   if (super->object == NULL)
-    return;
+    return NULL;
   ref = super->object->prototype;
   if (ref == NULL)
-    return;
+    return NULL;
   context = swfdec_gc_object_get_context (super);
-  if (function_name && context->version > 6) {
+  if (name && context->version > 6) {
     /* skip prototypes to find the next one that has this function defined */
     SwfdecAsObject *res;
     if (swfdec_as_object_get_variable_and_flags (ref, 
-         function_name, NULL, NULL, &res) && ref != res) {
+         name, NULL, NULL, &res) && ref != res) {
       while (ref->prototype != res) {
         ref = ref->prototype;
-        g_return_if_fail (ref);
+        g_assert (ref);
       }
     }
   }
-  swfdec_as_super_new (frame, super->thisp, ref);
+  return ref;
 }
 
diff --git a/swfdec/swfdec_as_super.h b/swfdec/swfdec_as_super.h
index a1a8e6a..d89100b 100644
--- a/swfdec/swfdec_as_super.h
+++ b/swfdec/swfdec_as_super.h
@@ -51,9 +51,9 @@ GType		swfdec_as_super_get_type	(void);
 void		swfdec_as_super_new		(SwfdecAsFrame *	frame,
 						 SwfdecAsObject *	thisp,
 						 SwfdecAsObject *	ref);
-void		swfdec_as_super_new_chain	(SwfdecAsFrame *	frame,
-						 SwfdecAsSuper *	super,
-						 const char *		function_name);
+SwfdecAsObject *swfdec_as_super_resolve_property(SwfdecAsSuper *	super,
+						 const char *		name);
+
 
 G_END_DECLS
 #endif
commit ca286927a6eafe53c0b3456563b28f7f38c0e8be
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 19:06:45 2008 +0100

    remove outdated docs

diff --git a/swfdec/swfdec_as_function.c b/swfdec/swfdec_as_function.c
index 3d71fe9..75ca424 100644
--- a/swfdec/swfdec_as_function.c
+++ b/swfdec/swfdec_as_function.c
@@ -173,8 +173,6 @@ swfdec_as_function_old_call (SwfdecAsFunction *function, SwfdecAsObject *thisp,
  * @thisp: this argument to use for the call or %NULL for none
  * @n_args: number of arguments to pass to the function
  * @args: the arguments to pass or %NULL to read the last @n_args stack elements.
- *        The memory must be unchanged until the function call has completed.
- *        This is after the call to swfdec_as_context_run () has finished.
  * @return_value: pointer for return value or %NULL to push the return value to 
  *                the stack
  *
@@ -191,8 +189,6 @@ swfdec_as_function_old_call (SwfdecAsFunction *function, SwfdecAsObject *thisp,
  *                   function call or %NULL to use the default.
  * @n_args: number of arguments to pass to the function
  * @args: the arguments to pass or %NULL to read the last @n_args stack elements.
- *        The memory must be unchanged until the function call has completed.
- *        This is after the call to swfdec_as_context_run () has finished.
  * @return_value: pointer for return value or %NULL to push the return value to 
  *                the stack
  *
commit 52edd9984c907e16a6ce08493b5bc1749d8c4407
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 19:06:15 2008 +0100

    convert construction to use new call API

diff --git a/swfdec/swfdec_as_object.c b/swfdec/swfdec_as_object.c
index 6ac1825..3dbe899 100644
--- a/swfdec/swfdec_as_object.c
+++ b/swfdec/swfdec_as_object.c
@@ -1265,7 +1265,6 @@ swfdec_as_object_create (SwfdecAsFunction *fun, guint n_args,
   SwfdecAsObject *new;
   SwfdecAsContext *context;
   SwfdecAsFunction *cur;
-  SwfdecAsFrame *frame;
   guint i, size = 0;
   GType type = 0;
 
@@ -1320,11 +1319,7 @@ swfdec_as_object_create (SwfdecAsFunction *fun, guint n_args,
   swfdec_as_object_set_variable_and_flags (new, SWFDEC_AS_STR___constructor__, 
       &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_VERSION_6_UP);
 
-  frame = swfdec_as_function_call_no_preload (fun, new, n_args, args, return_value);
-  frame->construct = TRUE;
-  swfdec_as_super_new (frame, new, new->prototype);
-  swfdec_as_frame_preload (frame);
-  swfdec_as_context_run (context);
+  swfdec_as_function_call_full (fun, new, TRUE, NULL, n_args, args, return_value);
 }
 
 /**
commit fc71b5dbca996e8ea84e14f2596549bc6aaa0862
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 19:02:12 2008 +0100

    convert to new call API

diff --git a/swfdec/swfdec_text_field_movie_as.c b/swfdec/swfdec_text_field_movie_as.c
index 805fe69..82fe13a 100644
--- a/swfdec/swfdec_text_field_movie_as.c
+++ b/swfdec/swfdec_text_field_movie_as.c
@@ -1414,10 +1414,8 @@ swfdec_text_field_movie_createTextField (SwfdecAsContext *cx,
       SWFDEC_AS_STR___constructor__, &val,
       SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_VERSION_6_UP);
 
-  swfdec_as_function_old_call (fun, SWFDEC_AS_OBJECT (movie), 0, NULL, 
-      cx->version > 7 ? rval : &val);
-  cx->frame->construct = TRUE;
-  swfdec_as_context_run (cx);
+  swfdec_as_function_call_full (fun, SWFDEC_AS_OBJECT (movie), TRUE, NULL,
+      0, NULL, cx->version > 7 ? rval : &val);
 }
 
 void
commit 71baf456680356fb325704e3d57640c60b715601
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 19:01:50 2008 +0100

    propose a function call API that works for every case

diff --git a/swfdec/swfdec_as_function.c b/swfdec/swfdec_as_function.c
index c1c75be..3d71fe9 100644
--- a/swfdec/swfdec_as_function.c
+++ b/swfdec/swfdec_as_function.c
@@ -168,9 +168,27 @@ swfdec_as_function_old_call (SwfdecAsFunction *function, SwfdecAsObject *thisp,
 }
 
 /**
- * swfdec_as_function_old_call:
+ * swfdec_as_function_call:
+ * @function: the #SwfdecAsFunction to call
+ * @thisp: this argument to use for the call or %NULL for none
+ * @n_args: number of arguments to pass to the function
+ * @args: the arguments to pass or %NULL to read the last @n_args stack elements.
+ *        The memory must be unchanged until the function call has completed.
+ *        This is after the call to swfdec_as_context_run () has finished.
+ * @return_value: pointer for return value or %NULL to push the return value to 
+ *                the stack
+ *
+ * Calls the given function. This is a macro that resolves to 
+ * swfdec_as_function_call_full().
+ **/
+/**
+ * swfdec_as_function_call_full:
  * @function: the #SwfdecAsFunction to call
  * @thisp: this argument to use for the call or %NULL for none
+ * @construct: call this function as a constructor. This is only relevant for 
+ *             native functions.
+ * @super_reference: The object to be referenced by the super object in this 
+ *                   function call or %NULL to use the default.
  * @n_args: number of arguments to pass to the function
  * @args: the arguments to pass or %NULL to read the last @n_args stack elements.
  *        The memory must be unchanged until the function call has completed.
@@ -181,13 +199,28 @@ swfdec_as_function_old_call (SwfdecAsFunction *function, SwfdecAsObject *thisp,
  * Calls the given function.
  **/
 void
-swfdec_as_function_call (SwfdecAsFunction *function, SwfdecAsObject *thisp, guint n_args,
+swfdec_as_function_call_full (SwfdecAsFunction *function, SwfdecAsObject *thisp, 
+    gboolean construct, SwfdecAsObject *super_reference, guint n_args, 
     const SwfdecAsValue *args, SwfdecAsValue *return_value)
 {
+  SwfdecAsFrame *frame;
+
   g_return_if_fail (SWFDEC_IS_AS_FUNCTION (function));
   g_return_if_fail (thisp == NULL || SWFDEC_IS_AS_OBJECT (thisp));
+  g_return_if_fail (super_reference == NULL || SWFDEC_IS_AS_OBJECT (super_reference));
 
-  swfdec_as_function_old_call (function, thisp, n_args, args, return_value);
+  frame = swfdec_as_function_call_no_preload (function, thisp, n_args, args, return_value);
+  if (frame == NULL)
+    return;
+  frame->construct = construct;
+  if (thisp != NULL) {
+    swfdec_as_super_new (frame, thisp, super_reference ? super_reference : thisp->prototype);
+  } else {
+    // FIXME: Does the super object really reference the function when thisp is NULL?
+    swfdec_as_super_new (frame, SWFDEC_AS_OBJECT (function), 
+	super_reference ? super_reference : SWFDEC_AS_OBJECT (function)->prototype);
+  }
+  swfdec_as_frame_preload (frame);
   swfdec_as_context_run (swfdec_gc_object_get_context (function));
 }
 
diff --git a/swfdec/swfdec_as_function.h b/swfdec/swfdec_as_function.h
index b91d56e..fe14d4e 100644
--- a/swfdec/swfdec_as_function.h
+++ b/swfdec/swfdec_as_function.h
@@ -55,8 +55,12 @@ void			swfdec_as_function_old_call	(SwfdecAsFunction *	function,
 							 guint			n_args,
 							 const SwfdecAsValue *	args,
 							 SwfdecAsValue *	return_value);
-void			swfdec_as_function_call	(SwfdecAsFunction *	function,
+#define swfdec_as_function_call(function, thisp, n_args, args, return_value) \
+  swfdec_as_function_call_full (function, thisp, FALSE, NULL, n_args, args, return_value)
+void			swfdec_as_function_call_full	(SwfdecAsFunction *	function,
 							 SwfdecAsObject *	thisp,
+							 gboolean		construct,
+							 SwfdecAsObject *	super_reference,
 							 guint			n_args,
 							 const SwfdecAsValue *	args,
 							 SwfdecAsValue *	return_value);
commit 1967c2494f60b52f154d9ea6c42d409d57700256
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 18:26:18 2008 +0100

    make swfdec_as_function_call() automatically do swfdec_as_context_run()
    
    We have swfdec_as_function_old_call() for the other cases

diff --git a/swfdec/swfdec_as_array.c b/swfdec/swfdec_as_array.c
index 2603ae4..ce53c72 100644
--- a/swfdec/swfdec_as_array.c
+++ b/swfdec/swfdec_as_array.c
@@ -940,7 +940,6 @@ swfdec_as_array_sort_compare_values (SwfdecAsContext *cx,
     SwfdecAsValue ret;
     SwfdecAsContext *context = swfdec_gc_object_get_context (custom_function);
     swfdec_as_function_call (custom_function, NULL, 2, argv, &ret);
-    swfdec_as_context_run (context);
     retval = swfdec_as_value_to_integer (context, &ret);
   }
   else if (options & SORT_OPTION_NUMERIC &&
diff --git a/swfdec/swfdec_as_function.c b/swfdec/swfdec_as_function.c
index 9bc4156..c1c75be 100644
--- a/swfdec/swfdec_as_function.c
+++ b/swfdec/swfdec_as_function.c
@@ -132,7 +132,7 @@ swfdec_as_function_call_no_preload (SwfdecAsFunction *function,
 }
 
 /**
- * swfdec_as_function_call:
+ * swfdec_as_function_old_call:
  * @function: the #SwfdecAsFunction to call
  * @thisp: this argument to use for the call or %NULL for none
  * @n_args: number of arguments to pass to the function
@@ -147,7 +147,7 @@ swfdec_as_function_call_no_preload (SwfdecAsFunction *function,
  * not executed. Call swfdec_as_context_run () to execute it.
  **/
 void
-swfdec_as_function_call (SwfdecAsFunction *function, SwfdecAsObject *thisp, guint n_args,
+swfdec_as_function_old_call (SwfdecAsFunction *function, SwfdecAsObject *thisp, guint n_args,
     const SwfdecAsValue *args, SwfdecAsValue *return_value)
 {
   SwfdecAsFrame *frame;
@@ -167,6 +167,30 @@ swfdec_as_function_call (SwfdecAsFunction *function, SwfdecAsObject *thisp, guin
   swfdec_as_frame_preload (frame);
 }
 
+/**
+ * swfdec_as_function_old_call:
+ * @function: the #SwfdecAsFunction to call
+ * @thisp: this argument to use for the call or %NULL for none
+ * @n_args: number of arguments to pass to the function
+ * @args: the arguments to pass or %NULL to read the last @n_args stack elements.
+ *        The memory must be unchanged until the function call has completed.
+ *        This is after the call to swfdec_as_context_run () has finished.
+ * @return_value: pointer for return value or %NULL to push the return value to 
+ *                the stack
+ *
+ * Calls the given function.
+ **/
+void
+swfdec_as_function_call (SwfdecAsFunction *function, SwfdecAsObject *thisp, guint n_args,
+    const SwfdecAsValue *args, SwfdecAsValue *return_value)
+{
+  g_return_if_fail (SWFDEC_IS_AS_FUNCTION (function));
+  g_return_if_fail (thisp == NULL || SWFDEC_IS_AS_OBJECT (thisp));
+
+  swfdec_as_function_old_call (function, thisp, n_args, args, return_value);
+  swfdec_as_context_run (swfdec_gc_object_get_context (function));
+}
+
 /*** AS CODE ***/
 
 SWFDEC_AS_NATIVE (101, 10, swfdec_as_function_do_call)
@@ -187,7 +211,6 @@ swfdec_as_function_do_call (SwfdecAsContext *cx, SwfdecAsObject *object,
     argv++;
   }
   swfdec_as_function_call (fun, thisp, argc, argv, ret);
-  swfdec_as_context_run (cx);
 }
 
 SWFDEC_AS_NATIVE (101, 11, swfdec_as_function_apply)
@@ -233,7 +256,6 @@ swfdec_as_function_apply (SwfdecAsContext *cx, SwfdecAsObject *object,
   }
 
   swfdec_as_function_call (fun, thisp, length, argv_pass, ret);
-  swfdec_as_context_run (cx);
 
   if (argv_pass) {
     swfdec_as_context_unuse_mem (cx, sizeof (SwfdecAsValue) * length);
diff --git a/swfdec/swfdec_as_function.h b/swfdec/swfdec_as_function.h
index 9e66329..b91d56e 100644
--- a/swfdec/swfdec_as_function.h
+++ b/swfdec/swfdec_as_function.h
@@ -50,7 +50,12 @@ struct _SwfdecAsFunctionClass {
 
 GType			swfdec_as_function_get_type	(void);
 
-void			swfdec_as_function_call		(SwfdecAsFunction *	function,
+void			swfdec_as_function_old_call	(SwfdecAsFunction *	function,
+							 SwfdecAsObject *	thisp,
+							 guint			n_args,
+							 const SwfdecAsValue *	args,
+							 SwfdecAsValue *	return_value);
+void			swfdec_as_function_call	(SwfdecAsFunction *	function,
 							 SwfdecAsObject *	thisp,
 							 guint			n_args,
 							 const SwfdecAsValue *	args,
diff --git a/swfdec/swfdec_as_object.c b/swfdec/swfdec_as_object.c
index 22005fa..6ac1825 100644
--- a/swfdec/swfdec_as_object.c
+++ b/swfdec/swfdec_as_object.c
@@ -315,7 +315,6 @@ swfdec_as_object_do_get (SwfdecAsObject *object, SwfdecAsObject *orig,
 
   if (var->get) {
     swfdec_as_function_call (var->get, orig, 0, NULL, val);
-    swfdec_as_context_run (swfdec_gc_object_get_context (object));
     *flags = var->flags;
   } else {
     *val = var->value;
@@ -506,7 +505,6 @@ swfdec_as_object_do_set (SwfdecAsObject *object, const char *variable,
       args[3] = watch->watch_data;
       swfdec_as_watch_ref (watch);
       swfdec_as_function_call (watch->watch, object, 4, args, &ret);
-      swfdec_as_context_run (swfdec_gc_object_get_context (object));
       swfdec_as_watch_unref (watch);
       var = swfdec_as_object_hash_lookup_with_prototype (object, variable,
 	  NULL);
@@ -526,7 +524,6 @@ swfdec_as_object_do_set (SwfdecAsObject *object, const char *variable,
     if (var->set) {
       SwfdecAsValue tmp;
       swfdec_as_function_call (var->set, object, 1, val, &tmp);
-      swfdec_as_context_run (swfdec_gc_object_get_context (object));
     }
   } else if (watch == NULL) {
     var->value = *val;
@@ -964,9 +961,6 @@ swfdec_as_object_get_variable_and_flags (SwfdecAsObject *object,
       return FALSE;
     SWFDEC_AS_VALUE_SET_STRING (&argv, variable);
     swfdec_as_function_call (fun, resolve, 1, &argv, value);
-    if (swfdec_as_context_is_aborted (context))
-      return TRUE;
-    swfdec_as_context_run (context);
 
     return TRUE;
   }
@@ -1249,9 +1243,6 @@ swfdec_as_object_call (SwfdecAsObject *object, const char *name, guint argc,
   if (!SWFDEC_IS_AS_FUNCTION (fun))
     return FALSE;
   swfdec_as_function_call (fun, object, argc, argv, return_value ? return_value : &tmp);
-  if (swfdec_as_context_is_aborted (swfdec_gc_object_get_context (object)))
-    return TRUE;
-  swfdec_as_context_run (swfdec_gc_object_get_context (object));
 
   return TRUE;
 }
diff --git a/swfdec/swfdec_interval.c b/swfdec/swfdec_interval.c
index 1dabd43..dd0c390 100644
--- a/swfdec/swfdec_interval.c
+++ b/swfdec/swfdec_interval.c
@@ -112,7 +112,6 @@ swfdec_interval_trigger (SwfdecTimeout *timeout)
   } else {
     swfdec_as_function_call (SWFDEC_AS_FUNCTION (interval->object), NULL, 
 	interval->n_args, interval->args, &ret);
-    swfdec_as_context_run (context);
   }
   swfdec_sandbox_unuse (interval->sandbox);
 }
diff --git a/swfdec/swfdec_text_field_movie_as.c b/swfdec/swfdec_text_field_movie_as.c
index 75a5ea9..805fe69 100644
--- a/swfdec/swfdec_text_field_movie_as.c
+++ b/swfdec/swfdec_text_field_movie_as.c
@@ -1414,8 +1414,8 @@ swfdec_text_field_movie_createTextField (SwfdecAsContext *cx,
       SWFDEC_AS_STR___constructor__, &val,
       SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_VERSION_6_UP);
 
-  swfdec_as_function_call (fun, SWFDEC_AS_OBJECT (movie), 0, NULL, 
-      cx->version > 7 ? rval : NULL);
+  swfdec_as_function_old_call (fun, SWFDEC_AS_OBJECT (movie), 0, NULL, 
+      cx->version > 7 ? rval : &val);
   cx->frame->construct = TRUE;
   swfdec_as_context_run (cx);
 }
commit d4b81cf8f6d824eba354a572a328b72293ed2bbf
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 17:51:39 2008 +0100

    don't special case END ation

diff --git a/swfdec/swfdec_as_context.c b/swfdec/swfdec_as_context.c
index 2a18326..88ba176 100644
--- a/swfdec/swfdec_as_context.c
+++ b/swfdec/swfdec_as_context.c
@@ -912,10 +912,6 @@ swfdec_as_context_run (SwfdecAsContext *context)
 
     /* decode next action */
     action = *pc;
-    if (action == 0) {
-      swfdec_as_frame_return (frame, NULL);
-      goto out;
-    }
     /* invoke debugger if there is one */
     if (step) {
       frame->pc = pc;
diff --git a/swfdec/swfdec_as_interpret.c b/swfdec/swfdec_as_interpret.c
index 7ed4e10..423959b 100644
--- a/swfdec/swfdec_as_interpret.c
+++ b/swfdec/swfdec_as_interpret.c
@@ -2057,6 +2057,12 @@ swfdec_action_define_local2 (SwfdecAsContext *cx, guint action, const guint8 *da
 }
 
 static void
+swfdec_action_end (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+  swfdec_as_frame_return (cx->frame, NULL);
+}
+
+static void
 swfdec_action_return (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
 {
   swfdec_as_frame_return (cx->frame, swfdec_as_stack_pop (cx));
@@ -3148,6 +3154,7 @@ swfdec_action_print_wait_for_frame (guint action, const guint8 *data, guint len)
 
 const SwfdecActionSpec swfdec_as_actions[256] = {
   /* version 1 */
+  [SWFDEC_AS_ACTION_END] = { "End", NULL, 0, 0, swfdec_action_end, 1 },
   [SWFDEC_AS_ACTION_NEXT_FRAME] = { "NextFrame", NULL, 0, 0, swfdec_action_next_frame, 1 },
   [SWFDEC_AS_ACTION_PREVIOUS_FRAME] = { "PreviousFrame", NULL, 0, 0, swfdec_action_previous_frame, 1 },
   [SWFDEC_AS_ACTION_PLAY] = { "Play", NULL, 0, 0, swfdec_action_play, 1 },
commit 9bd883a6bed02c9e21f8ac445de5da239023e833
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 17:41:17 2008 +0100

    simplify frame creation

diff --git a/swfdec/swfdec_as_frame.c b/swfdec/swfdec_as_frame.c
index f169f66..851d7ca 100644
--- a/swfdec/swfdec_as_frame.c
+++ b/swfdec/swfdec_as_frame.c
@@ -286,29 +286,15 @@ swfdec_as_frame_free (SwfdecAsFrame *frame)
   }
 }
 
-static void
-swfdec_as_frame_load (SwfdecAsFrame *frame, SwfdecAsContext *context)
-{
-  frame->stack_begin = context->cur;
-  context->base = frame->stack_begin;
-  frame->next = context->frame;
-  context->frame = frame;
-  context->call_depth++;
-}
-
 SwfdecAsFrame *
 swfdec_as_frame_new (SwfdecAsContext *context, SwfdecScript *script)
 {
   SwfdecAsFrame *frame;
-  gsize size;
 
   g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
   g_return_val_if_fail (script != NULL, NULL);
   
-  size = sizeof (SwfdecAsFrame) + sizeof (SwfdecAsValue) * script->n_registers;
-  frame = g_new0 (SwfdecAsFrame, 1);
-  frame->blocks = g_array_new (FALSE, FALSE, sizeof (SwfdecAsFrameBlock));
-  frame->block_end = (gpointer) -1;
+  frame = swfdec_as_frame_new_native (context);
   frame->script = swfdec_script_ref (script);
   SWFDEC_DEBUG ("new frame for function %s", script->name);
   frame->pc = script->main;
@@ -321,7 +307,6 @@ swfdec_as_frame_new (SwfdecAsContext *context, SwfdecScript *script)
       SWFDEC_ERROR ("couldn't create constant pool");
     }
   }
-  swfdec_as_frame_load (frame, context);
   return frame;
 }
 
@@ -329,16 +314,19 @@ SwfdecAsFrame *
 swfdec_as_frame_new_native (SwfdecAsContext *context)
 {
   SwfdecAsFrame *frame;
-  gsize size;
 
   g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
   
-  size = sizeof (SwfdecAsFrame);
   frame = g_new0 (SwfdecAsFrame, 1);
+
   frame->blocks = g_array_new (FALSE, FALSE, sizeof (SwfdecAsFrameBlock));
   frame->block_end = (gpointer) -1;
-  SWFDEC_DEBUG ("new native frame");
-  swfdec_as_frame_load (frame, context);
+  frame->stack_begin = context->cur;
+  context->base = frame->stack_begin;
+  frame->next = context->frame;
+  context->frame = frame;
+  context->call_depth++;
+
   return frame;
 }
 
commit 8185afb4255db5b0eb391f963361c85e870c172c
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 17:30:14 2008 +0100

    Make SwfdecAsFrame a normal allocated struct
    
    side note: the vivified app is completely broken

diff --git a/doc/swfdec.types b/doc/swfdec.types
index 5b2ea54..80390fd 100644
--- a/doc/swfdec.types
+++ b/doc/swfdec.types
@@ -4,7 +4,6 @@
 swfdec_as_array_get_type
 swfdec_as_context_get_type
 swfdec_as_debugger_get_type
-swfdec_as_frame_get_type
 swfdec_as_function_get_type
 swfdec_as_native_function_get_type
 swfdec_as_object_get_type
diff --git a/swfdec/swfdec_as_frame.c b/swfdec/swfdec_as_frame.c
index 2d40cd8..f169f66 100644
--- a/swfdec/swfdec_as_frame.c
+++ b/swfdec/swfdec_as_frame.c
@@ -79,7 +79,7 @@ swfdec_as_stack_iterator_init_arguments (SwfdecAsStackIterator *iter, SwfdecAsFr
   SwfdecAsContext *context;
 
   g_return_val_if_fail (iter != NULL, NULL);
-  g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
+  g_return_val_if_fail (frame != NULL, NULL);
 
   if (frame->argc == 0) {
     iter->i = iter->n = 0;
@@ -132,7 +132,7 @@ swfdec_as_stack_iterator_init (SwfdecAsStackIterator *iter, SwfdecAsFrame *frame
   SwfdecAsStack *stack;
 
   g_return_val_if_fail (iter != NULL, NULL);
-  g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
+  g_return_val_if_fail (frame != NULL, NULL);
 
   context = swfdec_gc_object_get_context (frame->target);
   iter->i = 0;
@@ -226,7 +226,7 @@ swfdec_as_frame_push_block (SwfdecAsFrame *frame, const guint8 *start,
 {
   SwfdecAsFrameBlock block = { start, end, func, data };
 
-  g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+  g_return_if_fail (frame != NULL);
   g_return_if_fail (start <= end);
   g_return_if_fail (start >= frame->block_start);
   g_return_if_fail (end <= frame->block_end);
@@ -244,7 +244,7 @@ swfdec_as_frame_pop_block (SwfdecAsFrame *frame, SwfdecAsContext *cx)
   gpointer data;
   SwfdecAsFrameBlock *block;
 
-  g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+  g_return_if_fail (frame != NULL);
   g_return_if_fail (frame->blocks->len > 0);
 
   block = &g_array_index (frame->blocks, SwfdecAsFrameBlock, frame->blocks->len - 1);
@@ -265,16 +265,12 @@ swfdec_as_frame_pop_block (SwfdecAsFrame *frame, SwfdecAsContext *cx)
 
 /*** FRAME ***/
 
-G_DEFINE_TYPE (SwfdecAsFrame, swfdec_as_frame, SWFDEC_TYPE_AS_OBJECT)
-
 static void
-swfdec_as_frame_dispose (GObject *object)
+swfdec_as_frame_free (SwfdecAsFrame *frame)
 {
-  SwfdecAsFrame *frame = SWFDEC_AS_FRAME (object);
-
   /* pop blocks while state is intact */
   while (frame->blocks->len > 0)
-    swfdec_as_frame_pop_block (frame, swfdec_gc_object_get_context (frame));
+    swfdec_as_frame_pop_block (frame, swfdec_gc_object_get_context (frame->target));
 
   /* clean up */
   g_slice_free1 (sizeof (SwfdecAsValue) * frame->n_registers, frame->registers);
@@ -288,91 +284,6 @@ swfdec_as_frame_dispose (GObject *object)
     swfdec_script_unref (frame->script);
     frame->script = NULL;
   }
-
-  G_OBJECT_CLASS (swfdec_as_frame_parent_class)->dispose (object);
-}
-
-static void
-swfdec_as_frame_mark (SwfdecGcObject *object)
-{
-  SwfdecAsFrame *frame = SWFDEC_AS_FRAME (object);
-  guint i;
-
-  if (frame->next)
-    swfdec_gc_object_mark (frame->next);
-  g_slist_foreach (frame->scope_chain, (GFunc) swfdec_gc_object_mark, NULL);
-  if (frame->thisp)
-    swfdec_gc_object_mark (frame->thisp);
-  if (frame->super)
-    swfdec_gc_object_mark (frame->super);
-  swfdec_gc_object_mark (frame->target);
-  swfdec_gc_object_mark (frame->original_target);
-  if (frame->function)
-    swfdec_gc_object_mark (frame->function);
-  for (i = 0; i < frame->n_registers; i++) {
-    swfdec_as_value_mark (&frame->registers[i]);
-  }
-  /* don't mark argv, it's const, others have to take care of it */
-  SWFDEC_GC_OBJECT_CLASS (swfdec_as_frame_parent_class)->mark (object);
-}
-
-static char *
-swfdec_as_frame_debug (SwfdecAsObject *object)
-{
-  SwfdecAsFrame *frame = SWFDEC_AS_FRAME (object);
-  GString *string = g_string_new ("");
-  SwfdecAsStackIterator iter;
-  SwfdecAsValue *val;
-  char *s;
-  guint i;
-
-  if (frame->thisp) {
-    s = swfdec_as_object_get_debug (frame->thisp);
-    g_string_append (string, s);
-    g_string_append (string, ".");
-    g_free (s);
-  }
-  s = swfdec_as_object_get_debug (SWFDEC_AS_OBJECT (frame->function));
-  g_string_append (string, s);
-  g_free (s);
-  g_string_append (string, " (");
-  i = 0;
-  for (val = swfdec_as_stack_iterator_init_arguments (&iter, frame); val && i < 4;
-      val = swfdec_as_stack_iterator_next (&iter)) {
-    if (i > 0)
-      g_string_append (string, ", ");
-    i++;
-    if (i == 3 && frame->argc > 4) {
-      g_string_append (string, "...");
-    } else {
-      s = swfdec_as_value_to_debug (val);
-      g_string_append (string, s);
-      g_free (s);
-    }
-  }
-  g_string_append (string, ")");
-  return g_string_free (string, FALSE);
-}
-
-static void
-swfdec_as_frame_class_init (SwfdecAsFrameClass *klass)
-{
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-  SwfdecGcObjectClass *gc_class = SWFDEC_GC_OBJECT_CLASS (klass);
-  SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
-
-  object_class->dispose = swfdec_as_frame_dispose;
-
-  gc_class->mark = swfdec_as_frame_mark;
-
-  asobject_class->debug = swfdec_as_frame_debug;
-}
-
-static void
-swfdec_as_frame_init (SwfdecAsFrame *frame)
-{
-  frame->blocks = g_array_new (FALSE, FALSE, sizeof (SwfdecAsFrameBlock));
-  frame->block_end = (gpointer) -1;
 }
 
 static void
@@ -395,7 +306,9 @@ swfdec_as_frame_new (SwfdecAsContext *context, SwfdecScript *script)
   g_return_val_if_fail (script != NULL, NULL);
   
   size = sizeof (SwfdecAsFrame) + sizeof (SwfdecAsValue) * script->n_registers;
-  frame = g_object_new (SWFDEC_TYPE_AS_FRAME, "context", context, NULL);
+  frame = g_new0 (SwfdecAsFrame, 1);
+  frame->blocks = g_array_new (FALSE, FALSE, sizeof (SwfdecAsFrameBlock));
+  frame->block_end = (gpointer) -1;
   frame->script = swfdec_script_ref (script);
   SWFDEC_DEBUG ("new frame for function %s", script->name);
   frame->pc = script->main;
@@ -421,7 +334,9 @@ swfdec_as_frame_new_native (SwfdecAsContext *context)
   g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
   
   size = sizeof (SwfdecAsFrame);
-  frame = g_object_new (SWFDEC_TYPE_AS_FRAME, "context", context, NULL);
+  frame = g_new0 (SwfdecAsFrame, 1);
+  frame->blocks = g_array_new (FALSE, FALSE, sizeof (SwfdecAsFrameBlock));
+  frame->block_end = (gpointer) -1;
   SWFDEC_DEBUG ("new native frame");
   swfdec_as_frame_load (frame, context);
   return frame;
@@ -444,8 +359,8 @@ swfdec_as_frame_return (SwfdecAsFrame *frame, SwfdecAsValue *return_value)
   SwfdecAsValue retval;
   SwfdecAsFrame *next;
 
-  g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
-  context = swfdec_gc_object_get_context (frame->target);
+  g_return_if_fail (frame != NULL);
+  context = swfdec_gc_object_get_context (frame->target ? (gpointer) frame->target : (gpointer) frame->function);
   g_return_if_fail (frame == context->frame);
 
   /* save return value in case it was on the stack somewhere */
@@ -503,6 +418,7 @@ swfdec_as_frame_return (SwfdecAsFrame *frame, SwfdecAsValue *return_value)
     swfdec_as_stack_ensure_free (context, 1);
     *swfdec_as_stack_push (context) = retval;
   }
+  swfdec_as_frame_free (frame);
 }
 
 /**
@@ -518,7 +434,7 @@ swfdec_as_frame_return (SwfdecAsFrame *frame, SwfdecAsValue *return_value)
 void
 swfdec_as_frame_set_this (SwfdecAsFrame *frame, SwfdecAsObject *thisp)
 {
-  g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+  g_return_if_fail (frame != NULL);
   g_return_if_fail (frame->thisp == NULL);
   g_return_if_fail (SWFDEC_IS_AS_OBJECT (thisp));
 
@@ -553,7 +469,7 @@ swfdec_as_frame_get_variable_and_flags (SwfdecAsFrame *frame, const char *variab
   GSList *walk;
   SwfdecAsContext *cx;
 
-  g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
+  g_return_val_if_fail (frame != NULL, NULL);
   g_return_val_if_fail (variable != NULL, NULL);
 
   cx = swfdec_gc_object_get_context (frame->target);
@@ -591,7 +507,7 @@ swfdec_as_frame_set_variable_and_flags (SwfdecAsFrame *frame, const char *variab
   SwfdecAsObject *pobject, *set;
   GSList *walk;
 
-  g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+  g_return_if_fail (frame != NULL);
   g_return_if_fail (variable != NULL);
 
   set = NULL;
@@ -626,7 +542,7 @@ swfdec_as_frame_delete_variable (SwfdecAsFrame *frame, const char *variable)
   GSList *walk;
   SwfdecAsDeleteReturn ret;
 
-  g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), FALSE);
+  g_return_val_if_fail (frame != NULL, FALSE);
   g_return_val_if_fail (variable != NULL, FALSE);
 
   for (walk = frame->scope_chain; walk; walk = walk->next) {
@@ -655,7 +571,7 @@ swfdec_as_frame_delete_variable (SwfdecAsFrame *frame, const char *variable)
 void
 swfdec_as_frame_set_target (SwfdecAsFrame *frame, SwfdecAsObject *target)
 {
-  g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+  g_return_if_fail (frame != NULL);
   g_return_if_fail (target == NULL || SWFDEC_IS_AS_OBJECT (target));
 
   if (target) {
@@ -676,10 +592,10 @@ swfdec_as_frame_preload (SwfdecAsFrame *frame)
   SwfdecAsContext *context;
   SwfdecAsStackIterator iter;
 
-  g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+  g_return_if_fail (frame != NULL);
 
   /* setup */
-  context = swfdec_gc_object_get_context (frame->target);
+  context = swfdec_gc_object_get_context (frame->target ? (gpointer) frame->target : (gpointer) frame->function);
   script = frame->script;
   if (frame->script == NULL)
     goto out;
@@ -821,7 +737,7 @@ swfdec_as_frame_handle_exception (SwfdecAsFrame *frame)
 {
   SwfdecAsContext *cx;
 
-  g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+  g_return_if_fail (frame != NULL);
   cx = swfdec_gc_object_get_context (frame->target);
   g_return_if_fail (cx->exception);
 
@@ -847,7 +763,7 @@ swfdec_as_frame_handle_exception (SwfdecAsFrame *frame)
 SwfdecAsFrame *
 swfdec_as_frame_get_next (SwfdecAsFrame *frame)
 {
-  g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
+  g_return_val_if_fail (frame != NULL, NULL);
 
   return frame->next;
 }
@@ -864,7 +780,7 @@ swfdec_as_frame_get_next (SwfdecAsFrame *frame)
 SwfdecScript *
 swfdec_as_frame_get_script (SwfdecAsFrame *frame)
 {
-  g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
+  g_return_val_if_fail (frame != NULL, NULL);
 
   return frame->script;
 }
@@ -881,7 +797,7 @@ swfdec_as_frame_get_script (SwfdecAsFrame *frame)
 SwfdecAsObject *
 swfdec_as_frame_get_this (SwfdecAsFrame *frame)
 {
-  g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
+  g_return_val_if_fail (frame != NULL, NULL);
 
   return frame->thisp;
 }
diff --git a/swfdec/swfdec_as_frame.h b/swfdec/swfdec_as_frame.h
index 7aa93f2..29b850e 100644
--- a/swfdec/swfdec_as_frame.h
+++ b/swfdec/swfdec_as_frame.h
@@ -37,15 +37,6 @@ struct _SwfdecAsStackIterator {
 };
 
 
-#define SWFDEC_TYPE_AS_FRAME                    (swfdec_as_frame_get_type())
-#define SWFDEC_IS_AS_FRAME(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_FRAME))
-#define SWFDEC_IS_AS_FRAME_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_FRAME))
-#define SWFDEC_AS_FRAME(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_FRAME, SwfdecAsFrame))
-#define SWFDEC_AS_FRAME_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_FRAME, SwfdecAsFrameClass))
-#define SWFDEC_AS_FRAME_GET_CLASS(obj)          (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_FRAME, SwfdecAsFrameClass))
-
-GType		swfdec_as_frame_get_type	(void);
-
 SwfdecAsFrame *	swfdec_as_frame_get_next	(SwfdecAsFrame *		frame);
 SwfdecScript *	swfdec_as_frame_get_script	(SwfdecAsFrame *		frame);
 SwfdecAsObject *swfdec_as_frame_get_this	(SwfdecAsFrame *		frame);
diff --git a/swfdec/swfdec_as_frame_internal.h b/swfdec/swfdec_as_frame_internal.h
index b5bd877..402e051 100644
--- a/swfdec/swfdec_as_frame_internal.h
+++ b/swfdec/swfdec_as_frame_internal.h
@@ -28,8 +28,6 @@ G_BEGIN_DECLS
 typedef void (* SwfdecAsFrameBlockFunc) (SwfdecAsContext *cx, SwfdecAsFrame *frame, gpointer data);
 
 struct _SwfdecAsFrame {
-  SwfdecAsObject	object;
-
   SwfdecAsFrame *	next;		/* next frame (FIXME: keep a list in the context instead?) */
   SwfdecAsFunction *	function;	/* function we're executing or NULL if toplevel */
   SwfdecAsObject *	thisp;		/* this object in current frame or NULL if none */
@@ -55,10 +53,6 @@ struct _SwfdecAsFrame {
   /* native function */
 };
 
-struct _SwfdecAsFrameClass {
-  SwfdecAsObjectClass	object_class;
-};
-
 SwfdecAsFrame *	swfdec_as_frame_new		(SwfdecAsContext *	context,
 						 SwfdecScript *		script);
 SwfdecAsFrame *	swfdec_as_frame_new_native	(SwfdecAsContext *	context);
diff --git a/swfdec/swfdec_as_interpret.c b/swfdec/swfdec_as_interpret.c
index 040f8f1..7ed4e10 100644
--- a/swfdec/swfdec_as_interpret.c
+++ b/swfdec/swfdec_as_interpret.c
@@ -2603,11 +2603,10 @@ swfdec_action_try_end_finally (SwfdecAsContext *cx, SwfdecAsFrame *frame, gpoint
 {
   SwfdecAsValue *exception_value = data;
 
-  g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
   g_return_if_fail (SWFDEC_IS_AS_VALUE (exception_value));
 
   // finally has ended and we had exception stored, throw it
-  if (!cx->exception)
+  if (!cx->exception && cx->frame == frame)
     swfdec_as_context_throw (cx, exception_value);
 
   g_free (data);
@@ -2619,7 +2618,6 @@ swfdec_action_try_end_catch (SwfdecAsContext *cx, SwfdecAsFrame *frame, gpointer
   TryData *try_data = data;
   SwfdecAsValue *exception_value, val;
 
-  g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
   g_return_if_fail (try_data != NULL);
 
   if (try_data->scope_object) {
@@ -2654,7 +2652,6 @@ swfdec_action_try_end_try (SwfdecAsContext *cx, SwfdecAsFrame *frame, gpointer d
   TryData *try_data = data;
   SwfdecAsValue val;
 
-  g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
   g_return_if_fail (try_data != NULL);
 
   // if we don't have a catch block, we handle try block exactly like it was
diff --git a/swfdec/swfdec_as_super.c b/swfdec/swfdec_as_super.c
index f01b375..9099c84 100644
--- a/swfdec/swfdec_as_super.c
+++ b/swfdec/swfdec_as_super.c
@@ -151,7 +151,7 @@ swfdec_as_super_new (SwfdecAsFrame *frame, SwfdecAsObject *thisp, SwfdecAsObject
   SwfdecAsContext *context;
   SwfdecAsSuper *super;
 
-  g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+  g_return_if_fail (frame != NULL);
   g_return_if_fail (SWFDEC_IS_AS_OBJECT (thisp));
   g_return_if_fail (ref == NULL || SWFDEC_IS_AS_OBJECT (ref));
   
@@ -188,7 +188,7 @@ swfdec_as_super_new_chain (SwfdecAsFrame *frame, SwfdecAsSuper *super,
   SwfdecAsObject *ref;
   SwfdecAsContext *context;
 	  
-  g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+  g_return_if_fail (frame != NULL);
   g_return_if_fail (SWFDEC_IS_AS_SUPER (super));
 
   if (frame->super != NULL)
diff --git a/vivified/core/vivi_debugger.c b/vivified/core/vivi_debugger.c
index 98f4466..508b27e 100644
--- a/vivified/core/vivi_debugger.c
+++ b/vivified/core/vivi_debugger.c
@@ -186,10 +186,10 @@ vivi_debugger_class_init (ViviDebuggerClass *klass)
       G_TYPE_BOOLEAN, 0);
   signals[ENTER_FRAME] = g_signal_new ("enter-frame", G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_LAST, 0, vivi_accumulate_or, NULL, vivi_marshal_BOOLEAN__OBJECT,
-      G_TYPE_BOOLEAN, 1, SWFDEC_TYPE_AS_FRAME);
+      G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
   signals[LEAVE_FRAME] = g_signal_new ("leave-frame", G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_LAST, 0, vivi_accumulate_or, NULL, vivi_marshal_BOOLEAN__OBJECT_POINTER,
-      G_TYPE_BOOLEAN, 2, SWFDEC_TYPE_AS_FRAME, G_TYPE_POINTER);
+      G_TYPE_BOOLEAN, 2, G_TYPE_POINTER, G_TYPE_POINTER);
   signals[SET_VARIABLE] = g_signal_new ("set-variable", G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_LAST, 0, vivi_accumulate_or, NULL, vivi_marshal_BOOLEAN__OBJECT_STRING_POINTER,
       G_TYPE_BOOLEAN, 3, SWFDEC_TYPE_AS_OBJECT, G_TYPE_STRING, G_TYPE_POINTER);
diff --git a/vivified/core/vivi_wrap.c b/vivified/core/vivi_wrap.c
index 8f99ddb..98ac100 100644
--- a/vivified/core/vivi_wrap.c
+++ b/vivified/core/vivi_wrap.c
@@ -55,7 +55,6 @@ vivi_wrap_init (ViviWrap *wrap)
 SwfdecAsObject *
 vivi_wrap_object (ViviApplication *app, SwfdecAsObject *object)
 {
-  const char *name;
   SwfdecAsContext *cx;
   SwfdecAsObject *wrap;
   SwfdecAsValue val;
@@ -66,12 +65,7 @@ vivi_wrap_object (ViviApplication *app, SwfdecAsObject *object)
 
   cx = SWFDEC_AS_CONTEXT (app);
   wrap = g_object_new (VIVI_TYPE_WRAP, "context", cx, NULL);
-  /* frames are special */
-  if (SWFDEC_IS_AS_FRAME (object))
-    name = "Frame";
-  else
-    name = "Wrap";
-  swfdec_as_object_get_variable (cx->global, swfdec_as_context_get_string (cx, name), &val);
+  swfdec_as_object_get_variable (cx->global, swfdec_as_context_get_string (cx, "Wrap"), &val);
   if (SWFDEC_AS_VALUE_IS_OBJECT (&val))
     swfdec_as_object_set_constructor (wrap, SWFDEC_AS_VALUE_GET_OBJECT (&val));
   VIVI_WRAP (wrap)->wrap = object;
diff --git a/vivified/core/vivi_wrap_as.c b/vivified/core/vivi_wrap_as.c
index 901c2c3..79d942d 100644
--- a/vivified/core/vivi_wrap_as.c
+++ b/vivified/core/vivi_wrap_as.c
@@ -74,6 +74,7 @@ void
 vivi_wrap_name_get (SwfdecAsContext *cx, SwfdecAsObject *this,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
 {
+#if 0
   ViviWrap *wrap;
   char *s;
 
@@ -81,12 +82,11 @@ vivi_wrap_name_get (SwfdecAsContext *cx, SwfdecAsObject *this,
     return;
   
   wrap = VIVI_WRAP (this);
-  if (!SWFDEC_IS_AS_FRAME (wrap->wrap))
-    return;
   
   /* FIXME: improve */
   s = swfdec_as_object_get_debug (wrap->wrap);
   SWFDEC_AS_VALUE_SET_STRING (retval, swfdec_as_context_give_string (cx, s));
+#endif
 }
 
 VIVI_FUNCTION ("frame_code_get", vivi_wrap_code_get)
@@ -94,6 +94,7 @@ void
 vivi_wrap_code_get (SwfdecAsContext *cx, SwfdecAsObject *this,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
 {
+#if 0
   ViviWrap *wrap;
   SwfdecScript *script;
 
@@ -108,6 +109,7 @@ vivi_wrap_code_get (SwfdecAsContext *cx, SwfdecAsObject *this,
   /* FIXME: wrap scripts */
   if (script)
     SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
+#endif
 }
 
 VIVI_FUNCTION ("frame_next_get", vivi_wrap_next_get)
@@ -115,6 +117,7 @@ void
 vivi_wrap_next_get (SwfdecAsContext *cx, SwfdecAsObject *this,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
 {
+#if 0
   ViviWrap *wrap;
   SwfdecAsObject *obj;
 
@@ -128,6 +131,7 @@ vivi_wrap_next_get (SwfdecAsContext *cx, SwfdecAsObject *this,
   obj = SWFDEC_AS_OBJECT (swfdec_as_frame_get_next (SWFDEC_AS_FRAME (wrap->wrap)));
   if (obj)
     SWFDEC_AS_VALUE_SET_OBJECT (retval, vivi_wrap_object (VIVI_APPLICATION (cx), obj));
+#endif
 }
 
 VIVI_FUNCTION ("frame_this_get", vivi_wrap_this_get)
@@ -135,6 +139,7 @@ void
 vivi_wrap_this_get (SwfdecAsContext *cx, SwfdecAsObject *this,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
 {
+#if 0
   ViviWrap *wrap;
   SwfdecAsObject *obj;
 
@@ -148,6 +153,7 @@ vivi_wrap_this_get (SwfdecAsContext *cx, SwfdecAsObject *this,
   obj = SWFDEC_AS_OBJECT (swfdec_as_frame_get_this (SWFDEC_AS_FRAME (wrap->wrap)));
   if (obj)
     SWFDEC_AS_VALUE_SET_OBJECT (retval, vivi_wrap_object (VIVI_APPLICATION (cx), obj));
+#endif
 }
 
 
commit 90fae751fd27068e13ab74661ad3819177826823
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 17:13:45 2008 +0100

    make swfdec_as_frame_load() take the context as an argument

diff --git a/swfdec/swfdec_as_frame.c b/swfdec/swfdec_as_frame.c
index 4e5d9f1..2d40cd8 100644
--- a/swfdec/swfdec_as_frame.c
+++ b/swfdec/swfdec_as_frame.c
@@ -376,10 +376,8 @@ swfdec_as_frame_init (SwfdecAsFrame *frame)
 }
 
 static void
-swfdec_as_frame_load (SwfdecAsFrame *frame)
+swfdec_as_frame_load (SwfdecAsFrame *frame, SwfdecAsContext *context)
 {
-  SwfdecAsContext *context = swfdec_gc_object_get_context (frame->target);
-
   frame->stack_begin = context->cur;
   context->base = frame->stack_begin;
   frame->next = context->frame;
@@ -410,7 +408,7 @@ swfdec_as_frame_new (SwfdecAsContext *context, SwfdecScript *script)
       SWFDEC_ERROR ("couldn't create constant pool");
     }
   }
-  swfdec_as_frame_load (frame);
+  swfdec_as_frame_load (frame, context);
   return frame;
 }
 
@@ -425,7 +423,7 @@ swfdec_as_frame_new_native (SwfdecAsContext *context)
   size = sizeof (SwfdecAsFrame);
   frame = g_object_new (SWFDEC_TYPE_AS_FRAME, "context", context, NULL);
   SWFDEC_DEBUG ("new native frame");
-  swfdec_as_frame_load (frame);
+  swfdec_as_frame_load (frame, context);
   return frame;
 }
 
commit e0695cf6c9648a12d6fb6dd328e3a781d27be331
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 16:14:23 2008 +0100

    pass the context when popping blocks

diff --git a/swfdec/swfdec_as_context.c b/swfdec/swfdec_as_context.c
index 5ee575c..2a18326 100644
--- a/swfdec/swfdec_as_context.c
+++ b/swfdec/swfdec_as_context.c
@@ -900,7 +900,7 @@ swfdec_as_context_run (SwfdecAsContext *context)
     }
     while (check_block && (pc < frame->block_start || pc >= frame->block_end)) {
       SWFDEC_LOG ("code exited block");
-      swfdec_as_frame_pop_block (frame);
+      swfdec_as_frame_pop_block (frame, context);
       pc = frame->pc;
       if (frame != context->frame)
 	goto out;
diff --git a/swfdec/swfdec_as_frame.c b/swfdec/swfdec_as_frame.c
index 64a5197..4e5d9f1 100644
--- a/swfdec/swfdec_as_frame.c
+++ b/swfdec/swfdec_as_frame.c
@@ -238,7 +238,7 @@ swfdec_as_frame_push_block (SwfdecAsFrame *frame, const guint8 *start,
 }
 
 void
-swfdec_as_frame_pop_block (SwfdecAsFrame *frame)
+swfdec_as_frame_pop_block (SwfdecAsFrame *frame, SwfdecAsContext *cx)
 {
   SwfdecAsFrameBlockFunc func;
   gpointer data;
@@ -260,7 +260,7 @@ swfdec_as_frame_pop_block (SwfdecAsFrame *frame)
     frame->block_end = frame->script->buffer->data + frame->script->buffer->length;
   }
   /* only call function after we popped the block, so the block can push a new one */
-  func (frame, data);
+  func (cx, frame, data);
 }
 
 /*** FRAME ***/
@@ -274,7 +274,7 @@ swfdec_as_frame_dispose (GObject *object)
 
   /* pop blocks while state is intact */
   while (frame->blocks->len > 0)
-    swfdec_as_frame_pop_block (frame);
+    swfdec_as_frame_pop_block (frame, swfdec_gc_object_get_context (frame));
 
   /* clean up */
   g_slice_free1 (sizeof (SwfdecAsValue) * frame->n_registers, frame->registers);
@@ -829,7 +829,7 @@ swfdec_as_frame_handle_exception (SwfdecAsFrame *frame)
 
   /* pop blocks in the hope that we are inside a Try block */
   while (cx->exception && frame->blocks->len) {
-    swfdec_as_frame_pop_block (frame);
+    swfdec_as_frame_pop_block (frame, cx);
   }
   /* no Try blocks caught it, exit frame */
   if (cx->exception) {
diff --git a/swfdec/swfdec_as_frame_internal.h b/swfdec/swfdec_as_frame_internal.h
index 166363d..b5bd877 100644
--- a/swfdec/swfdec_as_frame_internal.h
+++ b/swfdec/swfdec_as_frame_internal.h
@@ -25,7 +25,7 @@
 
 G_BEGIN_DECLS
 
-typedef void (* SwfdecAsFrameBlockFunc) (SwfdecAsFrame *frame, gpointer data);
+typedef void (* SwfdecAsFrameBlockFunc) (SwfdecAsContext *cx, SwfdecAsFrame *frame, gpointer data);
 
 struct _SwfdecAsFrame {
   SwfdecAsObject	object;
@@ -97,7 +97,8 @@ void		swfdec_as_frame_push_block	(SwfdecAsFrame *	frame,
 						 const guint8 *		end,
 						 SwfdecAsFrameBlockFunc	func,
 						 gpointer		data);
-void		swfdec_as_frame_pop_block	(SwfdecAsFrame *	frame);
+void		swfdec_as_frame_pop_block	(SwfdecAsFrame *	frame,
+						 SwfdecAsContext *	context);
 void		swfdec_as_frame_handle_exception(SwfdecAsFrame *	frame);
 
 
diff --git a/swfdec/swfdec_as_interpret.c b/swfdec/swfdec_as_interpret.c
index af68aa2..040f8f1 100644
--- a/swfdec/swfdec_as_interpret.c
+++ b/swfdec/swfdec_as_interpret.c
@@ -2599,16 +2599,13 @@ swfdec_action_try_data_free (gpointer data)
 }
 
 static void
-swfdec_action_try_end_finally (SwfdecAsFrame *frame, gpointer data)
+swfdec_action_try_end_finally (SwfdecAsContext *cx, SwfdecAsFrame *frame, gpointer data)
 {
   SwfdecAsValue *exception_value = data;
-  SwfdecAsContext *cx;
 
   g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
   g_return_if_fail (SWFDEC_IS_AS_VALUE (exception_value));
 
-  cx = swfdec_gc_object_get_context (frame->target);
-
   // finally has ended and we had exception stored, throw it
   if (!cx->exception)
     swfdec_as_context_throw (cx, exception_value);
@@ -2617,17 +2614,14 @@ swfdec_action_try_end_finally (SwfdecAsFrame *frame, gpointer data)
 }
 
 static void
-swfdec_action_try_end_catch (SwfdecAsFrame *frame, gpointer data)
+swfdec_action_try_end_catch (SwfdecAsContext *cx, SwfdecAsFrame *frame, gpointer data)
 {
   TryData *try_data = data;
-  SwfdecAsContext *cx;
   SwfdecAsValue *exception_value, val;
 
   g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
   g_return_if_fail (try_data != NULL);
 
-  cx = swfdec_gc_object_get_context (frame->target);
-
   if (try_data->scope_object) {
     g_assert (frame->scope_chain->data == try_data->scope_object);
     frame->scope_chain =
@@ -2655,10 +2649,9 @@ swfdec_action_try_end_catch (SwfdecAsFrame *frame, gpointer data)
 }
 
 static void
-swfdec_action_try_end_try (SwfdecAsFrame *frame, gpointer data)
+swfdec_action_try_end_try (SwfdecAsContext *cx, SwfdecAsFrame *frame, gpointer data)
 {
   TryData *try_data = data;
-  SwfdecAsContext *cx;
   SwfdecAsValue val;
 
   g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
@@ -2667,12 +2660,10 @@ swfdec_action_try_end_try (SwfdecAsFrame *frame, gpointer data)
   // if we don't have a catch block, we handle try block exactly like it was
   // catch block
   if (!try_data->catch_start) {
-    swfdec_action_try_end_catch (frame, try_data);
+    swfdec_action_try_end_catch (cx, frame, try_data);
     return;
   }
 
-  cx = swfdec_gc_object_get_context (frame->target);
-
   if (swfdec_as_context_catch (cx, &val))
   {
     // we got an exception while in try block:
@@ -2762,7 +2753,7 @@ swfdec_action_try (SwfdecAsContext *cx, guint action, const guint8 *data, guint
 }
 
 static void
-swfdec_action_pop_with (SwfdecAsFrame *frame, gpointer with_object)
+swfdec_action_pop_with (SwfdecAsContext *cx, SwfdecAsFrame *frame, gpointer with_object)
 {
   g_assert (frame->scope_chain->data == with_object);
   frame->scope_chain = g_slist_delete_link (frame->scope_chain, frame->scope_chain);
commit f6da8ddf2338116e7a754d1d2d4e5533ac6f6f32
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 16:00:30 2008 +0100

    replace all frame calls to swfdec_gc_object_get_context()

diff --git a/swfdec/swfdec_as_frame.c b/swfdec/swfdec_as_frame.c
index 782f603..64a5197 100644
--- a/swfdec/swfdec_as_frame.c
+++ b/swfdec/swfdec_as_frame.c
@@ -87,7 +87,7 @@ swfdec_as_stack_iterator_init_arguments (SwfdecAsStackIterator *iter, SwfdecAsFr
     iter->current = NULL;
     return NULL;
   }
-  context = swfdec_gc_object_get_context (frame);
+  context = swfdec_gc_object_get_context (frame->target);
   if (frame->argv) {
     iter->stack = NULL;
     iter->current = (SwfdecAsValue *) frame->argv;
@@ -134,7 +134,7 @@ swfdec_as_stack_iterator_init (SwfdecAsStackIterator *iter, SwfdecAsFrame *frame
   g_return_val_if_fail (iter != NULL, NULL);
   g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
 
-  context = swfdec_gc_object_get_context (frame);
+  context = swfdec_gc_object_get_context (frame->target);
   iter->i = 0;
   stack = context->stack;
   if (context->frame == frame) {
@@ -378,7 +378,7 @@ swfdec_as_frame_init (SwfdecAsFrame *frame)
 static void
 swfdec_as_frame_load (SwfdecAsFrame *frame)
 {
-  SwfdecAsContext *context = swfdec_gc_object_get_context (frame);
+  SwfdecAsContext *context = swfdec_gc_object_get_context (frame->target);
 
   frame->stack_begin = context->cur;
   context->base = frame->stack_begin;
@@ -447,7 +447,7 @@ swfdec_as_frame_return (SwfdecAsFrame *frame, SwfdecAsValue *return_value)
   SwfdecAsFrame *next;
 
   g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
-  context = swfdec_gc_object_get_context (frame);
+  context = swfdec_gc_object_get_context (frame->target);
   g_return_if_fail (frame == context->frame);
 
   /* save return value in case it was on the stack somewhere */
@@ -558,7 +558,7 @@ swfdec_as_frame_get_variable_and_flags (SwfdecAsFrame *frame, const char *variab
   g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
   g_return_val_if_fail (variable != NULL, NULL);
 
-  cx = swfdec_gc_object_get_context (frame);
+  cx = swfdec_gc_object_get_context (frame->target);
 
   for (walk = frame->scope_chain; walk; walk = walk->next) {
     if (swfdec_as_object_get_variable_and_flags (walk->data, variable, value, 
@@ -581,7 +581,7 @@ swfdec_as_frame_get_variable_and_flags (SwfdecAsFrame *frame, const char *variab
   /* FIXME: ignored on version 4, but should it never be created instead? */
   if (cx->version > 4 && swfdec_as_object_get_variable_and_flags (cx->global,
 	variable, value, flags, pobject))
-    return swfdec_gc_object_get_context (frame)->global;
+    return cx->global;
 
   return NULL;
 }
@@ -642,7 +642,7 @@ swfdec_as_frame_delete_variable (SwfdecAsFrame *frame, const char *variable)
   if (ret)
     return ret;
   /* 2) the global object */
-  return swfdec_as_object_delete_variable (swfdec_gc_object_get_context (frame)->global, variable);
+  return swfdec_as_object_delete_variable (swfdec_gc_object_get_context (frame->target)->global, variable);
 }
 
 /**
@@ -681,7 +681,7 @@ swfdec_as_frame_preload (SwfdecAsFrame *frame)
   g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
 
   /* setup */
-  context = swfdec_gc_object_get_context (frame);
+  context = swfdec_gc_object_get_context (frame->target);
   script = frame->script;
   if (frame->script == NULL)
     goto out;
@@ -824,7 +824,7 @@ swfdec_as_frame_handle_exception (SwfdecAsFrame *frame)
   SwfdecAsContext *cx;
 
   g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
-  cx = swfdec_gc_object_get_context (frame);
+  cx = swfdec_gc_object_get_context (frame->target);
   g_return_if_fail (cx->exception);
 
   /* pop blocks in the hope that we are inside a Try block */
diff --git a/swfdec/swfdec_as_interpret.c b/swfdec/swfdec_as_interpret.c
index 4429652..af68aa2 100644
--- a/swfdec/swfdec_as_interpret.c
+++ b/swfdec/swfdec_as_interpret.c
@@ -2607,7 +2607,7 @@ swfdec_action_try_end_finally (SwfdecAsFrame *frame, gpointer data)
   g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
   g_return_if_fail (SWFDEC_IS_AS_VALUE (exception_value));
 
-  cx = swfdec_gc_object_get_context (frame);
+  cx = swfdec_gc_object_get_context (frame->target);
 
   // finally has ended and we had exception stored, throw it
   if (!cx->exception)
@@ -2626,7 +2626,7 @@ swfdec_action_try_end_catch (SwfdecAsFrame *frame, gpointer data)
   g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
   g_return_if_fail (try_data != NULL);
 
-  cx = swfdec_gc_object_get_context (frame);
+  cx = swfdec_gc_object_get_context (frame->target);
 
   if (try_data->scope_object) {
     g_assert (frame->scope_chain->data == try_data->scope_object);
@@ -2671,7 +2671,7 @@ swfdec_action_try_end_try (SwfdecAsFrame *frame, gpointer data)
     return;
   }
 
-  cx = swfdec_gc_object_get_context (frame);
+  cx = swfdec_gc_object_get_context (frame->target);
 
   if (swfdec_as_context_catch (cx, &val))
   {
diff --git a/swfdec/swfdec_as_super.c b/swfdec/swfdec_as_super.c
index d86cb36..f01b375 100644
--- a/swfdec/swfdec_as_super.c
+++ b/swfdec/swfdec_as_super.c
@@ -157,7 +157,7 @@ swfdec_as_super_new (SwfdecAsFrame *frame, SwfdecAsObject *thisp, SwfdecAsObject
   
   if (frame->super != NULL)
     return;
-  context = swfdec_gc_object_get_context (frame);
+  context = swfdec_gc_object_get_context (thisp);
   if (context->version <= 5)
     return;
 
@@ -199,7 +199,7 @@ swfdec_as_super_new_chain (SwfdecAsFrame *frame, SwfdecAsSuper *super,
   ref = super->object->prototype;
   if (ref == NULL)
     return;
-  context = swfdec_gc_object_get_context (frame);
+  context = swfdec_gc_object_get_context (super);
   if (function_name && context->version > 6) {
     /* skip prototypes to find the next one that has this function defined */
     SwfdecAsObject *res;
commit b43332242e664586424f15148d181db2dd816d42
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 15:55:43 2008 +0100

    don't make the frame the activation object, use a seperate one

diff --git a/swfdec/swfdec_as_frame.c b/swfdec/swfdec_as_frame.c
index 6bba46a..782f603 100644
--- a/swfdec/swfdec_as_frame.c
+++ b/swfdec/swfdec_as_frame.c
@@ -401,7 +401,6 @@ swfdec_as_frame_new (SwfdecAsContext *context, SwfdecScript *script)
   frame->script = swfdec_script_ref (script);
   SWFDEC_DEBUG ("new frame for function %s", script->name);
   frame->pc = script->main;
-  frame->scope_chain = g_slist_prepend (frame->scope_chain, frame);
   frame->n_registers = script->n_registers;
   frame->registers = g_slice_alloc0 (sizeof (SwfdecAsValue) * frame->n_registers);
   if (script->constant_pool) {
@@ -608,8 +607,8 @@ swfdec_as_frame_set_variable_and_flags (SwfdecAsFrame *frame, const char *variab
     }
   }
   if (set == NULL) {
-    if (local && frame->is_local) {
-      set = SWFDEC_AS_OBJECT (frame);
+    if (local && frame->activation) {
+      set = frame->activation;
     } else {
       set = frame->target;
     }
@@ -682,11 +681,13 @@ swfdec_as_frame_preload (SwfdecAsFrame *frame)
   g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
 
   /* setup */
-  object = SWFDEC_AS_OBJECT (frame);
   context = swfdec_gc_object_get_context (frame);
   script = frame->script;
   if (frame->script == NULL)
     goto out;
+  frame->activation = swfdec_as_object_new_empty (context);
+  object = frame->activation;
+  frame->scope_chain = g_slist_prepend (frame->scope_chain, object);
 
   /* create arguments and super object if necessary */
   if ((script->flags & (SWFDEC_SCRIPT_PRELOAD_ARGS | SWFDEC_SCRIPT_SUPPRESS_ARGS)) != SWFDEC_SCRIPT_SUPPRESS_ARGS) {
diff --git a/swfdec/swfdec_as_frame_internal.h b/swfdec/swfdec_as_frame_internal.h
index 0cc87c7..166363d 100644
--- a/swfdec/swfdec_as_frame_internal.h
+++ b/swfdec/swfdec_as_frame_internal.h
@@ -46,7 +46,7 @@ struct _SwfdecAsFrame {
   GArray *		blocks;		/* blocks we have entered (like With) */
   SwfdecAsObject *	target;		/* target to use as last object in scope chain or for SetVariable */
   SwfdecAsObject *	original_target;/* original target (used when resetting target) */
-  gboolean		is_local;	/* TRUE if this frame takes local variables */
+  SwfdecAsObject *	activation;	/* activation object or NULL if the frame takes no local variables */
   SwfdecAsValue *	registers;	/* the registers */
   guint			n_registers;	/* number of allocated registers */
   SwfdecConstantPool *	constant_pool;	/* constant pool currently in use */
diff --git a/swfdec/swfdec_as_function.c b/swfdec/swfdec_as_function.c
index be93e0c..9bc4156 100644
--- a/swfdec/swfdec_as_function.c
+++ b/swfdec/swfdec_as_function.c
@@ -125,7 +125,6 @@ swfdec_as_function_call_no_preload (SwfdecAsFunction *function,
   if (thisp != NULL && frame->thisp == NULL) {
     swfdec_as_frame_set_this (frame, swfdec_as_object_resolve (thisp));
   }
-  frame->is_local = TRUE;
   frame->argc = n_args;
   frame->argv = args;
   frame->return_value = return_value;
diff --git a/swfdec/swfdec_as_object.c b/swfdec/swfdec_as_object.c
index f23c7a7..22005fa 100644
--- a/swfdec/swfdec_as_object.c
+++ b/swfdec/swfdec_as_object.c
@@ -1205,6 +1205,8 @@ swfdec_as_object_run (SwfdecAsObject *object, SwfdecScript *script)
     return;
   swfdec_as_frame_set_this (frame, object);
   swfdec_as_frame_preload (frame);
+  /* we take no prisoners */
+  frame->activation = NULL;
   swfdec_as_context_run (context);
   swfdec_as_stack_pop (context);
 }
commit 2892c2e05047f4b0196038faeca1ce32540e8ab0
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 11:53:27 2008 +0100

    remove code that was only necessary for inlining

diff --git a/swfdec/swfdec_as_context.c b/swfdec/swfdec_as_context.c
index 2fd3e1d..5ee575c 100644
--- a/swfdec/swfdec_as_context.c
+++ b/swfdec/swfdec_as_context.c
@@ -789,7 +789,7 @@ swfdec_as_context_get_time (SwfdecAsContext *context, GTimeVal *tv)
 void
 swfdec_as_context_run (SwfdecAsContext *context)
 {
-  SwfdecAsFrame *frame, *last_frame;
+  SwfdecAsFrame *frame;
   SwfdecScript *script;
   const SwfdecActionSpec *spec;
   const guint8 *startpc, *pc, *endpc, *nextpc, *exitpc;
@@ -803,33 +803,31 @@ swfdec_as_context_run (SwfdecAsContext *context)
   gboolean check_block; /* some opcodes avoid a scope check */
 
   g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+  g_return_if_fail (context->frame != NULL);
+  g_return_if_fail (context->global); /* check here because of swfdec_sandbox_(un)use() */
 
-  if (context->frame == NULL || context->state == SWFDEC_AS_CONTEXT_ABORTED)
-    return;
-
-  if (context->debugger) {
-    SwfdecAsDebuggerClass *klass = SWFDEC_AS_DEBUGGER_GET_CLASS (context->debugger);
-    step = klass->step;
-  } else {
-    step = NULL;
-  }
-
-  last_frame = context->last_frame;
-  context->last_frame = context->frame->next;
+  /* setup data */
+  frame = context->frame;
   original_version = context->version;
-start:
-  g_return_if_fail (context->global); /* check here because of swfdec_sandbox_(un)use() */
+
+  /* sanity checks */
+  if (context->state == SWFDEC_AS_CONTEXT_ABORTED)
+    goto error;
   if (!swfdec_as_context_check_continue (context))
     goto error;
-  /* setup data */
-  frame = context->frame;
-  if (frame == context->last_frame)
-    goto out;
   if (context->call_depth > 256) {
     /* we've exceeded our maximum call depth, throw an error and abort */
     swfdec_as_context_abort (context, "Stack overflow");
     goto error;
   }
+
+  if (context->debugger) {
+    SwfdecAsDebuggerClass *klass = SWFDEC_AS_DEBUGGER_GET_CLASS (context->debugger);
+    step = klass->step;
+  } else {
+    step = NULL;
+  }
+
   if (SWFDEC_IS_AS_NATIVE_FUNCTION (frame->function)) {
     SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (frame->function);
     SwfdecAsValue rval = { 0, };
@@ -872,7 +870,7 @@ start:
       }
     }
     swfdec_as_frame_return (frame, &rval);
-    goto start;
+    goto out;
   }
   g_assert (frame->script);
   g_assert (frame->target);
@@ -888,13 +886,13 @@ start:
     if (context->exception) {
       swfdec_as_frame_handle_exception (frame);
       if (frame != context->frame)
-	goto start;
+	goto out;
       pc = frame->pc;
       continue;
     }
     if (pc == exitpc) {
       swfdec_as_frame_return (frame, NULL);
-      goto start;
+      goto out;
     }
     if (pc < startpc || pc >= endpc) {
       SWFDEC_ERROR ("pc %p not in valid range [%p, %p) anymore", pc, startpc, endpc);
@@ -905,7 +903,7 @@ start:
       swfdec_as_frame_pop_block (frame);
       pc = frame->pc;
       if (frame != context->frame)
-	goto start;
+	goto out;
       if (context->exception)
 	break;
     }
@@ -916,16 +914,16 @@ start:
     action = *pc;
     if (action == 0) {
       swfdec_as_frame_return (frame, NULL);
-      goto start;
+      goto out;
     }
     /* invoke debugger if there is one */
     if (step) {
       frame->pc = pc;
       (* step) (context->debugger, context);
-      if (frame != context->frame || 
-	  frame->pc != pc) {
-	goto start;
-      }
+      if (frame != context->frame)
+	goto out;
+      if (frame->pc != pc)
+	continue;
     }
     /* prepare action */
     spec = swfdec_as_actions + action;
@@ -998,15 +996,14 @@ start:
 #endif
     } else {
       /* someone called/returned from a function, reread variables */
-      goto start;
+      goto out;
     }
   }
 
 error:
-  while (context->frame != context->last_frame)
-    swfdec_as_frame_return (context->frame, NULL);
+  if (context->frame == frame)
+    swfdec_as_frame_return (frame, NULL);
 out:
-  context->last_frame = last_frame;
   context->version = original_version;
   return;
 }
diff --git a/swfdec/swfdec_as_context.h b/swfdec/swfdec_as_context.h
index 1e56dc6..9bf4aef 100644
--- a/swfdec/swfdec_as_context.h
+++ b/swfdec/swfdec_as_context.h
@@ -64,7 +64,6 @@ struct _SwfdecAsContext {
   unsigned int	      	version;	/* currently active version */
   unsigned int		call_depth;   	/* current depth of call stack (equals length of frame list) */
   SwfdecAsFrame *	frame;		/* topmost stack frame */
-  SwfdecAsFrame *	last_frame;   	/* last frame before calling context_run */
   gboolean		exception;	/* whether we are throwing an exception */
   SwfdecAsValue		exception_value; /* value of the exception being thrown, can be anything including undefined */
 
commit 7771101110ddce49b1b4fc5f3d8f041d739deb3b
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 11:30:46 2008 +0100

    remove empty line

diff --git a/swfdec/swfdec_as_frame.c b/swfdec/swfdec_as_frame.c
index 8b53051..6bba46a 100644
--- a/swfdec/swfdec_as_frame.c
+++ b/swfdec/swfdec_as_frame.c
@@ -681,7 +681,6 @@ swfdec_as_frame_preload (SwfdecAsFrame *frame)
 
   g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
 
-
   /* setup */
   object = SWFDEC_AS_OBJECT (frame);
   context = swfdec_gc_object_get_context (frame);
commit 36102bf713c26811d7e36137feb2ce882bbb1a2b
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 11:28:03 2008 +0100

    rename call vfunc to old_call in anticipation for new one

diff --git a/swfdec/swfdec_as_function.c b/swfdec/swfdec_as_function.c
index 8bea780..be93e0c 100644
--- a/swfdec/swfdec_as_function.c
+++ b/swfdec/swfdec_as_function.c
@@ -114,8 +114,8 @@ swfdec_as_function_call_no_preload (SwfdecAsFunction *function,
     SWFDEC_AS_VALUE_SET_UNDEFINED (return_value);
 
   klass = SWFDEC_AS_FUNCTION_GET_CLASS (function);
-  g_assert (klass->call);
-  frame = klass->call (function);
+  g_assert (klass->old_call);
+  frame = klass->old_call (function);
   /* FIXME: figure out what to do in these situations?
    * It's a problem when called inside swfdec_as_function_call () as the
    * user of that function expects success, but super may fail here */
diff --git a/swfdec/swfdec_as_function.h b/swfdec/swfdec_as_function.h
index fbc461d..9e66329 100644
--- a/swfdec/swfdec_as_function.h
+++ b/swfdec/swfdec_as_function.h
@@ -45,7 +45,7 @@ struct _SwfdecAsFunctionClass {
   SwfdecAsObjectClass	object_class;
 
   /* return a frame that calls this function or NULL if uncallable */
-  SwfdecAsFrame *	(* call)			(SwfdecAsFunction *	function);
+  SwfdecAsFrame *	(* old_call)			(SwfdecAsFunction *	function);
 };
 
 GType			swfdec_as_function_get_type	(void);
diff --git a/swfdec/swfdec_as_native_function.c b/swfdec/swfdec_as_native_function.c
index 312b877..7c4a3a0 100644
--- a/swfdec/swfdec_as_native_function.c
+++ b/swfdec/swfdec_as_native_function.c
@@ -53,7 +53,7 @@
 G_DEFINE_TYPE (SwfdecAsNativeFunction, swfdec_as_native_function, SWFDEC_TYPE_AS_FUNCTION)
 
 static SwfdecAsFrame *
-swfdec_as_native_function_call (SwfdecAsFunction *function)
+swfdec_as_native_function_old_call (SwfdecAsFunction *function)
 {
   SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (function);
   SwfdecAsFrame *frame;
@@ -107,7 +107,7 @@ swfdec_as_native_function_class_init (SwfdecAsNativeFunctionClass *klass)
 
   asobject_class->debug = swfdec_as_native_function_debug;
 
-  function_class->call = swfdec_as_native_function_call;
+  function_class->old_call = swfdec_as_native_function_old_call;
 }
 
 static void
diff --git a/swfdec/swfdec_as_script_function.c b/swfdec/swfdec_as_script_function.c
index d61f4f4..552224e 100644
--- a/swfdec/swfdec_as_script_function.c
+++ b/swfdec/swfdec_as_script_function.c
@@ -32,7 +32,7 @@
 G_DEFINE_TYPE (SwfdecAsScriptFunction, swfdec_as_script_function, SWFDEC_TYPE_AS_FUNCTION)
 
 static SwfdecAsFrame *
-swfdec_as_script_function_call (SwfdecAsFunction *function)
+swfdec_as_script_function_old_call (SwfdecAsFunction *function)
 {
   SwfdecAsScriptFunction *script = SWFDEC_AS_SCRIPT_FUNCTION (function);
   SwfdecAsFrame *frame;
@@ -106,7 +106,7 @@ swfdec_as_script_function_class_init (SwfdecAsScriptFunctionClass *klass)
 
   asobject_class->debug = swfdec_as_script_function_debug;
 
-  function_class->call = swfdec_as_script_function_call;
+  function_class->old_call = swfdec_as_script_function_old_call;
 }
 
 static void
diff --git a/swfdec/swfdec_as_super.c b/swfdec/swfdec_as_super.c
index 379c4b0..d86cb36 100644
--- a/swfdec/swfdec_as_super.c
+++ b/swfdec/swfdec_as_super.c
@@ -35,7 +35,7 @@
 G_DEFINE_TYPE (SwfdecAsSuper, swfdec_as_super, SWFDEC_TYPE_AS_FUNCTION)
 
 static SwfdecAsFrame *
-swfdec_as_super_call (SwfdecAsFunction *function)
+swfdec_as_super_old_call (SwfdecAsFunction *function)
 {
   SwfdecAsSuper *super = SWFDEC_AS_SUPER (function);
   SwfdecAsValue val;
@@ -54,7 +54,7 @@ swfdec_as_super_call (SwfdecAsFunction *function)
     return NULL;
 
   klass = SWFDEC_AS_FUNCTION_GET_CLASS (fun);
-  frame = klass->call (fun);
+  frame = klass->old_call (fun);
   if (frame == NULL)
     return NULL;
   /* We set the real function here. 1) swfdec_as_context_run() requires it. 
@@ -137,7 +137,7 @@ swfdec_as_super_class_init (SwfdecAsSuperClass *klass)
   asobject_class->del = swfdec_as_super_delete;
   asobject_class->resolve = swfdec_as_super_resolve;
 
-  function_class->call = swfdec_as_super_call;
+  function_class->old_call = swfdec_as_super_old_call;
 }
 
 static void
commit 4bc16a88286201efedbf8787c1cdf6e298ef8e51
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 11:02:39 2008 +0100

    make swfdec_as_object_create() call swfdec_as_context_run()

diff --git a/swfdec/swfdec_as_interpret.c b/swfdec/swfdec_as_interpret.c
index 97d1a13..4429652 100644
--- a/swfdec/swfdec_as_interpret.c
+++ b/swfdec/swfdec_as_interpret.c
@@ -1732,7 +1732,6 @@ swfdec_action_new_object (SwfdecAsContext *cx, guint action, const guint8 *data,
 
   swfdec_as_stack_pop_n (cx, 2);
   swfdec_as_object_create (fun, n_args, NULL, NULL);
-  swfdec_as_context_run (cx);
   return;
 
 fail:
@@ -1772,7 +1771,6 @@ swfdec_action_new_method (SwfdecAsContext *cx, guint action, const guint8 *data,
 
   swfdec_as_stack_pop_n (cx, 3);
   swfdec_as_object_create (fun, n_args, NULL, NULL);
-  swfdec_as_context_run (cx);
   return;
 
 fail:
diff --git a/swfdec/swfdec_as_object.c b/swfdec/swfdec_as_object.c
index cc726de..f23c7a7 100644
--- a/swfdec/swfdec_as_object.c
+++ b/swfdec/swfdec_as_object.c
@@ -1262,9 +1262,7 @@ swfdec_as_object_call (SwfdecAsObject *object, const char *name, guint argc,
  * @return_value: pointer for return value or %NULL to push the return value to 
  *                the stack
  *
- * 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 
- * swfdec_as_context_run().
+ * Creates a new object for the given constructor and runs the constructor.
  **/
 void
 swfdec_as_object_create (SwfdecAsFunction *fun, guint n_args, 
@@ -1333,6 +1331,7 @@ swfdec_as_object_create (SwfdecAsFunction *fun, guint n_args,
   frame->construct = TRUE;
   swfdec_as_super_new (frame, new, new->prototype);
   swfdec_as_frame_preload (frame);
+  swfdec_as_context_run (context);
 }
 
 /**
diff --git a/swfdec/swfdec_as_types.c b/swfdec/swfdec_as_types.c
index 2500a26..9c6d70e 100644
--- a/swfdec/swfdec_as_types.c
+++ b/swfdec/swfdec_as_types.c
@@ -606,7 +606,6 @@ swfdec_as_value_to_object (SwfdecAsContext *context, const SwfdecAsValue *value)
       !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val)))
     return NULL;
   swfdec_as_object_create (fun, 1, value, &val);
-  swfdec_as_context_run (context);
   if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
     return SWFDEC_AS_VALUE_GET_OBJECT (&val);
   } else {
diff --git a/swfdec/swfdec_bitmap_data.c b/swfdec/swfdec_bitmap_data.c
index 94abc10..dbcc3a3 100644
--- a/swfdec/swfdec_bitmap_data.c
+++ b/swfdec/swfdec_bitmap_data.c
@@ -257,7 +257,6 @@ swfdec_bitmap_data_get_rectangle (SwfdecAsContext *cx, SwfdecAsObject *object,
   SWFDEC_AS_VALUE_SET_INT (&args[2], cairo_image_surface_get_width (bitmap->surface));
   SWFDEC_AS_VALUE_SET_INT (&args[3], cairo_image_surface_get_width (bitmap->surface));
   swfdec_as_object_create (SWFDEC_AS_FUNCTION (o), 4, args, ret);
-  swfdec_as_context_run (cx);
 }
 
 SWFDEC_AS_NATIVE (1100, 105, swfdec_bitmap_data_set_rectangle)
commit b4dfdc0b2cb4e8b502ed76a87fcfd60da8ef9b2d
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 10:55:47 2008 +0100

    no more function inlining: call swfdec_as_context_run() everytime
    
    step 1 for rewriting function calling

diff --git a/swfdec/swfdec_as_interpret.c b/swfdec/swfdec_as_interpret.c
index 93a6226..97d1a13 100644
--- a/swfdec/swfdec_as_interpret.c
+++ b/swfdec/swfdec_as_interpret.c
@@ -827,6 +827,7 @@ swfdec_action_call_function (SwfdecAsContext *cx, guint action, const guint8 *da
   frame = swfdec_action_call (cx, n_args);
   if (frame) {
     swfdec_as_frame_preload (frame);
+    swfdec_as_context_run (cx);
   } else {
     SWFDEC_WARNING ("no function named %s", name);
   }
@@ -878,6 +879,7 @@ swfdec_action_call_method (SwfdecAsContext *cx, guint action, const guint8 *data
       swfdec_as_super_new (frame, obj, obj->prototype);
     }
     swfdec_as_frame_preload (frame);
+    swfdec_as_context_run (cx);
   } else {
     SWFDEC_WARNING ("no function named \"%s\" on object %s", name, obj ? G_OBJECT_TYPE_NAME(obj) : "unknown");
   }
@@ -1730,6 +1732,7 @@ swfdec_action_new_object (SwfdecAsContext *cx, guint action, const guint8 *data,
 
   swfdec_as_stack_pop_n (cx, 2);
   swfdec_as_object_create (fun, n_args, NULL, NULL);
+  swfdec_as_context_run (cx);
   return;
 
 fail:
@@ -1769,6 +1772,7 @@ swfdec_action_new_method (SwfdecAsContext *cx, guint action, const guint8 *data,
 
   swfdec_as_stack_pop_n (cx, 3);
   swfdec_as_object_create (fun, n_args, NULL, NULL);
+  swfdec_as_context_run (cx);
   return;
 
 fail:
commit 8660d7952769a757f6964e8f35bcf54296a876e3
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Aug 4 01:30:54 2008 +0100

    changes semantics of optional arguments for SWFDEC_AS_CHECK
    
    previously, optional arguments where initialized to a default value depending
    on the type of the value (0, FALSE, "" etc). Now they don't get touched at
    all. This requires initializing them to their default value prior to calling
    SWFDEC_AS_CHECK.
    All users of this API were fixed.

diff --git a/swfdec/swfdec_as_function.c b/swfdec/swfdec_as_function.c
index edeb990..8bea780 100644
--- a/swfdec/swfdec_as_function.c
+++ b/swfdec/swfdec_as_function.c
@@ -176,7 +176,7 @@ swfdec_as_function_do_call (SwfdecAsContext *cx, SwfdecAsObject *object,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
 {
   SwfdecAsFunction *fun;
-  SwfdecAsObject *thisp;
+  SwfdecAsObject *thisp = NULL;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_FUNCTION, &fun, "|O", &thisp);
 
@@ -199,7 +199,7 @@ swfdec_as_function_apply (SwfdecAsContext *cx, SwfdecAsObject *object,
   SwfdecAsValue *argv_pass = NULL;
   int length = 0;
   SwfdecAsFunction *fun;
-  SwfdecAsObject *thisp;
+  SwfdecAsObject *thisp = NULL;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_FUNCTION, &fun, "|O", &thisp);
 
diff --git a/swfdec/swfdec_as_native_function.c b/swfdec/swfdec_as_native_function.c
index 90a483e..312b877 100644
--- a/swfdec/swfdec_as_native_function.c
+++ b/swfdec/swfdec_as_native_function.c
@@ -286,63 +286,43 @@ swfdec_as_native_function_checkv (SwfdecAsContext *cx, SwfdecAsObject *object,
       return FALSE;
     *result = object;
   }
-  for (i = 0; *args; i++, args++) {
-    if (!optional && i >= argc && *args != '|')
-      break;
+  for (i = 0; *args && i < argc; i++, args++) {
     switch (*args) {
       case 'v':
 	{
 	  SwfdecAsValue *val = va_arg (varargs, SwfdecAsValue *);
-	  if (i < argc)
-	    *val = argv[i];
-	  else
-	    SWFDEC_AS_VALUE_SET_UNDEFINED (val);
+	  *val = argv[i];
 	}
 	break;
       case 'b':
 	{
 	  gboolean *b = va_arg (varargs, gboolean *);
-	  if (i < argc)
-	    *b = swfdec_as_value_to_boolean (cx, &argv[i]);
-	  else
-	    *b = FALSE;
+	  *b = swfdec_as_value_to_boolean (cx, &argv[i]);
 	}
 	break;
       case 'i':
 	{
 	  int *j = va_arg (varargs, int *);
-	  if (i < argc)
-	    *j = swfdec_as_value_to_integer (cx, &argv[i]);
-	  else
-	    *j = 0;
+	  *j = swfdec_as_value_to_integer (cx, &argv[i]);
 	}
 	break;
       case 'n':
 	{
 	  double *d = va_arg (varargs, double *);
-	  if (i < argc)
-	    *d = swfdec_as_value_to_number (cx, &argv[i]);
-	  else
-	    *d = 0;
+	  *d = swfdec_as_value_to_number (cx, &argv[i]);
 	}
 	break;
       case 's':
 	{
 	  const char **s = va_arg (varargs, const char **);
-	  if (i < argc)
-	    *s = swfdec_as_value_to_string (cx, &argv[i]);
-	  else
-	    *s = SWFDEC_AS_STR_EMPTY;
+	  *s = swfdec_as_value_to_string (cx, &argv[i]);
 	}
 	break;
       case 'o':
       case 'O':
 	{
 	  SwfdecAsObject **o = va_arg (varargs, SwfdecAsObject **);
-	  if (i < argc)
-	    *o = swfdec_as_value_to_object (cx, &argv[i]);
-	  else
-	    *o = NULL;
+	  *o = swfdec_as_value_to_object (cx, &argv[i]);
 	  if (*o == NULL && *args != 'O')
 	    return FALSE;
 	}
@@ -357,7 +337,7 @@ swfdec_as_native_function_checkv (SwfdecAsContext *cx, SwfdecAsObject *object,
 	return FALSE;
     }
   }
-  if (*args)
+  if (*args && !optional && *args != '|')
     return FALSE;
   return TRUE;
 }
diff --git a/swfdec/swfdec_as_number.c b/swfdec/swfdec_as_number.c
index a7e99f6..75d0cb5 100644
--- a/swfdec/swfdec_as_number.c
+++ b/swfdec/swfdec_as_number.c
@@ -119,7 +119,7 @@ swfdec_as_number_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
   SwfdecAsNumber *num;
   SwfdecAsValue val;
   const char *s;
-  int radix;
+  int radix = 10;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_NUMBER, &num, "|i", &radix);
 
diff --git a/swfdec/swfdec_as_strings.c b/swfdec/swfdec_as_strings.c
index a5106eb..735b25a 100644
--- a/swfdec/swfdec_as_strings.c
+++ b/swfdec/swfdec_as_strings.c
@@ -529,5 +529,6 @@ const char swfdec_as_strings[] =
   SWFDEC_AS_CONSTANT_STRING ("tx")
   SWFDEC_AS_CONSTANT_STRING ("ty")
   SWFDEC_AS_CONSTANT_STRING ("Invalid Date")
+  SWFDEC_AS_CONSTANT_STRING ("auto")
   /* add more here */
 ;
diff --git a/swfdec/swfdec_bitmap_data.c b/swfdec/swfdec_bitmap_data.c
index 9abc1e5..94abc10 100644
--- a/swfdec/swfdec_bitmap_data.c
+++ b/swfdec/swfdec_bitmap_data.c
@@ -406,10 +406,10 @@ void
 swfdec_bitmap_data_copyPixels (SwfdecAsContext *cx, SwfdecAsObject *object,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
 {
-  SwfdecBitmapData *bitmap, *source, *alpha;
-  SwfdecAsObject *recto, *apt, *pt;
+  SwfdecBitmapData *bitmap, *source, *alpha = NULL;
+  SwfdecAsObject *recto, *pt, *apt = NULL;
   SwfdecRectangle rect;
-  gboolean copy_alpha;
+  gboolean copy_alpha = FALSE;
   cairo_t *cr;
   int x, y;
 
@@ -538,7 +538,7 @@ void
 swfdec_bitmap_data_draw (SwfdecAsContext *cx, SwfdecAsObject *object,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
 {
-  SwfdecAsObject *o, *matrix, *trans;
+  SwfdecAsObject *o, *matrix = NULL, *trans = NULL;
   cairo_t *cr;
   SwfdecColorTransform ctrans;
   SwfdecBitmapData *bitmap;
@@ -791,8 +791,8 @@ swfdec_bitmap_data_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
 {
   SwfdecBitmapData *bitmap;
   int w, h;
-  gboolean transparent;
-  guint color;
+  gboolean transparent = TRUE;
+  guint color = 0;
 
   if (!swfdec_as_context_is_constructing (cx))
     return;
@@ -804,8 +804,6 @@ swfdec_bitmap_data_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
     SWFDEC_FIXME ("the constructor should return undefined here");
     return;
   }
-  if (argc < 3)
-    transparent = TRUE;
 
   if (!swfdec_as_context_try_use_mem (cx, w * h * 4))
     return;
diff --git a/swfdec/swfdec_load_object_as.c b/swfdec/swfdec_load_object_as.c
index 1ee7dd6..0326a37 100644
--- a/swfdec/swfdec_load_object_as.c
+++ b/swfdec/swfdec_load_object_as.c
@@ -181,7 +181,7 @@ void
 swfdec_load_object_as_send (SwfdecAsContext *cx, SwfdecAsObject *object,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
-  const char *url, *target, *method, *data;
+  const char *url, *target = SWFDEC_AS_STR_EMPTY, *method = NULL, *data;
   guint header_count;
   char **header_names, **header_values;
   SwfdecAsValue val;
@@ -216,7 +216,7 @@ void
 swfdec_load_object_as_sendAndLoad (SwfdecAsContext *cx, SwfdecAsObject *object,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
-  const char *url, *data, *method;
+  const char *url, *data, *method = NULL;
   guint header_count;
   char **header_names, **header_values;
   SwfdecAsObject *target;
diff --git a/swfdec/swfdec_movie_as_drawing.c b/swfdec/swfdec_movie_as_drawing.c
index c42ad88..75a1050 100644
--- a/swfdec/swfdec_movie_as_drawing.c
+++ b/swfdec/swfdec_movie_as_drawing.c
@@ -81,7 +81,7 @@ swfdec_sprite_movie_beginFill (SwfdecAsContext *cx, SwfdecAsObject *object,
 {
   SwfdecMovie *movie;
   SwfdecDraw *draw;
-  int color, alpha;
+  int color, alpha = 100;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "|ii", &color, &alpha);
   movie->draw_fill = NULL;
@@ -90,9 +90,6 @@ swfdec_sprite_movie_beginFill (SwfdecAsContext *cx, SwfdecAsObject *object,
     color = 0;
   } else {
     color = color & 0xFFFFFF;
-    if (argc <= 1) {
-      alpha = 255;
-    }
     color = SWFDEC_COLOR_FROM_COLOR_ALPHA (color, alpha);
   }
   draw = SWFDEC_DRAW (swfdec_pattern_new_color (color));
@@ -188,13 +185,9 @@ swfdec_sprite_movie_beginGradientFill (SwfdecAsContext *cx, SwfdecAsObject *obje
   gboolean radial;
   int i, len;
 
-  SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "|sOOOO", &s, &colors, &alphas, &ratios, &matrix);
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "soooo", &s, &colors, &alphas, &ratios, &matrix);
   movie->draw_fill = NULL;
   
-  if (colors == NULL || alphas == NULL || ratios == NULL || matrix == NULL) {
-    SWFDEC_ERROR ("could not convert one of the parameters to an object");
-    return;
-  }
   if (s == SWFDEC_AS_STR_linear) {
     radial = FALSE;
   } else if (s == SWFDEC_AS_STR_radial) {
@@ -268,7 +261,7 @@ swfdec_sprite_movie_moveTo (SwfdecAsContext *cx, SwfdecAsObject *object,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
   SwfdecMovie *movie;
-  double x, y;
+  double x = 0, y = 0;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "|nn", &x, &y);
 
@@ -357,15 +350,13 @@ swfdec_sprite_movie_lineStyle (SwfdecAsContext *cx, SwfdecAsObject *object,
 {
   SwfdecMovie *movie;
   SwfdecStroke *stroke;
-  int width, color, alpha;
+  int width, color = 0, alpha = 100;
 
-  SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "|iii", &width, &color, &alpha);
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "i|ii", &width, &color, &alpha);
 
   movie->draw_line = NULL;
-  if (argc < 1 || SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
+  if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
     return;
-  if (argc < 3)
-    alpha = 100;
   if (argc > 3) {
     SWFDEC_FIXME ("implement Flash 8 arguments to lineStyle");
   }
diff --git a/swfdec/swfdec_player_as.c b/swfdec/swfdec_player_as.c
index 86f9ded..2455156 100644
--- a/swfdec/swfdec_player_as.c
+++ b/swfdec/swfdec_player_as.c
@@ -293,7 +293,7 @@ ASSetNativeAccessor (SwfdecAsContext *cx, SwfdecAsObject *object,
   SwfdecAsVariableFlag flags;
   const char *s;
   char **names;
-  guint i, x, y;
+  guint i, x, y = 0;
 
   SWFDEC_AS_CHECK (0, NULL, "ois|i", &target, &x, &s, &y);
 
diff --git a/swfdec/swfdec_sound_object.c b/swfdec/swfdec_sound_object.c
index 8150c78..d5f959b 100644
--- a/swfdec/swfdec_sound_object.c
+++ b/swfdec/swfdec_sound_object.c
@@ -392,8 +392,8 @@ swfdec_sound_object_start (SwfdecAsContext *cx, SwfdecAsObject *object, guint ar
 {
   SwfdecSoundObject *sound;
   SwfdecActor *actor;
-  double offset;
-  int loops;
+  double offset = 0;
+  int loops = 1;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_SOUND_OBJECT, &sound, "|ni", &offset, &loops);
   actor = swfdec_sound_object_get_actor (sound);
@@ -404,7 +404,7 @@ swfdec_sound_object_start (SwfdecAsContext *cx, SwfdecAsObject *object, guint ar
     SWFDEC_INFO ("no sound attached when calling Sound.start()");
     return;
   }
-  if (argc < 2 || loops <= 0)
+  if (loops <= 0)
     loops = 1;
   if (offset < 0 || !isfinite (offset))
     offset = 0;
@@ -418,7 +418,7 @@ swfdec_sound_object_stop (SwfdecAsContext *cx, SwfdecAsObject *object, guint arg
     SwfdecAsValue *argv, SwfdecAsValue *ret)
 {
   SwfdecSoundObject *sound;
-  const char *name;
+  const char *name = NULL;
   SwfdecSound *stopme;
   SwfdecActor *actor;
 
@@ -427,7 +427,7 @@ swfdec_sound_object_stop (SwfdecAsContext *cx, SwfdecAsObject *object, guint arg
   if (actor == NULL)
     return;
 
-  if (argc > 0) {
+  if (name) {
     stopme = swfdec_sound_object_get_sound (sound, name);
     if (stopme == NULL)
       return;
diff --git a/swfdec/swfdec_sprite_movie_as.c b/swfdec/swfdec_sprite_movie_as.c
index b4b0785..b1bb452 100644
--- a/swfdec/swfdec_sprite_movie_as.c
+++ b/swfdec/swfdec_sprite_movie_as.c
@@ -350,8 +350,8 @@ swfdec_sprite_movie_attachBitmap (SwfdecAsContext *cx, SwfdecAsObject *object,
 {
   SwfdecMovie *parent;
   SwfdecBitmapData *bitmap;
-  const char *snapping;
-  gboolean smoothing;
+  const char *snapping = SWFDEC_AS_STR_auto;
+  gboolean smoothing = FALSE;
   int depth;
   SwfdecMovie *movie;
 
diff --git a/test/swfdec_test_buffer.c b/test/swfdec_test_buffer.c
index 3d5c74d..f9064d3 100644
--- a/test/swfdec_test_buffer.c
+++ b/test/swfdec_test_buffer.c
@@ -140,7 +140,7 @@ void
 swfdec_test_buffer_diff (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
     SwfdecAsValue *argv, SwfdecAsValue *retval)
 {
-  SwfdecTestBuffer *buffer, *compare;
+  SwfdecTestBuffer *buffer, *compare = NULL;
   GError *error = NULL;
   char *ret;
   
@@ -215,7 +215,7 @@ swfdec_test_buffer_sub (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
   SwfdecBuffer *b;
   SwfdecTestBuffer *buffer;
   SwfdecAsObject *o;
-  guint offset, length;
+  guint offset, length = 0;
   
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_BUFFER, &buffer, "i|i", &offset, &length);
 
diff --git a/test/swfdec_test_image.c b/test/swfdec_test_image.c
index 388df6b..b54f713 100644
--- a/test/swfdec_test_image.c
+++ b/test/swfdec_test_image.c
@@ -211,10 +211,7 @@ swfdec_test_image_create (SwfdecAsContext *cx, SwfdecAsObject *object, guint arg
   SwfdecTestImage *image;
   const char *filename;
 
-  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_IMAGE, &image, "|s", &filename);
-
-  if (filename[0] == '\0')
-    return;
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_IMAGE, &image, "s", &filename);
 
   image->surface = cairo_image_surface_create_from_png (filename);
 }
diff --git a/test/swfdec_test_socket.c b/test/swfdec_test_socket.c
index c6655c3..2b65f14 100644
--- a/test/swfdec_test_socket.c
+++ b/test/swfdec_test_socket.c
@@ -119,7 +119,7 @@ swfdec_test_socket_receive (SwfdecAsContext *cx, SwfdecAsObject *object, guint a
 {
   SwfdecTestSocket *sock;
   SwfdecBuffer *buffer;
-  gsize len, depth;
+  gsize len = 0, depth;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_SOCKET, &sock, "|i", &len);
 
diff --git a/test/swfdec_test_test.c b/test/swfdec_test_test.c
index ae8f502..b567d32 100644
--- a/test/swfdec_test_test.c
+++ b/test/swfdec_test_test.c
@@ -236,7 +236,7 @@ swfdec_test_test_reset (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
     SwfdecAsValue *argv, SwfdecAsValue *retval)
 {
   SwfdecTestTest *test;
-  const char *filename;
+  const char *filename = NULL;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "|s", &filename);
 
@@ -270,7 +270,7 @@ swfdec_test_test_mouse_press (SwfdecAsContext *cx, SwfdecAsObject *object, guint
 {
   SwfdecTestTest *test;
   double x, y;
-  int button;
+  int button = 1;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "nn|i", &x, &y, &button);
 
@@ -292,7 +292,7 @@ swfdec_test_test_mouse_release (SwfdecAsContext *cx, SwfdecAsObject *object, gui
 {
   SwfdecTestTest *test;
   double x, y;
-  int button;
+  int button = 1;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "nn|i", &x, &y, &button);
 
@@ -314,7 +314,7 @@ swfdec_test_test_render (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc
 {
   SwfdecTestTest *test;
   SwfdecAsObject *image;
-  int x, y, w, h;
+  int x = 0, y = 0, w = 0, h = 0;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "|iiii", &x, &y, &w, &h);
 
@@ -343,11 +343,11 @@ swfdec_test_test_new (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
     SwfdecAsValue *argv, SwfdecAsValue *retval)
 {
   SwfdecTestTest *test;
-  const char *filename;
+  const char *filename = NULL;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "|s", &filename);
 
-  swfdec_test_do_reset (test, filename[0] ? filename : NULL);
+  swfdec_test_do_reset (test, filename);
 }
 
 SWFDEC_TEST_FUNCTION ("Test_get_launched", swfdec_test_test_get_launched, 0)
commit bbe6ab85db20b9eeff905399c32284f81606a4b1
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Aug 3 21:42:39 2008 +0100

    get rid of debug string in SwfdecAsFrame

diff --git a/swfdec/swfdec_as_frame.c b/swfdec/swfdec_as_frame.c
index f85843c..8b53051 100644
--- a/swfdec/swfdec_as_frame.c
+++ b/swfdec/swfdec_as_frame.c
@@ -332,7 +332,9 @@ swfdec_as_frame_debug (SwfdecAsObject *object)
     g_string_append (string, ".");
     g_free (s);
   }
-  g_string_append (string, frame->function_name);
+  s = swfdec_as_object_get_debug (SWFDEC_AS_OBJECT (frame->function));
+  g_string_append (string, s);
+  g_free (s);
   g_string_append (string, " (");
   i = 0;
   for (val = swfdec_as_stack_iterator_init_arguments (&iter, frame); val && i < 4;
@@ -369,7 +371,6 @@ swfdec_as_frame_class_init (SwfdecAsFrameClass *klass)
 static void
 swfdec_as_frame_init (SwfdecAsFrame *frame)
 {
-  frame->function_name = "unnamed";
   frame->blocks = g_array_new (FALSE, FALSE, sizeof (SwfdecAsFrameBlock));
   frame->block_end = (gpointer) -1;
 }
@@ -398,8 +399,7 @@ swfdec_as_frame_new (SwfdecAsContext *context, SwfdecScript *script)
   size = sizeof (SwfdecAsFrame) + sizeof (SwfdecAsValue) * script->n_registers;
   frame = g_object_new (SWFDEC_TYPE_AS_FRAME, "context", context, NULL);
   frame->script = swfdec_script_ref (script);
-  frame->function_name = script->name;
-  SWFDEC_DEBUG ("new frame for function %s", frame->function_name);
+  SWFDEC_DEBUG ("new frame for function %s", script->name);
   frame->pc = script->main;
   frame->scope_chain = g_slist_prepend (frame->scope_chain, frame);
   frame->n_registers = script->n_registers;
@@ -855,24 +855,6 @@ swfdec_as_frame_get_next (SwfdecAsFrame *frame)
 }
 
 /**
- * swfdec_as_frame_get_function_name:
- * @frame: a #SwfdecAsFrame
- *
- * Gets the name of the function that is currently executing. This function is
- * intended for debugging purposes.
- *
- * Returns: a string. Do not free.
- **/
-const char *
-swfdec_as_frame_get_function_name (SwfdecAsFrame *frame)
-{
-  g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
-
-  g_assert (frame->function_name);
-  return frame->function_name;
-}
-
-/**
  * swfdec_as_frame_get_script:
  * @frame: a #SwfdecAsFrame
  *
diff --git a/swfdec/swfdec_as_frame.h b/swfdec/swfdec_as_frame.h
index db58580..7aa93f2 100644
--- a/swfdec/swfdec_as_frame.h
+++ b/swfdec/swfdec_as_frame.h
@@ -47,7 +47,6 @@ struct _SwfdecAsStackIterator {
 GType		swfdec_as_frame_get_type	(void);
 
 SwfdecAsFrame *	swfdec_as_frame_get_next	(SwfdecAsFrame *		frame);
-const char *	swfdec_as_frame_get_function_name (SwfdecAsFrame *		frame);
 SwfdecScript *	swfdec_as_frame_get_script	(SwfdecAsFrame *		frame);
 SwfdecAsObject *swfdec_as_frame_get_this	(SwfdecAsFrame *		frame);
 
diff --git a/swfdec/swfdec_as_frame_internal.h b/swfdec/swfdec_as_frame_internal.h
index 712c3e6..0cc87c7 100644
--- a/swfdec/swfdec_as_frame_internal.h
+++ b/swfdec/swfdec_as_frame_internal.h
@@ -38,8 +38,6 @@ struct _SwfdecAsFrame {
   SwfdecAsValue *	return_value;	/* pointer to where to store the return value */
   guint			argc;		/* number of arguments */
   const SwfdecAsValue *	argv;		/* arguments or %NULL if taken from stack */
-  /* debugging */
-  const char *		function_name;	/* name of function */
   /* script execution */
   SwfdecScript *	script;		/* script being executed */
   GSList *		scope_chain;  	/* the scope chain (with objects etc) */
diff --git a/swfdec/swfdec_as_native_function.c b/swfdec/swfdec_as_native_function.c
index 767fced..90a483e 100644
--- a/swfdec/swfdec_as_native_function.c
+++ b/swfdec/swfdec_as_native_function.c
@@ -64,7 +64,6 @@ swfdec_as_native_function_call (SwfdecAsFunction *function)
   if (frame == NULL)
     return NULL;
   g_assert (native->name);
-  frame->function_name = native->name;
   frame->function = function;
   /* We copy the target here so we have a proper SwfdecMovie reference inside native 
    * functions. This is for example necessary for swfdec_player_get_movie_by_value()
diff --git a/vivified/core/vivi_wrap_as.c b/vivified/core/vivi_wrap_as.c
index 8110286..901c2c3 100644
--- a/vivified/core/vivi_wrap_as.c
+++ b/vivified/core/vivi_wrap_as.c
@@ -75,7 +75,7 @@ vivi_wrap_name_get (SwfdecAsContext *cx, SwfdecAsObject *this,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
 {
   ViviWrap *wrap;
-  const char *s;
+  char *s;
 
   if (!VIVI_IS_WRAP (this))
     return;
@@ -84,8 +84,9 @@ vivi_wrap_name_get (SwfdecAsContext *cx, SwfdecAsObject *this,
   if (!SWFDEC_IS_AS_FRAME (wrap->wrap))
     return;
   
-  s = swfdec_as_frame_get_function_name (SWFDEC_AS_FRAME (wrap->wrap));
-  SWFDEC_AS_VALUE_SET_STRING (retval, swfdec_as_context_get_string (cx, s));
+  /* FIXME: improve */
+  s = swfdec_as_object_get_debug (wrap->wrap);
+  SWFDEC_AS_VALUE_SET_STRING (retval, swfdec_as_context_give_string (cx, s));
 }
 
 VIVI_FUNCTION ("frame_code_get", vivi_wrap_code_get)
commit 5c6fe4d6a6c89147d62d81976d7a6e87592273a7
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Aug 3 19:58:12 2008 +0100

    get rid of native functions' min_args and type arguments
    
    This is solved by the SWFDEC_AS_CHECK macro these days

diff --git a/swfdec/swfdec_as_context.c b/swfdec/swfdec_as_context.c
index 4234dff..2fd3e1d 100644
--- a/swfdec/swfdec_as_context.c
+++ b/swfdec/swfdec_as_context.c
@@ -833,11 +833,8 @@ start:
   if (SWFDEC_IS_AS_NATIVE_FUNCTION (frame->function)) {
     SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (frame->function);
     SwfdecAsValue rval = { 0, };
-    if (frame->argc >= native->min_args && 
-	(native->type == 0 || 
-	 g_type_is_a (G_OBJECT_TYPE (frame->thisp), native->type)) &&
-	(!frame->construct || native->construct_type == 0 ||
-	 g_type_is_a (G_OBJECT_TYPE (frame->thisp), native->construct_type))) {
+    if (!frame->construct || native->construct_type == 0 ||
+	g_type_is_a (G_OBJECT_TYPE (frame->thisp), native->construct_type)) {
       SwfdecAsValue *argv;
       /* accumulate argv */
       if (frame->argc == 0 || frame->argv != NULL) {
diff --git a/swfdec/swfdec_as_function.c b/swfdec/swfdec_as_function.c
index 3096ad3..edeb990 100644
--- a/swfdec/swfdec_as_function.c
+++ b/swfdec/swfdec_as_function.c
@@ -251,7 +251,7 @@ swfdec_as_function_init_context (SwfdecAsContext *context)
   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, NULL, 0));
+      SWFDEC_AS_STR_Function, NULL));
   swfdec_as_object_set_variable_flags (context->global, SWFDEC_AS_STR_Function, SWFDEC_AS_VARIABLE_VERSION_6_UP);
   context->Function = function;
   SWFDEC_AS_VALUE_SET_OBJECT (&val, function);
diff --git a/swfdec/swfdec_as_native_function.c b/swfdec/swfdec_as_native_function.c
index c6c2b7a..767fced 100644
--- a/swfdec/swfdec_as_native_function.c
+++ b/swfdec/swfdec_as_native_function.c
@@ -121,21 +121,17 @@ swfdec_as_native_function_init (SwfdecAsNativeFunction *function)
  * @context: a #SwfdecAsContext
  * @name: name of the function
  * @native: function to call when executed
- * @min_args: minimum number of arguments required
  * @prototype: The object to be used as "prototype" property for the created 
  *             function or %NULL for none.
  *
- * Creates a new native function, that will execute @native when called. The
- * @min_args parameter sets a requirement for the minimum number of arguments
- * to pass to @native. If the function gets called with less arguments, it
- * will just redurn undefined. You might want to use 
- * swfdec_as_object_add_function() instead of this function.
+ * Creates a new native function, that will execute @native when called. You 
+ * might want to use swfdec_as_object_add_function() instead of this function.
  *
  * Returns: a new #SwfdecAsFunction
  **/
 SwfdecAsFunction *
 swfdec_as_native_function_new (SwfdecAsContext *context, const char *name,
-    SwfdecAsNative native, guint min_args, SwfdecAsObject *prototype)
+    SwfdecAsNative native, SwfdecAsObject *prototype)
 {
   SwfdecAsNativeFunction *fun;
 
@@ -145,7 +141,6 @@ swfdec_as_native_function_new (SwfdecAsContext *context, const char *name,
 
   fun = g_object_new (SWFDEC_TYPE_AS_NATIVE_FUNCTION, "context", context, NULL);
   fun->native = native;
-  fun->min_args = min_args;
   fun->name = g_strdup (name);
   /* need to set prototype before setting the constructor or Function.constructor 
    * being CONSTANT disallows setting it. */
@@ -161,27 +156,6 @@ swfdec_as_native_function_new (SwfdecAsContext *context, const char *name,
 }
 
 /**
- * swfdec_as_native_function_set_object_type:
- * @function: a #SwfdecAsNativeFunction
- * @type: required #GType for the this object
- *
- * Sets the required type for the this object to @type. If the this object 
- * isn't of the required type, the function will not be called and its
- * return value will be undefined.
- **/
-void
-swfdec_as_native_function_set_object_type (SwfdecAsNativeFunction *function, GType type)
-{
-  GTypeQuery query;
-
-  g_return_if_fail (SWFDEC_IS_AS_NATIVE_FUNCTION (function));
-  g_return_if_fail (g_type_is_a (type, SWFDEC_TYPE_AS_OBJECT));
-
-  g_type_query (type, &query);
-  function->type = type;
-}
-
-/**
  * swfdec_as_native_function_set_construct_type:
  * @function: a #SwfdecAsNativeFunction
  * @type: #GType used when constructing an object with @function
diff --git a/swfdec/swfdec_as_native_function.h b/swfdec/swfdec_as_native_function.h
index 8089e5b..283d3cc 100644
--- a/swfdec/swfdec_as_native_function.h
+++ b/swfdec/swfdec_as_native_function.h
@@ -42,9 +42,6 @@ struct _SwfdecAsNativeFunction {
 
   SwfdecAsNative	native;		/* native call or NULL when script */
   char *		name;		/* function name */
-  /* checks for calling this function */
-  GType			type;		/* required type for this object when caling function */
-  guint			min_args;	/* minimum number of required arguments */
   /* constructor info */
   GType			construct_type;	/* type used when used as a constructor or 0 */
   guint			construct_size;	/* instance size of type */
@@ -59,12 +56,8 @@ GType		swfdec_as_native_function_get_type	(void);
 SwfdecAsFunction *swfdec_as_native_function_new	(SwfdecAsContext *	context,
 						 const char *		name,
 						 SwfdecAsNative		native,
-						 guint			min_args,
 						 SwfdecAsObject *	prototype);
 
-void		swfdec_as_native_function_set_object_type
-						(SwfdecAsNativeFunction *function,
-						 GType			type);
 void		swfdec_as_native_function_set_construct_type
 						(SwfdecAsNativeFunction *function,
 						 GType			type);
diff --git a/swfdec/swfdec_as_object.c b/swfdec/swfdec_as_object.c
index a8705ab..cc726de 100644
--- a/swfdec/swfdec_as_object.c
+++ b/swfdec/swfdec_as_object.c
@@ -1126,10 +1126,7 @@ swfdec_as_object_do_nothing (SwfdecAsContext *cx, SwfdecAsObject *object,
  * @object: a #SwfdecAsObject
  * @name: name of the function. The string does not have to be 
  *        garbage-collected.
- * @type: the required type of the this Object to make this function execute.
- *        May be 0 to accept any type.
  * @native: a native function or %NULL to just not do anything
- * @min_args: minimum number of arguments to pass to @native
  *
  * Adds @native as a variable named @name to @object. The newly added variable
  * will not be enumerated.
@@ -1137,14 +1134,12 @@ swfdec_as_object_do_nothing (SwfdecAsContext *cx, SwfdecAsObject *object,
  * Returns: the newly created #SwfdecAsFunction
  **/
 SwfdecAsFunction *
-swfdec_as_object_add_function (SwfdecAsObject *object, const char *name, GType type,
-    SwfdecAsNative native, guint min_args)
+swfdec_as_object_add_function (SwfdecAsObject *object, const char *name, SwfdecAsNative native)
 {
   g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
   g_return_val_if_fail (name != NULL, NULL);
-  g_return_val_if_fail (type == 0 || g_type_is_a (type, SWFDEC_TYPE_AS_OBJECT), NULL);
 
-  return swfdec_as_object_add_constructor (object, name, type, 0, native, min_args, NULL);
+  return swfdec_as_object_add_constructor (object, name, 0, native, NULL);
 }
 
 /**
@@ -1152,12 +1147,9 @@ swfdec_as_object_add_function (SwfdecAsObject *object, const char *name, GType t
  * @object: a #SwfdecAsObject
  * @name: name of the function. The string does not have to be 
  *        garbage-collected.
- * @type: the required type of the this Object to make this function execute.
- *        May be 0 to accept any type.
  * @construct_type: type used when using this function as a constructor. May 
  *                  be 0 to use the default type.
  * @native: a native function or %NULL to just not do anything
- * @min_args: minimum number of arguments to pass to @native
  * @prototype: An optional object to be set as the "prototype" property of the
  *             new function. The prototype will be hidden and constant.
  *
@@ -1167,23 +1159,20 @@ swfdec_as_object_add_function (SwfdecAsObject *object, const char *name, GType t
  * Returns: the newly created #SwfdecAsFunction
  **/
 SwfdecAsFunction *
-swfdec_as_object_add_constructor (SwfdecAsObject *object, const char *name, GType type,
-    GType construct_type, SwfdecAsNative native, guint min_args, SwfdecAsObject *prototype)
+swfdec_as_object_add_constructor (SwfdecAsObject *object, const char *name,
+    GType construct_type, SwfdecAsNative native, SwfdecAsObject *prototype)
 {
   SwfdecAsFunction *function;
   SwfdecAsValue val;
 
   g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
   g_return_val_if_fail (name != NULL, NULL);
-  g_return_val_if_fail (type == 0 || g_type_is_a (type, SWFDEC_TYPE_AS_OBJECT), NULL);
   g_return_val_if_fail (construct_type == 0 || g_type_is_a (construct_type, SWFDEC_TYPE_AS_OBJECT), NULL);
   g_return_val_if_fail (prototype == NULL || SWFDEC_IS_AS_OBJECT (prototype), NULL);
 
   if (!native)
     native = swfdec_as_object_do_nothing;
-  function = swfdec_as_native_function_new (swfdec_gc_object_get_context (object), name, native, min_args, prototype);
-  if (type != 0)
-    swfdec_as_native_function_set_object_type (SWFDEC_AS_NATIVE_FUNCTION (function), type);
+  function = swfdec_as_native_function_new (swfdec_gc_object_get_context (object), name, native, prototype);
   if (construct_type != 0)
     swfdec_as_native_function_set_construct_type (SWFDEC_AS_NATIVE_FUNCTION (function), construct_type);
   name = swfdec_as_context_get_string (swfdec_gc_object_get_context (object), name);
@@ -1426,13 +1415,13 @@ swfdec_as_object_add_native_variable (SwfdecAsObject *object,
   g_return_if_fail (get != NULL);
 
   get_func =
-    swfdec_as_native_function_new (swfdec_gc_object_get_context (object), variable, get, 0, NULL);
+    swfdec_as_native_function_new (swfdec_gc_object_get_context (object), variable, get, NULL);
   if (get_func == NULL)
     return;
 
   if (set != NULL) {
     set_func =
-      swfdec_as_native_function_new (swfdec_gc_object_get_context (object), variable, set, 0, NULL);
+      swfdec_as_native_function_new (swfdec_gc_object_get_context (object), variable, set, NULL);
   } else {
     set_func = NULL;
   }
@@ -1739,7 +1728,7 @@ swfdec_as_object_init_context (SwfdecAsContext *context)
 
   proto = swfdec_as_object_new_empty (context);
   object = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context->global, 
-      SWFDEC_AS_STR_Object, 0, swfdec_as_object_construct, 0));
+      SWFDEC_AS_STR_Object, swfdec_as_object_construct));
   context->Object = object;
   context->Object_prototype = proto;
   SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
diff --git a/swfdec/swfdec_as_object.h b/swfdec/swfdec_as_object.h
index c91a9d9..9293cfa 100644
--- a/swfdec/swfdec_as_object.h
+++ b/swfdec/swfdec_as_object.h
@@ -155,16 +155,12 @@ gboolean	swfdec_as_object_foreach	(SwfdecAsObject *       object,
 
 SwfdecAsFunction *swfdec_as_object_add_function	(SwfdecAsObject *	object,
 						 const char *		name,
-						 GType			type,
-						 SwfdecAsNative		native,
-						 guint			min_args);
+						 SwfdecAsNative		native);
 SwfdecAsFunction *swfdec_as_object_add_constructor
 						(SwfdecAsObject *	object,
 						 const char *		name,
-						 GType			type,
 						 GType			construct_type,
 						 SwfdecAsNative		native,
-						 guint			min_args,
 						 SwfdecAsObject *	prototype);
 
 gboolean	swfdec_as_object_call		(SwfdecAsObject *       object,
diff --git a/swfdec/swfdec_net_stream_as.c b/swfdec/swfdec_net_stream_as.c
index bf1bdf3..72a7f01 100644
--- a/swfdec/swfdec_net_stream_as.c
+++ b/swfdec/swfdec_net_stream_as.c
@@ -158,7 +158,8 @@ swfdec_net_stream_construct (SwfdecAsContext *cx, SwfdecAsObject *obj, guint arg
     return;
   }
   stream = SWFDEC_NET_STREAM (obj);
-  if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]) || 
+  if (argc == 0 ||
+      !SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]) || 
       !SWFDEC_IS_NET_CONNECTION ((conn = (SwfdecNetConnection *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[0])))) {
     SWFDEC_WARNING ("no connection passed to NetStream ()");
     return;
@@ -178,15 +179,12 @@ swfdec_net_stream_init_context (SwfdecPlayer *player)
   context = SWFDEC_AS_CONTEXT (player);
   proto = swfdec_as_object_new_empty (context);
   stream = SWFDEC_AS_OBJECT (swfdec_as_object_add_constructor (context->global, 
-      SWFDEC_AS_STR_NetStream, SWFDEC_TYPE_NET_STREAM, SWFDEC_TYPE_NET_STREAM,
-      swfdec_net_stream_construct, 1, proto));
+      SWFDEC_AS_STR_NetStream, SWFDEC_TYPE_NET_STREAM, 
+      swfdec_net_stream_construct, proto));
   /* set the right properties on the NetStream.prototype object */
-  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_pause, 0,
-      swfdec_net_stream_pause, 0);
-  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_play, 0,
-      swfdec_net_stream_play, 0);
-  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_seek, 0,
-      swfdec_net_stream_do_seek, 0);
+  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_pause, swfdec_net_stream_pause);
+  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_play, swfdec_net_stream_play);
+  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_seek, swfdec_net_stream_do_seek);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, stream);
   swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
       &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
diff --git a/swfdec/swfdec_player_as.c b/swfdec/swfdec_player_as.c
index de9744a..86f9ded 100644
--- a/swfdec/swfdec_player_as.c
+++ b/swfdec/swfdec_player_as.c
@@ -171,7 +171,7 @@ swfdec_get_asnative (SwfdecAsContext *cx, guint x, guint y)
       x_exists = TRUE;
     if (native_funcs[i].x == x && native_funcs[i].y == y) {
       SwfdecAsFunction *fun = swfdec_as_native_function_new (cx, native_funcs[i].name,
-	  native_funcs[i].func, 0, NULL);
+	  native_funcs[i].func, NULL);
       if (native_funcs[i].get_type) {
 	swfdec_as_native_function_set_construct_type (SWFDEC_AS_NATIVE_FUNCTION (fun),
 	    native_funcs[i].get_type ());
@@ -184,7 +184,7 @@ swfdec_get_asnative (SwfdecAsContext *cx, guint x, guint y)
     SwfdecAsFunction *func;
     char *name = g_strdup_printf ("ASnative (%u, %u)", x, y);
     func = swfdec_as_native_function_new (cx, name, swfdec_player_do_nothing,
-	0, NULL);
+	NULL);
     g_free (name);
     return func;
   } else {
@@ -353,11 +353,10 @@ swfdec_player_preinit_global (SwfdecAsContext *context)
   /* init these two before swfdec_as_context_startup, so they won't get
    * __proto__ and constructor properties */
   swfdec_as_object_add_function (context->global, SWFDEC_AS_STR_ASnative, 
-      0, swfdec_player_ASnative, 2);
+      swfdec_player_ASnative);
   swfdec_as_object_add_function (context->global, SWFDEC_AS_STR_ASconstructor,
-      0, swfdec_player_ASconstructor, 2);
+      swfdec_player_ASconstructor);
   // FIXME: is this only the debug player?
   swfdec_as_object_add_function (context->global,
-      SWFDEC_AS_STR_enableDebugConsole, 0, swfdec_player_enableDebugConsole,
-      2);
+      SWFDEC_AS_STR_enableDebugConsole, swfdec_player_enableDebugConsole);
 }
diff --git a/swfdec/swfdec_sprite_movie_as.c b/swfdec/swfdec_sprite_movie_as.c
index 973a751..b4b0785 100644
--- a/swfdec/swfdec_sprite_movie_as.c
+++ b/swfdec/swfdec_sprite_movie_as.c
@@ -963,7 +963,7 @@ swfdec_sprite_movie_init_context (SwfdecPlayer *player)
   SwfdecAsObject *proto, *movie;
 
   movie = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context->global, 
-      SWFDEC_AS_STR_MovieClip, 0, NULL, 0));
+      SWFDEC_AS_STR_MovieClip, NULL));
   SWFDEC_SANDBOX (context->global)->MovieClip = movie;
   proto = swfdec_as_object_new (context);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
diff --git a/swfdec/swfdec_text_format.c b/swfdec/swfdec_text_format.c
index b1ebb00..153c2d7 100644
--- a/swfdec/swfdec_text_format.c
+++ b/swfdec/swfdec_text_format.c
@@ -1035,7 +1035,7 @@ swfdec_text_format_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
   tmp = cx->Function;
   cx->Function = NULL;
   function = swfdec_as_native_function_new (cx, SWFDEC_AS_STR_getTextExtent,
-      swfdec_text_format_getTextExtent, 0, NULL);
+      swfdec_text_format_getTextExtent, NULL);
   cx->Function = tmp;
   if (function != NULL) {
     SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (function));
@@ -1090,7 +1090,7 @@ swfdec_text_format_new_no_properties (SwfdecAsContext *context)
   tmp = context->Function;
   context->Function = NULL;
   function = swfdec_as_native_function_new (context, SWFDEC_AS_STR_getTextExtent,
-      swfdec_text_format_getTextExtent, 0, NULL);
+      swfdec_text_format_getTextExtent, NULL);
   context->Function = tmp;
   if (function != NULL) {
     SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (function));
diff --git a/swfdec/swfdec_video_movie_as.c b/swfdec/swfdec_video_movie_as.c
index 3e5a5f7..62492ff 100644
--- a/swfdec/swfdec_video_movie_as.c
+++ b/swfdec/swfdec_video_movie_as.c
@@ -72,7 +72,7 @@ swfdec_video_movie_init_context (SwfdecPlayer *player)
 
   context = SWFDEC_AS_CONTEXT (player);
   video = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context->global, 
-      SWFDEC_AS_STR_Video, 0, NULL, 0));
+      SWFDEC_AS_STR_Video, NULL));
   SWFDEC_SANDBOX (context->global)->Video = video;
   proto = swfdec_as_object_new_empty (context);
   /* set the right properties on the Video object */
diff --git a/test/swfdec_test_function.c b/test/swfdec_test_function.c
index aa5e8aa..fafde52 100644
--- a/test/swfdec_test_function.c
+++ b/test/swfdec_test_function.c
@@ -68,7 +68,7 @@ swfdec_test_function_init_context (SwfdecAsContext *cx)
     GType type = functions[i].type ? functions[i].type () : 0;
     swfdec_as_object_add_constructor (obj,
       swfdec_as_context_get_string (cx, functions[i].name),
-      type, type, functions[i].fun, 0, NULL);
+      type, functions[i].fun, NULL);
   }
 }
 
diff --git a/vivified/core/vivi_function.c b/vivified/core/vivi_function.c
index 686862a..a44c9aa 100644
--- a/vivified/core/vivi_function.c
+++ b/vivified/core/vivi_function.c
@@ -68,12 +68,12 @@ vivi_function_init_context (ViviApplication *app)
   for (i = 0; functions[i].name; i++) {
     swfdec_as_object_add_function (obj,
       swfdec_as_context_get_string (cx, functions[i].name),
-      0, functions[i].fun, 0);
+      functions[i].fun);
   }
   /* FIXME: find a better solution than this */
   fun = swfdec_as_object_add_function (obj,
     swfdec_as_context_get_string (cx, "Breakpoint"),
-    0, functions[i].fun, 0);
+    functions[i].fun);
   swfdec_as_native_function_set_construct_type (SWFDEC_AS_NATIVE_FUNCTION (fun),
       VIVI_TYPE_BREAKPOINT);
   obj = swfdec_as_object_new (cx);
commit 65a5038bc83f9458eddbf800ef80d53a5df26d15
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Aug 3 19:24:37 2008 +0100

    convert NetStream to use SWFDEC_AS_CHECK

diff --git a/swfdec/swfdec_net_stream_as.c b/swfdec/swfdec_net_stream_as.c
index f1c7ac8..bf1bdf3 100644
--- a/swfdec/swfdec_net_stream_as.c
+++ b/swfdec/swfdec_net_stream_as.c
@@ -45,22 +45,27 @@ swfdec_net_stream_close (SwfdecAsContext *cx, SwfdecAsObject *object,
 }
 
 static void
-swfdec_net_stream_play (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_net_stream_play (SwfdecAsContext *cx, SwfdecAsObject *object, 
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
-  SwfdecNetStream *stream = SWFDEC_NET_STREAM (obj);
+  SwfdecNetStream *stream;
   const char *url;
 
-  url = swfdec_as_value_to_string (cx, &argv[0]);
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_NET_STREAM, &stream, "s", &url);
+
   swfdec_net_stream_set_url (stream, url);
   swfdec_net_stream_set_playing (stream, TRUE);
 }
 
 static void
-swfdec_net_stream_pause (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_net_stream_pause (SwfdecAsContext *cx, SwfdecAsObject *object,
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
-  SwfdecNetStream *stream = SWFDEC_NET_STREAM (obj);
+  SwfdecNetStream *stream;
   gboolean playing;
 
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_NET_STREAM, &stream, "");
+
   if (argc == 0) {
     playing = !swfdec_net_stream_get_playing (stream);
   } else {
@@ -126,13 +131,15 @@ swfdec_net_stream_set_checkPolicyFile (SwfdecAsContext *cx,
 }
 
 static void
-swfdec_net_stream_do_seek (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_net_stream_do_seek (SwfdecAsContext *cx, SwfdecAsObject *object,
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
-  SwfdecNetStream *stream = SWFDEC_NET_STREAM (obj);
+  SwfdecNetStream *stream;
   SwfdecSandbox *cur;
   double d;
 
-  d = swfdec_as_value_to_number (cx, &argv[0]);
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_NET_STREAM, &stream, "n", &d);
+
   cur = SWFDEC_SANDBOX (cx->global);
   swfdec_sandbox_unuse (cur);
   /* FIXME: perform security check if seeking is allowed here? */
@@ -174,12 +181,12 @@ swfdec_net_stream_init_context (SwfdecPlayer *player)
       SWFDEC_AS_STR_NetStream, SWFDEC_TYPE_NET_STREAM, SWFDEC_TYPE_NET_STREAM,
       swfdec_net_stream_construct, 1, proto));
   /* set the right properties on the NetStream.prototype object */
-  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_pause, SWFDEC_TYPE_NET_STREAM,
+  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_pause, 0,
       swfdec_net_stream_pause, 0);
-  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_play, SWFDEC_TYPE_NET_STREAM,
-      swfdec_net_stream_play, 1);
-  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_seek, SWFDEC_TYPE_NET_STREAM,
-      swfdec_net_stream_do_seek, 1);
+  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_play, 0,
+      swfdec_net_stream_play, 0);
+  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_seek, 0,
+      swfdec_net_stream_do_seek, 0);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, stream);
   swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
       &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
commit 2e91dc6c017bdc3bab5c057eaed8a30041acaea3
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Aug 3 19:15:24 2008 +0100

    don't cast before we know we are constructing

diff --git a/swfdec/swfdec_net_stream_as.c b/swfdec/swfdec_net_stream_as.c
index a27af26..f1c7ac8 100644
--- a/swfdec/swfdec_net_stream_as.c
+++ b/swfdec/swfdec_net_stream_as.c
@@ -143,13 +143,14 @@ swfdec_net_stream_do_seek (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc,
 static void
 swfdec_net_stream_construct (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
-  SwfdecNetStream *stream = SWFDEC_NET_STREAM (obj);
+  SwfdecNetStream *stream;
   SwfdecNetConnection *conn;
   
   if (!swfdec_as_context_is_constructing (cx)) {
     SWFDEC_FIXME ("What do we do if not constructing?");
     return;
   }
+  stream = SWFDEC_NET_STREAM (obj);
   if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]) || 
       !SWFDEC_IS_NET_CONNECTION ((conn = (SwfdecNetConnection *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[0])))) {
     SWFDEC_WARNING ("no connection passed to NetStream ()");
commit 09fd94a1e67eb99343f2e3562c1d2edd4a64ee0e
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Aug 2 00:55:48 2008 +0100

    back to development

diff --git a/configure.ac b/configure.ac
index c30398f..28ab014 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
 AC_PREREQ([2.58])
-AC_INIT(swfdec,0.7.4)
+AC_INIT(swfdec,0.7.5)
 
 [is_dev=$(echo $PACKAGE_VERSION | sed 's/[0-9]\.[0-9][0-9]*\.[0-9]*[13579]/1/')]
 if test x"$is_dev" = x1 ; then
commit 96f3f60acc14d813b2ad59b6f61803074dbbe163
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Jul 30 22:22:20 2008 +0200

    paint the widget in white when there is no player
    
    Previously we just didn't do anything, but this seems to cause artifacts.

diff --git a/swfdec-gtk/swfdec_gtk_widget.c b/swfdec-gtk/swfdec_gtk_widget.c
index f9a37c8..925ef7f 100644
--- a/swfdec-gtk/swfdec_gtk_widget.c
+++ b/swfdec-gtk/swfdec_gtk_widget.c
@@ -260,7 +260,6 @@ swfdec_gtk_widget_expose (GtkWidget *gtkwidget, GdkEventExpose *event)
   cairo_surface_t *surface = NULL;
 
   if (event->window != gtkwidget->window ||
-      priv->player == NULL ||
       priv->fullscreen_window != NULL)
     return FALSE;
 
@@ -278,8 +277,12 @@ swfdec_gtk_widget_expose (GtkWidget *gtkwidget, GdkEventExpose *event)
   }
   gdk_cairo_region (cr, event->region);
   cairo_clip (cr);
-  swfdec_player_render (priv->player, cr);
-  cairo_show_page (cr);
+  if (priv->player == NULL) {
+    cairo_set_source_rgb (cr, 1, 1, 1);
+    cairo_paint (cr);
+  } else {
+    swfdec_player_render (priv->player, cr);
+  }
   cairo_destroy (cr);
 
   if (surface) {


More information about the Swfdec-commits mailing list