Benjamin Otte
2007-Jun-05 20:20 UTC
[Swfdec] Branch 'as' - 8 commits - libswfdec/Makefile.am libswfdec/swfdec_as_context.c libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_frame.h libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_number.c libswfdec/swfdec_as_scope.h libswfdec/swfdec_as_script_function.c libswfdec/swfdec_as_with.c libswfdec/swfdec_as_with.h libswfdec/swfdec_button_movie.c libswfdec/swfdec_mouse_as.c libswfdec/swfdec_movie.c libswfdec/swfdec_player.c libswfdec/swfdec_root_movie.c libswfdec/swfdec_root_movie.h libswfdec/swfdec_sprite_movie_as.c libswfdec/swfdec_sprite_movie.c player/swfdec_debug_movies.c test/trace
libswfdec/Makefile.am | 2 libswfdec/swfdec_as_context.c | 6 libswfdec/swfdec_as_frame.c | 32 ++++- libswfdec/swfdec_as_frame.h | 5 libswfdec/swfdec_as_interpret.c | 33 ++++- libswfdec/swfdec_as_number.c | 7 - libswfdec/swfdec_as_scope.h | 2 libswfdec/swfdec_as_script_function.c | 1 libswfdec/swfdec_as_with.c | 133 +++++++++++++++++++++ libswfdec/swfdec_as_with.h | 56 ++++++++ libswfdec/swfdec_button_movie.c | 2 libswfdec/swfdec_mouse_as.c | 4 libswfdec/swfdec_movie.c | 30 ++-- libswfdec/swfdec_player.c | 1 libswfdec/swfdec_root_movie.c | 13 +- libswfdec/swfdec_root_movie.h | 2 libswfdec/swfdec_sprite_movie.c | 8 - libswfdec/swfdec_sprite_movie_as.c | 9 - player/swfdec_debug_movies.c | 4 test/trace/Makefile.am | 23 +++ test/trace/jump-into-with.as | 20 +++ test/trace/jump-into-with.swf |binary test/trace/jump-into-with.swf.trace | 21 +++ test/trace/jump-out-and-back-into-with-2.as | 22 +++ test/trace/jump-out-and-back-into-with-2.swf |binary test/trace/jump-out-and-back-into-with-2.swf.trace | 22 +++ test/trace/jump-out-and-back-into-with-3.as | 26 ++++ test/trace/jump-out-and-back-into-with-3.swf |binary test/trace/jump-out-and-back-into-with-3.swf.trace | 13 ++ test/trace/jump-out-and-back-into-with-4.as | 23 +++ test/trace/jump-out-and-back-into-with-4.swf |binary test/trace/jump-out-and-back-into-with-4.swf.trace | 13 ++ test/trace/jump-out-and-back-into-with-5.as | 26 ++++ test/trace/jump-out-and-back-into-with-5.swf |binary test/trace/jump-out-and-back-into-with-5.swf.trace | 22 +++ test/trace/jump-out-and-back-into-with.as | 23 +++ test/trace/jump-out-and-back-into-with.swf |binary test/trace/jump-out-and-back-into-with.swf.trace | 4 test/trace/jump-out-of-with.as | 20 +++ test/trace/jump-out-of-with.swf |binary test/trace/jump-out-of-with.swf.trace | 41 ++++++ 41 files changed, 617 insertions(+), 52 deletions(-) New commits: diff-tree 777b3d0c598129177ec806335ba681b41fd1d239 (from 945e8d45a71407e1c8579f8bc4906bc9b78f34ab) Author: Benjamin Otte <otte at gnome.org> Date: Tue Jun 5 22:21:47 2007 +0200 Add various tests for With action note that these tests' swf files are binary modified to get the right jumps diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am index 800eda2..dd0ea9b 100644 --- a/test/trace/Makefile.am +++ b/test/trace/Makefile.am @@ -193,6 +193,7 @@ EXTRA_DIST = \ isnan-6.swf \ isnan-6.swf.trace \ isnan-7.swf \ + isnan-7.swf.trace \ if.as \ if-5.swf \ if-5.swf.trace \ @@ -200,7 +201,27 @@ EXTRA_DIST = \ if-6.swf.trace \ if-7.swf \ if-7.swf.trace \ - isnan-7.swf.trace \ + jump-into-with.as \ + jump-into-with.swf \ + jump-into-with.swf.trace \ + jump-out-and-back-into-with.as \ + jump-out-and-back-into-with.swf \ + jump-out-and-back-into-with.swf.trace \ + jump-out-and-back-into-with-2.as \ + jump-out-and-back-into-with-2.swf \ + jump-out-and-back-into-with-2.swf.trace \ + jump-out-and-back-into-with-3.as \ + jump-out-and-back-into-with-3.swf \ + jump-out-and-back-into-with-3.swf.trace \ + jump-out-and-back-into-with-4.as \ + jump-out-and-back-into-with-4.swf \ + jump-out-and-back-into-with-4.swf.trace \ + jump-out-and-back-into-with-5.as \ + jump-out-and-back-into-with-5.swf \ + jump-out-and-back-into-with-5.swf.trace \ + jump-out-of-with.as \ + jump-out-of-with.swf \ + jump-out-of-with.swf.trace \ lifetime1.swf \ lifetime1.swf.trace \ load-4.swf \ diff --git a/test/trace/jump-into-with.as b/test/trace/jump-into-with.as new file mode 100644 index 0000000..7f83c51 --- /dev/null +++ b/test/trace/jump-into-with.as @@ -0,0 +1,20 @@ +// makeswf -v 7 -s 200x150 -r 1 -o movie68.swf movie68.as + +// note that the real checks are binary-modified to produce the desired tests. +// The branch offsets have been adjusted. +trace ("Check various things when jumping into with commands"); +x = 0; +o = new Object (); +o.x = -1; +with (o) { + trace (x); +} +trace (x); +x++; +if (x < 10) { + asm { + branchalways "hi" + }; +} + +loadMovie ("FSCommand:quit", ""); diff --git a/test/trace/jump-into-with.swf b/test/trace/jump-into-with.swf new file mode 100644 index 0000000..2baaeb5 Binary files /dev/null and b/test/trace/jump-into-with.swf differ diff --git a/test/trace/jump-into-with.swf.trace b/test/trace/jump-into-with.swf.trace new file mode 100644 index 0000000..260afc1 --- /dev/null +++ b/test/trace/jump-into-with.swf.trace @@ -0,0 +1,21 @@ +Check various things when jumping into with commands +-1 +0 +1 +1 +2 +2 +3 +3 +4 +4 +5 +5 +6 +6 +7 +7 +8 +8 +9 +9 diff --git a/test/trace/jump-out-and-back-into-with-2.as b/test/trace/jump-out-and-back-into-with-2.as new file mode 100644 index 0000000..4f45223 --- /dev/null +++ b/test/trace/jump-out-and-back-into-with-2.as @@ -0,0 +1,22 @@ +// makeswf -v 7 -s 200x150 -r 1 -o movie68.swf movie68.as + +// note that the real checks are binary-modified to produce the desired tests. +// The branch offsets have been adjusted. +trace ("Check how jumping out of a With and back in works"); +x = 0; +o = new Object (); +o.x = -10; +with (o) { + trace (x); + x++; + if (x > 10) { + asm { + branchalways "hi" + }; + } +} +asm { + branchalways "hi" +}; + +loadMovie ("FSCommand:quit", ""); diff --git a/test/trace/jump-out-and-back-into-with-2.swf b/test/trace/jump-out-and-back-into-with-2.swf new file mode 100644 index 0000000..309a4cd Binary files /dev/null and b/test/trace/jump-out-and-back-into-with-2.swf differ diff --git a/test/trace/jump-out-and-back-into-with-2.swf.trace b/test/trace/jump-out-and-back-into-with-2.swf.trace new file mode 100644 index 0000000..9e08aab --- /dev/null +++ b/test/trace/jump-out-and-back-into-with-2.swf.trace @@ -0,0 +1,22 @@ +Check how jumping out of a With and back in works +-10 +-9 +-8 +-7 +-6 +-5 +-4 +-3 +-2 +-1 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 diff --git a/test/trace/jump-out-and-back-into-with-3.as b/test/trace/jump-out-and-back-into-with-3.as new file mode 100644 index 0000000..ca620ac --- /dev/null +++ b/test/trace/jump-out-and-back-into-with-3.as @@ -0,0 +1,26 @@ +// makeswf -v 7 -s 200x150 -r 1 -o movie68.swf movie68.as + +// note that the real checks are binary-modified to produce the desired tests. +// The branch offsets have been adjusted. +trace ("Check how jumping out of a With and back in works"); +x = 0; +o = new Object (); +o.x = -10; +with (o) { + trace (x); + x++; + if (x > 10) { + asm { + branchalways "hi" + }; + } + asm { + push "hi" + }; +} +asm { + trace + branchalways "hi" +}; + +loadMovie ("FSCommand:quit", ""); diff --git a/test/trace/jump-out-and-back-into-with-3.swf b/test/trace/jump-out-and-back-into-with-3.swf new file mode 100644 index 0000000..890e735 Binary files /dev/null and b/test/trace/jump-out-and-back-into-with-3.swf differ diff --git a/test/trace/jump-out-and-back-into-with-3.swf.trace b/test/trace/jump-out-and-back-into-with-3.swf.trace new file mode 100644 index 0000000..8fb9392 --- /dev/null +++ b/test/trace/jump-out-and-back-into-with-3.swf.trace @@ -0,0 +1,13 @@ +Check how jumping out of a With and back in works +-10 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 diff --git a/test/trace/jump-out-and-back-into-with-4.as b/test/trace/jump-out-and-back-into-with-4.as new file mode 100644 index 0000000..83fdacb --- /dev/null +++ b/test/trace/jump-out-and-back-into-with-4.as @@ -0,0 +1,23 @@ +// makeswf -v 7 -s 200x150 -r 1 -o movie68.swf movie68.as + +// note that the real checks are binary-modified to produce the desired tests. +// The branch offsets have been adjusted. +trace ("Check how jumping out of a With and back in works"); +x = 0; +o = new Object (); +o.x = -10; +with (o) { + trace (x); + x++; + if (x > 10) { + asm { + branchalways "hi" + }; + }; +}; +asm { + stop + branchalways "hi" +}; + +loadMovie ("FSCommand:quit", ""); diff --git a/test/trace/jump-out-and-back-into-with-4.swf b/test/trace/jump-out-and-back-into-with-4.swf new file mode 100644 index 0000000..dc68c2e Binary files /dev/null and b/test/trace/jump-out-and-back-into-with-4.swf differ diff --git a/test/trace/jump-out-and-back-into-with-4.swf.trace b/test/trace/jump-out-and-back-into-with-4.swf.trace new file mode 100644 index 0000000..8fb9392 --- /dev/null +++ b/test/trace/jump-out-and-back-into-with-4.swf.trace @@ -0,0 +1,13 @@ +Check how jumping out of a With and back in works +-10 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 diff --git a/test/trace/jump-out-and-back-into-with-5.as b/test/trace/jump-out-and-back-into-with-5.as new file mode 100644 index 0000000..2d27dbc --- /dev/null +++ b/test/trace/jump-out-and-back-into-with-5.as @@ -0,0 +1,26 @@ +// makeswf -v 7 -s 200x150 -r 1 -o movie68.swf movie68.as + +// note that the real checks are binary-modified to produce the desired tests. +// The branch offsets have been adjusted. +trace ("Check how jumping out of a With and back in works"); +x = 0; +o = new Object (); +o.x = -10; +with (o) { + trace (x); + x++; + if (x > 10) { + asm { + push 0 + }; + } else { + asm { + push 1 + }; + } +}; +asm { + branchiftrue "hi" +}; + +loadMovie ("FSCommand:quit", ""); diff --git a/test/trace/jump-out-and-back-into-with-5.swf b/test/trace/jump-out-and-back-into-with-5.swf new file mode 100644 index 0000000..94956e4 Binary files /dev/null and b/test/trace/jump-out-and-back-into-with-5.swf differ diff --git a/test/trace/jump-out-and-back-into-with-5.swf.trace b/test/trace/jump-out-and-back-into-with-5.swf.trace new file mode 100644 index 0000000..9e08aab --- /dev/null +++ b/test/trace/jump-out-and-back-into-with-5.swf.trace @@ -0,0 +1,22 @@ +Check how jumping out of a With and back in works +-10 +-9 +-8 +-7 +-6 +-5 +-4 +-3 +-2 +-1 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 diff --git a/test/trace/jump-out-and-back-into-with.as b/test/trace/jump-out-and-back-into-with.as new file mode 100644 index 0000000..5ded997 --- /dev/null +++ b/test/trace/jump-out-and-back-into-with.as @@ -0,0 +1,23 @@ +// makeswf -v 7 -s 200x150 -r 1 -o movie68.swf movie68.as + +// note that the real checks are binary-modified to produce the desired tests. +// The branch offsets have been adjusted. +trace ("Check how jumping out of a With and back in works"); +x = 0; +o = new Object (); +o.x = -1; +with (o) { + trace (x); + asm { + branchalways "hi" + }; + trace (x); +} +if (0) { + trace ("hi"); + asm { + branchalways "hi" + }; +} + +loadMovie ("FSCommand:quit", ""); diff --git a/test/trace/jump-out-and-back-into-with.swf b/test/trace/jump-out-and-back-into-with.swf new file mode 100644 index 0000000..b0871d7 Binary files /dev/null and b/test/trace/jump-out-and-back-into-with.swf differ diff --git a/test/trace/jump-out-and-back-into-with.swf.trace b/test/trace/jump-out-and-back-into-with.swf.trace new file mode 100644 index 0000000..a25ecad --- /dev/null +++ b/test/trace/jump-out-and-back-into-with.swf.trace @@ -0,0 +1,4 @@ +Check how jumping out of a With and back in works +-1 +hi +0 diff --git a/test/trace/jump-out-of-with.as b/test/trace/jump-out-of-with.as new file mode 100644 index 0000000..83170b9 --- /dev/null +++ b/test/trace/jump-out-of-with.as @@ -0,0 +1,20 @@ +// makeswf -v 7 -s 200x150 -r 1 -o movie68.swf movie68.as + +// note that the real checks are binary-modified to produce the desired tests. +// The branch offsets have been adjusted. +trace ("Check how jumping out of a With works"); +x = 0; +o = new Object (); +o.x = -10; +trace (x); +with (o) { + trace (x); + x++; + if (x < 10) { + asm { + branchalways "hi" + }; + } +}; + +loadMovie ("FSCommand:quit", ""); diff --git a/test/trace/jump-out-of-with.swf b/test/trace/jump-out-of-with.swf new file mode 100644 index 0000000..987e10a Binary files /dev/null and b/test/trace/jump-out-of-with.swf differ diff --git a/test/trace/jump-out-of-with.swf.trace b/test/trace/jump-out-of-with.swf.trace new file mode 100644 index 0000000..9f97a38 --- /dev/null +++ b/test/trace/jump-out-of-with.swf.trace @@ -0,0 +1,41 @@ +Check how jumping out of a With works +0 +-10 +0 +-9 +0 +-8 +0 +-7 +0 +-6 +0 +-5 +0 +-4 +0 +-3 +0 +-2 +0 +-1 +0 +0 +0 +1 +0 +2 +0 +3 +0 +4 +0 +5 +0 +6 +0 +7 +0 +8 +0 +9 diff-tree 945e8d45a71407e1c8579f8bc4906bc9b78f34ab (from 2351e7d7d1dd6269ead9447fe49de3163e174de2) Author: Benjamin Otte <otte at gnome.org> Date: Tue Jun 5 22:18:22 2007 +0200 Add With action This includes a With object, lots of code to jump out of scope at the right time and various other modifications to make With a reality diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am index d701d51..68350fc 100644 --- a/libswfdec/Makefile.am +++ b/libswfdec/Makefile.am @@ -47,6 +47,7 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES swfdec_as_strings.c \ swfdec_as_super.c \ swfdec_as_types.c \ + swfdec_as_with.c \ swfdec_amf.c \ swfdec_audio.c \ swfdec_audio_event.c \ @@ -151,6 +152,7 @@ noinst_HEADERS = \ swfdec_as_strings.h \ swfdec_as_super.h \ swfdec_as_types.h \ + swfdec_as_with.h \ swfdec_amf.h \ swfdec_audio_internal.h \ swfdec_audio_event.h \ diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c index d899d1e..c10a5ea 100644 --- a/libswfdec/swfdec_as_context.c +++ b/libswfdec/swfdec_as_context.c @@ -402,6 +402,7 @@ swfdec_as_context_run (SwfdecAsContext * int version; SwfdecAsContextClass *klass; void (* step) (SwfdecAsContext *context); + gboolean check_scope; /* some opcodes avoid a scope check */ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context)); if (context->frame == NULL) @@ -437,6 +438,7 @@ start: startpc = script->buffer->data; endpc = startpc + script->buffer->length; pc = frame->pc; + check_scope = TRUE; while (TRUE) { if (pc == endpc) { @@ -447,6 +449,8 @@ start: SWFDEC_ERROR ("pc %p not in valid range [%p, %p) anymore", pc, startpc, endpc); goto error; } + if (check_scope) + swfdec_as_frame_check_scope (frame); /* decode next action */ action = *pc; @@ -508,8 +512,10 @@ start: /* FIXME: do this via flag? */ if (frame->pc == pc) { frame->pc = pc = nextpc; + check_scope = TRUE; } else { pc = frame->pc; + check_scope = FALSE; } if (frame == context->frame) { #ifndef G_DISABLE_ASSERT diff --git a/libswfdec/swfdec_as_frame.c b/libswfdec/swfdec_as_frame.c index b36e1e4..de18973 100644 --- a/libswfdec/swfdec_as_frame.c +++ b/libswfdec/swfdec_as_frame.c @@ -122,7 +122,7 @@ swfdec_as_frame_new (SwfdecAsContext *co SWFDEC_DEBUG ("new frame for function %s", frame->function_name); frame->pc = script->buffer->data; frame->stack = stack; - frame->scope = NULL; + frame->scope = SWFDEC_AS_SCOPE (frame); if (frame->next) frame->var_object = frame->next->var_object; frame->n_registers = script->n_registers; @@ -202,7 +202,7 @@ swfdec_as_frame_find_variable (SwfdecAsF g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL); g_return_val_if_fail (variable != NULL, NULL); - cur = SWFDEC_AS_SCOPE (frame); + cur = frame->scope; for (i = 0; i < 256; i++) { ret = swfdec_as_object_find_variable (SWFDEC_AS_OBJECT (cur), variable); if (ret) @@ -348,3 +348,31 @@ swfdec_as_frame_preload (SwfdecAsFrame * } } } + +/** + * swfdec_as_frame_check_scope: + * @frame: a #SwfdecAsFrame + * + * Checks that the current scope of the given @frame is still correct. + * If it is not, the current scope is popped and the next one is used. + * If the + **/ +void +swfdec_as_frame_check_scope (SwfdecAsFrame *frame) +{ + SwfdecAsScope *frame_scope; + + g_return_if_fail (SWFDEC_IS_AS_FRAME (frame)); + + frame_scope = SWFDEC_AS_SCOPE (frame); + while (frame->scope != frame_scope) { + SwfdecAsScope *cur = frame->scope; + + if (frame->pc >= cur->startpc && + frame->pc < cur->endpc) + break; + + frame->scope = cur->next; + } +} + diff --git a/libswfdec/swfdec_as_frame.h b/libswfdec/swfdec_as_frame.h index c0c2d71..c2423e3 100644 --- a/libswfdec/swfdec_as_frame.h +++ b/libswfdec/swfdec_as_frame.h @@ -42,11 +42,11 @@ struct _SwfdecAsFrame { SwfdecAsFunction * function; /* function we're executing or NULL if toplevel */ SwfdecAsObject * thisp; /* this object in current frame or NULL if none */ gboolean construct; /* TRUE if this is the constructor for thisp */ - /* debugging */ - char * function_name; /* name of function */ SwfdecAsValue * return_value; /* pointer to where to store the return value */ guint argc; /* number of arguments */ const SwfdecAsValue * argv; /* arguments */ + /* debugging */ + char * function_name; /* name of function */ /* normal execution */ SwfdecScript * script; /* script being executed */ SwfdecAsScope * scope; /* first object in scope chain (can be NULL) */ @@ -79,6 +79,7 @@ SwfdecAsObject *swfdec_as_frame_find_var void swfdec_as_frame_set_target (SwfdecAsFrame * frame, SwfdecAsObject * target); +void swfdec_as_frame_check_scope (SwfdecAsFrame * frame); G_END_DECLS diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c index 8cf7966..f1898a1 100644 --- a/libswfdec/swfdec_as_interpret.c +++ b/libswfdec/swfdec_as_interpret.c @@ -27,6 +27,7 @@ #include "swfdec_as_function.h" #include "swfdec_as_script_function.h" #include "swfdec_as_stack.h" +#include "swfdec_as_with.h" #include "swfdec_debug.h" #include <errno.h> @@ -55,8 +56,7 @@ swfdec_action_get_target (SwfdecAsContex SwfdecAsObject *target = context->frame->target; if (target == NULL) { - SwfdecAsScope *scope = context->frame->scope ? - context->frame->scope : SWFDEC_AS_SCOPE (context->frame); + SwfdecAsScope *scope = context->frame->scope; while (scope->next) scope = scope->next; g_assert (SWFDEC_IS_AS_FRAME (scope)); @@ -1945,9 +1945,36 @@ swfdec_action_mb_ascii_to_char_5 (Swfdec } } +static void +swfdec_action_with (SwfdecAsContext *cx, guint action, const guint8 *data, guint len) +{ + SwfdecAsObject *object; + + if (len != 2) { + SWFDEC_ERROR ("With action requires a length of 2, but got %u", len); + return; + } + object = swfdec_as_value_to_object (cx, swfdec_as_stack_pop (cx->frame->stack)); + if (object == NULL) { + SWFDEC_ERROR ("With called without an object"); + return; + } + swfdec_as_with_new (object, data + len, GUINT16_FROM_LE (*(guint16 *) data)); +} + /*** PRINT FUNCTIONS ***/ static char * +swfdec_action_print_with (guint action, const guint8 *data, guint len) +{ + if (len != 2) { + SWFDEC_ERROR ("With action requires a length of 2, but got %u", len); + return NULL; + } + return g_strdup_printf ("With %u", GUINT16_FROM_LE (*(guint16 *) data)); +} + +static char * swfdec_action_print_store_register (guint action, const guint8 *data, guint len) { if (len != 1) { @@ -2344,7 +2371,7 @@ const SwfdecActionSpec swfdec_as_actions [SWFDEC_AS_ACTION_DEFINE_FUNCTION2] = { "DefineFunction2", swfdec_action_print_define_function, 0, -1, { NULL, NULL, NULL, swfdec_action_define_function, swfdec_action_define_function } }, [SWFDEC_AS_ACTION_TRY] = { "Try", NULL }, /* version 5 */ - [SWFDEC_AS_ACTION_WITH] = { "With", NULL }, + [SWFDEC_AS_ACTION_WITH] = { "With", swfdec_action_print_with, 1, 0, { NULL, NULL, swfdec_action_with, swfdec_action_with, swfdec_action_with } }, /* version 4 */ [SWFDEC_AS_ACTION_PUSH] = { "Push", swfdec_action_print_push, 0, -1, { NULL, swfdec_action_push, swfdec_action_push, swfdec_action_push, swfdec_action_push } }, [SWFDEC_AS_ACTION_JUMP] = { "Jump", swfdec_action_print_jump, 0, 0, { NULL, swfdec_action_jump, swfdec_action_jump, swfdec_action_jump, swfdec_action_jump } }, diff --git a/libswfdec/swfdec_as_scope.h b/libswfdec/swfdec_as_scope.h index d0a4c89..7c32e02 100644 --- a/libswfdec/swfdec_as_scope.h +++ b/libswfdec/swfdec_as_scope.h @@ -40,6 +40,8 @@ struct _SwfdecAsScope { /*< private >*/ SwfdecAsScope * next; /* next scope or NULL if last */ + const guint8 * startpc; /* start of this scope */ + const guint8 * endpc; /* end of this scope */ }; struct _SwfdecAsScopeClass { diff --git a/libswfdec/swfdec_as_script_function.c b/libswfdec/swfdec_as_script_function.c index 14873d1..2144816 100644 --- a/libswfdec/swfdec_as_script_function.c +++ b/libswfdec/swfdec_as_script_function.c @@ -37,7 +37,6 @@ swfdec_as_script_function_call (SwfdecAs frame = swfdec_as_frame_new (SWFDEC_AS_OBJECT (function)->context, script->script); SWFDEC_AS_SCOPE (frame)->next = script->scope; - frame->scope = SWFDEC_AS_SCOPE (frame); frame->function = function; return frame; } diff --git a/libswfdec/swfdec_as_with.c b/libswfdec/swfdec_as_with.c new file mode 100644 index 0000000..b5c6ce1 --- /dev/null +++ b/libswfdec/swfdec_as_with.c @@ -0,0 +1,133 @@ +/* Swfdec + * Copyright (C) 2007 Benjamin Otte <otte at gnome.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "swfdec_as_with.h" +#include "swfdec_as_context.h" +#include "swfdec_as_frame.h" +#include "swfdec_debug.h" + +G_DEFINE_TYPE (SwfdecAsWith, swfdec_as_with, SWFDEC_TYPE_AS_SCOPE) + +static void +swfdec_as_with_mark (SwfdecAsObject *object) +{ + SwfdecAsWith *with = SWFDEC_AS_WITH (object); + + swfdec_as_object_mark (with->object); + + SWFDEC_AS_OBJECT_CLASS (swfdec_as_with_parent_class)->mark (object); +} + +static gboolean +swfdec_as_with_get (SwfdecAsObject *object, const char *variable, + SwfdecAsValue *val, guint *flags) +{ + SwfdecAsWith *with = SWFDEC_AS_WITH (object); + SwfdecAsObjectClass *klass = SWFDEC_AS_OBJECT_GET_CLASS (with->object); + + return klass->get (with->object, variable, val, flags); +} + +static void +swfdec_as_with_set (SwfdecAsObject *object, const char *variable, + const SwfdecAsValue *val) +{ + SwfdecAsWith *with = SWFDEC_AS_WITH (object); + SwfdecAsObjectClass *klass = SWFDEC_AS_OBJECT_GET_CLASS (with->object); + + klass->set (with->object, variable, val); +} + +static void +swfdec_as_with_set_flags (SwfdecAsObject *object, const char *variable, + guint flags, guint mask) +{ + SwfdecAsWith *with = SWFDEC_AS_WITH (object); + SwfdecAsObjectClass *klass = SWFDEC_AS_OBJECT_GET_CLASS (with->object); + + klass->set_flags (with->object, variable, flags, mask); +} + +static void +swfdec_as_with_delete (SwfdecAsObject *object, const char *variable) +{ + SwfdecAsWith *with = SWFDEC_AS_WITH (object); + SwfdecAsObjectClass *klass = SWFDEC_AS_OBJECT_GET_CLASS (with->object); + + klass->delete (with->object, variable); +} + +static gboolean +swfdec_as_with_foreach (SwfdecAsObject *object, SwfdecAsVariableForeach func, + gpointer data) +{ + SwfdecAsWith *with = SWFDEC_AS_WITH (object); + SwfdecAsObjectClass *klass = SWFDEC_AS_OBJECT_GET_CLASS (with->object); + + return klass->foreach (with->object, func, data); +} + +static void +swfdec_as_with_class_init (SwfdecAsWithClass *klass) +{ + SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass); + + asobject_class->mark = swfdec_as_with_mark; + asobject_class->get = swfdec_as_with_get; + asobject_class->set = swfdec_as_with_set; + asobject_class->set_flags = swfdec_as_with_set_flags; + asobject_class->delete = swfdec_as_with_delete; + asobject_class->foreach = swfdec_as_with_foreach; +} + +static void +swfdec_as_with_init (SwfdecAsWith *with) +{ +} + +SwfdecAsScope * +swfdec_as_with_new (SwfdecAsObject *object, const guint8 *startpc, guint n_bytes) +{ + SwfdecAsContext *context; + SwfdecAsFrame *frame; + SwfdecAsScope *scope; + SwfdecAsWith *with; + + g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL); + + context = object->context; + if (!swfdec_as_context_use_mem (context, sizeof (SwfdecAsWith))) + return NULL; + with = g_object_new (SWFDEC_TYPE_AS_WITH, NULL); + swfdec_as_object_add (SWFDEC_AS_OBJECT (with), context, sizeof (SwfdecAsWith)); + scope = SWFDEC_AS_SCOPE (with); + frame = context->frame; + with->object = object; + scope->startpc = startpc; + scope->endpc = startpc + n_bytes; + scope->next = frame->scope; + frame->scope = scope; + + return scope; +} + diff --git a/libswfdec/swfdec_as_with.h b/libswfdec/swfdec_as_with.h new file mode 100644 index 0000000..1d24d07 --- /dev/null +++ b/libswfdec/swfdec_as_with.h @@ -0,0 +1,56 @@ +/* Swfdec + * Copyright (C) 2007 Benjamin Otte <otte at gnome.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifndef _SWFDEC_AS_WITH_H_ +#define _SWFDEC_AS_WITH_H_ + +#include <libswfdec/swfdec_as_scope.h> +#include <libswfdec/swfdec_as_types.h> + +G_BEGIN_DECLS + +typedef struct _SwfdecAsWith SwfdecAsWith; +typedef struct _SwfdecAsWithClass SwfdecAsWithClass; + +#define SWFDEC_TYPE_AS_WITH (swfdec_as_with_get_type()) +#define SWFDEC_IS_AS_WITH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_WITH)) +#define SWFDEC_IS_AS_WITH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_WITH)) +#define SWFDEC_AS_WITH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_WITH, SwfdecAsWith)) +#define SWFDEC_AS_WITH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_WITH, SwfdecAsWithClass)) +#define SWFDEC_AS_WITH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_WITH, SwfdecAsWithClass)) + +struct _SwfdecAsWith { + SwfdecAsScope scope; + + /*< private >*/ + SwfdecAsObject * object; /* the object of this With context */ +}; + +struct _SwfdecAsWithClass { + SwfdecAsScopeClass scope_class; +}; + +GType swfdec_as_with_get_type (void); + +SwfdecAsScope * swfdec_as_with_new (SwfdecAsObject * object, + const guint8 * startpc, + guint n_bytes); + +G_END_DECLS +#endif diff-tree 2351e7d7d1dd6269ead9447fe49de3163e174de2 (from 5edf0a4e83374e21222b949a4aed0b0d3b8f0e2a) Author: Benjamin Otte <otte at gnome.org> Date: Tue Jun 5 13:53:49 2007 +0200 fix debugger bits for removal of SwfdecRootMovie.player diff --git a/player/swfdec_debug_movies.c b/player/swfdec_debug_movies.c index 14e4281..30d758a 100644 --- a/player/swfdec_debug_movies.c +++ b/player/swfdec_debug_movies.c @@ -126,7 +126,7 @@ swfdec_debug_movies_movie_to_path (Swfde path = swfdec_debug_movies_movie_to_path (movie->parent); gtk_tree_path_append_index (path, i); } else { - i = my_g_list_is_nth (SWFDEC_ROOT_MOVIE (movie)->player->roots, movie); + i = my_g_list_is_nth (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context)->roots, movie); g_assert (i >= 0); path = gtk_tree_path_new (); gtk_tree_path_append_index (path, i); @@ -182,7 +182,7 @@ swfdec_debug_movies_iter_next (GtkTreeMo if (movie->parent) { list = movie->parent->list; } else { - list = SWFDEC_ROOT_MOVIE (movie)->player->roots; + list = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context)->roots; } list = g_list_find (list, movie); g_assert (list); diff-tree 5edf0a4e83374e21222b949a4aed0b0d3b8f0e2a (from parents) Merge: 73d835f1e18e1043402e5edf60f35bfc0fb94066 e59e5f97c9e7b48205a7c557b9107b8a5d04a8a4 Author: Benjamin Otte <otte at gnome.org> Date: Tue Jun 5 13:42:22 2007 +0200 Merge branch 'as' of ssh://company at git.freedesktop.org/git/swfdec into as diff-tree 73d835f1e18e1043402e5edf60f35bfc0fb94066 (from ed331b00d990804d0ed7e8e008370eea4b76cccf) Author: Benjamin Otte <otte at gnome.org> Date: Mon Jun 4 21:37:27 2007 +0200 remove SwfdecRootMovie.player - it has been replaced by SwfdecAsObject.context diff --git a/libswfdec/swfdec_button_movie.c b/libswfdec/swfdec_button_movie.c index a16a4f9..97824a0 100644 --- a/libswfdec/swfdec_button_movie.c +++ b/libswfdec/swfdec_button_movie.c @@ -182,7 +182,7 @@ swfdec_button_movie_change_mouse (Swfdec SwfdecAudio *audio; SWFDEC_LOG ("playing button sound %d", sound); audio = swfdec_audio_event_new ( - SWFDEC_ROOT_MOVIE (SWFDEC_MOVIE (movie)->root)->player, + SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), movie->button->sounds[sound]); if (audio) g_object_unref (audio); diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c index a173c3c..6051b01 100644 --- a/libswfdec/swfdec_movie.c +++ b/libswfdec/swfdec_movie.c @@ -78,7 +78,7 @@ swfdec_movie_invalidate (SwfdecMovie *mo return; swfdec_rect_transform (&rect, &rect, &movie->matrix); } - swfdec_player_invalidate (SWFDEC_ROOT_MOVIE (movie)->player, &rect); + swfdec_player_invalidate (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), &rect); } /** @@ -271,8 +271,11 @@ swfdec_movie_find (SwfdecMovie *movie, i static gboolean swfdec_movie_do_remove (SwfdecMovie *movie) { + SwfdecPlayer *player; + SWFDEC_LOG ("removing %s %s", G_OBJECT_TYPE_NAME (movie), movie->name); + player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context); movie->will_be_removed = TRUE; while (movie->list) { GList *walk = movie->list; @@ -283,10 +286,10 @@ swfdec_movie_do_remove (SwfdecMovie *mov swfdec_movie_remove (walk->data); } /* FIXME: all of this here or in destroy callback? */ - if (SWFDEC_ROOT_MOVIE (movie->root)->player->mouse_grab == movie) - SWFDEC_ROOT_MOVIE (movie->root)->player->mouse_grab = NULL; - if (SWFDEC_ROOT_MOVIE (movie->root)->player->mouse_drag == movie) - SWFDEC_ROOT_MOVIE (movie->root)->player->mouse_drag = NULL; + if (player->mouse_grab == movie) + player->mouse_grab = NULL; + if (player->mouse_drag == movie) + player->mouse_drag = NULL; swfdec_movie_invalidate (movie); movie->depth = -16385 - movie->depth; /* don't ask me why... */ if (movie->parent) @@ -330,7 +333,7 @@ void swfdec_movie_destroy (SwfdecMovie *movie) { SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (movie); - SwfdecPlayer *player = SWFDEC_ROOT_MOVIE (movie->root)->player; + SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context); g_assert (movie->state < SWFDEC_MOVIE_STATE_DESTROYED); if (movie->state < SWFDEC_MOVIE_STATE_REMOVED) { @@ -341,14 +344,12 @@ swfdec_movie_destroy (SwfdecMovie *movie swfdec_movie_destroy (movie->list->data); } if (movie->parent) { - SwfdecPlayer *player = SWFDEC_ROOT_MOVIE (movie->root)->player; if (SWFDEC_IS_DEBUGGER (player) && g_list_find (movie->parent->list, movie)) { g_signal_emit_by_name (player, "movie-removed", movie); } movie->parent->list = g_list_remove (movie->parent->list, movie); } else { - SwfdecPlayer *player = SWFDEC_ROOT_MOVIE (movie)->player; if (SWFDEC_IS_DEBUGGER (player) && g_list_find (player->roots, movie)) { g_signal_emit_by_name (player, "movie-removed", movie); @@ -380,7 +381,7 @@ swfdec_movie_run_init (SwfdecMovie *movi g_return_if_fail (SWFDEC_IS_MOVIE (movie)); - player = SWFDEC_ROOT_MOVIE (movie->root)->player; + player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context); g_queue_remove (player->init_queue, movie); swfdec_movie_execute_script (movie, SWFDEC_EVENT_INITIALIZE); } @@ -400,7 +401,7 @@ swfdec_movie_run_construct (SwfdecMovie g_return_if_fail (SWFDEC_IS_MOVIE (movie)); - player = SWFDEC_ROOT_MOVIE (movie->root)->player; + player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context); g_queue_remove (player->construct_queue, movie); swfdec_movie_execute_script (movie, SWFDEC_EVENT_CONSTRUCT); swfdec_as_object_call (SWFDEC_AS_OBJECT (movie), SWFDEC_AS_STR_constructor, 0, NULL, NULL); @@ -457,7 +458,7 @@ swfdec_movie_queue_script (SwfdecMovie * return FALSE; } - player = SWFDEC_ROOT_MOVIE (movie->root)->player; + player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context); swfdec_player_add_action (player, movie, swfdec_movie_do_execute_script, GUINT_TO_POINTER (condition)); return TRUE; @@ -557,7 +558,7 @@ swfdec_movie_get_mouse (SwfdecMovie *mov g_return_if_fail (x != NULL); g_return_if_fail (y != NULL); - player = SWFDEC_ROOT_MOVIE (movie->root)->player; + player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context); *x = player->mouse_x; *y = player->mouse_y; swfdec_movie_global_to_local (movie, x, y); @@ -577,7 +578,7 @@ swfdec_movie_send_mouse_change (SwfdecMo button = 0; } else { mouse_in = swfdec_movie_mouse_in (movie, x, y); - button = SWFDEC_ROOT_MOVIE (movie->root)->player->mouse_button; + button = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context)->mouse_button; } klass = SWFDEC_MOVIE_GET_CLASS (movie); g_assert (klass->mouse_change != NULL); @@ -840,7 +841,7 @@ static void swfdec_movie_set_parent (SwfdecMovie *movie) { SwfdecMovie *parent = movie->parent; - SwfdecPlayer *player = SWFDEC_ROOT_MOVIE (movie->root)->player; + SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context); SwfdecMovieClass *klass; g_return_if_fail (SWFDEC_IS_MOVIE (movie)); @@ -936,7 +937,6 @@ swfdec_movie_new_for_player (SwfdecPlaye content->name = g_strdup_printf ("_level%u", depth); ret = g_object_new (SWFDEC_TYPE_ROOT_MOVIE, NULL); g_object_weak_ref (G_OBJECT (ret), (GWeakNotify) swfdec_content_free, content); - SWFDEC_ROOT_MOVIE (ret)->player = player; ret->root = ret; if (swfdec_as_context_use_mem (SWFDEC_AS_CONTEXT (player), sizeof (SwfdecRootMovie))) { g_object_ref (ret); diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c index 54a2707..288e9ef 100644 --- a/libswfdec/swfdec_player.c +++ b/libswfdec/swfdec_player.c @@ -968,7 +968,6 @@ swfdec_player_add_level_from_loader (Swf swfdec_player_remove_level (player, depth); movie = swfdec_movie_new_for_player (player, depth); root = SWFDEC_ROOT_MOVIE (movie); - root->player = player; root->loader = loader; if (variables) swfdec_movie_set_variables (movie, variables); diff --git a/libswfdec/swfdec_root_movie.c b/libswfdec/swfdec_root_movie.c index 8b22055..1fcba46 100644 --- a/libswfdec/swfdec_root_movie.c +++ b/libswfdec/swfdec_root_movie.c @@ -47,7 +47,7 @@ G_DEFINE_TYPE_WITH_CODE (SwfdecRootMovie static SwfdecPlayer * swfdec_root_movie_loader_target_get_player (SwfdecLoaderTarget *target) { - return SWFDEC_ROOT_MOVIE (target)->player; + return SWFDEC_PLAYER (SWFDEC_AS_OBJECT (target)->context); } static SwfdecDecoder * @@ -148,7 +148,7 @@ swfdec_root_movie_iterate_end (SwfdecMov if (!SWFDEC_MOVIE_CLASS (swfdec_root_movie_parent_class)->iterate_end (movie)) return FALSE; - return g_list_find (SWFDEC_ROOT_MOVIE (movie)->player->roots, movie) != NULL; + return g_list_find (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context)->roots, movie) != NULL; } static void @@ -173,10 +173,13 @@ swfdec_root_movie_init (SwfdecRootMovie void swfdec_root_movie_load (SwfdecRootMovie *root, const char *url, const char *target) { + SwfdecPlayer *player; + g_return_if_fail (SWFDEC_IS_ROOT_MOVIE (root)); g_return_if_fail (url != NULL); g_return_if_fail (target != NULL); + player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (root)->context); /* yay for the multiple uses of GetURL - one of the crappier Flash things */ if (g_str_has_prefix (target, "_level")) { const char *nr = target + strlen ("_level"); @@ -187,11 +190,11 @@ swfdec_root_movie_load (SwfdecRootMovie depth = strtoul (nr, &end, 10); if (errno == 0 && *end == '\0') { if (url[0] == '\0') { - swfdec_player_remove_level (root->player, depth); + swfdec_player_remove_level (player, depth); } else { SwfdecLoader *loader = swfdec_loader_load (root->loader, url); if (loader) { - swfdec_player_add_level_from_loader (root->player, depth, loader, NULL); + swfdec_player_add_level_from_loader (player, depth, loader, NULL); swfdec_loader_queue_parse (loader); } else { SWFDEC_WARNING ("didn't get a loader for url \"%s\" at depth %u", url, depth); @@ -207,7 +210,7 @@ swfdec_root_movie_load (SwfdecRootMovie SWFDEC_WARNING ("unhandled fscommand: %s %s", command, target); return; } - swfdec_player_launch (root->player, url, target); + swfdec_player_launch (player, url, target); } void diff --git a/libswfdec/swfdec_root_movie.h b/libswfdec/swfdec_root_movie.h index 408a40b..378cfec 100644 --- a/libswfdec/swfdec_root_movie.h +++ b/libswfdec/swfdec_root_movie.h @@ -38,7 +38,6 @@ struct _SwfdecRootMovie { SwfdecSpriteMovie sprite_movie; - SwfdecPlayer * player; /* player we're played in */ SwfdecLoader * loader; /* the loader providing data for the decoder */ SwfdecDecoder * decoder; /* decoder that decoded all the stuff used by us */ guint unnamed_count; /* variable used for naming unnamed movies */ diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c index 3e25eb9..c0d0647 100644 --- a/libswfdec/swfdec_sprite_movie.c +++ b/libswfdec/swfdec_sprite_movie.c @@ -74,7 +74,7 @@ swfdec_sprite_movie_perform_one_action ( gboolean skip_scripts, GList **movie_list) { SwfdecMovie *mov = SWFDEC_MOVIE (movie); - SwfdecPlayer *player = SWFDEC_ROOT_MOVIE (mov->root)->player; + SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (mov)->context); SwfdecMovie *child; SwfdecContent *content; @@ -176,7 +176,7 @@ swfdec_sprite_movie_goto (SwfdecMovie *m if (goto_frame == movie->current_frame) return; - player = SWFDEC_ROOT_MOVIE (mov->root)->player; + player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (mov)->context); SWFDEC_LOG ("doing goto %u for %p %d", goto_frame, mov, SWFDEC_CHARACTER (SWFDEC_SPRITE_MOVIE (mov)->sprite)->id); mov->frame = goto_frame; @@ -248,7 +248,7 @@ swfdec_sprite_movie_iterate_end (SwfdecM SwfdecSpriteFrame *last; SwfdecSpriteFrame *current; GSList *walk; - SwfdecPlayer *player = SWFDEC_ROOT_MOVIE (SWFDEC_MOVIE (movie)->root)->player; + SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (mov)->context); current = &movie->sprite->frames[movie->current_frame]; if (!SWFDEC_MOVIE_CLASS (swfdec_sprite_movie_parent_class)->iterate_end (mov)) { @@ -323,7 +323,7 @@ static void swfdec_sprite_movie_finish_movie (SwfdecMovie *mov) { SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov); - SwfdecPlayer *player = SWFDEC_ROOT_MOVIE (mov->root)->player; + SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (mov)->context); swfdec_player_remove_all_actions (player, mov); if (movie->sound_stream) { diff --git a/libswfdec/swfdec_sprite_movie_as.c b/libswfdec/swfdec_sprite_movie_as.c index 0049ec6..fa48596 100644 --- a/libswfdec/swfdec_sprite_movie_as.c +++ b/libswfdec/swfdec_sprite_movie_as.c @@ -201,6 +201,7 @@ static void swfdec_sprite_movie_startDrag (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval) { SwfdecMovie *movie = SWFDEC_MOVIE (obj); + SwfdecPlayer *player = SWFDEC_PLAYER (obj->context); gboolean center = FALSE; if (argc > 0) { @@ -213,11 +214,9 @@ swfdec_sprite_movie_startDrag (SwfdecAsO rect.x1 = swfdec_as_value_to_number (obj->context, &argv[3]); rect.y1 = swfdec_as_value_to_number (obj->context, &argv[4]); swfdec_rect_scale (&rect, &rect, SWFDEC_TWIPS_SCALE_FACTOR); - swfdec_player_set_drag_movie (SWFDEC_ROOT_MOVIE (movie->root)->player, movie, - center, &rect); + swfdec_player_set_drag_movie (player, movie, center, &rect); } else { - swfdec_player_set_drag_movie (SWFDEC_ROOT_MOVIE (movie->root)->player, movie, - center, NULL); + swfdec_player_set_drag_movie (player, movie, center, NULL); } } @@ -268,7 +267,7 @@ swfdec_sprite_movie_init_from_object (Sw { SwfdecPlayer *player; - player = SWFDEC_ROOT_MOVIE (movie->root)->player; + player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context); g_queue_remove (player->init_queue, movie); } diff-tree ed331b00d990804d0ed7e8e008370eea4b76cccf (from 2abb607a68429fb202f76674e82a0b4b9f758a72) Author: Benjamin Otte <otte at gnome.org> Date: Mon Jun 4 21:17:16 2007 +0200 that variable is unused diff --git a/libswfdec/swfdec_root_movie.h b/libswfdec/swfdec_root_movie.h index 67c785e..408a40b 100644 --- a/libswfdec/swfdec_root_movie.h +++ b/libswfdec/swfdec_root_movie.h @@ -38,7 +38,6 @@ struct _SwfdecRootMovie { SwfdecSpriteMovie sprite_movie; - gboolean error; /* we're in error */ SwfdecPlayer * player; /* player we're played in */ SwfdecLoader * loader; /* the loader providing data for the decoder */ SwfdecDecoder * decoder; /* decoder that decoded all the stuff used by us */ diff-tree 2abb607a68429fb202f76674e82a0b4b9f758a72 (from 1a442e379efc06ab078924f0d824b94aae01b34a) Author: Nguyen Thai Ngoc Duy <pclouds at gmail.com> Date: Mon Jun 4 10:11:34 2007 +0200 Fix wrong check diff --git a/libswfdec/swfdec_mouse_as.c b/libswfdec/swfdec_mouse_as.c index d4d53d9..ef36dc7 100644 --- a/libswfdec/swfdec_mouse_as.c +++ b/libswfdec/swfdec_mouse_as.c @@ -31,7 +31,7 @@ swfdec_mouse_addListener (SwfdecAsObject { SwfdecPlayer *player = SWFDEC_PLAYER (object->context); - if (!SWFDEC_IS_AS_OBJECT (&argv[0])) + if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0])) return; swfdec_listener_add (player->mouse_listener, SWFDEC_AS_VALUE_GET_OBJECT (&argv[0])); } @@ -41,7 +41,7 @@ swfdec_mouse_removeListener (SwfdecAsObj { SwfdecPlayer *player = SWFDEC_PLAYER (object->context); - if (!SWFDEC_IS_AS_OBJECT (&argv[0])) + if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0])) return; swfdec_listener_remove (player->mouse_listener, SWFDEC_AS_VALUE_GET_OBJECT (&argv[0])); } diff-tree 1a442e379efc06ab078924f0d824b94aae01b34a (from 89c4d90d1c31e4bba4b15f8419f7ebd13cd6cbb8) Author: Benjamin Otte <otte at gnome.org> Date: Sat Jun 2 19:10:50 2007 +0200 Number.prototype is an object, not a number diff --git a/libswfdec/swfdec_as_number.c b/libswfdec/swfdec_as_number.c index 8d5e3b3..edeb3c3 100644 --- a/libswfdec/swfdec_as_number.c +++ b/libswfdec/swfdec_as_number.c @@ -119,15 +119,10 @@ swfdec_as_number_init_context (SwfdecAsC context->Number = number; swfdec_as_native_function_set_object_type (SWFDEC_AS_NATIVE_FUNCTION (number), SWFDEC_TYPE_AS_NUMBER); - if (!swfdec_as_context_use_mem (context, sizeof (SwfdecAsNumber))) - return; - proto = g_object_new (SWFDEC_TYPE_AS_NUMBER, NULL); - swfdec_as_object_add (proto, context, sizeof (SwfdecAsNumber)); + proto = swfdec_as_object_new (context); /* set the right properties on the Number object */ - swfdec_as_object_root (proto); SWFDEC_AS_VALUE_SET_OBJECT (&val, proto); swfdec_as_object_set_variable (number, SWFDEC_AS_STR_prototype, &val); - swfdec_as_object_unroot (proto); SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Function); swfdec_as_object_set_variable (number, SWFDEC_AS_STR_constructor, &val); SWFDEC_AS_VALUE_SET_NUMBER (&val, NAN);
Seemingly Similar Threads
- 5 commits - libswfdec/Makefile.am libswfdec/swfdec_as_context.c libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_frame_internal.h libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_scope.c libswfdec/swfdec_as_scope.h libswfdec/swfdec_as_script_function.c
- 15 commits - libswfdec/swfdec_as_context.c libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_frame_internal.h libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_object.h libswfdec/swfdec_as_super.c libswfdec/swfdec_as_with.c
- 3 commits - doc/Makefile.am doc/swfdec-docs.sgml doc/swfdec-sections.txt libswfdec/Makefile.am libswfdec/swfdec_as_array.c libswfdec/swfdec_as_boolean.c libswfdec/swfdec_as_context.c libswfdec/swfdec_as_context.h libswfdec/swfdec_as_frame.c
- Branch 'as' - 7 commits - libswfdec/swfdec_as_array.c libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_object.h libswfdec/swfdec_as_with.c libswfdec/swfdec_sprite_movie.c test/trace
- Branch 'as' - 13 commits - libswfdec/swfdec_as_context.c libswfdec/swfdec_as_context.h libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_frame.h libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_object.h