[Swfdec] Branch 'vivi' - 12 commits - libswfdec-gtk/swfdec_gtk_player.c libswfdec-gtk/swfdec_gtk_player.h libswfdec/Makefile.am libswfdec/swfdec_as_array.h libswfdec/swfdec_as_context.c libswfdec/swfdec_as_context.h libswfdec/swfdec_as_debugger.c libswfdec/swfdec_as_debugger.h libswfdec/swfdec_as_frame_internal.h libswfdec/swfdec_as_internal.h libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_object.h libswfdec/swfdec_as_types.h libswfdec/swfdec_color_as.h libswfdec/swfdec_debugger.c libswfdec/swfdec_event.c libswfdec/swfdec.h libswfdec/swfdec_player.c libswfdec/swfdec_player.h libswfdec/swfdec_script.c libswfdec/swfdec_script.h libswfdec/swfdec_script_internal.h libswfdec/swfdec_swf_decoder.c libswfdec/swfdec_tag.c libswfdec/swfdec_types.h player/swfdec_debug_scripts.c player/swfdec_player_manager.c player/swfplay.c test/image test/sound test/swfedit_tag.c test/swfedit_token.c test/swfscript.c test/trace vivified/core vivified/ui
Benjamin Otte
company at kemper.freedesktop.org
Thu Aug 9 14:24:05 PDT 2007
libswfdec-gtk/swfdec_gtk_player.c | 7 +-
libswfdec-gtk/swfdec_gtk_player.h | 2
libswfdec/Makefile.am | 5 +
libswfdec/swfdec.h | 2
libswfdec/swfdec_as_array.h | 1
libswfdec/swfdec_as_context.c | 60 +++++++++++++++++++--
libswfdec/swfdec_as_context.h | 5 +
libswfdec/swfdec_as_debugger.c | 72 +++++++++++++++++++++++++
libswfdec/swfdec_as_debugger.h | 58 ++++++++++++++++++++
libswfdec/swfdec_as_frame_internal.h | 2
libswfdec/swfdec_as_internal.h | 2
libswfdec/swfdec_as_interpret.c | 3 -
libswfdec/swfdec_as_object.h | 2
libswfdec/swfdec_as_types.h | 3 +
libswfdec/swfdec_color_as.h | 2
libswfdec/swfdec_debugger.c | 5 -
libswfdec/swfdec_event.c | 4 -
libswfdec/swfdec_player.c | 11 ++-
libswfdec/swfdec_player.h | 3 -
libswfdec/swfdec_script.c | 41 ++++++--------
libswfdec/swfdec_script.h | 69 ------------------------
libswfdec/swfdec_script_internal.h | 93 +++++++++++++++++++++++++++++++++
libswfdec/swfdec_swf_decoder.c | 1
libswfdec/swfdec_tag.c | 7 +-
libswfdec/swfdec_types.h | 1
player/swfdec_debug_scripts.c | 1
player/swfdec_player_manager.c | 1
player/swfplay.c | 2
test/image/image.c | 2
test/sound/sound.c | 2
test/swfedit_tag.c | 4 -
test/swfedit_token.c | 7 --
test/swfscript.c | 7 --
test/trace/trace.c | 2
vivified/core/Makefile.am | 8 +-
vivified/core/vivi_application.c | 56 ++++++++++++++++++--
vivified/core/vivi_application.h | 19 ++++++
vivified/core/vivi_ming.c | 98 +++++++++++++++++++++++++++++++++++
vivified/core/vivi_ming.h | 34 ++++++++++++
vivified/ui/vivi_commandline.c | 61 ++++++++++++++++++---
vivified/ui/vivi_commandline.h | 3 +
41 files changed, 611 insertions(+), 157 deletions(-)
New commits:
diff-tree bd466511d940904f33e8b3553f529e1b2eca5c7d (from 9b937d1fa8a9709dda1e153b22adf63c5df2d445)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Aug 9 23:22:46 2007 +0200
have a text output window
diff --git a/vivified/ui/vivi_commandline.c b/vivified/ui/vivi_commandline.c
index ced3e15..6ae6b03 100644
--- a/vivified/ui/vivi_commandline.c
+++ b/vivified/ui/vivi_commandline.c
@@ -26,9 +26,29 @@
G_DEFINE_TYPE (ViviCommandLine, vivi_command_line, VIVI_TYPE_DOCKLET)
static void
+vivi_command_line_append_message (ViviApplication *app, guint type, const char *message, GtkTextView *view)
+{
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer (view);
+ GtkTextIter iter;
+ GtkTextMark *mark;
+ const char *tag_names[] = { "input", "output", "error" };
+
+ gtk_text_buffer_get_end_iter (buffer, &iter);
+ mark = gtk_text_buffer_get_mark (buffer, "end");
+ if (mark == NULL)
+ mark = gtk_text_buffer_create_mark (buffer, "end", &iter, FALSE);
+ if (gtk_text_buffer_get_char_count (buffer) > 0)
+ gtk_text_buffer_insert (buffer, &iter, "\n", 1);
+ gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, message, -1, tag_names[type], NULL);
+ gtk_text_view_scroll_to_mark (view, mark, 0.0, TRUE, 0.0, 0.0);
+}
+
+static void
vivi_command_line_dispose (GObject *object)
{
- //ViviCommandLine *command_line = VIVI_COMMAND_LINE (object);
+ ViviCommandLine *cl = VIVI_COMMAND_LINE (object);
+
+ g_signal_handlers_disconnect_by_func (cl->app, vivi_command_line_append_message, cl->view);
G_OBJECT_CLASS (vivi_command_line_parent_class)->dispose (object);
}
@@ -49,27 +69,48 @@ command_line_entry_activate_cb (GtkEntry
if (text[0] == '\0')
return;
- g_print ("%s\n", text);
- //swfdec_player_manager_execute (manager, text);
+ vivi_application_run (command_line->app, text);
gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
}
static void
-vivi_command_line_init (ViviCommandLine *command_line)
+vivi_command_line_init (ViviCommandLine *cl)
{
- GtkWidget *entry;
+ GtkWidget *box, *widget, *scroll;
+
+ box = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (cl), box);
+ /* the text entry */
+ widget = gtk_entry_new ();
+ g_signal_connect (widget, "activate", G_CALLBACK (command_line_entry_activate_cb), cl);
+ gtk_box_pack_end (GTK_BOX (box), widget, FALSE, TRUE, 0);
+ /* the text view for outputting messages */
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_box_pack_start (GTK_BOX (box), scroll, TRUE, TRUE, 0);
+ cl->view = gtk_text_view_new ();
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (cl->view), FALSE);
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (cl->view), GTK_WRAP_WORD_CHAR);
+ gtk_text_buffer_create_tag (gtk_text_view_get_buffer (GTK_TEXT_VIEW (cl->view)),
+ "error", "foreground", "red", "left-margin", 15, NULL);
+ gtk_text_buffer_create_tag (gtk_text_view_get_buffer (GTK_TEXT_VIEW (cl->view)),
+ "input", "foreground", "dark grey", NULL);
+ gtk_text_buffer_create_tag (gtk_text_view_get_buffer (GTK_TEXT_VIEW (cl->view)),
+ "output", "left-margin", 15, NULL);
+ gtk_container_add (GTK_CONTAINER (scroll), cl->view);
- entry = gtk_entry_new ();
- gtk_container_add (GTK_CONTAINER (command_line), entry);
- g_signal_connect (entry, "activate", G_CALLBACK (command_line_entry_activate_cb), command_line);
+ gtk_widget_show_all (box);
}
GtkWidget *
vivi_command_line_new (ViviApplication *app)
{
- GtkWidget *cl;
+ ViviCommandLine *cl;
cl = g_object_new (VIVI_TYPE_COMMAND_LINE, "title", "Command Line", NULL);
- return cl;
+ cl->app = app;
+ g_signal_connect (cl->app, "message", G_CALLBACK (vivi_command_line_append_message), cl->view);
+ return GTK_WIDGET (cl);
}
diff --git a/vivified/ui/vivi_commandline.h b/vivified/ui/vivi_commandline.h
index f38da32..96e5924 100644
--- a/vivified/ui/vivi_commandline.h
+++ b/vivified/ui/vivi_commandline.h
@@ -38,6 +38,9 @@ typedef struct _ViviCommandLineClass Viv
struct _ViviCommandLine {
ViviDocklet docklet;
+
+ ViviApplication * app; /* the application we connect to */
+ GtkWidget * view; /* text view for outputting stuff to */
};
struct _ViviCommandLineClass
diff-tree 9b937d1fa8a9709dda1e153b22adf63c5df2d445 (from f1b1180d52d93122385178620d984597471fa9d0)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Aug 9 23:22:32 2007 +0200
add ability to emit messages, just like SwfdecPlayerManager
Also startup the context on init
diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index c526580..783a3f9 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -26,12 +26,18 @@
#include "vivi_ming.h"
enum {
+ MESSAGE,
+ LAST_SIGNAL
+};
+
+enum {
PROP_0,
PROP_FILENAME,
PROP_PLAYER
};
G_DEFINE_TYPE (ViviApplication, vivi_application, SWFDEC_TYPE_AS_CONTEXT)
+static guint signals[LAST_SIGNAL] = { 0, };
static void
vivi_application_get_property (GObject *object, guint param_id, GValue *value,
@@ -93,6 +99,10 @@ vivi_application_class_init (ViviApplica
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));
+
+ signals[MESSAGE] = g_signal_new ("message", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__UINT_POINTER, /* FIXME */
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_POINTER);
}
static void
@@ -104,7 +114,11 @@ vivi_application_init (ViviApplication *
ViviApplication *
vivi_application_new (void)
{
- return g_object_new (VIVI_TYPE_APPLICATION, NULL);
+ ViviApplication *app;
+
+ app = g_object_new (VIVI_TYPE_APPLICATION, NULL);
+ swfdec_as_context_startup (SWFDEC_AS_CONTEXT (app), 8);
+ return app;
}
void
@@ -153,11 +167,27 @@ vivi_application_run (ViviApplication *a
g_return_if_fail (VIVI_IS_APPLICATION (app));
g_return_if_fail (command != NULL);
+ vivi_application_input (app, command);
script = vivi_ming_compile (command, &error);
if (script == NULL) {
+ vivi_application_error (app, error);
g_free (error);
}
swfdec_as_object_run (SWFDEC_AS_CONTEXT (app)->global, script);
swfdec_script_unref (script);
}
+void
+vivi_application_send_message (ViviApplication *app,
+ ViviMessageType type, const char *format, ...)
+{
+ va_list args;
+ char *msg;
+
+ va_start (args, format);
+ msg = g_strdup_vprintf (format, args);
+ va_end (args);
+ g_signal_emit (app, signals[MESSAGE], 0, (guint) type, msg);
+ g_free (msg);
+}
+
diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h
index 8a21410..40bdc64 100644
--- a/vivified/core/vivi_application.h
+++ b/vivified/core/vivi_application.h
@@ -28,6 +28,12 @@ G_BEGIN_DECLS
typedef struct _ViviApplication ViviApplication;
typedef struct _ViviApplicationClass ViviApplicationClass;
+typedef enum {
+ VIVI_MESSAGE_INPUT,
+ VIVI_MESSAGE_OUTPUT,
+ VIVI_MESSAGE_ERROR
+} ViviMessageType;
+
#define VIVI_TYPE_APPLICATION (vivi_application_get_type())
#define VIVI_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIVI_TYPE_APPLICATION))
#define VIVI_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIVI_TYPE_APPLICATION))
@@ -52,6 +58,17 @@ GType vivi_application_get_type (vo
ViviApplication * vivi_application_new (void);
+void vivi_application_send_message (ViviApplication * app,
+ ViviMessageType type,
+ const char * format,
+ ...) G_GNUC_PRINTF (3, 4);
+#define vivi_application_input(manager, ...) \
+ vivi_application_send_message (manager, VIVI_MESSAGE_INPUT, __VA_ARGS__)
+#define vivi_application_output(manager, ...) \
+ vivi_application_send_message (manager, VIVI_MESSAGE_OUTPUT, __VA_ARGS__)
+#define vivi_application_error(manager, ...) \
+ vivi_application_send_message (manager, VIVI_MESSAGE_ERROR, __VA_ARGS__)
+
void vivi_application_set_filename (ViviApplication * app,
const char * filename);
const char * vivi_application_get_filename (ViviApplication * app);
diff-tree f1b1180d52d93122385178620d984597471fa9d0 (from 748618dc3faea26ad390e6a033f96054deb9b020)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Aug 9 22:17:56 2007 +0200
add vivi_application_run() function
This requires hooking up ming
diff --git a/vivified/core/Makefile.am b/vivified/core/Makefile.am
index dc15041..0bcac39 100644
--- a/vivified/core/Makefile.am
+++ b/vivified/core/Makefile.am
@@ -1,11 +1,13 @@
noinst_LTLIBRARIES = libvivified-core.la
-libvivified_core_la_CFLAGS = $(GLOBAL_CFLAGS) $(SWFDEC_GTK_CFLAGS)
-libvivified_core_la_LDFLAGS = $(SWFDEC_GTK_LIBS)
+libvivified_core_la_CFLAGS = $(GLOBAL_CFLAGS) $(SWFDEC_GTK_CFLAGS) $(VIVI_CFLAGS)
+libvivified_core_la_LDFLAGS = $(SWFDEC_GTK_LIBS) $(VIVI_LIBS)
libvivified_core_la_SOURCES = \
- vivi_application.c
+ vivi_application.c \
+ vivi_ming.c
noinst_HEADERS = \
vivi_application.h \
+ vivi_ming.h \
vivified-core.h
diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index dd85bc4..c526580 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -21,8 +21,9 @@
#include "config.h"
#endif
-#include "vivi_application.h"
#include <libswfdec-gtk/swfdec-gtk.h>
+#include "vivi_application.h"
+#include "vivi_ming.h"
enum {
PROP_0,
@@ -143,3 +144,20 @@ vivi_application_get_player (ViviApplica
return app->player;
}
+void
+vivi_application_run (ViviApplication *app, const char *command)
+{
+ SwfdecScript *script;
+ char *error = NULL;
+
+ g_return_if_fail (VIVI_IS_APPLICATION (app));
+ g_return_if_fail (command != NULL);
+
+ script = vivi_ming_compile (command, &error);
+ if (script == NULL) {
+ g_free (error);
+ }
+ swfdec_as_object_run (SWFDEC_AS_CONTEXT (app)->global, script);
+ swfdec_script_unref (script);
+}
+
diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h
index 6e0df41..8a21410 100644
--- a/vivified/core/vivi_application.h
+++ b/vivified/core/vivi_application.h
@@ -58,6 +58,8 @@ const char * vivi_application_get_filen
SwfdecPlayer * vivi_application_get_player (ViviApplication * app);
void vivi_application_reset (ViviApplication * app);
+void vivi_application_run (ViviApplication * app,
+ const char * command);
G_END_DECLS
#endif
diff --git a/vivified/core/vivi_ming.c b/vivified/core/vivi_ming.c
new file mode 100644
index 0000000..3ef14b1
--- /dev/null
+++ b/vivified/core/vivi_ming.c
@@ -0,0 +1,98 @@
+/* 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_ming.h"
+#include <string.h>
+
+static GString *ming_errors = NULL;
+
+static void
+vivi_ming_error (const char *format, ...)
+{
+ va_list varargs;
+ char *s;
+
+ if (ming_errors) {
+ g_string_append_c (ming_errors, '\n');
+ } else {
+ ming_errors = g_string_new ("");
+ }
+ va_start (varargs, format);
+ g_string_append_vprintf (ming_errors, format, varargs);
+ s = g_strdup_vprintf (format, varargs);
+ va_end (varargs);
+}
+
+static char *
+vivi_ming_get_error (void)
+{
+ char *ret;
+
+ if (ming_errors == NULL)
+ return g_strdup ("Unknown error");
+
+ ret = g_string_free (ming_errors, FALSE);
+ ming_errors = NULL;
+ return ret;
+}
+
+static void
+vivi_ming_init (void)
+{
+ static gboolean ming_inited = FALSE;
+
+ if (ming_inited)
+ return;
+
+ ming_inited = TRUE;
+
+ Ming_init ();
+ Ming_useSWFVersion (8);
+ Ming_setErrorFunction (vivi_ming_error);
+ Ming_setWarnFunction (vivi_ming_error);
+}
+
+SwfdecScript *
+vivi_ming_compile (const char *code, char **error)
+{
+ byte *data;
+ SWFAction action;
+ gsize len;
+ SwfdecBuffer *buffer;
+ SwfdecScript *script;
+
+ vivi_ming_init ();
+
+ action = newSWFAction (code);
+ data = SWFAction_getByteCode (action, &len);
+ if (data == NULL || len == 0) {
+ if (error)
+ *error = vivi_ming_get_error ();
+ return NULL;
+ }
+ buffer = swfdec_buffer_new_and_alloc (len);
+ memcpy (buffer->data, data, len);
+ script = swfdec_script_new (buffer, "compiled script", 8);
+ return script;
+}
+
diff --git a/vivified/core/vivi_ming.h b/vivified/core/vivi_ming.h
new file mode 100644
index 0000000..98d3b85
--- /dev/null
+++ b/vivified/core/vivi_ming.h
@@ -0,0 +1,34 @@
+/* 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
+ */
+
+#include <libswfdec/swfdec.h>
+#include <ming.h>
+
+#ifndef _VIVI_MING_H_
+#define _VIVI_MING_H_
+
+G_BEGIN_DECLS
+
+
+SwfdecScript * vivi_ming_compile (const char * code,
+ char ** error);
+
+
+G_END_DECLS
+#endif
diff-tree 748618dc3faea26ad390e6a033f96054deb9b020 (from 54778c3616f3488668d7ba7b12105ea722b2845a)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Aug 9 20:56:45 2007 +0200
make swfdec_script_new take ownership of the passed in buffer
And document that behaviour
diff --git a/libswfdec/swfdec_script.c b/libswfdec/swfdec_script.c
index c207435..221e25c 100644
--- a/libswfdec/swfdec_script.c
+++ b/libswfdec/swfdec_script.c
@@ -199,15 +199,29 @@ validate_action (gconstpointer bytecode,
return TRUE;
}
+/**
+ * swfdec_script_new:
+ * @buffer: the #SwfdecBuffer containing the script. This function will take
+ * ownership of the passed in buffer.
+ * @name: name of the script for debugging purposes
+ * @version: Actionscript version to use in this script
+ *
+ * Creates a new script for the actionscript provided in @buffer.
+ *
+ * Returns: a new #SwfdecScript for executing the script i @buffer.
+ **/
SwfdecScript *
swfdec_script_new (SwfdecBuffer *buffer, const char *name, guint version)
{
SwfdecBits bits;
+ SwfdecScript *script;
g_return_val_if_fail (buffer != NULL, NULL);
swfdec_bits_init (&bits, buffer);
- return swfdec_script_new_from_bits (&bits, name, version);
+ script = swfdec_script_new_from_bits (&bits, name, version);
+ swfdec_buffer_unref (buffer);
+ return script;
}
SwfdecScript *
diff --git a/test/swfedit_token.c b/test/swfedit_token.c
index 11bb485..34496df 100644
--- a/test/swfedit_token.c
+++ b/test/swfedit_token.c
@@ -322,7 +322,6 @@ swfedit_script_from_string (const char *
}
script = swfdec_script_new (buffer, "unknown", 6 /* FIXME */);
- swfdec_buffer_unref (buffer);
if (script != NULL) {
*result = script;
return TRUE;
diff --git a/test/swfscript.c b/test/swfscript.c
index 187aeb5..4e2a9e4 100644
--- a/test/swfscript.c
+++ b/test/swfscript.c
@@ -208,7 +208,6 @@ modify_file (SwfeditToken *token, guint
state.buffer->length, state.script->buffer->length);
#endif
script = swfdec_script_new (state.buffer, state.script->name, state.script->version);
- swfdec_buffer_unref (state.buffer);
g_assert (script);
swfedit_token_set (token, idx, script);
diff-tree 54778c3616f3488668d7ba7b12105ea722b2845a (from 5c17c6e1324644006db930660e04ea910d6d4a6c)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Aug 9 19:15:16 2007 +0200
move SwfdecScript into the API
this unfortunately requires a new internal header, and all the files need to be
updated
diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am
index dd62712..fc9d47f 100644
--- a/libswfdec/Makefile.am
+++ b/libswfdec/Makefile.am
@@ -136,6 +136,7 @@ public_headers = \
swfdec_keys.h \
swfdec_loader.h \
swfdec_player.h \
+ swfdec_script.h \
swfdec_url.h
libswfdec_ at SWFDEC_MAJORMINOR@_la_LIBADD = jpeg/libjpeg.la
@@ -201,7 +202,7 @@ noinst_HEADERS = \
swfdec_player_internal.h \
swfdec_rect.h \
swfdec_ringbuffer.h \
- swfdec_script.h \
+ swfdec_script_internal.h \
swfdec_shape.h \
swfdec_sound.h \
swfdec_sprite.h \
diff --git a/libswfdec/swfdec.h b/libswfdec/swfdec.h
index 27e65e9..ec4d136 100644
--- a/libswfdec/swfdec.h
+++ b/libswfdec/swfdec.h
@@ -27,6 +27,7 @@
#include <libswfdec/swfdec_as_frame.h>
#include <libswfdec/swfdec_as_object.h>
#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_script.h>
#include <libswfdec/swfdec_audio.h>
#include <libswfdec/swfdec_buffer.h>
diff --git a/libswfdec/swfdec_as_frame_internal.h b/libswfdec/swfdec_as_frame_internal.h
index f6d7644..4f613b4 100644
--- a/libswfdec/swfdec_as_frame_internal.h
+++ b/libswfdec/swfdec_as_frame_internal.h
@@ -22,7 +22,7 @@
#include <libswfdec/swfdec_as_scope.h>
#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script.h>
+#include <libswfdec/swfdec_script_internal.h>
G_BEGIN_DECLS
diff --git a/libswfdec/swfdec_as_internal.h b/libswfdec/swfdec_as_internal.h
index ca6ab2d..5906ef4 100644
--- a/libswfdec/swfdec_as_internal.h
+++ b/libswfdec/swfdec_as_internal.h
@@ -49,8 +49,6 @@ guint swfdec_as_object_foreach_remove (
void swfdec_as_object_foreach_rename (SwfdecAsObject * object,
SwfdecAsVariableForeachRename func,
gpointer data);
-void swfdec_as_object_run (SwfdecAsObject * object,
- SwfdecScript * script);
void swfdec_as_object_init_context (SwfdecAsContext * context,
guint version);
diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index 90fd2e2..73907ee 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -1551,7 +1551,7 @@ swfdec_action_define_function (SwfdecAsC
}
if (name == NULL)
name = "unnamed_function";
- script = swfdec_script_new (&bits, name, cx->version);
+ script = swfdec_script_new_from_bits (&bits, name, cx->version);
if (script == NULL) {
SWFDEC_ERROR ("failed to create script");
g_free (args);
diff --git a/libswfdec/swfdec_as_object.h b/libswfdec/swfdec_as_object.h
index f82cd9c..7ad1c98 100644
--- a/libswfdec/swfdec_as_object.h
+++ b/libswfdec/swfdec_as_object.h
@@ -151,6 +151,8 @@ void swfdec_as_object_call (SwfdecAsOb
guint argc,
SwfdecAsValue * argv,
SwfdecAsValue * return_value);
+void swfdec_as_object_run (SwfdecAsObject * object,
+ SwfdecScript * script);
G_END_DECLS
diff --git a/libswfdec/swfdec_as_types.h b/libswfdec/swfdec_as_types.h
index d435cb9..294df40 100644
--- a/libswfdec/swfdec_as_types.h
+++ b/libswfdec/swfdec_as_types.h
@@ -49,6 +49,8 @@ typedef void (* SwfdecAsNative) (SwfdecA
guint argc,
SwfdecAsValue * argv,
SwfdecAsValue * retval);
+typedef struct _SwfdecScript SwfdecScript;
+
/* IMPORTANT: a SwfdecAsValue memset to 0 is a valid undefined value */
struct _SwfdecAsValue {
diff --git a/libswfdec/swfdec_color_as.h b/libswfdec/swfdec_color_as.h
index b197f8e..97bc731 100644
--- a/libswfdec/swfdec_color_as.h
+++ b/libswfdec/swfdec_color_as.h
@@ -22,7 +22,7 @@
#include <libswfdec/swfdec_as_object.h>
#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script.h>
+#include <libswfdec/swfdec_movie.h>
G_BEGIN_DECLS
diff --git a/libswfdec/swfdec_event.c b/libswfdec/swfdec_event.c
index 26c4dfb..5474248 100644
--- a/libswfdec/swfdec_event.c
+++ b/libswfdec/swfdec_event.c
@@ -25,7 +25,7 @@
#include "swfdec_as_strings.h"
#include "swfdec_debug.h"
#include "swfdec_player_internal.h"
-#include "swfdec_script.h"
+#include "swfdec_script_internal.h"
typedef struct _SwfdecEvent SwfdecEvent;
@@ -202,7 +202,7 @@ swfdec_event_list_parse (SwfdecEventList
event.key = key;
name = g_strconcat (description, ".",
swfdec_event_list_condition_name (conditions), NULL);
- event.script = swfdec_script_new (bits, name, version);
+ event.script = swfdec_script_new_from_bits (bits, name, version);
g_free (name);
if (event.script)
g_array_append_val (list->events, event);
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index a1acf87..e1c7748 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -40,7 +40,7 @@
#include "swfdec_loader_internal.h"
#include "swfdec_marshal.h"
#include "swfdec_movie.h"
-#include "swfdec_script.h"
+#include "swfdec_script_internal.h"
#include "swfdec_sprite_movie.h"
#include "swfdec_swf_instance.h"
@@ -1432,7 +1432,7 @@ swfdec_player_initialize (SwfdecPlayer *
SwfdecBits bits;
SwfdecScript *script;
swfdec_bits_init_data (&bits, swfdec_initialize, sizeof (swfdec_initialize));
- script = swfdec_script_new (&bits, "init", version);
+ script = swfdec_script_new_from_bits (&bits, "init", version);
g_assert (script);
swfdec_as_object_run (context->global, script);
swfdec_script_unref (script);
diff --git a/libswfdec/swfdec_script.c b/libswfdec/swfdec_script.c
index 87f2010..c207435 100644
--- a/libswfdec/swfdec_script.c
+++ b/libswfdec/swfdec_script.c
@@ -22,6 +22,7 @@
#endif
#include "swfdec_script.h"
+#include "swfdec_script_internal.h"
#include "swfdec_as_context.h"
#include "swfdec_as_interpret.h"
#include "swfdec_debug.h"
@@ -199,7 +200,18 @@ validate_action (gconstpointer bytecode,
}
SwfdecScript *
-swfdec_script_new (SwfdecBits *bits, const char *name, guint version)
+swfdec_script_new (SwfdecBuffer *buffer, const char *name, guint version)
+{
+ SwfdecBits bits;
+
+ g_return_val_if_fail (buffer != NULL, NULL);
+
+ swfdec_bits_init (&bits, buffer);
+ return swfdec_script_new_from_bits (&bits, name, version);
+}
+
+SwfdecScript *
+swfdec_script_new_from_bits (SwfdecBits *bits, const char *name, guint version)
{
SwfdecScript *script;
SwfdecBits org;
diff --git a/libswfdec/swfdec_script.h b/libswfdec/swfdec_script.h
index 6a0870b..fe90428 100644
--- a/libswfdec/swfdec_script.h
+++ b/libswfdec/swfdec_script.h
@@ -20,76 +20,18 @@
#ifndef _SWFDEC_SCRIPT_H_
#define _SWFDEC_SCRIPT_H_
-#include <libswfdec/swfdec.h>
#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_bits.h>
+#include <libswfdec/swfdec_buffer.h>
G_BEGIN_DECLS
-//typedef struct _SwfdecScript SwfdecScript;
-typedef struct _SwfdecScriptArgument SwfdecScriptArgument;
-typedef struct _SwfdecConstantPool SwfdecConstantPool;
-
-typedef enum {
- SWFDEC_SCRIPT_PRELOAD_THIS = (1 << 0),
- SWFDEC_SCRIPT_SUPPRESS_THIS = (1 << 1),
- SWFDEC_SCRIPT_PRELOAD_ARGS = (1 << 2),
- SWFDEC_SCRIPT_SUPPRESS_ARGS = (1 << 3),
- SWFDEC_SCRIPT_PRELOAD_SUPER = (1 << 4),
- SWFDEC_SCRIPT_SUPPRESS_SUPER = (1 << 5),
- SWFDEC_SCRIPT_PRELOAD_ROOT = (1 << 6),
- SWFDEC_SCRIPT_PRELOAD_PARENT = (1 << 7),
- SWFDEC_SCRIPT_PRELOAD_GLOBAL = (1 << 8)
-} SwfdecScriptFlag;
-
-typedef gboolean (* SwfdecScriptForeachFunc) (gconstpointer bytecode, guint action,
- const guint8 *data, guint len, gpointer user_data);
-
-/* FIXME: May want to typedef to SwfdecBuffer directly */
-struct _SwfdecScript {
- SwfdecBuffer * buffer; /* buffer holding the script */
- guint refcount; /* reference count */
- char * name; /* name identifying this script */
- guint version; /* version of the script */
- guint n_registers; /* number of registers */
- SwfdecBuffer * constant_pool; /* constant pool action */
- guint flags; /* SwfdecScriptFlags */
- guint n_arguments; /* number of arguments */
- SwfdecScriptArgument *arguments; /* arguments or NULL if none */
-};
-
-struct _SwfdecScriptArgument {
- char * name; /* name of the argument (not GC'ed) */
- guint preload; /* preload slot to preload to or 0 */
-};
-
-const char * swfdec_action_get_name (guint action);
-guint swfdec_action_get_from_name (const char * name);
-
-SwfdecConstantPool *
- swfdec_constant_pool_new_from_action (const guint8 * data,
- guint len,
- guint version);
-void swfdec_constant_pool_free (SwfdecConstantPool * pool);
-guint swfdec_constant_pool_size (SwfdecConstantPool * pool);
-const char * swfdec_constant_pool_get (SwfdecConstantPool * pool,
- guint i);
-void swfdec_constant_pool_attach_to_context (SwfdecConstantPool * pool,
- SwfdecAsContext * context);
-SwfdecScript * swfdec_script_new (SwfdecBits * bits,
+SwfdecScript * swfdec_script_new (SwfdecBuffer * buffer,
const char * name,
guint version);
SwfdecScript * swfdec_script_ref (SwfdecScript * script);
void swfdec_script_unref (SwfdecScript * script);
-gboolean swfdec_script_foreach (SwfdecScript * script,
- SwfdecScriptForeachFunc func,
- gpointer user_data);
-char * swfdec_script_print_action (guint action,
- const guint8 * data,
- guint len);
G_END_DECLS
diff --git a/libswfdec/swfdec_script_internal.h b/libswfdec/swfdec_script_internal.h
new file mode 100644
index 0000000..aee0b94
--- /dev/null
+++ b/libswfdec/swfdec_script_internal.h
@@ -0,0 +1,93 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_SCRIPT_INTERNAL_H_
+#define _SWFDEC_SCRIPT_INTERNAL_H_
+
+#include <libswfdec/swfdec.h>
+#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_types.h>
+#include <libswfdec/swfdec_bits.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecScriptArgument SwfdecScriptArgument;
+typedef struct _SwfdecConstantPool SwfdecConstantPool;
+
+typedef enum {
+ SWFDEC_SCRIPT_PRELOAD_THIS = (1 << 0),
+ SWFDEC_SCRIPT_SUPPRESS_THIS = (1 << 1),
+ SWFDEC_SCRIPT_PRELOAD_ARGS = (1 << 2),
+ SWFDEC_SCRIPT_SUPPRESS_ARGS = (1 << 3),
+ SWFDEC_SCRIPT_PRELOAD_SUPER = (1 << 4),
+ SWFDEC_SCRIPT_SUPPRESS_SUPER = (1 << 5),
+ SWFDEC_SCRIPT_PRELOAD_ROOT = (1 << 6),
+ SWFDEC_SCRIPT_PRELOAD_PARENT = (1 << 7),
+ SWFDEC_SCRIPT_PRELOAD_GLOBAL = (1 << 8)
+} SwfdecScriptFlag;
+
+typedef gboolean (* SwfdecScriptForeachFunc) (gconstpointer bytecode, guint action,
+ const guint8 *data, guint len, gpointer user_data);
+
+/* FIXME: May want to typedef to SwfdecBuffer directly */
+struct _SwfdecScript {
+ SwfdecBuffer * buffer; /* buffer holding the script */
+ guint refcount; /* reference count */
+ char * name; /* name identifying this script */
+ guint version; /* version of the script */
+ guint n_registers; /* number of registers */
+ SwfdecBuffer * constant_pool; /* constant pool action */
+ guint flags; /* SwfdecScriptFlags */
+ guint n_arguments; /* number of arguments */
+ SwfdecScriptArgument *arguments; /* arguments or NULL if none */
+};
+
+struct _SwfdecScriptArgument {
+ char * name; /* name of the argument (not GC'ed) */
+ guint preload; /* preload slot to preload to or 0 */
+};
+
+const char * swfdec_action_get_name (guint action);
+guint swfdec_action_get_from_name (const char * name);
+
+SwfdecConstantPool *
+ swfdec_constant_pool_new_from_action (const guint8 * data,
+ guint len,
+ guint version);
+void swfdec_constant_pool_free (SwfdecConstantPool * pool);
+guint swfdec_constant_pool_size (SwfdecConstantPool * pool);
+const char * swfdec_constant_pool_get (SwfdecConstantPool * pool,
+ guint i);
+void swfdec_constant_pool_attach_to_context (SwfdecConstantPool * pool,
+ SwfdecAsContext * context);
+
+SwfdecScript * swfdec_script_new_from_bits (SwfdecBits * bits,
+ const char * name,
+ guint version);
+
+gboolean swfdec_script_foreach (SwfdecScript * script,
+ SwfdecScriptForeachFunc func,
+ gpointer user_data);
+char * swfdec_script_print_action (guint action,
+ const guint8 * data,
+ guint len);
+
+G_END_DECLS
+
+#endif
diff --git a/libswfdec/swfdec_swf_decoder.c b/libswfdec/swfdec_swf_decoder.c
index 1521e6f..3f67ebc 100644
--- a/libswfdec/swfdec_swf_decoder.c
+++ b/libswfdec/swfdec_swf_decoder.c
@@ -36,6 +36,7 @@
#include "swfdec_debug.h"
#include "swfdec_player_internal.h"
#include "swfdec_script.h"
+#include "swfdec_script_internal.h"
#include "swfdec_sprite.h"
enum {
diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c
index a8b77fc..82ac572 100644
--- a/libswfdec/swfdec_tag.c
+++ b/libswfdec/swfdec_tag.c
@@ -39,7 +39,7 @@
#include "swfdec_movie.h" /* for SwfdecContent */
#include "swfdec_pattern.h"
#include "swfdec_player_internal.h"
-#include "swfdec_script.h"
+#include "swfdec_script_internal.h"
#include "swfdec_shape.h"
#include "swfdec_sound.h"
#include "swfdec_sprite.h"
@@ -545,7 +545,7 @@ tag_func_do_init_action (SwfdecSwfDecode
return SWFDEC_STATUS_OK;
}
name = g_strdup_printf ("InitAction %u", id);
- sprite->init_action = swfdec_script_new (bits, name, s->version);
+ sprite->init_action = swfdec_script_new_from_bits (bits, name, s->version);
g_free (name);
if (sprite->init_action) {
swfdec_script_ref (sprite->init_action);
@@ -594,7 +594,7 @@ tag_func_do_action (SwfdecSwfDecoder * s
name = g_strdup_printf ("Sprite%u_Frame%u", SWFDEC_CHARACTER (s->parse_sprite)->id,
s->parse_sprite->parse_frame);
- script = swfdec_script_new (&s->b, name, s->version);
+ script = swfdec_script_new_from_bits (&s->b, name, s->version);
g_free (name);
if (script) {
swfdec_swf_decoder_add_script (s, script);
diff --git a/libswfdec/swfdec_types.h b/libswfdec/swfdec_types.h
index 44edd85..907ac87 100644
--- a/libswfdec/swfdec_types.h
+++ b/libswfdec/swfdec_types.h
@@ -49,7 +49,6 @@ typedef struct _SwfdecShape SwfdecShape;
typedef struct _SwfdecShapeVec SwfdecShapeVec;
typedef struct _SwfdecRect SwfdecRect;
typedef struct _SwfdecRootSprite SwfdecRootSprite;
-typedef struct _SwfdecScript SwfdecScript;
typedef struct _SwfdecScriptable SwfdecScriptable;
typedef struct _SwfdecSound SwfdecSound;
typedef struct _SwfdecSoundChunk SwfdecSoundChunk;
diff --git a/player/swfdec_debug_scripts.c b/player/swfdec_debug_scripts.c
index 3877da8..14471c3 100644
--- a/player/swfdec_debug_scripts.c
+++ b/player/swfdec_debug_scripts.c
@@ -22,6 +22,7 @@
#endif
#include "swfdec_debug_scripts.h"
+#include <libswfdec/swfdec_script_internal.h>
G_DEFINE_TYPE (SwfdecDebugScripts, swfdec_debug_scripts, GTK_TYPE_TREE_VIEW)
diff --git a/player/swfdec_player_manager.c b/player/swfdec_player_manager.c
index 1ff9fbf..7eb1edc 100644
--- a/player/swfdec_player_manager.c
+++ b/player/swfdec_player_manager.c
@@ -26,6 +26,7 @@
#include <libswfdec/swfdec_debugger.h>
#include <libswfdec/swfdec_as_object.h>
#include "swfdec_player_manager.h"
+#include <libswfdec/swfdec_script_internal.h>
#include <libswfdec-gtk/swfdec_source.h>
enum {
diff --git a/test/swfedit_tag.c b/test/swfedit_tag.c
index b2f887a..0b6b8c2 100644
--- a/test/swfedit_tag.c
+++ b/test/swfedit_tag.c
@@ -26,7 +26,7 @@
#include <libswfdec/swfdec_bits.h>
#include <libswfdec/swfdec_debug.h>
-#include <libswfdec/swfdec_script.h>
+#include <libswfdec/swfdec_script_internal.h>
#include <libswfdec/swfdec_tag.h>
#include "swfedit_tag.h"
#include "swfdec_out.h"
@@ -217,7 +217,7 @@ swfedit_script_read (SwfeditToken *token
token = token->parent;
if (!SWFEDIT_IS_FILE (token))
return NULL;
- return swfdec_script_new (bits, "original script", swfedit_file_get_version (SWFEDIT_FILE (token)));
+ return swfdec_script_new_from_bits (bits, "original script", swfedit_file_get_version (SWFEDIT_FILE (token)));
}
static void
diff --git a/test/swfedit_token.c b/test/swfedit_token.c
index dfb55db..11bb485 100644
--- a/test/swfedit_token.c
+++ b/test/swfedit_token.c
@@ -26,7 +26,7 @@
#include <gtk/gtk.h>
#include <libswfdec/swfdec_buffer.h>
#include <libswfdec/swfdec_color.h>
-#include <libswfdec/swfdec_script.h>
+#include <libswfdec/swfdec_script_internal.h>
#include "swfedit_token.h"
/*** CONVERTERS ***/
@@ -315,15 +315,13 @@ static gboolean
swfedit_script_from_string (const char *s, gpointer* result)
{
gpointer buffer;
- SwfdecBits bits;
SwfdecScript *script;
if (!swfedit_binary_from_string (s, &buffer)) {
return FALSE;
}
- swfdec_bits_init (&bits, buffer);
- script = swfdec_script_new (&bits, "unknown", 6 /* FIXME */);
+ script = swfdec_script_new (buffer, "unknown", 6 /* FIXME */);
swfdec_buffer_unref (buffer);
if (script != NULL) {
*result = script;
diff --git a/test/swfscript.c b/test/swfscript.c
index e53a3d9..187aeb5 100644
--- a/test/swfscript.c
+++ b/test/swfscript.c
@@ -22,7 +22,7 @@
#endif
#include <gtk/gtk.h>
-#include "libswfdec/swfdec_script.h"
+#include "libswfdec/swfdec_script_internal.h"
#include "swfdec_out.h"
#include "swfedit_file.h"
@@ -162,7 +162,6 @@ modify_file (SwfeditToken *token, guint
SwfeditTokenType type, gconstpointer value, gpointer data)
{
Action end;
- SwfdecBits bits;
SwfdecScript *script;
State state;
@@ -208,8 +207,7 @@ modify_file (SwfeditToken *token, guint
g_print ("got a new script in %u bytes - old script was %u bytes\n",
state.buffer->length, state.script->buffer->length);
#endif
- swfdec_bits_init (&bits, state.buffer);
- script = swfdec_script_new (&bits, state.script->name, state.script->version);
+ script = swfdec_script_new (state.buffer, state.script->name, state.script->version);
swfdec_buffer_unref (state.buffer);
g_assert (script);
swfedit_token_set (token, idx, script);
diff-tree 5c17c6e1324644006db930660e04ea910d6d4a6c (from a9149d4d660483affd985c5a854e2a55b0fdb923)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Aug 9 17:07:53 2007 +0200
make swfdec_gtk_player_new () take an optional debugger argument
diff --git a/libswfdec-gtk/swfdec_gtk_player.c b/libswfdec-gtk/swfdec_gtk_player.c
index 06a71c5..485f708 100644
--- a/libswfdec-gtk/swfdec_gtk_player.c
+++ b/libswfdec-gtk/swfdec_gtk_player.c
@@ -160,6 +160,7 @@ swfdec_gtk_player_init (SwfdecGtkPlayer
/**
* swfdec_gtk_player_new:
+ * @debugger: %NULL or a #SwfdecAsDebugger to debug this player
*
* Creates a new Swfdec Gtk player.
* This function calls swfdec_init () for you if it wasn't called before.
@@ -167,12 +168,12 @@ swfdec_gtk_player_init (SwfdecGtkPlayer
* Returns: The new player
**/
SwfdecPlayer *
-swfdec_gtk_player_new (void)
+swfdec_gtk_player_new (SwfdecAsDebugger *debugger)
{
SwfdecPlayer *player;
swfdec_init ();
- player = g_object_new (SWFDEC_TYPE_GTK_PLAYER, NULL);
+ player = g_object_new (SWFDEC_TYPE_GTK_PLAYER, "debugger", debugger, NULL);
return player;
}
@@ -198,8 +199,8 @@ swfdec_gtk_player_new_from_uri (const ch
g_return_val_if_fail (uri != NULL, NULL);
+ player = swfdec_gtk_player_new (NULL);
loader = swfdec_gtk_loader_new (uri);
- player = swfdec_gtk_player_new ();
swfdec_player_set_loader (player, loader);
return player;
diff --git a/libswfdec-gtk/swfdec_gtk_player.h b/libswfdec-gtk/swfdec_gtk_player.h
index b040fe9..a8a9b30 100644
--- a/libswfdec-gtk/swfdec_gtk_player.h
+++ b/libswfdec-gtk/swfdec_gtk_player.h
@@ -36,7 +36,7 @@ typedef struct _SwfdecGtkPlayerClass Swf
GType swfdec_gtk_player_get_type (void);
-SwfdecPlayer * swfdec_gtk_player_new (void);
+SwfdecPlayer * swfdec_gtk_player_new (SwfdecAsDebugger * debugger);
SwfdecPlayer * swfdec_gtk_player_new_from_uri (const char * uri);
void swfdec_gtk_player_set_playing (SwfdecGtkPlayer * player,
diff --git a/player/swfplay.c b/player/swfplay.c
index c4f8523..23e3f8f 100644
--- a/player/swfplay.c
+++ b/player/swfplay.c
@@ -136,7 +136,7 @@ main (int argc, char *argv[])
g_object_unref (loader);
return 1;
}
- player = swfdec_gtk_player_new ();
+ player = swfdec_gtk_player_new (NULL);
if (trace)
g_signal_connect (player, "trace", G_CALLBACK (print_trace), NULL);
diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index a56ecab..dd85bc4 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -97,7 +97,7 @@ vivi_application_class_init (ViviApplica
static void
vivi_application_init (ViviApplication *app)
{
- app->player = swfdec_gtk_player_new ();
+ app->player = swfdec_gtk_player_new (NULL);
}
ViviApplication *
@@ -112,7 +112,7 @@ vivi_application_reset (ViviApplication
g_return_if_fail (VIVI_IS_APPLICATION (app));
g_object_unref (app->player);
- app->player = swfdec_gtk_player_new ();
+ app->player = swfdec_gtk_player_new (NULL);
}
void
diff-tree a9149d4d660483affd985c5a854e2a55b0fdb923 (from 510ecc39d83221ead3735a72c2ec044111ac299c)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Aug 9 17:05:14 2007 +0200
make swfdec_player_new () take an optional debugger argument
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 98ded92..a1acf87 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -1509,6 +1509,7 @@ swfdec_player_set_export_class (SwfdecPl
/**
* swfdec_player_new:
+ * @debugger: %NULL or a #SwfdecAsDebugger to use for debugging this player.
*
* Creates a new player.
* This function calls swfdec_init () for you if it wasn't called before.
@@ -1516,12 +1517,12 @@ swfdec_player_set_export_class (SwfdecPl
* Returns: The new player
**/
SwfdecPlayer *
-swfdec_player_new (void)
+swfdec_player_new (SwfdecAsDebugger *debugger)
{
SwfdecPlayer *player;
swfdec_init ();
- player = g_object_new (SWFDEC_TYPE_PLAYER, NULL);
+ player = g_object_new (SWFDEC_TYPE_PLAYER, "debugger", debugger, NULL);
return player;
}
@@ -1597,7 +1598,7 @@ swfdec_player_new_from_file (const char
g_return_val_if_fail (filename != NULL, NULL);
loader = swfdec_file_loader_new (filename);
- player = swfdec_player_new ();
+ player = swfdec_player_new (NULL);
swfdec_player_set_loader (player, loader);
return player;
diff --git a/libswfdec/swfdec_player.h b/libswfdec/swfdec_player.h
index 905235a..aba2b62 100644
--- a/libswfdec/swfdec_player.h
+++ b/libswfdec/swfdec_player.h
@@ -22,6 +22,7 @@
#include <glib-object.h>
#include <cairo.h>
+#include <libswfdec/swfdec_as_types.h>
#include <libswfdec/swfdec_loader.h>
G_BEGIN_DECLS
@@ -66,7 +67,7 @@ void swfdec_init (void);
GType swfdec_player_get_type (void);
-SwfdecPlayer * swfdec_player_new (void);
+SwfdecPlayer * swfdec_player_new (SwfdecAsDebugger * debugger);
SwfdecPlayer * swfdec_player_new_from_file (const char * filename);
void swfdec_player_set_loader (SwfdecPlayer * player,
SwfdecLoader * loader);
diff --git a/test/image/image.c b/test/image/image.c
index 70e6f43..e50c9c6 100644
--- a/test/image/image.c
+++ b/test/image/image.c
@@ -167,7 +167,7 @@ run_test (const char *filename)
g_object_unref (loader);
goto error;
}
- player = swfdec_player_new ();
+ player = swfdec_player_new (NULL);
swfdec_player_set_loader (player, loader);
for (i = 0; i < 10; i++) {
diff --git a/test/sound/sound.c b/test/sound/sound.c
index c962453..2053446 100644
--- a/test/sound/sound.c
+++ b/test/sound/sound.c
@@ -206,7 +206,7 @@ run_test (const char *filename)
g_object_unref (loader);
goto error;
}
- player = swfdec_player_new ();
+ player = swfdec_player_new (NULL);
g_signal_connect (player, "audio-added", G_CALLBACK (audio_added), &data);
g_signal_connect (player, "audio-removed", G_CALLBACK (audio_removed), &data);
g_signal_connect (player, "advance", G_CALLBACK (render_all_streams), &data);
diff --git a/test/trace/trace.c b/test/trace/trace.c
index 0f986e5..99d6a5a 100644
--- a/test/trace/trace.c
+++ b/test/trace/trace.c
@@ -100,7 +100,7 @@ run_test (gpointer testp, gpointer unuse
goto fail;
}
string = g_string_new ("");
- player = swfdec_player_new ();
+ player = swfdec_player_new (NULL);
g_signal_connect (player, "trace", G_CALLBACK (trace_cb), string);
g_signal_connect (player, "fscommand", G_CALLBACK (fscommand_cb), &quit);
swfdec_player_set_loader (player, loader);
diff-tree 510ecc39d83221ead3735a72c2ec044111ac299c (from 70d532781b8e404e33afe989d94d7d3fa14ad90c)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Aug 9 17:03:08 2007 +0200
we use gtk players unconditionally
diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index 496eadf..a56ecab 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -112,7 +112,7 @@ vivi_application_reset (ViviApplication
g_return_if_fail (VIVI_IS_APPLICATION (app));
g_object_unref (app->player);
- app->player = swfdec_player_new ();
+ app->player = swfdec_gtk_player_new ();
}
void
diff-tree 70d532781b8e404e33afe989d94d7d3fa14ad90c (from 260be3fc109be6884aba0d01a9f9429ab4099562)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Aug 9 16:59:06 2007 +0200
make the SwfdecAsContext have a debugger property
diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c
index 49ec05e..1a311e9 100644
--- a/libswfdec/swfdec_as_context.c
+++ b/libswfdec/swfdec_as_context.c
@@ -417,10 +417,47 @@ enum {
LAST_SIGNAL
};
+enum {
+ PROP_0,
+ PROP_DEBUGGER,
+};
+
G_DEFINE_TYPE (SwfdecAsContext, swfdec_as_context, G_TYPE_OBJECT)
static guint signals[LAST_SIGNAL] = { 0, };
static void
+swfdec_as_context_get_property (GObject *object, guint param_id, GValue *value,
+ GParamSpec * pspec)
+{
+ SwfdecAsContext *context = SWFDEC_AS_CONTEXT (object);
+
+ switch (param_id) {
+ case PROP_DEBUGGER:
+ g_value_set_object (value, context->debugger);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_as_context_set_property (GObject *object, guint param_id, const GValue *value,
+ GParamSpec * pspec)
+{
+ SwfdecAsContext *context = SWFDEC_AS_CONTEXT (object);
+
+ switch (param_id) {
+ case PROP_DEBUGGER:
+ context->debugger = g_value_dup_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
swfdec_as_context_dispose (GObject *object)
{
SwfdecAsContext *context = SWFDEC_AS_CONTEXT (object);
@@ -435,6 +472,10 @@ swfdec_as_context_dispose (GObject *obje
g_hash_table_destroy (context->objects);
g_hash_table_destroy (context->strings);
g_rand_free (context->rand);
+ if (context->debugger) {
+ g_object_unref (context->debugger);
+ context->debugger = NULL;
+ }
G_OBJECT_CLASS (swfdec_as_context_parent_class)->dispose (object);
}
@@ -445,6 +486,12 @@ swfdec_as_context_class_init (SwfdecAsCo
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = swfdec_as_context_dispose;
+ object_class->get_property = swfdec_as_context_get_property;
+ object_class->set_property = swfdec_as_context_set_property;
+
+ g_object_class_install_property (object_class, PROP_DEBUGGER,
+ g_param_spec_object ("debugger", "debugger", "debugger used in this player",
+ SWFDEC_TYPE_AS_DEBUGGER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/**
* SwfdecAsContext::trace:
@@ -642,16 +689,19 @@ swfdec_as_context_run (SwfdecAsContext *
guint action, len;
guint8 *data;
int version;
- SwfdecAsContextClass *klass;
- void (* step) (SwfdecAsContext *context);
+ void (* step) (SwfdecAsDebugger *debugger, SwfdecAsContext *context);
gboolean check_scope; /* some opcodes avoid a scope check */
g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
if (context->frame == NULL || context->state == SWFDEC_AS_CONTEXT_ABORTED)
return;
- klass = SWFDEC_AS_CONTEXT_GET_CLASS (context);
- step = klass->step;
+ if (context->debugger) {
+ SwfdecAsDebuggerClass *klass = SWFDEC_AS_DEBUGGER_GET_CLASS (context->debugger);
+ step = klass->step;
+ } else {
+ step = NULL;
+ }
last_frame = context->last_frame;
context->last_frame = context->frame->next;
@@ -737,7 +787,7 @@ start:
/* invoke debugger if there is one */
if (step) {
frame->pc = pc;
- (* step) (context);
+ (* step) (context->debugger, context);
if (frame != context->frame ||
frame->pc != pc) {
goto start;
diff --git a/libswfdec/swfdec_as_context.h b/libswfdec/swfdec_as_context.h
index d18fa62..fbcb6e9 100644
--- a/libswfdec/swfdec_as_context.h
+++ b/libswfdec/swfdec_as_context.h
@@ -76,6 +76,9 @@ struct _SwfdecAsContext {
SwfdecAsObject * Object; /* Object */
SwfdecAsObject * Object_prototype; /* Object.prototype */
SwfdecAsObject * Array; /* Array */
+
+ /* debugging */
+ SwfdecAsDebugger * debugger; /* debugger (or NULL if none) */
};
struct _SwfdecAsContextClass {
@@ -83,8 +86,6 @@ struct _SwfdecAsContextClass {
/* mark all objects that should not be collected */
void (* mark) (SwfdecAsContext * context);
- /* debugging: call this function before executing a bytecode if non-NULL */
- void (* step) (SwfdecAsContext * context);
/* overwrite if you want to report a different time than gettimeofday */
void (* get_time) (SwfdecAsContext * context,
GTimeVal * tv);
diff --git a/libswfdec/swfdec_debugger.c b/libswfdec/swfdec_debugger.c
index 9b0fd2a..89adbf6 100644
--- a/libswfdec/swfdec_debugger.c
+++ b/libswfdec/swfdec_debugger.c
@@ -386,6 +386,7 @@ swfdec_debugger_dispose (GObject *object
G_OBJECT_CLASS (swfdec_debugger_parent_class)->dispose (object);
}
+#if 0
static void
swfdec_debugger_do_breakpoint (SwfdecDebugger *debugger, guint id)
{
@@ -439,12 +440,12 @@ swfdec_debugger_step (SwfdecAsContext *c
}
}
}
+#endif
static void
swfdec_debugger_class_init (SwfdecDebuggerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecAsContextClass *context_class = SWFDEC_AS_CONTEXT_CLASS (klass);
object_class->dispose = swfdec_debugger_dispose;
@@ -469,8 +470,6 @@ swfdec_debugger_class_init (SwfdecDebugg
signals[MOVIE_REMOVED] = g_signal_new ("movie-removed",
G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
-
- context_class->step = swfdec_debugger_step;
}
static void
diff-tree 260be3fc109be6884aba0d01a9f9429ab4099562 (from dbbc914ef87434d4d1c9aa8332451441030ef655)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Aug 9 15:55:58 2007 +0200
add a debugger class that is not a subclass of SwfdecAsContext
diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am
index 2f48811..dd62712 100644
--- a/libswfdec/Makefile.am
+++ b/libswfdec/Makefile.am
@@ -23,6 +23,7 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES
swfdec_as_array.c \
swfdec_as_boolean.c \
swfdec_as_context.c \
+ swfdec_as_debugger.c \
swfdec_as_frame.c \
swfdec_as_function.c \
swfdec_as_interpret.c \
@@ -125,6 +126,7 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_LDFLAGS
public_headers = \
swfdec.h \
swfdec_as_context.h \
+ swfdec_as_debugger.h \
swfdec_as_frame.h \
swfdec_as_object.h \
swfdec_as_types.h \
diff --git a/libswfdec/swfdec.h b/libswfdec/swfdec.h
index b4b9ab8..27e65e9 100644
--- a/libswfdec/swfdec.h
+++ b/libswfdec/swfdec.h
@@ -23,6 +23,7 @@
#define __SWFDEC_H__
#include <libswfdec/swfdec_as_context.h>
+#include <libswfdec/swfdec_as_debugger.h>
#include <libswfdec/swfdec_as_frame.h>
#include <libswfdec/swfdec_as_object.h>
#include <libswfdec/swfdec_as_types.h>
diff --git a/libswfdec/swfdec_as_debugger.c b/libswfdec/swfdec_as_debugger.c
new file mode 100644
index 0000000..ac0c6a4
--- /dev/null
+++ b/libswfdec/swfdec_as_debugger.c
@@ -0,0 +1,72 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "swfdec_as_debugger.h"
+#include "swfdec_as_context.h"
+
+G_DEFINE_TYPE (SwfdecAsDebugger, swfdec_as_debugger, G_TYPE_OBJECT)
+
+/**
+ * SECTION:SwfdecAsDebugger
+ * @title: SwfdecAsDebugger
+ * @short_description: the debugger object
+ * @see also: SwfdecAsContext
+ *
+ * The debugger object is a special object that can be set on a #SwfdecAsContext
+ * upon creation. If that is done, the debugger can then be used to inspect the
+ * running Actionscript application.
+ */
+
+/**
+ * SwfdecAsDebugger
+ *
+ * This is the type of the debugger object.
+ */
+
+/**
+ * SwfdecAsDebuggerClass
+ * @step: This function is called everytime just before a bytecode is executed by
+ * the script engine. So it's very powerful, but can also slow down the
+ * script engine a lot.
+ * @frame_change: Called whenever the current frame changes. This happens either
+ * when calling a function or when a function call returns. The
+ * function call is called for any type of frame, even calls to
+ * native functions.
+ *
+ * The class object for the debugger. You need to override these functions to
+ * get useful functionality for the debugger.
+ */
+
+static void
+swfdec_as_debugger_class_init (SwfdecAsDebuggerClass *klass)
+{
+}
+
+static void
+swfdec_as_debugger_init (SwfdecAsDebugger *debugger)
+{
+}
+
diff --git a/libswfdec/swfdec_as_debugger.h b/libswfdec/swfdec_as_debugger.h
new file mode 100644
index 0000000..643ac53
--- /dev/null
+++ b/libswfdec/swfdec_as_debugger.h
@@ -0,0 +1,58 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_DEBUGGER_H_
+#define _SWFDEC_AS_DEBUGGER_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_script.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAsDebuggerClass SwfdecAsDebuggerClass;
+
+#define SWFDEC_TYPE_AS_DEBUGGER (swfdec_as_debugger_get_type())
+#define SWFDEC_IS_AS_DEBUGGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_DEBUGGER))
+#define SWFDEC_IS_AS_DEBUGGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_DEBUGGER))
+#define SWFDEC_AS_DEBUGGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_DEBUGGER, SwfdecAsDebugger))
+#define SWFDEC_AS_DEBUGGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_DEBUGGER, SwfdecAsDebuggerClass))
+#define SWFDEC_AS_DEBUGGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_DEBUGGER, SwfdecAsDebuggerClass))
+
+struct _SwfdecAsDebugger {
+ /*< private >*/
+ GObject object;
+};
+
+struct _SwfdecAsDebuggerClass {
+ GObjectClass object_class;
+
+ /* 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);
+};
+
+GType swfdec_as_debugger_get_type (void);
+
+
+G_END_DECLS
+#endif
diff --git a/libswfdec/swfdec_as_types.h b/libswfdec/swfdec_as_types.h
index dbb9394..d435cb9 100644
--- a/libswfdec/swfdec_as_types.h
+++ b/libswfdec/swfdec_as_types.h
@@ -37,6 +37,7 @@ typedef enum {
typedef struct _SwfdecAsArray SwfdecAsArray;
typedef struct _SwfdecAsContext SwfdecAsContext;
+typedef struct _SwfdecAsDebugger SwfdecAsDebugger;
typedef struct _SwfdecAsFrame SwfdecAsFrame;
typedef struct _SwfdecAsFunction SwfdecAsFunction;
typedef struct _SwfdecAsObject SwfdecAsObject;
diff-tree dbbc914ef87434d4d1c9aa8332451441030ef655 (from 6f1d4325411f14379a2f7fdfd4cec1ed0a166db0)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Aug 9 15:22:01 2007 +0200
no need for swfdec_script.h here
diff --git a/libswfdec/swfdec_as_array.h b/libswfdec/swfdec_as_array.h
index a437301..7a06296 100644
--- a/libswfdec/swfdec_as_array.h
+++ b/libswfdec/swfdec_as_array.h
@@ -23,7 +23,6 @@
#include <libswfdec/swfdec_as_object.h>
#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script.h>
G_BEGIN_DECLS
diff-tree 6f1d4325411f14379a2f7fdfd4cec1ed0a166db0 (from e506ea7bfceb2b1a0a9237141d6137cf39110233)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Aug 9 15:12:08 2007 +0200
get rid of the debugger pointer in SwfdecScript
diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index ecc828a..90fd2e2 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -1564,7 +1564,6 @@ swfdec_action_define_function (SwfdecAsC
script->n_arguments = n_args;
script->arguments = args;
SWFDEC_AS_SCRIPT_FUNCTION (fun)->script = script;
- swfdec_script_add_to_context (script, cx);
/* attach the function */
if (*function_name == '\0') {
swfdec_as_stack_ensure_free (cx, 1);
diff --git a/libswfdec/swfdec_event.c b/libswfdec/swfdec_event.c
index aa123ca..26c4dfb 100644
--- a/libswfdec/swfdec_event.c
+++ b/libswfdec/swfdec_event.c
@@ -202,7 +202,7 @@ swfdec_event_list_parse (SwfdecEventList
event.key = key;
name = g_strconcat (description, ".",
swfdec_event_list_condition_name (conditions), NULL);
- event.script = swfdec_script_new_for_context (SWFDEC_AS_CONTEXT (list->player), bits, name, version);
+ event.script = swfdec_script_new (bits, name, version);
g_free (name);
if (event.script)
g_array_append_val (list->events, event);
diff --git a/libswfdec/swfdec_script.c b/libswfdec/swfdec_script.c
index eec940b..87f2010 100644
--- a/libswfdec/swfdec_script.c
+++ b/libswfdec/swfdec_script.c
@@ -111,15 +111,6 @@ swfdec_constant_pool_free (SwfdecConstan
/*** SUPPORT FUNCTIONS ***/
-void
-swfdec_script_add_to_context (SwfdecScript *script, SwfdecAsContext *context)
-{
- if (SWFDEC_IS_DEBUGGER (context)) {
- swfdec_debugger_add_script (SWFDEC_DEBUGGER (context), script);
- script->debugger = context;
- }
-}
-
char *
swfdec_script_print_action (guint action, const guint8 *data, guint len)
{
@@ -208,21 +199,6 @@ validate_action (gconstpointer bytecode,
}
SwfdecScript *
-swfdec_script_new_for_context (SwfdecAsContext *context, SwfdecBits *bits,
- const char *name, guint version)
-{
- SwfdecScript *script;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
- g_return_val_if_fail (bits != NULL, NULL);
-
- script = swfdec_script_new (bits, name, version);
- if (script)
- swfdec_script_add_to_context (script, context);
- return script;
-}
-
-SwfdecScript *
swfdec_script_new (SwfdecBits *bits, const char *name, guint version)
{
SwfdecScript *script;
@@ -280,11 +256,6 @@ swfdec_script_unref (SwfdecScript *scrip
g_return_if_fail (script->refcount > 0);
script->refcount--;
- if (script->refcount == 1 && script->debugger) {
- script->debugger = NULL;
- swfdec_debugger_remove_script (script->debugger, script);
- return;
- }
if (script->refcount > 0)
return;
diff --git a/libswfdec/swfdec_script.h b/libswfdec/swfdec_script.h
index 31ae882..6a0870b 100644
--- a/libswfdec/swfdec_script.h
+++ b/libswfdec/swfdec_script.h
@@ -53,7 +53,6 @@ struct _SwfdecScript {
char * name; /* name identifying this script */
guint version; /* version of the script */
guint n_registers; /* number of registers */
- gpointer debugger; /* debugger owning us or NULL */
SwfdecBuffer * constant_pool; /* constant pool action */
guint flags; /* SwfdecScriptFlags */
guint n_arguments; /* number of arguments */
@@ -82,12 +81,6 @@ void swfdec_constant_pool_attach_to_con
SwfdecScript * swfdec_script_new (SwfdecBits * bits,
const char * name,
guint version);
-SwfdecScript * swfdec_script_new_for_context (SwfdecAsContext * context,
- SwfdecBits * bits,
- const char * name,
- guint version);
-void swfdec_script_add_to_context (SwfdecScript * script,
- SwfdecAsContext * context);
SwfdecScript * swfdec_script_ref (SwfdecScript * script);
void swfdec_script_unref (SwfdecScript * script);
diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c
index b6acf1b..a8b77fc 100644
--- a/libswfdec/swfdec_tag.c
+++ b/libswfdec/swfdec_tag.c
@@ -545,8 +545,7 @@ tag_func_do_init_action (SwfdecSwfDecode
return SWFDEC_STATUS_OK;
}
name = g_strdup_printf ("InitAction %u", id);
- sprite->init_action = swfdec_script_new_for_context (SWFDEC_AS_CONTEXT (SWFDEC_DECODER (s)->player),
- bits, name, s->version);
+ sprite->init_action = swfdec_script_new (bits, name, s->version);
g_free (name);
if (sprite->init_action) {
swfdec_script_ref (sprite->init_action);
@@ -595,7 +594,7 @@ tag_func_do_action (SwfdecSwfDecoder * s
name = g_strdup_printf ("Sprite%u_Frame%u", SWFDEC_CHARACTER (s->parse_sprite)->id,
s->parse_sprite->parse_frame);
- script = swfdec_script_new_for_context (SWFDEC_AS_CONTEXT (SWFDEC_DECODER (s)->player), &s->b, name, s->version);
+ script = swfdec_script_new (&s->b, name, s->version);
g_free (name);
if (script) {
swfdec_swf_decoder_add_script (s, script);
More information about the Swfdec
mailing list