[Swfdec] Branch 'vivi' - 13 commits - libswfdec/swfdec_as_context.c libswfdec/swfdec_as_debugger.h libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_script_function.c test/trace vivified/core vivified/ui

Benjamin Otte company at kemper.freedesktop.org
Fri Aug 17 08:36:57 PDT 2007


 libswfdec/swfdec_as_context.c                    |   25 +
 libswfdec/swfdec_as_debugger.h                   |    8 
 libswfdec/swfdec_as_interpret.c                  |    2 
 libswfdec/swfdec_as_object.c                     |    6 
 libswfdec/swfdec_as_script_function.c            |    4 
 test/trace/Makefile.am                           |    9 
 test/trace/definefunction2-registers-5.swf       |binary
 test/trace/definefunction2-registers-5.swf.trace |   67 ++++
 test/trace/definefunction2-registers-6.swf       |binary
 test/trace/definefunction2-registers-6.swf.trace |   67 ++++
 test/trace/definefunction2-registers-7.swf       |binary
 test/trace/definefunction2-registers-7.swf.trace |   67 ++++
 test/trace/definefunction2-registers-8.swf       |binary
 test/trace/definefunction2-registers-8.swf.trace |   67 ++++
 test/trace/definefunction2-registers.xml         |  336 +++++++++++++++++++++++
 test/trace/trace.c                               |    4 
 vivified/core/vivi_application.c                 |   20 +
 vivified/core/vivi_application.h                 |    1 
 vivified/core/vivi_breakpoint.c                  |   18 +
 vivified/core/vivi_debugger.c                    |   20 +
 vivified/core/vivi_initialize.as                 |    3 
 vivified/core/vivi_marshal.list                  |    1 
 vivified/core/vivi_player_as.c                   |   67 ++++
 vivified/ui/main.c                               |    3 
 24 files changed, 777 insertions(+), 18 deletions(-)

New commits:
diff-tree c168f4149f139c40bd7556f3baa4af67c969c32e (from 6878ba31199421d00813814f6822b3d30e2e3884)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 17:35:29 2007 +0200

    set a somewhat sane default size

diff --git a/vivified/ui/main.c b/vivified/ui/main.c
index 617e317..fe4b35c 100644
--- a/vivified/ui/main.c
+++ b/vivified/ui/main.c
@@ -67,6 +67,7 @@ setup (const char *filename, const char 
   vivi_application_set_filename (app, filename);
   vivi_application_set_variables (app, variables);
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_default_size (GTK_WINDOW (window), 400, 450);
   g_signal_connect_swapped (app, "notify::quit", G_CALLBACK (gtk_widget_destroy), window);
   g_signal_connect (app, "notify::filename", G_CALLBACK (set_title), window);
   set_title (app, NULL, GTK_WINDOW (window));
diff-tree 6878ba31199421d00813814f6822b3d30e2e3884 (from f781524c4f4ad87e3e277417b6e29df6d9d1a7a5)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 17:35:07 2007 +0200

    add test for registers

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 45b56a8..124ea62 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -245,6 +245,15 @@ EXTRA_DIST = \
 	definefunction2-overwrite.swf \
 	definefunction2-overwrite.swf.trace \
 	definefunction2-overwrite.xml \
+	definefunction2-registers.xml \
+	definefunction2-registers-5.swf \
+	definefunction2-registers-5.swf.trace \
+	definefunction2-registers-6.swf \
+	definefunction2-registers-6.swf.trace \
+	definefunction2-registers-7.swf \
+	definefunction2-registers-7.swf.trace \
+	definefunction2-registers-8.swf \
+	definefunction2-registers-8.swf.trace \
 	definefunction2-this.swf \
 	definefunction2-this.swf.trace \
 	definefunction2-this.xml \
diff --git a/test/trace/definefunction2-registers-5.swf b/test/trace/definefunction2-registers-5.swf
new file mode 100644
index 0000000..6d1adce
Binary files /dev/null and b/test/trace/definefunction2-registers-5.swf differ
diff --git a/test/trace/definefunction2-registers-5.swf.trace b/test/trace/definefunction2-registers-5.swf.trace
new file mode 100644
index 0000000..fe4c04b
--- /dev/null
+++ b/test/trace/definefunction2-registers-5.swf.trace
@@ -0,0 +1,67 @@
+Check how DefineFunction2 handles register counts
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
diff --git a/test/trace/definefunction2-registers-6.swf b/test/trace/definefunction2-registers-6.swf
new file mode 100644
index 0000000..e7a5958
Binary files /dev/null and b/test/trace/definefunction2-registers-6.swf differ
diff --git a/test/trace/definefunction2-registers-6.swf.trace b/test/trace/definefunction2-registers-6.swf.trace
new file mode 100644
index 0000000..fe4c04b
--- /dev/null
+++ b/test/trace/definefunction2-registers-6.swf.trace
@@ -0,0 +1,67 @@
+Check how DefineFunction2 handles register counts
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
diff --git a/test/trace/definefunction2-registers-7.swf b/test/trace/definefunction2-registers-7.swf
new file mode 100644
index 0000000..7abb8c1
Binary files /dev/null and b/test/trace/definefunction2-registers-7.swf differ
diff --git a/test/trace/definefunction2-registers-7.swf.trace b/test/trace/definefunction2-registers-7.swf.trace
new file mode 100644
index 0000000..fe4c04b
--- /dev/null
+++ b/test/trace/definefunction2-registers-7.swf.trace
@@ -0,0 +1,67 @@
+Check how DefineFunction2 handles register counts
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
diff --git a/test/trace/definefunction2-registers-8.swf b/test/trace/definefunction2-registers-8.swf
new file mode 100644
index 0000000..917dfc6
Binary files /dev/null and b/test/trace/definefunction2-registers-8.swf differ
diff --git a/test/trace/definefunction2-registers-8.swf.trace b/test/trace/definefunction2-registers-8.swf.trace
new file mode 100644
index 0000000..fe4c04b
--- /dev/null
+++ b/test/trace/definefunction2-registers-8.swf.trace
@@ -0,0 +1,67 @@
+Check how DefineFunction2 handles register counts
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
+hi
+hi
+hi
+hi
+hi
+undefined
+undefined
+undefined
+undefined
+undefined
+hi
diff --git a/test/trace/definefunction2-registers.xml b/test/trace/definefunction2-registers.xml
new file mode 100644
index 0000000..00f53c3
--- /dev/null
+++ b/test/trace/definefunction2-registers.xml
@@ -0,0 +1,336 @@
+<?xml version="1.0"?>
+<swf version="5" compressed="1">
+  <!-- swfmill xml2swf definefunction2-registers.xml definefunction2-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 how DefineFunction2 handles register counts"/>
+	    </items>
+	  </PushData>
+	  <Trace/>
+	  <DeclareFunction2 name="foo" argc="0" regc="0">
+            <actions>
+	      <PushData>
+		<items>
+                  <StackString value="hi"/>
+		</items>
+	      </PushData>
+	      <StoreRegister reg="0"/>
+	      <StoreRegister reg="1"/>
+	      <StoreRegister reg="2"/>
+	      <StoreRegister reg="3"/>
+	      <StoreRegister reg="4"/>
+	      <StoreRegister reg="5"/>
+	      <StoreRegister reg="6"/>
+	      <StoreRegister reg="7"/>
+	      <StoreRegister reg="8"/>
+	      <StoreRegister reg="9"/>
+	      <PushData>
+		<items>
+                  <StackRegister reg="9"/>
+                  <StackRegister reg="8"/>
+                  <StackRegister reg="7"/>
+                  <StackRegister reg="6"/>
+                  <StackRegister reg="5"/>
+                  <StackRegister reg="4"/>
+                  <StackRegister reg="3"/>
+                  <StackRegister reg="2"/>
+                  <StackRegister reg="1"/>
+                  <StackRegister reg="0"/>
+		</items>
+	      </PushData>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	    </actions>
+	  </DeclareFunction2>
+          <PushData>
+            <items>
+              <StackInteger value="0"/>
+              <StackString value="foo"/>
+            </items>
+          </PushData>
+	  <CallFunction/>
+	  <Pop/>
+	  <DeclareFunction2 name="foo" argc="0" regc="1">
+            <actions>
+	      <PushData>
+		<items>
+                  <StackString value="hi"/>
+		</items>
+	      </PushData>
+	      <StoreRegister reg="0"/>
+	      <StoreRegister reg="1"/>
+	      <StoreRegister reg="2"/>
+	      <StoreRegister reg="3"/>
+	      <StoreRegister reg="4"/>
+	      <StoreRegister reg="5"/>
+	      <StoreRegister reg="6"/>
+	      <StoreRegister reg="7"/>
+	      <StoreRegister reg="8"/>
+	      <StoreRegister reg="9"/>
+	      <PushData>
+		<items>
+                  <StackRegister reg="9"/>
+                  <StackRegister reg="8"/>
+                  <StackRegister reg="7"/>
+                  <StackRegister reg="6"/>
+                  <StackRegister reg="5"/>
+                  <StackRegister reg="4"/>
+                  <StackRegister reg="3"/>
+                  <StackRegister reg="2"/>
+                  <StackRegister reg="1"/>
+                  <StackRegister reg="0"/>
+		</items>
+	      </PushData>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	    </actions>
+	  </DeclareFunction2>
+          <PushData>
+            <items>
+              <StackInteger value="0"/>
+              <StackString value="foo"/>
+            </items>
+          </PushData>
+	  <CallFunction/>
+	  <Pop/>
+	  <DeclareFunction2 name="foo" argc="0" regc="2">
+            <actions>
+	      <PushData>
+		<items>
+                  <StackString value="hi"/>
+		</items>
+	      </PushData>
+	      <StoreRegister reg="0"/>
+	      <StoreRegister reg="1"/>
+	      <StoreRegister reg="2"/>
+	      <StoreRegister reg="3"/>
+	      <StoreRegister reg="4"/>
+	      <StoreRegister reg="5"/>
+	      <StoreRegister reg="6"/>
+	      <StoreRegister reg="7"/>
+	      <StoreRegister reg="8"/>
+	      <StoreRegister reg="9"/>
+	      <PushData>
+		<items>
+                  <StackRegister reg="9"/>
+                  <StackRegister reg="8"/>
+                  <StackRegister reg="7"/>
+                  <StackRegister reg="6"/>
+                  <StackRegister reg="5"/>
+                  <StackRegister reg="4"/>
+                  <StackRegister reg="3"/>
+                  <StackRegister reg="2"/>
+                  <StackRegister reg="1"/>
+                  <StackRegister reg="0"/>
+		</items>
+	      </PushData>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	    </actions>
+	  </DeclareFunction2>
+          <PushData>
+            <items>
+              <StackInteger value="0"/>
+              <StackString value="foo"/>
+            </items>
+          </PushData>
+	  <CallFunction/>
+	  <Pop/>
+	  <DeclareFunction2 name="foo" argc="0" regc="3">
+            <actions>
+	      <PushData>
+		<items>
+                  <StackString value="hi"/>
+		</items>
+	      </PushData>
+	      <StoreRegister reg="0"/>
+	      <StoreRegister reg="1"/>
+	      <StoreRegister reg="2"/>
+	      <StoreRegister reg="3"/>
+	      <StoreRegister reg="4"/>
+	      <StoreRegister reg="5"/>
+	      <StoreRegister reg="6"/>
+	      <StoreRegister reg="7"/>
+	      <StoreRegister reg="8"/>
+	      <StoreRegister reg="9"/>
+	      <PushData>
+		<items>
+                  <StackRegister reg="9"/>
+                  <StackRegister reg="8"/>
+                  <StackRegister reg="7"/>
+                  <StackRegister reg="6"/>
+                  <StackRegister reg="5"/>
+                  <StackRegister reg="4"/>
+                  <StackRegister reg="3"/>
+                  <StackRegister reg="2"/>
+                  <StackRegister reg="1"/>
+                  <StackRegister reg="0"/>
+		</items>
+	      </PushData>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	    </actions>
+	  </DeclareFunction2>
+          <PushData>
+            <items>
+              <StackInteger value="0"/>
+              <StackString value="foo"/>
+            </items>
+          </PushData>
+	  <CallFunction/>
+	  <Pop/>
+	  <DeclareFunction2 name="foo" argc="0" regc="4">
+            <actions>
+	      <PushData>
+		<items>
+                  <StackString value="hi"/>
+		</items>
+	      </PushData>
+	      <StoreRegister reg="0"/>
+	      <StoreRegister reg="1"/>
+	      <StoreRegister reg="2"/>
+	      <StoreRegister reg="3"/>
+	      <StoreRegister reg="4"/>
+	      <StoreRegister reg="5"/>
+	      <StoreRegister reg="6"/>
+	      <StoreRegister reg="7"/>
+	      <StoreRegister reg="8"/>
+	      <StoreRegister reg="9"/>
+	      <PushData>
+		<items>
+                  <StackRegister reg="9"/>
+                  <StackRegister reg="8"/>
+                  <StackRegister reg="7"/>
+                  <StackRegister reg="6"/>
+                  <StackRegister reg="5"/>
+                  <StackRegister reg="4"/>
+                  <StackRegister reg="3"/>
+                  <StackRegister reg="2"/>
+                  <StackRegister reg="1"/>
+                  <StackRegister reg="0"/>
+		</items>
+	      </PushData>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	    </actions>
+	  </DeclareFunction2>
+          <PushData>
+            <items>
+              <StackInteger value="0"/>
+              <StackString value="foo"/>
+            </items>
+          </PushData>
+	  <CallFunction/>
+	  <Pop/>
+	  <DeclareFunction2 name="foo" argc="0" regc="5">
+            <actions>
+	      <PushData>
+		<items>
+                  <StackString value="hi"/>
+		</items>
+	      </PushData>
+	      <StoreRegister reg="0"/>
+	      <StoreRegister reg="1"/>
+	      <StoreRegister reg="2"/>
+	      <StoreRegister reg="3"/>
+	      <StoreRegister reg="4"/>
+	      <StoreRegister reg="5"/>
+	      <StoreRegister reg="6"/>
+	      <StoreRegister reg="7"/>
+	      <StoreRegister reg="8"/>
+	      <StoreRegister reg="9"/>
+	      <PushData>
+		<items>
+                  <StackRegister reg="9"/>
+                  <StackRegister reg="8"/>
+                  <StackRegister reg="7"/>
+                  <StackRegister reg="6"/>
+                  <StackRegister reg="5"/>
+                  <StackRegister reg="4"/>
+                  <StackRegister reg="3"/>
+                  <StackRegister reg="2"/>
+                  <StackRegister reg="1"/>
+                  <StackRegister reg="0"/>
+		</items>
+	      </PushData>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <Trace/>
+	      <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 f781524c4f4ad87e3e277417b6e29df6d9d1a7a5 (from 8c9b43ea93defc0eb2fd8b36f5b59fe0d2e1693a)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 17:33:47 2007 +0200

    fix warnings

diff --git a/test/trace/trace.c b/test/trace/trace.c
index 99d6a5a..cc788db 100644
--- a/test/trace/trace.c
+++ b/test/trace/trace.c
@@ -248,7 +248,7 @@ main (int argc, char **argv)
       Test *test = walk->data;
       
       run_test (test, NULL);
-      g_print (test->output);
+      g_print ("%s", test->output);
       if (!test->success) {
 	failures++;
 	g_string_append_printf (failed_tests, 
@@ -276,7 +276,7 @@ main (int argc, char **argv)
       Test *test = walk->data;
       while (test->output == NULL)
 	g_cond_wait (cond, mutex);
-      g_print (test->output);
+      g_print ("%s", test->output);
       if (!test->success) {
 	failures++;
 	g_string_append_printf (failed_tests, 
diff-tree 8c9b43ea93defc0eb2fd8b36f5b59fe0d2e1693a (from 766540d421a3bfc96ca32b66dedb9f96b49682d0)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 17:33:29 2007 +0200

    define scope and target earlier

diff --git a/libswfdec/swfdec_as_script_function.c b/libswfdec/swfdec_as_script_function.c
index f8b6ad2..3ab7064 100644
--- a/libswfdec/swfdec_as_script_function.c
+++ b/libswfdec/swfdec_as_script_function.c
@@ -124,6 +124,8 @@ swfdec_as_script_function_new (SwfdecAsS
       SWFDEC_TYPE_AS_SCRIPT_FUNCTION, sizeof (SwfdecAsScriptFunction));
   if (fun == NULL)
     return NULL;
+  SWFDEC_AS_SCRIPT_FUNCTION (fun)->scope = scope;
+  SWFDEC_AS_SCRIPT_FUNCTION (fun)->target = target;
   proto = swfdec_as_object_new (SWFDEC_AS_OBJECT (scope)->context);
   if (proto == NULL)
     return NULL;
@@ -131,8 +133,6 @@ swfdec_as_script_function_new (SwfdecAsS
   swfdec_as_object_set_variable (proto, SWFDEC_AS_STR_constructor, &val);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
   swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (fun), SWFDEC_AS_STR_prototype, &val);
-  SWFDEC_AS_SCRIPT_FUNCTION (fun)->scope = scope;
-  SWFDEC_AS_SCRIPT_FUNCTION (fun)->target = target;
 
   return fun;
 }
diff-tree 766540d421a3bfc96ca32b66dedb9f96b49682d0 (from dbc065c9730a6dc69caca57bb5509cf356e5cd51)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 17:32:34 2007 +0200

    just use a higher version interpreter for a bytecode if the vurrent version doesn't know it

diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c
index 96c23e4..b2a74cb 100644
--- a/libswfdec/swfdec_as_context.c
+++ b/libswfdec/swfdec_as_context.c
@@ -682,6 +682,7 @@ swfdec_as_context_run (SwfdecAsContext *
   SwfdecAsFrame *frame, *last_frame;
   SwfdecScript *script;
   const SwfdecActionSpec *spec;
+  SwfdecActionExec exec;
   guint8 *startpc, *pc, *endpc, *nextpc;
 #ifndef G_DISABLE_ASSERT
   SwfdecAsValue *check;
@@ -813,12 +814,22 @@ start:
       nextpc = pc + 1;
     }
     /* check action is valid */
-    if (spec->exec[version] == NULL) {
-      SWFDEC_WARNING ("cannot interpret action %3u 0x%02X %s for version %u, skipping it", action,
-	  action, spec->name ? spec->name : "Unknown", script->version);
-      frame->pc = pc = nextpc;
-      check_scope = TRUE;
-      continue;
+    exec = spec->exec[version];
+    if (!exec) {
+      guint real_version;
+      for (real_version = version + 1; !exec && real_version <= SWFDEC_AS_MAX_SCRIPT_VERSION; real_version++) {
+	exec = spec->exec[real_version];
+      }
+      if (!exec) {
+	SWFDEC_WARNING ("cannot interpret action %3u 0x%02X %s for version %u, skipping it", action,
+	    action, spec->name ? spec->name : "Unknown", script->version);
+	frame->pc = pc = nextpc;
+	check_scope = TRUE;
+	continue;
+      }
+      SWFDEC_WARNING ("cannot interpret action %3u 0x%02X %s for version %u, using version %u instead", 
+	  action, action, spec->name ? spec->name : "Unknown", script->version, 
+	  script->version + real_version - version);
     }
     if (spec->remove > 0) {
       if (spec->add > spec->remove)
@@ -836,7 +847,7 @@ start:
     check = (spec->add >= 0 && spec->remove >= 0) ? context->cur + spec->add - spec->remove : NULL;
 #endif
     /* execute action */
-    spec->exec[version] (context, action, data, len);
+    exec (context, action, data, len);
     /* adapt the pc if the action did not, otherwise, leave it alone */
     /* FIXME: do this via flag? */
     if (frame->pc == pc) {
diff-tree dbc065c9730a6dc69caca57bb5509cf356e5cd51 (from 4c21f27a1d0da5548142668069eecf835fadd541)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 17:31:44 2007 +0200

    0 registers means 4 registers

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index 73907ee..7b5d231 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -1499,6 +1499,8 @@ swfdec_action_define_function (SwfdecAsC
   n_args = swfdec_bits_get_u16 (&bits);
   if (v2) {
     n_registers = swfdec_bits_get_u8 (&bits);
+    if (n_registers == 0)
+      n_registers = 4;
     flags = swfdec_bits_get_u16 (&bits);
   } else {
     n_registers = 5;
diff-tree 4c21f27a1d0da5548142668069eecf835fadd541 (from 30dee9addcb7b3da9dbf00e260662acd648df851)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 13:11:50 2007 +0200

    implement Breakpoint.onSetVariable breakpoint

diff --git a/vivified/core/vivi_breakpoint.c b/vivified/core/vivi_breakpoint.c
index 506ee08..15cfc26 100644
--- a/vivified/core/vivi_breakpoint.c
+++ b/vivified/core/vivi_breakpoint.c
@@ -63,6 +63,21 @@ vivi_breakpoint_finish_frame (ViviDebugg
   return swfdec_as_value_to_boolean (obj->context, &retval);
 }
 
+static gboolean
+vivi_breakpoint_set_variable (ViviDebugger *debugger, SwfdecAsObject *object, 
+    const char *variable, const SwfdecAsValue *value, ViviBreakpoint *breakpoint)
+{
+  SwfdecAsObject *obj = SWFDEC_AS_OBJECT (breakpoint);
+  SwfdecAsValue vals[3];
+  SwfdecAsValue retval;
+
+  SWFDEC_AS_VALUE_SET_OBJECT (&vals[0], vivi_wrap_object (VIVI_APPLICATION (obj->context), object));
+  SWFDEC_AS_VALUE_SET_STRING (&vals[1], swfdec_as_context_get_string (obj->context, variable));
+  vivi_wrap_value (VIVI_APPLICATION (obj->context), &vals[2], value);
+  swfdec_as_object_call (obj, swfdec_as_context_get_string (obj->context, "onSetVariable"), 3, vals, &retval);
+  return swfdec_as_value_to_boolean (obj->context, &retval);
+}
+
 static const struct {
   const char *	event;
   const char *	signal;
@@ -71,7 +86,8 @@ static const struct {
   { NULL, NULL, NULL }, /* invalid */
   { "onCommand", "step", G_CALLBACK (vivi_breakpoint_step) },
   { "onStartFrame", "start-frame", G_CALLBACK (vivi_breakpoint_start_frame) },
-  { "onExitFrame", "finish-frame", G_CALLBACK (vivi_breakpoint_finish_frame) }
+  { "onExitFrame", "finish-frame", G_CALLBACK (vivi_breakpoint_finish_frame) },
+  { "onSetVariable", "set-variable", G_CALLBACK (vivi_breakpoint_set_variable) }
 };
 
 static guint
diff --git a/vivified/core/vivi_debugger.c b/vivified/core/vivi_debugger.c
index c8c76a8..a5ae2eb 100644
--- a/vivified/core/vivi_debugger.c
+++ b/vivified/core/vivi_debugger.c
@@ -31,6 +31,7 @@ enum {
   STEP,
   START_FRAME,
   FINISH_FRAME,
+  SET_VARIABLE,
   LAST_SIGNAL
 };
 
@@ -129,6 +130,18 @@ vivi_debugger_finish_frame (SwfdecAsDebu
 }
 
 static void
+vivi_debugger_set_variable (SwfdecAsDebugger *debugger, SwfdecAsContext *context, 
+    SwfdecAsObject *object, const char *variable, const SwfdecAsValue *value)
+{
+  gboolean retval = FALSE;
+
+  g_signal_emit (debugger, signals[SET_VARIABLE], 0, object, variable, value, &retval);
+
+  if (retval)
+    vivi_debugger_break (VIVI_DEBUGGER (debugger));
+}
+
+static void
 vivi_debugger_class_init (ViviDebuggerClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -145,10 +158,14 @@ vivi_debugger_class_init (ViviDebuggerCl
   signals[FINISH_FRAME] = g_signal_new ("finish-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);
+  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);
 
   debugger_class->step = vivi_debugger_step;
   debugger_class->start_frame = vivi_debugger_start_frame;
   debugger_class->finish_frame = vivi_debugger_finish_frame;
+  debugger_class->set_variable = vivi_debugger_set_variable;
 }
 
 static void
diff --git a/vivified/core/vivi_marshal.list b/vivified/core/vivi_marshal.list
index 7dce98e..e28004f 100644
--- a/vivified/core/vivi_marshal.list
+++ b/vivified/core/vivi_marshal.list
@@ -1,3 +1,4 @@
 BOOLEAN:OBJECT
 BOOLEAN:OBJECT,POINTER
+BOOLEAN:OBJECT,STRING,POINTER
 BOOLEAN:VOID
diff-tree 30dee9addcb7b3da9dbf00e260662acd648df851 (from 66ab735ff2220bb72c978d827978edda1b215fe9)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 13:11:02 2007 +0200

    allow getting the global variable of the player

diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as
index 16384fd..65f51d1 100644
--- a/vivified/core/vivi_initialize.as
+++ b/vivified/core/vivi_initialize.as
@@ -41,8 +41,9 @@ Breakpoint.prototype.addProperty ("activ
 /*** information about the player ***/
 
 Player = {};
-Player.addProperty ("frame", Native.player_frame_get, null);
 Player.addProperty ("filename", Native.player_filename_get, Native.player_filename_set);
+Player.addProperty ("frame", Native.player_frame_get, null);
+Player.addProperty ("global", Native.player_global_get, null);
 Player.addProperty ("variables", Native.player_variables_get, Native.player_variables_set);
 
 /*** commands available for debugging ***/
diff --git a/vivified/core/vivi_player_as.c b/vivified/core/vivi_player_as.c
index 01eb69a..c7e36ad 100644
--- a/vivified/core/vivi_player_as.c
+++ b/vivified/core/vivi_player_as.c
@@ -92,3 +92,16 @@ vivi_player_as_variables_set (SwfdecAsCo
   vivi_application_set_variables (app, s);
 }
 
+VIVI_FUNCTION ("player_global_get", vivi_player_as_global_get)
+void
+vivi_player_as_global_get (SwfdecAsContext *cx, SwfdecAsObject *this,
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+  ViviApplication *app = VIVI_APPLICATION (cx);
+  
+  if (SWFDEC_AS_CONTEXT (app->player)->global) {
+    SWFDEC_AS_VALUE_SET_OBJECT (retval, vivi_wrap_object (app, 
+	  SWFDEC_AS_CONTEXT (app->player)->global));
+  }
+}
+
diff-tree 66ab735ff2220bb72c978d827978edda1b215fe9 (from f7aaf7413c4306caf1f870a7606fbbe86540f16e)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 13:10:28 2007 +0200

    handle stepping outside of breakpoints correctly

diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index cc1d4c2..b7f3b9f 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -257,9 +257,18 @@ vivi_application_step_forward (gpointer 
   ViviApplication *app = appp;
   guint next_event;
 
+  app->step_source = 0;
+  if (app->loop != NULL ||
+      app->playback_state != VIVI_APPLICATION_STEPPING)
+    return FALSE;
+
+  app->playback_count--;
+  if (app->playback_count == 0)
+    app->playback_state = VIVI_APPLICATION_STOPPED;
   next_event = swfdec_player_get_next_event (app->player);
   swfdec_player_advance (app->player, next_event);
 
+  vivi_application_check (app);
   return FALSE;
 }
 
@@ -281,9 +290,8 @@ vivi_application_check (ViviApplication 
     case VIVI_APPLICATION_PLAYING:
       break;
     case VIVI_APPLICATION_STEPPING:
-      if (!is_breakpoint) {
-	/* FIXME: sanely handle this */
-	g_idle_add_full (-100, vivi_application_step_forward, app, NULL);
+      if (!is_breakpoint && app->step_source == 0) {
+	app->step_source = g_idle_add_full (-100, vivi_application_step_forward, app, NULL);
       }
       break;
     default:
@@ -391,6 +399,12 @@ vivi_application_quit (ViviApplication *
     return;
   app->playback_state = VIVI_APPLICATION_EXITING;
   app->playback_count = 1;
+  if (app->step_source) {
+    if (!g_source_remove (app->step_source)) {
+      g_assert_not_reached ();
+    } 
+    app->step_source = 0;
+  }
   g_object_notify (G_OBJECT (app), "quit");
   vivi_application_check (app);
 }
diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h
index 33694bf..1a8c68a 100644
--- a/vivified/core/vivi_application.h
+++ b/vivified/core/vivi_application.h
@@ -62,6 +62,7 @@ struct _ViviApplication
   ViviApplicationPlayback playback_state;	/* (running, stepping or stopped) */
   guint			playback_count;	/* how often to just restart this on breakpoints */
   GMainLoop *		loop;		/* the breakpoint main loop */
+  guint			step_source;	/* source for stepping forward */
 
   GHashTable *		wraps;		/* all wrapped objects from @player */
 };
diff-tree f7aaf7413c4306caf1f870a7606fbbe86540f16e (from 308d22cae15ac29dd9e7914ec9d3151639a7f529)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 13:09:51 2007 +0200

    make that breakpoint work and not crash

diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index 4dbcb1d..111dbb3 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -564,7 +564,7 @@ swfdec_as_object_set_variable (SwfdecAsO
 
   if (object->context->debugger) {
     SwfdecAsDebugger *debugger = object->context->debugger;
-    SwfdecAsDebuggerClass *dklass = SWFDEC_AS_DEBUGGER_CLASS (klass);
+    SwfdecAsDebuggerClass *dklass = SWFDEC_AS_DEBUGGER_GET_CLASS (debugger);
     if (dklass->set_variable)
       dklass->set_variable (debugger, object->context, object, variable, value);
   }
diff-tree 308d22cae15ac29dd9e7914ec9d3151639a7f529 (from 76ee7efbfdf7f2c77b52784a9f6e118fe20f8044)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 10:07:16 2007 +0200

    add set_variable entry point for debugger
    
    includes a constness fix

diff --git a/libswfdec/swfdec_as_debugger.h b/libswfdec/swfdec_as_debugger.h
index fdd2a76..4a0f952 100644
--- a/libswfdec/swfdec_as_debugger.h
+++ b/libswfdec/swfdec_as_debugger.h
@@ -54,7 +54,13 @@ struct _SwfdecAsDebuggerClass {
   void			(* finish_frame)(SwfdecAsDebugger *	debugger,
 					 SwfdecAsContext *	context,
 					 SwfdecAsFrame *	frame,
-					 SwfdecAsValue *	return_value);
+					 const SwfdecAsValue *	return_value);
+  /* called before setting a variable */
+  void			(* set_variable)(SwfdecAsDebugger *	debugger,
+					 SwfdecAsContext *	context,
+					 SwfdecAsObject *	object,
+					 const char *		variable,
+					 const SwfdecAsValue *	value);
 };
 
 GType		swfdec_as_debugger_get_type	(void);
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index ee112db..4dbcb1d 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -562,6 +562,12 @@ swfdec_as_object_set_variable (SwfdecAsO
   g_return_if_fail (variable != NULL);
   g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
 
+  if (object->context->debugger) {
+    SwfdecAsDebugger *debugger = object->context->debugger;
+    SwfdecAsDebuggerClass *dklass = SWFDEC_AS_DEBUGGER_CLASS (klass);
+    if (dklass->set_variable)
+      dklass->set_variable (debugger, object->context, object, variable, value);
+  }
   klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
   klass->set (object, variable, value);
 }
diff --git a/vivified/core/vivi_debugger.c b/vivified/core/vivi_debugger.c
index 670daff..c8c76a8 100644
--- a/vivified/core/vivi_debugger.c
+++ b/vivified/core/vivi_debugger.c
@@ -117,7 +117,8 @@ vivi_debugger_start_frame (SwfdecAsDebug
 }
 
 static void
-vivi_debugger_finish_frame (SwfdecAsDebugger *debugger, SwfdecAsContext *context, SwfdecAsFrame *frame, SwfdecAsValue *ret)
+vivi_debugger_finish_frame (SwfdecAsDebugger *debugger, SwfdecAsContext *context, 
+    SwfdecAsFrame *frame, const SwfdecAsValue *ret)
 {
   gboolean retval = FALSE;
 
diff-tree 76ee7efbfdf7f2c77b52784a9f6e118fe20f8044 (from 9ed5469d665215b4a46f2f7de2628a4347cf8378)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 09:56:43 2007 +0200

    allow changing filename and variables

diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as
index bf6ed76..16384fd 100644
--- a/vivified/core/vivi_initialize.as
+++ b/vivified/core/vivi_initialize.as
@@ -42,6 +42,8 @@ Breakpoint.prototype.addProperty ("activ
 
 Player = {};
 Player.addProperty ("frame", Native.player_frame_get, null);
+Player.addProperty ("filename", Native.player_filename_get, Native.player_filename_set);
+Player.addProperty ("variables", Native.player_variables_get, Native.player_variables_set);
 
 /*** commands available for debugging ***/
 
diff --git a/vivified/core/vivi_player_as.c b/vivified/core/vivi_player_as.c
index ab8c4de..01eb69a 100644
--- a/vivified/core/vivi_player_as.c
+++ b/vivified/core/vivi_player_as.c
@@ -38,3 +38,57 @@ vivi_player_as_frame_get (SwfdecAsContex
     SWFDEC_AS_VALUE_SET_OBJECT (retval, vivi_wrap_object (app, obj));
 }
 
+VIVI_FUNCTION ("player_filename_get", vivi_player_as_filename_get)
+void
+vivi_player_as_filename_get (SwfdecAsContext *cx, SwfdecAsObject *this,
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+  ViviApplication *app = VIVI_APPLICATION (cx);
+  const char *s = vivi_application_get_filename (app);
+
+  if (s)
+    SWFDEC_AS_VALUE_SET_STRING (retval, swfdec_as_context_get_string (cx, s));
+}
+
+VIVI_FUNCTION ("player_filename_set", vivi_player_as_filename_set)
+void
+vivi_player_as_filename_set (SwfdecAsContext *cx, SwfdecAsObject *this,
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+  ViviApplication *app = VIVI_APPLICATION (cx);
+  const char *s;
+  
+  if (argc == 0)
+    return;
+  s = swfdec_as_value_to_string (cx, &argv[0]);
+  
+  vivi_application_set_filename (app, s);
+}
+
+VIVI_FUNCTION ("player_variables_get", vivi_player_as_variables_get)
+void
+vivi_player_as_variables_get (SwfdecAsContext *cx, SwfdecAsObject *this,
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+  ViviApplication *app = VIVI_APPLICATION (cx);
+  const char *s = vivi_application_get_variables (app);
+
+  if (s)
+    SWFDEC_AS_VALUE_SET_STRING (retval, swfdec_as_context_get_string (cx, s));
+}
+
+VIVI_FUNCTION ("player_variables_set", vivi_player_as_variables_set)
+void
+vivi_player_as_variables_set (SwfdecAsContext *cx, SwfdecAsObject *this,
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+  ViviApplication *app = VIVI_APPLICATION (cx);
+  const char *s;
+  
+  if (argc == 0)
+    return;
+  s = swfdec_as_value_to_string (cx, &argv[0]);
+  
+  vivi_application_set_variables (app, s);
+}
+
diff-tree 9ed5469d665215b4a46f2f7de2628a4347cf8378 (from be3bc1a6cd88c0f2294b4f6059898c3989f172eb)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 09:55:42 2007 +0200

    don't connect the signal swapped
    
    copy/paste error

diff --git a/vivified/ui/main.c b/vivified/ui/main.c
index 13d03ab..617e317 100644
--- a/vivified/ui/main.c
+++ b/vivified/ui/main.c
@@ -68,7 +68,7 @@ setup (const char *filename, const char 
   vivi_application_set_variables (app, variables);
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   g_signal_connect_swapped (app, "notify::quit", G_CALLBACK (gtk_widget_destroy), window);
-  g_signal_connect_swapped (app, "notify::filename", G_CALLBACK (set_title), window);
+  g_signal_connect (app, "notify::filename", G_CALLBACK (set_title), window);
   set_title (app, NULL, GTK_WINDOW (window));
   box = vivi_vdock_new ();
   gtk_container_add (GTK_CONTAINER (window), box);


More information about the Swfdec mailing list