[Swfdec] 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
Benjamin Otte
company at kemper.freedesktop.org
Wed Aug 15 10:05:20 PDT 2007
doc/swfdec-sections.txt | 1
libswfdec/swfdec_as_debugger.h | 12 +++-
libswfdec/swfdec_as_frame.c | 36 +++++++++++-
libswfdec/swfdec_as_frame.h | 1
libswfdec/swfdec_as_types.h | 2
vivified/core/.gitignore | 2
vivified/core/Makefile.am | 25 +++++++-
vivified/core/vivi_application.c | 12 +---
vivified/core/vivi_application.h | 13 +++-
vivified/core/vivi_breakpoint.c | 39 ++++++++++++-
vivified/core/vivi_breakpoint.h | 2
vivified/core/vivi_debugger.c | 51 +++++++++++++++++
vivified/core/vivi_function.c | 2
vivified/core/vivi_initialize.as | 9 +++
vivified/core/vivi_marshal.list | 3 +
vivified/core/vivi_wrap.c | 113 +++++++++++++++++++++++++++++++++++++++
vivified/core/vivi_wrap.h | 60 ++++++++++++++++++++
vivified/core/vivi_wrap_as.c | 68 +++++++++++++++++++++++
vivified/ui/vivi_commandline.c | 2
19 files changed, 426 insertions(+), 27 deletions(-)
New commits:
diff-tree 82cbf15d290ca8584505fd0c1970fa976de545dc (from a3c5a9238df3924961d13599cbdad970f79ddede)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 12:50:18 2007 +0200
get rid of debugging prints
diff --git a/vivified/core/vivi_wrap_as.c b/vivified/core/vivi_wrap_as.c
index 9cc9b5d..cf9e4a8 100644
--- a/vivified/core/vivi_wrap_as.c
+++ b/vivified/core/vivi_wrap_as.c
@@ -54,16 +54,13 @@ vivi_wrap_name_get (SwfdecAsContext *cx,
ViviWrap *wrap;
const char *s;
- g_print ("1\n");
if (!VIVI_IS_WRAP (this))
return;
- g_print ("2\n");
wrap = VIVI_WRAP (this);
if (!SWFDEC_IS_AS_FRAME (wrap->wrap))
return;
- g_print ("3\n");
s = swfdec_as_frame_get_function_name (SWFDEC_AS_FRAME (wrap->wrap));
SWFDEC_AS_VALUE_SET_STRING (retval, swfdec_as_context_get_string (cx, s));
}
diff-tree a3c5a9238df3924961d13599cbdad970f79ddede (from e2df3bc346bf44ba07d4a6c62876d1d96279412e)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 12:49:48 2007 +0200
add support for having Frame and Wrap objects
diff --git a/vivified/core/Makefile.am b/vivified/core/Makefile.am
index e535481..9403543 100644
--- a/vivified/core/Makefile.am
+++ b/vivified/core/Makefile.am
@@ -14,7 +14,8 @@ libvivified_core_la_SOURCES = \
vivi_initialize.s \
vivi_marshal.c \
vivi_ming.c \
- vivi_wrap.c
+ vivi_wrap.c \
+ vivi_wrap_as.c
vivi_initialize.lo: vivi_initialize.s vivi_initialize.as
$(LTCCASCOMPILE) -c -o $@ vivi_initialize.s
diff --git a/vivified/core/vivi_debugger.c b/vivified/core/vivi_debugger.c
index 4d81c45..44149cc 100644
--- a/vivified/core/vivi_debugger.c
+++ b/vivified/core/vivi_debugger.c
@@ -88,7 +88,7 @@ vivi_debugger_step (SwfdecAsDebugger *de
g_signal_emit (debugger, signals[STEP], 0, &retval);
if (!retval) {
- ViviApplication *app = VIVI_APPLICATION (context);
+ ViviApplication *app = VIVI_DEBUGGER (debugger)->app;
if (app->playback_state == VIVI_APPLICATION_STEPPING) {
app->playback_count--;
diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as
index 376e594..4852d82 100644
--- a/vivified/core/vivi_initialize.as
+++ b/vivified/core/vivi_initialize.as
@@ -33,3 +33,12 @@ Commands.restart = function () {
Commands.quit = Native.quit;
Breakpoint = Native.Breakpoint;
+
+Wrap = function () {};
+Wrap.prototype = {};
+Wrap.prototype.toString = Native.wrap_toString;
+
+Frame = function () extends Wrap {};
+Frame.prototype = new Wrap ();
+Frame.prototype.addProperty ("name", Native.frame_name_get, null);
+
diff --git a/vivified/core/vivi_wrap_as.c b/vivified/core/vivi_wrap_as.c
new file mode 100644
index 0000000..9cc9b5d
--- /dev/null
+++ b/vivified/core/vivi_wrap_as.c
@@ -0,0 +1,71 @@
+/* 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 ("wrap_toString", vivi_wrap_toString)
+void
+vivi_wrap_toString (SwfdecAsContext *cx, SwfdecAsObject *this,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ ViviWrap *wrap;
+ char *s;
+
+ if (!VIVI_IS_WRAP (this))
+ return;
+
+ wrap = VIVI_WRAP (this);
+ if (wrap->wrap == NULL)
+ return;
+
+ s = swfdec_as_object_get_debug (wrap->wrap);
+ SWFDEC_AS_VALUE_SET_STRING (retval, swfdec_as_context_give_string (cx, s));
+}
+
+/*** FRAME specific code ***/
+
+VIVI_FUNCTION ("frame_name_get", vivi_wrap_name_get)
+void
+vivi_wrap_name_get (SwfdecAsContext *cx, SwfdecAsObject *this,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ ViviWrap *wrap;
+ const char *s;
+
+ g_print ("1\n");
+ if (!VIVI_IS_WRAP (this))
+ return;
+
+ g_print ("2\n");
+ wrap = VIVI_WRAP (this);
+ if (!SWFDEC_IS_AS_FRAME (wrap->wrap))
+ return;
+
+ g_print ("3\n");
+ s = swfdec_as_frame_get_function_name (SWFDEC_AS_FRAME (wrap->wrap));
+ SWFDEC_AS_VALUE_SET_STRING (retval, swfdec_as_context_get_string (cx, s));
+}
+
+
diff-tree e2df3bc346bf44ba07d4a6c62876d1d96279412e (from a4cedb3d624ef14126d783967a564d0c572040b2)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 10:57:21 2007 +0200
add swfdec_as_frame_get_function_name() function
diff --git a/doc/swfdec-sections.txt b/doc/swfdec-sections.txt
index 69d7785..cf0e5b1 100644
--- a/doc/swfdec-sections.txt
+++ b/doc/swfdec-sections.txt
@@ -373,6 +373,7 @@ SWFDEC_TYPE_AS_NATIVE_FUNCTION
<TITLE>SwfdecAsFrame</TITLE>
SwfdecAsFrame
swfdec_as_frame_get_next
+swfdec_as_frame_get_function_name
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 3a08819..0721022 100644
--- a/libswfdec/swfdec_as_frame.c
+++ b/libswfdec/swfdec_as_frame.c
@@ -743,3 +743,20 @@ swfdec_as_frame_get_next (SwfdecAsFrame
return frame->next;
}
+/**
+ * swfdec_as_frame_get_function_name:
+ * @frame: a #SwfdecAsFrame
+ *
+ * Gets the name of the function that is currently executing. This function is
+ * intended for debugging purposes.
+ *
+ * Returns: a string. Do not free.
+ **/
+const char *
+swfdec_as_frame_get_function_name (SwfdecAsFrame *frame)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
+
+ g_assert (frame->function_name);
+ return frame->function_name;
+}
diff --git a/libswfdec/swfdec_as_frame.h b/libswfdec/swfdec_as_frame.h
index 17fdccf..183f55d 100644
--- a/libswfdec/swfdec_as_frame.h
+++ b/libswfdec/swfdec_as_frame.h
@@ -47,6 +47,7 @@ struct _SwfdecAsStackIterator {
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);
SwfdecAsValue * swfdec_as_stack_iterator_init (SwfdecAsStackIterator * iter,
SwfdecAsFrame * frame);
diff-tree a4cedb3d624ef14126d783967a564d0c572040b2 (from faabbdf9705060fdf574260e3e0cea87261ebeb1)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 10:43:20 2007 +0200
implement onStartFrame and onExitFrame breakpoint callbacks
diff --git a/vivified/core/vivi_breakpoint.c b/vivified/core/vivi_breakpoint.c
index 19a1f22..94922d4 100644
--- a/vivified/core/vivi_breakpoint.c
+++ b/vivified/core/vivi_breakpoint.c
@@ -24,6 +24,7 @@
#include "vivi_breakpoint.h"
#include "vivi_application.h"
#include "vivi_function.h"
+#include "vivi_wrap.h"
G_DEFINE_TYPE (ViviBreakpoint, vivi_breakpoint, SWFDEC_TYPE_AS_OBJECT)
@@ -31,10 +32,35 @@ static gboolean
vivi_breakpoint_step (ViviDebugger *debugger, ViviBreakpoint *breakpoint)
{
SwfdecAsObject *obj = SWFDEC_AS_OBJECT (breakpoint);
+ SwfdecAsValue retval;
+
+ swfdec_as_object_call (obj, swfdec_as_context_get_string (obj->context, "onCommand"), 0, NULL, &retval);
+ return swfdec_as_value_to_boolean (obj->context, &retval);
+}
+
+static gboolean
+vivi_breakpoint_start_frame (ViviDebugger *debugger, SwfdecAsFrame *frame, ViviBreakpoint *breakpoint)
+{
+ SwfdecAsObject *obj = SWFDEC_AS_OBJECT (breakpoint);
SwfdecAsValue val;
+ SwfdecAsValue retval;
+
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, vivi_wrap_object (VIVI_APPLICATION (obj->context), SWFDEC_AS_OBJECT (frame)));
+ swfdec_as_object_call (obj, swfdec_as_context_get_string (obj->context, "onStartFrame"), 1, &val, &retval);
+ return swfdec_as_value_to_boolean (obj->context, &retval);
+}
+
+static gboolean
+vivi_breakpoint_finish_frame (ViviDebugger *debugger, SwfdecAsFrame *frame, const SwfdecAsValue *ret, ViviBreakpoint *breakpoint)
+{
+ SwfdecAsObject *obj = SWFDEC_AS_OBJECT (breakpoint);
+ SwfdecAsValue vals[2];
+ SwfdecAsValue retval;
- 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);
+ SWFDEC_AS_VALUE_SET_OBJECT (&vals[0], vivi_wrap_object (VIVI_APPLICATION (obj->context), SWFDEC_AS_OBJECT (frame)));
+ vivi_wrap_value (VIVI_APPLICATION (obj->context), &vals[1], ret);
+ swfdec_as_object_call (obj, swfdec_as_context_get_string (obj->context, "onStartFrame"), 2, vals, &retval);
+ return swfdec_as_value_to_boolean (obj->context, &retval);
}
static const struct {
@@ -43,7 +69,9 @@ static const struct {
GCallback handler;
} events[] = {
{ NULL, NULL, NULL }, /* invalid */
- { "onStep", "step", G_CALLBACK (vivi_breakpoint_step) }
+ { "onCommand", "step", G_CALLBACK (vivi_breakpoint_step) },
+ { "onStartFrame", "start-frame", G_CALLBACK (vivi_breakpoint_start_frame) },
+ { "onExitFrame", "finish-frame", G_CALLBACK (vivi_breakpoint_finish_frame) }
};
static guint
diff --git a/vivified/core/vivi_breakpoint.h b/vivified/core/vivi_breakpoint.h
index 084cc8f..5925ec9 100644
--- a/vivified/core/vivi_breakpoint.h
+++ b/vivified/core/vivi_breakpoint.h
@@ -40,7 +40,7 @@ struct _ViviBreakpoint
{
SwfdecAsObject object;
- gulong handlers[2]; /* handlers for every signal of the debugger or 0 */
+ gulong handlers[4]; /* handlers for every signal of the debugger or 0 */
};
struct _ViviBreakpointClass
diff --git a/vivified/core/vivi_debugger.c b/vivified/core/vivi_debugger.c
index fcd8ef1..4d81c45 100644
--- a/vivified/core/vivi_debugger.c
+++ b/vivified/core/vivi_debugger.c
@@ -29,6 +29,8 @@
enum {
STEP,
+ START_FRAME,
+ FINISH_FRAME,
LAST_SIGNAL
};
@@ -99,6 +101,28 @@ vivi_debugger_step (SwfdecAsDebugger *de
}
static void
+vivi_debugger_start_frame (SwfdecAsDebugger *debugger, SwfdecAsContext *context, SwfdecAsFrame *frame)
+{
+ gboolean retval = FALSE;
+
+ g_signal_emit (debugger, signals[START_FRAME], 0, frame, &retval);
+
+ if (retval)
+ vivi_debugger_break (VIVI_DEBUGGER (debugger));
+}
+
+static void
+vivi_debugger_finish_frame (SwfdecAsDebugger *debugger, SwfdecAsContext *context, SwfdecAsFrame *frame, SwfdecAsValue *ret)
+{
+ gboolean retval = FALSE;
+
+ g_signal_emit (debugger, signals[FINISH_FRAME], 0, frame, ret, &retval);
+
+ if (retval)
+ vivi_debugger_break (VIVI_DEBUGGER (debugger));
+}
+
+static void
vivi_debugger_class_init (ViviDebuggerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -109,8 +133,16 @@ vivi_debugger_class_init (ViviDebuggerCl
signals[STEP] = g_signal_new ("step", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, vivi_accumulate_or, NULL, vivi_marshal_BOOLEAN__VOID,
G_TYPE_BOOLEAN, 0);
+ signals[START_FRAME] = g_signal_new ("start-frame", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, vivi_accumulate_or, NULL, vivi_marshal_BOOLEAN__OBJECT,
+ G_TYPE_BOOLEAN, 1, SWFDEC_TYPE_AS_FRAME);
+ signals[FINISH_FRAME] = g_signal_new ("finish-frame", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, vivi_accumulate_or, NULL, vivi_marshal_BOOLEAN__OBJECT_POINTER,
+ G_TYPE_BOOLEAN, 2, SWFDEC_TYPE_AS_FRAME, G_TYPE_POINTER);
debugger_class->step = vivi_debugger_step;
+ debugger_class->start_frame = vivi_debugger_start_frame;
+ debugger_class->finish_frame = vivi_debugger_finish_frame;
}
static void
diff --git a/vivified/core/vivi_marshal.list b/vivified/core/vivi_marshal.list
index 6ff7797..7dce98e 100644
--- a/vivified/core/vivi_marshal.list
+++ b/vivified/core/vivi_marshal.list
@@ -1 +1,3 @@
+BOOLEAN:OBJECT
+BOOLEAN:OBJECT,POINTER
BOOLEAN:VOID
diff-tree faabbdf9705060fdf574260e3e0cea87261ebeb1 (from b0e4a32fae4e15452d78f6175dc3f6959435e4cd)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 10:41:34 2007 +0200
frames are special
diff --git a/vivified/core/vivi_wrap.c b/vivified/core/vivi_wrap.c
index 9329d93..66eb3a4 100644
--- a/vivified/core/vivi_wrap.c
+++ b/vivified/core/vivi_wrap.c
@@ -55,6 +55,7 @@ vivi_wrap_init (ViviWrap *wrap)
SwfdecAsObject *
vivi_wrap_object (ViviApplication *app, SwfdecAsObject *object)
{
+ const char *name;
SwfdecAsContext *cx;
SwfdecAsObject *wrap;
SwfdecAsValue val;
@@ -68,7 +69,12 @@ vivi_wrap_object (ViviApplication *app,
return NULL;
wrap = g_object_new (VIVI_TYPE_WRAP, NULL);
swfdec_as_object_add (wrap, cx, sizeof (ViviWrap));
- swfdec_as_object_get_variable (cx->global, swfdec_as_context_get_string (cx, "Wrap"), &val);
+ /* frames are special */
+ if (SWFDEC_IS_AS_FRAME (object))
+ name = "Frame";
+ else
+ name = "Wrap";
+ swfdec_as_object_get_variable (cx->global, swfdec_as_context_get_string (cx, name), &val);
if (SWFDEC_AS_VALUE_IS_OBJECT (&val))
swfdec_as_object_set_constructor (wrap, SWFDEC_AS_VALUE_GET_OBJECT (&val), FALSE);
VIVI_WRAP (wrap)->wrap = object;
diff-tree b0e4a32fae4e15452d78f6175dc3f6959435e4cd (from 9bbbf2efb2a6f96c6c9c3c236072c0608464fa2b)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 10:27:33 2007 +0200
hoour even more playback state
diff --git a/vivified/core/vivi_debugger.c b/vivified/core/vivi_debugger.c
index cd8e949..fcd8ef1 100644
--- a/vivified/core/vivi_debugger.c
+++ b/vivified/core/vivi_debugger.c
@@ -60,6 +60,11 @@ vivi_debugger_break (ViviDebugger *debug
g_assert (app);
if (app->playback_state == VIVI_APPLICATION_EXITING)
return;
+ if (app->playback_state == VIVI_APPLICATION_PLAYING) {
+ app->playback_count--;
+ if (app->playback_count > 0)
+ return;
+ }
swfdec_player_unlock_soft (app->player);
app->playback_state = 0;
diff-tree 9bbbf2efb2a6f96c6c9c3c236072c0608464fa2b (from 1cdf11f6d70a3275a8ae01a8a1a25eba685a2de7)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 10:26:07 2007 +0200
honour playback state in debugger
diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index 51ac709..e8f489f 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -27,13 +27,6 @@
#include "vivi_function.h"
#include "vivi_ming.h"
-typedef enum {
- VIVI_APPLICATION_STOPPED,
- VIVI_APPLICATION_PLAYING,
- VIVI_APPLICATION_STEPPING,
- VIVI_APPLICATION_EXITING,
-} ViviApplicationPlayback;
-
enum {
MESSAGE,
LAST_SIGNAL
diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h
index d691f81..2636453 100644
--- a/vivified/core/vivi_application.h
+++ b/vivified/core/vivi_application.h
@@ -31,6 +31,13 @@ typedef struct _ViviApplicationClass Viv
typedef struct _ViviDebugger ViviDebugger;
typedef enum {
+ VIVI_APPLICATION_STOPPED,
+ VIVI_APPLICATION_PLAYING,
+ VIVI_APPLICATION_STEPPING,
+ VIVI_APPLICATION_EXITING,
+} ViviApplicationPlayback;
+
+typedef enum {
VIVI_MESSAGE_INPUT,
VIVI_MESSAGE_OUTPUT,
VIVI_MESSAGE_ERROR
@@ -51,7 +58,7 @@ struct _ViviApplication
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) */
+ ViviApplicationPlayback playback_state; /* (running, stepping or stopped) */
guint playback_count; /* how often to just restart this on breakpoints */
GMainLoop * loop; /* the breakpoint main loop */
diff --git a/vivified/core/vivi_debugger.c b/vivified/core/vivi_debugger.c
index 70c71b3..cd8e949 100644
--- a/vivified/core/vivi_debugger.c
+++ b/vivified/core/vivi_debugger.c
@@ -58,6 +58,8 @@ vivi_debugger_break (ViviDebugger *debug
ViviApplication *app = debugger->app;
g_assert (app);
+ if (app->playback_state == VIVI_APPLICATION_EXITING)
+ return;
swfdec_player_unlock_soft (app->player);
app->playback_state = 0;
@@ -78,6 +80,15 @@ vivi_debugger_step (SwfdecAsDebugger *de
g_signal_emit (debugger, signals[STEP], 0, &retval);
+ if (!retval) {
+ ViviApplication *app = VIVI_APPLICATION (context);
+
+ if (app->playback_state == VIVI_APPLICATION_STEPPING) {
+ app->playback_count--;
+ if (app->playback_count == 0)
+ retval = TRUE;
+ }
+ }
if (retval)
vivi_debugger_break (VIVI_DEBUGGER (debugger));
}
diff-tree 1cdf11f6d70a3275a8ae01a8a1a25eba685a2de7 (from 5c7937ed5b7d16814cf95d45c77bccaf1c9814f0)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 10:21:46 2007 +0200
allow referencing values in the debugged context
Everything but objects can be translated literally. Objects need to be wrapped.
The ViviWrap object does exactly this.
diff --git a/vivified/core/Makefile.am b/vivified/core/Makefile.am
index 28916c3..e535481 100644
--- a/vivified/core/Makefile.am
+++ b/vivified/core/Makefile.am
@@ -13,7 +13,8 @@ libvivified_core_la_SOURCES = \
vivi_initialize.as \
vivi_initialize.s \
vivi_marshal.c \
- vivi_ming.c
+ vivi_ming.c \
+ vivi_wrap.c
vivi_initialize.lo: vivi_initialize.s vivi_initialize.as
$(LTCCASCOMPILE) -c -o $@ vivi_initialize.s
@@ -26,6 +27,7 @@ noinst_HEADERS = \
vivi_function_list.h \
vivi_marshal.h \
vivi_ming.h \
+ vivi_wrap.h \
vivified-core.h
BUILT_SOURCES = \
diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index 318630f..51ac709 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -89,6 +89,7 @@ vivi_application_dispose (GObject *objec
ViviApplication *app = VIVI_APPLICATION (object);
g_object_unref (app->player);
+ g_hash_table_destroy (app->wraps);
G_OBJECT_CLASS (vivi_application_parent_class)->dispose (object);
}
@@ -120,6 +121,8 @@ vivi_application_init (ViviApplication *
app->debugger = g_object_new (VIVI_TYPE_DEBUGGER, NULL);
app->debugger->app = app;
app->player = swfdec_gtk_player_new (SWFDEC_AS_DEBUGGER (app->debugger));
+
+ app->wraps = g_hash_table_new (g_direct_hash, g_direct_equal);
}
ViviApplication *
diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h
index 1e0d4c0..d691f81 100644
--- a/vivified/core/vivi_application.h
+++ b/vivified/core/vivi_application.h
@@ -54,6 +54,8 @@ struct _ViviApplication
guint playback_state; /* (running, stepping or stopped) */
guint playback_count; /* how often to just restart this on breakpoints */
GMainLoop * loop; /* the breakpoint main loop */
+
+ GHashTable * wraps; /* all wrapped objects from @player */
};
struct _ViviApplicationClass
diff --git a/vivified/core/vivi_wrap.c b/vivified/core/vivi_wrap.c
new file mode 100644
index 0000000..9329d93
--- /dev/null
+++ b/vivified/core/vivi_wrap.c
@@ -0,0 +1,107 @@
+/* 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"
+
+G_DEFINE_TYPE (ViviWrap, vivi_wrap, SWFDEC_TYPE_AS_OBJECT)
+
+static void
+vivi_wrap_dispose (GObject *object)
+{
+ ViviWrap *wrap = VIVI_WRAP (object);
+
+ if (wrap->wrap) {
+ g_hash_table_remove (VIVI_APPLICATION (SWFDEC_AS_OBJECT (wrap)->context)->wraps, wrap->wrap);
+ wrap->wrap = NULL;
+ }
+
+ G_OBJECT_CLASS (vivi_wrap_parent_class)->dispose (object);
+}
+
+static void
+vivi_wrap_class_init (ViviWrapClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = vivi_wrap_dispose;
+}
+
+static void
+vivi_wrap_init (ViviWrap *wrap)
+{
+}
+
+SwfdecAsObject *
+vivi_wrap_object (ViviApplication *app, SwfdecAsObject *object)
+{
+ SwfdecAsContext *cx;
+ SwfdecAsObject *wrap;
+ SwfdecAsValue val;
+
+ wrap = g_hash_table_lookup (app->wraps, object);
+ if (wrap)
+ return wrap;
+
+ cx = SWFDEC_AS_CONTEXT (app);
+ if (!swfdec_as_context_use_mem (cx, sizeof (ViviWrap)))
+ return NULL;
+ wrap = g_object_new (VIVI_TYPE_WRAP, NULL);
+ swfdec_as_object_add (wrap, cx, sizeof (ViviWrap));
+ swfdec_as_object_get_variable (cx->global, swfdec_as_context_get_string (cx, "Wrap"), &val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ swfdec_as_object_set_constructor (wrap, SWFDEC_AS_VALUE_GET_OBJECT (&val), FALSE);
+ VIVI_WRAP (wrap)->wrap = object;
+ g_hash_table_insert (app->wraps, object, wrap);
+ return wrap;
+}
+
+void
+vivi_wrap_value (ViviApplication *app, SwfdecAsValue *dest, const SwfdecAsValue *src)
+{
+ g_return_if_fail (VIVI_IS_APPLICATION (app));
+ g_return_if_fail (dest != NULL);
+ g_return_if_fail (SWFDEC_IS_AS_VALUE (src));
+
+ switch (src->type) {
+ case SWFDEC_AS_TYPE_UNDEFINED:
+ case SWFDEC_AS_TYPE_BOOLEAN:
+ case SWFDEC_AS_TYPE_NUMBER:
+ case SWFDEC_AS_TYPE_NULL:
+ *dest = *src;
+ break;
+ case SWFDEC_AS_TYPE_STRING:
+ SWFDEC_AS_VALUE_SET_STRING (dest,
+ swfdec_as_context_get_string (SWFDEC_AS_CONTEXT (app),
+ SWFDEC_AS_VALUE_GET_STRING (src)));
+ break;
+ case SWFDEC_AS_TYPE_OBJECT:
+ SWFDEC_AS_VALUE_SET_OBJECT (dest,
+ vivi_wrap_object (app, SWFDEC_AS_VALUE_GET_OBJECT (src)));
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
diff --git a/vivified/core/vivi_wrap.h b/vivified/core/vivi_wrap.h
new file mode 100644
index 0000000..2c551e0
--- /dev/null
+++ b/vivified/core/vivi_wrap.h
@@ -0,0 +1,60 @@
+/* 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_WRAP_H_
+#define _VIVI_WRAP_H_
+
+#include <libswfdec/swfdec.h>
+#include <vivified/core/vivi_application.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _ViviWrap ViviWrap;
+typedef struct _ViviWrapClass ViviWrapClass;
+
+#define VIVI_TYPE_WRAP (vivi_wrap_get_type())
+#define VIVI_IS_WRAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIVI_TYPE_WRAP))
+#define VIVI_IS_WRAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIVI_TYPE_WRAP))
+#define VIVI_WRAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIVI_TYPE_WRAP, ViviWrap))
+#define VIVI_WRAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VIVI_TYPE_WRAP, ViviWrapClass))
+#define VIVI_WRAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VIVI_TYPE_WRAP, ViviWrapClass))
+
+struct _ViviWrap
+{
+ SwfdecAsObject object;
+
+ SwfdecAsObject * wrap; /* the object we wrap */
+};
+
+struct _ViviWrapClass
+{
+ SwfdecAsObjectClass object_class;
+};
+
+GType vivi_wrap_get_type (void);
+
+SwfdecAsObject * vivi_wrap_object (ViviApplication * app,
+ SwfdecAsObject * object);
+void vivi_wrap_value (ViviApplication * app,
+ SwfdecAsValue * dest,
+ const SwfdecAsValue * src);
+
+G_END_DECLS
+#endif
diff-tree 5c7937ed5b7d16814cf95d45c77bccaf1c9814f0 (from 05162930a43aa66d14489b56f63484a32ca51988)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 10:20:28 2007 +0200
check for NULL in SWFDEC_IS_AS_VALUE
diff --git a/libswfdec/swfdec_as_types.h b/libswfdec/swfdec_as_types.h
index 294df40..54189d8 100644
--- a/libswfdec/swfdec_as_types.h
+++ b/libswfdec/swfdec_as_types.h
@@ -64,7 +64,7 @@ struct _SwfdecAsValue {
} value;
};
-#define SWFDEC_IS_AS_VALUE(val) ((val)->type <= SWFDEC_TYPE_AS_OBJECT)
+#define SWFDEC_IS_AS_VALUE(val) ((val) != NULL && (val)->type <= SWFDEC_TYPE_AS_OBJECT)
#define SWFDEC_AS_VALUE_IS_UNDEFINED(val) ((val)->type == SWFDEC_AS_TYPE_UNDEFINED)
#define SWFDEC_AS_VALUE_SET_UNDEFINED(val) (val)->type = SWFDEC_AS_TYPE_UNDEFINED
diff-tree 05162930a43aa66d14489b56f63484a32ca51988 (from f523ffa3245e965c28d8ea8b1d9f64dc6e149f4d)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 15 09:57:55 2007 +0200
fix function name typo
diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index 585d295..318630f 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -247,7 +247,7 @@ vivi_application_check (ViviApplication
}
void
-vivi_applciation_execute (ViviApplication *app, const char *command)
+vivi_application_execute (ViviApplication *app, const char *command)
{
SwfdecAsValue val;
SwfdecAsObject *object;
diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h
index d1f0da7..1e0d4c0 100644
--- a/vivified/core/vivi_application.h
+++ b/vivified/core/vivi_application.h
@@ -89,7 +89,7 @@ void vivi_application_step (ViviAppli
guint n_times);
void vivi_application_quit (ViviApplication * app);
-void vivi_applciation_execute (ViviApplication * app,
+void vivi_application_execute (ViviApplication * app,
const char * command);
G_END_DECLS
diff --git a/vivified/core/vivi_function.c b/vivified/core/vivi_function.c
index cfcb382..4c2608c 100644
--- a/vivified/core/vivi_function.c
+++ b/vivified/core/vivi_function.c
@@ -78,7 +78,7 @@ vivi_function_init_context (ViviApplicat
VIVI_TYPE_BREAKPOINT);
g_signal_connect (app, "message", G_CALLBACK (vivi_function_not_reached), NULL);
- vivi_applciation_execute (app, vivi_initialize);
+ vivi_application_execute (app, vivi_initialize);
g_signal_handlers_disconnect_by_func (app, G_CALLBACK (vivi_function_not_reached), NULL);
}
diff --git a/vivified/ui/vivi_commandline.c b/vivified/ui/vivi_commandline.c
index 7003065..555e922 100644
--- a/vivified/ui/vivi_commandline.c
+++ b/vivified/ui/vivi_commandline.c
@@ -90,7 +90,7 @@ vivi_command_line_execute (ViviCommandLi
}
- vivi_applciation_execute (cl->app, run);
+ vivi_application_execute (cl->app, run);
if (command != run)
g_free (run);
}
diff-tree f523ffa3245e965c28d8ea8b1d9f64dc6e149f4d (from eedb937ec77addb1da3710a776951c886c7a5d70)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Aug 14 22:29:46 2007 +0200
add support for new frames and finishing frames
diff --git a/libswfdec/swfdec_as_debugger.h b/libswfdec/swfdec_as_debugger.h
index 643ac53..fdd2a76 100644
--- a/libswfdec/swfdec_as_debugger.h
+++ b/libswfdec/swfdec_as_debugger.h
@@ -46,9 +46,15 @@ struct _SwfdecAsDebuggerClass {
/* called before executing a bytecode */
void (* step) (SwfdecAsDebugger * debugger,
SwfdecAsContext * context);
- /* called after adding or removing a frame from the function stack */
- void (* frame_change)(SwfdecAsDebugger * debugger,
- SwfdecAsContext * context);
+ /* called after adding a frame from the function stack */
+ void (* start_frame) (SwfdecAsDebugger * debugger,
+ SwfdecAsContext * context,
+ SwfdecAsFrame * frame);
+ /* called after removing a frame from the function stack */
+ void (* finish_frame)(SwfdecAsDebugger * debugger,
+ SwfdecAsContext * context,
+ SwfdecAsFrame * frame,
+ SwfdecAsValue * return_value);
};
GType swfdec_as_debugger_get_type (void);
diff --git a/libswfdec/swfdec_as_frame.c b/libswfdec/swfdec_as_frame.c
index 4608b0a..3a08819 100644
--- a/libswfdec/swfdec_as_frame.c
+++ b/libswfdec/swfdec_as_frame.c
@@ -419,6 +419,12 @@ swfdec_as_frame_return (SwfdecAsFrame *f
swfdec_as_stack_pop_segment (context);
}
}
+ if (context->debugger) {
+ SwfdecAsDebuggerClass *klass = SWFDEC_AS_DEBUGGER_GET_CLASS (context->debugger);
+
+ if (klass->finish_frame)
+ klass->finish_frame (context->debugger, context, frame, &retval);
+ }
/* set return value */
if (frame->return_value) {
*frame->return_value = retval;
@@ -569,12 +575,13 @@ swfdec_as_frame_preload (SwfdecAsFrame *
g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
- if (frame->script == NULL)
- return;
+
/* setup */
object = SWFDEC_AS_OBJECT (frame);
context = object->context;
script = frame->script;
+ if (frame->script == NULL)
+ goto out;
/* create arguments and super object if necessary */
if ((script->flags & (SWFDEC_SCRIPT_PRELOAD_ARGS | SWFDEC_SCRIPT_SUPPRESS_ARGS)) != SWFDEC_SCRIPT_SUPPRESS_ARGS) {
@@ -682,6 +689,14 @@ swfdec_as_frame_preload (SwfdecAsFrame *
if (script->flags & SWFDEC_SCRIPT_PRELOAD_GLOBAL && current_reg < script->n_registers) {
SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], context->global);
}
+
+out:
+ if (context->debugger) {
+ SwfdecAsDebuggerClass *klass = SWFDEC_AS_DEBUGGER_GET_CLASS (context->debugger);
+
+ if (klass->start_frame)
+ klass->start_frame (context->debugger, context, frame);
+ }
}
/**
diff-tree eedb937ec77addb1da3710a776951c886c7a5d70 (from 0fc26b7da7563261f05d8930120e2ae8a566d3f9)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Aug 14 20:48:31 2007 +0200
properly accumulate signal return values
diff --git a/vivified/core/.gitignore b/vivified/core/.gitignore
index da08114..4bc848f 100644
--- a/vivified/core/.gitignore
+++ b/vivified/core/.gitignore
@@ -12,3 +12,5 @@ Makefile.in
*.loT
vivi_function_list.h
+vivi_marshal.h
+vivi_marshal.c
diff --git a/vivified/core/Makefile.am b/vivified/core/Makefile.am
index 694ddad..28916c3 100644
--- a/vivified/core/Makefile.am
+++ b/vivified/core/Makefile.am
@@ -12,6 +12,7 @@ libvivified_core_la_SOURCES = \
vivi_function.c \
vivi_initialize.as \
vivi_initialize.s \
+ vivi_marshal.c \
vivi_ming.c
vivi_initialize.lo: vivi_initialize.s vivi_initialize.as
@@ -23,11 +24,14 @@ noinst_HEADERS = \
vivi_debugger.h \
vivi_function.h \
vivi_function_list.h \
+ vivi_marshal.h \
vivi_ming.h \
vivified-core.h
BUILT_SOURCES = \
- vivi_function_list.h
+ vivi_function_list.h \
+ vivi_marshal.h \
+ vivi_marshal.c
CLEANFILES = \
$(BUILT_SOURCES)
@@ -36,5 +40,17 @@ vivi_function_list.h: $(libvivified_core
(cd $(srcdir) \
&& grep -he "^VIVI_FUNCTION" $(libvivified_core_la_SOURCES) \
) >> xgen-vfl \
- && (cmp -s xgen-vfl swfdec_asnative.h || cp xgen-vfl vivi_function_list.h) \
+ && (cmp -s xgen-vfl vivi_asnative.h || cp xgen-vfl vivi_function_list.h) \
&& rm -f xgen-vfl
+
+vivi_marshal.h: vivi_marshal.list Makefile
+ $(GLIB_GENMARSHAL) --prefix=vivi_marshal $(srcdir)/vivi_marshal.list --header >> xgen-vmh \
+ && (cmp -s xgen-vmh vivi_marshal.h || cp xgen-vmh vivi_marshal.h) \
+ && rm -f xgen-vmh
+
+vivi_marshal.c: vivi_marshal.list vivi_marshal.h Makefile
+ (echo "#include \"vivi_marshal.h\""; \
+ $(GLIB_GENMARSHAL) --prefix=vivi_marshal $(srcdir)/vivi_marshal.list --body;) >> xgen-vmc \
+ && cp xgen-vmc vivi_marshal.c \
+ && rm -f xgen-vmc
+
diff --git a/vivified/core/vivi_debugger.c b/vivified/core/vivi_debugger.c
index fcad454..70c71b3 100644
--- a/vivified/core/vivi_debugger.c
+++ b/vivified/core/vivi_debugger.c
@@ -23,6 +23,7 @@
#include "vivi_debugger.h"
#include "vivi_application.h"
+#include "vivi_marshal.h"
/* FIXME: oops */
#include "libswfdec/swfdec_player_internal.h"
@@ -90,7 +91,7 @@ vivi_debugger_class_init (ViviDebuggerCl
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_SIGNAL_RUN_LAST, 0, vivi_accumulate_or, NULL, vivi_marshal_BOOLEAN__VOID,
G_TYPE_BOOLEAN, 0);
debugger_class->step = vivi_debugger_step;
diff --git a/vivified/core/vivi_marshal.list b/vivified/core/vivi_marshal.list
new file mode 100644
index 0000000..6ff7797
--- /dev/null
+++ b/vivified/core/vivi_marshal.list
@@ -0,0 +1 @@
+BOOLEAN:VOID
diff-tree 0fc26b7da7563261f05d8930120e2ae8a566d3f9 (from adc7c2987283fe1ec7df8aa442d6d11b6d8d762a)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Aug 14 20:47:59 2007 +0200
make sure handlers are properly cleared so setting them up again later does work.
diff --git a/vivified/core/vivi_breakpoint.c b/vivified/core/vivi_breakpoint.c
index 7931e28..19a1f22 100644
--- a/vivified/core/vivi_breakpoint.c
+++ b/vivified/core/vivi_breakpoint.c
@@ -73,8 +73,10 @@ vivi_breakpoint_set (SwfdecAsObject *obj
breakpoint->handlers[i] = g_signal_connect (debugger, events[i].signal,
events[i].handler, object);
} else {
- if (breakpoint->handlers[i])
+ if (breakpoint->handlers[i]) {
g_signal_handler_disconnect (debugger, breakpoint->handlers[i]);
+ breakpoint->handlers[i] = 0;
+ }
}
}
SWFDEC_AS_OBJECT_CLASS (vivi_breakpoint_parent_class)->set (object, variable, val);
@@ -90,6 +92,7 @@ vivi_breakpoint_delete (SwfdecAsObject *
if (i && breakpoint->handlers[i]) {
ViviDebugger *debugger = VIVI_APPLICATION (object->context)->debugger;
g_signal_handler_disconnect (debugger, breakpoint->handlers[i]);
+ breakpoint->handlers[i] = 0;
}
return SWFDEC_AS_OBJECT_CLASS (vivi_breakpoint_parent_class)->del (object, variable);
More information about the Swfdec
mailing list