Benjamin Otte
2007-Sep-03 15:38 UTC
[Swfdec] 4 commits - libswfdec/swfdec_as_boolean.c libswfdec/swfdec_as_boolean.h libswfdec/swfdec_as_context.c libswfdec/swfdec_as_initialize.as libswfdec/swfdec_as_initialize.h libswfdec/swfdec_as_interpret.c test/trace
libswfdec/swfdec_as_boolean.c | 49 ++++++++--------------- libswfdec/swfdec_as_boolean.h | 3 - libswfdec/swfdec_as_context.c | 2 libswfdec/swfdec_as_initialize.as | 4 + libswfdec/swfdec_as_initialize.h | 58 +++++++++++++++------------- libswfdec/swfdec_as_interpret.c | 44 +++++++++++++++++---- test/trace/Makefile.am | 9 ++++ test/trace/foreach-proto-simple-5.swf |binary test/trace/foreach-proto-simple-5.swf.trace | 4 + test/trace/foreach-proto-simple-6.swf |binary test/trace/foreach-proto-simple-6.swf.trace | 4 + test/trace/foreach-proto-simple-7.swf |binary test/trace/foreach-proto-simple-7.swf.trace | 4 + test/trace/foreach-proto-simple-8.swf |binary test/trace/foreach-proto-simple-8.swf.trace | 4 + test/trace/foreach-proto-simple.as | 17 ++++++++ test/trace/trace.c | 1 17 files changed, 133 insertions(+), 70 deletions(-) New commits: diff-tree b8da9da8a7a5ebd58cb38cf4c981d809ad6fd5ab (from e4f9bfc6dbbf8aefe0cef9d4c9d8f000931ace9e) Author: Benjamin Otte <otte at gnome.org> Date: Mon Sep 3 17:37:55 2007 +0200 init Boolean class via script diff --git a/libswfdec/swfdec_as_boolean.c b/libswfdec/swfdec_as_boolean.c index 5d3a90b..6764cbe 100644 --- a/libswfdec/swfdec_as_boolean.c +++ b/libswfdec/swfdec_as_boolean.c @@ -28,6 +28,7 @@ #include "swfdec_as_native_function.h" #include "swfdec_as_strings.h" #include "swfdec_debug.h" +#include "swfdec_player_internal.h" G_DEFINE_TYPE (SwfdecAsBoolean, swfdec_as_boolean, SWFDEC_TYPE_AS_OBJECT) @@ -43,7 +44,8 @@ swfdec_as_boolean_init (SwfdecAsBoolean /*** AS CODE ***/ -static void +SWFDEC_AS_CONSTRUCTOR (107, 2, swfdec_as_boolean_construct, swfdec_as_boolean_get_type) +void swfdec_as_boolean_construct (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret) { @@ -63,48 +65,31 @@ swfdec_as_boolean_construct (SwfdecAsCon } } -static void +SWFDEC_AS_NATIVE (107, 1, swfdec_as_boolean_toString) +void swfdec_as_boolean_toString (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret) { - SwfdecAsBoolean *b = SWFDEC_AS_BOOLEAN (object); + SwfdecAsBoolean *b; + + if (!SWFDEC_IS_AS_BOOLEAN (object)) + return; + b = SWFDEC_AS_BOOLEAN (object); SWFDEC_AS_VALUE_SET_STRING (ret, b->boolean ? SWFDEC_AS_STR_true : SWFDEC_AS_STR_false); } -static void +SWFDEC_AS_NATIVE (107, 0, swfdec_as_boolean_valueOf) +void swfdec_as_boolean_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret) { - SwfdecAsBoolean *b = SWFDEC_AS_BOOLEAN (object); - - SWFDEC_AS_VALUE_SET_BOOLEAN (ret, b->boolean); -} - -void -swfdec_as_boolean_init_context (SwfdecAsContext *context, guint version) -{ - SwfdecAsObject *boolean, *proto; - SwfdecAsValue val; + SwfdecAsBoolean *b; - g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context)); - - proto = swfdec_as_object_new_empty (context); - if (proto == NULL) - return; - boolean = SWFDEC_AS_OBJECT (swfdec_as_object_add_constructor (context->global, - SWFDEC_AS_STR_Boolean, 0, SWFDEC_TYPE_AS_BOOLEAN, - swfdec_as_boolean_construct, 0, proto)); - if (!boolean) + if (!SWFDEC_IS_AS_BOOLEAN (object)) return; - /* set the right properties on the Boolean.prototype object */ - SWFDEC_AS_VALUE_SET_OBJECT (&val, boolean); - swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor, - &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT); - swfdec_as_object_add_function (proto, SWFDEC_AS_STR_toString, SWFDEC_TYPE_AS_BOOLEAN, swfdec_as_boolean_toString, 0); - swfdec_as_object_add_function (proto, SWFDEC_AS_STR_valueOf, SWFDEC_TYPE_AS_BOOLEAN, swfdec_as_boolean_valueOf, 0); - SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype); - swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR___proto__, &val, - SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT); + b = SWFDEC_AS_BOOLEAN (object); + + SWFDEC_AS_VALUE_SET_BOOLEAN (ret, b->boolean); } diff --git a/libswfdec/swfdec_as_boolean.h b/libswfdec/swfdec_as_boolean.h index 16bdebd..723f076 100644 --- a/libswfdec/swfdec_as_boolean.h +++ b/libswfdec/swfdec_as_boolean.h @@ -47,9 +47,6 @@ struct _SwfdecAsBooleanClass { GType swfdec_as_boolean_get_type (void); -void swfdec_as_boolean_init_context (SwfdecAsContext * context, - guint version); - G_END_DECLS #endif diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c index 3b0ec12..3ce9356 100644 --- a/libswfdec/swfdec_as_context.c +++ b/libswfdec/swfdec_as_context.c @@ -25,7 +25,6 @@ #include <string.h> #include "swfdec_as_context.h" #include "swfdec_as_array.h" -#include "swfdec_as_boolean.h" #include "swfdec_as_frame_internal.h" #include "swfdec_as_function.h" #include "swfdec_as_initialize.h" @@ -1227,7 +1226,6 @@ swfdec_as_context_startup (SwfdecAsConte swfdec_as_context_init_global (context, version); swfdec_as_array_init_context (context, version); /* define the type objects */ - swfdec_as_boolean_init_context (context, version); swfdec_as_string_init_context (context, version); /* define the rest */ swfdec_as_math_init_context (context, version); diff --git a/libswfdec/swfdec_as_initialize.as b/libswfdec/swfdec_as_initialize.as index 4085c91..8ded5bb 100644 --- a/libswfdec/swfdec_as_initialize.as +++ b/libswfdec/swfdec_as_initialize.as @@ -24,6 +24,10 @@ ASSetNativeAccessor = ASnative (4, 1); /*** BASE OBJECTS ***/ +Boolean = ASconstructor(107, 2); +ASSetNative(Boolean.prototype, 107, "valueOf,toString"); +ASSetPropFlags(Boolean.prototype, null, 3); + Number = ASconstructor (106, 2); ASSetNative (Number.prototype, 106, "valueOf,toString"); ASSetPropFlags(Number.prototype, null, 3); diff --git a/libswfdec/swfdec_as_initialize.h b/libswfdec/swfdec_as_initialize.h index 64fd129..fec8c25 100644 --- a/libswfdec/swfdec_as_initialize.h +++ b/libswfdec/swfdec_as_initialize.h @@ -2,32 +2,38 @@ /* compiled from swfdec_as_initialize.as */ const unsigned char swfdec_as_initialize[] = { - 0x88, 0xAF, 0x00, 0x0E, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74, 0x4E, 0x61, 0x74, 0x69, 0x76, 0x65, + 0x88, 0xB7, 0x00, 0x0F, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74, 0x4E, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00, 0x41, 0x53, 0x6E, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74, 0x4E, - 0x61, 0x74, 0x69, 0x76, 0x65, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6F, 0x72, 0x00, 0x4E, 0x75, - 0x6D, 0x62, 0x65, 0x72, 0x00, 0x41, 0x53, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, - 0x6F, 0x72, 0x00, 0x70, 0x72, 0x6F, 0x74, 0x6F, 0x74, 0x79, 0x70, 0x65, 0x00, 0x76, 0x61, 0x6C, - 0x75, 0x65, 0x4F, 0x66, 0x2C, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x41, 0x53, - 0x53, 0x65, 0x74, 0x50, 0x72, 0x6F, 0x70, 0x46, 0x6C, 0x61, 0x67, 0x73, 0x00, 0x4E, 0x61, 0x4E, - 0x00, 0x50, 0x4F, 0x53, 0x49, 0x54, 0x49, 0x56, 0x45, 0x5F, 0x49, 0x4E, 0x46, 0x49, 0x4E, 0x49, - 0x54, 0x59, 0x00, 0x49, 0x6E, 0x66, 0x69, 0x6E, 0x69, 0x74, 0x79, 0x00, 0x4E, 0x45, 0x47, 0x41, - 0x54, 0x49, 0x56, 0x45, 0x5F, 0x49, 0x4E, 0x46, 0x49, 0x4E, 0x49, 0x54, 0x59, 0x00, 0x4D, 0x49, - 0x4E, 0x5F, 0x56, 0x41, 0x4C, 0x55, 0x45, 0x00, 0x4D, 0x41, 0x58, 0x5F, 0x56, 0x41, 0x4C, 0x55, - 0x45, 0x00, 0x96, 0x13, 0x00, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, 0x00, - 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x02, 0x07, - 0x01, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, - 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x03, 0x07, 0x02, 0x00, 0x00, 0x00, 0x07, 0x6A, 0x00, 0x00, - 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04, 0x3D, 0x1D, 0x96, 0x09, 0x00, 0x08, 0x06, 0x07, - 0x6A, 0x00, 0x00, 0x00, 0x08, 0x03, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x05, 0x4E, 0x96, 0x07, 0x00, - 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, - 0x00, 0x02, 0x08, 0x03, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x05, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, - 0x00, 0x00, 0x00, 0x08, 0x07, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x03, 0x1C, 0x96, 0x04, 0x00, - 0x08, 0x08, 0x08, 0x08, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x03, 0x1C, 0x96, 0x04, 0x00, 0x08, - 0x09, 0x08, 0x0A, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x03, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x0B, - 0x08, 0x0A, 0x1C, 0x96, 0x05, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x0C, 0x4F, 0x96, 0x02, 0x00, - 0x08, 0x03, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x0C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, - 0x00, 0x08, 0x03, 0x1C, 0x96, 0x0B, 0x00, 0x08, 0x0D, 0x06, 0xFF, 0xFF, 0xEF, 0x7F, 0xE2, 0xFF, - 0xFF, 0xFF, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x03, 0x1C, 0x96, - 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x07, 0x3D, 0x17, 0x00 + 0x61, 0x74, 0x69, 0x76, 0x65, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6F, 0x72, 0x00, 0x42, 0x6F, + 0x6F, 0x6C, 0x65, 0x61, 0x6E, 0x00, 0x41, 0x53, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x72, 0x75, 0x63, + 0x74, 0x6F, 0x72, 0x00, 0x70, 0x72, 0x6F, 0x74, 0x6F, 0x74, 0x79, 0x70, 0x65, 0x00, 0x76, 0x61, + 0x6C, 0x75, 0x65, 0x4F, 0x66, 0x2C, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x41, + 0x53, 0x53, 0x65, 0x74, 0x50, 0x72, 0x6F, 0x70, 0x46, 0x6C, 0x61, 0x67, 0x73, 0x00, 0x4E, 0x75, + 0x6D, 0x62, 0x65, 0x72, 0x00, 0x4E, 0x61, 0x4E, 0x00, 0x50, 0x4F, 0x53, 0x49, 0x54, 0x49, 0x56, + 0x45, 0x5F, 0x49, 0x4E, 0x46, 0x49, 0x4E, 0x49, 0x54, 0x59, 0x00, 0x49, 0x6E, 0x66, 0x69, 0x6E, + 0x69, 0x74, 0x79, 0x00, 0x4E, 0x45, 0x47, 0x41, 0x54, 0x49, 0x56, 0x45, 0x5F, 0x49, 0x4E, 0x46, + 0x49, 0x4E, 0x49, 0x54, 0x59, 0x00, 0x4D, 0x49, 0x4E, 0x5F, 0x56, 0x41, 0x4C, 0x55, 0x45, 0x00, + 0x4D, 0x41, 0x58, 0x5F, 0x56, 0x41, 0x4C, 0x55, 0x45, 0x00, 0x96, 0x13, 0x00, 0x08, 0x00, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, + 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x02, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, 0x00, + 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x03, 0x07, + 0x02, 0x00, 0x00, 0x00, 0x07, 0x6B, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04, + 0x3D, 0x1D, 0x96, 0x09, 0x00, 0x08, 0x06, 0x07, 0x6B, 0x00, 0x00, 0x00, 0x08, 0x03, 0x1C, 0x96, + 0x02, 0x00, 0x08, 0x05, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, + 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x03, 0x1C, 0x96, 0x02, 0x00, + 0x08, 0x05, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x07, 0x3D, 0x17, 0x96, + 0x13, 0x00, 0x08, 0x08, 0x07, 0x02, 0x00, 0x00, 0x00, 0x07, 0x6A, 0x00, 0x00, 0x00, 0x07, 0x02, + 0x00, 0x00, 0x00, 0x08, 0x04, 0x3D, 0x1D, 0x96, 0x09, 0x00, 0x08, 0x06, 0x07, 0x6A, 0x00, 0x00, + 0x00, 0x08, 0x08, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x05, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, + 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, + 0x08, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x05, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, + 0x08, 0x07, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x08, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x09, 0x08, + 0x09, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x08, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x0A, 0x08, 0x0B, + 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x08, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x0C, 0x08, 0x0B, 0x1C, + 0x96, 0x05, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x0C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x08, 0x1C, + 0x96, 0x07, 0x00, 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x08, + 0x1C, 0x96, 0x0B, 0x00, 0x08, 0x0E, 0x06, 0xFF, 0xFF, 0xEF, 0x7F, 0xE2, 0xFF, 0xFF, 0xFF, 0x4F, + 0x96, 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x08, 0x1C, 0x96, 0x07, 0x00, 0x07, + 0x03, 0x00, 0x00, 0x00, 0x08, 0x07, 0x3D, 0x17, 0x00 }; diff-tree e4f9bfc6dbbf8aefe0cef9d4c9d8f000931ace9e (from e33c93491cd56f9db52b0390106b2340b7f34e89) Author: Benjamin Otte <otte at gnome.org> Date: Mon Sep 3 17:37:20 2007 +0200 check that prototype properties get included in foreach diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am index 70c60e3..7dec009 100644 --- a/test/trace/Makefile.am +++ b/test/trace/Makefile.am @@ -438,6 +438,15 @@ EXTRA_DIST = \ extends-simple.swf.trace \ extends-super.swf \ extends-super.swf.trace \ + foreach-proto-simple.as \ + foreach-proto-simple-5.swf \ + foreach-proto-simple-5.swf.trace \ + foreach-proto-simple-6.swf \ + foreach-proto-simple-6.swf.trace \ + foreach-proto-simple-7.swf \ + foreach-proto-simple-7.swf.trace \ + foreach-proto-simple-8.swf \ + foreach-proto-simple-8.swf.trace \ fromcharcode.as \ fromcharcode-5.swf \ fromcharcode-5.swf.trace \ diff --git a/test/trace/foreach-proto-simple-5.swf b/test/trace/foreach-proto-simple-5.swf new file mode 100644 index 0000000..16b6c92 Binary files /dev/null and b/test/trace/foreach-proto-simple-5.swf differ diff --git a/test/trace/foreach-proto-simple-5.swf.trace b/test/trace/foreach-proto-simple-5.swf.trace new file mode 100644 index 0000000..635389b --- /dev/null +++ b/test/trace/foreach-proto-simple-5.swf.trace @@ -0,0 +1,4 @@ +Run for in loop with properties on parent +x +y +z diff --git a/test/trace/foreach-proto-simple-6.swf b/test/trace/foreach-proto-simple-6.swf new file mode 100644 index 0000000..1a57e04 Binary files /dev/null and b/test/trace/foreach-proto-simple-6.swf differ diff --git a/test/trace/foreach-proto-simple-6.swf.trace b/test/trace/foreach-proto-simple-6.swf.trace new file mode 100644 index 0000000..635389b --- /dev/null +++ b/test/trace/foreach-proto-simple-6.swf.trace @@ -0,0 +1,4 @@ +Run for in loop with properties on parent +x +y +z diff --git a/test/trace/foreach-proto-simple-7.swf b/test/trace/foreach-proto-simple-7.swf new file mode 100644 index 0000000..e1c7b0c Binary files /dev/null and b/test/trace/foreach-proto-simple-7.swf differ diff --git a/test/trace/foreach-proto-simple-7.swf.trace b/test/trace/foreach-proto-simple-7.swf.trace new file mode 100644 index 0000000..635389b --- /dev/null +++ b/test/trace/foreach-proto-simple-7.swf.trace @@ -0,0 +1,4 @@ +Run for in loop with properties on parent +x +y +z diff --git a/test/trace/foreach-proto-simple-8.swf b/test/trace/foreach-proto-simple-8.swf new file mode 100644 index 0000000..0bcbaee Binary files /dev/null and b/test/trace/foreach-proto-simple-8.swf differ diff --git a/test/trace/foreach-proto-simple-8.swf.trace b/test/trace/foreach-proto-simple-8.swf.trace new file mode 100644 index 0000000..635389b --- /dev/null +++ b/test/trace/foreach-proto-simple-8.swf.trace @@ -0,0 +1,4 @@ +Run for in loop with properties on parent +x +y +z diff --git a/test/trace/foreach-proto-simple.as b/test/trace/foreach-proto-simple.as new file mode 100644 index 0000000..f04edf3 --- /dev/null +++ b/test/trace/foreach-proto-simple.as @@ -0,0 +1,17 @@ +// makeswf -v 7 -s 200x150 -r 1 -o foreach-proto-simple.swf foreach-proto-simple.as + +trace ("Run for in loop with properties on parent"); +o = new Object (); +o.z = 42; +p = new Object; +p.y = 21; +p.__proto__ = o; +o.x = 842; +a = []; +for (i in p) + a.push (i); +a.sort(); +for (i = 0; i < a.length; i++) + trace (a[i]); + +loadMovie ("FSCommand:quit", ""); diff-tree e33c93491cd56f9db52b0390106b2340b7f34e89 (from 649c77ee37b7d290023c20b546b3b6a29a390359) Author: Benjamin Otte <otte at gnome.org> Date: Mon Sep 3 17:36:17 2007 +0200 make enumerate actions include prototype stuff diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c index 32613a2..fcbd035 100644 --- a/libswfdec/swfdec_as_interpret.c +++ b/libswfdec/swfdec_as_interpret.c @@ -1896,19 +1896,49 @@ fail: } static gboolean -swfdec_action_do_enumerate (SwfdecAsObject *object, const char *variable, - SwfdecAsValue *value, guint flags, gpointer cxp) +swfdec_action_enumerate_foreach (SwfdecAsObject *object, const char *variable, + SwfdecAsValue *value, guint flags, gpointer listp) { - SwfdecAsContext *cx = cxp; + GSList **list = listp; if (flags & SWFDEC_AS_VARIABLE_HIDDEN) return TRUE; - swfdec_as_stack_ensure_free (cx, 1); - SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_push (cx), variable); + + *list = g_slist_remove (*list, variable); + *list = g_slist_prepend (*list, (gpointer) variable); return TRUE; } static void +swfdec_action_do_enumerate (SwfdecAsContext *cx, SwfdecAsObject *object) +{ + guint i; + GSList *walk, *list = NULL; + + for (i = 0; i < 256 && object; i++) { + swfdec_as_object_foreach (object, swfdec_action_enumerate_foreach, &list); + object = object->prototype; + } + if (i == 256) { + swfdec_as_context_abort (object->context, "Prototype recursion limit exceeded"); + g_slist_free (list); + return; + } + list = g_slist_reverse (list); + i = 0; + for (walk = list; walk; walk = walk->next) { + /* 8 is an arbitrary value */ + if (i % 8 == 0) { + swfdec_as_stack_ensure_free (cx, 8); + i = 0; + } + i++; + SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_push (cx), walk->data); + } + g_slist_free (list); +} + +static void swfdec_action_enumerate (SwfdecAsContext *cx, guint action, const guint8 *data, guint len) { SwfdecAsValue *val; @@ -1924,7 +1954,7 @@ swfdec_action_enumerate (SwfdecAsContext } obj = SWFDEC_AS_VALUE_GET_OBJECT (val); SWFDEC_AS_VALUE_SET_NULL (val); - swfdec_as_object_foreach (obj, swfdec_action_do_enumerate, cx); + swfdec_action_do_enumerate (cx, obj); } static void @@ -1941,7 +1971,7 @@ swfdec_action_enumerate2 (SwfdecAsContex } obj = SWFDEC_AS_VALUE_GET_OBJECT (val); SWFDEC_AS_VALUE_SET_NULL (val); - swfdec_as_object_foreach (obj, swfdec_action_do_enumerate, cx); + swfdec_action_do_enumerate (cx, obj); } static void diff-tree 649c77ee37b7d290023c20b546b3b6a29a390359 (from 635b7b3bfceaa763cd502b478f122b39c27bd040) Author: Benjamin Otte <otte at gnome.org> Date: Mon Sep 3 17:34:36 2007 +0200 fix memleak diff --git a/test/trace/trace.c b/test/trace/trace.c index f42fb0f..bd31799 100644 --- a/test/trace/trace.c +++ b/test/trace/trace.c @@ -175,6 +175,7 @@ run_test (gpointer testp, gpointer unuse g_error_free (error); } else { g_string_append (output, result); + g_free (result); } } g_string_free (string, TRUE);
Seemingly Similar Threads
- 9 commits - libswfdec/swfdec_as_function.c libswfdec/swfdec_as_initialize.as libswfdec/swfdec_as_initialize.h libswfdec/swfdec_as_object.c libswfdec/swfdec_as_strings.c libswfdec/swfdec_player_as.c test/trace
- 8 commits - libswfdec/swfdec_as_function.c libswfdec/swfdec_as_initialize.as libswfdec/swfdec_as_initialize.h libswfdec/swfdec_as_object.c libswfdec/swfdec_as_strings.c test/trace
- 20 commits - libswfdec/Makefile.am libswfdec/swfdec_as_context.c libswfdec/swfdec_as_function.c libswfdec/swfdec_as_initialize.as libswfdec/swfdec_as_initialize.h libswfdec/swfdec_as_internal.h libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_number.c
- 3 commits - libswfdec/swfdec_as_function.c libswfdec/swfdec_as_initialize.as libswfdec/swfdec_as_initialize.h libswfdec/swfdec_as_object.c
- 5 commits - libswfdec/swfdec_as_array.c libswfdec/swfdec_as_boolean.c libswfdec/swfdec_as_function.c libswfdec/swfdec_as_math.c libswfdec/swfdec_as_number.c libswfdec/swfdec_as_script_function.c libswfdec/swfdec_initialize.as libswfdec/swfdec_initialize.h