[Swfdec] 2 commits - libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_script_function.h

Benjamin Otte company at kemper.freedesktop.org
Wed Oct 10 07:38:44 PDT 2007


 libswfdec/swfdec_as_interpret.c       |    9 +++++++--
 libswfdec/swfdec_as_script_function.h |    2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

New commits:
diff-tree 31c9f0582260817777348c96a3576e5955f44ab3 (from 3d089e6c7d75cdf5584e2123ad514f36e331a010)
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Oct 10 16:38:37 2007 +0200

    don't set the target of functions defined in the init scripts

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index 907e01e..868f6f9 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -1850,6 +1850,11 @@ swfdec_action_define_function (SwfdecAsC
   }
   if (fun == NULL)
     return;
+  /* This is a hack that should only trigger for functions defined in the init scripts.
+   * It is supposed to ensure that those functions inherit their target when being 
+   * called instead of when being defined */
+  if (!SWFDEC_IS_MOVIE (frame->original_target))
+    SWFDEC_AS_SCRIPT_FUNCTION (fun)->target = NULL;
   /* attach the function */
   if (*function_name == '\0') {
     swfdec_as_stack_ensure_free (cx, 1);
diff --git a/libswfdec/swfdec_as_script_function.h b/libswfdec/swfdec_as_script_function.h
index c82aa62..1972e15 100644
--- a/libswfdec/swfdec_as_script_function.h
+++ b/libswfdec/swfdec_as_script_function.h
@@ -43,7 +43,7 @@ struct _SwfdecAsScriptFunction {
   /* for script script_functions */
   SwfdecScript *	script;		/* script being executed or NULL when native */
   GSList *		scope_chain;  	/* scope this script_function was defined in */
-  SwfdecAsObject *	target;		/* target this object was defined in */
+  SwfdecAsObject *	target;		/* target this object was defined in or NULL if in init script */
 };
 
 struct _SwfdecAsScriptFunctionClass {
diff-tree 3d089e6c7d75cdf5584e2123ad514f36e331a010 (from 0c961bd3f00f8bc768e085f449df7ffb828a8e50)
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Oct 10 16:37:18 2007 +0200

    use the original target as target of defined functions

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index 6ef4b23..907e01e 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -1844,9 +1844,9 @@ swfdec_action_define_function (SwfdecAsC
   /* see function-scope tests */
   if (cx->version > 5) {
     /* FIXME: or original target? */
-    fun = swfdec_as_script_function_new (frame->target, frame->scope_chain, script);
+    fun = swfdec_as_script_function_new (frame->original_target, frame->scope_chain, script);
   } else {
-    fun = swfdec_as_script_function_new (frame->target, NULL, script);
+    fun = swfdec_as_script_function_new (frame->original_target, NULL, script);
   }
   if (fun == NULL)
     return;


More information about the Swfdec mailing list