[Swfdec] 2 commits - libswfdec/swfdec_as_object.c test/trace

Pekka Lampila medar at kemper.freedesktop.org
Wed Aug 22 03:06:50 PDT 2007


 libswfdec/swfdec_as_object.c     |    3 -
 test/trace/propflags-5.swf       |binary
 test/trace/propflags-5.swf.trace |    2 
 test/trace/propflags-6.swf       |binary
 test/trace/propflags-6.swf.trace |    2 
 test/trace/propflags-7.swf       |binary
 test/trace/propflags-7.swf.trace |    2 
 test/trace/propflags.as          |    2 
 test/trace/trace_properties.as   |  116 +++++++++++++++++++++++++++------------
 9 files changed, 88 insertions(+), 39 deletions(-)

New commits:
diff-tree d0a5d682d6cac81945ea8e2494f4826ececb37ec (from 9b23146c74f7298f3fa3398127b6ecb0517cbee9)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Wed Aug 22 13:04:33 2007 +0300

    Make trace_properties.as use smarter ids for properties
    
    Ids are now names of the lowest level occurance of the object
    Updated propflags test

diff --git a/test/trace/propflags-5.swf b/test/trace/propflags-5.swf
index 3648a4f..f39eb9c 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 78090aa..e19117a 100644
--- a/test/trace/propflags-5.swf.trace
+++ b/test/trace/propflags-5.swf.trace
@@ -1,4 +1,4 @@
-o object[0] : toString => ""
+o object[local.o] : toString => ""
   0 = number : 0
   1 (h) = number : 1
   2 (p) = number : 2
diff --git a/test/trace/propflags-6.swf b/test/trace/propflags-6.swf
index bb8f6ef..be9cb59 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 78090aa..e19117a 100644
--- a/test/trace/propflags-6.swf.trace
+++ b/test/trace/propflags-6.swf.trace
@@ -1,4 +1,4 @@
-o object[0] : toString => ""
+o object[local.o] : toString => ""
   0 = number : 0
   1 (h) = number : 1
   2 (p) = number : 2
diff --git a/test/trace/propflags-7.swf b/test/trace/propflags-7.swf
index 3bcd68d..b0df499 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 6a3c4b1..445ec27 100644
--- a/test/trace/propflags-7.swf.trace
+++ b/test/trace/propflags-7.swf.trace
@@ -1,4 +1,4 @@
-o object[0] : toString => "undefined"
+o object[local.o] : toString => "undefined"
   0 = number : 0
   1 (h) = number : 1
   2 (p) = number : 2
diff --git a/test/trace/propflags.as b/test/trace/propflags.as
index 8387431..72c7124 100644
--- a/test/trace/propflags.as
+++ b/test/trace/propflags.as
@@ -9,6 +9,6 @@ for (var i = 1; i <= 7; i++) {
   ASSetPropFlags (o, i, i, 0);
 }
 
-trace_properties (o, "o");
+trace_properties (o, "local", "o");
 
 loadMovie ("FSCommand:quit", "");
diff --git a/test/trace/trace_properties.as b/test/trace/trace_properties.as
index 5c6f171..e547478 100644
--- a/test/trace/trace_properties.as
+++ b/test/trace/trace_properties.as
@@ -134,15 +134,15 @@ function is_blaclisted (o, prop)
   return false;
 }
 
-function trace_properties_recurse (o, level, nextSecretId)
+function trace_properties_recurse (o, prefix, identifier, level)
 {
   // to collect info about different properties
   var info = new_info ();
 
-  // calculate prefix
-  var prefix = "";
+  // calculate indentation
+  var indentation = "";
   for (var j = 0; j < level; j++) {
-    prefix = prefix + "  ";
+    indentation = indentation + "  ";
   }
 
   // mark the ones that are not hidden
@@ -179,7 +179,7 @@ function trace_properties_recurse (o, le
   ASSetPropFlags (o, hidden, 1, 0);
 
   if (all.length == 0) {
-    trace (prefix + "no children");
+    trace (indentation + "no children");
     return nextSecretId;
   }
 
@@ -260,22 +260,9 @@ function trace_properties_recurse (o, le
     if (flags != "")
       flags = " (" + flags + ")";
 
-    // handle secretId that keeps track what things we have seen earlier
     var id_string = "";
-    var seen = false;
-    if (typeof (o[prop]) == "object" || typeof (o[prop]) == "function") {
-      if (hasOwnProperty (o[prop], "mySecretId")) {
-	seen = true;
-      } else {
-	o[prop]["mySecretId"] = nextSecretId;
-	if (o[prop]["mySecretId"] != undefined) {
-	  ASSetPropFlags (o[prop], "mySecretId", 7);
-	  nextSecretId++;
-	}
-      }
-      if (o[prop]["mySecretId"] != undefined)
-	id_string = "[" + o[prop]["mySecretId"] + "]";
-    }
+    if (typeof (o[prop]) == "object" || typeof (o[prop]) == "function")
+      id_string = "[" + o[prop]["mySecretId"] + "]";
 
     // put things together
     var output = prop + flags + " = " + typeof (o[prop]) + id_string;
@@ -290,33 +277,94 @@ function trace_properties_recurse (o, le
     }
 
     // print it out
-    trace (prefix + output);
+    trace (indentation + output);
 
     // recurse if it's object or function that hasn't been seen earlier
-    if (seen == false &&
-	(typeof (o[prop]) == "object" || typeof (o[prop]) == "function"))
+    if ((typeof (o[prop]) == "object" || typeof (o[prop]) == "function") &&
+	prefix + (prefix != "" ? "." : "") + identifier + "." + prop == o[prop]["mySecretId"])
     {
-      // move the next mySecretId to next hundred, this is to avoid screwing up
-      // all the ids between two runs if they disagree at the start
-      nextSecretId += 99;
-      nextSecretId -= nextSecretId % 100;
+      trace_properties_recurse (o[prop], prefix + (prefix != "" ? "." : "") +
+	  identifier, prop, level + 1);
+    }
+  }
+}
+
+function generate_names (o, prefix, identifier)
+{
+  var info = new_info ();
 
-      // recurse
-      nextSecretId =
-	trace_properties_recurse (o[prop], level + 1, nextSecretId);
+  // mark the ones that are not hidden
+  for (var prop in o)
+  {
+    // only get the ones that are not only in the __proto__
+    if (is_blaclisted (o, prop) == false) {
+      if (hasOwnProperty (o, prop) == true)
+	set_info (info, prop, "hidden", false);
     }
   }
 
-  return nextSecretId;
+  // unhide everything
+  ASSetPropFlags (o, null, 0, 1);
+
+  var all = new Array ();
+  var hidden = new Array ();
+  for (var prop in o)
+  {
+    // only get the ones that are not only in the __proto__
+    if (is_blaclisted (o, prop) == false) {
+      if (hasOwnProperty (o, prop) == true) {
+	all.push (prop);
+	if (get_info (info, prop, "hidden") != false) {
+	  set_info (info, prop, "hidden", true);
+	  hidden.push (prop);
+	}
+      }
+    }
+  }
+  all.sort ();
+
+  // hide the ones that were already hidden
+  ASSetPropFlags (o, hidden, 1, 0);
+
+  for (var i = 0; i < all.length; i++) {
+    var prop = all[i];
+
+    if (typeof (o[prop]) == "object" || typeof (o[prop]) == "function") {
+      if (hasOwnProperty (o[prop], "mySecretId")) {
+	all[i] = null; // don't recurse to it again
+      } else {
+	o[prop]["mySecretId"] = prefix + (prefix != "" ? "." : "") +
+	  identifier + "." + prop;
+      }
+    }
+  }
+
+  for (var i = 0; i < all.length; i++) {
+    var prop = all[i];
+
+    if (prop != null) {
+      if (typeof (o[prop]) == "object" || typeof (o[prop]) == "function")
+	generate_names (o[prop], prefix + (prefix != "" ? "." : "") +
+	    identifier, prop);
+    }
+  }
 }
 
-function trace_properties (o, identifier)
+function trace_properties (o, prefix, identifier)
 {
-  var output = identifier + " " + typeof (o) + "[0]";
+  _global["mySecretId"] = "_global";
+  _global.Object["mySecretId"] = "_global.Object";
+  generate_names (_global.Object, "_global", "Object");
+  generate_names (_global, "", "_global");
+
+  generate_names (o, prefix, identifier);
+
+  var output = identifier + " " + typeof (o) + "[" + prefix +
+    (prefix != "" ? "." : "") + identifier + "]";
   if (typeof (o) == "object")
     output += " : toString => \"" + o[prop] + "\"";
   trace (output);
 
   if (typeof (o) == "object" || typeof (o) == "function")
-    trace_properties_recurse (o, 1, 1);
+    trace_properties_recurse (o, prefix, identifier, 1);
 }
diff-tree 9b23146c74f7298f3fa3398127b6ecb0517cbee9 (from 71cba217cf8baa498b14a09685aef92266e72dba)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Wed Aug 22 12:39:02 2007 +0300

    Make functions permanent in swfdec_as_object_add_function

diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index 7d7062f..d18fe1f 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -835,7 +835,8 @@ swfdec_as_object_add_constructor (Swfdec
   name = swfdec_as_context_get_string (object->context, name);
   SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (function));
   /* FIXME: I'd like to make sure no such property exists yet */
-  swfdec_as_object_set_variable_and_flags (object, name, &val, SWFDEC_AS_VARIABLE_HIDDEN);
+  swfdec_as_object_set_variable_and_flags (object, name, &val,
+      SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
   return function;
 }
 


More information about the Swfdec mailing list