[Swfdec] 11 commits - libswfdec/swfdec_asbroadcaster.c libswfdec/swfdec_as_strings.c libswfdec/swfdec_initialize.as libswfdec/swfdec_initialize.h libswfdec/swfdec_net_stream.c libswfdec/swfdec_player.c libswfdec/swfdec_sprite_movie_as.c test/trace
Benjamin Otte
company at kemper.freedesktop.org
Fri Jul 27 10:11:51 PDT 2007
libswfdec/swfdec_as_strings.c | 7 +
libswfdec/swfdec_asbroadcaster.c | 10 +
libswfdec/swfdec_initialize.as | 1
libswfdec/swfdec_initialize.h | 8 -
libswfdec/swfdec_net_stream.c | 10 +
libswfdec/swfdec_player.c | 77 +++++------
libswfdec/swfdec_sprite_movie_as.c | 35 +++++
test/trace/Makefile.am | 45 ++++++
test/trace/asbroadcaster-broadcastMessage-retval-5.swf |binary
test/trace/asbroadcaster-broadcastMessage-retval-5.swf.trace | 7 +
test/trace/asbroadcaster-broadcastMessage-retval-6.swf |binary
test/trace/asbroadcaster-broadcastMessage-retval-6.swf.trace | 7 +
test/trace/asbroadcaster-broadcastMessage-retval-7.swf |binary
test/trace/asbroadcaster-broadcastMessage-retval-7.swf.trace | 7 +
test/trace/asbroadcaster-broadcastMessage-retval-8.swf |binary
test/trace/asbroadcaster-broadcastMessage-retval-8.swf.trace | 7 +
test/trace/asbroadcaster-broadcastMessage-retval.as | 19 ++
test/trace/asbroadcaster-listeners-5.swf |binary
test/trace/asbroadcaster-listeners-5.swf.trace | 3
test/trace/asbroadcaster-listeners-6.swf |binary
test/trace/asbroadcaster-listeners-6.swf.trace | 3
test/trace/asbroadcaster-listeners-7.swf |binary
test/trace/asbroadcaster-listeners-7.swf.trace | 3
test/trace/asbroadcaster-listeners-8.swf |binary
test/trace/asbroadcaster-listeners-8.swf.trace | 3
test/trace/asbroadcaster-listeners.as | 16 ++
test/trace/asbroadcaster-override-5.swf |binary
test/trace/asbroadcaster-override-5.swf.trace | 5
test/trace/asbroadcaster-override-6.swf |binary
test/trace/asbroadcaster-override-6.swf.trace | 9 +
test/trace/asbroadcaster-override-7.swf |binary
test/trace/asbroadcaster-override-7.swf.trace | 9 +
test/trace/asbroadcaster-override-8.swf |binary
test/trace/asbroadcaster-override-8.swf.trace | 9 +
test/trace/asbroadcaster-override.as | 31 ++++
test/trace/asnative-create-5.swf |binary
test/trace/asnative-create-5.swf.trace | 7 +
test/trace/asnative-create-6.swf |binary
test/trace/asnative-create-6.swf.trace | 7 +
test/trace/asnative-create-7.swf |binary
test/trace/asnative-create-7.swf.trace | 7 +
test/trace/asnative-create-8.swf |binary
test/trace/asnative-create-8.swf.trace | 7 +
test/trace/asnative-create.as | 15 ++
test/trace/onresize-5.swf |binary
test/trace/onresize-5.swf.trace | 1
test/trace/onresize-6.swf |binary
test/trace/onresize-6.swf.trace | 1
test/trace/onresize-7.swf |binary
test/trace/onresize-7.swf.trace | 1
test/trace/onresize-8.swf |binary
test/trace/onresize-8.swf.trace | 1
test/trace/onresize.as | 20 ++
53 files changed, 348 insertions(+), 50 deletions(-)
New commits:
diff-tree b3ab4943fa2579832e3cf9e346caab16feab4b46 (from adcd9b97486a5983702b8938a0b961ac9146b2f4)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Jul 27 18:24:17 2007 +0200
only goto on the video if there is a video
diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c
index 7af040c..2f993c3 100644
--- a/libswfdec/swfdec_net_stream.c
+++ b/libswfdec/swfdec_net_stream.c
@@ -63,15 +63,19 @@ swfdec_net_stream_video_goto (SwfdecNetS
SWFDEC_LOG ("goto %ums", timestamp);
process_events = timestamp == stream->next_time;
process_events_from = MIN (stream->next_time, stream->current_time + 1);
- buffer = swfdec_flv_decoder_get_video (stream->flvdecoder, timestamp,
- FALSE, &format, &stream->current_time, &stream->next_time);
old = stream->surface;
if (stream->surface) {
cairo_surface_destroy (stream->surface);
stream->surface = NULL;
}
+ if (stream->flvdecoder->video) {
+ buffer = swfdec_flv_decoder_get_video (stream->flvdecoder, timestamp,
+ FALSE, &format, &stream->current_time, &stream->next_time);
+ } else {
+ buffer = NULL;
+ }
if (buffer == NULL) {
- SWFDEC_ERROR ("got no buffer?!");
+ SWFDEC_ERROR ("got no buffer - no video available?");
} else {
if (format != stream->format) {
if (stream->decoder)
diff-tree adcd9b97486a5983702b8938a0b961ac9146b2f4 (from 00f6b6ce1b01dd2f2eb2a0c1532c2b8f83741a36)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Jul 27 13:11:06 2007 +0200
add test for when broadcaster._listeners is not an array
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 2fefd62..7e5e2c4 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -77,6 +77,15 @@ EXTRA_DIST = \
asbroadcaster-broadcastMessage-retval-7.swf.trace \
asbroadcaster-broadcastMessage-retval-8.swf \
asbroadcaster-broadcastMessage-retval-8.swf.trace \
+ asbroadcaster-listeners.as \
+ asbroadcaster-listeners-5.swf \
+ asbroadcaster-listeners-5.swf.trace \
+ asbroadcaster-listeners-6.swf \
+ asbroadcaster-listeners-6.swf.trace \
+ asbroadcaster-listeners-7.swf \
+ asbroadcaster-listeners-7.swf.trace \
+ asbroadcaster-listeners-8.swf \
+ asbroadcaster-listeners-8.swf.trace \
asbroadcaster-override.as \
asbroadcaster-override-5.swf \
asbroadcaster-override-5.swf.trace \
diff --git a/test/trace/asbroadcaster-listeners-5.swf b/test/trace/asbroadcaster-listeners-5.swf
new file mode 100644
index 0000000..c9b0911
Binary files /dev/null and b/test/trace/asbroadcaster-listeners-5.swf differ
diff --git a/test/trace/asbroadcaster-listeners-5.swf.trace b/test/trace/asbroadcaster-listeners-5.swf.trace
new file mode 100644
index 0000000..71a845e
--- /dev/null
+++ b/test/trace/asbroadcaster-listeners-5.swf.trace
@@ -0,0 +1,3 @@
+Check what happens if _listeners is not an array
+[object Object]
+undefined
diff --git a/test/trace/asbroadcaster-listeners-6.swf b/test/trace/asbroadcaster-listeners-6.swf
new file mode 100644
index 0000000..e263532
Binary files /dev/null and b/test/trace/asbroadcaster-listeners-6.swf differ
diff --git a/test/trace/asbroadcaster-listeners-6.swf.trace b/test/trace/asbroadcaster-listeners-6.swf.trace
new file mode 100644
index 0000000..71a845e
--- /dev/null
+++ b/test/trace/asbroadcaster-listeners-6.swf.trace
@@ -0,0 +1,3 @@
+Check what happens if _listeners is not an array
+[object Object]
+undefined
diff --git a/test/trace/asbroadcaster-listeners-7.swf b/test/trace/asbroadcaster-listeners-7.swf
new file mode 100644
index 0000000..9962deb
Binary files /dev/null and b/test/trace/asbroadcaster-listeners-7.swf differ
diff --git a/test/trace/asbroadcaster-listeners-7.swf.trace b/test/trace/asbroadcaster-listeners-7.swf.trace
new file mode 100644
index 0000000..71a845e
--- /dev/null
+++ b/test/trace/asbroadcaster-listeners-7.swf.trace
@@ -0,0 +1,3 @@
+Check what happens if _listeners is not an array
+[object Object]
+undefined
diff --git a/test/trace/asbroadcaster-listeners-8.swf b/test/trace/asbroadcaster-listeners-8.swf
new file mode 100644
index 0000000..bb6859d
Binary files /dev/null and b/test/trace/asbroadcaster-listeners-8.swf differ
diff --git a/test/trace/asbroadcaster-listeners-8.swf.trace b/test/trace/asbroadcaster-listeners-8.swf.trace
new file mode 100644
index 0000000..71a845e
--- /dev/null
+++ b/test/trace/asbroadcaster-listeners-8.swf.trace
@@ -0,0 +1,3 @@
+Check what happens if _listeners is not an array
+[object Object]
+undefined
diff --git a/test/trace/asbroadcaster-listeners.as b/test/trace/asbroadcaster-listeners.as
new file mode 100644
index 0000000..0f99c6f
--- /dev/null
+++ b/test/trace/asbroadcaster-listeners.as
@@ -0,0 +1,16 @@
+// makeswf -v 7 -s 200x150 -r 1 -o asbroadcaster-listeners.swf asbroadcaster-listeners.as
+
+trace ("Check what happens if _listeners is not an array");
+
+emitter = new Object ();
+AsBroadcaster.initialize (emitter);
+o1 = new Object ();
+o1.foo = function () {
+ trace ("o1");
+};
+emitter._listeners = new Object ();
+emitter._listeners[10] = o1;
+trace (emitter._listeners[10]);
+trace (emitter.broadcastMessage ("foo"));
+
+loadMovie ("FSCommand:quit", "");
diff-tree 00f6b6ce1b01dd2f2eb2a0c1532c2b8f83741a36 (from e617568c097b604b54d0137431ee92ed0d427a0e)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Jul 27 13:06:24 2007 +0200
add a test for return values of AsBroadcaster
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 16035e3..2fefd62 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -68,6 +68,15 @@ EXTRA_DIST = \
array2-7.swf.trace \
array2-8.swf \
array2-8.swf.trace \
+ asbroadcaster-broadcastMessage-retval.as \
+ asbroadcaster-broadcastMessage-retval-5.swf \
+ asbroadcaster-broadcastMessage-retval-5.swf.trace \
+ asbroadcaster-broadcastMessage-retval-6.swf \
+ asbroadcaster-broadcastMessage-retval-6.swf.trace \
+ asbroadcaster-broadcastMessage-retval-7.swf \
+ asbroadcaster-broadcastMessage-retval-7.swf.trace \
+ asbroadcaster-broadcastMessage-retval-8.swf \
+ asbroadcaster-broadcastMessage-retval-8.swf.trace \
asbroadcaster-override.as \
asbroadcaster-override-5.swf \
asbroadcaster-override-5.swf.trace \
diff --git a/test/trace/asbroadcaster-broadcastMessage-retval-5.swf b/test/trace/asbroadcaster-broadcastMessage-retval-5.swf
new file mode 100644
index 0000000..2538c94
Binary files /dev/null and b/test/trace/asbroadcaster-broadcastMessage-retval-5.swf differ
diff --git a/test/trace/asbroadcaster-broadcastMessage-retval-5.swf.trace b/test/trace/asbroadcaster-broadcastMessage-retval-5.swf.trace
new file mode 100644
index 0000000..458241c
--- /dev/null
+++ b/test/trace/asbroadcaster-broadcastMessage-retval-5.swf.trace
@@ -0,0 +1,7 @@
+check return value of broadcastMessage
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
diff --git a/test/trace/asbroadcaster-broadcastMessage-retval-6.swf b/test/trace/asbroadcaster-broadcastMessage-retval-6.swf
new file mode 100644
index 0000000..83b0e6c
Binary files /dev/null and b/test/trace/asbroadcaster-broadcastMessage-retval-6.swf differ
diff --git a/test/trace/asbroadcaster-broadcastMessage-retval-6.swf.trace b/test/trace/asbroadcaster-broadcastMessage-retval-6.swf.trace
new file mode 100644
index 0000000..f61d1b4
--- /dev/null
+++ b/test/trace/asbroadcaster-broadcastMessage-retval-6.swf.trace
@@ -0,0 +1,7 @@
+check return value of broadcastMessage
+undefined
+true
+undefined
+undefined
+undefined
+undefined
diff --git a/test/trace/asbroadcaster-broadcastMessage-retval-7.swf b/test/trace/asbroadcaster-broadcastMessage-retval-7.swf
new file mode 100644
index 0000000..8605b63
Binary files /dev/null and b/test/trace/asbroadcaster-broadcastMessage-retval-7.swf differ
diff --git a/test/trace/asbroadcaster-broadcastMessage-retval-7.swf.trace b/test/trace/asbroadcaster-broadcastMessage-retval-7.swf.trace
new file mode 100644
index 0000000..f61d1b4
--- /dev/null
+++ b/test/trace/asbroadcaster-broadcastMessage-retval-7.swf.trace
@@ -0,0 +1,7 @@
+check return value of broadcastMessage
+undefined
+true
+undefined
+undefined
+undefined
+undefined
diff --git a/test/trace/asbroadcaster-broadcastMessage-retval-8.swf b/test/trace/asbroadcaster-broadcastMessage-retval-8.swf
new file mode 100644
index 0000000..893ecad
Binary files /dev/null and b/test/trace/asbroadcaster-broadcastMessage-retval-8.swf differ
diff --git a/test/trace/asbroadcaster-broadcastMessage-retval-8.swf.trace b/test/trace/asbroadcaster-broadcastMessage-retval-8.swf.trace
new file mode 100644
index 0000000..f61d1b4
--- /dev/null
+++ b/test/trace/asbroadcaster-broadcastMessage-retval-8.swf.trace
@@ -0,0 +1,7 @@
+check return value of broadcastMessage
+undefined
+true
+undefined
+undefined
+undefined
+undefined
diff --git a/test/trace/asbroadcaster-broadcastMessage-retval.as b/test/trace/asbroadcaster-broadcastMessage-retval.as
new file mode 100644
index 0000000..d5fb899
--- /dev/null
+++ b/test/trace/asbroadcaster-broadcastMessage-retval.as
@@ -0,0 +1,19 @@
+// makeswf -v 7 -s 200x150 -r 1 -o asbroadcaster-broadcastMessage-retval.swf asbroadcaster-broadcastMessage-retval.as
+
+trace ("check return value of broadcastMessage");
+
+emitter = new Object ();
+AsBroadcaster.initialize (emitter);
+trace (emitter.broadcastMessage ("foo"));
+emitter._listeners[0] = "hi";
+trace (emitter.broadcastMessage ("foo"));
+emitter._listeners.length = 0;
+trace (emitter.broadcastMessage ("foo"));
+emitter._listeners.length = -1;
+trace (emitter.broadcastMessage ("foo"));
+emitter._listeners.length = 1;
+trace (emitter.broadcastMessage ("foo"));
+emitter._listeners[1] = null;
+trace (emitter.broadcastMessage ("foo"));
+
+loadMovie ("FSCommand:quit", "");
diff-tree e617568c097b604b54d0137431ee92ed0d427a0e (from d027fca4a18863373b5f1b8332fb29dbe5918a24)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Jul 27 13:03:45 2007 +0200
rewrite broadcastMessage so it produces the correct return value
diff --git a/libswfdec/swfdec_asbroadcaster.c b/libswfdec/swfdec_asbroadcaster.c
index 7d1d9dc..1e69533 100644
--- a/libswfdec/swfdec_asbroadcaster.c
+++ b/libswfdec/swfdec_asbroadcaster.c
@@ -35,7 +35,7 @@ broadcastMessage (SwfdecAsContext *cx, S
guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SwfdecAsValue val;
- SwfdecAsObject *listeners;
+ SwfdecAsObject *listeners, *o;
gint i, length;
const char *name;
GSList *list = NULL, *walk;
@@ -61,9 +61,13 @@ broadcastMessage (SwfdecAsContext *cx, S
/* FIXME: solve this wth foreach, so it gets faster for weird cases */
for (i = 0; i < length; i++) {
swfdec_as_object_get_variable (listeners, swfdec_as_double_to_string (cx, i), &val);
- if (SWFDEC_AS_VALUE_IS_OBJECT (&val))
- list = g_slist_prepend (list, SWFDEC_AS_VALUE_GET_OBJECT (&val));
+ o = swfdec_as_value_to_object (cx, &val);
+ if (o == NULL)
+ continue;
+ list = g_slist_prepend (list, o);
}
+ if (list == NULL)
+ return;
list = g_slist_reverse (list);
for (walk = list; walk; walk = walk->next) {
swfdec_as_object_call (walk->data, name, argc, argv, &val);
diff-tree d027fca4a18863373b5f1b8332fb29dbe5918a24 (from 842140435a75459c869f9b432085db9be9963410)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Jul 27 12:55:05 2007 +0200
add a test for overriding AsBroadcaster methods
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index c86810b..16035e3 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -68,6 +68,15 @@ EXTRA_DIST = \
array2-7.swf.trace \
array2-8.swf \
array2-8.swf.trace \
+ asbroadcaster-override.as \
+ asbroadcaster-override-5.swf \
+ asbroadcaster-override-5.swf.trace \
+ asbroadcaster-override-6.swf \
+ asbroadcaster-override-6.swf.trace \
+ asbroadcaster-override-7.swf \
+ asbroadcaster-override-7.swf.trace \
+ asbroadcaster-override-8.swf \
+ asbroadcaster-override-8.swf.trace \
asnative-create.as \
asnative-create-5.swf \
asnative-create-5.swf.trace \
diff --git a/test/trace/asbroadcaster-override-5.swf b/test/trace/asbroadcaster-override-5.swf
new file mode 100644
index 0000000..8d7c104
Binary files /dev/null and b/test/trace/asbroadcaster-override-5.swf differ
diff --git a/test/trace/asbroadcaster-override-5.swf.trace b/test/trace/asbroadcaster-override-5.swf.trace
new file mode 100644
index 0000000..1e661a4
--- /dev/null
+++ b/test/trace/asbroadcaster-override-5.swf.trace
@@ -0,0 +1,5 @@
+override AsBroadcaster methods
+undefined
+undefined
+undefined
+undefined
diff --git a/test/trace/asbroadcaster-override-6.swf b/test/trace/asbroadcaster-override-6.swf
new file mode 100644
index 0000000..1fb94d1
Binary files /dev/null and b/test/trace/asbroadcaster-override-6.swf differ
diff --git a/test/trace/asbroadcaster-override-6.swf.trace b/test/trace/asbroadcaster-override-6.swf.trace
new file mode 100644
index 0000000..a1a0daa
--- /dev/null
+++ b/test/trace/asbroadcaster-override-6.swf.trace
@@ -0,0 +1,9 @@
+override AsBroadcaster methods
+add
+true
+remove
+[type Function]
+22
+add
+undefined
+remove
diff --git a/test/trace/asbroadcaster-override-7.swf b/test/trace/asbroadcaster-override-7.swf
new file mode 100644
index 0000000..ff5bdee
Binary files /dev/null and b/test/trace/asbroadcaster-override-7.swf differ
diff --git a/test/trace/asbroadcaster-override-7.swf.trace b/test/trace/asbroadcaster-override-7.swf.trace
new file mode 100644
index 0000000..a1a0daa
--- /dev/null
+++ b/test/trace/asbroadcaster-override-7.swf.trace
@@ -0,0 +1,9 @@
+override AsBroadcaster methods
+add
+true
+remove
+[type Function]
+22
+add
+undefined
+remove
diff --git a/test/trace/asbroadcaster-override-8.swf b/test/trace/asbroadcaster-override-8.swf
new file mode 100644
index 0000000..23fb2eb
Binary files /dev/null and b/test/trace/asbroadcaster-override-8.swf differ
diff --git a/test/trace/asbroadcaster-override-8.swf.trace b/test/trace/asbroadcaster-override-8.swf.trace
new file mode 100644
index 0000000..a1a0daa
--- /dev/null
+++ b/test/trace/asbroadcaster-override-8.swf.trace
@@ -0,0 +1,9 @@
+override AsBroadcaster methods
+add
+true
+remove
+[type Function]
+22
+add
+undefined
+remove
diff --git a/test/trace/asbroadcaster-override.as b/test/trace/asbroadcaster-override.as
new file mode 100644
index 0000000..d406420
--- /dev/null
+++ b/test/trace/asbroadcaster-override.as
@@ -0,0 +1,31 @@
+// makeswf -v 7 -s 200x150 -r 1 -o asbroadcaster-override.swf asbroadcaster-override.as
+
+trace ("override AsBroadcaster methods");
+
+AsBroadcaster.addListener = function () {
+ trace ("add");
+};
+AsBroadcaster.removeListener = function () {
+ trace ("remove");
+};
+AsBroadcaster.broadcastMessage = function () {
+ trace ("broadcast");
+};
+function test () {
+ emitter = new Object ();
+ AsBroadcaster.initialize (emitter);
+ emitter._listeners[0] = "hi";
+ emitter.addListener (null);
+ trace (emitter.broadcastMessage ("foo"));
+ emitter.removeListener (null);
+};
+
+test ();
+
+trace (_global.ASnative);
+_global.ASnative = 22;
+trace (_global.ASnative);
+
+test ();
+
+loadMovie ("FSCommand:quit", "");
diff-tree 842140435a75459c869f9b432085db9be9963410 (from 1c9a301f4bc6a0f1d54e8af60e9929f8a06cdb53)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Jul 27 12:50:59 2007 +0200
add a test for ASnative
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index e1510c9..c86810b 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -68,6 +68,15 @@ EXTRA_DIST = \
array2-7.swf.trace \
array2-8.swf \
array2-8.swf.trace \
+ asnative-create.as \
+ asnative-create-5.swf \
+ asnative-create-5.swf.trace \
+ asnative-create-6.swf \
+ asnative-create-6.swf.trace \
+ asnative-create-7.swf \
+ asnative-create-7.swf.trace \
+ asnative-create-8.swf \
+ asnative-create-8.swf.trace \
bitwise.as \
bitwise-5.swf \
bitwise-5.swf.trace \
diff --git a/test/trace/asnative-create-5.swf b/test/trace/asnative-create-5.swf
new file mode 100644
index 0000000..fda2a6d
Binary files /dev/null and b/test/trace/asnative-create-5.swf differ
diff --git a/test/trace/asnative-create-5.swf.trace b/test/trace/asnative-create-5.swf.trace
new file mode 100644
index 0000000..bbc81b2
--- /dev/null
+++ b/test/trace/asnative-create-5.swf.trace
@@ -0,0 +1,7 @@
+Check ASnative creates a new functio object every time
+[type Function]
+42
+undefined
+true
+true
+undefined
diff --git a/test/trace/asnative-create-6.swf b/test/trace/asnative-create-6.swf
new file mode 100644
index 0000000..441420c
Binary files /dev/null and b/test/trace/asnative-create-6.swf differ
diff --git a/test/trace/asnative-create-6.swf.trace b/test/trace/asnative-create-6.swf.trace
new file mode 100644
index 0000000..b61c244
--- /dev/null
+++ b/test/trace/asnative-create-6.swf.trace
@@ -0,0 +1,7 @@
+Check ASnative creates a new functio object every time
+[type Function]
+42
+undefined
+false
+false
+undefined
diff --git a/test/trace/asnative-create-7.swf b/test/trace/asnative-create-7.swf
new file mode 100644
index 0000000..e1cf91d
Binary files /dev/null and b/test/trace/asnative-create-7.swf differ
diff --git a/test/trace/asnative-create-7.swf.trace b/test/trace/asnative-create-7.swf.trace
new file mode 100644
index 0000000..b61c244
--- /dev/null
+++ b/test/trace/asnative-create-7.swf.trace
@@ -0,0 +1,7 @@
+Check ASnative creates a new functio object every time
+[type Function]
+42
+undefined
+false
+false
+undefined
diff --git a/test/trace/asnative-create-8.swf b/test/trace/asnative-create-8.swf
new file mode 100644
index 0000000..7c2e3ab
Binary files /dev/null and b/test/trace/asnative-create-8.swf differ
diff --git a/test/trace/asnative-create-8.swf.trace b/test/trace/asnative-create-8.swf.trace
new file mode 100644
index 0000000..b61c244
--- /dev/null
+++ b/test/trace/asnative-create-8.swf.trace
@@ -0,0 +1,7 @@
+Check ASnative creates a new functio object every time
+[type Function]
+42
+undefined
+false
+false
+undefined
diff --git a/test/trace/asnative-create.as b/test/trace/asnative-create.as
new file mode 100644
index 0000000..70c369f
--- /dev/null
+++ b/test/trace/asnative-create.as
@@ -0,0 +1,15 @@
+// makeswf -v 7 -s 200x150 -r 1 -o asnative-create.swf asnative-create.as
+
+trace ("Check ASnative creates a new functio object every time");
+
+foo = ASnative(5, 0);
+foo.bla = 42;
+trace (foo);
+trace (foo.bla);
+foo2 = ASnative(5, 0);
+trace (foo2.bla);
+trace (foo == foo2);
+trace (foo == Mouse.show);
+trace (Mouse.show.bla);
+
+loadMovie ("FSCommand:quit", "");
diff-tree 1c9a301f4bc6a0f1d54e8af60e9929f8a06cdb53 (from 4179c20f5d0f9f072ad00a63e4eeb58437f602d0)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Jul 27 10:01:18 2007 +0200
implement MovieClip.getBounds()
completely untested as I'm missing tests atm
diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index d6e23b0..ab08338 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -244,6 +244,11 @@ const char swfdec_as_strings[] =
SWFDEC_AS_CONSTANT_STRING ("noScale")
SWFDEC_AS_CONSTANT_STRING ("Stage")
SWFDEC_AS_CONSTANT_STRING ("onResize")
+ SWFDEC_AS_CONSTANT_STRING ("getBounds")
+ SWFDEC_AS_CONSTANT_STRING ("xMin")
+ SWFDEC_AS_CONSTANT_STRING ("xMax")
+ SWFDEC_AS_CONSTANT_STRING ("yMin")
+ SWFDEC_AS_CONSTANT_STRING ("yMax")
/* add more here */
;
diff --git a/libswfdec/swfdec_sprite_movie_as.c b/libswfdec/swfdec_sprite_movie_as.c
index 087cfda..bef0690 100644
--- a/libswfdec/swfdec_sprite_movie_as.c
+++ b/libswfdec/swfdec_sprite_movie_as.c
@@ -412,6 +412,39 @@ swfdec_sprite_movie_getDepth (SwfdecAsCo
SWFDEC_AS_VALUE_SET_INT (rval, movie->depth);
}
+static void
+swfdec_sprite_movie_getBounds (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ int x0, x1, y0, y1;
+ SwfdecAsValue val;
+ SwfdecAsObject *object;
+ SwfdecMovie *movie = SWFDEC_MOVIE (obj);
+
+ object = swfdec_as_object_new_empty (cx);
+ if (object == NULL)
+ return;
+
+ if (swfdec_rect_is_empty (&movie->extents)) {
+ x0 = x1 = y0 = y1 = 0x7FFFFFF;
+ } else {
+ x0 = movie->extents.x0;
+ y0 = movie->extents.y0;
+ x1 = movie->extents.x1;
+ y1 = movie->extents.y1;
+ }
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, SWFDEC_TWIPS_TO_DOUBLE (x0));
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_xMin, &val);
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, SWFDEC_TWIPS_TO_DOUBLE (y0));
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_yMin, &val);
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, SWFDEC_TWIPS_TO_DOUBLE (x1));
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_xMax, &val);
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, SWFDEC_TWIPS_TO_DOUBLE (y1));
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_yMax, &val);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, object);
+}
+
void
swfdec_sprite_movie_init_context (SwfdecPlayer *player, guint version)
{
@@ -469,4 +502,6 @@ swfdec_sprite_movie_init_context (Swfdec
swfdec_sprite_movie_stopDrag, 0);
swfdec_as_object_add_function (proto, SWFDEC_AS_STR_swapDepths, SWFDEC_TYPE_SPRITE_MOVIE,
swfdec_sprite_movie_swapDepths, 1);
+ swfdec_as_object_add_function (proto, SWFDEC_AS_STR_getBounds, SWFDEC_TYPE_SPRITE_MOVIE,
+ swfdec_sprite_movie_getBounds, 0);
};
diff-tree 4179c20f5d0f9f072ad00a63e4eeb58437f602d0 (from cddba05b6db9b8fc0e4935afeb505790f68a2179)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Jul 27 09:59:36 2007 +0200
perform actions before unlocking
Otherwise we'll get nasty assertion failures
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index cf0f01c..88c14e0 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -1756,6 +1756,7 @@ swfdec_player_set_size (SwfdecPlayer *pl
swfdec_player_lock (player);
swfdec_player_set_size_internal (player, width, height);
+ swfdec_player_perform_actions (player);
swfdec_player_unlock (player);
}
diff-tree cddba05b6db9b8fc0e4935afeb505790f68a2179 (from 72b5819a508a106b81bde86f6dd7b16006166dc5)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Jul 27 09:43:56 2007 +0200
add test for onResize event emission
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index e273dfe..e1510c9 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -477,6 +477,15 @@ EXTRA_DIST = \
onload-childparent.c \
onload-childparent.swf \
onload-childparent.swf.trace \
+ onresize.as \
+ onresize-5.swf \
+ onresize-5.swf.trace \
+ onresize-6.swf \
+ onresize-6.swf.trace \
+ onresize-7.swf \
+ onresize-7.swf.trace \
+ onresize-8.swf \
+ onresize-8.swf.trace \
order.swf \
order.swf.trace \
parent-root.swf \
diff --git a/test/trace/onresize-5.swf b/test/trace/onresize-5.swf
new file mode 100644
index 0000000..8b4cc54
Binary files /dev/null and b/test/trace/onresize-5.swf differ
diff --git a/test/trace/onresize-5.swf.trace b/test/trace/onresize-5.swf.trace
new file mode 100644
index 0000000..043a497
--- /dev/null
+++ b/test/trace/onresize-5.swf.trace
@@ -0,0 +1 @@
+Check no onResize happens when setting scaleMode
diff --git a/test/trace/onresize-6.swf b/test/trace/onresize-6.swf
new file mode 100644
index 0000000..8c6e850
Binary files /dev/null and b/test/trace/onresize-6.swf differ
diff --git a/test/trace/onresize-6.swf.trace b/test/trace/onresize-6.swf.trace
new file mode 100644
index 0000000..043a497
--- /dev/null
+++ b/test/trace/onresize-6.swf.trace
@@ -0,0 +1 @@
+Check no onResize happens when setting scaleMode
diff --git a/test/trace/onresize-7.swf b/test/trace/onresize-7.swf
new file mode 100644
index 0000000..91776f4
Binary files /dev/null and b/test/trace/onresize-7.swf differ
diff --git a/test/trace/onresize-7.swf.trace b/test/trace/onresize-7.swf.trace
new file mode 100644
index 0000000..043a497
--- /dev/null
+++ b/test/trace/onresize-7.swf.trace
@@ -0,0 +1 @@
+Check no onResize happens when setting scaleMode
diff --git a/test/trace/onresize-8.swf b/test/trace/onresize-8.swf
new file mode 100644
index 0000000..d7d4155
Binary files /dev/null and b/test/trace/onresize-8.swf differ
diff --git a/test/trace/onresize-8.swf.trace b/test/trace/onresize-8.swf.trace
new file mode 100644
index 0000000..043a497
--- /dev/null
+++ b/test/trace/onresize-8.swf.trace
@@ -0,0 +1 @@
+Check no onResize happens when setting scaleMode
diff --git a/test/trace/onresize.as b/test/trace/onresize.as
new file mode 100644
index 0000000..d1295a3
--- /dev/null
+++ b/test/trace/onresize.as
@@ -0,0 +1,20 @@
+// makeswf -v 7 -s 200x150 -r 1 -o onresize.swf onresize.as
+
+trace ("Check no onResize happens when setting scaleMode");
+
+o = { };
+o.onResize = function () {
+ trace (this);
+ trace (this.foo);
+ trace (foo);
+};
+Stage.addListener (o);
+foo = 42;
+
+Stage.scaleMode = "noScale";
+Stage.scaleMode = "noBorder";
+Stage.scaleMode = "noScale";
+Stage.width = 20;
+
+loadMovie ("FSCommand:quit", "");
+
diff-tree 72b5819a508a106b81bde86f6dd7b16006166dc5 (from 46d21b4eb753a088a89f1b0059b2ee2870968fc0)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 26 23:54:45 2007 +0200
implement emitting the onResize signal
diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index a97471d..d6e23b0 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -242,6 +242,8 @@ const char swfdec_as_strings[] =
SWFDEC_AS_CONSTANT_STRING ("noBorder")
SWFDEC_AS_CONSTANT_STRING ("exactFit")
SWFDEC_AS_CONSTANT_STRING ("noScale")
+ SWFDEC_AS_CONSTANT_STRING ("Stage")
+ SWFDEC_AS_CONSTANT_STRING ("onResize")
/* add more here */
;
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 398db18..cf0f01c 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -586,22 +586,19 @@ swfdec_player_dispose (GObject *object)
}
static void
-swfdec_player_dispatch_properties_changed (GObject *object, guint n_pspecs,
- GParamSpec **pspecs)
+swfdec_player_broadcast (SwfdecPlayer *player, const char *object_name, const char *signal)
{
- guint i;
+ SwfdecAsValue val;
+ SwfdecAsObject *obj;
- G_OBJECT_CLASS (swfdec_player_parent_class)->dispatch_properties_changed (
- object, n_pspecs, pspecs);
-
- /* check if we need to emit any stage signals */
- for (i = 0; i < n_pspecs; i++) {
- if (g_str_equal (pspecs[i]->name, "width") ||
- g_str_equal (pspecs[i]->name, "height")) {
- SWFDEC_FIXME ("width or height got changed, emit a Stage signal!");
- break;
- }
- }
+ SWFDEC_DEBUG ("broadcasting message %s.%s", object_name, signal);
+ obj = SWFDEC_AS_CONTEXT (player)->global;
+ swfdec_as_object_get_variable (obj, object_name, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+ obj = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ SWFDEC_AS_VALUE_SET_STRING (&val, signal);
+ swfdec_as_object_call (obj, SWFDEC_AS_STR_broadcastMessage, 1, &val, NULL);
}
static void
@@ -733,21 +730,6 @@ swfdec_player_update_mouse_position (Swf
}
static void
-swfdec_player_broadcast (SwfdecPlayer *player, const char *object_name, const char *signal)
-{
- SwfdecAsValue val;
- SwfdecAsObject *obj;
-
- obj = SWFDEC_AS_CONTEXT (player)->global;
- swfdec_as_object_get_variable (obj, object_name, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return;
- obj = SWFDEC_AS_VALUE_GET_OBJECT (&val);
- SWFDEC_AS_VALUE_SET_STRING (&val, signal);
- swfdec_as_object_call (obj, SWFDEC_AS_STR_broadcastMessage, 1, &val, NULL);
-}
-
-static void
swfdec_player_do_mouse_move (SwfdecPlayer *player)
{
GList *walk;
@@ -1024,7 +1006,6 @@ swfdec_player_class_init (SwfdecPlayerCl
object_class->get_property = swfdec_player_get_property;
object_class->set_property = swfdec_player_set_property;
object_class->dispose = swfdec_player_dispose;
- object_class->dispatch_properties_changed = swfdec_player_dispatch_properties_changed;
g_object_class_install_property (object_class, PROP_INITIALIZED,
g_param_spec_boolean ("initialized", "initialized", "TRUE when the player has initialized its basic values",
@@ -1733,6 +1714,27 @@ swfdec_player_get_size (SwfdecPlayer *pl
*height = player->stage_height;
}
+static void
+swfdec_player_set_size_internal (SwfdecPlayer *player, int width, int height)
+{
+ gboolean changed = FALSE;
+
+ if (player->stage_width != width) {
+ player->stage_width = width;
+ g_object_notify (G_OBJECT (player), "width");
+ changed = TRUE;
+ }
+ if (player->stage_height != height) {
+ player->stage_height = height;
+ g_object_notify (G_OBJECT (player), "height");
+ changed = TRUE;
+ }
+ swfdec_player_update_scale (player);
+ if (changed && player->scale_mode == SWFDEC_SCALE_NONE) {
+ swfdec_player_broadcast (player, SWFDEC_AS_STR_Stage, SWFDEC_AS_STR_onResize);
+ }
+}
+
/**
* swfdec_player_set_size:
* @player: a #SwfdecPlayer
@@ -1752,17 +1754,9 @@ swfdec_player_set_size (SwfdecPlayer *pl
g_return_if_fail (width >= -1);
g_return_if_fail (height >= -1);
- g_object_freeze_notify (G_OBJECT (player));
- if (player->stage_width != width) {
- player->stage_width = width;
- g_object_notify (G_OBJECT (player), "width");
- }
- if (player->stage_height != height) {
- player->stage_height = height;
- g_object_notify (G_OBJECT (player), "height");
- }
- g_object_thaw_notify (G_OBJECT (player));
- swfdec_player_update_scale (player);
+ swfdec_player_lock (player);
+ swfdec_player_set_size_internal (player, width, height);
+ swfdec_player_unlock (player);
}
/**
diff-tree 46d21b4eb753a088a89f1b0059b2ee2870968fc0 (from 53d6aae6f5cf72dc934950928315ca48897365d5)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 26 23:12:55 2007 +0200
Stage is a broadcaster
diff --git a/libswfdec/swfdec_initialize.as b/libswfdec/swfdec_initialize.as
index f81e1e6..624cfdc 100644
--- a/libswfdec/swfdec_initialize.as
+++ b/libswfdec/swfdec_initialize.as
@@ -65,5 +65,6 @@ AsBroadcaster.initialize (Mouse);
/*** STAGE ***/
Stage = new Object ();
+AsBroadcaster.initialize (Stage);
ASSetNativeAccessor (Stage, 666, "scaleMode,align,width,height", 1);
diff --git a/libswfdec/swfdec_initialize.h b/libswfdec/swfdec_initialize.h
index 3e15dd3..993de28 100644
--- a/libswfdec/swfdec_initialize.h
+++ b/libswfdec/swfdec_initialize.h
@@ -56,8 +56,10 @@ const unsigned char swfdec_initialize[]
0x13, 0x00, 0x08, 0x16, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07, 0x05, 0x00, 0x00, 0x00, 0x07, 0x02,
0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x96, 0x07, 0x00,
0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x02, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x52, 0x17, 0x96,
- 0x09, 0x00, 0x08, 0x17, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x14, 0x40, 0x1D, 0x96, 0x0E, 0x00,
- 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x18, 0x07, 0x9A, 0x02, 0x00, 0x00, 0x08, 0x17, 0x1C, 0x96,
- 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x00
+ 0x09, 0x00, 0x08, 0x17, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x14, 0x40, 0x1D, 0x96, 0x02, 0x00,
+ 0x08, 0x17, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x02, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x0E, 0x52, 0x17, 0x96, 0x0E, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x18, 0x07,
+ 0x9A, 0x02, 0x00, 0x00, 0x08, 0x17, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08,
+ 0x00, 0x3D, 0x17, 0x00
};
More information about the Swfdec
mailing list