Benjamin Otte
2007-Aug-15 20:09 UTC
[Swfdec] 2 commits - libswfdec/swfdec_as_object.c test/trace
libswfdec/swfdec_as_object.c | 62 +++++++++++++++-------
test/trace/Makefile.am | 9 +++
test/trace/addProperty-set-prototypes-5.swf |binary
test/trace/addProperty-set-prototypes-5.swf.trace | 4 +
test/trace/addProperty-set-prototypes-6.swf |binary
test/trace/addProperty-set-prototypes-6.swf.trace | 5 +
test/trace/addProperty-set-prototypes-7.swf |binary
test/trace/addProperty-set-prototypes-7.swf.trace | 5 +
test/trace/addProperty-set-prototypes-8.swf |binary
test/trace/addProperty-set-prototypes-8.swf.trace | 5 +
test/trace/addProperty-set-prototypes.as | 18 ++++++
11 files changed, 91 insertions(+), 17 deletions(-)
New commits:
diff-tree 01e8d90362605acf52d171de350853bd773e7edb (from
d43d504a01b534233965d5c7fd851ae65ac5ce09)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 22:03:07 2007 +0200
add check for last commit
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 7e72228..591144a 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -37,6 +37,15 @@ EXTRA_DIST = \
addProperty-7.swf.trace \
addProperty-8.swf \
addProperty-8.swf.trace \
+ addProperty-set-prototypes.as \
+ addProperty-set-prototypes-5.swf \
+ addProperty-set-prototypes-5.swf.trace \
+ addProperty-set-prototypes-6.swf \
+ addProperty-set-prototypes-6.swf.trace \
+ addProperty-set-prototypes-7.swf \
+ addProperty-set-prototypes-7.swf.trace \
+ addProperty-set-prototypes-8.swf \
+ addProperty-set-prototypes-8.swf.trace \
and-or-5.swf \
and-or-5.swf.trace \
and-or-6.swf \
diff --git a/test/trace/addProperty-set-prototypes-5.swf
b/test/trace/addProperty-set-prototypes-5.swf
new file mode 100644
index 0000000..956a6b1
Binary files /dev/null and b/test/trace/addProperty-set-prototypes-5.swf differ
diff --git a/test/trace/addProperty-set-prototypes-5.swf.trace
b/test/trace/addProperty-set-prototypes-5.swf.trace
new file mode 100644
index 0000000..50d348c
--- /dev/null
+++ b/test/trace/addProperty-set-prototypes-5.swf.trace
@@ -0,0 +1,4 @@
+Check how addProperty affects prototypes
+10
+15
+15
diff --git a/test/trace/addProperty-set-prototypes-6.swf
b/test/trace/addProperty-set-prototypes-6.swf
new file mode 100644
index 0000000..22ca2dc
Binary files /dev/null and b/test/trace/addProperty-set-prototypes-6.swf differ
diff --git a/test/trace/addProperty-set-prototypes-6.swf.trace
b/test/trace/addProperty-set-prototypes-6.swf.trace
new file mode 100644
index 0000000..2d83ca9
--- /dev/null
+++ b/test/trace/addProperty-set-prototypes-6.swf.trace
@@ -0,0 +1,5 @@
+Check how addProperty affects prototypes
+10
+10
+a set
+10
diff --git a/test/trace/addProperty-set-prototypes-7.swf
b/test/trace/addProperty-set-prototypes-7.swf
new file mode 100644
index 0000000..e49f1e8
Binary files /dev/null and b/test/trace/addProperty-set-prototypes-7.swf differ
diff --git a/test/trace/addProperty-set-prototypes-7.swf.trace
b/test/trace/addProperty-set-prototypes-7.swf.trace
new file mode 100644
index 0000000..2d83ca9
--- /dev/null
+++ b/test/trace/addProperty-set-prototypes-7.swf.trace
@@ -0,0 +1,5 @@
+Check how addProperty affects prototypes
+10
+10
+a set
+10
diff --git a/test/trace/addProperty-set-prototypes-8.swf
b/test/trace/addProperty-set-prototypes-8.swf
new file mode 100644
index 0000000..e3cf58f
Binary files /dev/null and b/test/trace/addProperty-set-prototypes-8.swf differ
diff --git a/test/trace/addProperty-set-prototypes-8.swf.trace
b/test/trace/addProperty-set-prototypes-8.swf.trace
new file mode 100644
index 0000000..2d83ca9
--- /dev/null
+++ b/test/trace/addProperty-set-prototypes-8.swf.trace
@@ -0,0 +1,5 @@
+Check how addProperty affects prototypes
+10
+10
+a set
+10
diff --git a/test/trace/addProperty-set-prototypes.as
b/test/trace/addProperty-set-prototypes.as
new file mode 100644
index 0000000..9cf4c38
--- /dev/null
+++ b/test/trace/addProperty-set-prototypes.as
@@ -0,0 +1,18 @@
+// makeswf -v 7 -s 200x150 -r 1 -o addProperty-set-prototypes.swf
addProperty-set-prototypes.as
+
+trace ("Check how addProperty affects prototypes");
+
+o = {name: "a"};
+o.__proto__ = {name: "b", x: 10 };
+o.__proto__.__proto__ = {name: "c"};
+o.__proto__.__proto__.__proto__ = {name: "d"};
+o.__proto__.__proto__.addProperty ("x", function () { trace
(this.name); return 42; }, null);
+o.__proto__.__proto__.__proto__.addProperty ("x", function () { trace
(this.name); return 642; }, function () { trace (this.name + " set");
});
+trace (o.x);
+o.x = 15;
+trace (o.x);
+o.__proto__.__proto__ = o.__proto__.__proto__.__proto__;
+o.x = 15;
+trace (o.x);
+
+loadMovie ("FSCommand:quit", "");
diff-tree d43d504a01b534233965d5c7fd851ae65ac5ce09 (from
01dc987b2068a641f131abed7da476b2f7fd852a)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 21:59:48 2007 +0200
fix property setting when addProperty had been called on parents
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index 64b8ff0..b1d06e5 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -139,6 +139,12 @@ swfdec_as_object_lookup_case_insensitive
return strcasecmp (key, user_data) == 0;
}
+static gboolean
+swfdec_as_variable_name_is_valid (const char *name)
+{
+ return name != SWFDEC_AS_STR_EMPTY;
+}
+
static inline SwfdecAsVariable *
swfdec_as_object_hash_lookup (SwfdecAsObject *object, const char *variable)
{
@@ -150,6 +156,21 @@ swfdec_as_object_hash_lookup (SwfdecAsOb
return var;
}
+static inline SwfdecAsVariable *
+swfdec_as_object_hash_create (SwfdecAsObject *object, const char *variable)
+{
+ SwfdecAsVariable *var;
+
+ if (!swfdec_as_context_use_mem (object->context, sizeof
(SwfdecAsVariable)))
+ return NULL;
+ if (!swfdec_as_variable_name_is_valid (variable))
+ return NULL;
+ var = g_slice_new0 (SwfdecAsVariable);
+ g_hash_table_insert (object->properties, (gpointer) variable, var);
+
+ return var;
+}
+
static gboolean
swfdec_as_object_do_get (SwfdecAsObject *object, const char *variable,
SwfdecAsValue *val, guint *flags)
@@ -173,26 +194,14 @@ swfdec_as_object_do_get (SwfdecAsObject
return TRUE;
}
-static gboolean
-swfdec_as_variable_name_is_valid (const char *name)
-{
- return name != SWFDEC_AS_STR_EMPTY;
-}
-
static SwfdecAsVariable *
swfdec_as_object_lookup_variable (SwfdecAsObject *object, const char *variable)
{
SwfdecAsVariable *var;
var = swfdec_as_object_hash_lookup (object, variable);
- if (var == NULL) {
- if (!swfdec_as_context_use_mem (object->context, sizeof
(SwfdecAsVariable)))
- return NULL;
- if (!swfdec_as_variable_name_is_valid (variable))
- return NULL;
- var = g_slice_new0 (SwfdecAsVariable);
- g_hash_table_insert (object->properties, (gpointer) variable, var);
- }
+ if (var == NULL)
+ var = swfdec_as_object_hash_create (object, variable);
return var;
}
@@ -214,9 +223,28 @@ swfdec_as_object_do_set (SwfdecAsObject
}
}
- var = swfdec_as_object_lookup_variable (object, variable);
- if (var == NULL)
- return;
+ var = swfdec_as_object_hash_lookup (object, variable);
+ if (var == NULL) {
+ guint i;
+ SwfdecAsObject *proto = object->prototype;
+
+ for (i = 0; i < 256 && proto; i++) {
+ var = swfdec_as_object_hash_lookup (proto, variable);
+ if (var && var->get)
+ break;
+ proto = proto->prototype;
+ var = NULL;
+ }
+ if (i == 256) {
+ swfdec_as_context_abort (object->context, "Prototype recursion
limit exceeded");
+ return;
+ }
+ }
+ if (var == NULL) {
+ var = swfdec_as_object_hash_create (object, variable);
+ if (var == NULL)
+ return;
+ }
if (var->flags & SWFDEC_AS_VARIABLE_READONLY)
return;
if (var->get) {
Benjamin Otte
2007-Aug-20 16:01 UTC
[Swfdec] 2 commits - libswfdec/swfdec_as_object.c test/trace
libswfdec/swfdec_as_object.c | 2 --
test/trace/Makefile.am | 9 +++++++++
test/trace/addProperty-flags-5.swf |binary
test/trace/addProperty-flags-5.swf.trace | 6 ++++++
test/trace/addProperty-flags-6.swf |binary
test/trace/addProperty-flags-6.swf.trace | 8 ++++++++
test/trace/addProperty-flags-7.swf |binary
test/trace/addProperty-flags-7.swf.trace | 8 ++++++++
test/trace/addProperty-flags-8.swf |binary
test/trace/addProperty-flags-8.swf.trace | 8 ++++++++
test/trace/addProperty-flags.as | 23 +++++++++++++++++++++++
11 files changed, 62 insertions(+), 2 deletions(-)
New commits:
diff-tree da9fc3e76d3757cb3a8a4459802c753adbbbcbe7 (from
589ed7ba10280a39d4ce2ce5c15863120511b600)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 20 17:59:23 2007 +0200
add test checking if flags change for addProperty calls
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 91f6c63..ba9619c 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -46,6 +46,15 @@ EXTRA_DIST = \
addProperty-delete-7.swf.trace \
addProperty-delete-8.swf \
addProperty-delete-8.swf.trace \
+ addProperty-flags.as \
+ addProperty-flags-5.swf \
+ addProperty-flags-5.swf.trace \
+ addProperty-flags-6.swf \
+ addProperty-flags-6.swf.trace \
+ addProperty-flags-7.swf \
+ addProperty-flags-7.swf.trace \
+ addProperty-flags-8.swf \
+ addProperty-flags-8.swf.trace \
addProperty-get-prototypes.as \
addProperty-get-prototypes-5.swf \
addProperty-get-prototypes-5.swf.trace \
diff --git a/test/trace/addProperty-flags-5.swf
b/test/trace/addProperty-flags-5.swf
new file mode 100644
index 0000000..c22255d
Binary files /dev/null and b/test/trace/addProperty-flags-5.swf differ
diff --git a/test/trace/addProperty-flags-5.swf.trace
b/test/trace/addProperty-flags-5.swf.trace
new file mode 100644
index 0000000..4fc2ce3
--- /dev/null
+++ b/test/trace/addProperty-flags-5.swf.trace
@@ -0,0 +1,6 @@
+Check if flags of variables get reset upon addProperty
+set:
+mark constant:
+overwrite:
+10
+10
diff --git a/test/trace/addProperty-flags-6.swf
b/test/trace/addProperty-flags-6.swf
new file mode 100644
index 0000000..74b9adf
Binary files /dev/null and b/test/trace/addProperty-flags-6.swf differ
diff --git a/test/trace/addProperty-flags-6.swf.trace
b/test/trace/addProperty-flags-6.swf.trace
new file mode 100644
index 0000000..ea545bd
--- /dev/null
+++ b/test/trace/addProperty-flags-6.swf.trace
@@ -0,0 +1,8 @@
+Check if flags of variables get reset upon addProperty
+set:
+set called
+mark constant:
+overwrite:
+10
+get
+42
diff --git a/test/trace/addProperty-flags-7.swf
b/test/trace/addProperty-flags-7.swf
new file mode 100644
index 0000000..237a007
Binary files /dev/null and b/test/trace/addProperty-flags-7.swf differ
diff --git a/test/trace/addProperty-flags-7.swf.trace
b/test/trace/addProperty-flags-7.swf.trace
new file mode 100644
index 0000000..ea545bd
--- /dev/null
+++ b/test/trace/addProperty-flags-7.swf.trace
@@ -0,0 +1,8 @@
+Check if flags of variables get reset upon addProperty
+set:
+set called
+mark constant:
+overwrite:
+10
+get
+42
diff --git a/test/trace/addProperty-flags-8.swf
b/test/trace/addProperty-flags-8.swf
new file mode 100644
index 0000000..469db26
Binary files /dev/null and b/test/trace/addProperty-flags-8.swf differ
diff --git a/test/trace/addProperty-flags-8.swf.trace
b/test/trace/addProperty-flags-8.swf.trace
new file mode 100644
index 0000000..ea545bd
--- /dev/null
+++ b/test/trace/addProperty-flags-8.swf.trace
@@ -0,0 +1,8 @@
+Check if flags of variables get reset upon addProperty
+set:
+set called
+mark constant:
+overwrite:
+10
+get
+42
diff --git a/test/trace/addProperty-flags.as b/test/trace/addProperty-flags.as
new file mode 100644
index 0000000..47049bb
--- /dev/null
+++ b/test/trace/addProperty-flags.as
@@ -0,0 +1,23 @@
+// makeswf -v 7 -s 200x150 -r 1 -o addProperty-flags.swf addProperty-flags.as
+
+trace ("Check if flags of variables get reset upon addProperty");
+
+o = {};
+o.addProperty ("foo", function () { trace ("get"); return
42; }, function () { trace ("set called"); });
+trace ("set:");
+o.foo = 20;
+trace ("mark constant:");
+ASSetPropFlags (o, "foo", 4);
+o.foo = 20;
+trace ("overwrite:");
+o.addProperty ("foo", function () { trace ("get"); return
42; }, function () { trace ("set called"); });
+o.foo = 20;
+
+o.bar = 10;
+ASSetPropFlags (o, "bar", 4);
+trace (o.bar);
+o.addProperty ("bar", function () { trace ("get"); return
42; }, function () { trace ("set called"); });
+
+trace (o.bar);
+
+loadMovie ("FSCommand:quit", "");
diff-tree 589ed7ba10280a39d4ce2ce5c15863120511b600 (from
fd36de2f156ce685d5095aaf323e0766ea017bd7)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 20 17:48:20 2007 +0200
don't mark addProperty()'d variables as constant when they have no
set function
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index 213ddb3..83ad4cf 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -1022,8 +1022,6 @@ swfdec_as_object_add_variable (SwfdecAsO
return;
var->get = get;
var->set = set;
- if (set == NULL)
- var->flags |= SWFDEC_AS_VARIABLE_CONSTANT;
}
/*** AS CODE ***/
Pekka Lampila
2007-Aug-22 10:06 UTC
[Swfdec] 2 commits - libswfdec/swfdec_as_object.c test/trace
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;
}
Benjamin Otte
2007-Sep-10 20:08 UTC
[Swfdec] 2 commits - libswfdec/swfdec_as_object.c test/trace
libswfdec/swfdec_as_object.c | 2 ++
test/trace/Makefile.am | 9 +++++++++
test/trace/object-watch-segv-5.swf |binary
test/trace/object-watch-segv-5.swf.trace | 7 +++++++
test/trace/object-watch-segv-6.swf |binary
test/trace/object-watch-segv-6.swf.trace | 9 +++++++++
test/trace/object-watch-segv-7.swf |binary
test/trace/object-watch-segv-7.swf.trace | 9 +++++++++
test/trace/object-watch-segv-8.swf |binary
test/trace/object-watch-segv-8.swf.trace | 9 +++++++++
test/trace/object-watch-segv.as | 25 +++++++++++++++++++++++++
11 files changed, 70 insertions(+)
New commits:
diff-tree 93f0e1b0eaeb04357370f7daf9ea8dbbe3786d3e (from
dc9b8d5aa159cf8b2e0c835a3038063a62a8393c)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Sep 10 22:07:56 2007 +0200
add a random Object.watch() test
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 95e7c9c..5f360cc 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -770,6 +770,15 @@ EXTRA_DIST = \
object-watch-6.swf.trace \
object-watch-7.swf \
object-watch-7.swf.trace \
+ object-watch-segv.as \
+ object-watch-segv-5.swf \
+ object-watch-segv-5.swf.trace \
+ object-watch-segv-6.swf \
+ object-watch-segv-6.swf.trace \
+ object-watch-segv-7.swf \
+ object-watch-segv-7.swf.trace \
+ object-watch-segv-8.swf \
+ object-watch-segv-8.swf.trace \
onload-childparent.c \
onload-childparent.swf \
onload-childparent.swf.trace \
diff --git a/test/trace/object-watch-segv-5.swf
b/test/trace/object-watch-segv-5.swf
new file mode 100644
index 0000000..4dc8336
Binary files /dev/null and b/test/trace/object-watch-segv-5.swf differ
diff --git a/test/trace/object-watch-segv-5.swf.trace
b/test/trace/object-watch-segv-5.swf.trace
new file mode 100644
index 0000000..1e63931
--- /dev/null
+++ b/test/trace/object-watch-segv-5.swf.trace
@@ -0,0 +1,7 @@
+undefined
+undefined
+42
+10
+undefined
+undefined
+100
diff --git a/test/trace/object-watch-segv-6.swf
b/test/trace/object-watch-segv-6.swf
new file mode 100644
index 0000000..85f3ca8
Binary files /dev/null and b/test/trace/object-watch-segv-6.swf differ
diff --git a/test/trace/object-watch-segv-6.swf.trace
b/test/trace/object-watch-segv-6.swf.trace
new file mode 100644
index 0000000..6a9ebe3
--- /dev/null
+++ b/test/trace/object-watch-segv-6.swf.trace
@@ -0,0 +1,9 @@
+true
+true
+run 2
+43
+run 2
+11
+true
+true
+5
diff --git a/test/trace/object-watch-segv-7.swf
b/test/trace/object-watch-segv-7.swf
new file mode 100644
index 0000000..6765d70
Binary files /dev/null and b/test/trace/object-watch-segv-7.swf differ
diff --git a/test/trace/object-watch-segv-7.swf.trace
b/test/trace/object-watch-segv-7.swf.trace
new file mode 100644
index 0000000..6a9ebe3
--- /dev/null
+++ b/test/trace/object-watch-segv-7.swf.trace
@@ -0,0 +1,9 @@
+true
+true
+run 2
+43
+run 2
+11
+true
+true
+5
diff --git a/test/trace/object-watch-segv-8.swf
b/test/trace/object-watch-segv-8.swf
new file mode 100644
index 0000000..c6d0bda
Binary files /dev/null and b/test/trace/object-watch-segv-8.swf differ
diff --git a/test/trace/object-watch-segv-8.swf.trace
b/test/trace/object-watch-segv-8.swf.trace
new file mode 100644
index 0000000..6a9ebe3
--- /dev/null
+++ b/test/trace/object-watch-segv-8.swf.trace
@@ -0,0 +1,9 @@
+true
+true
+run 2
+43
+run 2
+11
+true
+true
+5
diff --git a/test/trace/object-watch-segv.as b/test/trace/object-watch-segv.as
new file mode 100644
index 0000000..db06b4a
--- /dev/null
+++ b/test/trace/object-watch-segv.as
@@ -0,0 +1,25 @@
+// makeswf -v 7 -s 200x150 -r 1 -o object-watch-segv.swf object-watch-segv.as
+
+function foo (name, old, new, data) {
+ delete this[x];
+ trace ("run " + data);
+ return new + 1;
+};
+function evil () {
+ this.unwatch ("x");
+ return 5;
+};
+
+trace (this.watch ("x", foo, 1));
+trace (this.watch ("x", foo, 2));
+this.x = 42;
+trace (x);
+delete this[x];
+this.x = 10;
+trace (x);
+trace (this.hasOwnProperty ("x"));
+trace (this.watch ("x", evil));
+this.x = 100;
+trace (this.x);
+
+loadMovie ("FSCommand:quit", "");
diff-tree dc9b8d5aa159cf8b2e0c835a3038063a62a8393c (from
890b14c29384f9610b68eaf44e4fedfcc6580618)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Sep 10 22:06:50 2007 +0200
actually change the watch function when it is reset
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index a331030..5719eaf 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -1322,6 +1322,8 @@ swfdec_as_object_watch (SwfdecAsContext
if (watch == NULL)
return;
g_hash_table_insert (object->watches, (char *) name, watch);
+ } else {
+ watch->watch = SWFDEC_AS_FUNCTION (SWFDEC_AS_VALUE_GET_OBJECT
(&argv[1]));
}
if (argc >= 3) {
Maybe Matching Threads
- 2 commits - test/trace
- Changes to 'refs/tags/0.5.2'
- Branch 'vivi' - 60 commits - libswfdec-gtk/swfdec_gtk_loader.c libswfdec/Makefile.am libswfdec/swfdec_as_array.c libswfdec/swfdec_as_context.c libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_frame_internal.h libswfdec/swfdec_as_interpret.c
- 20 commits - libswfdec/Makefile.am libswfdec/swfdec_as_context.c libswfdec/swfdec_as_function.c libswfdec/swfdec_as_initialize.as libswfdec/swfdec_as_initialize.h libswfdec/swfdec_as_internal.h libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_number.c
- Changes to 'refs/tags/0.5.3'