[Swfdec] 3 commits - libswfdec/swfdec_as_context.c test/trace

Pekka Lampila medar at kemper.freedesktop.org
Mon Aug 20 04:41:29 PDT 2007


 libswfdec/swfdec_as_context.c    |    4 -
 test/trace/loadvars-5.swf        |binary
 test/trace/loadvars-6.swf        |binary
 test/trace/loadvars-6.swf.trace  |   50 ++++++++-----
 test/trace/loadvars-7.swf        |binary
 test/trace/loadvars-7.swf.trace  |   50 ++++++++-----
 test/trace/loadvars.as           |    4 -
 test/trace/loadvars.txt          |    3 
 test/trace/propflags-5.swf       |binary
 test/trace/propflags-5.swf.trace |   14 ++-
 test/trace/propflags-6.swf       |binary
 test/trace/propflags-6.swf.trace |   14 ++-
 test/trace/propflags-7.swf       |binary
 test/trace/propflags-7.swf.trace |   13 ++-
 test/trace/propflags.as          |   85 ++--------------------
 test/trace/trace_properties.as   |  147 +++++++++++++++++++++++++++++++++++++++
 16 files changed, 256 insertions(+), 128 deletions(-)

New commits:
diff-tree 8871593035346615d3b0394184271674d5fd725d (from fdee654c4bc721aa1c18167bcaa7b52183565c96)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Mon Aug 20 14:39:30 2007 +0300

    Improve propflags test case
    
    Split most of the code to trace_properties.as so it can be included from other
    test too

diff --git a/test/trace/propflags-5.swf b/test/trace/propflags-5.swf
index 644c5ac..893b801 100644
Binary files a/test/trace/propflags-5.swf and b/test/trace/propflags-5.swf differ
diff --git a/test/trace/propflags-5.swf.trace b/test/trace/propflags-5.swf.trace
index eeaa55a..e7da22a 100644
--- a/test/trace/propflags-5.swf.trace
+++ b/test/trace/propflags-5.swf.trace
@@ -1,3 +1,11 @@
-Hidden: 1,3,5,7,__constructor__,__proto__,constructor
-Constant: 4,5,6,7
-Permanent: 
+   
+h  
+   
+h  
+  c
+h c
+  c
+h c
+h  
+h  
+h  
diff --git a/test/trace/propflags-6.swf b/test/trace/propflags-6.swf
index 2af13d8..c702cf4 100644
Binary files a/test/trace/propflags-6.swf and b/test/trace/propflags-6.swf differ
diff --git a/test/trace/propflags-6.swf.trace b/test/trace/propflags-6.swf.trace
index 8d59d4e..a3858d3 100644
--- a/test/trace/propflags-6.swf.trace
+++ b/test/trace/propflags-6.swf.trace
@@ -1,3 +1,11 @@
-Hidden: 1,3,5,7,__constructor__,__proto__,constructor
-Constant: 4,5,6,7
-Permanent: 2,3,6,7,__proto__
+    0 = 0
+h   1 = 1
+ p  2 = 2
+hp  3 = 3
+  c 4 = 4
+h c 5 = 5
+ pc 6 = 6
+hpc 7 = 7
+h   __constructor__ = [type Function]
+hp  __proto__ = [object Object]
+h   constructor = [type Function] __proto__.constructor = [type Function]
diff --git a/test/trace/propflags-7.swf b/test/trace/propflags-7.swf
index 9ae55c5..8780cfb 100644
Binary files a/test/trace/propflags-7.swf and b/test/trace/propflags-7.swf differ
diff --git a/test/trace/propflags-7.swf.trace b/test/trace/propflags-7.swf.trace
index 74b639d..3c66620 100644
--- a/test/trace/propflags-7.swf.trace
+++ b/test/trace/propflags-7.swf.trace
@@ -1,3 +1,10 @@
-Hidden: 1,3,5,7,__constructor__,__proto__
-Constant: 4,5,6,7
-Permanent: 2,3,6,7,__proto__
+    0 = 0
+h   1 = 1
+ p  2 = 2
+hp  3 = 3
+  c 4 = 4
+h c 5 = 5
+ pc 6 = 6
+hpc 7 = 7
+h   __constructor__ = [type Function]
+hp  __proto__ = [object Object]
diff --git a/test/trace/propflags.as b/test/trace/propflags.as
index 34ce251..daca383 100644
--- a/test/trace/propflags.as
+++ b/test/trace/propflags.as
@@ -1,83 +1,14 @@
-// makeswf -v 7 -r 1 -o test-7.swf test.as
+// makeswf -v 7 -r 1 -o propflags-7.swf propflags.as
 
-function hidden_properties (obj)
-{
-  normal = new Array ();
-  for (prop in obj) {
-    normal.push (prop);
-  }
+#include "trace_properties.as"
 
-  hidden = new Array ();
-  ASSetPropFlags (obj, null, 0, 1);
-  for (prop in obj) {
-    for (i = 0; i < normal.length; i++) {
-      if (normal[i] == prop)
-	break;
-    }
-    if (i == normal.length)
-      hidden.push (prop);
-  }
-  ASSetPropFlags (obj, hidden, 1, 0);
-
-  return hidden.sort ();
-}
-
-// loses flags from the properties that are not permanent
-function permanent_properties (obj)
-{
-  hidden = hidden_properties (obj);
-  constant = constant_properties (obj);
-
-  ASSetPropFlags (obj, hidden, 0, 1);
-
-  permanent = new Array();
-  for (var prop in obj) {
-    var old = obj[prop];
-    delete obj[prop];
-    if (obj.hasOwnProperty (prop)) {
-      permanent.push (prop);
-    } else {
-      obj[prop] = old;
-    }
-  }
-
-  ASSetPropFlags (obj, hidden, 1, 0);
-  ASSetPropFlags (obj, constant, 3, 0);
-
-  return permanent.sort ();
-}
-
-function constant_properties (obj)
-{
-  hidden = hidden_properties (obj);
-
-  ASSetPropFlags (obj, hidden, 0, 1);
-
-  constant = new Array();
-  for (var prop in obj) {
-    var old = obj[prop];
-    var val = "hello " + obj[prop];
-    obj[prop] = val;
-    if (obj[prop] != val) {
-      constant.push (prop);
-    } else {
-      obj[prop] = old;
-    }
-  }
-
-  ASSetPropFlags (obj, hidden, 1, 0);
-
-  return constant.sort ();
-}
-
-var obj = new Object ();
-obj[0] = 0;
+var o = new Object ();
+o[0] = 0;
 for (var i = 1; i <= 7; i++) {
-  obj[i] = i;
-  ASSetPropFlags (obj, i, i, 0);
+  o[i] = i;
+  ASSetPropFlags (o, i, i, 0);
 }
-trace ("Hidden: " + hidden_properties (obj));
-trace ("Constant: " + constant_properties (obj));
-trace ("Permanent: " + permanent_properties (obj));
+
+trace_properties (o);
 
 loadMovie ("FSCommand:quit", "");
diff --git a/test/trace/trace_properties.as b/test/trace/trace_properties.as
new file mode 100644
index 0000000..a62fea1
--- /dev/null
+++ b/test/trace/trace_properties.as
@@ -0,0 +1,147 @@
+// doesn't work right in Flash 5
+
+function new_empty_object () {
+  var hash = new Object ();
+  ASSetPropFlags (hash, null, 0, 7);
+  for (var prop in hash) {
+    delete hash[prop];
+  }
+  return hash;
+}
+
+function new_info () {
+  return new_empty_object ();
+}
+
+function set_info (info, prop, id, value) {
+  info[prop + "_-_" + id] = value;
+}
+
+function get_info (info, prop, id) {
+  return info[prop + "_-_" + id];
+}
+
+// print all properties of a given object, flags are:
+// h = hidden
+// p = permanent
+// P = permanent even without propflag
+// c = constant
+// C = constant even without propflag
+function trace_properties (o)
+{
+  var info = new_info ();
+  for (var prop in o) {
+    set_info (info, prop, "hidden", false);
+  }
+
+  var hidden = new Array ();
+
+  ASSetPropFlags (o, null, 0, 1);
+
+  var all = new Array ();
+  for (var prop in o) {
+    all.push (prop);
+    if (o.hasOwnProperty (prop)) {
+      set_info (info, prop, "outproto", true);
+    } else {
+      set_info (info, prop, "outproto", false);
+    }
+    if (o.__proto__.hasOwnProperty (prop)) {
+      set_info (info, prop, "inproto", true);
+    } else {
+      set_info (info, prop, "inproto", false);
+    }
+  }
+  all.sort ();
+
+  for (var prop in o) {
+    if (get_info (info, prop, "hidden") != false) {
+      set_info (info, prop, "hidden", true);
+      hidden.push (prop);
+    }
+  }
+
+  for (var prop in o) {
+    var old = o[prop];
+    var val = "hello " + o[prop];
+    o[prop] = val;
+    if (o[prop] != val) {
+      set_info (info, prop, "constant", true);
+      ASSetPropFlags (o, prop, 0, 4);
+      o[prop] = val;
+      if (o[prop] != val) {
+	set_info (info, prop, "superconstant", true);
+      } else {
+	set_info (info, prop, "superconstant", false);
+	o[prop] = old;
+      }
+      ASSetPropFlags (o, prop, 4);
+    } else {
+      set_info (info, prop, "constant", false);
+      set_info (info, prop, "superconstant", false);
+      o[prop] = old;
+    }
+  }
+
+  for (var prop in o) {
+    ASSetPropFlags (o, prop, 0, 4);
+    var old = o[prop];
+    delete o[prop];
+    if (o.hasOwnProperty (prop)) {
+      set_info (info, prop, "permanent", true);
+      ASSetPropFlags (o, prop, 0, 2);
+      delete o[prop];
+      if (o.hasOwnProperty (prop)) {
+	set_info (info, prop, "superpermanent", true);
+      } else {
+	set_info (info, prop, "superpermanent", false);
+	o[prop] = old;
+      }
+      ASSetPropFlags (o, prop, 4);
+    } else {
+      set_info (info, prop, "permanent", false);
+      o[prop] = old;
+    }
+    if (get_info (info, prop, "constant") == true)
+      ASSetPropFlags (o, prop, 4);
+  }
+
+  ASSetPropFlags (o, hidden, 1, 0);
+
+  for (var i = 0; i < all.length; i++) {
+    var flags = "";
+
+    if (get_info (info, all[i], "hidden") == true) {
+      flags += "h";
+    } else {
+      flags += " ";
+    }
+
+    if (get_info (info, all[i], "superpermanent") == true) {
+      flags += "P";
+    } else if (get_info (info, all[i], "permanent") == true) {
+      flags += "p";
+    } else {
+      flags += " ";
+    }
+
+    if (get_info (info, all[i], "superconstant") == true) {
+      flags += "C";
+    } else if (get_info (info, all[i], "constant") == true) {
+      flags += "c";
+    } else {
+      flags += " ";
+    }
+
+    values = "";
+
+    if (get_info (info, all[i], "outproto") == true) {
+      values += " " + all[i] + " = " + o[all[i]];
+    }
+    if (get_info (info, all[i], "inproto") == true) {
+      values += " __proto__." + all[i] + " = " + o.__proto__[all[i]];
+    }
+
+    trace (flags + values);
+  }
+}
diff-tree fdee654c4bc721aa1c18167bcaa7b52183565c96 (from daed3a3bd2d1517f271c8868670148eba0af3c8f)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Mon Aug 20 14:17:53 2007 +0300

    Fix errors in ASSetPropFlags

diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c
index 75ab9d6..9e71c0d 100644
--- a/libswfdec/swfdec_as_context.c
+++ b/libswfdec/swfdec_as_context.c
@@ -1018,7 +1018,7 @@ swfdec_as_context_ASSetPropFlags_foreach
   guint *flags = data;
 
   /* shortcut if the flags already match */
-  if ((cur_flags & flags[1]) == flags[0])
+  if (cur_flags == ((cur_flags &~ flags[1]) | flags[0]))
     return TRUE;
 
   swfdec_as_context_ASSetPropFlags_set_one_flag (object, s, flags);
@@ -1039,7 +1039,7 @@ swfdec_as_context_ASSetPropFlags (Swfdec
     return;
   obj = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
   flags[0] = swfdec_as_value_to_integer (cx, &argv[2]);
-  flags[1] = (argc > 3) ? swfdec_as_value_to_integer (cx, &argv[3]) : -1;
+  flags[1] = (argc > 3) ? swfdec_as_value_to_integer (cx, &argv[3]) : 0;
   if (SWFDEC_AS_VALUE_IS_NULL (&argv[1])) {
     swfdec_as_object_foreach (obj, swfdec_as_context_ASSetPropFlags_foreach, flags);
   } else {
diff-tree daed3a3bd2d1517f271c8868670148eba0af3c8f (from 58a57fd8b8361870a39382099717b3fe2fdf38e7)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Mon Aug 20 13:34:18 2007 +0300

    Forgot to add .txt file for loadvars test

diff --git a/test/trace/loadvars-5.swf b/test/trace/loadvars-5.swf
index 1c89902..42c7476 100644
Binary files a/test/trace/loadvars-5.swf and b/test/trace/loadvars-5.swf differ
diff --git a/test/trace/loadvars-6.swf b/test/trace/loadvars-6.swf
index 5d623a9..56ae085 100644
Binary files a/test/trace/loadvars-6.swf and b/test/trace/loadvars-6.swf differ
diff --git a/test/trace/loadvars-6.swf.trace b/test/trace/loadvars-6.swf.trace
index 093c6d0..3a22913 100644
--- a/test/trace/loadvars-6.swf.trace
+++ b/test/trace/loadvars-6.swf.trace
@@ -1,39 +1,51 @@
 [type Function]
 undefined
-onData: test=2&moi=terve&tyhja&=taysi&hehe=jotain%20muuta&hehe2=jotain muuta&on=lal=lel=luu
+onData: test=2&hi=hello&empty_value&=empty_name&spa%20ce=spa%20ce&sp ace&spa ce=sp ace&many=equal=signs=in=row&eof=
+was there&eof
+=was there&
 
 false
-84
-84
+134
+134
 onLoad: true
 true
-84
-84
-hehe = jotain muuta
-hehe2 = jotain muuta
-moi = terve
-on = lal=lel=luu
+134
+134
 
+ = 
+empty_value = 
+eof = 
+was there
+eof
+ = was there
+hi = hello
+many = equal=signs=in=row
 onData = [type Function]
 onDataReal = [type Function]
 onLoad = [type Function]
+sp ace = 
+spa ce = sp ace
 test = 2
-tyhja = 
 onData: 
 true
-84
-84
+134
+134
 onLoad: false
 true
-84
-84
-hehe = jotain muuta
-hehe2 = jotain muuta
-moi = terve
-on = lal=lel=luu
+134
+134
 
+ = 
+empty_value = 
+eof = 
+was there
+eof
+ = was there
+hi = hello
+many = equal=signs=in=row
 onData = [type Function]
 onDataReal = [type Function]
 onLoad = [type Function]
+sp ace = 
+spa ce = sp ace
 test = 2
-tyhja = 
diff --git a/test/trace/loadvars-7.swf b/test/trace/loadvars-7.swf
index 7af6ca7..ee18028 100644
Binary files a/test/trace/loadvars-7.swf and b/test/trace/loadvars-7.swf differ
diff --git a/test/trace/loadvars-7.swf.trace b/test/trace/loadvars-7.swf.trace
index 11f965b..95d654a 100644
--- a/test/trace/loadvars-7.swf.trace
+++ b/test/trace/loadvars-7.swf.trace
@@ -1,39 +1,51 @@
 [type Function]
 undefined
-onData: test=2&moi=terve&tyhja&=taysi&hehe=jotain%20muuta&hehe2=jotain muuta&on=lal=lel=luu
+onData: test=2&hi=hello&empty_value&=empty_name&spa%20ce=spa%20ce&sp ace&spa ce=sp ace&many=equal=signs=in=row&eof=
+was there&eof
+=was there&
 
 false
-84
-84
+134
+134
 onLoad: true
 true
-84
-84
-hehe = jotain muuta
-hehe2 = jotain muuta
-moi = terve
-on = lal=lel=luu
+134
+134
 
+ = 
+empty_value = 
+eof = 
+was there
+eof
+ = was there
+hi = hello
+many = equal=signs=in=row
 onData = [type Function]
 onDataReal = [type Function]
 onLoad = [type Function]
+sp ace = 
+spa ce = sp ace
 test = 2
-tyhja = 
 onData: undefined
 true
-84
-84
+134
+134
 onLoad: false
 true
-84
-84
-hehe = jotain muuta
-hehe2 = jotain muuta
-moi = terve
-on = lal=lel=luu
+134
+134
 
+ = 
+empty_value = 
+eof = 
+was there
+eof
+ = was there
+hi = hello
+many = equal=signs=in=row
 onData = [type Function]
 onDataReal = [type Function]
 onLoad = [type Function]
+sp ace = 
+spa ce = sp ace
 test = 2
-tyhja = 
diff --git a/test/trace/loadvars.as b/test/trace/loadvars.as
index b21ea99..b3203a4 100644
--- a/test/trace/loadvars.as
+++ b/test/trace/loadvars.as
@@ -29,8 +29,8 @@ lv.onLoad = function (success) {
   }
 };
 
-lv.load ("params.txt");
-lv.load ("blah.txt");
+lv.load ("loadvars.txt");
+lv.load ("404");
 
 function quit () {
   loadMovie ("FSCommand:quit", "");
diff --git a/test/trace/loadvars.txt b/test/trace/loadvars.txt
new file mode 100644
index 0000000..867ba7e
--- /dev/null
+++ b/test/trace/loadvars.txt
@@ -0,0 +1,3 @@
+test=2&hi=hello&empty_value&=empty_name&spa%20ce=spa%20ce&sp ace&spa ce=sp ace&many=equal=signs=in=row&eof=
+was there&eof
+=was there&


More information about the Swfdec mailing list