[Swfdec] 11 commits - libswfdec/swfdec_as_strings.c libswfdec/swfdec_sprite_movie_as.c libswfdec/swfdec_xml.c libswfdec/swfdec_xml.h libswfdec/swfdec_xml_node.c libswfdec/swfdec_xml_node.h test/image test/swfdec_test.c test/swfdec_test_image.c test/trace
Pekka Lampila
medar at kemper.freedesktop.org
Sat Jan 19 01:31:55 PST 2008
libswfdec/swfdec_as_strings.c | 2
libswfdec/swfdec_sprite_movie_as.c | 22 ++--
libswfdec/swfdec_xml.c | 117 ++++++++++++++++-------
libswfdec/swfdec_xml.h | 8 -
libswfdec/swfdec_xml_node.c | 32 +++---
libswfdec/swfdec_xml_node.h | 2
test/image/default.stas | 17 ++-
test/image/default.sts |binary
test/swfdec_test.c | 7 +
test/swfdec_test_image.c | 21 +---
test/trace/Makefile.am | 16 +++
test/trace/movieclip-get-bounds-line-5.swf |binary
test/trace/movieclip-get-bounds-line-5.swf.trace | 28 +++++
test/trace/movieclip-get-bounds-line-6.swf |binary
test/trace/movieclip-get-bounds-line-6.swf.trace | 28 +++++
test/trace/movieclip-get-bounds-line-7.swf |binary
test/trace/movieclip-get-bounds-line-7.swf.trace | 28 +++++
test/trace/movieclip-get-bounds-line.as | 49 +++++++++
test/trace/xml-escape-5.swf |binary
test/trace/xml-escape-5.swf.trace | 1
test/trace/xml-escape.as | 3
test/trace/xml-id-map-5.swf |binary
test/trace/xml-id-map-5.swf.trace | 25 ++++
test/trace/xml-id-map-6.swf |binary
test/trace/xml-id-map-6.swf.trace | 32 ++++++
test/trace/xml-id-map-7.swf |binary
test/trace/xml-id-map-7.swf.trace | 31 ++++++
test/trace/xml-id-map-8.swf |binary
test/trace/xml-id-map-8.swf.trace | 32 ++++++
test/trace/xml-id-map.as | 88 +++++++++++++++++
30 files changed, 508 insertions(+), 81 deletions(-)
New commits:
commit 22eb51703dca86e6cf91bc034842ae6a9fd15cd9
Merge: 1f756e1... 81a5772...
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Sat Jan 19 11:29:47 2008 +0200
Merge branch 'master' of ssh://medar@git.freedesktop.org/git/swfdec/swfdec
commit 1f756e1674d8287196821b61070c6f000d5a4255
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Jan 17 20:50:13 2008 +0200
Add --dump (-d) flag to test for dumping test image and diff on failure
diff --git a/test/image/default.stas b/test/image/default.stas
index 402a189..1d2a3a0 100644
--- a/test/image/default.stas
+++ b/test/image/default.stas
@@ -24,10 +24,21 @@ run_test = function (t, file) {
t.reset (file);
t.advance (0);
t.advance (Math.ceil (10000 / t.rate));
- image = t.render ();
- compare = new Image (file + ".png");
- if (!image.compare (compare)) {
+ var image = t.render ();
+ var compare = new Image (file + ".png");
+ if (compare == null) {
+ error ("compare image missing");
+ return false;
+ }
+ var diff = compare.compare (image);
+ if (diff != null) {
error ("images differ");
+ if (dump) {
+ Native.print (" SAVING: " + file + ".dump.png");
+ image.save (file + ".dump.png");
+ Native.print (" SAVING: " + file + ".diff.png");
+ diff.save (file + ".diff.png");
+ }
return false;
}
} catch (e) {
diff --git a/test/image/default.sts b/test/image/default.sts
index 6ef85c1..1f5da52 100644
Binary files a/test/image/default.sts and b/test/image/default.sts differ
diff --git a/test/swfdec_test.c b/test/swfdec_test.c
index 87fb39a..6e1e1d6 100644
--- a/test/swfdec_test.c
+++ b/test/swfdec_test.c
@@ -77,8 +77,10 @@ main (int argc, char **argv)
SwfdecScript *script;
SwfdecAsValue val;
int i, ret;
+ gboolean dump;
GOptionEntry options[] = {
+ { "dump", 'd', 0, G_OPTION_ARG_NONE, &dump, "dump images on failure", FALSE },
{ "script", 's', 0, G_OPTION_ARG_STRING, &script_filename, "script to execute if not ./default.sts", "FILENAME" },
{ NULL }
};
@@ -110,6 +112,11 @@ main (int argc, char **argv)
context = g_object_new (SWFDEC_TYPE_AS_CONTEXT, NULL);
swfdec_as_context_startup (context, SWFDEC_TEST_VERSION);
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (&val, dump);
+ swfdec_as_object_set_variable (context->global,
+ swfdec_as_context_get_string (context, "dump"), &val);
+
swfdec_test_function_init_context (context);
swfdec_as_context_run_init_script (context, swfdec_test_initialize,
sizeof (swfdec_test_initialize), SWFDEC_TEST_VERSION);
diff --git a/test/swfdec_test_image.c b/test/swfdec_test_image.c
index bcead21..26282ba 100644
--- a/test/swfdec_test_image.c
+++ b/test/swfdec_test_image.c
@@ -144,16 +144,15 @@ void
swfdec_test_image_compare (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
SwfdecAsValue *argv, SwfdecAsValue *retval)
{
- SwfdecTestImage *image, *compare;
+ SwfdecTestImage *image, *compare, *diff;
int w, h;
- cairo_surface_t *diff;
SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_IMAGE, &image, "O", &compare);
if (!SWFDEC_IS_TEST_IMAGE (compare))
return;
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
+ SWFDEC_AS_VALUE_SET_OBJECT (retval, SWFDEC_AS_OBJECT (image));
if (!SWFDEC_TEST_IMAGE_IS_VALID (image) ||
!SWFDEC_TEST_IMAGE_IS_VALID (compare))
return;
@@ -167,21 +166,21 @@ swfdec_test_image_compare (SwfdecAsContext *cx, SwfdecAsObject *object, guint ar
h = cairo_image_surface_get_height (image->surface);
if (h != cairo_image_surface_get_height (compare->surface))
return;
- diff = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w, h);
+ diff = SWFDEC_TEST_IMAGE (swfdec_test_image_new (cx, w, h));
+ if (!diff)
+ return;
if (!buffer_diff_core (cairo_image_surface_get_data (image->surface),
cairo_image_surface_get_data (compare->surface),
- cairo_image_surface_get_data (diff),
+ cairo_image_surface_get_data (diff->surface),
w, h,
cairo_image_surface_get_stride (image->surface),
cairo_image_surface_get_stride (compare->surface),
- cairo_image_surface_get_stride (diff)) != 0) {
- cairo_surface_destroy (diff);
- return;
+ cairo_image_surface_get_stride (diff->surface)) != 0) {
+ SWFDEC_AS_VALUE_SET_OBJECT (retval, SWFDEC_AS_OBJECT (diff));
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (retval);
}
- cairo_surface_destroy (diff);
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
}
SWFDEC_TEST_FUNCTION ("Image_save", swfdec_test_image_save, 0)
commit ae8a6152b013a94b49327de159f4113bf493e3d4
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Jan 17 19:55:26 2008 +0200
Add a test for getBounds with lineTo
Version 8 of the test fails and was not added
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 5288369..84a7c48 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -1473,6 +1473,13 @@ EXTRA_DIST = \
movie-enumerate-7.swf.trace \
movie-enumerate-8.swf \
movie-enumerate-8.swf.trace \
+ movieclip-get-bounds-line.as \
+ movieclip-get-bounds-line-5.swf \
+ movieclip-get-bounds-line-5.swf.trace \
+ movieclip-get-bounds-line-6.swf \
+ movieclip-get-bounds-line-6.swf.trace \
+ movieclip-get-bounds-line-7.swf \
+ movieclip-get-bounds-line-7.swf.trace \
movieclip-get-swf-version.as \
movieclip-get-swf-version-5.swf \
movieclip-get-swf-version-5.swf.trace \
diff --git a/test/trace/movieclip-get-bounds-line-5.swf b/test/trace/movieclip-get-bounds-line-5.swf
new file mode 100644
index 0000000..af33a67
Binary files /dev/null and b/test/trace/movieclip-get-bounds-line-5.swf differ
diff --git a/test/trace/movieclip-get-bounds-line-5.swf.trace b/test/trace/movieclip-get-bounds-line-5.swf.trace
new file mode 100644
index 0000000..e308b2f
--- /dev/null
+++ b/test/trace/movieclip-get-bounds-line-5.swf.trace
@@ -0,0 +1,28 @@
+Testing: this
+undefined
+yMax:
+yMin:
+xMax:
+xMin:
+width, height: ,
+Testing: a
+undefined
+yMax:
+yMin:
+xMax:
+xMin:
+width, height: ,
+Testing: (no args)
+undefined
+yMax:
+yMin:
+xMax:
+xMin:
+width, height: ,
+Testing: 2
+undefined
+yMax:
+yMin:
+xMax:
+xMin:
+width, height: ,
diff --git a/test/trace/movieclip-get-bounds-line-6.swf b/test/trace/movieclip-get-bounds-line-6.swf
new file mode 100644
index 0000000..706ab51
Binary files /dev/null and b/test/trace/movieclip-get-bounds-line-6.swf differ
diff --git a/test/trace/movieclip-get-bounds-line-6.swf.trace b/test/trace/movieclip-get-bounds-line-6.swf.trace
new file mode 100644
index 0000000..e7321bd
--- /dev/null
+++ b/test/trace/movieclip-get-bounds-line-6.swf.trace
@@ -0,0 +1,28 @@
+Testing: this
+[type Object]
+yMax: 114
+yMin: 6
+xMax: 114
+xMin: 6
+width, height: 108, 108
+Testing: a
+[type Object]
+yMax: 104
+yMin: -4
+xMax: 104
+xMin: -4
+width, height: 108, 108
+Testing: (no args)
+[type Object]
+yMax: 104
+yMin: -4
+xMax: 104
+xMin: -4
+width, height: 108, 108
+Testing: 2
+undefined
+yMax:
+yMin:
+xMax:
+xMin:
+width, height: 108, 108
diff --git a/test/trace/movieclip-get-bounds-line-7.swf b/test/trace/movieclip-get-bounds-line-7.swf
new file mode 100644
index 0000000..08edf01
Binary files /dev/null and b/test/trace/movieclip-get-bounds-line-7.swf differ
diff --git a/test/trace/movieclip-get-bounds-line-7.swf.trace b/test/trace/movieclip-get-bounds-line-7.swf.trace
new file mode 100644
index 0000000..013c179
--- /dev/null
+++ b/test/trace/movieclip-get-bounds-line-7.swf.trace
@@ -0,0 +1,28 @@
+Testing: this
+[type Object]
+yMax: 114
+yMin: 6
+xMax: 114
+xMin: 6
+width, height: 108, 108
+Testing: a
+[type Object]
+yMax: 104
+yMin: -4
+xMax: 104
+xMin: -4
+width, height: 108, 108
+Testing: (no args)
+[type Object]
+yMax: 104
+yMin: -4
+xMax: 104
+xMin: -4
+width, height: 108, 108
+Testing: 2
+undefined
+yMax: undefined
+yMin: undefined
+xMax: undefined
+xMin: undefined
+width, height: 108, 108
diff --git a/test/trace/movieclip-get-bounds-line.as b/test/trace/movieclip-get-bounds-line.as
new file mode 100644
index 0000000..1612d9f
--- /dev/null
+++ b/test/trace/movieclip-get-bounds-line.as
@@ -0,0 +1,49 @@
+// makeswf -v 7 -r 1 -o movieclip-get-bounds-7.swf movieclip-get-bounds.as
+
+// FIXME this test doesn't yet pass on version 8
+
+var keys = ["yMax", "yMin", "xMax", "xMin"];
+
+this.createEmptyMovieClip ("a", 1);
+a._x = 10;
+a._y = 10;
+a.lineStyle (4);
+a.moveTo (0, 0);
+a.lineTo (100, 0);
+a.lineTo (100, 100);
+a.lineTo (0, 100);
+a.lineTo (0, 0);
+
+trace ("Testing: this");
+var o = a.getBounds (this);
+trace (o);
+for (var i = 0; i < keys.length; i++) {
+ trace (keys[i] + ": " + o[keys[i]]);
+}
+trace ("width, height: " + a._width + ", " + a._height);
+
+trace ("Testing: a");
+var o = a.getBounds (a);
+trace (o);
+for (var i = 0; i < keys.length; i++) {
+ trace (keys[i] + ": " + o[keys[i]]);
+}
+trace ("width, height: " + a._width + ", " + a._height);
+
+trace ("Testing: (no args)");
+var o = a.getBounds ();
+trace (o);
+for (var i = 0; i < keys.length; i++) {
+ trace (keys[i] + ": " + o[keys[i]]);
+}
+trace ("width, height: " + a._width + ", " + a._height);
+
+trace ("Testing: 2");
+var o = a.getBounds (2);
+trace (o);
+for (var i = 0; i < keys.length; i++) {
+ trace (keys[i] + ": " + o[keys[i]]);
+}
+trace ("width, height: " + a._width + ", " + a._height);
+
+loadMovie ("FSCommand:quit", "");
commit 820ca7f28c3f39d4496dcfef5f8f110051e6b3ff
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Jan 17 18:40:15 2008 +0200
Fix MovieClip's getBounds' handling of missing argument and invalid argument
diff --git a/libswfdec/swfdec_sprite_movie_as.c b/libswfdec/swfdec_sprite_movie_as.c
index e1e5d7a..223d3b1 100644
--- a/libswfdec/swfdec_sprite_movie_as.c
+++ b/libswfdec/swfdec_sprite_movie_as.c
@@ -789,17 +789,21 @@ swfdec_sprite_movie_getBounds (SwfdecAsContext *cx, SwfdecAsObject *object,
x0 = x1 = y0 = y1 = 0x7FFFFFF;
} else {
SwfdecRect rect = movie->extents;
+ SwfdecMovie *other;
+
if (argc > 0) {
- SwfdecMovie *other = swfdec_player_get_movie_from_value (
- SWFDEC_PLAYER (cx), &argv[0]);
- if (other) {
- if (movie->parent)
- swfdec_movie_rect_local_to_global (movie->parent, &rect);
- swfdec_movie_rect_global_to_local (other, &rect);
- } else {
- SWFDEC_FIXME ("what's getBounds relative to invalid?");
- }
+ other =
+ swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx), &argv[0]);
+ if (!other)
+ return;
+ } else {
+ other = movie;
}
+
+ if (movie->parent)
+ swfdec_movie_rect_local_to_global (movie->parent, &rect);
+ swfdec_movie_rect_global_to_local ((other != NULL ? other : movie), &rect);
+
x0 = rect.x0;
y0 = rect.y0;
x1 = rect.x1;
commit 1a34f5bbf5c900b85ff4199e62826786cf75f086
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Jan 17 13:46:56 2008 +0200
Add a test for XML's id mappings
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 13423ad..5288369 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -3105,6 +3105,15 @@ EXTRA_DIST = \
xml-escape-7.swf.trace \
xml-escape-8.swf \
xml-escape-8.swf.trace \
+ xml-id-map.as \
+ xml-id-map-5.swf \
+ xml-id-map-5.swf.trace \
+ xml-id-map-6.swf \
+ xml-id-map-6.swf.trace \
+ xml-id-map-7.swf \
+ xml-id-map-7.swf.trace \
+ xml-id-map-8.swf \
+ xml-id-map-8.swf.trace \
xml-init.as \
xml-init-5.swf \
xml-init-5.swf.trace \
diff --git a/test/trace/xml-id-map-5.swf b/test/trace/xml-id-map-5.swf
new file mode 100644
index 0000000..2e49272
Binary files /dev/null and b/test/trace/xml-id-map-5.swf differ
diff --git a/test/trace/xml-id-map-5.swf.trace b/test/trace/xml-id-map-5.swf.trace
new file mode 100644
index 0000000..b2dfdb1
--- /dev/null
+++ b/test/trace/xml-id-map-5.swf.trace
@@ -0,0 +1,25 @@
+local.x = object
+ 1 = object
+ __proto__ (hp) = _global.XMLNode.prototype
+ constructor (hp) = _global.XMLNode
+ 2 = object
+ __proto__ (hp) = _global.XMLNode.prototype
+ constructor (hp) = _global.XMLNode
+ __constructor__ (hn) = _global.XML
+ __proto__ (hp) = _global.XML.prototype
+ constructor (h) = _global.XML
+
+done
+<a><b id="test" /></a>
+
+done
+ <a> <b id="change" /> <c /> <d id="change" /> </a>
+
+2
+undefined
+[object Object]
+undefined
+[object Object]
+hello
+[object Object]
+hello
diff --git a/test/trace/xml-id-map-6.swf b/test/trace/xml-id-map-6.swf
new file mode 100644
index 0000000..937d44c
Binary files /dev/null and b/test/trace/xml-id-map-6.swf differ
diff --git a/test/trace/xml-id-map-6.swf.trace b/test/trace/xml-id-map-6.swf.trace
new file mode 100644
index 0000000..8579758
--- /dev/null
+++ b/test/trace/xml-id-map-6.swf.trace
@@ -0,0 +1,32 @@
+local.x = object
+ 1 = object
+ __proto__ (hp) = _global.XMLNode.prototype
+ constructor (hp) = _global.XMLNode
+ 2 = object
+ __proto__ (hp) = _global.XMLNode.prototype
+ constructor (hp) = _global.XMLNode
+ __constructor__ (h) = _global.XML
+ __proto__ (hp) = _global.XML.prototype
+ constructor (h) = _global.XML
+
+test_set: <b id="test" />
+caller: null, callee: [type Function]
+<a><b id="test" /></a>
+done
+<a><b id="test" /></a>
+
+changed ignoreWhite to: true
+ <a> <b id="change" /></a>
+changed ignoreWhite to: false
+ <a> <b id="change" /> <c /> <d id="change" /></a>
+done
+ <a> <b id="change" /> <c /> <d id="change" /> </a>
+
+2
+undefined
+[object Object]
+undefined
+[object Object]
+hello
+[object Object]
+hello
diff --git a/test/trace/xml-id-map-7.swf b/test/trace/xml-id-map-7.swf
new file mode 100644
index 0000000..06d649c
Binary files /dev/null and b/test/trace/xml-id-map-7.swf differ
diff --git a/test/trace/xml-id-map-7.swf.trace b/test/trace/xml-id-map-7.swf.trace
new file mode 100644
index 0000000..539856b
--- /dev/null
+++ b/test/trace/xml-id-map-7.swf.trace
@@ -0,0 +1,31 @@
+local.x = object
+ 1 = object
+ __proto__ (hp) = _global.XMLNode.prototype
+ constructor (hp) = _global.XMLNode
+ 2 = object
+ __proto__ (hp) = _global.XMLNode.prototype
+ constructor (hp) = _global.XMLNode
+ __constructor__ (h) = _global.XML
+ __proto__ (hp) = _global.XML.prototype
+
+test_set: <b id="test" />
+caller: null, callee: [type Function]
+<a><b id="test" /></a>
+done
+<a><b id="test" /></a>
+
+changed ignoreWhite to: true
+ <a> <b id="change" /></a>
+changed ignoreWhite to: false
+ <a> <b id="change" /> <c /> <d id="change" /></a>
+done
+ <a> <b id="change" /> <c /> <d id="change" /> </a>
+
+2
+undefined
+[object Object]
+undefined
+[object Object]
+hello
+[object Object]
+hello
diff --git a/test/trace/xml-id-map-8.swf b/test/trace/xml-id-map-8.swf
new file mode 100644
index 0000000..1a68eb4
Binary files /dev/null and b/test/trace/xml-id-map-8.swf differ
diff --git a/test/trace/xml-id-map-8.swf.trace b/test/trace/xml-id-map-8.swf.trace
new file mode 100644
index 0000000..2205d43
--- /dev/null
+++ b/test/trace/xml-id-map-8.swf.trace
@@ -0,0 +1,32 @@
+local.x = object
+ __constructor__ (h) = _global.XML
+ __proto__ (hp) = _global.XML.prototype
+ idMap = object
+ 1 = object
+ __proto__ (hp) = _global.XMLNode.prototype
+ constructor (hp) = _global.XMLNode
+ 2 = object
+ __proto__ (hp) = _global.XMLNode.prototype
+ constructor (hp) = _global.XMLNode
+
+test_set: <b id="test" />
+caller: null, callee: [type Function]
+<a><b id="test" /></a>
+done
+<a><b id="test" /></a>
+
+changed ignoreWhite to: true
+ <a> <b id="change" /></a>
+changed ignoreWhite to: false
+ <a> <b id="change" /> <c /> <d id="change" /></a>
+done
+ <a> <b id="change" /> <c /> <d id="change" /> </a>
+
+2
+undefined
+[object Object]
+<a id="1" />
+[object Object]
+<a id="1" />
+[object Object]
+hello
diff --git a/test/trace/xml-id-map.as b/test/trace/xml-id-map.as
new file mode 100644
index 0000000..68393f5
--- /dev/null
+++ b/test/trace/xml-id-map.as
@@ -0,0 +1,88 @@
+// makeswf -v 7 -r 1 -o xml-id-map-7.swf xml-id-map.as
+
+// Basic stuff
+#include "trace_properties.as"
+
+var x = new XML ("<a id='1'><b id='2'/><c/></a>");
+trace_properties (x, "local", "x");
+
+
+// See the state when set is called
+trace ("");
+
+function test_get () {
+ trace ("test_get");
+}
+
+function test_set (n) {
+ trace ("test_set: " + arguments);
+ trace ("caller: " + arguments.caller + ", callee: " + arguments.callee);
+ trace (x);
+}
+
+x = new XML ();
+x.addProperty ("test", test_get, test_set);
+x.idMap = {};
+x.idMap.addProperty = Object.prototype.addProperty;
+x.idMap.addProperty ("test", test_get, test_set);
+delete x.idMap.addProperty;
+x.parseXML ("<a><b id='test'/></a>");
+trace ("done");
+trace (x);
+
+
+// Change ignoreWhite while parsing
+trace ("");
+
+function change_get () {
+};
+
+function change_set () {
+ x.ignoreWhite = !x.ignoreWhite;
+ trace ("changed ignoreWhite to: " + x.ignoreWhite);
+ trace (x);
+}
+
+x = new XML ();
+x.addProperty ("change", change_get, change_set);
+x.idMap = {};
+x.idMap.addProperty = Object.prototype.addProperty;
+x.idMap.addProperty ("change", change_get, change_set);
+delete x.idMap.addProperty;
+x.parseXML (" <a> <b id='change'/> <c/> <d id='change'/> </a>");
+trace ("done");
+trace (x);
+
+
+// idMap preset
+trace ("");
+
+x = new XML ();
+x.idMap = 2;
+x.parseXML ("<a id='1'/>");
+trace (x.idMap);
+trace (x.idMap[1]);
+
+x = new XML ();
+x.idMap = new Object ();
+x.parseXML ("<a id='1'/>");
+trace (x.idMap);
+trace (x.idMap[1]);
+
+x = new XML ();
+x.idMap = {};
+x.idMap[1] = "hello";
+x.parseXML ("<a id='1'/>");
+trace (x.idMap);
+trace (x.idMap[1]);
+
+x = new XML ();
+x.idMap = {};
+x.idMap[1] = "hello";
+ASSetPropFlags (x.idMap, "1", 7);
+x.parseXML ("<a id='1'/>");
+trace (x.idMap);
+trace (x.idMap[1]);
+
+
+loadMovie ("FSCommand:quit", "");
commit 57962eb4a74640067bc53c662b2ce5f5c7a8457c
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Jan 17 13:40:25 2008 +0200
Don't use camel case in XML's and XMLNode's variables
diff --git a/libswfdec/swfdec_xml.c b/libswfdec/swfdec_xml.c
index 816443a..e5331c6 100644
--- a/libswfdec/swfdec_xml.c
+++ b/libswfdec/swfdec_xml.c
@@ -43,10 +43,10 @@ swfdec_xml_do_mark (SwfdecAsObject *object)
{
SwfdecXml *xml = SWFDEC_XML (object);
- if (xml->xmlDecl != NULL)
- swfdec_as_string_mark (xml->xmlDecl);
- if (xml->docTypeDecl != NULL)
- swfdec_as_string_mark (xml->docTypeDecl);
+ if (xml->xml_decl != NULL)
+ swfdec_as_string_mark (xml->xml_decl);
+ if (xml->doc_type_decl != NULL)
+ swfdec_as_string_mark (xml->doc_type_decl);
SWFDEC_AS_OBJECT_CLASS (swfdec_xml_parent_class)->mark (object);
}
@@ -186,7 +186,7 @@ swfdec_xml_get_ignoreWhite (SwfdecAsContext *cx, SwfdecAsObject *object,
if (!SWFDEC_IS_XML (object))
return;
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, SWFDEC_XML (object)->ignoreWhite);
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, SWFDEC_XML (object)->ignore_white);
}
static void
@@ -207,7 +207,8 @@ swfdec_xml_set_ignoreWhite (SwfdecAsContext *cx, SwfdecAsObject *object,
if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
swfdec_as_value_to_string (cx, &argv[0]);
- SWFDEC_XML (object)->ignoreWhite = swfdec_as_value_to_boolean (cx, &argv[0]);
+ SWFDEC_XML (object)->ignore_white =
+ swfdec_as_value_to_boolean (cx, &argv[0]);
}
static void
@@ -217,8 +218,8 @@ swfdec_xml_get_xmlDecl (SwfdecAsContext *cx, SwfdecAsObject *object,
if (!SWFDEC_IS_XML (object))
return;
- if (SWFDEC_XML (object)->xmlDecl != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_XML (object)->xmlDecl);
+ if (SWFDEC_XML (object)->xml_decl != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_XML (object)->xml_decl);
} else {
SWFDEC_AS_VALUE_SET_UNDEFINED (ret);
}
@@ -238,7 +239,7 @@ swfdec_xml_set_xmlDecl (SwfdecAsContext *cx, SwfdecAsObject *object,
if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
return;
- SWFDEC_XML (object)->xmlDecl = swfdec_as_value_to_string (cx, &argv[0]);
+ SWFDEC_XML (object)->xml_decl = swfdec_as_value_to_string (cx, &argv[0]);
}
static void
@@ -248,8 +249,8 @@ swfdec_xml_get_docTypeDecl (SwfdecAsContext *cx, SwfdecAsObject *object,
if (!SWFDEC_IS_XML (object))
return;
- if (SWFDEC_XML (object)->docTypeDecl != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_XML (object)->docTypeDecl);
+ if (SWFDEC_XML (object)->doc_type_decl != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_XML (object)->doc_type_decl);
} else {
SWFDEC_AS_VALUE_SET_UNDEFINED (ret);
}
@@ -269,7 +270,8 @@ swfdec_xml_set_docTypeDecl (SwfdecAsContext *cx, SwfdecAsObject *object,
if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
return;
- SWFDEC_XML (object)->docTypeDecl = swfdec_as_value_to_string (cx, &argv[0]);
+ SWFDEC_XML (object)->doc_type_decl =
+ swfdec_as_value_to_string (cx, &argv[0]);
}
static void
@@ -279,7 +281,7 @@ swfdec_xml_get_contentType (SwfdecAsContext *cx, SwfdecAsObject *object,
if (!SWFDEC_IS_XML (object))
return;
- *ret = SWFDEC_XML (object)->contentType;
+ *ret = SWFDEC_XML (object)->content_type;
}
static void
@@ -296,7 +298,7 @@ swfdec_xml_set_contentType (SwfdecAsContext *cx, SwfdecAsObject *object,
if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
return;
- SWFDEC_XML (object)->contentType = argv[0];
+ SWFDEC_XML (object)->content_type = argv[0];
}
static void
@@ -380,10 +382,10 @@ swfdec_xml_parse_xmlDecl (SwfdecXml *xml, SwfdecXmlNode *node, const char *p)
end += strlen ("?>");
- string = g_string_new ((xml->xmlDecl != NULL ? xml->xmlDecl : ""));
+ string = g_string_new ((xml->xml_decl != NULL ? xml->xml_decl : ""));
string = g_string_append_len (string, p, end - p);
- xml->xmlDecl = swfdec_as_context_give_string (SWFDEC_AS_OBJECT (xml)->context,
- g_string_free (string, FALSE));
+ xml->xml_decl = swfdec_as_context_give_string (
+ SWFDEC_AS_OBJECT (xml)->context, g_string_free (string, FALSE));
// in version 5 parsing xmlDecl or docType always adds undefined element to
// the childNodes array
@@ -424,7 +426,7 @@ swfdec_xml_parse_docTypeDecl (SwfdecXml *xml, SwfdecXmlNode *node,
if (*end == '\0') {
xml->status = XML_PARSE_STATUS_DOCTYPEDECL_NOT_TERMINATED;
} else {
- xml->docTypeDecl = swfdec_as_context_give_string (
+ xml->doc_type_decl = swfdec_as_context_give_string (
SWFDEC_AS_OBJECT (xml)->context, g_strndup (p, end - p));
// in version 5 parsing xmlDecl or docType always adds undefined element to
@@ -666,7 +668,7 @@ swfdec_xml_parse_tag (SwfdecXml *xml, SwfdecXmlNode **node, const char *p)
static const char *
swfdec_xml_parse_text (SwfdecXml *xml, SwfdecXmlNode *node,
- const char *p, gboolean ignoreWhite)
+ const char *p, gboolean ignore_white)
{
SwfdecXmlNode *child;
const char *end;
@@ -680,7 +682,7 @@ swfdec_xml_parse_text (SwfdecXml *xml, SwfdecXmlNode *node,
if (end == NULL)
end = strchr (p, '\0');
- if (!ignoreWhite || strspn (p, " \t\r\n") < (gsize)(end - p))
+ if (!ignore_white || strspn (p, " \t\r\n") < (gsize)(end - p))
{
text = g_strndup (p, end - p);
unescaped = swfdec_xml_unescape (SWFDEC_AS_OBJECT (xml)->context, text);
@@ -705,7 +707,7 @@ swfdec_xml_parseXML (SwfdecXml *xml, const char *value)
SwfdecAsObject *object;
SwfdecXmlNode *node;
const char *p;
- gboolean ignoreWhite;
+ gboolean ignore_white;
g_return_if_fail (SWFDEC_IS_XML (xml));
g_return_if_fail (value != NULL);
@@ -713,15 +715,15 @@ swfdec_xml_parseXML (SwfdecXml *xml, const char *value)
object = SWFDEC_AS_OBJECT (xml);
swfdec_xml_node_removeChildren (SWFDEC_XML_NODE (xml));
- xml->xmlDecl = NULL;
- xml->docTypeDecl = NULL;
+ xml->xml_decl = NULL;
+ xml->doc_type_decl = NULL;
xml->status = XML_PARSE_STATUS_OK;
p = value;
node = SWFDEC_XML_NODE (xml);
// special case: we only use the ignoreWhite set at the start
- ignoreWhite = xml->ignoreWhite;
+ ignore_white = xml->ignore_white;
while (xml->status == XML_PARSE_STATUS_OK && *p != '\0') {
if (*p == '<') {
@@ -735,7 +737,7 @@ swfdec_xml_parseXML (SwfdecXml *xml, const char *value)
p = swfdec_xml_parse_tag (xml, &node, p);
}
} else {
- p = swfdec_xml_parse_text (xml, node, p, ignoreWhite);
+ p = swfdec_xml_parse_text (xml, node, p, ignore_white);
}
g_assert (p != NULL);
}
@@ -877,7 +879,7 @@ swfdec_xml_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
swfdec_xml_node_init_values (SWFDEC_XML_NODE (object),
SWFDEC_XML_NODE_ELEMENT, SWFDEC_AS_STR_EMPTY);
- SWFDEC_AS_VALUE_SET_STRING (&SWFDEC_XML (object)->contentType,
+ SWFDEC_AS_VALUE_SET_STRING (&SWFDEC_XML (object)->content_type,
SWFDEC_AS_STR_application_x_www_form_urlencoded);
SWFDEC_XML_NODE (object)->name = NULL;
@@ -912,12 +914,12 @@ swfdec_xml_new_no_properties (SwfdecAsContext *context, const char *str,
SWFDEC_AS_VALUE_GET_OBJECT (&val));
}
- xml->ignoreWhite = ignore_white;
+ xml->ignore_white = ignore_white;
swfdec_xml_node_init_values (SWFDEC_XML_NODE (xml),
SWFDEC_XML_NODE_ELEMENT, SWFDEC_AS_STR_EMPTY);
- SWFDEC_AS_VALUE_SET_STRING (&xml->contentType,
+ SWFDEC_AS_VALUE_SET_STRING (&xml->content_type,
SWFDEC_AS_STR_application_x_www_form_urlencoded);
if (str != NULL)
diff --git a/libswfdec/swfdec_xml.h b/libswfdec/swfdec_xml.h
index 6d5235f..3be92d5 100644
--- a/libswfdec/swfdec_xml.h
+++ b/libswfdec/swfdec_xml.h
@@ -54,12 +54,12 @@ typedef enum {
struct _SwfdecXml {
SwfdecXmlNode xml_node;
- gboolean ignoreWhite;
+ gboolean ignore_white;
int status;
- const char *xmlDecl;
- const char *docTypeDecl;
+ const char *xml_decl;
+ const char *doc_type_decl;
- SwfdecAsValue contentType;
+ SwfdecAsValue content_type;
SwfdecAsValue loaded;
};
diff --git a/libswfdec/swfdec_xml_node.c b/libswfdec/swfdec_xml_node.c
index 5c74870..b0d35aa 100644
--- a/libswfdec/swfdec_xml_node.c
+++ b/libswfdec/swfdec_xml_node.c
@@ -53,8 +53,8 @@ swfdec_xml_node_do_mark (SwfdecAsObject *object)
swfdec_as_object_mark (SWFDEC_AS_OBJECT (node->children));
if (node->attributes != NULL)
swfdec_as_object_mark (SWFDEC_AS_OBJECT (node->attributes));
- if (node->childNodes != NULL)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (node->childNodes));
+ if (node->child_nodes != NULL)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (node->child_nodes));
SWFDEC_AS_OBJECT_CLASS (swfdec_xml_node_parent_class)->mark (object);
}
@@ -120,7 +120,7 @@ swfdec_xml_node_index_of_child (SwfdecXmlNode *node, SwfdecXmlNode *child)
}
static void
-swfdec_xml_node_update_childNodes (SwfdecXmlNode *node)
+swfdec_xml_node_update_child_nodes (SwfdecXmlNode *node)
{
SwfdecAsValue val;
SwfdecAsValue *vals;
@@ -130,7 +130,7 @@ swfdec_xml_node_update_childNodes (SwfdecXmlNode *node)
// remove old
SWFDEC_AS_VALUE_SET_INT (&val, 0);
- swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (node->childNodes),
+ swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (node->child_nodes),
SWFDEC_AS_STR_length, &val);
// add everything
@@ -140,7 +140,7 @@ swfdec_xml_node_update_childNodes (SwfdecXmlNode *node)
SWFDEC_AS_VALUE_SET_OBJECT (&vals[i],
SWFDEC_AS_OBJECT (swfdec_xml_node_get_child (node, i)));
}
- swfdec_as_array_append_with_flags (node->childNodes, num, vals,
+ swfdec_as_array_append_with_flags (node->child_nodes, num, vals,
SWFDEC_AS_VARIABLE_CONSTANT);
g_free (vals);
}
@@ -555,7 +555,7 @@ swfdec_xml_node_get_childNodes (SwfdecAsContext *cx, SwfdecAsObject *object,
return;
SWFDEC_AS_VALUE_SET_OBJECT (ret,
- SWFDEC_AS_OBJECT (SWFDEC_XML_NODE (object)->childNodes));
+ SWFDEC_AS_OBJECT (SWFDEC_XML_NODE (object)->child_nodes));
}
SWFDEC_AS_NATIVE (253, 7, swfdec_xml_node_do_getNamespaceForPrefix)
@@ -660,7 +660,7 @@ swfdec_xml_node_clone (SwfdecAsContext *cx, SwfdecXmlNode *node, gboolean deep)
swfdec_as_array_push (new->children, &val);
}
- swfdec_xml_node_update_childNodes (new);
+ swfdec_xml_node_update_child_nodes (new);
}
return new;
@@ -704,7 +704,7 @@ swfdec_xml_node_removeNode (SwfdecXmlNode *node)
g_assert (i >= 0);
swfdec_as_array_remove (node->parent->children, i);
- swfdec_xml_node_update_childNodes (node->parent);
+ swfdec_xml_node_update_child_nodes (node->parent);
node->parent = NULL;
}
@@ -754,10 +754,10 @@ swfdec_xml_node_insertAt (SwfdecXmlNode *node, SwfdecXmlNode *child, gint32 ind)
// remove the previous parent of the child
swfdec_xml_node_removeNode (child);
- // insert child to node's childNodes array
+ // insert child to node's child_nodes array
SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (child));
swfdec_as_array_insert (node->children, ind, &val);
- swfdec_xml_node_update_childNodes (node);
+ swfdec_xml_node_update_child_nodes (node);
// set node as parent of child
child->parent = node;
@@ -891,10 +891,10 @@ swfdec_xml_node_toString (SwfdecXmlNode *node)
string = g_string_new ("");
if (SWFDEC_IS_XML (node)) {
- if (SWFDEC_XML (node)->xmlDecl != NULL)
- string = g_string_append (string, SWFDEC_XML (node)->xmlDecl);
- if (SWFDEC_XML (node)->docTypeDecl != NULL)
- string = g_string_append (string, SWFDEC_XML (node)->docTypeDecl);
+ if (SWFDEC_XML (node)->xml_decl != NULL)
+ string = g_string_append (string, SWFDEC_XML (node)->xml_decl);
+ if (SWFDEC_XML (node)->doc_type_decl != NULL)
+ string = g_string_append (string, SWFDEC_XML (node)->doc_type_decl);
}
switch (node->type) {
@@ -989,10 +989,10 @@ swfdec_xml_node_init_values (SwfdecXmlNode *node, int type, const char* value)
node->value = value;
}
- node->childNodes = SWFDEC_AS_ARRAY (swfdec_as_array_new (object->context));
+ node->child_nodes = SWFDEC_AS_ARRAY (swfdec_as_array_new (object->context));
if (node->children == NULL || node->attributes == NULL ||
- node->childNodes == NULL) {
+ node->child_nodes == NULL) {
node->valid = FALSE;
}
}
diff --git a/libswfdec/swfdec_xml_node.h b/libswfdec/swfdec_xml_node.h
index 3573a9d..7135613 100644
--- a/libswfdec/swfdec_xml_node.h
+++ b/libswfdec/swfdec_xml_node.h
@@ -71,7 +71,7 @@ struct _SwfdecXmlNode {
// visible trough childNodes property, if modified by the user directly, the
// changes are not visible in children and will get overwritten by next
// internal change
- SwfdecAsArray *childNodes;
+ SwfdecAsArray *child_nodes;
};
struct _SwfdecXmlNodeClass {
commit e6da5c25955dc814346d12ff7f7ccb7c65531155
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Jan 17 13:34:32 2008 +0200
Don't let changing ignoreWhite property while parsing XML have an effect
diff --git a/libswfdec/swfdec_xml.c b/libswfdec/swfdec_xml.c
index 00680a9..816443a 100644
--- a/libswfdec/swfdec_xml.c
+++ b/libswfdec/swfdec_xml.c
@@ -666,7 +666,7 @@ swfdec_xml_parse_tag (SwfdecXml *xml, SwfdecXmlNode **node, const char *p)
static const char *
swfdec_xml_parse_text (SwfdecXml *xml, SwfdecXmlNode *node,
- const char *p)
+ const char *p, gboolean ignoreWhite)
{
SwfdecXmlNode *child;
const char *end;
@@ -680,7 +680,7 @@ swfdec_xml_parse_text (SwfdecXml *xml, SwfdecXmlNode *node,
if (end == NULL)
end = strchr (p, '\0');
- if (!xml->ignoreWhite || strspn (p, " \t\r\n") < (gsize)(end - p))
+ if (!ignoreWhite || strspn (p, " \t\r\n") < (gsize)(end - p))
{
text = g_strndup (p, end - p);
unescaped = swfdec_xml_unescape (SWFDEC_AS_OBJECT (xml)->context, text);
@@ -705,6 +705,7 @@ swfdec_xml_parseXML (SwfdecXml *xml, const char *value)
SwfdecAsObject *object;
SwfdecXmlNode *node;
const char *p;
+ gboolean ignoreWhite;
g_return_if_fail (SWFDEC_IS_XML (xml));
g_return_if_fail (value != NULL);
@@ -719,6 +720,9 @@ swfdec_xml_parseXML (SwfdecXml *xml, const char *value)
p = value;
node = SWFDEC_XML_NODE (xml);
+ // special case: we only use the ignoreWhite set at the start
+ ignoreWhite = xml->ignoreWhite;
+
while (xml->status == XML_PARSE_STATUS_OK && *p != '\0') {
if (*p == '<') {
if (g_ascii_strncasecmp (p + 1, "?xml", strlen ("?xml")) == 0) {
@@ -731,7 +735,7 @@ swfdec_xml_parseXML (SwfdecXml *xml, const char *value)
p = swfdec_xml_parse_tag (xml, &node, p);
}
} else {
- p = swfdec_xml_parse_text (xml, node, p);
+ p = swfdec_xml_parse_text (xml, node, p, ignoreWhite);
}
g_assert (p != NULL);
}
commit 641bd37363b62386a8bd6310147c7a982e1e70fc
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Jan 17 12:31:14 2008 +0200
When adding attributes from XML tag, only add first one for each name
diff --git a/libswfdec/swfdec_xml.c b/libswfdec/swfdec_xml.c
index 2a5b72d..00680a9 100644
--- a/libswfdec/swfdec_xml.c
+++ b/libswfdec/swfdec_xml.c
@@ -498,8 +498,8 @@ static const char *
swfdec_xml_parse_attribute (SwfdecXml *xml, SwfdecXmlNode *node, const char *p)
{
SwfdecAsValue val;
- const char *end, *name, *value;
- char *text, *unescaped;
+ const char *end, *name;
+ char *text;
g_return_val_if_fail (SWFDEC_IS_XML (xml), strchr (p, '\0'));
g_return_val_if_fail (SWFDEC_IS_XML_NODE (node), strchr (p, '\0'));
@@ -538,13 +538,18 @@ swfdec_xml_parse_attribute (SwfdecXml *xml, SwfdecXmlNode *node, const char *p)
return strchr (p, '\0');
}
- unescaped = swfdec_xml_unescape_len (SWFDEC_AS_OBJECT (xml)->context, p + 1,
- end - (p + 1), TRUE);
- value = swfdec_as_context_give_string (SWFDEC_AS_OBJECT (node)->context,
- unescaped);
- SWFDEC_AS_VALUE_SET_STRING (&val, value);
+ if (!swfdec_as_object_get_variable (node->attributes, name, NULL)) {
+ char *unescaped;
+ const char *value;
+
+ unescaped = swfdec_xml_unescape_len (SWFDEC_AS_OBJECT (xml)->context,
+ p + 1, end - (p + 1), TRUE);
+ value = swfdec_as_context_give_string (SWFDEC_AS_OBJECT (node)->context,
+ unescaped);
+ SWFDEC_AS_VALUE_SET_STRING (&val, value);
- swfdec_as_object_set_variable (node->attributes, name, &val);
+ swfdec_as_object_set_variable (node->attributes, name, &val);
+ }
g_return_val_if_fail (end + 1 > p, strchr (p, '\0'));
commit 3e07fe3da575baff13e120a25371435f88350f29
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Jan 17 12:26:21 2008 +0200
Add the XML's id mapping later, after appending the child
diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index b57540d..0729919 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -484,5 +484,6 @@ const char swfdec_as_strings[] =
SWFDEC_AS_CONSTANT_STRING ("x")
SWFDEC_AS_CONSTANT_STRING ("y")
SWFDEC_AS_CONSTANT_STRING ("idMap")
+ SWFDEC_AS_CONSTANT_STRING ("id")
/* add more here */
;
diff --git a/libswfdec/swfdec_xml.c b/libswfdec/swfdec_xml.c
index 4b89a30..2a5b72d 100644
--- a/libswfdec/swfdec_xml.c
+++ b/libswfdec/swfdec_xml.c
@@ -546,9 +546,6 @@ swfdec_xml_parse_attribute (SwfdecXml *xml, SwfdecXmlNode *node, const char *p)
swfdec_as_object_set_variable (node->attributes, name, &val);
- if (!g_ascii_strcasecmp (name, "id") && value != SWFDEC_AS_STR_EMPTY)
- swfdec_xml_add_id_map (xml, node, value);
-
g_return_val_if_fail (end + 1 > p, strchr (p, '\0'));
return end + 1;
@@ -643,8 +640,14 @@ swfdec_xml_parse_tag (SwfdecXml *xml, SwfdecXmlNode **node, const char *p)
}
g_free (name);
} else {
+ const char *id;
+
swfdec_xml_node_appendChild (*node, child);
+ id = swfdec_xml_node_get_attribute (child, SWFDEC_AS_STR_id);
+ if (id != NULL)
+ swfdec_xml_add_id_map (xml, child, id);
+
if (*(end - 1) != '/')
*node = child;
}
commit 3d36d5b1c7556de6fbc7dd0b038882bb1abe6ee6
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Jan 17 12:18:00 2008 +0200
Implement adding id mappings when parsing XML
diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index 89896ce..b57540d 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -483,5 +483,6 @@ const char swfdec_as_strings[] =
SWFDEC_AS_CONSTANT_STRING ("w")
SWFDEC_AS_CONSTANT_STRING ("x")
SWFDEC_AS_CONSTANT_STRING ("y")
+ SWFDEC_AS_CONSTANT_STRING ("idMap")
/* add more here */
;
diff --git a/libswfdec/swfdec_xml.c b/libswfdec/swfdec_xml.c
index afcf618..4b89a30 100644
--- a/libswfdec/swfdec_xml.c
+++ b/libswfdec/swfdec_xml.c
@@ -462,6 +462,38 @@ swfdec_xml_parse_comment (SwfdecXml *xml, const char *p)
return end;
}
+static void
+swfdec_xml_add_id_map (SwfdecXml *xml, SwfdecXmlNode *node, const char *id)
+{
+ SwfdecAsObject *object;
+ SwfdecAsValue val;
+
+ g_return_if_fail (SWFDEC_IS_XML (xml));
+ g_return_if_fail (SWFDEC_IS_XML_NODE (xml));
+ g_return_if_fail (id != NULL && id != SWFDEC_AS_STR_EMPTY);
+
+ if (SWFDEC_AS_OBJECT (xml)->context->version >= 8) {
+ if (swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (xml),
+ SWFDEC_AS_STR_idMap, &val)) {
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
+ object = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ } else {
+ return;
+ }
+ } else {
+ object = swfdec_as_object_new_empty (SWFDEC_AS_OBJECT (xml)->context);
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
+ swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (xml),
+ SWFDEC_AS_STR_idMap, &val);
+ }
+ } else {
+ object = SWFDEC_AS_OBJECT (xml);
+ }
+
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (node));
+ swfdec_as_object_set_variable (object, id, &val);
+}
+
static const char *
swfdec_xml_parse_attribute (SwfdecXml *xml, SwfdecXmlNode *node, const char *p)
{
@@ -514,6 +546,9 @@ swfdec_xml_parse_attribute (SwfdecXml *xml, SwfdecXmlNode *node, const char *p)
swfdec_as_object_set_variable (node->attributes, name, &val);
+ if (!g_ascii_strcasecmp (name, "id") && value != SWFDEC_AS_STR_EMPTY)
+ swfdec_xml_add_id_map (xml, node, value);
+
g_return_val_if_fail (end + 1 > p, strchr (p, '\0'));
return end + 1;
commit c0531816972ede791f6673dbae99bf5c28b729d1
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Jan 17 11:27:17 2008 +0200
Enable non-breaking space part of xml-escape test for version 5 too
diff --git a/test/trace/xml-escape-5.swf b/test/trace/xml-escape-5.swf
index 78ad1d1..7d3cd18 100644
Binary files a/test/trace/xml-escape-5.swf and b/test/trace/xml-escape-5.swf differ
diff --git a/test/trace/xml-escape-5.swf.trace b/test/trace/xml-escape-5.swf.trace
index fd057c3..e1d12ad 100644
--- a/test/trace/xml-escape-5.swf.trace
+++ b/test/trace/xml-escape-5.swf.trace
@@ -3,3 +3,4 @@ te&lt;st
undefined
ma'ny
hmm&amp;hrr
+non breaking space: ÃÂ
diff --git a/test/trace/xml-escape.as b/test/trace/xml-escape.as
index db89bc6..48ca39d 100644
--- a/test/trace/xml-escape.as
+++ b/test/trace/xml-escape.as
@@ -8,9 +8,6 @@ trace (xmlEscape ("te<st"));
trace (xmlEscape ());
trace (xmlEscape ("ma'ny", "param&eters"));
trace (xmlEscape ("hmm&hrr"));
-// FIXME: Make it work in v5 too
-#if __SWF_VERSION__ > 5
trace (xmlEscape ("non breaking space: Â "));
-#endif
loadMovie ("FSCommand:quit", "");
More information about the Swfdec
mailing list