[Swfdec] 4 commits - libswfdec/swfdec_as_array.c libswfdec/swfdec_video_movie_as.c test/trace
Pekka Lampila
medar at kemper.freedesktop.org
Tue Sep 4 00:30:50 PDT 2007
libswfdec/swfdec_as_array.c | 15 ++-----
libswfdec/swfdec_video_movie_as.c | 10 +++--
test/trace/Makefile.am | 20 ++++++++++
test/trace/array-properties-5.swf |binary
test/trace/array-properties-5.swf.trace | 42 ++++++++++++++++++++++
test/trace/array2-5.swf |binary
test/trace/array2-5.swf.trace | 2 +
test/trace/array2-6.swf |binary
test/trace/array2-6.swf.trace | 2 +
test/trace/array2-7.swf |binary
test/trace/array2-7.swf.trace | 2 +
test/trace/array2.as | 7 +++
test/trace/asbroadcaster-properties-5.swf |binary
test/trace/asbroadcaster-properties-5.swf.trace | 2 +
test/trace/asfunction-properties-5.swf |binary
test/trace/asfunction-properties-5.swf.trace | 24 ++++++++++++
test/trace/boolean-properties-5.swf |binary
test/trace/boolean-properties-5.swf.trace | 12 ++++++
test/trace/function-properties-5.swf |binary
test/trace/function-properties-5.swf.trace | 7 +++
test/trace/global-function-properties-5.swf |binary
test/trace/global-function-properties-5.swf.trace | 14 +++++++
test/trace/global-variable-properties-5.swf |binary
test/trace/global-variable-properties-5.swf.trace | 3 +
test/trace/number-properties-5.swf |binary
test/trace/number-properties-5.swf.trace | 17 ++++++++
test/trace/trace_properties.as | 14 ++++---
test/trace/video-properties-5.swf |binary
test/trace/video-properties-5.swf.trace | 8 ++++
29 files changed, 182 insertions(+), 19 deletions(-)
New commits:
diff-tree 13df1826b6865f15a09f190b759613ba7693a35c (from 2c6e1bac0a0f2defa01a80e2c8b1316bfa9b60ec)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Tue Sep 4 10:30:17 2007 +0300
Expand array test to check changes in last commit.
diff --git a/test/trace/array2-5.swf b/test/trace/array2-5.swf
index 803ccac..50d48ba 100644
Binary files a/test/trace/array2-5.swf and b/test/trace/array2-5.swf differ
diff --git a/test/trace/array2-5.swf.trace b/test/trace/array2-5.swf.trace
index d3081e8..6768915 100644
--- a/test/trace/array2-5.swf.trace
+++ b/test/trace/array2-5.swf.trace
@@ -586,4 +586,6 @@ c,b,a
5: x:x:i:j:y
i,j,x,x,y
5: i:j:x:x:y
+[object Object]
+4, 3
[, , , , , , ]
diff --git a/test/trace/array2-6.swf b/test/trace/array2-6.swf
index 1d5c236..b9ab904 100644
Binary files a/test/trace/array2-6.swf and b/test/trace/array2-6.swf differ
diff --git a/test/trace/array2-6.swf.trace b/test/trace/array2-6.swf.trace
index bd63dd6..fc370f7 100644
--- a/test/trace/array2-6.swf.trace
+++ b/test/trace/array2-6.swf.trace
@@ -586,4 +586,6 @@ c,b,a
5: x:x:i:j:y
i,j,x,x,y
5: i:j:x:x:y
+[object Object]
+4, 3
## Done
diff --git a/test/trace/array2-7.swf b/test/trace/array2-7.swf
index e93a801..15090b1 100644
Binary files a/test/trace/array2-7.swf and b/test/trace/array2-7.swf differ
diff --git a/test/trace/array2-7.swf.trace b/test/trace/array2-7.swf.trace
index e51c513..1ebe055 100644
--- a/test/trace/array2-7.swf.trace
+++ b/test/trace/array2-7.swf.trace
@@ -586,4 +586,6 @@ c,b,a
5: x:x:i:j:y
i,j,x,x,y
5: i:j:x:x:y
+[object Object]
+4, 3
## Done
diff --git a/test/trace/array2.as b/test/trace/array2.as
index 237a156..4847af0 100644
--- a/test/trace/array2.as
+++ b/test/trace/array2.as
@@ -518,6 +518,13 @@ trace (fake.length + ": " + fake.join ("
trace (fake.sort ());
trace (fake.length + ": " + fake.join (":"));
+fake = new Object();
+fake.sort = Array.prototype.sort;
+fake[0] = 4;
+fake[1] = 3;
+trace (fake.sort ());
+trace (fake[0] + ", " + fake[1]);
+
mytrace ("## Done");
loadMovie ("FSCommand:quit", "");
diff-tree 2c6e1bac0a0f2defa01a80e2c8b1316bfa9b60ec (from 20f8453d82adc963b2afa898f921d94d2206f49c)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Tue Sep 4 10:29:32 2007 +0300
Re-enable Array.sort for normal objects.
Fix it and few others to work when there are index variables in the object that
are bigger than the length.
diff --git a/libswfdec/swfdec_as_array.c b/libswfdec/swfdec_as_array.c
index ff446d8..30cf22a 100644
--- a/libswfdec/swfdec_as_array.c
+++ b/libswfdec/swfdec_as_array.c
@@ -549,7 +549,7 @@ swfdec_as_array_foreach_reverse (SwfdecA
gint32 idx;
idx = swfdec_as_array_to_index (variable);
- if (idx == -1)
+ if (idx == -1 || idx >= *length)
return variable;
return swfdec_as_double_to_string (object->context, *length - 1 - idx);
@@ -761,7 +761,7 @@ swfdec_as_array_foreach_sort_rename (Swf
gboolean after_undefined = FALSE;
idx = swfdec_as_array_to_index (variable);
- if (idx == -1)
+ if (idx == -1 || idx >= fdata->length)
return variable;
if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
@@ -796,7 +796,7 @@ swfdec_as_array_foreach_sort_indexedarra
gboolean after_undefined = FALSE;
idx = swfdec_as_array_to_index (variable);
- if (idx == -1)
+ if (idx == -1 || idx >= fdata->length)
return TRUE;
if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
@@ -861,7 +861,7 @@ swfdec_as_array_foreach_sort_compare_und
gint32 idx;
idx = swfdec_as_array_to_index (variable);
- if (idx == -1)
+ if (idx == -1 || idx >= fdata->length)
return TRUE;
if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
@@ -886,7 +886,7 @@ swfdec_as_array_foreach_sort_populate (S
gint cval = -1;
idx = swfdec_as_array_to_index (variable);
- if (idx == -1)
+ if (idx == -1 || idx >= fdata->length)
return TRUE;
if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
@@ -943,11 +943,6 @@ swfdec_as_array_sort (SwfdecAsContext *c
ForeachSortData fdata;
guint pos;
- if (!SWFDEC_IS_AS_ARRAY (object)) {
- SWFDEC_FIXME ("Array.sort should work on non-array objects too");
- return;
- }
-
fdata.length = swfdec_as_array_get_length (object);
fdata.order_size =
MIN ((gint32)g_hash_table_size (object->properties) + 1, fdata.length + 1);
diff-tree 20f8453d82adc963b2afa898f921d94d2206f49c (from 519c526cc2ec5b2f367fed22d40d09125d4dfce0)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Tue Sep 4 10:09:17 2007 +0300
Don't add attachVideo and clear to the Video object in version 5
diff --git a/libswfdec/swfdec_video_movie_as.c b/libswfdec/swfdec_video_movie_as.c
index bde3a24..2edf5b4 100644
--- a/libswfdec/swfdec_video_movie_as.c
+++ b/libswfdec/swfdec_video_movie_as.c
@@ -74,10 +74,12 @@ swfdec_video_movie_init_context (SwfdecP
swfdec_as_object_set_variable_and_flags (video, SWFDEC_AS_STR_prototype, &val,
SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
/* set the right properties on the Video.prototype object */
- swfdec_as_object_add_function (proto, SWFDEC_AS_STR_attachVideo, SWFDEC_TYPE_VIDEO_MOVIE,
- swfdec_video_attach_video, 1);
- swfdec_as_object_add_function (proto, SWFDEC_AS_STR_clear, SWFDEC_TYPE_VIDEO_MOVIE,
- swfdec_video_clear, 0);
+ if (context->version >= 6) {
+ swfdec_as_object_add_function (proto, SWFDEC_AS_STR_attachVideo,
+ SWFDEC_TYPE_VIDEO_MOVIE, swfdec_video_attach_video, 1);
+ swfdec_as_object_add_function (proto, SWFDEC_AS_STR_clear,
+ SWFDEC_TYPE_VIDEO_MOVIE, swfdec_video_clear, 0);
+ }
SWFDEC_AS_VALUE_SET_OBJECT (&val, video);
swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
&val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
diff-tree 519c526cc2ec5b2f367fed22d40d09125d4dfce0 (from b8da9da8a7a5ebd58cb38cf4c981d809ad6fd5ab)
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Tue Sep 4 10:00:33 2007 +0300
Make trace_properties less eager to print errors on version 5.
Add v5 versions of various properties tests
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 7dec009..6c51380 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -96,8 +96,12 @@ EXTRA_DIST = \
array-new-override-7.swf \
array-new-override-7.swf.trace \
array-properties.as \
+ array-properties-5.swf \
+ array-properties-5.swf.trace \
array-properties-6.swf \
array-properties-6.swf.trace \
+ array-properties-7.swf \
+ array-properties-7.swf.trace \
array2.as \
array2-5.swf \
array2-5.swf.trace \
@@ -135,11 +139,15 @@ EXTRA_DIST = \
asbroadcaster-override-8.swf \
asbroadcaster-override-8.swf.trace \
asbroadcaster-properties.as \
+ asbroadcaster-properties-5.swf \
+ asbroadcaster-properties-5.swf.trace \
asbroadcaster-properties-6.swf \
asbroadcaster-properties-6.swf.trace \
asbroadcaster-properties-7.swf \
asbroadcaster-properties-7.swf.trace \
asfunction-properties.as \
+ asfunction-properties-5.swf \
+ asfunction-properties-5.swf.trace \
asfunction-properties-6.swf \
asfunction-properties-6.swf.trace \
asfunction-properties-7.swf \
@@ -179,6 +187,8 @@ EXTRA_DIST = \
bitwise-7.swf \
bitwise-7.swf.trace \
boolean-properties.as \
+ boolean-properties-5.swf \
+ boolean-properties-5.swf.trace \
boolean-properties-6.swf \
boolean-properties-6.swf.trace \
boolean-properties-7.swf \
@@ -459,6 +469,8 @@ EXTRA_DIST = \
function2.swf \
function2.swf.trace \
function-properties.as \
+ function-properties-5.swf \
+ function-properties-5.swf.trace \
function-properties-6.swf \
function-properties-6.swf.trace \
function-properties-7.swf \
@@ -489,11 +501,15 @@ EXTRA_DIST = \
forin-delete-7.swf \
forin-delete-7.swf.trace \
global-function-properties.as \
+ global-function-properties-5.swf \
+ global-function-properties-5.swf.trace \
global-function-properties-6.swf \
global-function-properties-6.swf.trace \
global-function-properties-7.swf \
global-function-properties-7.swf.trace \
global-variable-properties.as \
+ global-variable-properties-5.swf \
+ global-variable-properties-5.swf.trace \
global-variable-properties-6.swf \
global-variable-properties-6.swf.trace \
global-variable-properties-7.swf \
@@ -675,6 +691,8 @@ EXTRA_DIST = \
number.swf \
number.swf.trace \
number-properties.as \
+ number-properties-5.swf \
+ number-properties-5.swf.trace \
number-properties-6.swf \
number-properties-6.swf.trace \
number-properties-7.swf \
@@ -1331,6 +1349,8 @@ EXTRA_DIST = \
values.as \
video.flv \
video-properties.as \
+ video-properties-5.swf \
+ video-properties-5.swf.trace \
video-properties-6.swf \
video-properties-6.swf.trace \
video-properties-7.swf \
diff --git a/test/trace/array-properties-5.swf b/test/trace/array-properties-5.swf
new file mode 100644
index 0000000..21161e4
Binary files /dev/null and b/test/trace/array-properties-5.swf differ
diff --git a/test/trace/array-properties-5.swf.trace b/test/trace/array-properties-5.swf.trace
new file mode 100644
index 0000000..40928f9
--- /dev/null
+++ b/test/trace/array-properties-5.swf.trace
@@ -0,0 +1,42 @@
+_global.Array = function
+ CASEINSENSITIVE = number : 1
+ DESCENDING = number : 2
+ NUMERIC = number : 16
+ RETURNINDEXEDARRAY = number : 8
+ UNIQUESORT = number : 4
+ constructor (hp) = _global.Object.constructor
+ prototype (hp) = object
+ __proto__ (hp) = _global.Object.prototype
+ concat (hp) = function
+ constructor (hp) = _global.Object.constructor
+ constructor (hp) = _global.Array
+ join (hp) = function
+ constructor (hp) = _global.Object.constructor
+ pop (hp) = function
+ constructor (hp) = _global.Object.constructor
+ push (hp) = function
+ constructor (hp) = _global.Object.constructor
+ reverse (hp) = function
+ constructor (hp) = _global.Object.constructor
+ shift (hp) = function
+ constructor (hp) = _global.Object.constructor
+ slice (hp) = function
+ constructor (hp) = _global.Object.constructor
+ sort (hp) = function
+ constructor (hp) = _global.Object.constructor
+ sortOn (hp) = function
+ constructor (hp) = _global.Object.constructor
+ splice (hp) = function
+ constructor (hp) = _global.Object.constructor
+ toString (hp) = function
+ constructor (hp) = _global.Object.constructor
+ unshift (hp) = function
+ constructor (hp) = _global.Object.constructor
+local.a = _global.Array.prototype
+ __proto__ (hp) = _global.Array.prototype
+ constructor (h) = _global.Array
+ length (hp) = number : 0
+local.b = _global.Array.prototype
+ __proto__ (hp) = _global.Array.prototype
+ constructor (hp) = _global.Array
+ length (hp) = number : 0
diff --git a/test/trace/asbroadcaster-properties-5.swf b/test/trace/asbroadcaster-properties-5.swf
new file mode 100644
index 0000000..d090a3e
Binary files /dev/null and b/test/trace/asbroadcaster-properties-5.swf differ
diff --git a/test/trace/asbroadcaster-properties-5.swf.trace b/test/trace/asbroadcaster-properties-5.swf.trace
new file mode 100644
index 0000000..a815e43
--- /dev/null
+++ b/test/trace/asbroadcaster-properties-5.swf.trace
@@ -0,0 +1,2 @@
+_global.AsBroadcaster = function
+ no children
diff --git a/test/trace/asfunction-properties-5.swf b/test/trace/asfunction-properties-5.swf
new file mode 100644
index 0000000..97853b7
Binary files /dev/null and b/test/trace/asfunction-properties-5.swf differ
diff --git a/test/trace/asfunction-properties-5.swf.trace b/test/trace/asfunction-properties-5.swf.trace
new file mode 100644
index 0000000..b7fcc06
--- /dev/null
+++ b/test/trace/asfunction-properties-5.swf.trace
@@ -0,0 +1,24 @@
+_global.ASconstructor = function
+ no children
+_global.ASnative = function
+ no children
+_global.ASSetNativeAccessor = function
+ constructor (hp) = _global.Object.constructor
+_global.ASSetNative = function
+ constructor (hp) = _global.Object.constructor
+_global.ASSetPropFlags = function
+ constructor (hp) = _global.Object.constructor
+local.a = function
+ constructor (hp) = _global.Object.constructor
+ prototype (hp) = object
+ __proto__ (hp) = _global.Object.prototype
+ constructor (hp) = local.a
+local.b = function
+ constructor (hp) = _global.Object.constructor
+local.c = function
+ constructor (hp) = _global.Object.constructor
+ prototype (hp) = object
+ __proto__ (hp) = _global.Object.prototype
+ constructor (hp) = local.c
+local.d = function
+ constructor (hp) = _global.Object.constructor
diff --git a/test/trace/boolean-properties-5.swf b/test/trace/boolean-properties-5.swf
new file mode 100644
index 0000000..ac296c8
Binary files /dev/null and b/test/trace/boolean-properties-5.swf differ
diff --git a/test/trace/boolean-properties-5.swf.trace b/test/trace/boolean-properties-5.swf.trace
new file mode 100644
index 0000000..524a383
--- /dev/null
+++ b/test/trace/boolean-properties-5.swf.trace
@@ -0,0 +1,12 @@
+_global.Boolean = function
+ constructor (hp) = _global.Object.constructor
+ prototype (hp) = object
+ __proto__ (hp) = _global.Object.prototype
+ constructor (hp) = _global.Boolean
+ toString (hp) = function
+ constructor (hp) = _global.Object.constructor
+ valueOf (hp) = function
+ constructor (hp) = _global.Object.constructor
+local.a = _global.Boolean.prototype
+ constructor (h) = _global.Boolean
+local.b = boolean : true
diff --git a/test/trace/function-properties-5.swf b/test/trace/function-properties-5.swf
new file mode 100644
index 0000000..9afc703
Binary files /dev/null and b/test/trace/function-properties-5.swf differ
diff --git a/test/trace/function-properties-5.swf.trace b/test/trace/function-properties-5.swf.trace
new file mode 100644
index 0000000..01a6e36
--- /dev/null
+++ b/test/trace/function-properties-5.swf.trace
@@ -0,0 +1,7 @@
+_global.Function = undefined
+local.a = object
+ myFunction = function
+ constructor (hp) = _global.Object.constructor
+ prototype (hp) = object
+ __proto__ (hp) = _global.Object.prototype
+ constructor (hp) = local.a.myFunction
diff --git a/test/trace/global-function-properties-5.swf b/test/trace/global-function-properties-5.swf
new file mode 100644
index 0000000..aac581a
Binary files /dev/null and b/test/trace/global-function-properties-5.swf differ
diff --git a/test/trace/global-function-properties-5.swf.trace b/test/trace/global-function-properties-5.swf.trace
new file mode 100644
index 0000000..3252305
--- /dev/null
+++ b/test/trace/global-function-properties-5.swf.trace
@@ -0,0 +1,14 @@
+_global.clearInterval = function
+ constructor (hp) = _global.Object.constructor
+_global.escape = function
+ constructor (hp) = _global.Object.constructor
+_global.isFinite = function
+ constructor (hp) = _global.Object.constructor
+_global.isNaN = function
+ constructor (hp) = _global.Object.constructor
+_global.parseInt = function
+ constructor (hp) = _global.Object.constructor
+_global.setInterval = function
+ constructor (hp) = _global.Object.constructor
+_global.unescape = function
+ constructor (hp) = _global.Object.constructor
diff --git a/test/trace/global-variable-properties-5.swf b/test/trace/global-variable-properties-5.swf
new file mode 100644
index 0000000..8a5bc86
Binary files /dev/null and b/test/trace/global-variable-properties-5.swf differ
diff --git a/test/trace/global-variable-properties-5.swf.trace b/test/trace/global-variable-properties-5.swf.trace
new file mode 100644
index 0000000..a11c582
--- /dev/null
+++ b/test/trace/global-variable-properties-5.swf.trace
@@ -0,0 +1,3 @@
+_global.Infinity = number : Infinity
+_global.NaN = number : NaN
+_global.o = null
diff --git a/test/trace/number-properties-5.swf b/test/trace/number-properties-5.swf
new file mode 100644
index 0000000..a0398ec
Binary files /dev/null and b/test/trace/number-properties-5.swf differ
diff --git a/test/trace/number-properties-5.swf.trace b/test/trace/number-properties-5.swf.trace
new file mode 100644
index 0000000..55e0b11
--- /dev/null
+++ b/test/trace/number-properties-5.swf.trace
@@ -0,0 +1,17 @@
+_global.Number = function
+ MAX_VALUE (hpc) = number : 1.79769313486231e+308
+ MIN_VALUE (hpc) = number : 0
+ NEGATIVE_INFINITY (hpc) = number : -Infinity
+ NaN (hpc) = number : NaN
+ POSITIVE_INFINITY (hpc) = number : Infinity
+ constructor (hpc) = _global.Object.constructor
+ prototype (hpc) = object
+ __proto__ (hp) = _global.Object.prototype
+ constructor (hp) = _global.Number
+ toString (hp) = function
+ constructor (hp) = _global.Object.constructor
+ valueOf (hp) = function
+ constructor (hp) = _global.Object.constructor
+local.a = _global.Number.prototype
+ constructor (h) = _global.Number
+local.b = number : 42
diff --git a/test/trace/trace_properties.as b/test/trace/trace_properties.as
index 3925bdb..bcd0a08 100644
--- a/test/trace/trace_properties.as
+++ b/test/trace/trace_properties.as
@@ -112,8 +112,9 @@ function hasOwnProperty (o, prop)
o.__proto__ = "to-be-deleted";
delete o.__proto__;
if (o.__proto__ != undefined) {
- trace ("ERROR: Couldn't delete temporary __proto__");
o.__proto__ = undefined;
+ if (o.__proto__ != undefined)
+ trace ("ERROR: Couldn't delete temporary __proto__");
}
return result;
@@ -133,8 +134,8 @@ function hasOwnProperty (o, prop)
if (o[prop] != o.__proto__[prop]) {
return true;
} else {
- trace ("ERROR: can't test property '" + prop +
- "', __proto__ has superconstant version");
+ //trace ("ERROR: can't test property '" + prop +
+ // "', __proto__ has superconstant version");
return false;
}
}
@@ -168,8 +169,11 @@ function hasOwnProperty (o, prop)
ASSetPropFlags (o, prop, 0, 4);
o.__proto__[prop] = "to-be-deleted";
delete o.__proto__[prop];
- if (o.__proto__[prop] != undefined)
- trace ("ERROR: Couldn't delete temporary __proto__[\"" + prop + "\"]");
+ if (o.__proto__[prop] != undefined) {
+ o.__proto__[prop] = undefined;
+ if (o.__proto__[prop] != undefined)
+ trace ("ERROR: Couldn't delete temporary __proto__[\"" + prop + "\"]");
+ }
return result;
}
diff --git a/test/trace/video-properties-5.swf b/test/trace/video-properties-5.swf
new file mode 100644
index 0000000..204f511
Binary files /dev/null and b/test/trace/video-properties-5.swf differ
diff --git a/test/trace/video-properties-5.swf.trace b/test/trace/video-properties-5.swf.trace
new file mode 100644
index 0000000..4ad6273
--- /dev/null
+++ b/test/trace/video-properties-5.swf.trace
@@ -0,0 +1,8 @@
+_global.Video = function
+ constructor (hp) = _global.Object.constructor
+ prototype (hp) = object
+ __proto__ (hp) = _global.Object.prototype
+ constructor (hp) = _global.Video
+local.a = _global.Video.prototype
+ __proto__ (hp) = _global.Video.prototype
+ constructor (h) = _global.Video
More information about the Swfdec
mailing list