Benjamin Otte
2007-Aug-14 18:29 UTC
[Swfdec] 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
libswfdec-gtk/swfdec_gtk_widget.c | 2 libswfdec/Makefile.am | 4 - libswfdec/swfdec.h | 2 libswfdec/swfdec_player.c | 26 ++++++- libswfdec/swfdec_player_internal.h | 2 vivified/core/Makefile.am | 5 + vivified/core/vivi_application.c | 39 +++++++++- vivified/core/vivi_application.h | 5 + vivified/core/vivi_application_as.c | 20 +++++ vivified/core/vivi_breakpoint.c | 130 ++++++++++++++++++++++++++++++++++++ vivified/core/vivi_breakpoint.h | 55 +++++++++++++++ vivified/core/vivi_debugger.c | 103 ++++++++++++++++++++++++++++ vivified/core/vivi_debugger.h | 55 +++++++++++++++ vivified/core/vivi_function.c | 9 ++ vivified/core/vivi_initialize.as | 5 + 15 files changed, 452 insertions(+), 10 deletions(-) New commits: diff-tree adc7c2987283fe1ec7df8aa442d6d11b6d8d762a (from c1e028a0e58fb2821ce1d10898aca11fbc3c19a0) Author: Benjamin Otte <otte at gnome.org> Date: Tue Aug 14 20:29:22 2007 +0200 remove debugging g_print's diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c index d822642..585d295 100644 --- a/vivified/core/vivi_application.c +++ b/vivified/core/vivi_application.c @@ -140,7 +140,6 @@ vivi_application_init_player (ViviApplic g_return_if_fail (VIVI_IS_APPLICATION (app)); - g_print ("init\n"); if (app->player_inited) return; @@ -149,7 +148,6 @@ vivi_application_init_player (ViviApplic return; } - g_print ("really init\n"); loader = swfdec_file_loader_new (app->filename); swfdec_player_set_loader (app->player, loader); app->player_inited = TRUE; diff-tree c1e028a0e58fb2821ce1d10898aca11fbc3c19a0 (from 507c1f215ba04bee30f9b82d13040b51780275e9) Author: Benjamin Otte <otte at gnome.org> Date: Tue Aug 14 20:29:01 2007 +0200 add a quit command/function diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c index fadfcde..d822642 100644 --- a/vivified/core/vivi_application.c +++ b/vivified/core/vivi_application.c @@ -31,6 +31,7 @@ typedef enum { VIVI_APPLICATION_STOPPED, VIVI_APPLICATION_PLAYING, VIVI_APPLICATION_STEPPING, + VIVI_APPLICATION_EXITING, } ViviApplicationPlayback; enum { @@ -215,6 +216,12 @@ vivi_application_check (ViviApplication 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); @@ -314,3 +321,13 @@ vivi_application_step (ViviApplication * app->playback_count = n_times; } +void +vivi_application_quit (ViviApplication *app) +{ + g_return_if_fail (VIVI_IS_APPLICATION (app)); + + app->playback_state = VIVI_APPLICATION_EXITING; + app->playback_count = 1; + gtk_main_quit (); +} + diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h index 2f4fd33..d1f0da7 100644 --- a/vivified/core/vivi_application.h +++ b/vivified/core/vivi_application.h @@ -87,6 +87,7 @@ void vivi_application_play (ViviAppli void vivi_application_stop (ViviApplication * app); void vivi_application_step (ViviApplication * app, guint n_times); +void vivi_application_quit (ViviApplication * app); void vivi_applciation_execute (ViviApplication * app, const char * command); diff --git a/vivified/core/vivi_application_as.c b/vivified/core/vivi_application_as.c index 2e72f23..a637428 100644 --- a/vivified/core/vivi_application_as.c +++ b/vivified/core/vivi_application_as.c @@ -89,3 +89,13 @@ vivi_application_as_print (SwfdecAsConte vivi_application_output (app, "%s", s); } +VIVI_FUNCTION ("quit", vivi_application_as_quit) +void +vivi_application_as_quit (SwfdecAsContext *cx, SwfdecAsObject *this, + guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval) +{ + ViviApplication *app = VIVI_APPLICATION (cx); + + vivi_application_quit (app); +} + diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index e5809b0..376e594 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -30,5 +30,6 @@ Commands.restart = function () { Commands.reset (); Commands.run (); }; +Commands.quit = Native.quit; Breakpoint = Native.Breakpoint; diff-tree 507c1f215ba04bee30f9b82d13040b51780275e9 (from c26fe8330d6c77a5a0bc34f4ca3ce63a74f8bf28) Author: Benjamin Otte <otte at gnome.org> Date: Tue Aug 14 15:16:31 2007 +0200 add breakpoints diff --git a/vivified/core/Makefile.am b/vivified/core/Makefile.am index 7d2fd48..694ddad 100644 --- a/vivified/core/Makefile.am +++ b/vivified/core/Makefile.am @@ -6,6 +6,8 @@ libvivified_core_la_LDFLAGS = $(SWFDEC_G libvivified_core_la_SOURCES = \ vivi_application.c \ vivi_application_as.c \ + vivi_application.c \ + vivi_breakpoint.c \ vivi_debugger.c \ vivi_function.c \ vivi_initialize.as \ @@ -17,6 +19,7 @@ vivi_initialize.lo: vivi_initialize.s vi noinst_HEADERS = \ vivi_application.h \ + vivi_breakpoint.h \ vivi_debugger.h \ vivi_function.h \ vivi_function_list.h \ diff --git a/vivified/core/vivi_breakpoint.c b/vivified/core/vivi_breakpoint.c new file mode 100644 index 0000000..7931e28 --- /dev/null +++ b/vivified/core/vivi_breakpoint.c @@ -0,0 +1,130 @@ +/* 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_breakpoint.h" +#include "vivi_application.h" +#include "vivi_function.h" + +G_DEFINE_TYPE (ViviBreakpoint, vivi_breakpoint, SWFDEC_TYPE_AS_OBJECT) + +static gboolean +vivi_breakpoint_step (ViviDebugger *debugger, ViviBreakpoint *breakpoint) +{ + SwfdecAsObject *obj = SWFDEC_AS_OBJECT (breakpoint); + SwfdecAsValue val; + + swfdec_as_object_call (obj, swfdec_as_context_get_string (obj->context, "onStep"), 0, NULL, &val); + return swfdec_as_value_to_boolean (obj->context, &val); +} + +static const struct { + const char * event; + const char * signal; + GCallback handler; +} events[] = { + { NULL, NULL, NULL }, /* invalid */ + { "onStep", "step", G_CALLBACK (vivi_breakpoint_step) } +}; + +static guint +vivi_breakpoint_find_event (const char *name) +{ + guint i; + + for (i = 1; i < G_N_ELEMENTS (events); i++) { + if (g_str_equal (events[i].event, name)) + return i; + } + return 0; +} + +static void +vivi_breakpoint_set (SwfdecAsObject *object, const char *variable, const SwfdecAsValue *val) +{ + guint i; + + 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); + } else { + if (breakpoint->handlers[i]) + g_signal_handler_disconnect (debugger, breakpoint->handlers[i]); + } + } + SWFDEC_AS_OBJECT_CLASS (vivi_breakpoint_parent_class)->set (object, variable, val); +} + +static gboolean +vivi_breakpoint_delete (SwfdecAsObject *object, const char *variable) +{ + ViviBreakpoint *breakpoint = VIVI_BREAKPOINT (object); + 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]); + } + + return SWFDEC_AS_OBJECT_CLASS (vivi_breakpoint_parent_class)->del (object, variable); +} + +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]); + } + G_OBJECT_CLASS (vivi_breakpoint_parent_class)->dispose (object); +} + +static void +vivi_breakpoint_class_init (ViviBreakpointClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + SwfdecAsObjectClass *as_object_class = SWFDEC_AS_OBJECT_CLASS (klass); + + object_class->dispose = vivi_breakpoint_dispose; + + as_object_class->set = vivi_breakpoint_set; + as_object_class->del = vivi_breakpoint_delete; +} + +static void +vivi_breakpoint_init (ViviBreakpoint *breakpoint) +{ +} + +/*** AS CODE ***/ + diff --git a/vivified/core/vivi_breakpoint.h b/vivified/core/vivi_breakpoint.h new file mode 100644 index 0000000..084cc8f --- /dev/null +++ b/vivified/core/vivi_breakpoint.h @@ -0,0 +1,55 @@ +/* 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 + */ + +#ifndef _VIVI_BREAKPOINT_H_ +#define _VIVI_BREAKPOINT_H_ + +#include <libswfdec/swfdec.h> +#include <vivified/core/vivi_application.h> + +G_BEGIN_DECLS + + +typedef struct _ViviBreakpoint ViviBreakpoint; +typedef struct _ViviBreakpointClass ViviBreakpointClass; + +#define VIVI_TYPE_BREAKPOINT (vivi_breakpoint_get_type()) +#define VIVI_IS_BREAKPOINT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIVI_TYPE_BREAKPOINT)) +#define VIVI_IS_BREAKPOINT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIVI_TYPE_BREAKPOINT)) +#define VIVI_BREAKPOINT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIVI_TYPE_BREAKPOINT, ViviBreakpoint)) +#define VIVI_BREAKPOINT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VIVI_TYPE_BREAKPOINT, ViviBreakpointClass)) +#define VIVI_BREAKPOINT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VIVI_TYPE_BREAKPOINT, ViviBreakpointClass)) + +struct _ViviBreakpoint +{ + SwfdecAsObject object; + + gulong handlers[2]; /* handlers for every signal of the debugger or 0 */ +}; + +struct _ViviBreakpointClass +{ + SwfdecAsObjectClass object_class; +}; + +GType vivi_breakpoint_get_type (void); + + +G_END_DECLS +#endif diff --git a/vivified/core/vivi_function.c b/vivified/core/vivi_function.c index 6fb5197..cfcb382 100644 --- a/vivified/core/vivi_function.c +++ b/vivified/core/vivi_function.c @@ -22,6 +22,7 @@ #endif #include "vivi_function.h" +#include "vivi_breakpoint.h" #include "vivi_function_list.h" /* include vivi_function_list with special macro definition, so we get a nice @@ -52,6 +53,7 @@ void vivi_function_init_context (ViviApplication *app) { SwfdecAsContext *cx = SWFDEC_AS_CONTEXT (app); + SwfdecAsFunction *fun; SwfdecAsObject *obj; SwfdecAsValue val; guint i; @@ -68,6 +70,13 @@ vivi_function_init_context (ViviApplicat swfdec_as_context_get_string (cx, functions[i].name), 0, functions[i].fun, 0); } + /* FIXME: find a better solution than this */ + fun = swfdec_as_object_add_function (obj, + swfdec_as_context_get_string (cx, "Breakpoint"), + 0, functions[i].fun, 0); + swfdec_as_native_function_set_construct_type (SWFDEC_AS_NATIVE_FUNCTION (fun), + VIVI_TYPE_BREAKPOINT); + g_signal_connect (app, "message", G_CALLBACK (vivi_function_not_reached), NULL); vivi_applciation_execute (app, vivi_initialize); g_signal_handlers_disconnect_by_func (app, G_CALLBACK (vivi_function_not_reached), NULL); diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index d8eadc5..e5809b0 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -30,3 +30,5 @@ Commands.restart = function () { Commands.reset (); Commands.run (); }; + +Breakpoint = Native.Breakpoint; diff-tree c26fe8330d6c77a5a0bc34f4ca3ce63a74f8bf28 (from 7cc61118ddf98319b1641013587b505affc01300) Author: Benjamin Otte <otte at gnome.org> Date: Tue Aug 14 14:49:56 2007 +0200 apparently the function headers weren't installed either. They are documented though (nice!) diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am index fc9d47f..b9a63b3 100644 --- a/libswfdec/Makefile.am +++ b/libswfdec/Makefile.am @@ -128,6 +128,8 @@ public_headers = \ swfdec_as_context.h \ swfdec_as_debugger.h \ swfdec_as_frame.h \ + swfdec_as_function.h \ + swfdec_as_native_function.h \ swfdec_as_object.h \ swfdec_as_types.h \ swfdec_audio.h \ @@ -147,11 +149,9 @@ noinst_HEADERS = \ swfdec_as_array.h \ swfdec_as_boolean.h \ swfdec_as_frame_internal.h \ - swfdec_as_function.h \ swfdec_as_internal.h \ swfdec_as_interpret.h \ swfdec_as_math.h \ - swfdec_as_native_function.h \ swfdec_as_number.h \ swfdec_as_scope.h \ swfdec_as_script_function.h \ diff-tree 7cc61118ddf98319b1641013587b505affc01300 (from b8865e69f74f00f1c2b373003900b24592df341b) Author: Benjamin Otte <otte at gnome.org> Date: Tue Aug 14 14:48:38 2007 +0200 These two files were missing in the headers diff --git a/libswfdec/swfdec.h b/libswfdec/swfdec.h index ec4d136..8a4cd65 100644 --- a/libswfdec/swfdec.h +++ b/libswfdec/swfdec.h @@ -25,6 +25,8 @@ #include <libswfdec/swfdec_as_context.h> #include <libswfdec/swfdec_as_debugger.h> #include <libswfdec/swfdec_as_frame.h> +#include <libswfdec/swfdec_as_function.h> +#include <libswfdec/swfdec_as_native_function.h> #include <libswfdec/swfdec_as_object.h> #include <libswfdec/swfdec_as_types.h> #include <libswfdec/swfdec_script.h> diff-tree b8865e69f74f00f1c2b373003900b24592df341b (from 2421ba7779043c938533566a0a23a8ab5c3a84ff) Author: Benjamin Otte <otte at gnome.org> Date: Tue Aug 14 12:47:48 2007 +0200 g_object_notify() about a new player diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c index dd3b46f..fadfcde 100644 --- a/vivified/core/vivi_application.c +++ b/vivified/core/vivi_application.c @@ -163,6 +163,7 @@ vivi_application_reset (ViviApplication g_object_unref (app->player); app->player = swfdec_gtk_player_new (SWFDEC_AS_DEBUGGER (app->debugger)); app->player_inited = FALSE; + g_object_notify (G_OBJECT (app), "player"); } void diff-tree 2421ba7779043c938533566a0a23a8ab5c3a84ff (from c5c3edfb757eb8ff0bad4301fc877cc38a648815) Author: Benjamin Otte <otte at gnome.org> Date: Tue Aug 14 12:45:24 2007 +0200 implement the debugger and use it diff --git a/vivified/core/Makefile.am b/vivified/core/Makefile.am index 6b0e473..7d2fd48 100644 --- a/vivified/core/Makefile.am +++ b/vivified/core/Makefile.am @@ -6,6 +6,7 @@ libvivified_core_la_LDFLAGS = $(SWFDEC_G libvivified_core_la_SOURCES = \ vivi_application.c \ vivi_application_as.c \ + vivi_debugger.c \ vivi_function.c \ vivi_initialize.as \ vivi_initialize.s \ @@ -16,6 +17,7 @@ vivi_initialize.lo: vivi_initialize.s vi noinst_HEADERS = \ vivi_application.h \ + vivi_debugger.h \ vivi_function.h \ vivi_function_list.h \ vivi_ming.h \ diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c index 958b459..dd3b46f 100644 --- a/vivified/core/vivi_application.c +++ b/vivified/core/vivi_application.c @@ -23,6 +23,7 @@ #include <libswfdec-gtk/swfdec-gtk.h> #include "vivi_application.h" +#include "vivi_debugger.h" #include "vivi_function.h" #include "vivi_ming.h" @@ -115,7 +116,9 @@ vivi_application_class_init (ViviApplica static void vivi_application_init (ViviApplication *app) { - app->player = swfdec_gtk_player_new (NULL); + app->debugger = g_object_new (VIVI_TYPE_DEBUGGER, NULL); + app->debugger->app = app; + app->player = swfdec_gtk_player_new (SWFDEC_AS_DEBUGGER (app->debugger)); } ViviApplication * @@ -156,8 +159,9 @@ 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? */ g_object_unref (app->player); - app->player = swfdec_gtk_player_new (NULL); + app->player = swfdec_gtk_player_new (SWFDEC_AS_DEBUGGER (app->debugger)); app->player_inited = FALSE; } diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h index fab0262..2f4fd33 100644 --- a/vivified/core/vivi_application.h +++ b/vivified/core/vivi_application.h @@ -27,6 +27,8 @@ G_BEGIN_DECLS typedef struct _ViviApplication ViviApplication; typedef struct _ViviApplicationClass ViviApplicationClass; +/* forward declarations */ +typedef struct _ViviDebugger ViviDebugger; typedef enum { VIVI_MESSAGE_INPUT, @@ -47,6 +49,7 @@ struct _ViviApplication char * filename; /* name of the file we play back or NULL if none set yet */ SwfdecPlayer * player; /* the current player */ + ViviDebugger * debugger; /* the debugger used in player */ gboolean player_inited; /* if the player is inited already */ guint playback_state; /* (running, stepping or stopped) */ guint playback_count; /* how often to just restart this on breakpoints */ diff --git a/vivified/core/vivi_debugger.c b/vivified/core/vivi_debugger.c new file mode 100644 index 0000000..fcad454 --- /dev/null +++ b/vivified/core/vivi_debugger.c @@ -0,0 +1,103 @@ +/* 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_debugger.h" +#include "vivi_application.h" +/* FIXME: oops */ +#include "libswfdec/swfdec_player_internal.h" + +enum { + STEP, + LAST_SIGNAL +}; + +G_DEFINE_TYPE (ViviDebugger, vivi_debugger, SWFDEC_TYPE_AS_DEBUGGER) +static guint signals[LAST_SIGNAL] = { 0, }; + +static gboolean +vivi_accumulate_or (GSignalInvocationHint *ihint, GValue *return_accu, + const GValue *handler_return, gpointer data) +{ + if (g_value_get_boolean (handler_return)) + g_value_set_boolean (return_accu, TRUE); + return TRUE; +} + +static void +vivi_debugger_dispose (GObject *object) +{ + //ViviDebugger *debugger = VIVI_DEBUGGER (object); + + G_OBJECT_CLASS (vivi_debugger_parent_class)->dispose (object); +} + +static void +vivi_debugger_break (ViviDebugger *debugger) +{ + ViviApplication *app = debugger->app; + + g_assert (app); + swfdec_player_unlock_soft (app->player); + + app->playback_state = 0; + app->playback_count = 0; + app->loop = g_main_loop_new (NULL, FALSE); + + g_main_loop_run (app->loop); + + g_main_loop_unref (app->loop); + app->loop = NULL; + swfdec_player_lock_soft (app->player); +} + +static void +vivi_debugger_step (SwfdecAsDebugger *debugger, SwfdecAsContext *context) +{ + gboolean retval = FALSE; + + g_signal_emit (debugger, signals[STEP], 0, &retval); + + if (retval) + vivi_debugger_break (VIVI_DEBUGGER (debugger)); +} + +static void +vivi_debugger_class_init (ViviDebuggerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + SwfdecAsDebuggerClass *debugger_class = SWFDEC_AS_DEBUGGER_CLASS (klass); + + object_class->dispose = vivi_debugger_dispose; + + signals[STEP] = g_signal_new ("step", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, 0, vivi_accumulate_or, NULL, g_cclosure_marshal_VOID__VOID, + G_TYPE_BOOLEAN, 0); + + debugger_class->step = vivi_debugger_step; +} + +static void +vivi_debugger_init (ViviDebugger *debugger) +{ +} + diff --git a/vivified/core/vivi_debugger.h b/vivified/core/vivi_debugger.h new file mode 100644 index 0000000..76873ab --- /dev/null +++ b/vivified/core/vivi_debugger.h @@ -0,0 +1,55 @@ +/* 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 + */ + +#ifndef _VIVI_DEBUGGER_H_ +#define _VIVI_DEBUGGER_H_ + +#include <libswfdec/swfdec.h> +#include <vivified/core/vivi_application.h> + +G_BEGIN_DECLS + + +//typedef struct _ViviDebugger ViviDebugger; +typedef struct _ViviDebuggerClass ViviDebuggerClass; + +#define VIVI_TYPE_DEBUGGER (vivi_debugger_get_type()) +#define VIVI_IS_DEBUGGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIVI_TYPE_DEBUGGER)) +#define VIVI_IS_DEBUGGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIVI_TYPE_DEBUGGER)) +#define VIVI_DEBUGGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIVI_TYPE_DEBUGGER, ViviDebugger)) +#define VIVI_DEBUGGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VIVI_TYPE_DEBUGGER, ViviDebuggerClass)) +#define VIVI_DEBUGGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VIVI_TYPE_DEBUGGER, ViviDebuggerClass)) + +struct _ViviDebugger +{ + SwfdecAsDebugger debugger; + + ViviApplication * app; /* the appliction we're playing for */ +}; + +struct _ViviDebuggerClass +{ + SwfdecAsDebuggerClass debugger_class; +}; + +GType vivi_debugger_get_type (void); + + +G_END_DECLS +#endif diff-tree c5c3edfb757eb8ff0bad4301fc877cc38a648815 (from df83f6880be9203515164615fae3da464d36027b) Author: Benjamin Otte <otte at gnome.org> Date: Tue Aug 14 12:26:37 2007 +0200 add swfdec_player_(un)lock_soft () functions diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c index e1c7748..2bb0264 100644 --- a/libswfdec/swfdec_player.c +++ b/libswfdec/swfdec_player.c @@ -1043,11 +1043,11 @@ swfdec_player_perform_actions (SwfdecPla player->invalid = old_inval; } +/* used for breakpoints */ void -swfdec_player_lock (SwfdecPlayer *player) +swfdec_player_lock_soft (SwfdecPlayer *player) { g_return_if_fail (SWFDEC_IS_PLAYER (player)); - g_assert (swfdec_ring_buffer_get_n_elements (player->actions) == 0); g_assert (swfdec_rect_is_empty (&player->invalid)); g_object_freeze_notify (G_OBJECT (player)); @@ -1055,18 +1055,36 @@ swfdec_player_lock (SwfdecPlayer *player } void -swfdec_player_unlock (SwfdecPlayer *player) +swfdec_player_lock (SwfdecPlayer *player) { g_return_if_fail (SWFDEC_IS_PLAYER (player)); g_assert (swfdec_ring_buffer_get_n_elements (player->actions) == 0); + swfdec_player_lock_soft (player); +} + +/* used for breakpoints */ +void +swfdec_player_unlock_soft (SwfdecPlayer *player) +{ + g_return_if_fail (SWFDEC_IS_PLAYER (player)); + SWFDEC_DEBUG ("UNLOCK"); - swfdec_as_context_maybe_gc (SWFDEC_AS_CONTEXT (player)); swfdec_player_update_mouse_cursor (player); g_object_thaw_notify (G_OBJECT (player)); swfdec_player_emit_signals (player); } +void +swfdec_player_unlock (SwfdecPlayer *player) +{ + g_return_if_fail (SWFDEC_IS_PLAYER (player)); + g_assert (swfdec_ring_buffer_get_n_elements (player->actions) == 0); + + swfdec_as_context_maybe_gc (SWFDEC_AS_CONTEXT (player)); + swfdec_player_unlock_soft (player); +} + static gboolean swfdec_accumulate_or (GSignalInvocationHint *ihint, GValue *return_accu, const GValue *handler_return, gpointer data) diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h index 0d27ec8..0c7ed68 100644 --- a/libswfdec/swfdec_player_internal.h +++ b/libswfdec/swfdec_player_internal.h @@ -148,7 +148,9 @@ void swfdec_player_remove_movie (Swfdec SwfdecMovie * movie); void swfdec_player_lock (SwfdecPlayer * player); +void swfdec_player_lock_soft (SwfdecPlayer * player); void swfdec_player_unlock (SwfdecPlayer * player); +void swfdec_player_unlock_soft (SwfdecPlayer * player); void swfdec_player_perform_actions (SwfdecPlayer * player); SwfdecAsObject *swfdec_player_get_export_class (SwfdecPlayer * player, diff-tree df83f6880be9203515164615fae3da464d36027b (from 1ffa1414f746e1ae2c7cce75518419a501428c83) Author: Benjamin Otte <otte at gnome.org> Date: Tue Aug 14 11:12:43 2007 +0200 maybe GC after function calls diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c index 0b13eaa..958b459 100644 --- a/vivified/core/vivi_application.c +++ b/vivified/core/vivi_application.c @@ -207,6 +207,8 @@ vivi_application_check (ViviApplication gboolean is_playing = swfdec_gtk_player_get_playing (SWFDEC_GTK_PLAYER (app->player)); gboolean is_breakpoint = app->loop != NULL; + swfdec_as_context_maybe_gc (SWFDEC_AS_CONTEXT (app)); + switch (app->playback_state) { case VIVI_APPLICATION_STOPPED: if (is_playing) diff-tree 1ffa1414f746e1ae2c7cce75518419a501428c83 (from f78c7cf7699db1844c0215bd637105b367d86912) Author: Benjamin Otte <otte at gnome.org> Date: Tue Aug 14 10:40:23 2007 +0200 return TRUE for consumed key press/reelease events This gets around those events changing focus, so the widget is still focused after pressing tab diff --git a/libswfdec-gtk/swfdec_gtk_widget.c b/libswfdec-gtk/swfdec_gtk_widget.c index 61cffca..94b7f31 100644 --- a/libswfdec-gtk/swfdec_gtk_widget.c +++ b/libswfdec-gtk/swfdec_gtk_widget.c @@ -166,6 +166,7 @@ swfdec_gtk_widget_key_press (GtkWidget * swfdec_player_key_press (priv->player, keycode, gdk_keyval_to_unicode (event->keyval)); } + return TRUE; } return FALSE; @@ -183,6 +184,7 @@ swfdec_gtk_widget_key_release (GtkWidget swfdec_player_key_release (priv->player, keycode, gdk_keyval_to_unicode (event->keyval)); } + return TRUE; } return FALSE; diff-tree f78c7cf7699db1844c0215bd637105b367d86912 (from e6ae2a00a9b1aadbbc45cea54cefe6bfa60f023b) Author: Benjamin Otte <otte at gnome.org> Date: Tue Aug 14 10:27:07 2007 +0200 add a method to stop a running player diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c index a87aa55..0b13eaa 100644 --- a/vivified/core/vivi_application.c +++ b/vivified/core/vivi_application.c @@ -290,6 +290,15 @@ vivi_application_play (ViviApplication * } void +vivi_application_stop (ViviApplication *app) +{ + g_return_if_fail (VIVI_IS_APPLICATION (app)); + + app->playback_state = VIVI_APPLICATION_STOPPED; + app->playback_count = 0; +} + +void vivi_application_step (ViviApplication *app, guint n_times) { g_return_if_fail (VIVI_IS_APPLICATION (app)); diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h index d250989..fab0262 100644 --- a/vivified/core/vivi_application.h +++ b/vivified/core/vivi_application.h @@ -81,6 +81,7 @@ SwfdecPlayer * vivi_application_g void vivi_application_init_player (ViviApplication * app); void vivi_application_reset (ViviApplication * app); void vivi_application_play (ViviApplication * app); +void vivi_application_stop (ViviApplication * app); void vivi_application_step (ViviApplication * app, guint n_times); diff --git a/vivified/core/vivi_application_as.c b/vivified/core/vivi_application_as.c index 24814a7..2e72f23 100644 --- a/vivified/core/vivi_application_as.c +++ b/vivified/core/vivi_application_as.c @@ -45,6 +45,16 @@ vivi_application_as_run (SwfdecAsContext vivi_application_play (app); } +VIVI_FUNCTION ("stop", vivi_application_as_stop) +void +vivi_application_as_stop (SwfdecAsContext *cx, SwfdecAsObject *this, + guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval) +{ + ViviApplication *app = VIVI_APPLICATION (cx); + + vivi_application_stop (app); +} + VIVI_FUNCTION ("step", vivi_application_as_step) void vivi_application_as_step (SwfdecAsContext *cx, SwfdecAsObject *this, diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as index dfae8f3..d8eadc5 100644 --- a/vivified/core/vivi_initialize.as +++ b/vivified/core/vivi_initialize.as @@ -21,6 +21,8 @@ Commands = new Object (); Commands.print = Native.print; Commands.r = Native.run; Commands.run = Native.run; +Commands.halt = Native.stop; +Commands.stop = Native.stop; Commands.s = Native.step; Commands.step = Native.step; Commands.reset = Native.reset;
Possibly Parallel 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' - 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
- 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' - 24 commits - configure.ac libswfdec/swfdec_sprite_movie.c libswfdec/swfdec_tag.c libswfdec/swfdec_tag.h vivified/core vivified/dock vivified/ui