[Swfdec] 4 commits - libswfdec/swfdec_as_object.c libswfdec/swfdec_as_object.h libswfdec/swfdec_as_super.c libswfdec/swfdec_as_with.c libswfdec/swfdec_movie.c libswfdec/swfdec_net_stream.c libswfdec/swfdec_sprite_movie.c test/trace
Benjamin Otte
company at kemper.freedesktop.org
Wed Aug 15 14:16:07 PDT 2007
libswfdec/swfdec_as_object.c | 21 +++++++++++----------
libswfdec/swfdec_as_object.h | 1 +
libswfdec/swfdec_as_super.c | 4 ++--
libswfdec/swfdec_as_with.c | 7 +++++--
libswfdec/swfdec_movie.c | 6 +++---
libswfdec/swfdec_net_stream.c | 6 +++---
libswfdec/swfdec_sprite_movie.c | 6 +++---
test/trace/Makefile.am | 18 ++++++++++++++++++
test/trace/addProperty-delete-5.swf |binary
test/trace/addProperty-delete-5.swf.trace | 3 +++
test/trace/addProperty-delete-6.swf |binary
test/trace/addProperty-delete-6.swf.trace | 3 +++
test/trace/addProperty-delete-7.swf |binary
test/trace/addProperty-delete-7.swf.trace | 3 +++
test/trace/addProperty-delete-8.swf |binary
test/trace/addProperty-delete-8.swf.trace | 3 +++
test/trace/addProperty-delete.as | 11 +++++++++++
test/trace/addProperty-get-prototypes-5.swf |binary
test/trace/addProperty-get-prototypes-5.swf.trace | 6 ++++++
test/trace/addProperty-get-prototypes-6.swf |binary
test/trace/addProperty-get-prototypes-6.swf.trace | 9 +++++++++
test/trace/addProperty-get-prototypes-7.swf |binary
test/trace/addProperty-get-prototypes-7.swf.trace | 9 +++++++++
test/trace/addProperty-get-prototypes-8.swf |binary
test/trace/addProperty-get-prototypes-8.swf.trace | 9 +++++++++
test/trace/addProperty-get-prototypes.as | 18 ++++++++++++++++++
26 files changed, 120 insertions(+), 23 deletions(-)
New commits:
diff-tree bf81efebf34c71944530945a70c24532de6ea111 (from 565cb315b34355849f0de3c656b3d9497b1164d2)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 23:14:01 2007 +0200
add test for deleting addProperty()'d properties
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 6ec5d28..45b56a8 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-delete.as \
+ addProperty-delete-5.swf \
+ addProperty-delete-5.swf.trace \
+ addProperty-delete-6.swf \
+ addProperty-delete-6.swf.trace \
+ addProperty-delete-7.swf \
+ addProperty-delete-7.swf.trace \
+ addProperty-delete-8.swf \
+ addProperty-delete-8.swf.trace \
addProperty-get-prototypes.as \
addProperty-get-prototypes-5.swf \
addProperty-get-prototypes-5.swf.trace \
diff --git a/test/trace/addProperty-delete-5.swf b/test/trace/addProperty-delete-5.swf
new file mode 100644
index 0000000..e10fec5
Binary files /dev/null and b/test/trace/addProperty-delete-5.swf differ
diff --git a/test/trace/addProperty-delete-5.swf.trace b/test/trace/addProperty-delete-5.swf.trace
new file mode 100644
index 0000000..2796bd0
--- /dev/null
+++ b/test/trace/addProperty-delete-5.swf.trace
@@ -0,0 +1,3 @@
+check if deleting a property added with addProperty works
+undefined
+undefined
diff --git a/test/trace/addProperty-delete-6.swf b/test/trace/addProperty-delete-6.swf
new file mode 100644
index 0000000..86571b2
Binary files /dev/null and b/test/trace/addProperty-delete-6.swf differ
diff --git a/test/trace/addProperty-delete-6.swf.trace b/test/trace/addProperty-delete-6.swf.trace
new file mode 100644
index 0000000..ec5834a
--- /dev/null
+++ b/test/trace/addProperty-delete-6.swf.trace
@@ -0,0 +1,3 @@
+check if deleting a property added with addProperty works
+42
+undefined
diff --git a/test/trace/addProperty-delete-7.swf b/test/trace/addProperty-delete-7.swf
new file mode 100644
index 0000000..ef3db72
Binary files /dev/null and b/test/trace/addProperty-delete-7.swf differ
diff --git a/test/trace/addProperty-delete-7.swf.trace b/test/trace/addProperty-delete-7.swf.trace
new file mode 100644
index 0000000..ec5834a
--- /dev/null
+++ b/test/trace/addProperty-delete-7.swf.trace
@@ -0,0 +1,3 @@
+check if deleting a property added with addProperty works
+42
+undefined
diff --git a/test/trace/addProperty-delete-8.swf b/test/trace/addProperty-delete-8.swf
new file mode 100644
index 0000000..cdf6511
Binary files /dev/null and b/test/trace/addProperty-delete-8.swf differ
diff --git a/test/trace/addProperty-delete-8.swf.trace b/test/trace/addProperty-delete-8.swf.trace
new file mode 100644
index 0000000..ec5834a
--- /dev/null
+++ b/test/trace/addProperty-delete-8.swf.trace
@@ -0,0 +1,3 @@
+check if deleting a property added with addProperty works
+42
+undefined
diff --git a/test/trace/addProperty-delete.as b/test/trace/addProperty-delete.as
new file mode 100644
index 0000000..2c8076b
--- /dev/null
+++ b/test/trace/addProperty-delete.as
@@ -0,0 +1,11 @@
+// makeswf -v 7 -s 200x150 -r 1 -o addProperty-delete.swf addProperty-delete.as
+
+trace ("check if deleting a property added with addProperty works");
+
+o = {};
+o.addProperty ("x", function () { return 42; }, null);
+trace (o.x);
+delete o.x;
+trace (o.x);
+
+loadMovie ("FSCommand:quit", "");
diff-tree 565cb315b34355849f0de3c656b3d9497b1164d2 (from b9d80cd0852b204c03e5828bfb4210e3ed98a2a4)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 23:11:31 2007 +0200
porperties added with addProperty aren't permanent.
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index 8999597..b5dcd25 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -991,7 +991,7 @@ swfdec_as_object_add_variable (SwfdecAsO
return;
var->get = get;
var->set = set;
- var->flags = SWFDEC_AS_VARIABLE_PERMANENT;
+ var->flags = 0;
if (set == NULL)
var->flags |= SWFDEC_AS_VARIABLE_READONLY;
}
diff-tree b9d80cd0852b204c03e5828bfb4210e3ed98a2a4 (from c94ea432d4a4a30c76cd89d701d8cb9395347647)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 23:09:59 2007 +0200
fix getting of properties added with addProperty
We need access to the original object, so we can call the getter function
with that object.
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index b1d06e5..8999597 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -172,8 +172,8 @@ swfdec_as_object_hash_create (SwfdecAsOb
}
static gboolean
-swfdec_as_object_do_get (SwfdecAsObject *object, const char *variable,
- SwfdecAsValue *val, guint *flags)
+swfdec_as_object_do_get (SwfdecAsObject *object, SwfdecAsObject *orig,
+ const char *variable, SwfdecAsValue *val, guint *flags)
{
SwfdecAsVariable *var = swfdec_as_object_hash_lookup (object, variable);
@@ -184,7 +184,7 @@ swfdec_as_object_do_get (SwfdecAsObject
return FALSE;
if (var->get) {
- swfdec_as_function_call (var->get, object, 0, NULL, val);
+ swfdec_as_function_call (var->get, orig, 0, NULL, val);
swfdec_as_context_run (object->context);
*flags = var->flags;
} else {
@@ -602,7 +602,7 @@ swfdec_as_object_get_variable_and_flags
guint i;
SwfdecAsValue tmp_val;
guint tmp_flags;
- SwfdecAsObject *tmp_pobject;
+ SwfdecAsObject *tmp_pobject, *cur;
g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
g_return_val_if_fail (variable != NULL, FALSE);
@@ -614,13 +614,14 @@ swfdec_as_object_get_variable_and_flags
if (pobject == NULL)
pobject = &tmp_pobject;
- for (i = 0; i < 256 && object != NULL; i++) {
- klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
- if (klass->get (object, variable, value, flags)) {
- *pobject = object;
+ cur = object;
+ for (i = 0; i < 256 && cur != NULL; i++) {
+ klass = SWFDEC_AS_OBJECT_GET_CLASS (cur);
+ if (klass->get (cur, object, variable, value, flags)) {
+ *pobject = cur;
return TRUE;
}
- object = object->prototype;
+ cur = cur->prototype;
}
if (i == 256) {
swfdec_as_context_abort (object->context, "Prototype recursion limit exceeded");
diff --git a/libswfdec/swfdec_as_object.h b/libswfdec/swfdec_as_object.h
index f82cd9c..265c6cb 100644
--- a/libswfdec/swfdec_as_object.h
+++ b/libswfdec/swfdec_as_object.h
@@ -65,6 +65,7 @@ struct _SwfdecAsObjectClass {
void (* add) (SwfdecAsObject * object);
/* get the value and flags for a variables */
gboolean (* get) (SwfdecAsObject * object,
+ SwfdecAsObject * orig,
const char * variable,
SwfdecAsValue * val,
guint * flags);
diff --git a/libswfdec/swfdec_as_super.c b/libswfdec/swfdec_as_super.c
index 5447bcd..653c30a 100644
--- a/libswfdec/swfdec_as_super.c
+++ b/libswfdec/swfdec_as_super.c
@@ -68,8 +68,8 @@ swfdec_as_super_call (SwfdecAsFunction *
}
static gboolean
-swfdec_as_super_get (SwfdecAsObject *object, const char *variable,
- SwfdecAsValue *val, guint *flags)
+swfdec_as_super_get (SwfdecAsObject *object, SwfdecAsObject *orig,
+ const char *variable, SwfdecAsValue *val, guint *flags)
{
SwfdecAsSuper *super = SWFDEC_AS_SUPER (object);
diff --git a/libswfdec/swfdec_as_with.c b/libswfdec/swfdec_as_with.c
index a000ca3..62af9b8 100644
--- a/libswfdec/swfdec_as_with.c
+++ b/libswfdec/swfdec_as_with.c
@@ -47,11 +47,14 @@ swfdec_as_with_resolve (SwfdecAsObject *
}
static gboolean
-swfdec_as_with_get (SwfdecAsObject *object, const char *variable,
- SwfdecAsValue *val, guint *flags)
+swfdec_as_with_get (SwfdecAsObject *object, SwfdecAsObject *orig,
+ const char *variable, SwfdecAsValue *val, guint *flags)
{
SwfdecAsWith *with = SWFDEC_AS_WITH (object);
+ if (orig != object) {
+ SWFDEC_FIXME ("write tests for this case");
+ }
return swfdec_as_object_get_variable_and_flags (with->object, variable, val, flags, NULL);
}
diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 776e2b1..3bac79f 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -841,15 +841,15 @@ swfdec_movie_get_by_name (SwfdecPlayer *
}
static gboolean
-swfdec_movie_get_variable (SwfdecAsObject *object, const char *variable,
- SwfdecAsValue *val, guint *flags)
+swfdec_movie_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig,
+ const char *variable, SwfdecAsValue *val, guint *flags)
{
SwfdecMovie *movie = SWFDEC_MOVIE (object);
if (movie->state == SWFDEC_MOVIE_STATE_DESTROYED)
return FALSE;
- if (SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->get (object, variable, val, flags))
+ if (SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->get (object, orig, variable, val, flags))
return TRUE;
if (swfdec_movie_get_asprop (movie, variable, val)) {
diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c
index b95f7a4..fac0886 100644
--- a/libswfdec/swfdec_net_stream.c
+++ b/libswfdec/swfdec_net_stream.c
@@ -350,12 +350,12 @@ swfdec_net_stream_dispose (GObject *obje
}
static gboolean
-swfdec_net_stream_get_variable (SwfdecAsObject *object, const char *variable,
- SwfdecAsValue *val, guint *flags)
+swfdec_net_stream_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig,
+ const char *variable, SwfdecAsValue *val, guint *flags)
{
SwfdecNetStream *stream;
- if (SWFDEC_AS_OBJECT_CLASS (swfdec_net_stream_parent_class)->get (object, variable, val, flags))
+ if (SWFDEC_AS_OBJECT_CLASS (swfdec_net_stream_parent_class)->get (object, orig, variable, val, flags))
return TRUE;
stream = SWFDEC_NET_STREAM (object);
diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
index 488864c..4f9067d 100644
--- a/libswfdec/swfdec_sprite_movie.c
+++ b/libswfdec/swfdec_sprite_movie.c
@@ -622,12 +622,12 @@ swfdec_sprite_movie_get_by_name (SwfdecM
}
static gboolean
-swfdec_sprite_movie_get_variable (SwfdecAsObject *object, const char *variable,
- SwfdecAsValue *val, guint *flags)
+swfdec_sprite_movie_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig,
+ const char *variable, SwfdecAsValue *val, guint *flags)
{
SwfdecMovie *movie;
- if (SWFDEC_AS_OBJECT_CLASS (swfdec_sprite_movie_parent_class)->get (object, variable, val, flags))
+ if (SWFDEC_AS_OBJECT_CLASS (swfdec_sprite_movie_parent_class)->get (object, orig, variable, val, flags))
return TRUE;
movie = swfdec_sprite_movie_get_by_name (SWFDEC_MOVIE (object), variable);
diff-tree c94ea432d4a4a30c76cd89d701d8cb9395347647 (from 01e8d90362605acf52d171de350853bd773e7edb)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 23:09:10 2007 +0200
add test case for next commit
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 591144a..6ec5d28 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-get-prototypes.as \
+ addProperty-get-prototypes-5.swf \
+ addProperty-get-prototypes-5.swf.trace \
+ addProperty-get-prototypes-6.swf \
+ addProperty-get-prototypes-6.swf.trace \
+ addProperty-get-prototypes-7.swf \
+ addProperty-get-prototypes-7.swf.trace \
+ addProperty-get-prototypes-8.swf \
+ addProperty-get-prototypes-8.swf.trace \
addProperty-set-prototypes.as \
addProperty-set-prototypes-5.swf \
addProperty-set-prototypes-5.swf.trace \
diff --git a/test/trace/addProperty-get-prototypes-5.swf b/test/trace/addProperty-get-prototypes-5.swf
new file mode 100644
index 0000000..171fd19
Binary files /dev/null and b/test/trace/addProperty-get-prototypes-5.swf differ
diff --git a/test/trace/addProperty-get-prototypes-5.swf.trace b/test/trace/addProperty-get-prototypes-5.swf.trace
new file mode 100644
index 0000000..f9ebb80
--- /dev/null
+++ b/test/trace/addProperty-get-prototypes-5.swf.trace
@@ -0,0 +1,6 @@
+Check getting of variables when addProperty has been used on prototypes.
+10
+10
+15
+undefined
+20
diff --git a/test/trace/addProperty-get-prototypes-6.swf b/test/trace/addProperty-get-prototypes-6.swf
new file mode 100644
index 0000000..9207fd8
Binary files /dev/null and b/test/trace/addProperty-get-prototypes-6.swf differ
diff --git a/test/trace/addProperty-get-prototypes-6.swf.trace b/test/trace/addProperty-get-prototypes-6.swf.trace
new file mode 100644
index 0000000..1082851
--- /dev/null
+++ b/test/trace/addProperty-get-prototypes-6.swf.trace
@@ -0,0 +1,9 @@
+Check getting of variables when addProperty has been used on prototypes.
+10
+10
+15
+o
+42
+o set
+o
+42
diff --git a/test/trace/addProperty-get-prototypes-7.swf b/test/trace/addProperty-get-prototypes-7.swf
new file mode 100644
index 0000000..cd76446
Binary files /dev/null and b/test/trace/addProperty-get-prototypes-7.swf differ
diff --git a/test/trace/addProperty-get-prototypes-7.swf.trace b/test/trace/addProperty-get-prototypes-7.swf.trace
new file mode 100644
index 0000000..1082851
--- /dev/null
+++ b/test/trace/addProperty-get-prototypes-7.swf.trace
@@ -0,0 +1,9 @@
+Check getting of variables when addProperty has been used on prototypes.
+10
+10
+15
+o
+42
+o set
+o
+42
diff --git a/test/trace/addProperty-get-prototypes-8.swf b/test/trace/addProperty-get-prototypes-8.swf
new file mode 100644
index 0000000..c2b4add
Binary files /dev/null and b/test/trace/addProperty-get-prototypes-8.swf differ
diff --git a/test/trace/addProperty-get-prototypes-8.swf.trace b/test/trace/addProperty-get-prototypes-8.swf.trace
new file mode 100644
index 0000000..1082851
--- /dev/null
+++ b/test/trace/addProperty-get-prototypes-8.swf.trace
@@ -0,0 +1,9 @@
+Check getting of variables when addProperty has been used on prototypes.
+10
+10
+15
+o
+42
+o set
+o
+42
diff --git a/test/trace/addProperty-get-prototypes.as b/test/trace/addProperty-get-prototypes.as
new file mode 100644
index 0000000..e617cc2
--- /dev/null
+++ b/test/trace/addProperty-get-prototypes.as
@@ -0,0 +1,18 @@
+// makeswf -v 7 -s 200x150 -r 1 -o addProperty-get-prototypes.swf addProperty-get-prototypes.as
+
+trace ("Check getting of variables when addProperty has been used on prototypes.");
+
+o = {name: "o"};
+o.__proto__ = {name: "proto"};
+o.x = 10;
+trace (o.x);
+o.__proto__.addProperty ("x", function () { trace (this.name); return 42; }, function () { trace (this.name + " set"); });
+trace (o.x);
+o.x = 15;
+trace (o.x);
+delete o.x;
+trace (o.x);
+o.x = 20;
+trace (o.x);
+
+loadMovie ("FSCommand:quit", "");
More information about the Swfdec
mailing list