[Swfdec] 10 commits - libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_super.c libswfdec/swfdec_video_movie_as.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Mon Jul 30 06:54:33 PDT 2007


 libswfdec/swfdec_as_frame.c                              |  144 +++++++--------
 libswfdec/swfdec_as_interpret.c                          |    7 
 libswfdec/swfdec_as_super.c                              |    1 
 libswfdec/swfdec_video_movie_as.c                        |    2 
 test/trace/Makefile.am                                   |   15 +
 test/trace/definefunction2-arguments-registers.swf       |binary
 test/trace/definefunction2-arguments-registers.swf.trace |    3 
 test/trace/definefunction2-arguments-registers.xml       |   49 +++++
 test/trace/definefunction2-arguments.swf                 |binary
 test/trace/definefunction2-arguments.swf.trace           |    3 
 test/trace/definefunction2-arguments.xml                 |   45 ++++
 test/trace/definefunction2-overwrite.swf                 |binary
 test/trace/definefunction2-overwrite.swf.trace           |    4 
 test/trace/definefunction2-overwrite.xml                 |   56 +++++
 test/trace/definefunction2-this.swf                      |binary
 test/trace/definefunction2-this.swf.trace                |    3 
 test/trace/definefunction2-this.xml                      |   45 ++++
 17 files changed, 300 insertions(+), 77 deletions(-)

New commits:
diff-tree 687fb9322f3f8ef29953d523c503c341e1bc6299 (from 33e2ea86862093d73fc9be0ff9cf9eac39d8f1bc)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Jul 30 15:51:25 2007 +0200

    add tests for swfdec_as_frame_preload order

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index d840712..4136972 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -209,9 +209,18 @@ EXTRA_DIST = \
 	countdown.swf.trace \
 	currentframe.swf \
 	currentframe.swf.trace \
+	definefunction2-arguments.swf \
+	definefunction2-arguments.swf.trace \
+	definefunction2-arguments.xml \
 	definefunction2-arguments-registers.swf \
 	definefunction2-arguments-registers.swf.trace \
 	definefunction2-arguments-registers.xml \
+	definefunction2-overwrite.swf \
+	definefunction2-overwrite.swf.trace \
+	definefunction2-overwrite.xml \
+	definefunction2-this.swf \
+	definefunction2-this.swf.trace \
+	definefunction2-this.xml \
 	definelocal-function-target.as \
 	definelocal-function-target-5.swf \
 	definelocal-function-target-5.swf.trace \
diff --git a/test/trace/definefunction2-arguments.swf b/test/trace/definefunction2-arguments.swf
new file mode 100644
index 0000000..0ad9b4e
Binary files /dev/null and b/test/trace/definefunction2-arguments.swf differ
diff --git a/test/trace/definefunction2-arguments.swf.trace b/test/trace/definefunction2-arguments.swf.trace
new file mode 100644
index 0000000..f53472a
--- /dev/null
+++ b/test/trace/definefunction2-arguments.swf.trace
@@ -0,0 +1,3 @@
+Check how DefineFunction2 handles flags involving this
+undefined
+
diff --git a/test/trace/definefunction2-arguments.xml b/test/trace/definefunction2-arguments.xml
new file mode 100644
index 0000000..fa0c345
--- /dev/null
+++ b/test/trace/definefunction2-arguments.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<swf version="7" compressed="1">
+  <!-- swfmill xml2swf definefunction2-arguments.xml definefunction2-arguments.swf -->
+  <Header framerate="25" frames="1">
+    <size>
+      <Rectangle left="0" right="4000" top="0" bottom="3000"/>
+    </size>
+    <tags>
+      <DoAction>
+	<actions>
+	  <PushData>
+	    <items>
+	      <StackString value="Check how DefineFunction2 handles flags involving arguments"/>
+	    </items>
+	  </PushData>
+	  <Trace/>
+	  <DeclareFunction2 name="foo" argc="0" regc="2" preloadArguments="1" suppressArguments="1" reserved="0">
+            <actions>
+	      <PushData>
+		<items>
+                  <StackRegister reg="1"/>
+                  <StackString value="arguments"/>
+		</items>
+	      </PushData>
+	      <GetVariable/>
+	      <Trace/>
+	      <Trace/>
+	    </actions>
+	  </DeclareFunction2>
+          <PushData>
+            <items>
+              <StackInteger value="0"/>
+              <StackString value="foo"/>
+            </items>
+          </PushData>
+	  <CallFunction/>
+	  <Pop/>
+	  <GetURL url="fscommand:quit" target=""/>
+	</actions>
+      </DoAction>
+      <ShowFrame/>
+      <End/>
+    </tags>
+  </Header>
+</swf>
diff --git a/test/trace/definefunction2-overwrite.swf b/test/trace/definefunction2-overwrite.swf
new file mode 100644
index 0000000..71f2367
Binary files /dev/null and b/test/trace/definefunction2-overwrite.swf differ
diff --git a/test/trace/definefunction2-overwrite.swf.trace b/test/trace/definefunction2-overwrite.swf.trace
new file mode 100644
index 0000000..292c902
--- /dev/null
+++ b/test/trace/definefunction2-overwrite.swf.trace
@@ -0,0 +1,4 @@
+Check if arguments override default variables this, arguments and super
+126
+84
+42
diff --git a/test/trace/definefunction2-overwrite.xml b/test/trace/definefunction2-overwrite.xml
new file mode 100644
index 0000000..4b5b2aa
--- /dev/null
+++ b/test/trace/definefunction2-overwrite.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<swf version="7" compressed="1">
+  <!-- swfmill xml2swf definefunction2-overwrite.xml definefunction2-overwrite.swf -->
+  <Header framerate="25" frames="1">
+    <size>
+      <Rectangle left="0" right="4000" top="0" bottom="3000"/>
+    </size>
+    <tags>
+      <DoAction>
+	<actions>
+	  <PushData>
+	    <items>
+	      <StackString value="Check if arguments override default variables this, arguments and super"/>
+	    </items>
+	  </PushData>
+	  <Trace/>
+	  <DeclareFunction2 name="foo" argc="3" regc="0" reserved="0">
+	    <args>
+	      <Parameter reg="0" name="arguments"/>
+	      <Parameter reg="0" name="this"/>
+	      <Parameter reg="0" name="super"/>
+	    </args>
+            <actions>
+	      <PushData>
+		<items>
+                  <StackString value="arguments"/>
+                  <StackString value="this"/>
+                  <StackString value="super"/>
+		</items>
+	      </PushData>
+	      <GetVariable/>
+	      <Trace/>
+	      <GetVariable/>
+	      <Trace/>
+	      <GetVariable/>
+	      <Trace/>
+	    </actions>
+	  </DeclareFunction2>
+          <PushData>
+            <items>
+              <StackInteger value="126"/>
+              <StackInteger value="84"/>
+              <StackInteger value="42"/>
+              <StackInteger value="3"/>
+              <StackString value="foo"/>
+            </items>
+          </PushData>
+	  <CallFunction/>
+	  <GetURL url="fscommand:quit" target=""/>
+	</actions>
+      </DoAction>
+      <ShowFrame/>
+      <End/>
+    </tags>
+  </Header>
+</swf>
diff --git a/test/trace/definefunction2-this.swf b/test/trace/definefunction2-this.swf
new file mode 100644
index 0000000..e8f44f8
Binary files /dev/null and b/test/trace/definefunction2-this.swf differ
diff --git a/test/trace/definefunction2-this.swf.trace b/test/trace/definefunction2-this.swf.trace
new file mode 100644
index 0000000..5405199
--- /dev/null
+++ b/test/trace/definefunction2-this.swf.trace
@@ -0,0 +1,3 @@
+Check how DefineFunction2 handles flags involving this
+_level0
+undefined
diff --git a/test/trace/definefunction2-this.xml b/test/trace/definefunction2-this.xml
new file mode 100644
index 0000000..5222b46
--- /dev/null
+++ b/test/trace/definefunction2-this.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<swf version="7" compressed="1">
+  <!-- swfmill xml2swf definefunction2-this.xml definefunction2-this.swf -->
+  <Header framerate="25" frames="1">
+    <size>
+      <Rectangle left="0" right="4000" top="0" bottom="3000"/>
+    </size>
+    <tags>
+      <DoAction>
+	<actions>
+	  <PushData>
+	    <items>
+	      <StackString value="Check how DefineFunction2 handles flags involving this"/>
+	    </items>
+	  </PushData>
+	  <Trace/>
+	  <DeclareFunction2 name="foo" argc="0" regc="2" preloadThis="1" suppressThis="1" reserved="0">
+            <actions>
+	      <PushData>
+		<items>
+                  <StackRegister reg="1"/>
+                  <StackString value="this"/>
+		</items>
+	      </PushData>
+	      <GetVariable/>
+	      <Trace/>
+	      <Trace/>
+	    </actions>
+	  </DeclareFunction2>
+          <PushData>
+            <items>
+              <StackInteger value="0"/>
+              <StackString value="foo"/>
+            </items>
+          </PushData>
+	  <CallFunction/>
+	  <Pop/>
+	  <GetURL url="fscommand:quit" target=""/>
+	</actions>
+      </DoAction>
+      <ShowFrame/>
+      <End/>
+    </tags>
+  </Header>
+</swf>
diff-tree 33e2ea86862093d73fc9be0ff9cf9eac39d8f1bc (from 0e8eceb483eaae6b2d3dca35b846287061728182)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Jul 30 15:47:23 2007 +0200

    reorganize swfdec_as_frame_preload() order to match tests

diff --git a/libswfdec/swfdec_as_frame.c b/libswfdec/swfdec_as_frame.c
index 87ff71a..fec2389 100644
--- a/libswfdec/swfdec_as_frame.c
+++ b/libswfdec/swfdec_as_frame.c
@@ -549,10 +549,10 @@ swfdec_as_frame_set_target (SwfdecAsFram
 void
 swfdec_as_frame_preload (SwfdecAsFrame *frame)
 {
-  SwfdecAsObject *object;
+  SwfdecAsObject *object, *args;
   guint i, current_reg = 1;
   SwfdecScript *script;
-  SwfdecAsValue val;
+  SwfdecAsValue val = { 0, };
   const SwfdecAsValue *cur;
   SwfdecAsContext *context;
   SwfdecAsStackIterator iter;
@@ -561,17 +561,30 @@ swfdec_as_frame_preload (SwfdecAsFrame *
 
   if (frame->script == NULL)
     return;
-
+  /* setup */
   object = SWFDEC_AS_OBJECT (frame);
   context = object->context;
   script = frame->script;
-  if (script->flags & SWFDEC_SCRIPT_PRELOAD_THIS) {
-    if (frame->thisp) {
-      SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], frame->thisp);
-    } else {
-      current_reg++;
+
+  /* create arguments and super object if necessary */
+  if ((script->flags & (SWFDEC_SCRIPT_PRELOAD_ARGS | SWFDEC_SCRIPT_SUPPRESS_ARGS)) != SWFDEC_SCRIPT_SUPPRESS_ARGS) {
+    args = swfdec_as_array_new (context);
+    if (!args)
+      return;
+    for (cur = swfdec_as_stack_iterator_init_arguments (&iter, frame); cur != NULL;
+	cur = swfdec_as_stack_iterator_next (&iter)) {
+      swfdec_as_array_push (SWFDEC_AS_ARRAY (args), cur);
     }
-  } else if (!(script->flags & SWFDEC_SCRIPT_SUPPRESS_THIS)) {
+  } else {
+    /* silence gcc */
+    args = NULL;
+  }
+  if ((script->flags & (SWFDEC_SCRIPT_PRELOAD_SUPER | SWFDEC_SCRIPT_SUPPRESS_SUPER)) != SWFDEC_SCRIPT_SUPPRESS_SUPER) {
+    frame->super = swfdec_as_super_new (frame);
+  }
+
+  /* set the default variables (unless suppressed */
+  if (!(script->flags & SWFDEC_SCRIPT_SUPPRESS_THIS)) {
     if (frame->thisp) {
       SWFDEC_AS_VALUE_SET_OBJECT (&val, frame->thisp);
     } else {
@@ -580,34 +593,59 @@ swfdec_as_frame_preload (SwfdecAsFrame *
     swfdec_as_object_set_variable (object, SWFDEC_AS_STR_this, &val);
   }
   if (!(script->flags & SWFDEC_SCRIPT_SUPPRESS_ARGS)) {
-    SwfdecAsObject *args = swfdec_as_array_new (context);
+    SWFDEC_AS_VALUE_SET_OBJECT (&val, args);
+    swfdec_as_object_set_variable (object, SWFDEC_AS_STR_arguments, &val);
+  }
+  if (!(script->flags & SWFDEC_SCRIPT_SUPPRESS_SUPER)) {
+    if (frame->super) {
+      SWFDEC_AS_VALUE_SET_OBJECT (&val, frame->super);
+    } else {
+      SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
+    }
+    swfdec_as_object_set_variable (object, SWFDEC_AS_STR_super, &val);
+  }
 
-    if (!args)
-      return;
-    for (cur = swfdec_as_stack_iterator_init_arguments (&iter, frame); cur != NULL;
-	cur = swfdec_as_stack_iterator_next (&iter)) {
-      swfdec_as_array_push (SWFDEC_AS_ARRAY (args), cur);
+  /* set and preload argument variables */
+  cur = swfdec_as_stack_iterator_init_arguments (&iter, frame);
+  for (i = 0; i < script->n_arguments; i++) {
+    if (cur == NULL)
+      cur = &val;
+    /* set this value at the right place */
+    if (script->arguments[i].preload) {
+      if (script->arguments[i].preload < frame->n_registers) {
+	frame->registers[script->arguments[i].preload] = *cur;
+      } else {
+	SWFDEC_ERROR ("trying to set %uth argument %s in nonexisting register %u", 
+	    i, script->arguments[i].name, script->arguments[i].preload);
+      }
+    } else {
+      const char *tmp = swfdec_as_context_get_string (context, script->arguments[i].name);
+      swfdec_as_object_set_variable (object, tmp, cur);
     }
-    /* FIXME: implement callee/caller */
-    if (script->flags & SWFDEC_SCRIPT_PRELOAD_ARGS) {
-      SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], args);
+    /* get the next argument */
+    cur = swfdec_as_stack_iterator_next (&iter);
+  }
+
+  /* preload from flags */
+  if ((script->flags & (SWFDEC_SCRIPT_PRELOAD_THIS | SWFDEC_SCRIPT_SUPPRESS_THIS)) == SWFDEC_SCRIPT_PRELOAD_THIS
+      && current_reg < script->n_registers) {
+    if (frame->thisp) {
+      SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], frame->thisp);
     } else {
-      SWFDEC_AS_VALUE_SET_OBJECT (&val, args);
-      swfdec_as_object_set_variable (object, SWFDEC_AS_STR_arguments, &val);
+      SWFDEC_AS_VALUE_SET_UNDEFINED (&frame->registers[current_reg++]);
     }
   }
-  if (!(script->flags & SWFDEC_SCRIPT_SUPPRESS_SUPER)) {
-    frame->super = swfdec_as_super_new (frame);
+  if (script->flags & SWFDEC_SCRIPT_PRELOAD_ARGS && current_reg < script->n_registers) {
+    SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], args);
+  }
+  if (script->flags & SWFDEC_SCRIPT_PRELOAD_SUPER && current_reg < script->n_registers) {
     if (frame->super) {
-      if (script->flags & SWFDEC_SCRIPT_PRELOAD_SUPER) {
-	SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], frame->super);
-      } else {
-	SWFDEC_AS_VALUE_SET_OBJECT (&val, frame->super);
-	swfdec_as_object_set_variable (object, SWFDEC_AS_STR_super, &val);
-      }
+      SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], frame->super);
+    } else {
+      SWFDEC_AS_VALUE_SET_UNDEFINED (&frame->registers[current_reg++]);
     }
   }
-  if (script->flags & SWFDEC_SCRIPT_PRELOAD_ROOT) {
+  if (script->flags & SWFDEC_SCRIPT_PRELOAD_ROOT && current_reg < script->n_registers) {
     SwfdecAsObject *obj;
     
     obj = swfdec_as_frame_find_variable (frame, SWFDEC_AS_STR__root);
@@ -615,10 +653,10 @@ swfdec_as_frame_preload (SwfdecAsFrame *
       swfdec_as_object_get_variable (obj, SWFDEC_AS_STR__root, &frame->registers[current_reg]);
     } else {
       SWFDEC_WARNING ("no root to preload");
+      SWFDEC_AS_VALUE_SET_UNDEFINED (&frame->registers[current_reg++]);
     }
-    current_reg++;
   }
-  if (script->flags & SWFDEC_SCRIPT_PRELOAD_PARENT) {
+  if (script->flags & SWFDEC_SCRIPT_PRELOAD_PARENT && current_reg < script->n_registers) {
     SwfdecAsObject *obj;
     
     obj = swfdec_as_frame_find_variable (frame, SWFDEC_AS_STR__parent);
@@ -626,33 +664,13 @@ swfdec_as_frame_preload (SwfdecAsFrame *
       swfdec_as_object_get_variable (obj, SWFDEC_AS_STR__parent, &frame->registers[current_reg++]);
     } else {
       SWFDEC_WARNING ("no parent to preload");
+      SWFDEC_AS_VALUE_SET_UNDEFINED (&frame->registers[current_reg++]);
     }
     current_reg++;
   }
-  if (script->flags & SWFDEC_SCRIPT_PRELOAD_GLOBAL) {
+  if (script->flags & SWFDEC_SCRIPT_PRELOAD_GLOBAL && current_reg < script->n_registers) {
     SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], context->global);
   }
-
-  cur = swfdec_as_stack_iterator_init_arguments (&iter, frame);
-  SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
-  for (i = 0; i < script->n_arguments; i++) {
-    if (cur == NULL)
-      cur = &val;
-    /* set this value at the right place */
-    if (script->arguments[i].preload) {
-      if (script->arguments[i].preload < frame->n_registers) {
-	frame->registers[script->arguments[i].preload] = *cur;
-      } else {
-	SWFDEC_ERROR ("trying to set %uth argument %s in nonexisting register %u", 
-	    i, script->arguments[i].name, script->arguments[i].preload);
-      }
-    } else {
-      const char *tmp = swfdec_as_context_get_string (context, script->arguments[i].name);
-      swfdec_as_object_set_variable (object, tmp, cur);
-    }
-    /* get the next argument */
-    cur = swfdec_as_stack_iterator_next (&iter);
-  }
 }
 
 /**
diff-tree 0e8eceb483eaae6b2d3dca35b846287061728182 (from 6f76b7e91fa0d0ea68a56cddcc8a416419b48945)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Jul 30 14:55:01 2007 +0200

    add a test for how registers are handled

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index efa9946..d840712 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -726,6 +726,9 @@ EXTRA_DIST = \
 	preload.swf.trace \
 	prototypes.swf \
 	prototypes.swf.trace \
+	register-count.swf \
+	register-count.swf.trace \
+	register-count.xml \
 	registerclass-previous.c \
 	registerclass-previous.swf \
 	registerclass-previous.swf.trace \
diff-tree 6f76b7e91fa0d0ea68a56cddcc8a416419b48945 (from 63d07e3882ee47cffd2a69b1c1e84b22fc52c64d)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Jul 30 14:53:36 2007 +0200

    if not enoguh registers are available, push undefined

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index 4802133..ecc828a 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -349,9 +349,10 @@ swfdec_action_push (SwfdecAsContext *cx,
 	  guint regnum = swfdec_bits_get_u8 (&bits);
 	  if (!swfdec_action_has_register (cx, regnum)) {
 	    SWFDEC_ERROR ("cannot Push register %u: not enough registers", regnum);
-	    return;
+	    SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_push (cx));
+	  } else {
+	    *swfdec_as_stack_push (cx) = cx->frame->registers[regnum];
 	  }
-	  *swfdec_as_stack_push (cx) = cx->frame->registers[regnum];
 	  break;
 	}
       case 5: /* boolean */
diff-tree 63d07e3882ee47cffd2a69b1c1e84b22fc52c64d (from ad8ff3e999a5e7fcae04ba5d9843dfdd303643d8)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Jul 30 14:46:41 2007 +0200

    use the right number of registers

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index b04136e..4802133 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -1497,7 +1497,7 @@ swfdec_action_define_function (SwfdecAsC
     return;
   n_args = swfdec_bits_get_u16 (&bits);
   if (v2) {
-    n_registers = swfdec_bits_get_u8 (&bits) + 1;
+    n_registers = swfdec_bits_get_u8 (&bits);
     flags = swfdec_bits_get_u16 (&bits);
   } else {
     n_registers = 5;
diff-tree ad8ff3e999a5e7fcae04ba5d9843dfdd303643d8 (from 7f22de1374ffd9c35a0f0262e53b2388c974c1de)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Jul 30 14:34:32 2007 +0200

    add test for argument preloading in registers

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 7e5e2c4..efa9946 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -209,6 +209,9 @@ EXTRA_DIST = \
 	countdown.swf.trace \
 	currentframe.swf \
 	currentframe.swf.trace \
+	definefunction2-arguments-registers.swf \
+	definefunction2-arguments-registers.swf.trace \
+	definefunction2-arguments-registers.xml \
 	definelocal-function-target.as \
 	definelocal-function-target-5.swf \
 	definelocal-function-target-5.swf.trace \
diff --git a/test/trace/definefunction2-arguments-registers.swf b/test/trace/definefunction2-arguments-registers.swf
new file mode 100644
index 0000000..8a6b9dd
Binary files /dev/null and b/test/trace/definefunction2-arguments-registers.swf differ
diff --git a/test/trace/definefunction2-arguments-registers.swf.trace b/test/trace/definefunction2-arguments-registers.swf.trace
new file mode 100644
index 0000000..3fcd243
--- /dev/null
+++ b/test/trace/definefunction2-arguments-registers.swf.trace
@@ -0,0 +1,3 @@
+Check that variables in registers don't get assigned to their value
+undefined
+42
diff --git a/test/trace/definefunction2-arguments-registers.xml b/test/trace/definefunction2-arguments-registers.xml
new file mode 100644
index 0000000..3a1861b
--- /dev/null
+++ b/test/trace/definefunction2-arguments-registers.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<swf version="7" compressed="1">
+  <!-- swfmill xml2swf definefunction2-arguments-registers.xml definefunction2-arguments-registers.swf -->
+  <Header framerate="25" frames="1">
+    <size>
+      <Rectangle left="0" right="4000" top="0" bottom="3000"/>
+    </size>
+    <tags>
+      <DoAction>
+	<actions>
+	  <PushData>
+	    <items>
+	      <StackString value="Check that variables in registers don't get assigned to their value"/>
+	    </items>
+	  </PushData>
+	  <Trace/>
+	  <DeclareFunction2 name="foo" argc="1" regc="2" reserved="0">
+	    <args>
+	      <Parameter reg="1" name="a"/>
+	    </args>
+            <actions>
+	      <PushData>
+		<items>
+                  <StackRegister reg="1"/>
+                  <StackString value="a"/>
+		</items>
+	      </PushData>
+	      <GetVariable/>
+	      <Trace/>
+	      <Trace/>
+	    </actions>
+	  </DeclareFunction2>
+          <PushData>
+            <items>
+              <StackInteger value="42"/>
+              <StackInteger value="1"/>
+              <StackString value="foo"/>
+            </items>
+          </PushData>
+	  <CallFunction/>
+	  <Pop/>
+	  <GetURL url="fscommand:quit" target=""/>
+	</actions>
+      </DoAction>
+      <ShowFrame/>
+      <End/>
+    </tags>
+  </Header>
+</swf>
diff-tree 7f22de1374ffd9c35a0f0262e53b2388c974c1de (from d6b5bd737f94823a1f2846443fe355aba770251d)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Jul 30 13:28:36 2007 +0200

    fix typo

diff --git a/libswfdec/swfdec_video_movie_as.c b/libswfdec/swfdec_video_movie_as.c
index e40b473..bebcd58 100644
--- a/libswfdec/swfdec_video_movie_as.c
+++ b/libswfdec/swfdec_video_movie_as.c
@@ -36,7 +36,7 @@ swfdec_video_attach_video (SwfdecAsConte
 
   if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]) ||
       !SWFDEC_IS_NET_STREAM (stream = (SwfdecNetStream *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]))) {
-    SWFDEC_WARNING ("calling attachVideo without a NetStraem object");
+    SWFDEC_WARNING ("calling attachVideo without a NetStream object");
     swfdec_video_movie_set_input (video, NULL);
     return;
   }
diff-tree d6b5bd737f94823a1f2846443fe355aba770251d (from 6f884b0d25ff56871fd1dc99458e15a8cc96546e)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Jul 30 12:42:27 2007 +0200

    create arguments variable using a SwfdecAsStackIterator

diff --git a/libswfdec/swfdec_as_frame.c b/libswfdec/swfdec_as_frame.c
index 76b6181..87ff71a 100644
--- a/libswfdec/swfdec_as_frame.c
+++ b/libswfdec/swfdec_as_frame.c
@@ -552,7 +552,6 @@ swfdec_as_frame_preload (SwfdecAsFrame *
   SwfdecAsObject *object;
   guint i, current_reg = 1;
   SwfdecScript *script;
-  SwfdecAsStack *stack;
   SwfdecAsValue val;
   const SwfdecAsValue *cur;
   SwfdecAsContext *context;
@@ -585,21 +584,9 @@ swfdec_as_frame_preload (SwfdecAsFrame *
 
     if (!args)
       return;
-    if (frame->argc > 0) {
-      if (frame->argv) {
-	swfdec_as_array_append (SWFDEC_AS_ARRAY (args), frame->argc, frame->argv);
-      } else {
-	stack = context->stack;
-	cur = context->cur;
-	for (i = 0; i < frame->argc; i++) {
-	  if (cur <= &stack->elements[0]) {
-	    stack = stack->next;
-	    cur = &stack->elements[stack->used_elements];
-	  }
-	  cur--;
-	  swfdec_as_array_push (SWFDEC_AS_ARRAY (args), cur);
-	}
-      }
+    for (cur = swfdec_as_stack_iterator_init_arguments (&iter, frame); cur != NULL;
+	cur = swfdec_as_stack_iterator_next (&iter)) {
+      swfdec_as_array_push (SWFDEC_AS_ARRAY (args), cur);
     }
     /* FIXME: implement callee/caller */
     if (script->flags & SWFDEC_SCRIPT_PRELOAD_ARGS) {
diff-tree 6f884b0d25ff56871fd1dc99458e15a8cc96546e (from fd2d4d8ae9c0d00efc638d93dab8723e25fdc4c6)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Jul 30 12:40:50 2007 +0200

    switch argument handling to use SwfdecAsStackIterator

diff --git a/libswfdec/swfdec_as_frame.c b/libswfdec/swfdec_as_frame.c
index 77f51f4..76b6181 100644
--- a/libswfdec/swfdec_as_frame.c
+++ b/libswfdec/swfdec_as_frame.c
@@ -556,6 +556,7 @@ swfdec_as_frame_preload (SwfdecAsFrame *
   SwfdecAsValue val;
   const SwfdecAsValue *cur;
   SwfdecAsContext *context;
+  SwfdecAsStackIterator iter;
 
   g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
 
@@ -644,23 +645,13 @@ swfdec_as_frame_preload (SwfdecAsFrame *
   if (script->flags & SWFDEC_SCRIPT_PRELOAD_GLOBAL) {
     SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], context->global);
   }
-  stack = context->stack;
+
+  cur = swfdec_as_stack_iterator_init_arguments (&iter, frame);
   SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
-  cur = frame->argv ? frame->argv - 1 : context->cur;
   for (i = 0; i < script->n_arguments; i++) {
-    /* first figure out the right value to set */
-    if (i >= frame->argc) {
+    if (cur == NULL)
       cur = &val;
-    } else if (frame->argv) {
-      cur++;
-    } else {
-      if (cur <= &stack->elements[0]) {
-	stack = stack->next;
-	cur = &stack->elements[stack->used_elements];
-      }
-      cur--;
-    }
-    /* now set this value at the right place */
+    /* set this value at the right place */
     if (script->arguments[i].preload) {
       if (script->arguments[i].preload < frame->n_registers) {
 	frame->registers[script->arguments[i].preload] = *cur;
@@ -672,6 +663,8 @@ swfdec_as_frame_preload (SwfdecAsFrame *
       const char *tmp = swfdec_as_context_get_string (context, script->arguments[i].name);
       swfdec_as_object_set_variable (object, tmp, cur);
     }
+    /* get the next argument */
+    cur = swfdec_as_stack_iterator_next (&iter);
   }
 }
 
diff-tree fd2d4d8ae9c0d00efc638d93dab8723e25fdc4c6 (from b9079d14ce23c4ff652934c1ef222ec2d966fa5c)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Jul 30 12:39:21 2007 +0200

    when calling super() we're still constructing
    
    FIXME: write test for this

diff --git a/libswfdec/swfdec_as_super.c b/libswfdec/swfdec_as_super.c
index 41a58f2..5447bcd 100644
--- a/libswfdec/swfdec_as_super.c
+++ b/libswfdec/swfdec_as_super.c
@@ -61,6 +61,7 @@ swfdec_as_super_call (SwfdecAsFunction *
    * in a debugger
    */
   frame->function = fun;
+  frame->construct = frame->next->construct;
   /* FIXME: this is ugly */
   swfdec_as_frame_set_this (frame, super->object);
   return frame;


More information about the Swfdec mailing list