Benjamin Otte
2007-Aug-16 19:31 UTC
[Swfdec] Branch 'vivi' - 18 commits - configure.ac doc/swfdec-sections.txt libswfdec/swfdec_as_context.c libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_frame.h libswfdec/swfdec_as_types.h libswfdec/swfdec_player.c vivified/core vivified/ui
configure.ac | 2 doc/swfdec-sections.txt | 1 libswfdec/swfdec_as_context.c | 2 libswfdec/swfdec_as_frame.c | 37 ++++++++++++--- libswfdec/swfdec_as_frame.h | 1 libswfdec/swfdec_as_types.h | 5 +- libswfdec/swfdec_player.c | 2 vivified/core/Makefile.am | 1 vivified/core/vivi_application.c | 68 ++++++++++++++++++--------- vivified/core/vivi_application.h | 6 ++ vivified/core/vivi_breakpoint.c | 95 +++++++++++++++++++++++++++++++-------- vivified/core/vivi_breakpoint.h | 3 + vivified/core/vivi_debugger.c | 7 ++ vivified/core/vivi_initialize.as | 48 +++++++++++++++++-- vivified/core/vivi_player_as.c | 40 ++++++++++++++++ vivified/core/vivi_wrap_as.c | 41 ++++++++++++++++ vivified/ui/main.c | 9 ++- 17 files changed, 305 insertions(+), 63 deletions(-) New commits: diff-tree da8a9e9b145d5cb1aebc04764e9ed66856a31c9b (from f0776fdc6d6e96c49e4daaa9d512c813b59b39df) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 21:31:25 2007 +0200 make backtrace function actually work diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index 7b6fdc6..bf6ed76 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -101,11 +101,12 @@ Commands.delete = Commands.del; Commands.where = function () { var frame = Player.frame; if (frame == undefined) { - print ("---"); + Commands.print ("---"); return; } + var i = 0; while (frame) { - print (frame); + Commands.print (i++ + ": " + frame); frame = frame.next; } }; diff-tree f0776fdc6d6e96c49e4daaa9d512c813b59b39df (from 46e54f2e89bcf81b9137cdba219d7322ee7055ad) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 21:26:41 2007 +0200 debugging g_print() ... diff --git a/vivified/core/vivi_debugger.c b/vivified/core/vivi_debugger.c index 53ea0ea..670daff 100644 --- a/vivified/core/vivi_debugger.c +++ b/vivified/core/vivi_debugger.c @@ -76,9 +76,7 @@ vivi_debugger_break (ViviDebugger *debug g_object_notify (G_OBJECT (app), "interrupted"); vivi_application_check (app); - g_print (">>>\n"); g_main_loop_run (app->loop); - g_print ("<<<\n"); g_main_loop_unref (app->loop); app->loop = NULL; diff-tree 46e54f2e89bcf81b9137cdba219d7322ee7055ad (from 19febb579adabc379bbb078c28d1afabf217dd38) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 21:26:20 2007 +0200 add backtrace function diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index 4751870..7b6fdc6 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -98,3 +98,16 @@ Commands.del = function (id) { b.active = false; }; Commands.delete = Commands.del; +Commands.where = function () { + var frame = Player.frame; + if (frame == undefined) { + print ("---"); + return; + } + while (frame) { + print (frame); + frame = frame.next; + } +}; +Commands.backtrace = Commands.where; +Commands.bt = Commands.where; diff-tree 19febb579adabc379bbb078c28d1afabf217dd38 (from 9201f46e7c8502e949f1ab9608cdb6073aa3e15d) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 21:26:06 2007 +0200 return the breakpoint that was added from Commands.add() diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index e654e74..4751870 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -78,6 +78,7 @@ Commands.add = function (name) { ret.toString = function () { return "function call " + name; }; + return ret; }; Commands.list = function () { var a = Breakpoint.list; diff-tree 9201f46e7c8502e949f1ab9608cdb6073aa3e15d (from e1b2e3c7a87d7f31d97553e9cc844afca9b8dd1d) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 21:23:47 2007 +0200 implement Player object and Player.frame for the current frame diff --git a/vivified/core/Makefile.am b/vivified/core/Makefile.am index 9403543..13411ef 100644 --- a/vivified/core/Makefile.am +++ b/vivified/core/Makefile.am @@ -14,6 +14,7 @@ libvivified_core_la_SOURCES = \ vivi_initialize.s \ vivi_marshal.c \ vivi_ming.c \ + vivi_player_as.c \ vivi_wrap.c \ vivi_wrap_as.c diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index 7686c8b..e654e74 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -38,6 +38,11 @@ Breakpoint = function () extends Native. Breakpoint.list = new Array (); Breakpoint.prototype.addProperty ("active", Native.breakpoint_active_get, Native.breakpoint_active_set); +/*** information about the player ***/ + +Player = {}; +Player.addProperty ("frame", Native.player_frame_get, null); + /*** commands available for debugging ***/ Commands = new Object (); diff --git a/vivified/core/vivi_player_as.c b/vivified/core/vivi_player_as.c new file mode 100644 index 0000000..ab8c4de --- /dev/null +++ b/vivified/core/vivi_player_as.c @@ -0,0 +1,40 @@ +/* Vivified + * 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 "vivi_wrap.h" +#include "vivi_application.h" +#include "vivi_function.h" + +VIVI_FUNCTION ("player_frame_get", vivi_player_as_frame_get) +void +vivi_player_as_frame_get (SwfdecAsContext *cx, SwfdecAsObject *this, + guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval) +{ + ViviApplication *app = VIVI_APPLICATION (cx); + SwfdecAsObject *obj; + + obj = SWFDEC_AS_OBJECT (swfdec_as_context_get_frame (SWFDEC_AS_CONTEXT (app->player))); + if (obj) + SWFDEC_AS_VALUE_SET_OBJECT (retval, vivi_wrap_object (app, obj)); +} + diff-tree e1b2e3c7a87d7f31d97553e9cc844afca9b8dd1d (from 45a3be6f561a80d6e7ef749e0fd5ad7cf1d43ce5) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 21:23:24 2007 +0200 make swfdec_as_stack_iterator_init_arguments() work with every frame, not just with the first frame on the stack diff --git a/libswfdec/swfdec_as_frame.c b/libswfdec/swfdec_as_frame.c index 17f88cb..5369dca 100644 --- a/libswfdec/swfdec_as_frame.c +++ b/libswfdec/swfdec_as_frame.c @@ -79,21 +79,29 @@ swfdec_as_stack_iterator_init_arguments g_return_val_if_fail (iter != NULL, NULL); g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL); - /* FIXME! */ - context = SWFDEC_AS_OBJECT (frame)->context; - g_return_val_if_fail (context->frame == frame, NULL); + if (frame->argc == 0) { + iter->current = NULL; + return NULL; + } + context = SWFDEC_AS_OBJECT (frame)->context; if (frame->argv) { iter->stack = NULL; iter->current = (SwfdecAsValue *) frame->argv; } else { - iter->stack = context->stack; + SwfdecAsStack *stack = context->stack; + SwfdecAsValue *end; iter->current = frame->stack_begin - 1; + end = context->cur; + while (iter->current < stack->elements || + iter->current > end) { + stack = stack->next; + end = &stack->elements[stack->used_elements]; + } + iter->stack = stack; } iter->i = 0; iter->n = frame->argc; - if (frame->argc == 0) - iter->current = NULL; return iter->current; } diff-tree 45a3be6f561a80d6e7ef749e0fd5ad7cf1d43ce5 (from b199888c9610670fe2e47791fe529156f11a3733) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 20:27:33 2007 +0200 reorder diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index 5e1edac..7686c8b 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -17,12 +17,7 @@ * Boston, MA 02110-1301 USA */ -Breakpoint = function () extends Native.Breakpoint { - super (); - Breakpoint.list.push (this); -}; -Breakpoint.list = new Array (); -Breakpoint.prototype.addProperty ("active", Native.breakpoint_active_get, Native.breakpoint_active_set); +/*** general objects ***/ Wrap = function () {}; Wrap.prototype = {}; @@ -34,6 +29,15 @@ Frame.prototype.addProperty ("code", Nat Frame.prototype.addProperty ("name", Native.frame_name_get, null); Frame.prototype.addProperty ("next", Native.frame_next_get, null); +/*** breakpoints ***/ + +Breakpoint = function () extends Native.Breakpoint { + super (); + Breakpoint.list.push (this); +}; +Breakpoint.list = new Array (); +Breakpoint.prototype.addProperty ("active", Native.breakpoint_active_get, Native.breakpoint_active_set); + /*** commands available for debugging ***/ Commands = new Object (); diff-tree b199888c9610670fe2e47791fe529156f11a3733 (from ee2cce889a2f70f535dec00093090836f13a1efd) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 20:11:25 2007 +0200 implement Frame.next property diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index f86991f..5e1edac 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -30,8 +30,9 @@ Wrap.prototype.toString = Native.wrap_to Frame = function () extends Wrap {}; Frame.prototype = new Wrap (); -Frame.prototype.addProperty ("name", Native.frame_name_get, null); Frame.prototype.addProperty ("code", Native.frame_code_get, null); +Frame.prototype.addProperty ("name", Native.frame_name_get, null); +Frame.prototype.addProperty ("next", Native.frame_next_get, null); /*** commands available for debugging ***/ diff --git a/vivified/core/vivi_wrap_as.c b/vivified/core/vivi_wrap_as.c index 0f4f3e6..c905f34 100644 --- a/vivified/core/vivi_wrap_as.c +++ b/vivified/core/vivi_wrap_as.c @@ -86,5 +86,24 @@ vivi_wrap_code_get (SwfdecAsContext *cx, SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE); } +VIVI_FUNCTION ("frame_next_get", vivi_wrap_next_get) +void +vivi_wrap_next_get (SwfdecAsContext *cx, SwfdecAsObject *this, + guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval) +{ + ViviWrap *wrap; + SwfdecAsObject *obj; + + if (!VIVI_IS_WRAP (this)) + return; + + wrap = VIVI_WRAP (this); + if (!SWFDEC_IS_AS_FRAME (wrap->wrap)) + return; + + obj = SWFDEC_AS_OBJECT (swfdec_as_frame_get_next (SWFDEC_AS_FRAME (wrap->wrap))); + if (obj) + SWFDEC_AS_VALUE_SET_OBJECT (retval, vivi_wrap_object (VIVI_APPLICATION (cx), obj)); +} diff-tree ee2cce889a2f70f535dec00093090836f13a1efd (from f469392f783d10984d4d6dc36ac03d41b3730bec) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 19:46:24 2007 +0200 don't use parameters as format strings diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c index 1a311e9..96c23e4 100644 --- a/libswfdec/swfdec_as_context.c +++ b/libswfdec/swfdec_as_context.c @@ -169,7 +169,7 @@ swfdec_as_context_abort (SwfdecAsContext { g_return_if_fail (context); - SWFDEC_ERROR (reason); + SWFDEC_ERROR ("%s", reason); context->state = SWFDEC_AS_CONTEXT_ABORTED; } diff-tree f469392f783d10984d4d6dc36ac03d41b3730bec (from 52bba717bd060881a2f47b202c129017a86bc955) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 19:46:12 2007 +0200 in SWFDEC_AS_OBJECT() only reference the object once diff --git a/libswfdec/swfdec_as_types.h b/libswfdec/swfdec_as_types.h index 54189d8..8da685d 100644 --- a/libswfdec/swfdec_as_types.h +++ b/libswfdec/swfdec_as_types.h @@ -104,9 +104,10 @@ struct _SwfdecAsValue { #define SWFDEC_AS_VALUE_GET_OBJECT(val) ((val)->value.object) #define SWFDEC_AS_VALUE_SET_OBJECT(val,o) G_STMT_START { \ SwfdecAsValue *__val = (val); \ - g_assert (o != NULL); \ + SwfdecAsObject *__o = (o); \ + g_assert (__o != NULL); \ (__val)->type = SWFDEC_AS_TYPE_OBJECT; \ - (__val)->value.object = o; \ + (__val)->value.object = __o; \ } G_STMT_END /* value conversion functions */ diff-tree 52bba717bd060881a2f47b202c129017a86bc955 (from 85ec6f14038b68f557c37a8ad23095dca8a9af1f) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 17:32:59 2007 +0200 support reset() in breakpoints (hopefully) diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c index 79b350d..cc1d4c2 100644 --- a/vivified/core/vivi_application.c +++ b/vivified/core/vivi_application.c @@ -181,7 +181,8 @@ vivi_application_reset (ViviApplication { g_return_if_fail (VIVI_IS_APPLICATION (app)); - g_assert (app->loop == NULL); /* FIXME: what do we do if we're inside a breakpoint? */ + if (app->loop != NULL) + g_main_loop_quit (app->loop); g_object_unref (app->player); app->player = swfdec_gtk_player_new (SWFDEC_AS_DEBUGGER (app->debugger)); app->player_inited = FALSE; @@ -262,42 +263,25 @@ vivi_application_step_forward (gpointer return FALSE; } -static void +void vivi_application_check (ViviApplication *app) { - gboolean is_playing, is_breakpoint; + gboolean is_breakpoint; /* if we're inside some script code, don't do anything */ if (swfdec_as_context_get_frame (SWFDEC_AS_CONTEXT (app))) return; - is_playing = swfdec_gtk_player_get_playing (SWFDEC_GTK_PLAYER (app->player)); is_breakpoint = app->loop != NULL; swfdec_as_context_maybe_gc (SWFDEC_AS_CONTEXT (app)); switch (app->playback_state) { case VIVI_APPLICATION_EXITING: - if (is_playing) - swfdec_gtk_player_set_playing (SWFDEC_GTK_PLAYER (app->player), FALSE); - if (is_breakpoint) - g_main_loop_quit (app->loop); - break; case VIVI_APPLICATION_STOPPED: - if (is_playing) - swfdec_gtk_player_set_playing (SWFDEC_GTK_PLAYER (app->player), FALSE); - break; case VIVI_APPLICATION_PLAYING: - if (!is_playing) - swfdec_gtk_player_set_playing (SWFDEC_GTK_PLAYER (app->player), TRUE); - if (is_breakpoint) - g_main_loop_quit (app->loop); break; case VIVI_APPLICATION_STEPPING: - if (is_playing) - swfdec_gtk_player_set_playing (SWFDEC_GTK_PLAYER (app->player), FALSE); - if (is_breakpoint) { - g_main_loop_quit (app->loop); - } else { + if (!is_breakpoint) { /* FIXME: sanely handle this */ g_idle_add_full (-100, vivi_application_step_forward, app, NULL); } @@ -306,6 +290,14 @@ vivi_application_check (ViviApplication g_assert_not_reached (); break; } + + /* only play when not in breakpoints and only when really playing */ + swfdec_gtk_player_set_playing (SWFDEC_GTK_PLAYER (app->player), !is_breakpoint && + app->playback_state == VIVI_APPLICATION_PLAYING); + + /* leave breakpoint unless stopped */ + if (is_breakpoint && app->playback_state != VIVI_APPLICATION_STOPPED) + g_main_loop_quit (app->loop); } void diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h index 7f66487..33694bf 100644 --- a/vivified/core/vivi_application.h +++ b/vivified/core/vivi_application.h @@ -75,6 +75,8 @@ GType vivi_application_get_type (vo ViviApplication * vivi_application_new (void); +void vivi_application_check (ViviApplication * app); + void vivi_application_send_message (ViviApplication * app, ViviMessageType type, const char * format, diff --git a/vivified/core/vivi_debugger.c b/vivified/core/vivi_debugger.c index 915dff0..53ea0ea 100644 --- a/vivified/core/vivi_debugger.c +++ b/vivified/core/vivi_debugger.c @@ -58,6 +58,7 @@ static void vivi_debugger_break (ViviDebugger *debugger) { ViviApplication *app = debugger->app; + SwfdecPlayer *player = app->player; g_assert (app); if (app->playback_state == VIVI_APPLICATION_EXITING) @@ -67,19 +68,23 @@ vivi_debugger_break (ViviDebugger *debug if (app->playback_count > 0) return; } - swfdec_player_unlock_soft (app->player); + swfdec_player_unlock_soft (player); app->playback_state = 0; app->playback_count = 0; app->loop = g_main_loop_new (NULL, FALSE); g_object_notify (G_OBJECT (app), "interrupted"); + vivi_application_check (app); + g_print (">>>\n"); g_main_loop_run (app->loop); + g_print ("<<<\n"); g_main_loop_unref (app->loop); app->loop = NULL; g_object_notify (G_OBJECT (app), "interrupted"); - swfdec_player_lock_soft (app->player); + vivi_application_check (app); + swfdec_player_lock_soft (player); } static void diff-tree 85ec6f14038b68f557c37a8ad23095dca8a9af1f (from f848345a3768d3029d5135db1556f9f0f8a7061f) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 17:32:31 2007 +0200 add a reference to the player when locking diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c index 2bb0264..e9a8010 100644 --- a/libswfdec/swfdec_player.c +++ b/libswfdec/swfdec_player.c @@ -1060,6 +1060,7 @@ swfdec_player_lock (SwfdecPlayer *player g_return_if_fail (SWFDEC_IS_PLAYER (player)); g_assert (swfdec_ring_buffer_get_n_elements (player->actions) == 0); + g_object_ref (player); swfdec_player_lock_soft (player); } @@ -1083,6 +1084,7 @@ swfdec_player_unlock (SwfdecPlayer *play swfdec_as_context_maybe_gc (SWFDEC_AS_CONTEXT (player)); swfdec_player_unlock_soft (player); + g_object_unref (player); } static gboolean diff-tree f848345a3768d3029d5135db1556f9f0f8a7061f (from 71440c71a145eb098445126cf0031f4a700df56f) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 15:42:10 2007 +0200 add the possibility to set variables to be used with the player Variables can be specified as second command line argument now. diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c index 3a2de0a..79b350d 100644 --- a/vivified/core/vivi_application.c +++ b/vivified/core/vivi_application.c @@ -35,6 +35,7 @@ enum { enum { PROP_0, PROP_FILENAME, + PROP_VARIABLES, PROP_PLAYER, PROP_INTERRUPTED, PROP_QUIT @@ -53,6 +54,9 @@ vivi_application_get_property (GObject * case PROP_FILENAME: g_value_set_string (value, app->filename); break; + case PROP_VARIABLES: + g_value_set_string (value, app->variables); + break; case PROP_PLAYER: g_value_set_object (value, app->player); break; @@ -78,6 +82,9 @@ vivi_application_set_property (GObject * case PROP_FILENAME: vivi_application_set_filename (app, g_value_get_string (value)); break; + case PROP_VARIABLES: + vivi_application_set_variables (app, g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -110,6 +117,9 @@ vivi_application_class_init (ViviApplica g_object_class_install_property (object_class, PROP_FILENAME, g_param_spec_string ("filename", "filename", "name of file to play", NULL, G_PARAM_READWRITE)); + g_object_class_install_property (object_class, PROP_FILENAME, + g_param_spec_string ("variables", "variables", "variables to pass to the file", + NULL, G_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_PLAYER, g_param_spec_object ("player", "player", "Flash player in use", SWFDEC_TYPE_PLAYER, G_PARAM_READABLE)); @@ -162,7 +172,7 @@ vivi_application_init_player (ViviApplic } loader = swfdec_file_loader_new (app->filename); - swfdec_player_set_loader (app->player, loader); + swfdec_player_set_loader_with_variables (app->player, loader, app->variables); app->player_inited = TRUE; } @@ -198,6 +208,24 @@ vivi_application_get_filename (ViviAppli return app->filename; } +void +vivi_application_set_variables (ViviApplication *app, const char *variables) +{ + g_return_if_fail (VIVI_IS_APPLICATION (app)); + + g_free (app->variables); + app->variables = g_strdup (variables); + g_object_notify (G_OBJECT (app), "variables"); +} + +const char * +vivi_application_get_variables (ViviApplication *app) +{ + g_return_val_if_fail (VIVI_IS_APPLICATION (app), NULL); + + return app->variables; +} + SwfdecPlayer * vivi_application_get_player (ViviApplication *app) { @@ -294,7 +322,7 @@ vivi_application_execute (ViviApplicatio vivi_application_input (app, "%s", command); script = vivi_ming_compile (command, &error); if (script == NULL) { - vivi_application_error (app, error); + vivi_application_error (app, "%s", error); g_free (error); return; } diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h index 812b304..7f66487 100644 --- a/vivified/core/vivi_application.h +++ b/vivified/core/vivi_application.h @@ -55,6 +55,7 @@ struct _ViviApplication SwfdecAsContext context; char * filename; /* name of the file we play back or NULL if none set yet */ + char * variables; /* variables to pass to player or NULL if none set */ SwfdecPlayer * player; /* the current player */ ViviDebugger * debugger; /* the debugger used in player */ gboolean player_inited; /* if the player is inited already */ @@ -88,6 +89,9 @@ void vivi_application_send_message (Vi void vivi_application_set_filename (ViviApplication * app, const char * filename); const char * vivi_application_get_filename (ViviApplication * app); +void vivi_application_set_variables (ViviApplication * app, + const char * filename); +const char * vivi_application_get_variables (ViviApplication * app); SwfdecPlayer * vivi_application_get_player (ViviApplication * app); gboolean vivi_application_get_interrupted(ViviApplication * app); gboolean vivi_application_is_quit (ViviApplication * app); diff --git a/vivified/ui/main.c b/vivified/ui/main.c index 3f96021..df123a9 100644 --- a/vivified/ui/main.c +++ b/vivified/ui/main.c @@ -48,13 +48,14 @@ delete_event (GtkWidget *widget, GdkEven } static void -setup (const char *filename) +setup (const char *filename, const char *variables) { GtkWidget *window, *box, *widget; ViviApplication *app; app = vivi_application_new (); vivi_application_set_filename (app, filename); + vivi_application_set_variables (app, variables); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect_swapped (app, "notify::quit", G_CALLBACK (gtk_widget_destroy), window); box = vivi_vdock_new (); @@ -75,12 +76,12 @@ main (int argc, char **argv) { gtk_init (&argc, &argv); - if (argc != 2) { - g_print ("usage: %s FILE\n", argv[0]); + if (argc < 2) { + g_print ("usage: %s FILE [VARIABLES]\n", argv[0]); return 0; } - setup (argv[1]); + setup (argv[1], argc > 2 ? argv[2] : NULL); gtk_main (); return 0; diff-tree 71440c71a145eb098445126cf0031f4a700df56f (from 5e6e05624c6c7cd7ecc9d8ea90a5ad4b4b04c542) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 14:48:32 2007 +0200 add Frame.code property diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index 51ce35d..f86991f 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -31,6 +31,7 @@ Wrap.prototype.toString = Native.wrap_to Frame = function () extends Wrap {}; Frame.prototype = new Wrap (); Frame.prototype.addProperty ("name", Native.frame_name_get, null); +Frame.prototype.addProperty ("code", Native.frame_code_get, null); /*** commands available for debugging ***/ diff --git a/vivified/core/vivi_wrap_as.c b/vivified/core/vivi_wrap_as.c index cf9e4a8..0f4f3e6 100644 --- a/vivified/core/vivi_wrap_as.c +++ b/vivified/core/vivi_wrap_as.c @@ -65,4 +65,26 @@ vivi_wrap_name_get (SwfdecAsContext *cx, SWFDEC_AS_VALUE_SET_STRING (retval, swfdec_as_context_get_string (cx, s)); } +VIVI_FUNCTION ("frame_code_get", vivi_wrap_code_get) +void +vivi_wrap_code_get (SwfdecAsContext *cx, SwfdecAsObject *this, + guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval) +{ + ViviWrap *wrap; + SwfdecScript *script; + + if (!VIVI_IS_WRAP (this)) + return; + + wrap = VIVI_WRAP (this); + if (!SWFDEC_IS_AS_FRAME (wrap->wrap)) + return; + + script = swfdec_as_frame_get_script (SWFDEC_AS_FRAME (wrap->wrap)); + /* FIXME: wrap scripts */ + if (script) + SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE); +} + + diff-tree 5e6e05624c6c7cd7ecc9d8ea90a5ad4b4b04c542 (from ecd3760b86ee8bc6d839b80303264d396131b60b) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 14:48:14 2007 +0200 don't use the input string as a format string diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c index 624c911..3a2de0a 100644 --- a/vivified/core/vivi_application.c +++ b/vivified/core/vivi_application.c @@ -291,7 +291,7 @@ vivi_application_execute (ViviApplicatio g_return_if_fail (VIVI_IS_APPLICATION (app)); g_return_if_fail (command != NULL); - vivi_application_input (app, command); + vivi_application_input (app, "%s", command); script = vivi_ming_compile (command, &error); if (script == NULL) { vivi_application_error (app, error); diff-tree ecd3760b86ee8bc6d839b80303264d396131b60b (from 32955946fda66c445e1e3de12629890a8e2f354a) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 14:47:25 2007 +0200 add some printf warning flags diff --git a/configure.ac b/configure.ac index 1303884..63a0bde 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ dnl if we support them, we set them unco AS_COMPILER_FLAG(-Wall, GLOBAL_CFLAGS="-Wall", GLOBAL_CFLAGS="") dnl I want this but stupid headers don't let me dnl AS_COMPILER_FLAG(-Wshadow, GLOBAL_CFLAGS="$GLOBAL_CFLAGS -Wshadow") -AS_COMPILER_FLAG(-Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wold-style-definition -Wdeclaration-after-statement -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Winline, GLOBAL_CFLAGS="$GLOBAL_CFLAGS -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wold-style-definition -Wdeclaration-after-statement -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Winline") +AS_COMPILER_FLAG(-Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wold-style-definition -Wdeclaration-after-statement -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wformat-nonliteral -Wformat-security, GLOBAL_CFLAGS="$GLOBAL_CFLAGS -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wold-style-definition -Wdeclaration-after-statement -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wformat-nonliteral -Wformat-security") dnl if we're in nano >= 1, add -Werror if supported if test x$SWFDEC_CVS = xyes ; then AS_COMPILER_FLAG(-Werror, GLOBAL_CFLAGS="$GLOBAL_CFLAGS -Werror") diff-tree 32955946fda66c445e1e3de12629890a8e2f354a (from c7d4ebd5b036b286a32706e74315c376553fb36d) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 14:00:15 2007 +0200 add swfdec_as_frame_get_script () diff --git a/doc/swfdec-sections.txt b/doc/swfdec-sections.txt index cf0e5b1..c5f9076 100644 --- a/doc/swfdec-sections.txt +++ b/doc/swfdec-sections.txt @@ -374,6 +374,7 @@ SWFDEC_TYPE_AS_NATIVE_FUNCTION SwfdecAsFrame swfdec_as_frame_get_next swfdec_as_frame_get_function_name +swfdec_as_frame_get_script SwfdecAsStackIterator swfdec_as_stack_iterator_init swfdec_as_stack_iterator_init_arguments diff --git a/libswfdec/swfdec_as_frame.c b/libswfdec/swfdec_as_frame.c index 0721022..17f88cb 100644 --- a/libswfdec/swfdec_as_frame.c +++ b/libswfdec/swfdec_as_frame.c @@ -760,3 +760,20 @@ swfdec_as_frame_get_function_name (Swfde g_assert (frame->function_name); return frame->function_name; } + +/** + * swfdec_as_frame_get_script: + * @frame: a #SwfdecAsFrame + * + * Gets the script associated with the given @frame. If the frame references + * a native function, there will be no script and this function returns %NULL. + * + * Returns: The script executed by this frame or %NULL + **/ +SwfdecScript * +swfdec_as_frame_get_script (SwfdecAsFrame *frame) +{ + g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL); + + return frame->script; +} diff --git a/libswfdec/swfdec_as_frame.h b/libswfdec/swfdec_as_frame.h index 183f55d..8157858 100644 --- a/libswfdec/swfdec_as_frame.h +++ b/libswfdec/swfdec_as_frame.h @@ -48,6 +48,7 @@ GType swfdec_as_frame_get_type (void); SwfdecAsFrame * swfdec_as_frame_get_next (SwfdecAsFrame * frame); const char * swfdec_as_frame_get_function_name (SwfdecAsFrame * frame); +SwfdecScript * swfdec_as_frame_get_script (SwfdecAsFrame * frame); SwfdecAsValue * swfdec_as_stack_iterator_init (SwfdecAsStackIterator * iter, SwfdecAsFrame * frame); diff-tree c7d4ebd5b036b286a32706e74315c376553fb36d (from 6e6a99cc02d9399a08398cdcffe0599bc724fe1a) Author: Benjamin Otte <otte at gnome.org> Date: Thu Aug 16 13:34:44 2007 +0200 add ability to deactivate breakpoints use this to implement a "delete" command diff --git a/vivified/core/vivi_breakpoint.c b/vivified/core/vivi_breakpoint.c index 94922d4..506ee08 100644 --- a/vivified/core/vivi_breakpoint.c +++ b/vivified/core/vivi_breakpoint.c @@ -87,6 +87,31 @@ vivi_breakpoint_find_event (const char * } static void +vivi_breakpoint_add (ViviBreakpoint *breakpoint, guint i) +{ + ViviDebugger *debugger = VIVI_APPLICATION (SWFDEC_AS_OBJECT (breakpoint)->context)->debugger; + + g_assert (i != 0); + if (breakpoint->active) { + breakpoint->handlers[i] = g_signal_connect (debugger, events[i].signal, + events[i].handler, breakpoint); + } else { + breakpoint->handlers[i] = 1; + } +} + +static void +vivi_breakpoint_remove (ViviBreakpoint *breakpoint, guint i) +{ + ViviDebugger *debugger = VIVI_APPLICATION (SWFDEC_AS_OBJECT (breakpoint)->context)->debugger; + + g_assert (i != 0); + if (breakpoint->active) + g_signal_handler_disconnect (debugger, breakpoint->handlers[i]); + breakpoint->handlers[i] = 0; +} + +static void vivi_breakpoint_set (SwfdecAsObject *object, const char *variable, const SwfdecAsValue *val) { guint i; @@ -94,17 +119,13 @@ vivi_breakpoint_set (SwfdecAsObject *obj i = vivi_breakpoint_find_event (variable); if (i) { ViviBreakpoint *breakpoint = VIVI_BREAKPOINT (object); - ViviDebugger *debugger = VIVI_APPLICATION (object->context)->debugger; if (SWFDEC_AS_VALUE_IS_OBJECT (val) && SWFDEC_IS_AS_FUNCTION (SWFDEC_AS_VALUE_GET_OBJECT (val))) { if (!breakpoint->handlers[i]) - breakpoint->handlers[i] = g_signal_connect (debugger, events[i].signal, - events[i].handler, object); + vivi_breakpoint_add (breakpoint, i); } else { - if (breakpoint->handlers[i]) { - g_signal_handler_disconnect (debugger, breakpoint->handlers[i]); - breakpoint->handlers[i] = 0; - } + if (breakpoint->handlers[i]) + vivi_breakpoint_remove (breakpoint, i); } } SWFDEC_AS_OBJECT_CLASS (vivi_breakpoint_parent_class)->set (object, variable, val); @@ -117,11 +138,8 @@ vivi_breakpoint_delete (SwfdecAsObject * guint i; i = vivi_breakpoint_find_event (variable); - if (i && breakpoint->handlers[i]) { - ViviDebugger *debugger = VIVI_APPLICATION (object->context)->debugger; - g_signal_handler_disconnect (debugger, breakpoint->handlers[i]); - breakpoint->handlers[i] = 0; - } + if (i && breakpoint->handlers[i]) + vivi_breakpoint_remove (breakpoint, i); return SWFDEC_AS_OBJECT_CLASS (vivi_breakpoint_parent_class)->del (object, variable); } @@ -130,13 +148,9 @@ static void vivi_breakpoint_dispose (GObject *object) { ViviBreakpoint *breakpoint = VIVI_BREAKPOINT (object); - ViviDebugger *debugger = VIVI_APPLICATION (SWFDEC_AS_OBJECT (breakpoint)->context)->debugger; - guint i; - for (i = 0; i < G_N_ELEMENTS (events); i++) { - if (breakpoint->handlers[i]) - g_signal_handler_disconnect (debugger, breakpoint->handlers[i]); - } + vivi_breakpoint_set_active (breakpoint, FALSE); + G_OBJECT_CLASS (vivi_breakpoint_parent_class)->dispose (object); } @@ -155,7 +169,52 @@ vivi_breakpoint_class_init (ViviBreakpoi static void vivi_breakpoint_init (ViviBreakpoint *breakpoint) { + breakpoint->active = TRUE; +} + +void +vivi_breakpoint_set_active (ViviBreakpoint *breakpoint, gboolean active) +{ + guint i; + + g_return_if_fail (VIVI_IS_BREAKPOINT (breakpoint)); + + g_print ("active = %d", active); + if (breakpoint->active == active) + return; + breakpoint->active = !breakpoint->active; + for (i = 1; i < G_N_ELEMENTS (events); i++) { + if (breakpoint->handlers[i] == 0) + continue; + /* FIXME: this is hacky */ + breakpoint->active = !breakpoint->active; + vivi_breakpoint_remove (breakpoint, i); + breakpoint->active = !breakpoint->active; + vivi_breakpoint_add (breakpoint, i); + } } /*** AS CODE ***/ +VIVI_FUNCTION ("breakpoint_active_get", vivi_breakpoint_as_get_active) +void +vivi_breakpoint_as_get_active (SwfdecAsContext *cx, SwfdecAsObject *this, + guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval) +{ + if (!VIVI_IS_BREAKPOINT (this)) + return; + + SWFDEC_AS_VALUE_SET_BOOLEAN (retval, VIVI_BREAKPOINT (this)->active); +} + +VIVI_FUNCTION ("breakpoint_active_set", vivi_breakpoint_as_set_active) +void +vivi_breakpoint_as_set_active (SwfdecAsContext *cx, SwfdecAsObject *this, + guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval) +{ + if (!VIVI_IS_BREAKPOINT (this) || + argc == 0) + return; + vivi_breakpoint_set_active (VIVI_BREAKPOINT (this), swfdec_as_value_to_boolean (cx, &argv[0])); +} + diff --git a/vivified/core/vivi_breakpoint.h b/vivified/core/vivi_breakpoint.h index 5925ec9..87b2220 100644 --- a/vivified/core/vivi_breakpoint.h +++ b/vivified/core/vivi_breakpoint.h @@ -40,6 +40,7 @@ struct _ViviBreakpoint { SwfdecAsObject object; + gboolean active; /* only active breakpoints receive events */ gulong handlers[4]; /* handlers for every signal of the debugger or 0 */ }; @@ -50,6 +51,8 @@ struct _ViviBreakpointClass GType vivi_breakpoint_get_type (void); +void vivi_breakpoint_set_active (ViviBreakpoint * breakpoint, + gboolean active); G_END_DECLS #endif diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index 430110d..51ce35d 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -22,6 +22,7 @@ Breakpoint = function () extends Native. Breakpoint.list.push (this); }; Breakpoint.list = new Array (); +Breakpoint.prototype.addProperty ("active", Native.breakpoint_active_get, Native.breakpoint_active_set); Wrap = function () {}; Wrap.prototype = {}; @@ -74,3 +75,14 @@ Commands.list = function () { Commands.print (i + ": " + a[i]); } }; +Commands.del = function (id) { + var a = Breakpoint.list; + if (id == undefined) { + while (a[0]) + Commands.del (0); + } + var b = a[id]; + a.splice (id, 1); + b.active = false; +}; +Commands.delete = Commands.del;
Apparently Analagous Threads
- Branch 'vivi' - 13 commits - doc/swfdec-sections.txt libswfdec/swfdec_as_debugger.h libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_frame.h libswfdec/swfdec_as_types.h vivified/core vivified/ui
- 163 commits - autogen.sh configure.ac doc/swfdec-sections.txt libswfdec-gtk/swfdec_gtk_player.c libswfdec-gtk/swfdec_gtk_player.h libswfdec-gtk/swfdec_gtk_widget.c libswfdec-gtk/swfdec_source.c libswfdec/Makefile.am libswfdec/swfdec_as_array.c
- Branch 'vivi' - 11 commits - libswfdec-gtk/swfdec_gtk_widget.c libswfdec/Makefile.am libswfdec/swfdec.h libswfdec/swfdec_player.c libswfdec/swfdec_player_internal.h vivified/core
- Branch 'vivi' - 13 commits - libswfdec/swfdec_as_context.c libswfdec/swfdec_as_debugger.h libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_script_function.c test/trace vivified/core vivified/ui
- Branch 'vivi' - 4 commits - doc/swfdec-sections.txt libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_frame.h libswfdec/swfdec_as_string.c vivified/core