[Swfdec] 17 commits - doc/swfdec-sections.txt libswfdec/compiler.c libswfdec/.gitignore libswfdec/Makefile.am libswfdec/swfdec_asbroadcaster.c libswfdec/swfdec_as_context.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_object.h libswfdec/swfdec_as_strings.c libswfdec/swfdec_initialize.as libswfdec/swfdec_initialize.h libswfdec/swfdec_internal.h libswfdec/swfdec_listener.c libswfdec/swfdec_listener.h libswfdec/swfdec_mouse_as.c libswfdec/swfdec_player_as.c libswfdec/swfdec_player.c libswfdec/swfdec_player.h libswfdec/swfdec_player_internal.h libswfdec/swfdec_swf_decoder.c test/trace
Benjamin Otte
company at kemper.freedesktop.org
Thu Jul 26 07:46:19 PDT 2007
doc/swfdec-sections.txt | 4
libswfdec/.gitignore | 2
libswfdec/Makefile.am | 23 +++
libswfdec/compiler.c | 140 +++++++++++++++++++++++
libswfdec/swfdec_as_context.c | 6 -
libswfdec/swfdec_as_object.c | 45 ++++---
libswfdec/swfdec_as_object.h | 5
libswfdec/swfdec_as_strings.c | 3
libswfdec/swfdec_asbroadcaster.c | 75 ++++++++++++
libswfdec/swfdec_initialize.as | 59 +++++++++
libswfdec/swfdec_initialize.h | 56 +++++++++
libswfdec/swfdec_internal.h | 2
libswfdec/swfdec_listener.c | 160 ---------------------------
libswfdec/swfdec_listener.h | 43 -------
libswfdec/swfdec_mouse_as.c | 50 --------
libswfdec/swfdec_player.c | 127 ++++++++++++++++++---
libswfdec/swfdec_player.h | 6 +
libswfdec/swfdec_player_as.c | 80 +++----------
libswfdec/swfdec_player_internal.h | 5
libswfdec/swfdec_swf_decoder.c | 4
test/trace/Makefile.am | 9 +
test/trace/invalid-variable-name-5.swf |binary
test/trace/invalid-variable-name-5.swf.trace | 2
test/trace/invalid-variable-name-6.swf |binary
test/trace/invalid-variable-name-6.swf.trace | 2
test/trace/invalid-variable-name-7.swf |binary
test/trace/invalid-variable-name-7.swf.trace | 2
test/trace/invalid-variable-name-8.swf |binary
test/trace/invalid-variable-name-8.swf.trace | 2
test/trace/invalid-variable-name.as | 8 +
30 files changed, 565 insertions(+), 355 deletions(-)
New commits:
diff-tree c2cef8e7f06bb5916c17839ae4c145241d26130a (from cfdeb2996fef35060746d10091f74a770e236d0a)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 26 16:43:21 2007 +0200
rework variable flag handling to be more in line with ASSetPropFlags
get rid of the native flag and add the v6+ flag
diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c
index ad606ad..5fc3b1a 100644
--- a/libswfdec/swfdec_as_context.c
+++ b/libswfdec/swfdec_as_context.c
@@ -1033,8 +1033,6 @@ swfdec_as_context_ASSetPropFlags (Swfdec
return;
obj = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
flags[0] = swfdec_as_value_to_integer (cx, &argv[2]);
- /* be sure to not delete the NATIVE flag */
- flags[0] &= 7;
flags[1] = (argc > 3) ? swfdec_as_value_to_integer (cx, &argv[3]) : -1;
if (SWFDEC_AS_VALUE_IS_NULL (&argv[1])) {
swfdec_as_object_foreach (obj, swfdec_as_context_ASSetPropFlags_foreach, flags);
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index 28a6f98..7a21a48 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -159,18 +159,25 @@ swfdec_as_object_do_get (SwfdecAsObject
{
SwfdecAsVariable *var = swfdec_as_object_hash_lookup (object, variable);
- if (var) {
- if (var->get) {
- swfdec_as_function_call (var->get, object, 0, NULL, val);
- swfdec_as_context_run (object->context);
- *flags = var->flags;
- } else {
- *val = var->value;
- *flags = var->flags;
- }
- return TRUE;
+ if (var == NULL)
+ return FALSE;
+
+ if (var->flags & SWFDEC_AS_VARIABLE_FLASH6_UP && object->context->version < 6) {
+ g_print ("HARHAR\n");
+ return FALSE;
+ } else if (var->flags & SWFDEC_AS_VARIABLE_FLASH6_UP) {
+ g_print ("HI MOM\n");
}
- return FALSE;
+
+ if (var->get) {
+ swfdec_as_function_call (var->get, object, 0, NULL, val);
+ swfdec_as_context_run (object->context);
+ *flags = var->flags;
+ } else {
+ *val = var->value;
+ *flags = var->flags;
+ }
+ return TRUE;
}
static SwfdecAsVariable *
@@ -974,16 +981,11 @@ static void
swfdec_as_object_hasOwnProperty (SwfdecAsContext *cx, SwfdecAsObject *object,
guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
- SwfdecAsObjectClass *klass;
const char *name;
- guint flags;
- SwfdecAsValue value;
name = swfdec_as_value_to_string (object->context, &argv[0]);
- klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
- if (klass->get (object, name, &value, &flags) &&
- (flags & SWFDEC_AS_VARIABLE_NATIVE) == 0)
+ if (swfdec_as_object_hash_lookup (object, name))
SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
else
SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
diff --git a/libswfdec/swfdec_as_object.h b/libswfdec/swfdec_as_object.h
index aab3cf5..bb2efeb 100644
--- a/libswfdec/swfdec_as_object.h
+++ b/libswfdec/swfdec_as_object.h
@@ -27,12 +27,11 @@ G_BEGIN_DECLS
/* NB: matches ASSetPropFlags */
typedef enum {
- /* ActionScript flags go here */
SWFDEC_AS_VARIABLE_DONT_ENUM = (1 << 0),
SWFDEC_AS_VARIABLE_PERMANENT = (1 << 1),
SWFDEC_AS_VARIABLE_READONLY = (1 << 2),
- /* internal flags go here */
- SWFDEC_AS_VARIABLE_NATIVE = (1 << 3)
+
+ SWFDEC_AS_VARIABLE_FLASH6_UP = (1 << 7)
} SwfdecAsVariableFlag;
typedef struct _SwfdecAsObjectClass SwfdecAsObjectClass;
diff-tree cfdeb2996fef35060746d10091f74a770e236d0a (from 16190862796df295e3ee8555d5434fb2e348b4b3)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 26 16:42:31 2007 +0200
call AsSetPropFlags on AsBroadcaster
diff --git a/libswfdec/swfdec_initialize.as b/libswfdec/swfdec_initialize.as
index 0741314..b153c7a 100644
--- a/libswfdec/swfdec_initialize.as
+++ b/libswfdec/swfdec_initialize.as
@@ -49,9 +49,10 @@ AsBroadcaster.initialize = function (o)
o._listeners = new Array ();
ASSetPropFlags(o, "broadcastMessage,addListener,removeListener,_listeners", 131);
};
-ASSetPropFlags(o, null, 131);
+ASSetPropFlags(AsBroadcaster, null, 131);
/*** MOUSE ***/
+
Mouse = new Object ();
Mouse.show = ASnative (5, 0);
Mouse.hide = ASnative (5, 1);
diff --git a/libswfdec/swfdec_initialize.h b/libswfdec/swfdec_initialize.h
index 6cc7420..2b6c78c 100644
--- a/libswfdec/swfdec_initialize.h
+++ b/libswfdec/swfdec_initialize.h
@@ -44,7 +44,7 @@ const unsigned char swfdec_initialize[]
0x00, 0x08, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0F, 0x40, 0x4F, 0x96, 0x09, 0x00, 0x07,
0x83, 0x00, 0x00, 0x00, 0x08, 0x10, 0x08, 0x0E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00,
0x00, 0x08, 0x11, 0x3D, 0x17, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x83, 0x00, 0x00, 0x00, 0x02, 0x08,
- 0x0E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x11, 0x3D, 0x17, 0x96, 0x09,
+ 0x00, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x11, 0x3D, 0x17, 0x96, 0x09,
0x00, 0x08, 0x12, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x13, 0x40, 0x1D, 0x96, 0x02, 0x00, 0x08,
0x12, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x14, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x05, 0x00, 0x00,
0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x12, 0x1C,
diff-tree 16190862796df295e3ee8555d5434fb2e348b4b3 (from 6e69820af1b177a54c692046e083bcbf0f1ae242)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 26 15:26:07 2007 +0200
remove now unused files
diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am
index a6365a4..88f4c2f 100644
--- a/libswfdec/Makefile.am
+++ b/libswfdec/Makefile.am
@@ -72,7 +72,6 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES
swfdec_html_parser.c \
swfdec_image.c \
swfdec_interval.c \
- swfdec_listener.c \
swfdec_loader.c \
swfdec_loadertarget.c \
swfdec_marshal.c \
@@ -181,7 +180,6 @@ noinst_HEADERS = \
swfdec_initialize.h \
swfdec_internal.h \
swfdec_interval.h \
- swfdec_listener.h \
swfdec_loader_internal.h \
swfdec_loadertarget.h \
swfdec_marshal.h \
diff --git a/libswfdec/swfdec_listener.c b/libswfdec/swfdec_listener.c
deleted file mode 100644
index 73c1bf9..0000000
--- a/libswfdec/swfdec_listener.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/* 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 <string.h>
-#include "swfdec_listener.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_object.h"
-#include "swfdec_debug.h"
-
-typedef struct {
- SwfdecAsObject * object; /* the object we care about or NULL if empty */
- const char * blocked_by; /* string of event we're about to execute */
- gboolean removed; /* TRUE if was removed but is blocked */
-} SwfdecListenerEntry;
-
-struct _SwfdecListener {
- SwfdecAsContext * context;
- /* we can't use GArray here because it reallocated below us, which JS_AddRoot doesn't like */
- SwfdecListenerEntry * entries; /* all allocated entries */
- guint n_entries; /* number of allocated entries */
-};
-
-SwfdecListener *
-swfdec_listener_new (SwfdecAsContext *context)
-{
- SwfdecListener *listener;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
-
- listener = g_new0 (SwfdecListener, 1);
- listener->context = context;
- listener->entries = NULL;
- listener->n_entries = 0;
-
- return listener;
-}
-
-void
-swfdec_listener_free (SwfdecListener *listener)
-{
- g_return_if_fail (listener != NULL);
-
- g_free (listener->entries);
- g_free (listener);
-}
-
-gboolean
-swfdec_listener_add (SwfdecListener *listener, SwfdecAsObject *obj)
-{
- guint found, i;
-
- g_return_val_if_fail (listener != NULL, FALSE);
- g_return_val_if_fail (SWFDEC_AS_OBJECT (obj), FALSE);
-
- found = listener->n_entries;
- for (i = 0; i < listener->n_entries; i++) {
- if (listener->entries[i].object == NULL && found >= listener->n_entries)
- found = i;
- else if (listener->entries[i].object == obj)
- return TRUE;
- }
- if (found >= listener->n_entries) {
- SwfdecListenerEntry *mem;
- guint new_len = listener->n_entries + 16;
-
- mem = g_try_realloc (listener->entries, sizeof (SwfdecListenerEntry) * new_len);
- if (mem == NULL)
- return FALSE;
- memset(mem+found, 0, sizeof(SwfdecListenerEntry) * (new_len - listener->n_entries));
- listener->entries = mem;
- listener->n_entries = new_len;
- }
- g_assert (listener->entries[found].object == NULL);
- listener->entries[found].object = obj;
- return TRUE;
-}
-
-void
-swfdec_listener_remove (SwfdecListener *listener, SwfdecAsObject *obj)
-{
- guint i;
-
- g_return_if_fail (listener != NULL);
- g_return_if_fail (obj != NULL);
-
- for (i = 0; i < listener->n_entries; i++) {
- if (listener->entries[i].object == obj) {
- if (listener->entries[i].blocked_by) {
- listener->entries[i].removed = TRUE;
- } else {
- listener->entries[i].object = NULL;
- }
- return;
- }
- }
-}
-
-void
-swfdec_listener_execute (SwfdecListener *listener, const char *event_name)
-{
- guint i;
-
- g_return_if_fail (listener != NULL);
- g_return_if_fail (event_name != NULL);
-
- for (i = 0; i < listener->n_entries; i++) {
- g_assert (listener->entries[i].blocked_by == NULL); /* ensure this happens only once */
- if (listener->entries[i].object) {
- listener->entries[i].blocked_by = event_name;
- }
- }
- for (i = 0; i < listener->n_entries; i++) {
- if (listener->entries[i].blocked_by) {
- SwfdecAsObject *obj = listener->entries[i].object;
- const char *event = listener->entries[i].blocked_by;
- if (listener->entries[i].removed) {
- listener->entries[i].object = NULL;
- listener->entries[i].removed = FALSE;
- }
- listener->entries[i].blocked_by = NULL;
- swfdec_as_object_call (obj, event, 0, NULL, NULL);
- }
- }
-}
-
-void
-swfdec_listener_mark (SwfdecListener *listener)
-{
- guint i;
-
- g_return_if_fail (listener != NULL);
-
- for (i = 0; i < listener->n_entries; i++) {
- if (listener->entries[i].object) {
- swfdec_as_object_mark (listener->entries[i].object);
- if (listener->entries[i].blocked_by)
- swfdec_as_string_mark (listener->entries[i].blocked_by);
- }
- }
-}
-
diff --git a/libswfdec/swfdec_listener.h b/libswfdec/swfdec_listener.h
deleted file mode 100644
index f0a0791..0000000
--- a/libswfdec/swfdec_listener.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* 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
- */
-
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_types.h>
-
-#ifndef _SWFDEC_LISTENER_H_
-#define _SWFDEC_LISTENER_H_
-
-G_BEGIN_DECLS
-
-
-SwfdecListener * swfdec_listener_new (SwfdecAsContext * context);
-void swfdec_listener_free (SwfdecListener * listener);
-gboolean swfdec_listener_add (SwfdecListener * listener,
- SwfdecAsObject * obj);
-void swfdec_listener_remove (SwfdecListener * listener,
- SwfdecAsObject * obj);
-void swfdec_listener_execute (SwfdecListener * listener,
- const char * event);
-void swfdec_listener_mark (SwfdecListener * listener);
-
-
-G_END_DECLS
-
-#endif
diff-tree 6e69820af1b177a54c692046e083bcbf0f1ae242 (from 43f02d66cd36015fb6b6b0a23cf248062e4ceadd)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 26 15:25:15 2007 +0200
rewrite Mouse object using scripts
diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index ba43ff1..f64e15f 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -237,6 +237,7 @@ const char swfdec_as_strings[] =
SWFDEC_AS_CONSTANT_STRING ("addProperty")
SWFDEC_AS_CONSTANT_STRING ("ASnative")
SWFDEC_AS_CONSTANT_STRING ("_listeners")
+ SWFDEC_AS_CONSTANT_STRING ("broadcastMessage")
/* add more here */
;
diff --git a/libswfdec/swfdec_initialize.as b/libswfdec/swfdec_initialize.as
index 1ceeedd..0741314 100644
--- a/libswfdec/swfdec_initialize.as
+++ b/libswfdec/swfdec_initialize.as
@@ -17,7 +17,7 @@
* Boston, MA 02110-1301 USA
*/
-/* initialize the AsBroadcaster object */
+/*** ASBROADCASTER ***/
function AsBroadcaster () { };
@@ -51,3 +51,8 @@ AsBroadcaster.initialize = function (o)
};
ASSetPropFlags(o, null, 131);
+/*** MOUSE ***/
+Mouse = new Object ();
+Mouse.show = ASnative (5, 0);
+Mouse.hide = ASnative (5, 1);
+AsBroadcaster.initialize (Mouse);
diff --git a/libswfdec/swfdec_initialize.h b/libswfdec/swfdec_initialize.h
index 3257770..6cc7420 100644
--- a/libswfdec/swfdec_initialize.h
+++ b/libswfdec/swfdec_initialize.h
@@ -2,7 +2,7 @@
/* compiled from swfdec_initialize.as */
const unsigned char swfdec_initialize[] = {
- 0x88, 0xC7, 0x00, 0x12, 0x00, 0x41, 0x73, 0x42, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+ 0x88, 0xDE, 0x00, 0x16, 0x00, 0x41, 0x73, 0x42, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
0x65, 0x72, 0x00, 0x62, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x4D, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x00, 0x41, 0x53, 0x6E, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00, 0x61, 0x64, 0x64,
0x4C, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72, 0x00, 0x74, 0x68, 0x69, 0x73, 0x00, 0x78, 0x00,
@@ -14,35 +14,43 @@ const unsigned char swfdec_initialize[]
0x73, 0x61, 0x67, 0x65, 0x2C, 0x61, 0x64, 0x64, 0x4C, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72,
0x2C, 0x72, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x4C, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72, 0x2C,
0x5F, 0x6C, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72, 0x73, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74,
- 0x50, 0x72, 0x6F, 0x70, 0x46, 0x6C, 0x61, 0x67, 0x73, 0x00, 0x9B, 0x12, 0x00, 0x41, 0x73, 0x42,
- 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96,
- 0x02, 0x00, 0x08, 0x00, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x01, 0x07, 0x0C, 0x00, 0x00, 0x00, 0x07,
- 0x65, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x00, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x03, 0x9B, 0x07, 0x00, 0x00, 0x01, 0x00, 0x78, 0x00,
- 0x3C, 0x00, 0x96, 0x02, 0x00, 0x08, 0x05, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x52, 0x17, 0x96, 0x02, 0x00, 0x08, 0x05, 0x1C,
- 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x07,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x08, 0x52, 0x17, 0x96, 0x02, 0x00, 0x05, 0x01, 0x3E, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x00, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x9B, 0x07, 0x00, 0x00, 0x01, 0x00,
- 0x78, 0x00, 0x8F, 0x00, 0x96, 0x04, 0x00, 0x08, 0x09, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x07, 0x4E, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x41, 0x96, 0x07, 0x00, 0x08, 0x0A, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x4C, 0x1C,
- 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x09, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x0B, 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x42, 0x00, 0x96, 0x02, 0x00, 0x08, 0x09,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x05, 0x1C, 0x49, 0x12,
- 0x9D, 0x02, 0x00, 0x23, 0x00, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C,
- 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x09, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0C,
- 0x52, 0x17, 0x96, 0x02, 0x00, 0x05, 0x01, 0x3E, 0x99, 0x02, 0x00, 0x9C, 0xFF, 0x96, 0x02, 0x00,
- 0x05, 0x00, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x00, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x9B,
- 0x07, 0x00, 0x00, 0x01, 0x00, 0x6F, 0x00, 0x75, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96,
- 0x13, 0x00, 0x08, 0x01, 0x07, 0x0C, 0x00, 0x00, 0x00, 0x07, 0x65, 0x00, 0x00, 0x00, 0x07, 0x02,
- 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96, 0x04, 0x00,
- 0x08, 0x03, 0x08, 0x00, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x03, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x0E, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x06, 0x08, 0x00, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96, 0x09, 0x00, 0x08, 0x07, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x08, 0x0F, 0x40, 0x4F, 0x96, 0x09, 0x00, 0x07, 0x83, 0x00, 0x00, 0x00, 0x08, 0x10, 0x08,
- 0x0E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x11, 0x3D, 0x17, 0x4F, 0x96,
- 0x08, 0x00, 0x07, 0x83, 0x00, 0x00, 0x00, 0x02, 0x08, 0x0E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03,
- 0x00, 0x00, 0x00, 0x08, 0x11, 0x3D, 0x17, 0x00
+ 0x50, 0x72, 0x6F, 0x70, 0x46, 0x6C, 0x61, 0x67, 0x73, 0x00, 0x4D, 0x6F, 0x75, 0x73, 0x65, 0x00,
+ 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x73, 0x68, 0x6F, 0x77, 0x00, 0x68, 0x69, 0x64, 0x65,
+ 0x00, 0x9B, 0x12, 0x00, 0x41, 0x73, 0x42, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x65,
+ 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0x02, 0x00, 0x08, 0x00, 0x1C, 0x96, 0x13, 0x00, 0x08,
+ 0x01, 0x07, 0x0C, 0x00, 0x00, 0x00, 0x07, 0x65, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00,
+ 0x08, 0x02, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x00, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x03, 0x9B,
+ 0x07, 0x00, 0x00, 0x01, 0x00, 0x78, 0x00, 0x3C, 0x00, 0x96, 0x02, 0x00, 0x08, 0x05, 0x1C, 0x96,
+ 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x52,
+ 0x17, 0x96, 0x02, 0x00, 0x08, 0x05, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
+ 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x07, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x08, 0x52, 0x17, 0x96,
+ 0x02, 0x00, 0x05, 0x01, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x00, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x06, 0x9B, 0x07, 0x00, 0x00, 0x01, 0x00, 0x78, 0x00, 0x8F, 0x00, 0x96, 0x04, 0x00, 0x08, 0x09,
+ 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x07, 0x4E, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x41,
+ 0x96, 0x07, 0x00, 0x08, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02, 0x00, 0x09, 0x00,
+ 0x96, 0x02, 0x00, 0x08, 0x0A, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x09, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0B, 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00,
+ 0x42, 0x00, 0x96, 0x02, 0x00, 0x08, 0x09, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4E, 0x96,
+ 0x02, 0x00, 0x08, 0x05, 0x1C, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x23, 0x00, 0x96, 0x07, 0x00, 0x07,
+ 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08,
+ 0x09, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0C, 0x52, 0x17, 0x96, 0x02, 0x00, 0x05, 0x01, 0x3E, 0x99,
+ 0x02, 0x00, 0x9C, 0xFF, 0x96, 0x02, 0x00, 0x05, 0x00, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x00,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x9B, 0x07, 0x00, 0x00, 0x01, 0x00, 0x6F, 0x00, 0x75, 0x00,
+ 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x01, 0x07, 0x0C, 0x00, 0x00, 0x00,
+ 0x07, 0x65, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x4F, 0x96, 0x02,
+ 0x00, 0x08, 0x0E, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x03, 0x08, 0x00, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x03, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x06, 0x08, 0x00,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96, 0x09,
+ 0x00, 0x08, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0F, 0x40, 0x4F, 0x96, 0x09, 0x00, 0x07,
+ 0x83, 0x00, 0x00, 0x00, 0x08, 0x10, 0x08, 0x0E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00,
+ 0x00, 0x08, 0x11, 0x3D, 0x17, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x83, 0x00, 0x00, 0x00, 0x02, 0x08,
+ 0x0E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x11, 0x3D, 0x17, 0x96, 0x09,
+ 0x00, 0x08, 0x12, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x13, 0x40, 0x1D, 0x96, 0x02, 0x00, 0x08,
+ 0x12, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x14, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x05, 0x00, 0x00,
+ 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x12, 0x1C,
+ 0x96, 0x13, 0x00, 0x08, 0x15, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07, 0x05, 0x00, 0x00, 0x00, 0x07,
+ 0x02, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x12, 0x1C, 0x96, 0x07,
+ 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x52, 0x17,
+ 0x00
};
diff --git a/libswfdec/swfdec_internal.h b/libswfdec/swfdec_internal.h
index c830eb7..563bd35 100644
--- a/libswfdec/swfdec_internal.h
+++ b/libswfdec/swfdec_internal.h
@@ -64,8 +64,6 @@ SwfdecVideoDecoder * swfdec_video_decode
void swfdec_player_init_global (SwfdecPlayer * player,
guint version);
-void swfdec_mouse_init_context (SwfdecPlayer * player,
- guint version);
void swfdec_movie_color_init_context (SwfdecPlayer * player,
guint version);
void swfdec_net_connection_init_context (SwfdecPlayer * player,
diff --git a/libswfdec/swfdec_mouse_as.c b/libswfdec/swfdec_mouse_as.c
index e640246..1459f0e 100644
--- a/libswfdec/swfdec_mouse_as.c
+++ b/libswfdec/swfdec_mouse_as.c
@@ -24,32 +24,8 @@
#include "swfdec_as_object.h"
#include "swfdec_as_strings.h"
#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-#include "swfdec_listener.h"
#include "swfdec_player_internal.h"
-static void
-swfdec_mouse_addListener (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *return_value)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
-
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
- return;
- swfdec_listener_add (player->mouse_listener, SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]));
-}
-
-static void
-swfdec_mouse_removeListener (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *return_value)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
-
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
- return;
- swfdec_listener_remove (player->mouse_listener, SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]));
-}
-
SWFDEC_AS_NATIVE (5, 0, swfdec_mouse_show)
void
swfdec_mouse_show (SwfdecAsContext *cx, SwfdecAsObject *object,
@@ -72,23 +48,3 @@ swfdec_mouse_hide (SwfdecAsContext *cx,
player->mouse_visible = FALSE;
}
-void
-swfdec_mouse_init_context (SwfdecPlayer *player, guint version)
-{
- SwfdecAsValue val;
- SwfdecAsObject *mouse;
-
- mouse = swfdec_as_object_new (SWFDEC_AS_CONTEXT (player));
- if (!mouse)
- return;
- SWFDEC_AS_VALUE_SET_OBJECT (&val, mouse);
- swfdec_as_object_set_variable (SWFDEC_AS_CONTEXT (player)->global, SWFDEC_AS_STR_Mouse, &val);
-
- if (version > 5) {
- swfdec_as_object_add_function (mouse, SWFDEC_AS_STR_addListener, 0, swfdec_mouse_addListener, 1);
- swfdec_as_object_add_function (mouse, SWFDEC_AS_STR_removeListener, 0, swfdec_mouse_removeListener, 1);
- }
- swfdec_as_object_add_function (mouse, SWFDEC_AS_STR_hide, 0, swfdec_mouse_hide, 0);
- swfdec_as_object_add_function (mouse, SWFDEC_AS_STR_show, 0, swfdec_mouse_show, 0);
-}
-
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index eab39f1..72313a4 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -37,7 +37,6 @@
#include "swfdec_event.h"
#include "swfdec_initialize.h"
#include "swfdec_internal.h"
-#include "swfdec_listener.h"
#include "swfdec_loader_internal.h"
#include "swfdec_marshal.h"
#include "swfdec_movie.h"
@@ -552,8 +551,6 @@ swfdec_player_dispose (GObject *object)
while (player->roots)
swfdec_movie_destroy (player->roots->data);
- swfdec_listener_free (player->mouse_listener);
- swfdec_listener_free (player->key_listener);
swfdec_player_remove_all_actions (player, player); /* HACK to allow non-removable actions */
/* we do this here so references to GC'd objects get freed */
@@ -736,6 +733,21 @@ swfdec_player_update_mouse_position (Swf
}
static void
+swfdec_player_broadcast (SwfdecPlayer *player, const char *object_name, const char *signal)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *obj;
+
+ obj = SWFDEC_AS_CONTEXT (player)->global;
+ swfdec_as_object_get_variable (obj, object_name, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+ obj = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ SWFDEC_AS_VALUE_SET_STRING (&val, signal);
+ swfdec_as_object_call (obj, SWFDEC_AS_STR_broadcastMessage, 1, &val, NULL);
+}
+
+static void
swfdec_player_do_mouse_move (SwfdecPlayer *player)
{
GList *walk;
@@ -744,7 +756,7 @@ swfdec_player_do_mouse_move (SwfdecPlaye
for (walk = player->movies; walk; walk = walk->next) {
swfdec_movie_queue_script (walk->data, SWFDEC_EVENT_MOUSE_MOVE);
}
- swfdec_listener_execute (player->mouse_listener, SWFDEC_AS_STR_onMouseMove);
+ swfdec_player_broadcast (player, SWFDEC_AS_STR_Mouse, SWFDEC_AS_STR_onMouseMove);
swfdec_player_update_mouse_position (player);
}
@@ -765,7 +777,7 @@ swfdec_player_do_mouse_button (SwfdecPla
for (walk = player->movies; walk; walk = walk->next) {
swfdec_movie_queue_script (walk->data, event);
}
- swfdec_listener_execute (player->mouse_listener, event_name);
+ swfdec_player_broadcast (player, SWFDEC_AS_STR_Mouse, event_name);
if (player->mouse_grab)
swfdec_movie_send_mouse_change (player->mouse_grab, FALSE);
}
@@ -985,8 +997,6 @@ swfdec_player_mark (SwfdecAsContext *con
GList *walk;
g_hash_table_foreach (player->registered_classes, swfdec_player_mark_string_object, NULL);
- swfdec_listener_mark (player->mouse_listener);
- swfdec_listener_mark (player->key_listener);
swfdec_as_object_mark (player->MovieClip);
swfdec_as_object_mark (player->Video);
for (walk = player->roots; walk; walk = walk->next) {
@@ -1167,9 +1177,6 @@ swfdec_player_class_init (SwfdecPlayerCl
static void
swfdec_player_init (SwfdecPlayer *player)
{
- //swfdec_js_init_player (player);
- player->mouse_listener = swfdec_listener_new (SWFDEC_AS_CONTEXT (player));
- player->key_listener = swfdec_listener_new (SWFDEC_AS_CONTEXT (player));
player->registered_classes = g_hash_table_new (g_direct_hash, g_direct_equal);
player->actions = swfdec_ring_buffer_new_for_type (SwfdecPlayerAction, 16);
@@ -1303,7 +1310,6 @@ swfdec_player_initialize (SwfdecPlayer *
if (context->state == SWFDEC_AS_CONTEXT_RUNNING) {
context->state = SWFDEC_AS_CONTEXT_NEW;
swfdec_player_init_global (player, version);
- swfdec_mouse_init_context (player, version);
swfdec_sprite_movie_init_context (player, version);
swfdec_video_movie_init_context (player, version);
swfdec_movie_color_init_context (player, version);
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index daa4d31..9c3ef99 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -75,8 +75,6 @@ struct _SwfdecPlayer
guint interval_id; /* id returned from setInterval call */
GList * intervals; /* all currently running intervals */
GHashTable * registered_classes; /* name => SwfdecAsObject constructor */
- SwfdecListener * mouse_listener; /* emitting mouse events */
- SwfdecListener * key_listener; /* emitting keyboard events */
SwfdecAsObject * MovieClip; /* MovieClip object */
SwfdecAsObject * Video; /* Video object */
diff-tree 43f02d66cd36015fb6b6b0a23cf248062e4ceadd (from ded76454d60429eb9026089816eb9c2945733a01)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 26 15:05:51 2007 +0200
add native function for AsBroadcaster
diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am
index b783460..a6365a4 100644
--- a/libswfdec/Makefile.am
+++ b/libswfdec/Makefile.am
@@ -39,6 +39,7 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES
swfdec_as_types.c \
swfdec_as_with.c \
swfdec_amf.c \
+ swfdec_asbroadcaster.c \
swfdec_audio.c \
swfdec_audio_event.c \
swfdec_audio_flv.c \
diff --git a/libswfdec/swfdec_asbroadcaster.c b/libswfdec/swfdec_asbroadcaster.c
new file mode 100644
index 0000000..7d1d9dc
--- /dev/null
+++ b/libswfdec/swfdec_asbroadcaster.c
@@ -0,0 +1,75 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_array.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+
+/*** AS CODE ***/
+
+SWFDEC_AS_NATIVE (101, 12, broadcastMessage)
+void
+broadcastMessage (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *listeners;
+ gint i, length;
+ const char *name;
+ GSList *list = NULL, *walk;
+
+ if (argc < 1)
+ return;
+ name = swfdec_as_value_to_string (cx, &argv[0]);
+ argv += 1;
+ argc--;
+
+ swfdec_as_object_get_variable (object, SWFDEC_AS_STR__listeners, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val) ||
+ !SWFDEC_IS_AS_ARRAY (listeners = SWFDEC_AS_VALUE_GET_OBJECT (&val)))
+ return;
+
+ swfdec_as_object_get_variable (listeners, SWFDEC_AS_STR_length, &val);
+ length = swfdec_as_value_to_integer (cx, &val);
+
+ /* return undefined if we won't try to call anything */
+ if (length <= 0)
+ return;
+
+ /* FIXME: solve this wth foreach, so it gets faster for weird cases */
+ for (i = 0; i < length; i++) {
+ swfdec_as_object_get_variable (listeners, swfdec_as_double_to_string (cx, i), &val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ list = g_slist_prepend (list, SWFDEC_AS_VALUE_GET_OBJECT (&val));
+ }
+ list = g_slist_reverse (list);
+ for (walk = list; walk; walk = walk->next) {
+ swfdec_as_object_call (walk->data, name, argc, argv, &val);
+ }
+ g_slist_free (list);
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
+}
+
diff-tree ded76454d60429eb9026089816eb9c2945733a01 (from 9df5084bd4208540592635cd747f9ed6eb808dc4)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 26 15:04:45 2007 +0200
implement ASnative
diff --git a/libswfdec/.gitignore b/libswfdec/.gitignore
index a203c5e..950f4f0 100644
--- a/libswfdec/.gitignore
+++ b/libswfdec/.gitignore
@@ -12,7 +12,9 @@ Makefile.in
*.loT
swfdec_as_strings.h
+swfdec_asnative.h
swfdec_enums.[ch]
swfdec_marshal.[ch]
+compiler
compute-strings
diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am
index 991c609..b783460 100644
--- a/libswfdec/Makefile.am
+++ b/libswfdec/Makefile.am
@@ -150,6 +150,7 @@ noinst_HEADERS = \
swfdec_as_strings.h \
swfdec_as_super.h \
swfdec_as_with.h \
+ swfdec_asnative.h \
swfdec_amf.h \
swfdec_audio_internal.h \
swfdec_audio_event.h \
@@ -214,6 +215,7 @@ EXTRA_DIST = \
swfdec_marshal.list
BUILT_SOURCES = \
+ swfdec_asnative.h \
swfdec_as_strings.h \
swfdec_enums.c \
swfdec_enums.h \
@@ -223,6 +225,18 @@ BUILT_SOURCES = \
CLEANFILES = \
$(BUILT_SOURCES)
+swfdec_asnative.h: $(libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES)
+ (echo "#include \"swfdec_player.h\"" \
+ && grep -he "^SWFDEC_AS_NATIVE" $(libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES) \
+ && echo "#undef SWFDEC_AS_NATIVE" \
+ && echo "#define SWFDEC_AS_NATIVE(x,y,func) { x, y, func, G_STRINGIFY (func) }," \
+ && echo "static const struct { guint x, y; SwfdecAsNative func; const char *name; } native_funcs[] = {" \
+ && grep -he "^SWFDEC_AS_NATIVE" $(libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES) \
+ && echo " { 0, 0, NULL }" \
+ && echo "};") >> xgen-san \
+ && (cmp -s xgen-san swfdec_asnative.h || cp xgen-san swfdec_asnative.h) \
+ && rm -f xgen-san
+
swfdec_marshal.h: swfdec_marshal.list Makefile
$(GLIB_GENMARSHAL) --prefix=swfdec_marshal $(srcdir)/swfdec_marshal.list --header >> xgen-smh \
&& (cmp -s xgen-smh swfdec_marshal.h || cp xgen-smh swfdec_marshal.h) \
diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index 5ec2d1f..ba43ff1 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -235,6 +235,8 @@ const char swfdec_as_strings[] =
SWFDEC_AS_CONSTANT_STRING ("call")
SWFDEC_AS_CONSTANT_STRING ("Boolean")
SWFDEC_AS_CONSTANT_STRING ("addProperty")
+ SWFDEC_AS_CONSTANT_STRING ("ASnative")
+ SWFDEC_AS_CONSTANT_STRING ("_listeners")
/* add more here */
;
diff --git a/libswfdec/swfdec_mouse_as.c b/libswfdec/swfdec_mouse_as.c
index 44deecc..e640246 100644
--- a/libswfdec/swfdec_mouse_as.c
+++ b/libswfdec/swfdec_mouse_as.c
@@ -50,7 +50,8 @@ swfdec_mouse_removeListener (SwfdecAsCon
swfdec_listener_remove (player->mouse_listener, SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]));
}
-static void
+SWFDEC_AS_NATIVE (5, 0, swfdec_mouse_show)
+void
swfdec_mouse_show (SwfdecAsContext *cx, SwfdecAsObject *object,
guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
@@ -60,7 +61,8 @@ swfdec_mouse_show (SwfdecAsContext *cx,
player->mouse_visible = TRUE;
}
-static void
+SWFDEC_AS_NATIVE (5, 1, swfdec_mouse_hide)
+void
swfdec_mouse_hide (SwfdecAsContext *cx, SwfdecAsObject *object,
guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
diff --git a/libswfdec/swfdec_player_as.c b/libswfdec/swfdec_player_as.c
index 80d6e60..3da2083 100644
--- a/libswfdec/swfdec_player_as.c
+++ b/libswfdec/swfdec_player_as.c
@@ -23,8 +23,10 @@
#include "swfdec_player_internal.h"
#include "swfdec_as_function.h"
+#include "swfdec_as_native_function.h"
#include "swfdec_as_object.h"
#include "swfdec_as_strings.h"
+#include "swfdec_asnative.h"
#include "swfdec_debug.h"
#include "swfdec_internal.h"
#include "swfdec_interval.h"
@@ -88,6 +90,27 @@ swfdec_player_clearInterval (SwfdecAsCon
swfdec_interval_remove (player, id);
}
+static void
+swfdec_player_ASnative (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ guint i, x, y;
+
+ x = swfdec_as_value_to_integer (cx, &argv[0]);
+ y = swfdec_as_value_to_integer (cx, &argv[1]);
+
+ for (i = 0; native_funcs[i].func != NULL; i++) {
+ if (native_funcs[i].x == x && native_funcs[i].y == y) {
+ SwfdecAsFunction *func = swfdec_as_native_function_new (cx, native_funcs[i].name,
+ native_funcs[i].func, 0);
+ if (func)
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (func));
+ return;
+ }
+ }
+ SWFDEC_FIXME ("ASnative for %u %u missing", x, y);
+}
+
/*** VARIOUS ***/
static void
@@ -118,5 +141,7 @@ swfdec_player_init_global (SwfdecPlayer
0, swfdec_player_setInterval, 2);
swfdec_as_object_add_function (context->global, SWFDEC_AS_STR_clearInterval,
0, swfdec_player_clearInterval, 1);
+ swfdec_as_object_add_function (context->global, SWFDEC_AS_STR_ASnative,
+ 0, swfdec_player_ASnative, 2);
}
diff-tree 9df5084bd4208540592635cd747f9ed6eb808dc4 (from f02c7e0cd52babfa17441e4014528b9696e0e3e5)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 26 14:56:05 2007 +0200
add scripted setup code
included is a tool that compiles the AS code (from swfdec_initialize.as)
into bytecode that can be included directly (swfdec_initialize.h)
diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am
index 313afbf..991c609 100644
--- a/libswfdec/Makefile.am
+++ b/libswfdec/Makefile.am
@@ -176,6 +176,7 @@ noinst_HEADERS = \
swfdec_graphic.h \
swfdec_graphic_movie.h \
swfdec_image.h \
+ swfdec_initialize.h \
swfdec_internal.h \
swfdec_interval.h \
swfdec_listener.h \
@@ -207,7 +208,10 @@ noinst_HEADERS = \
swfdec_video_movie.h \
swfdec_xml.h
-EXTRA_DIST = swfdec_marshal.list
+EXTRA_DIST = \
+ compiler.c \
+ swfdec_initialize.as \
+ swfdec_marshal.list
BUILT_SOURCES = \
swfdec_as_strings.h \
diff --git a/libswfdec/compiler.c b/libswfdec/compiler.c
new file mode 100644
index 0000000..c702b8b
--- /dev/null
+++ b/libswfdec/compiler.c
@@ -0,0 +1,140 @@
+//gcc -Wall -Werror `pkg-config --libs --cflags libming glib-2.0` compiler.c -o copiler
+
+#include <glib.h>
+#include <ming.h>
+#include <string.h>
+
+/* This is what is used to compile the Actionscript parts of the source to
+ * includable C data that can later be executed.
+ * Note that this is pretty much a hack until someone writes a proper
+ * Actionscript compiler for Swfdec.
+ * Also note that the creation of the include-scripts should probably not be
+ * autorun, as we don't want to depend on external bugs, only on internal ones.
+ */
+static gboolean
+write_data (guint8 *data, gsize len)
+{
+ gsize i;
+
+ /* debug */
+ //g_file_set_contents ("foo", (char *) data, len, NULL);
+
+ /* skip SWF crap */
+ data += 25;
+
+ /* sanity checks */
+ /* 1) ensure file is long enough */
+ if (len < 31)
+ return FALSE;
+ i = data[0] + (data[1] << 8);
+ data += 2;
+ /* 2) ensure we have a DoAction tag */
+ if (((i >> 6) & 0x3ff) != 12)
+ return FALSE;
+ i = i & 0x3F;
+ if (i == 0x3F) {
+ i = data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24);
+ data += 4;
+ len -= 31;
+ } else {
+ len -= 27;
+ }
+ /* 3) check size of tag is correct */
+ if (i >= len + 2)
+ return FALSE;
+ /* 4) check a ShowFrame comes next */
+ if (data[i] != 0x40 || data[i + 1] != 0x00)
+ return FALSE;
+ /* trust the data */
+ len = i;
+ for (i = 0; i < len; i++) {
+ switch (i % 16) {
+ case 0:
+ if (i == 0)
+ g_print (" 0x%02X", data[i]);
+ else
+ g_print (",\n 0x%02X", data[i]);
+ break;
+ case 4:
+ case 8:
+ case 12:
+ g_print (", 0x%02X", data[i]);
+ break;
+ default:
+ g_print (", 0x%02X", data[i]);
+ break;
+ }
+ }
+ g_print ("\n");
+ return TRUE;
+}
+
+static void
+output_array (guint8 b, void *data)
+{
+ GByteArray *array = data;
+
+ g_byte_array_append (array, &b, 1);
+}
+
+static char *
+get_name (const char *filename)
+{
+ char *end;
+
+ end = strrchr (filename, '/');
+ if (end)
+ filename = end + 1;
+ end = strchr (filename, '.');
+ if (end)
+ return g_strndup (filename, end - filename);
+ else
+ return g_strdup (filename);
+}
+
+int
+main (int argc, char **argv)
+{
+ SWFMovie movie;
+ SWFAction action;
+ GByteArray *array;
+ char *contents;
+ GError *error = NULL;
+ guint i;
+
+ if (argc < 2) {
+ g_print ("usage: %s FILE ...\n\n", argv[0]);
+ return 1;
+ }
+
+ Ming_init ();
+ Ming_setSWFCompression (-1);
+
+ g_print ("/* This file is autogenerated, do not edit! */\n\n");
+ for (i = 1; i < argc; i++) {
+ if (!g_file_get_contents (argv[1], &contents, NULL, &error)) {
+ g_printerr ("%s\n", error->message);
+ g_error_free (error);
+ error = NULL;
+ return 1;
+ }
+ movie = newSWFMovie ();
+ action = newSWFAction (contents);
+ SWFMovie_add (movie, (SWFBlock) action);
+ g_free (contents);
+
+ array = g_byte_array_new ();
+ SWFMovie_output (movie, output_array, array);
+ contents = get_name (argv[i]);
+ g_print ("/* compiled from %s */\n", argv[i]);
+ g_print ("const unsigned char %s[] = {\n", contents);
+ g_free (contents);
+ if (!write_data (array->data, array->len)) {
+ g_printerr ("failed extracting compiled data for %s\n", argv[i]);
+ return 1;
+ }
+ g_print ("};\n\n");
+ g_byte_array_free (array, TRUE);
+ }
+ return 0;
+}
diff --git a/libswfdec/swfdec_initialize.as b/libswfdec/swfdec_initialize.as
new file mode 100644
index 0000000..1ceeedd
--- /dev/null
+++ b/libswfdec/swfdec_initialize.as
@@ -0,0 +1,53 @@
+/* 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
+ */
+
+/* initialize the AsBroadcaster object */
+
+function AsBroadcaster () { };
+
+AsBroadcaster.broadcastMessage = ASnative(101, 12);
+
+AsBroadcaster.addListener = function (x) {
+ this.removeListener (x);
+ this._listeners.push (x);
+ return true;
+};
+
+AsBroadcaster.removeListener = function (x) {
+ var l = this._listeners;
+ var i;
+
+ for (var i = 0; i < l.length; i++) {
+ if (l[i] == x) {
+ l.splice (i, 1);
+ return true;
+ }
+ }
+ return false;
+};
+
+AsBroadcaster.initialize = function (o) {
+ o.broadcastMessage = ASnative(101, 12);
+ o.addListener = AsBroadcaster.addListener;
+ o.removeListener = AsBroadcaster.removeListener;
+ o._listeners = new Array ();
+ ASSetPropFlags(o, "broadcastMessage,addListener,removeListener,_listeners", 131);
+};
+ASSetPropFlags(o, null, 131);
+
diff --git a/libswfdec/swfdec_initialize.h b/libswfdec/swfdec_initialize.h
new file mode 100644
index 0000000..3257770
--- /dev/null
+++ b/libswfdec/swfdec_initialize.h
@@ -0,0 +1,48 @@
+/* This file is autogenerated, do not edit! */
+
+/* compiled from swfdec_initialize.as */
+const unsigned char swfdec_initialize[] = {
+ 0x88, 0xC7, 0x00, 0x12, 0x00, 0x41, 0x73, 0x42, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+ 0x65, 0x72, 0x00, 0x62, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x4D, 0x65, 0x73, 0x73,
+ 0x61, 0x67, 0x65, 0x00, 0x41, 0x53, 0x6E, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00, 0x61, 0x64, 0x64,
+ 0x4C, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72, 0x00, 0x74, 0x68, 0x69, 0x73, 0x00, 0x78, 0x00,
+ 0x72, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x4C, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72, 0x00, 0x5F,
+ 0x6C, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72, 0x73, 0x00, 0x70, 0x75, 0x73, 0x68, 0x00, 0x6C,
+ 0x00, 0x69, 0x00, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x00, 0x73, 0x70, 0x6C, 0x69, 0x63, 0x65,
+ 0x00, 0x69, 0x6E, 0x69, 0x74, 0x69, 0x61, 0x6C, 0x69, 0x7A, 0x65, 0x00, 0x6F, 0x00, 0x41, 0x72,
+ 0x72, 0x61, 0x79, 0x00, 0x62, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x4D, 0x65, 0x73,
+ 0x73, 0x61, 0x67, 0x65, 0x2C, 0x61, 0x64, 0x64, 0x4C, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72,
+ 0x2C, 0x72, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x4C, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72, 0x2C,
+ 0x5F, 0x6C, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72, 0x73, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74,
+ 0x50, 0x72, 0x6F, 0x70, 0x46, 0x6C, 0x61, 0x67, 0x73, 0x00, 0x9B, 0x12, 0x00, 0x41, 0x73, 0x42,
+ 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96,
+ 0x02, 0x00, 0x08, 0x00, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x01, 0x07, 0x0C, 0x00, 0x00, 0x00, 0x07,
+ 0x65, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x00, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x03, 0x9B, 0x07, 0x00, 0x00, 0x01, 0x00, 0x78, 0x00,
+ 0x3C, 0x00, 0x96, 0x02, 0x00, 0x08, 0x05, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00,
+ 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x52, 0x17, 0x96, 0x02, 0x00, 0x08, 0x05, 0x1C,
+ 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x07,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x08, 0x52, 0x17, 0x96, 0x02, 0x00, 0x05, 0x01, 0x3E, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x00, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x9B, 0x07, 0x00, 0x00, 0x01, 0x00,
+ 0x78, 0x00, 0x8F, 0x00, 0x96, 0x04, 0x00, 0x08, 0x09, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x07, 0x4E, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x41, 0x96, 0x07, 0x00, 0x08, 0x0A, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x4C, 0x1C,
+ 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x09, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x0B, 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x42, 0x00, 0x96, 0x02, 0x00, 0x08, 0x09,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x05, 0x1C, 0x49, 0x12,
+ 0x9D, 0x02, 0x00, 0x23, 0x00, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C,
+ 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x09, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0C,
+ 0x52, 0x17, 0x96, 0x02, 0x00, 0x05, 0x01, 0x3E, 0x99, 0x02, 0x00, 0x9C, 0xFF, 0x96, 0x02, 0x00,
+ 0x05, 0x00, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x00, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x9B,
+ 0x07, 0x00, 0x00, 0x01, 0x00, 0x6F, 0x00, 0x75, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96,
+ 0x13, 0x00, 0x08, 0x01, 0x07, 0x0C, 0x00, 0x00, 0x00, 0x07, 0x65, 0x00, 0x00, 0x00, 0x07, 0x02,
+ 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96, 0x04, 0x00,
+ 0x08, 0x03, 0x08, 0x00, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x03, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x0E, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x06, 0x08, 0x00, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96, 0x09, 0x00, 0x08, 0x07, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x0F, 0x40, 0x4F, 0x96, 0x09, 0x00, 0x07, 0x83, 0x00, 0x00, 0x00, 0x08, 0x10, 0x08,
+ 0x0E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x11, 0x3D, 0x17, 0x4F, 0x96,
+ 0x08, 0x00, 0x07, 0x83, 0x00, 0x00, 0x00, 0x02, 0x08, 0x0E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03,
+ 0x00, 0x00, 0x00, 0x08, 0x11, 0x3D, 0x17, 0x00
+};
+
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index bf74ccd..eab39f1 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -27,6 +27,7 @@
#include <liboil/liboil.h>
#include "swfdec_player_internal.h"
+#include "swfdec_as_internal.h"
#include "swfdec_as_strings.h"
#include "swfdec_audio_internal.h"
#include "swfdec_button_movie.h" /* for mouse cursor */
@@ -34,11 +35,13 @@
#include "swfdec_debug.h"
#include "swfdec_enums.h"
#include "swfdec_event.h"
+#include "swfdec_initialize.h"
#include "swfdec_internal.h"
#include "swfdec_listener.h"
#include "swfdec_loader_internal.h"
#include "swfdec_marshal.h"
#include "swfdec_movie.h"
+#include "swfdec_script.h"
#include "swfdec_sprite_movie.h"
#include "swfdec_swf_instance.h"
@@ -1311,6 +1314,15 @@ swfdec_player_initialize (SwfdecPlayer *
context->state = SWFDEC_AS_CONTEXT_RUNNING;
swfdec_as_object_set_constructor (player->roots->data, player->MovieClip, FALSE);
}
+ if (version > 4) {
+ SwfdecBits bits;
+ SwfdecScript *script;
+ swfdec_bits_init_data (&bits, swfdec_initialize, sizeof (swfdec_initialize));
+ script = swfdec_script_new (&bits, "init", version);
+ g_assert (script);
+ swfdec_as_object_run (context->global, script);
+ swfdec_script_unref (script);
+ }
}
SWFDEC_INFO ("initializing player to size %ux%u", width, height);
player->rate = rate;
diff-tree f02c7e0cd52babfa17441e4014528b9696e0e3e5 (from 0f4bc42aec9d9db13fc6a4567a0ad62121b83129)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 26 14:48:13 2007 +0200
simplify code
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index cb45d3e..bf74ccd 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -1167,8 +1167,7 @@ swfdec_player_init (SwfdecPlayer *player
//swfdec_js_init_player (player);
player->mouse_listener = swfdec_listener_new (SWFDEC_AS_CONTEXT (player));
player->key_listener = swfdec_listener_new (SWFDEC_AS_CONTEXT (player));
- player->registered_classes = g_hash_table_new_full (g_direct_hash, g_direct_equal,
- NULL, NULL);
+ player->registered_classes = g_hash_table_new (g_direct_hash, g_direct_equal);
player->actions = swfdec_ring_buffer_new_for_type (SwfdecPlayerAction, 16);
player->cache = swfdec_cache_new (50 * 1024 * 1024); /* 100 MB */
diff-tree 0f4bc42aec9d9db13fc6a4567a0ad62121b83129 (from 51555cdec92aa2859005071a04543e1032ee3333)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 26 14:46:52 2007 +0200
allow declaring a function as part of ASnative
These functions must take 0 minimum args (so do the args check themselves),
and they must not be static.
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index 3010bf0..daa4d31 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -27,6 +27,9 @@
G_BEGIN_DECLS
+#define SWFDEC_AS_NATIVE(x, y, func) void func (SwfdecAsContext *cx, \
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret);
+
typedef enum {
SWFDEC_ALIGN_FLAG_TOP = (1 << 0),
SWFDEC_ALIGN_FLAG_BOTTOM = (1 << 1),
diff-tree 51555cdec92aa2859005071a04543e1032ee3333 (from 865fbab009d84a3c36216d9a56ba5ffa399c96b2)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 26 14:44:48 2007 +0200
warn if data is left after a Flash file
diff --git a/libswfdec/swfdec_swf_decoder.c b/libswfdec/swfdec_swf_decoder.c
index 1bd5ff5..1521e6f 100644
--- a/libswfdec/swfdec_swf_decoder.c
+++ b/libswfdec/swfdec_swf_decoder.c
@@ -365,6 +365,10 @@ swfdec_swf_decoder_parse (SwfdecDecoder
}
break;
case SWFDEC_STATE_EOF:
+ if (swfdec_buffer_queue_get_depth (s->input_queue) > 0) {
+ SWFDEC_WARNING ("%u bytes after EOF", swfdec_buffer_queue_get_depth (s->input_queue));
+ swfdec_buffer_queue_clear (s->input_queue);
+ }
return SWFDEC_STATUS_EOF;
}
diff-tree 865fbab009d84a3c36216d9a56ba5ffa399c96b2 (from bc30a8fb8c5ebfb708102e0eb9e7a0382f428c73)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jul 26 14:44:10 2007 +0200
issue a warning when aborting
Turns out that calling swfdec_as_object_run() before swfdec_as_context_sartup()
doesn't do anything, and I had no clue why
diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c
index 5abad28..ad606ad 100644
--- a/libswfdec/swfdec_as_context.c
+++ b/libswfdec/swfdec_as_context.c
@@ -778,8 +778,10 @@ start:
if (spec->add > 0)
swfdec_as_stack_ensure_free (context, spec->add);
}
- if (context->state != SWFDEC_AS_CONTEXT_RUNNING)
+ if (context->state != SWFDEC_AS_CONTEXT_RUNNING) {
+ SWFDEC_WARNING ("context not running anymore, aborting");
goto error;
+ }
#ifndef G_DISABLE_ASSERT
check = (spec->add >= 0 && spec->remove >= 0) ? context->cur + spec->add - spec->remove : NULL;
#endif
diff-tree bc30a8fb8c5ebfb708102e0eb9e7a0382f428c73 (from parents)
Merge: 0556e6c44af1b25585ab3a18f33470bfb5a469fd f1909bbdbc7a34c8f72909f7c29e24a0c1a78d33
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jul 25 22:55:23 2007 +0200
Merge branch 'master' of ssh://company@git.freedesktop.org/git/swfdec/swfdec
diff-tree 0556e6c44af1b25585ab3a18f33470bfb5a469fd (from 409a626fee709e115f03c86f7119a93da4171bce)
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Jul 22 17:12:15 2007 +0100
remove ifdeffed code
diff --git a/libswfdec/swfdec_player_as.c b/libswfdec/swfdec_player_as.c
index 95ee8ac..80d6e60 100644
--- a/libswfdec/swfdec_player_as.c
+++ b/libswfdec/swfdec_player_as.c
@@ -90,71 +90,6 @@ swfdec_player_clearInterval (SwfdecAsCon
/*** VARIOUS ***/
-#if 0
-void
-swfdec_js_global_eval (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- if (JSVAL_IS_STRING (argv[0])) {
- const char *bytes = swfdec_js_to_string (cx, argv[0]);
- if (bytes == NULL)
- return JS_FALSE;
- *rval = swfdec_js_eval (cx, obj, bytes);
- } else {
- *rval = argv[0];
- }
- return JS_TRUE;
-}
-
-static void
-swfdec_js_trace (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecPlayer *player = JS_GetContextPrivate (cx);
- const char *bytes;
-
- bytes = swfdec_js_to_string (cx, argv[0]);
- if (bytes == NULL)
- return JS_TRUE;
-
- swfdec_player_trace (player, bytes);
- return JS_TRUE;
-}
-
-static void
-swfdec_js_random (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- gint32 max, result;
-
- if (!JS_ValueToECMAInt32 (cx, argv[0], &max))
- return JS_FALSE;
-
- if (max <= 0)
- result = 0;
- else
- result = g_random_int_range (0, max);
-
- return JS_NewNumberValue(cx, result, rval);
-}
-
-static void
-swfdec_js_stopAllSounds (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecPlayer *player = JS_GetContextPrivate (cx);
-
- swfdec_player_stop_all_sounds (player);
- return JS_TRUE;
-}
-
-static JSFunctionSpec global_methods[] = {
- { "clearInterval", swfdec_js_global_clearInterval, 1, 0, 0 },
- { "eval", swfdec_js_global_eval, 1, 0, 0 },
- { "random", swfdec_js_random, 1, 0, 0 },
- { "setInterval", swfdec_js_global_setInterval, 2, 0, 0 },
- { "stopAllSounds", swfdec_js_stopAllSounds, 0, 0, 0 },
- { "trace", swfdec_js_trace, 1, 0, 0 },
- { NULL, NULL, 0, 0, 0 }
-};
-#endif
-
static void
swfdec_player_object_registerClass (SwfdecAsContext *cx, SwfdecAsObject *object,
guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
diff-tree 409a626fee709e115f03c86f7119a93da4171bce (from c720a64ea9e90947de905b6669cbe83762261ec4)
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Jul 22 16:50:01 2007 +0100
add test vor invalid variable names
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 2828f72..3f3d6f1 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -346,6 +346,15 @@ EXTRA_DIST = \
instance-name-loaded-6.swf.trace \
instance-name-loaded-7.swf \
instance-name-loaded-7.swf.trace \
+ invalid-variable-name.as \
+ invalid-variable-name-5.swf \
+ invalid-variable-name-5.swf.trace \
+ invalid-variable-name-6.swf \
+ invalid-variable-name-6.swf.trace \
+ invalid-variable-name-7.swf \
+ invalid-variable-name-7.swf.trace \
+ invalid-variable-name-8.swf \
+ invalid-variable-name-8.swf.trace \
isnan.as \
isnan-5.swf \
isnan-5.swf.trace \
diff --git a/test/trace/invalid-variable-name-5.swf b/test/trace/invalid-variable-name-5.swf
new file mode 100644
index 0000000..944a2c5
Binary files /dev/null and b/test/trace/invalid-variable-name-5.swf differ
diff --git a/test/trace/invalid-variable-name-5.swf.trace b/test/trace/invalid-variable-name-5.swf.trace
new file mode 100644
index 0000000..2ab9467
--- /dev/null
+++ b/test/trace/invalid-variable-name-5.swf.trace
@@ -0,0 +1,2 @@
+Check invalid variable names don't work
+undefined
diff --git a/test/trace/invalid-variable-name-6.swf b/test/trace/invalid-variable-name-6.swf
new file mode 100644
index 0000000..2b89e58
Binary files /dev/null and b/test/trace/invalid-variable-name-6.swf differ
diff --git a/test/trace/invalid-variable-name-6.swf.trace b/test/trace/invalid-variable-name-6.swf.trace
new file mode 100644
index 0000000..2ab9467
--- /dev/null
+++ b/test/trace/invalid-variable-name-6.swf.trace
@@ -0,0 +1,2 @@
+Check invalid variable names don't work
+undefined
diff --git a/test/trace/invalid-variable-name-7.swf b/test/trace/invalid-variable-name-7.swf
new file mode 100644
index 0000000..a30a1f8
Binary files /dev/null and b/test/trace/invalid-variable-name-7.swf differ
diff --git a/test/trace/invalid-variable-name-7.swf.trace b/test/trace/invalid-variable-name-7.swf.trace
new file mode 100644
index 0000000..2ab9467
--- /dev/null
+++ b/test/trace/invalid-variable-name-7.swf.trace
@@ -0,0 +1,2 @@
+Check invalid variable names don't work
+undefined
diff --git a/test/trace/invalid-variable-name-8.swf b/test/trace/invalid-variable-name-8.swf
new file mode 100644
index 0000000..908b528
Binary files /dev/null and b/test/trace/invalid-variable-name-8.swf differ
diff --git a/test/trace/invalid-variable-name-8.swf.trace b/test/trace/invalid-variable-name-8.swf.trace
new file mode 100644
index 0000000..2ab9467
--- /dev/null
+++ b/test/trace/invalid-variable-name-8.swf.trace
@@ -0,0 +1,2 @@
+Check invalid variable names don't work
+undefined
diff --git a/test/trace/invalid-variable-name.as b/test/trace/invalid-variable-name.as
new file mode 100644
index 0000000..6c97d8a
--- /dev/null
+++ b/test/trace/invalid-variable-name.as
@@ -0,0 +1,8 @@
+// makeswf -v 7 -s 200x150 -r 1 -o invalid-varable-name.swf invalid-varable-name.as
+
+trace ("Check invalid variable names don't work");
+
+this[""] = 42;
+trace (this [""]);
+
+loadMovie ("FSCommand:quit", "");
diff-tree c720a64ea9e90947de905b6669cbe83762261ec4 (from 3f0783f7ae4339b781bd76e1686764301f926cd1)
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Jul 22 16:49:14 2007 +0100
don't allow setting of invalid variables
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index ae37d96..28a6f98 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -188,12 +188,21 @@ swfdec_as_object_lookup_variable (Swfdec
return var;
}
+static gboolean
+swfdec_as_variable_name_is_valid (const char *name)
+{
+ return name != SWFDEC_AS_STR_EMPTY;
+}
+
static void
swfdec_as_object_do_set (SwfdecAsObject *object, const char *variable,
const SwfdecAsValue *val)
{
SwfdecAsVariable *var;
+ if (!swfdec_as_variable_name_is_valid (variable))
+ return;
+
if (variable == SWFDEC_AS_STR___proto__) {
if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
object->prototype = SWFDEC_AS_VALUE_GET_OBJECT (val);
diff-tree 3f0783f7ae4339b781bd76e1686764301f926cd1 (from f81419a85d48078043e43cb42ba354dc1a42bf8b)
Author: Benjamin Otte <otte at gnome.org>
Date: Sat Jul 21 13:29:04 2007 +0100
add swfdec_player_[gs]et_alignment
diff --git a/doc/swfdec-sections.txt b/doc/swfdec-sections.txt
index 29528af..9c9eb75 100644
--- a/doc/swfdec-sections.txt
+++ b/doc/swfdec-sections.txt
@@ -57,6 +57,8 @@ swfdec_player_get_background_color
swfdec_player_set_background_color
swfdec_player_get_scale_mode
swfdec_player_set_scale_mode
+swfdec_player_get_alignment
+swfdec_player_set_alignment
swfdec_player_render
swfdec_player_advance
swfdec_player_handle_mouse
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index f5dafd6..cb45d3e 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -120,7 +120,7 @@
* @SWFDEC_SCALE_SHOW_ALL: Show the whole content as large as possible
* @SWFDEC_SCALE_NO_BORDER: Fill the whole area, possibly cropping parts
* @SWFDEC_SCALE_EXACT_FIT: Fill the whole area, don't keep aspect ratio
- * @SWFDEC_SCALE_NO_SCALE: Do not scale the movie at all
+ * @SWFDEC_SCALE_NONE: Do not scale the movie at all
*
* Describes how the movie should be scaled if the given size doesn't equal the
* movie's size.
@@ -1840,3 +1840,44 @@ swfdec_player_set_scale_mode (SwfdecPlay
}
}
+/**
+ * swfdec_player_get_alignment:
+ * @player: a #SwfdecPlayer
+ *
+ * Gets the alignment of the player. The alignment describes what point is used
+ * as the anchor for drawing the contents. See #SwfdecAlignment for possible
+ * values.
+ *
+ * Returns: the current alignment
+ **/
+SwfdecAlignment
+swfdec_player_get_alignment (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), SWFDEC_ALIGNMENT_CENTER);
+
+ return swfdec_player_alignment_from_flags (player->align_flags);
+}
+
+/**
+ * swfdec_player_set_alignment:
+ * @player: a #SwfdecPlayer
+ * @align: #SwfdecAlignment to set
+ *
+ * Sets the alignment to @align. For details about alignment, see
+ * swfdec_player_get_alignment() and #SwfdecAlignment.
+ **/
+void
+swfdec_player_set_alignment (SwfdecPlayer *player, SwfdecAlignment align)
+{
+ guint flags;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ flags = swfdec_player_alignment_to_flags (align);
+ if (flags != player->align_flags) {
+ player->align_flags = flags;
+ swfdec_player_update_scale (player);
+ g_object_notify (G_OBJECT (player), "alignment");
+ }
+}
+
diff --git a/libswfdec/swfdec_player.h b/libswfdec/swfdec_player.h
index b6b451b..e712583 100644
--- a/libswfdec/swfdec_player.h
+++ b/libswfdec/swfdec_player.h
@@ -95,6 +95,9 @@ void swfdec_player_set_background_color
SwfdecScaleMode swfdec_player_get_scale_mode (SwfdecPlayer * player);
void swfdec_player_set_scale_mode (SwfdecPlayer * player,
SwfdecScaleMode mode);
+SwfdecAlignment swfdec_player_get_alignment (SwfdecPlayer * player);
+void swfdec_player_set_alignment (SwfdecPlayer * player,
+ SwfdecAlignment align);
void swfdec_player_render (SwfdecPlayer * player,
cairo_t * cr,
diff-tree f81419a85d48078043e43cb42ba354dc1a42bf8b (from a3c1cdc6959557e10b6c0b2cfd0fdd87967db00c)
Author: Benjamin Otte <otte at gnome.org>
Date: Sat Jul 21 12:58:26 2007 +0100
add swfdec_player_[gs]et_scale_mode
diff --git a/doc/swfdec-sections.txt b/doc/swfdec-sections.txt
index 5ad6dec..29528af 100644
--- a/doc/swfdec-sections.txt
+++ b/doc/swfdec-sections.txt
@@ -55,6 +55,8 @@ swfdec_player_set_size
swfdec_player_get_next_event
swfdec_player_get_background_color
swfdec_player_set_background_color
+swfdec_player_get_scale_mode
+swfdec_player_set_scale_mode
swfdec_player_render
swfdec_player_advance
swfdec_player_handle_mouse
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index bed9c22..f5dafd6 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -530,8 +530,7 @@ swfdec_player_set_property (GObject *obj
swfdec_player_update_scale (player);
break;
case PROP_SCALE:
- player->scale_mode = g_value_get_enum (value);
- swfdec_player_update_scale (player);
+ swfdec_player_set_scale_mode (player, g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -1803,3 +1802,41 @@ swfdec_player_set_background_color (Swfd
(double) player->width, (double) player->height);
}
}
+
+/**
+ * swfdec_player_get_scale_mode:
+ * @player: a #SwfdecPlayer
+ *
+ * Gets the currrent mode used for scaling the movie. See #SwfdecScaleMode for
+ * the different modes.
+ *
+ * Returns: the current scale mode
+ **/
+SwfdecScaleMode
+swfdec_player_get_scale_mode (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), SWFDEC_SCALE_SHOW_ALL);
+
+ return player->scale_mode;
+}
+
+/**
+ * swfdec_player_set_scale_mode:
+ * @player: a #SwfdecPlayer
+ * @mode: a #SwfdecScaleMode
+ *
+ * Sets the currrent mode used for scaling the movie. See #SwfdecScaleMode for
+ * the different modes.
+ **/
+void
+swfdec_player_set_scale_mode (SwfdecPlayer *player, SwfdecScaleMode mode)
+{
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ if (player->scale_mode != mode) {
+ player->scale_mode = mode;
+ swfdec_player_update_scale (player);
+ g_object_notify (G_OBJECT (player), "scale-mode");
+ }
+}
+
diff --git a/libswfdec/swfdec_player.h b/libswfdec/swfdec_player.h
index 578427e..b6b451b 100644
--- a/libswfdec/swfdec_player.h
+++ b/libswfdec/swfdec_player.h
@@ -92,6 +92,9 @@ guint swfdec_player_get_background_colo
void swfdec_player_set_background_color
(SwfdecPlayer * player,
guint color);
+SwfdecScaleMode swfdec_player_get_scale_mode (SwfdecPlayer * player);
+void swfdec_player_set_scale_mode (SwfdecPlayer * player,
+ SwfdecScaleMode mode);
void swfdec_player_render (SwfdecPlayer * player,
cairo_t * cr,
More information about the Swfdec
mailing list