[Swfdec] 2 commits - libswfdec/swfdec_as_object.c test/trace
Benjamin Otte
company at kemper.freedesktop.org
Wed Aug 15 13:09:25 PDT 2007
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) {
More information about the Swfdec
mailing list