[Swfdec] 6 commits - libswfdec/swfdec_as_interpret.c test/trace
Pekka Lampila
medar at kemper.freedesktop.org
Thu Oct 25 10:12:39 PDT 2007
libswfdec/swfdec_as_interpret.c | 89 ++++++++++++++++++++++++-------
test/trace/Makefile.am | 9 +++
test/trace/cast-5.swf |binary
test/trace/cast-5.swf.trace | 2
test/trace/cast-6.swf |binary
test/trace/cast-6.swf.trace | 2
test/trace/cast-7.swf |binary
test/trace/cast-7.swf.trace | 2
test/trace/cast-8.swf |binary
test/trace/cast-8.swf.trace | 2
test/trace/cast.as | 23 ++++++++
test/trace/text-field-scroll-5.swf |binary
test/trace/text-field-scroll-5.swf.trace | 18 +++---
test/trace/text-field-scroll-6.swf |binary
test/trace/text-field-scroll-6.swf.trace | 16 ++---
test/trace/text-field-scroll-7.swf |binary
test/trace/text-field-scroll-7.swf.trace | 18 +++---
test/trace/text-field-scroll-8.swf |binary
test/trace/text-field-scroll-8.swf.trace | 18 +++---
test/trace/text-field-scroll.as | 2
20 files changed, 145 insertions(+), 56 deletions(-)
New commits:
commit 8b5bfc15c7f60d4cd1787ab3b0d24668ff86a63c
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Oct 25 20:08:05 2007 +0300
Add a test for Cast
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 5bde4df..b4c1f06 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -239,6 +239,15 @@ EXTRA_DIST = \
case1-6.swf.trace \
case1-7.swf \
case1-7.swf.trace \
+ cast.as \
+ cast-5.swf \
+ cast-5.swf.trace \
+ cast-6.swf \
+ cast-6.swf.trace \
+ cast-7.swf \
+ cast-7.swf.trace \
+ cast-8.swf \
+ cast-8.swf.trace \
charat.as \
charat-5.swf \
charat-5.swf.trace \
diff --git a/test/trace/cast-5.swf b/test/trace/cast-5.swf
new file mode 100644
index 0000000..ab4e417
Binary files /dev/null and b/test/trace/cast-5.swf differ
diff --git a/test/trace/cast-5.swf.trace b/test/trace/cast-5.swf.trace
new file mode 100644
index 0000000..6d36aad
--- /dev/null
+++ b/test/trace/cast-5.swf.trace
@@ -0,0 +1,2 @@
+null
+[object Object]
diff --git a/test/trace/cast-6.swf b/test/trace/cast-6.swf
new file mode 100644
index 0000000..088ca99
Binary files /dev/null and b/test/trace/cast-6.swf differ
diff --git a/test/trace/cast-6.swf.trace b/test/trace/cast-6.swf.trace
new file mode 100644
index 0000000..6d36aad
--- /dev/null
+++ b/test/trace/cast-6.swf.trace
@@ -0,0 +1,2 @@
+null
+[object Object]
diff --git a/test/trace/cast-7.swf b/test/trace/cast-7.swf
new file mode 100644
index 0000000..f68597c
Binary files /dev/null and b/test/trace/cast-7.swf differ
diff --git a/test/trace/cast-7.swf.trace b/test/trace/cast-7.swf.trace
new file mode 100644
index 0000000..6d36aad
--- /dev/null
+++ b/test/trace/cast-7.swf.trace
@@ -0,0 +1,2 @@
+null
+[object Object]
diff --git a/test/trace/cast-8.swf b/test/trace/cast-8.swf
new file mode 100644
index 0000000..485e287
Binary files /dev/null and b/test/trace/cast-8.swf differ
diff --git a/test/trace/cast-8.swf.trace b/test/trace/cast-8.swf.trace
new file mode 100644
index 0000000..6d36aad
--- /dev/null
+++ b/test/trace/cast-8.swf.trace
@@ -0,0 +1,2 @@
+null
+[object Object]
diff --git a/test/trace/cast.as b/test/trace/cast.as
new file mode 100644
index 0000000..66ae59d
--- /dev/null
+++ b/test/trace/cast.as
@@ -0,0 +1,23 @@
+// makeswf -v 7 -r 1 -o cast-7.swf cast.as
+
+var o = new Object ();
+
+asm {
+ push "o"
+ getvariable
+ push "Object"
+ getvariable
+ cast
+ trace
+};
+
+asm {
+ push "Object"
+ getvariable
+ push "o"
+ getvariable
+ cast
+ trace
+};
+
+loadMovie ("FSCommand:quit", "");
commit 85b0e8b36a6ccadd5bd54dbd9e384bc5fa73292d
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Oct 25 20:06:08 2007 +0300
Cast takes the arguments in opposite order than instanceOf
diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index b18ddbf..5224538 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -2239,19 +2239,18 @@ swfdec_action_cast (SwfdecAsContext *cx, guint action, const guint8 *data,
val = swfdec_as_stack_pop (cx);
if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
- constructor = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ object = SWFDEC_AS_VALUE_GET_OBJECT (val);
} else {
- constructor = NULL;
+ object = NULL;
}
-
+
val = swfdec_as_stack_pop (cx);
if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
- object = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ constructor = SWFDEC_AS_VALUE_GET_OBJECT (val);
} else {
- object = NULL;
+ constructor = NULL;
}
-
if (object == NULL || constructor == NULL) {
SWFDEC_AS_VALUE_SET_NULL (swfdec_as_stack_push (cx));
return;
commit 0a4255c80ae147befa09d263b6025ee775e95ab5
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Oct 25 19:53:15 2007 +0300
Implement Cast ActionScript action
diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index 3b45b3b..b18ddbf 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -2231,6 +2231,40 @@ swfdec_action_instance_of (SwfdecAsContext *cx, guint action,
}
static void
+swfdec_action_cast (SwfdecAsContext *cx, guint action, const guint8 *data,
+ guint len)
+{
+ SwfdecAsValue *val;
+ SwfdecAsObject *object, *constructor;
+
+ val = swfdec_as_stack_pop (cx);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
+ constructor = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ } else {
+ constructor = NULL;
+ }
+
+ val = swfdec_as_stack_pop (cx);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
+ object = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ } else {
+ object = NULL;
+ }
+
+
+ if (object == NULL || constructor == NULL) {
+ SWFDEC_AS_VALUE_SET_NULL (swfdec_as_stack_push (cx));
+ return;
+ }
+
+ if (swfdec_action_is_instance_of (object, constructor)) {
+ SWFDEC_AS_VALUE_SET_OBJECT (swfdec_as_stack_push (cx), object);
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (swfdec_as_stack_push (cx));
+ }
+}
+
+static void
swfdec_action_extends (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
{
SwfdecAsValue *superclass, *subclass, proto;
@@ -2873,7 +2907,7 @@ const SwfdecActionSpec swfdec_as_actions[256] = {
[SWFDEC_AS_ACTION_STRING_LESS] = { "StringLess", NULL, 2, 1, { NULL, swfdec_action_string_compare, swfdec_action_string_compare, swfdec_action_string_compare, swfdec_action_string_compare } },
/* version 7 */
[SWFDEC_AS_ACTION_THROW] = { "Throw", NULL },
- [SWFDEC_AS_ACTION_CAST] = { "Cast", NULL },
+ [SWFDEC_AS_ACTION_CAST] = { "Cast", NULL, 2, 1, { NULL, NULL, NULL, NULL, swfdec_action_cast } },
[SWFDEC_AS_ACTION_IMPLEMENTS] = { "Implements", NULL },
/* version 4 */
[0x30] = { "RandomNumber", NULL, 1, 1, { NULL, swfdec_action_random_number, swfdec_action_random_number, swfdec_action_random_number, swfdec_action_random_number } },
commit 78828b96e49c946e2c3aab29fc9bbd0fbd2dfeb0
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Oct 25 19:21:53 2007 +0300
Reorganize instanceOf code to get separate swfdec_action_is_instance_of func
diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index f2867a3..3b45b3b 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -2174,45 +2174,60 @@ swfdec_action_get_time (SwfdecAsContext *cx, guint action, const guint8 *data, g
SWFDEC_AS_VALUE_SET_INT (swfdec_as_stack_push (cx), diff);
}
+static gboolean
+swfdec_action_is_instance_of (SwfdecAsObject *object,
+ SwfdecAsObject *constructor)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *class, *prototype;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (constructor), FALSE);
+
+ // FIXME: propflag tests are wrong, and we shouldn't get __proto__.prototype
+ swfdec_as_object_get_variable (constructor, SWFDEC_AS_STR_prototype, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return FALSE;
+ prototype = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+
+ class = object;
+ while ((class = swfdec_as_object_get_prototype (class)) != NULL) {
+ if (class == prototype)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
swfdec_action_instance_of (SwfdecAsContext *cx, guint action,
const guint8 *data, guint len)
{
- SwfdecAsValue val, *val_p;
- SwfdecAsObject *object, *class, *constructor, *prototype;
+ SwfdecAsValue *val;
+ SwfdecAsObject *object, *constructor;
- val_p = swfdec_as_stack_pop (cx);
- if (SWFDEC_AS_VALUE_IS_OBJECT (val_p)) {
- constructor = SWFDEC_AS_VALUE_GET_OBJECT (val_p);
+ val = swfdec_as_stack_pop (cx);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
+ constructor = SWFDEC_AS_VALUE_GET_OBJECT (val);
} else {
constructor = NULL;
}
- val_p = swfdec_as_stack_pop (cx);
- if (SWFDEC_AS_VALUE_IS_OBJECT (val_p)) {
- object = SWFDEC_AS_VALUE_GET_OBJECT (val_p);
+ val = swfdec_as_stack_pop (cx);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
+ object = SWFDEC_AS_VALUE_GET_OBJECT (val);
} else {
object = NULL;
}
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_push (cx), FALSE);
- if (object == NULL || constructor == NULL)
- return;
-
- // FIXME: propflag tests are wrong, and we shouldn't get __proto__.prototype
- swfdec_as_object_get_variable (constructor, SWFDEC_AS_STR_prototype, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ if (object == NULL || constructor == NULL) {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_push (cx), FALSE);
return;
- prototype = SWFDEC_AS_VALUE_GET_OBJECT (&val);
-
- class = object;
- while ((class = swfdec_as_object_get_prototype (class)) != NULL) {
- if (class == prototype) {
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), TRUE);
- break;
- }
}
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_push (cx),
+ swfdec_action_is_instance_of (object, constructor));
}
static void
commit c20df1bc66973049550097a853e19c7d9d2e5dfd
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Oct 25 19:08:29 2007 +0300
Add FIXME comment to instanceOf
diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index b30bde8..f2867a3 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -2200,6 +2200,7 @@ swfdec_action_instance_of (SwfdecAsContext *cx, guint action,
if (object == NULL || constructor == NULL)
return;
+ // FIXME: propflag tests are wrong, and we shouldn't get __proto__.prototype
swfdec_as_object_get_variable (constructor, SWFDEC_AS_STR_prototype, &val);
if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
return;
commit 7b7e186ddf576b4514c643db21c5280e37373c85
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Oct 25 19:04:36 2007 +0300
Hopefully text-field-scroll now really doesn't depend on the font
diff --git a/test/trace/text-field-scroll-5.swf b/test/trace/text-field-scroll-5.swf
index 578d1fe..a9ea84b 100644
Binary files a/test/trace/text-field-scroll-5.swf and b/test/trace/text-field-scroll-5.swf differ
diff --git a/test/trace/text-field-scroll-5.swf.trace b/test/trace/text-field-scroll-5.swf.trace
index 4d134cd..3cc5df5 100644
--- a/test/trace/text-field-scroll-5.swf.trace
+++ b/test/trace/text-field-scroll-5.swf.trace
@@ -2,53 +2,53 @@
bottomScroll:
hscroll:
maxhscroll > 0: false
-maxscroll:
+maxscroll > 0: false
scroll:
# WITH TEXT
bottomScroll:
hscroll: 200
maxhscroll > 0: false
-maxscroll:
+maxscroll > 0: false
scroll: 3
# WITH WORD WRAP
bottomScroll:
hscroll: 200
maxhscroll > 0: false
-maxscroll:
+maxscroll > 0: false
scroll: 3
# WITHOUT WORD WRAP
bottomScroll:
hscroll: 200
maxhscroll > 0: false
-maxscroll:
+maxscroll > 0: false
scroll: 3
# WITH WORD WRAP - SCROLL RESET
bottomScroll:
hscroll: 200
maxhscroll > 0: false
-maxscroll:
+maxscroll > 0: false
scroll: 3
# WITH WORD WRAP - FORMAT RESET
bottomScroll:
hscroll: 200
maxhscroll > 0: false
-maxscroll:
+maxscroll > 0: false
scroll: 3
# WITH WORD WRAP - TEXT RESET
bottomScroll:
hscroll: 200
maxhscroll > 0: false
-maxscroll:
+maxscroll > 0: false
scroll: 3
# WITHOUT WORD WRAP - FORMAT RESET
bottomScroll:
hscroll: 200
maxhscroll > 0: false
-maxscroll:
+maxscroll > 0: false
scroll: 30
# WITHOUT WORD WRAP - TEXT RESET
bottomScroll:
hscroll: 200
maxhscroll > 0: false
-maxscroll:
+maxscroll > 0: false
scroll: 30
diff --git a/test/trace/text-field-scroll-6.swf b/test/trace/text-field-scroll-6.swf
index 8b0b513..d5420f7 100644
Binary files a/test/trace/text-field-scroll-6.swf and b/test/trace/text-field-scroll-6.swf differ
diff --git a/test/trace/text-field-scroll-6.swf.trace b/test/trace/text-field-scroll-6.swf.trace
index 73460cd..3c6948b 100644
--- a/test/trace/text-field-scroll-6.swf.trace
+++ b/test/trace/text-field-scroll-6.swf.trace
@@ -2,47 +2,47 @@
bottomScroll: 1
hscroll: 0
maxhscroll > 0: false
-maxscroll: 1
+maxscroll > 0: true
scroll: 1
# WITH TEXT
bottomScroll: 8
hscroll: 200
maxhscroll > 0: true
-maxscroll: 11
+maxscroll > 0: true
scroll: 3
# WITH WORD WRAP
bottomScroll: 8
hscroll: 200
maxhscroll > 0: false
-maxscroll: 11
+maxscroll > 0: true
scroll: 3
# WITHOUT WORD WRAP
bottomScroll: 8
hscroll: 200
maxhscroll > 0: true
-maxscroll: 11
+maxscroll > 0: true
scroll: 3
# WITH WORD WRAP - SCROLL RESET
bottomScroll: 8
hscroll: 200
maxhscroll > 0: false
-maxscroll: 11
+maxscroll > 0: true
scroll: 3
# WITH WORD WRAP - TEXT RESET
bottomScroll: 8
hscroll: 0
maxhscroll > 0: false
-maxscroll: 79
+maxscroll > 0: true
scroll: 3
# WITHOUT WORD WRAP - FORMAT RESET
bottomScroll: 30
hscroll: 0
maxhscroll > 0: true
-maxscroll: 11
+maxscroll > 0: true
scroll: 30
# WITHOUT WORD WRAP - TEXT RESET
bottomScroll: 16
hscroll: 0
maxhscroll > 0: true
-maxscroll: 11
+maxscroll > 0: true
scroll: 11
diff --git a/test/trace/text-field-scroll-7.swf b/test/trace/text-field-scroll-7.swf
index 67c1847..90292cf 100644
Binary files a/test/trace/text-field-scroll-7.swf and b/test/trace/text-field-scroll-7.swf differ
diff --git a/test/trace/text-field-scroll-7.swf.trace b/test/trace/text-field-scroll-7.swf.trace
index 38002d0..abccb32 100644
--- a/test/trace/text-field-scroll-7.swf.trace
+++ b/test/trace/text-field-scroll-7.swf.trace
@@ -2,53 +2,53 @@
bottomScroll: 1
hscroll: 0
maxhscroll > 0: false
-maxscroll: 1
+maxscroll > 0: true
scroll: 1
# WITH TEXT
bottomScroll: 8
hscroll: 200
maxhscroll > 0: true
-maxscroll: 11
+maxscroll > 0: true
scroll: 3
# WITH WORD WRAP
bottomScroll: 8
hscroll: 200
maxhscroll > 0: false
-maxscroll: 11
+maxscroll > 0: true
scroll: 3
# WITHOUT WORD WRAP
bottomScroll: 8
hscroll: 200
maxhscroll > 0: true
-maxscroll: 11
+maxscroll > 0: true
scroll: 3
# WITH WORD WRAP - SCROLL RESET
bottomScroll: 8
hscroll: 200
maxhscroll > 0: false
-maxscroll: 11
+maxscroll > 0: true
scroll: 3
# WITH WORD WRAP - FORMAT RESET
bottomScroll: 8
hscroll: 200
maxhscroll > 0: false
-maxscroll: 79
+maxscroll > 0: true
scroll: 3
# WITH WORD WRAP - TEXT RESET
bottomScroll: 8
hscroll: 0
maxhscroll > 0: false
-maxscroll: 79
+maxscroll > 0: true
scroll: 3
# WITHOUT WORD WRAP - FORMAT RESET
bottomScroll: 30
hscroll: 0
maxhscroll > 0: true
-maxscroll: 11
+maxscroll > 0: true
scroll: 30
# WITHOUT WORD WRAP - TEXT RESET
bottomScroll: 16
hscroll: 0
maxhscroll > 0: true
-maxscroll: 11
+maxscroll > 0: true
scroll: 11
diff --git a/test/trace/text-field-scroll-8.swf b/test/trace/text-field-scroll-8.swf
index 4b1656e..f78ca7d 100644
Binary files a/test/trace/text-field-scroll-8.swf and b/test/trace/text-field-scroll-8.swf differ
diff --git a/test/trace/text-field-scroll-8.swf.trace b/test/trace/text-field-scroll-8.swf.trace
index 38002d0..abccb32 100644
--- a/test/trace/text-field-scroll-8.swf.trace
+++ b/test/trace/text-field-scroll-8.swf.trace
@@ -2,53 +2,53 @@
bottomScroll: 1
hscroll: 0
maxhscroll > 0: false
-maxscroll: 1
+maxscroll > 0: true
scroll: 1
# WITH TEXT
bottomScroll: 8
hscroll: 200
maxhscroll > 0: true
-maxscroll: 11
+maxscroll > 0: true
scroll: 3
# WITH WORD WRAP
bottomScroll: 8
hscroll: 200
maxhscroll > 0: false
-maxscroll: 11
+maxscroll > 0: true
scroll: 3
# WITHOUT WORD WRAP
bottomScroll: 8
hscroll: 200
maxhscroll > 0: true
-maxscroll: 11
+maxscroll > 0: true
scroll: 3
# WITH WORD WRAP - SCROLL RESET
bottomScroll: 8
hscroll: 200
maxhscroll > 0: false
-maxscroll: 11
+maxscroll > 0: true
scroll: 3
# WITH WORD WRAP - FORMAT RESET
bottomScroll: 8
hscroll: 200
maxhscroll > 0: false
-maxscroll: 79
+maxscroll > 0: true
scroll: 3
# WITH WORD WRAP - TEXT RESET
bottomScroll: 8
hscroll: 0
maxhscroll > 0: false
-maxscroll: 79
+maxscroll > 0: true
scroll: 3
# WITHOUT WORD WRAP - FORMAT RESET
bottomScroll: 30
hscroll: 0
maxhscroll > 0: true
-maxscroll: 11
+maxscroll > 0: true
scroll: 30
# WITHOUT WORD WRAP - TEXT RESET
bottomScroll: 16
hscroll: 0
maxhscroll > 0: true
-maxscroll: 11
+maxscroll > 0: true
scroll: 11
diff --git a/test/trace/text-field-scroll.as b/test/trace/text-field-scroll.as
index bd60a7d..77cbb82 100644
--- a/test/trace/text-field-scroll.as
+++ b/test/trace/text-field-scroll.as
@@ -4,7 +4,7 @@ function trace_scroll_properties () {
trace ("bottomScroll: " + t.bottomScroll);
trace ("hscroll: " + t.hscroll);
trace ("maxhscroll > 0: " + (t.maxhscroll > 0));
- trace ("maxscroll: " + t.maxscroll);
+ trace ("maxscroll > 0: " + (t.maxscroll > 0));
trace ("scroll: " + t.scroll);
}
More information about the Swfdec
mailing list