[Swfdec] 4 commits - libswfdec/swfdec_script.c test/image test/trace
Benjamin Otte
company at kemper.freedesktop.org
Fri Mar 16 13:12:57 PDT 2007
libswfdec/swfdec_script.c | 15 ++++++++++---
test/image/Makefile.am | 6 ++++-
test/image/bw.jpg |binary
test/image/image.c | 1
test/image/negative-color-transform.c | 32 ++++++++++++++++++++++++++++
test/image/negative-color-transform.swf |binary
test/image/negative-color-transform.swf.png |binary
test/trace/Makefile.am | 7 ++++++
test/trace/function-scope-5.swf |binary
test/trace/function-scope-5.swf.trace | 3 ++
test/trace/function-scope-6.swf |binary
test/trace/function-scope-6.swf.trace | 3 ++
test/trace/function-scope-7.swf |binary
test/trace/function-scope-7.swf.trace | 3 ++
test/trace/function-scope.as | 18 +++++++++++++++
15 files changed, 84 insertions(+), 4 deletions(-)
New commits:
diff-tree 852a195c76af81618bc0b4ebf3bc820ac03bbb95 (from e61b375e9d7e9921d312bdb98d303db45ef1c8db)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Mar 16 21:08:22 2007 +0100
print "OK" when a test succeeded
diff --git a/test/image/image.c b/test/image/image.c
index 85c00e1..29b96a3 100644
--- a/test/image/image.c
+++ b/test/image/image.c
@@ -189,6 +189,7 @@ run_test (const char *filename)
}
cairo_surface_destroy (surface);
g_object_unref (player);
+ g_print (" OK\n");
return TRUE;
error:
diff-tree e61b375e9d7e9921d312bdb98d303db45ef1c8db (from 5bcd6f8b43f4587911f5c34c77e33d00e7c00e67)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Mar 16 21:07:09 2007 +0100
add a test for negative color transforms
diff --git a/test/image/Makefile.am b/test/image/Makefile.am
index e9eec1f..84bed85 100644
--- a/test/image/Makefile.am
+++ b/test/image/Makefile.am
@@ -7,6 +7,7 @@ image_LDFLAGS = $(SWF_LIBS) $(CAIRO_LIBS
EXTRA_DIST = \
README \
+ bw.jpg \
color-transform-add80.swf \
color-transform-add80.swf.png \
color-transform-add80-alpha.swf \
@@ -14,4 +15,7 @@ EXTRA_DIST = \
image-jpeg-alpha.swf \
image-jpeg-alpha.swf.png \
image-lossless-alpha.swf \
- image-lossless-alpha.swf.png
+ image-lossless-alpha.swf.png \
+ negative-color-transform.c \
+ negative-color-transform.swf \
+ negative-color-transform.swf.png
diff --git a/test/image/bw.jpg b/test/image/bw.jpg
new file mode 100644
index 0000000..bd428a5
Binary files /dev/null and b/test/image/bw.jpg differ
diff --git a/test/image/negative-color-transform.c b/test/image/negative-color-transform.c
new file mode 100644
index 0000000..1e18c7d
--- /dev/null
+++ b/test/image/negative-color-transform.c
@@ -0,0 +1,32 @@
+/* gcc `pkg-config --libs --cflags libming` negative-color-transform.c -o negative-color-transform && ./negative-color-transform
+ */
+
+#include <ming.h>
+#include <stdio.h>
+
+int
+main (int argc, char **argv)
+{
+ SWFMovie movie;
+ SWFDisplayItem item;
+ SWFJpegBitmap image;
+ SWFShape shape;
+
+ if (Ming_init ())
+ return 1;
+ Ming_useSWFVersion (7);
+
+ movie = newSWFMovie();
+ SWFMovie_setRate (movie, 1);
+ SWFMovie_setDimension (movie, 10, 10);
+
+ image = newSWFJpegBitmap (fopen ("bw.jpg", "r+"));
+ shape = newSWFShapeFromBitmap ((SWFBitmap) image, SWFFILL_BITMAP);
+
+ item = SWFMovie_add (movie, (SWFBlock) shape);
+ SWFDisplayItem_setCXform (item, newSWFCXform (100, 0, 0, 0, -90./256, 1.0, 1.0, 1.0));
+ SWFMovie_nextFrame (movie);
+
+ SWFMovie_save (movie, "negative-color-transform.swf");
+ return 0;
+}
diff --git a/test/image/negative-color-transform.swf b/test/image/negative-color-transform.swf
new file mode 100644
index 0000000..7c9eebe
Binary files /dev/null and b/test/image/negative-color-transform.swf differ
diff --git a/test/image/negative-color-transform.swf.png b/test/image/negative-color-transform.swf.png
new file mode 100644
index 0000000..886809e
Binary files /dev/null and b/test/image/negative-color-transform.swf.png differ
diff-tree 5bcd6f8b43f4587911f5c34c77e33d00e7c00e67 (from 685b09b065232899527707ac18ddba292cb6459e)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Mar 16 18:00:46 2007 +0100
add function scope tests
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 20e4684..c72b19b 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -75,6 +75,13 @@ EXTRA_DIST = \
function2.swf.trace \
function-prototype-chain.swf \
function-prototype-chain.swf.trace \
+ function-scope.as \
+ function-scope-5.swf \
+ function-scope-5.swf.trace \
+ function-scope-6.swf \
+ function-scope-6.swf.trace \
+ function-scope-7.swf \
+ function-scope-7.swf.trace \
function-undefined.swf \
function-undefined.swf.trace \
goto1.swf \
diff --git a/test/trace/function-scope-5.swf b/test/trace/function-scope-5.swf
new file mode 100644
index 0000000..aad1665
Binary files /dev/null and b/test/trace/function-scope-5.swf differ
diff --git a/test/trace/function-scope-5.swf.trace b/test/trace/function-scope-5.swf.trace
new file mode 100644
index 0000000..a17a92e
--- /dev/null
+++ b/test/trace/function-scope-5.swf.trace
@@ -0,0 +1,3 @@
+Check the function scope chain works
+outermost scope
+outermost scope
diff --git a/test/trace/function-scope-6.swf b/test/trace/function-scope-6.swf
new file mode 100644
index 0000000..6847e4d
Binary files /dev/null and b/test/trace/function-scope-6.swf differ
diff --git a/test/trace/function-scope-6.swf.trace b/test/trace/function-scope-6.swf.trace
new file mode 100644
index 0000000..a2c85f2
--- /dev/null
+++ b/test/trace/function-scope-6.swf.trace
@@ -0,0 +1,3 @@
+Check the function scope chain works
+inner scope
+innermost scope
diff --git a/test/trace/function-scope-7.swf b/test/trace/function-scope-7.swf
new file mode 100644
index 0000000..3bba0db
Binary files /dev/null and b/test/trace/function-scope-7.swf differ
diff --git a/test/trace/function-scope-7.swf.trace b/test/trace/function-scope-7.swf.trace
new file mode 100644
index 0000000..a2c85f2
--- /dev/null
+++ b/test/trace/function-scope-7.swf.trace
@@ -0,0 +1,3 @@
+Check the function scope chain works
+inner scope
+innermost scope
diff --git a/test/trace/function-scope.as b/test/trace/function-scope.as
new file mode 100644
index 0000000..ae89edb
--- /dev/null
+++ b/test/trace/function-scope.as
@@ -0,0 +1,18 @@
+// makeswf -v 7 -s 200x150 -r 1 -o function-scope.swf function-scope.as
+
+trace ("Check the function scope chain works");
+Foo = function () {
+ var bla = "inner scope";
+ this.bla = "this";
+ this.func = function () {
+ trace (bla);
+ var bla = "innermost scope";
+ this.func = function () {
+ trace (bla);
+ };
+ };
+};
+bla = "outermost scope";
+x = new Foo ();
+x.func ();
+x.func ();
diff-tree 685b09b065232899527707ac18ddba292cb6459e (from 0c7b304d2eb371c85616808e083f353e174bf263)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Mar 16 17:58:30 2007 +0100
fix scope chains in Flash 5
diff --git a/libswfdec/swfdec_script.c b/libswfdec/swfdec_script.c
index 7b520eb..5c6a0c2 100644
--- a/libswfdec/swfdec_script.c
+++ b/libswfdec/swfdec_script.c
@@ -1647,6 +1647,7 @@ swfdec_action_define_function (JSContext
SwfdecBits bits;
JSFunction *fun;
SwfdecScript *script;
+ JSObject *scope;
gboolean has_preloads = FALSE;
guint flags = 0;
guint8 *preloads = NULL;
@@ -1659,14 +1660,23 @@ swfdec_action_define_function (JSContext
return JS_FALSE;
}
n_args = swfdec_bits_get_u16 (&bits);
+ scope = cx->fp->scopeChain;
+ script = cx->fp->swf;
+ if (script->version == 5) {
+ /* In Flash 5 there's only the root scope as a parent scope */
+ JSObject *parent;
+ /* FIXME: this implementation is hacky (but it works) */
+ while (JS_GetClass (scope) == &js_CallClass && (parent = JS_GetParent (cx, scope)))
+ scope = parent;
+ }
if (*function_name == '\0') {
/* anonymous function */
fun = JS_NewFunction (cx, NULL, n_args, JSFUN_LAMBDA | JSFUN_HEAVYWEIGHT,
- cx->fp->scopeChain, NULL);
+ scope, NULL);
} else {
/* named function */
fun = JS_NewFunction (cx, NULL, n_args, JSFUN_HEAVYWEIGHT,
- cx->fp->scopeChain, function_name);
+ scope, function_name);
}
if (fun == NULL)
return JS_FALSE;
@@ -1716,7 +1726,6 @@ swfdec_action_define_function (JSContext
}
size = swfdec_bits_get_u16 (&bits);
/* check the script can be created */
- script = cx->fp->swf;
if (script->buffer->data + script->buffer->length < cx->fp->pc + 3 + len + size) {
SWFDEC_ERROR ("size of function is too big");
return FALSE;
More information about the Swfdec
mailing list