[Swfdec] Branch 'as' - 3 commits - libswfdec/swfdec_as_array.c libswfdec/swfdec_as_context.c libswfdec/swfdec_as_math.c libswfdec/swfdec_as_native_function.c libswfdec/swfdec_as_number.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_string.c libswfdec/swfdec_as_types.h libswfdec/swfdec_color_as.c libswfdec/swfdec_mouse_as.c libswfdec/swfdec_net_connection.c libswfdec/swfdec_player_as.c libswfdec/swfdec_sprite_movie_as.c
Benjamin Otte
company at kemper.freedesktop.org
Tue Jun 12 12:56:07 PDT 2007
libswfdec/swfdec_as_array.c | 7 +-
libswfdec/swfdec_as_context.c | 36 +++++++-----
libswfdec/swfdec_as_math.c | 43 ++++++++-------
libswfdec/swfdec_as_native_function.c | 15 +++++
libswfdec/swfdec_as_number.c | 27 +++++++--
libswfdec/swfdec_as_object.c | 21 +++++--
libswfdec/swfdec_as_string.c | 95 ++++++++++++++++++----------------
libswfdec/swfdec_as_types.h | 6 +-
libswfdec/swfdec_color_as.c | 19 ++++--
libswfdec/swfdec_mouse_as.c | 20 ++++---
libswfdec/swfdec_net_connection.c | 3 -
libswfdec/swfdec_player_as.c | 30 +++++-----
libswfdec/swfdec_sprite_movie_as.c | 86 ++++++++++++++++++------------
13 files changed, 250 insertions(+), 158 deletions(-)
New commits:
diff-tree e7db3c7145922223dbd67702992e5d47df703fa4 (from ed4f2f63fe303a3c06be46a52c3ed8ea07cbe29a)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Jun 12 21:56:24 2007 +0200
thisp may now be NULL
diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c
index 5d4435a..a63cf4d 100644
--- a/libswfdec/swfdec_as_context.c
+++ b/libswfdec/swfdec_as_context.c
@@ -446,8 +446,7 @@ start:
SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (frame->function);
if (frame->argc >= native->min_args &&
(native->type == 0 ||
- (frame->thisp != NULL &&
- g_type_is_a (G_OBJECT_TYPE (frame->thisp), native->type)))) {
+ g_type_is_a (G_OBJECT_TYPE (frame->thisp), native->type))) {
/* FIXME FIXME FIXME: no casting here please! */
native->native (context, frame->thisp, frame->argc,
(SwfdecAsValue *) frame->argv, frame->return_value);
diff-tree ed4f2f63fe303a3c06be46a52c3ed8ea07cbe29a (from 6096f55dc8f87d0ae8096bcb73dada791637fee5)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Jun 12 21:54:02 2007 +0200
add documentation for SwfdecAsNative
diff --git a/libswfdec/swfdec_as_native_function.c b/libswfdec/swfdec_as_native_function.c
index 5d68ba4..f6a5d64 100644
--- a/libswfdec/swfdec_as_native_function.c
+++ b/libswfdec/swfdec_as_native_function.c
@@ -29,6 +29,17 @@
/*** GTK-DOC ***/
+/**
+ * SwfdecAsNative:
+ * context: #SwfdecAsContext
+ * thisp: the this object. <warning>Can be %NULL.</warning>
+ * argc: number of arguments passed to this function
+ * argv: the @argc arguments passed to this function
+ * retval: set to the return value. Initialized to undefined by default
+ *
+ * This is the prototype for all native functions.
+ */
+
/*** IMPLEMENTATION ***/
G_DEFINE_TYPE (SwfdecAsNativeFunction, swfdec_as_native_function, SWFDEC_TYPE_AS_FUNCTION)
diff-tree 6096f55dc8f87d0ae8096bcb73dada791637fee5 (from 7bd2ff52ba93f0405bd99cb4162649e92ba4c1fd)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Jun 12 15:29:47 2007 +0200
make native functions take the context as first argument
This is necessary, because passing NULL as this is possible, think
parseInt.call (null, "123");
If you need a this object, make sure to define the required type of
the this object in swfdec_as_object_add_function () or via
swfdec_as_native_function_set_object_type ().
diff --git a/libswfdec/swfdec_as_array.c b/libswfdec/swfdec_as_array.c
index e2071b6..b72e43b 100644
--- a/libswfdec/swfdec_as_array.c
+++ b/libswfdec/swfdec_as_array.c
@@ -160,9 +160,9 @@ swfdec_as_array_append (SwfdecAsArray *a
/*** AS CODE ***/
static void
-swfdec_as_array_toString (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_array_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
- SwfdecAsContext *cx = object->context;
int i, length;
const char *s, *str;
SwfdecAsValue val;
@@ -186,7 +186,8 @@ swfdec_as_array_toString (SwfdecAsObject
}
static void
-swfdec_as_array_do_push (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_array_do_push (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SwfdecAsArray *array = SWFDEC_AS_ARRAY (object);
diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c
index 50cff5b..5d4435a 100644
--- a/libswfdec/swfdec_as_context.c
+++ b/libswfdec/swfdec_as_context.c
@@ -448,8 +448,9 @@ start:
(native->type == 0 ||
(frame->thisp != NULL &&
g_type_is_a (G_OBJECT_TYPE (frame->thisp), native->type)))) {
- /* FIXME FIXME FIXME! */
- native->native (frame->thisp, frame->argc, (SwfdecAsValue *) frame->argv, frame->return_value);
+ /* FIXME FIXME FIXME: no casting here please! */
+ native->native (context, frame->thisp, frame->argc,
+ (SwfdecAsValue *) frame->argv, frame->return_value);
}
swfdec_as_context_return (context);
goto start;
@@ -770,46 +771,50 @@ swfdec_as_context_ASSetPropFlags_foreach
}
static void
-swfdec_as_context_ASSetPropFlags (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+swfdec_as_context_ASSetPropFlags (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
guint flags[2]; /* flags and mask - array so we can pass it as data pointer */
SwfdecAsObject *obj;
- if (object->context->version < 6) {
- SWFDEC_WARNING ("ASSetPropFlags needs some limiteations for Flash 5");
+ if (cx->version < 6) {
+ SWFDEC_FIXME ("ASSetPropFlags needs some limitations for Flash 5");
}
if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
return;
obj = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
- flags[0] = swfdec_as_value_to_integer (object->context, &argv[2]);
+ 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 (object->context, &argv[3]) : -1;
+ 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);
} else {
- SWFDEC_ERROR ("ASSetPropFlags for non-null properties not implemented yet");
+ SWFDEC_FIXME ("ASSetPropFlags for non-null properties not implemented yet");
}
}
static void
-swfdec_as_context_isFinite (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+swfdec_as_context_isFinite (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
- double d = swfdec_as_value_to_number (object->context, &argv[0]);
+ double d = swfdec_as_value_to_number (cx, &argv[0]);
SWFDEC_AS_VALUE_SET_BOOLEAN (retval, isfinite (d) ? TRUE : FALSE);
}
static void
-swfdec_as_context_isNaN (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+swfdec_as_context_isNaN (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
- double d = swfdec_as_value_to_number (object->context, &argv[0]);
+ double d = swfdec_as_value_to_number (cx, &argv[0]);
SWFDEC_AS_VALUE_SET_BOOLEAN (retval, isnan (d) ? TRUE : FALSE);
}
static void
-swfdec_as_context_parseInt (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+swfdec_as_context_parseInt (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
- int i = swfdec_as_value_to_integer (object->context, &argv[0]);
+ int i = swfdec_as_value_to_integer (cx, &argv[0]);
SWFDEC_AS_VALUE_SET_INT (retval, i);
}
diff --git a/libswfdec/swfdec_as_math.c b/libswfdec/swfdec_as_math.c
index 72fd090..cfc5fc1 100644
--- a/libswfdec/swfdec_as_math.c
+++ b/libswfdec/swfdec_as_math.c
@@ -32,9 +32,10 @@
#define MATH_FUN(name) \
static void \
-swfdec_as_math_ ## name (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret) \
+swfdec_as_math_ ## name (SwfdecAsContext *cx, SwfdecAsObject *object, \
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret) \
{ \
- double d = swfdec_as_value_to_number (object->context, &argv[0]); \
+ double d = swfdec_as_value_to_number (cx, &argv[0]); \
\
d = name (d); \
SWFDEC_AS_VALUE_SET_NUMBER (ret, d); \
@@ -54,52 +55,58 @@ MATH_FUN (sqrt)
MATH_FUN (tan)
static void
-swfdec_as_math_abs (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_math_abs (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
- double v = swfdec_as_value_to_number (object->context, &argv[0]);
+ double v = swfdec_as_value_to_number (cx, &argv[0]);
SWFDEC_AS_VALUE_SET_NUMBER (ret, fabs (v));
}
static void
-swfdec_as_math_atan2 (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_math_atan2 (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
- double y = swfdec_as_value_to_number (object->context, &argv[0]);
- double x = swfdec_as_value_to_number (object->context, &argv[1]);
+ double y = swfdec_as_value_to_number (cx, &argv[0]);
+ double x = swfdec_as_value_to_number (cx, &argv[1]);
SWFDEC_AS_VALUE_SET_NUMBER (ret, atan2 (y, x));
}
static void
-swfdec_as_math_max (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_math_max (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
- double x = swfdec_as_value_to_number (object->context, &argv[0]);
- double y = swfdec_as_value_to_number (object->context, &argv[1]);
+ double x = swfdec_as_value_to_number (cx, &argv[0]);
+ double y = swfdec_as_value_to_number (cx, &argv[1]);
SWFDEC_AS_VALUE_SET_NUMBER (ret, MAX (x, y));
}
static void
-swfdec_as_math_min (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_math_min (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
- double x = swfdec_as_value_to_number (object->context, &argv[0]);
- double y = swfdec_as_value_to_number (object->context, &argv[1]);
+ double x = swfdec_as_value_to_number (cx, &argv[0]);
+ double y = swfdec_as_value_to_number (cx, &argv[1]);
SWFDEC_AS_VALUE_SET_NUMBER (ret, MIN (x, y));
}
static void
-swfdec_as_math_pow (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_math_pow (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
- double x = swfdec_as_value_to_number (object->context, &argv[0]);
- double y = swfdec_as_value_to_number (object->context, &argv[1]);
+ double x = swfdec_as_value_to_number (cx, &argv[0]);
+ double y = swfdec_as_value_to_number (cx, &argv[1]);
SWFDEC_AS_VALUE_SET_NUMBER (ret, pow (x, y));
}
static void
-swfdec_as_math_random (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_math_random (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
- SWFDEC_AS_VALUE_SET_NUMBER (ret, g_rand_double (object->context->rand));
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, g_rand_double (cx->rand));
}
/* define some math constants if glib doesn't have them */
diff --git a/libswfdec/swfdec_as_native_function.c b/libswfdec/swfdec_as_native_function.c
index 2960b0e..5d68ba4 100644
--- a/libswfdec/swfdec_as_native_function.c
+++ b/libswfdec/swfdec_as_native_function.c
@@ -27,6 +27,10 @@
#include "swfdec_as_stack.h"
#include "swfdec_debug.h"
+/*** GTK-DOC ***/
+
+/*** IMPLEMENTATION ***/
+
G_DEFINE_TYPE (SwfdecAsNativeFunction, swfdec_as_native_function, SWFDEC_TYPE_AS_FUNCTION)
static SwfdecAsFrame *
diff --git a/libswfdec/swfdec_as_number.c b/libswfdec/swfdec_as_number.c
index edeb3c3..63908ed 100644
--- a/libswfdec/swfdec_as_number.c
+++ b/libswfdec/swfdec_as_number.c
@@ -71,24 +71,36 @@ swfdec_as_number_new (SwfdecAsContext *c
/*** AS CODE ***/
static void
-swfdec_as_number_construct (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_number_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
- if (object->context->frame->construct && argc > 0) {
+ double d;
+
+ if (argc > 0) {
+ d = swfdec_as_value_to_number (object->context, &argv[0]);
+ } else {
+ d = NAN;
+ }
+
+ if (cx->frame->construct) {
SwfdecAsNumber *num = SWFDEC_AS_NUMBER (object);
- num->number = swfdec_as_value_to_number (object->context, &argv[0]);
+ num->number = d;
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
+ } else {
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, d);
}
- SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
}
static void
-swfdec_as_number_toString (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_number_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SwfdecAsNumber *num = SWFDEC_AS_NUMBER (object);
SwfdecAsValue val;
const char *s;
if (argc > 0) {
- SWFDEC_ERROR ("radix is not yet implemented");
+ SWFDEC_FIXME ("radix is not yet implemented");
}
SWFDEC_AS_VALUE_SET_NUMBER (&val, num->number);
s = swfdec_as_value_to_string (object->context, &val);
@@ -96,7 +108,8 @@ swfdec_as_number_toString (SwfdecAsObjec
}
static void
-swfdec_as_number_valueOf (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_number_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SwfdecAsNumber *num = SWFDEC_AS_NUMBER (object);
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index 3d17f0b..849c9d4 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -424,7 +424,8 @@ swfdec_as_object_foreach (SwfdecAsObject
/*** SIMPLIFICATIONS ***/
static void
-swfdec_as_object_do_nothing (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+swfdec_as_object_do_nothing (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
}
@@ -647,7 +648,8 @@ swfdec_as_object_set_constructor (Swfdec
/*** AS CODE ***/
static void
-swfdec_as_object_hasOwnProperty (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+swfdec_as_object_hasOwnProperty (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
const char *name;
guint flags;
@@ -662,13 +664,15 @@ swfdec_as_object_hasOwnProperty (SwfdecA
}
static void
-swfdec_as_object_valueOf (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+swfdec_as_object_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
SWFDEC_AS_VALUE_SET_OBJECT (retval, object);
}
static void
-swfdec_as_object_toString (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+swfdec_as_object_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
if (SWFDEC_IS_AS_FUNCTION (object)) {
SWFDEC_AS_VALUE_SET_STRING (retval, SWFDEC_AS_STR__type_Function_);
@@ -701,10 +705,13 @@ swfdec_as_object_init_context (SwfdecAsC
swfdec_as_object_set_variable (object, SWFDEC_AS_STR_prototype, &val);
if (version > 5) {
- swfdec_as_object_add_function (proto, SWFDEC_AS_STR_hasOwnProperty, 0, swfdec_as_object_hasOwnProperty, 1);
+ swfdec_as_object_add_function (proto, SWFDEC_AS_STR_hasOwnProperty,
+ SWFDEC_TYPE_AS_OBJECT, swfdec_as_object_hasOwnProperty, 1);
}
- swfdec_as_object_add_function (proto, SWFDEC_AS_STR_valueOf, 0, swfdec_as_object_valueOf, 0);
- swfdec_as_object_add_function (proto, SWFDEC_AS_STR_toString, 0, swfdec_as_object_toString, 0);
+ swfdec_as_object_add_function (proto, SWFDEC_AS_STR_valueOf,
+ SWFDEC_TYPE_AS_OBJECT, swfdec_as_object_valueOf, 0);
+ swfdec_as_object_add_function (proto, SWFDEC_AS_STR_toString,
+ SWFDEC_TYPE_AS_OBJECT, swfdec_as_object_toString, 0);
}
void
diff --git a/libswfdec/swfdec_as_string.c b/libswfdec/swfdec_as_string.c
index d18b068..22fccaa 100644
--- a/libswfdec/swfdec_as_string.c
+++ b/libswfdec/swfdec_as_string.c
@@ -66,7 +66,8 @@ swfdec_as_str_nth_char (const char *s, g
}
static void
-swfdec_as_string_charAt (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_string_charAt (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SwfdecAsString *string = SWFDEC_AS_STRING (object);
int i;
@@ -83,26 +84,27 @@ swfdec_as_string_charAt (SwfdecAsObject
return;
}
t = g_utf8_next_char (s);
- s = swfdec_as_context_give_string (object->context, g_strndup (s, t - s));
+ s = swfdec_as_context_give_string (cx, g_strndup (s, t - s));
SWFDEC_AS_VALUE_SET_STRING (ret, s);
}
static void
-swfdec_as_string_charCodeAt (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_string_charCodeAt (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SwfdecAsString *string = SWFDEC_AS_STRING (object);
int i;
const char *s;
gunichar c;
- i = swfdec_as_value_to_integer (object->context, &argv[0]);
+ i = swfdec_as_value_to_integer (cx, &argv[0]);
if (i < 0) {
SWFDEC_AS_VALUE_SET_NUMBER (ret, NAN);
return;
}
s = swfdec_as_str_nth_char (string->string, i);
if (*s == 0) {
- if (object->context->version > 5) {
+ if (cx->version > 5) {
SWFDEC_AS_VALUE_SET_NUMBER (ret, NAN);
} else {
SWFDEC_AS_VALUE_SET_INT (ret, 0);
@@ -114,7 +116,8 @@ swfdec_as_string_charCodeAt (SwfdecAsObj
}
static void
-swfdec_as_string_fromCharCode_5 (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_string_fromCharCode_5 (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
guint i, c;
guint8 append;
@@ -123,7 +126,7 @@ swfdec_as_string_fromCharCode_5 (SwfdecA
GByteArray *array = g_byte_array_new ();
for (i = 0; i < argc; i++) {
- c = ((guint) swfdec_as_value_to_integer (object->context, &argv[i])) % 65536;
+ c = ((guint) swfdec_as_value_to_integer (cx, &argv[i])) % 65536;
if (c > 255) {
append = c / 256;
g_byte_array_append (array, &append, 1);
@@ -135,7 +138,7 @@ swfdec_as_string_fromCharCode_5 (SwfdecA
/* FIXME: are these the correct charset names? */
s = g_convert ((char *) array->data, array->len, "UTF8", "LATIN1", NULL, NULL, &error);
if (s) {
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (object->context, s));
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, s));
g_free (s);
} else {
SWFDEC_ERROR ("%s", error->message);
@@ -145,7 +148,8 @@ swfdec_as_string_fromCharCode_5 (SwfdecA
}
static void
-swfdec_as_string_fromCharCode (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_string_fromCharCode (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
gunichar tmp[8];
gunichar *chars;
@@ -159,12 +163,12 @@ swfdec_as_string_fromCharCode (SwfdecAsO
chars = g_new (gunichar, argc);
for (i = 0; i < argc; i++) {
- chars[i] = ((guint) swfdec_as_value_to_integer (object->context, &argv[i])) % 65536;
+ chars[i] = ((guint) swfdec_as_value_to_integer (cx, &argv[i])) % 65536;
}
s = g_ucs4_to_utf8 (chars, argc, NULL, NULL, &error);
if (s) {
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (object->context, s));
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, s));
g_free (s);
} else {
SWFDEC_ERROR ("%s", error->message);
@@ -176,17 +180,18 @@ swfdec_as_string_fromCharCode (SwfdecAsO
}
static void
-swfdec_as_string_construct (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_string_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
const char *s;
if (argc > 0) {
- s = swfdec_as_value_to_string (object->context, &argv[0]);
+ s = swfdec_as_value_to_string (cx, &argv[0]);
} else {
s = SWFDEC_AS_STR_EMPTY;
}
- if (object->context->frame->construct) {
+ if (cx->frame->construct) {
SwfdecAsString *string = SWFDEC_AS_STRING (object);
SwfdecAsValue val;
@@ -200,7 +205,8 @@ swfdec_as_string_construct (SwfdecAsObje
}
static void
-swfdec_as_string_toString (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_string_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SwfdecAsString *string = SWFDEC_AS_STRING (object);
@@ -208,7 +214,8 @@ swfdec_as_string_toString (SwfdecAsObjec
}
static void
-swfdec_as_string_valueOf (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_string_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SwfdecAsString *string = SWFDEC_AS_STRING (object);
@@ -229,27 +236,25 @@ static const char *
swfdec_as_str_sub (SwfdecAsContext *cx, const char *str, guint offset, guint len)
{
const char *end;
- char *dup;
str = g_utf8_offset_to_pointer (str, offset);
end = g_utf8_offset_to_pointer (str, len);
- dup = g_strndup (str, end - str);
- str = swfdec_as_context_get_string (cx, dup);
- g_free (dup);
+ str = swfdec_as_context_give_string (cx, g_strndup (str, end - str));
return str;
}
static void
-swfdec_as_string_substr (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_string_substr (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SwfdecAsString *string = SWFDEC_AS_STRING (object);
int from, to, len;
- from = swfdec_as_value_to_integer (object->context, &argv[0]);
+ from = swfdec_as_value_to_integer (cx, &argv[0]);
len = g_utf8_strlen (string->string, -1);
if (argc > 1) {
- to = swfdec_as_value_to_integer (object->context, &argv[1]);
+ to = swfdec_as_value_to_integer (cx, &argv[1]);
/* FIXME: wtf? */
if (to < 0) {
if (-to <= from)
@@ -268,19 +273,20 @@ swfdec_as_string_substr (SwfdecAsObject
from += len;
from = CLAMP (from, 0, len);
to = CLAMP (to, 0, len - from);
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_str_sub (object->context, string->string, from, to));
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_str_sub (cx, string->string, from, to));
}
static void
-swfdec_as_string_substring (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_string_substring (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SwfdecAsString *string = SWFDEC_AS_STRING (object);
int from, to, len;
len = g_utf8_strlen (string->string, -1);
- from = swfdec_as_value_to_integer (object->context, &argv[0]);
+ from = swfdec_as_value_to_integer (cx, &argv[0]);
if (argc > 1) {
- to = swfdec_as_value_to_integer (object->context, &argv[1]);
+ to = swfdec_as_value_to_integer (cx, &argv[1]);
} else {
to = len;
}
@@ -295,35 +301,38 @@ swfdec_as_string_substring (SwfdecAsObje
to = from;
from = tmp;
}
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_str_sub (object->context, string->string, from, to - from));
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_str_sub (cx, string->string, from, to - from));
}
static void
-swfdec_as_string_toLowerCase (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_string_toLowerCase (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SwfdecAsString *string = SWFDEC_AS_STRING (object);
char *s;
s = g_utf8_strdown (string->string, -1);
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (object->context, s));
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, s));
g_free (s);
}
static void
-swfdec_as_string_toUpperCase (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_string_toUpperCase (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SwfdecAsString *string = SWFDEC_AS_STRING (object);
char *s;
s = g_utf8_strup (string->string, -1);
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (object->context, s));
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, s));
g_free (s);
}
/* escape and unescape are implemented here so the mad string functions share the same place */
static void
-swfdec_as_string_unescape_5 (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_string_unescape_5 (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
GByteArray *array;
const char *msg;
@@ -336,7 +345,7 @@ swfdec_as_string_unescape_5 (SwfdecAsObj
g_byte_array_append (array, (guchar *) chr, 1); \
}G_STMT_END
array = g_byte_array_new ();
- msg = swfdec_as_value_to_string (object->context, &argv[0]);
+ msg = swfdec_as_value_to_string (cx, &argv[0]);
in = s = g_convert (msg, -1, "LATIN1", "UTF8", NULL, NULL, NULL);
if (s == NULL) {
SWFDEC_FIXME ("%s can not be converted to utf8 - is this Flash 5 or what?", msg);
@@ -379,7 +388,7 @@ swfdec_as_string_unescape_5 (SwfdecAsObj
g_byte_array_append (array, (guchar *) &cur, 1);
out = g_convert ((char *) array->data, -1, "UTF8", "LATIN1", NULL, NULL, NULL);
if (out) {
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (object->context, out));
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, out));
g_free (out);
} else {
g_warning ("can't convert %s to UTF-8", msg);
@@ -390,15 +399,16 @@ swfdec_as_string_unescape_5 (SwfdecAsObj
}
static void
-swfdec_as_string_escape (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_string_escape (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
GByteArray *array;
const char *s;
char *in = NULL;
array = g_byte_array_new ();
- s = swfdec_as_value_to_string (object->context, &argv[0]);
- if (object->context->version <= 5) {
+ s = swfdec_as_value_to_string (cx, &argv[0]);
+ if (cx->version <= 5) {
in = g_convert (s, -1, "LATIN1", "UTF8", NULL, NULL, NULL);
if (s == NULL) {
SWFDEC_FIXME ("%s can not be converted to utf8 - is this Flash 5 or what?", s);
@@ -423,13 +433,14 @@ swfdec_as_string_escape (SwfdecAsObject
s++;
}
g_byte_array_append (array, (guchar *) s, 1);
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (object->context, (char *) array->data));
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, (char *) array->data));
g_byte_array_free (array, TRUE);
g_free (in);
}
static void
-swfdec_as_string_unescape (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+swfdec_as_string_unescape (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
GByteArray *array;
const char *s, *msg;
@@ -469,7 +480,7 @@ swfdec_as_string_unescape (SwfdecAsObjec
} \
}G_STMT_END
array = g_byte_array_new ();
- msg = s = swfdec_as_value_to_string (object->context, &argv[0]);
+ msg = s = swfdec_as_value_to_string (cx, &argv[0]);
while (*s != 0) {
if (decoding) {
decoding++;
@@ -511,7 +522,7 @@ swfdec_as_string_unescape (SwfdecAsObjec
}
g_byte_array_append (array, (guchar *) &cur, 1);
if (g_utf8_validate ((char *) array->data, -1, NULL)) {
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (object->context, (char *) array->data));
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, (char *) array->data));
} else {
g_warning ("%s unescaped is invalid UTF-8", msg);
SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_EMPTY);
diff --git a/libswfdec/swfdec_as_types.h b/libswfdec/swfdec_as_types.h
index 67b87b5..0dc580f 100644
--- a/libswfdec/swfdec_as_types.h
+++ b/libswfdec/swfdec_as_types.h
@@ -45,7 +45,11 @@ typedef struct _SwfdecAsObject SwfdecAsO
typedef struct _SwfdecAsScope SwfdecAsScope;
typedef struct _SwfdecAsStack SwfdecAsStack;
typedef struct _SwfdecAsValue SwfdecAsValue;
-typedef void (* SwfdecAsNative) (SwfdecAsObject *thisp, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval);
+typedef void (* SwfdecAsNative) (SwfdecAsContext * context,
+ SwfdecAsObject * thisp,
+ guint argc,
+ SwfdecAsValue * argv,
+ SwfdecAsValue * retval);
/* IMPORTANT: a SwfdecAsValue memset to 0 is a valid undefined value */
struct _SwfdecAsValue {
diff --git a/libswfdec/swfdec_color_as.c b/libswfdec/swfdec_color_as.c
index e73505d..8ebefe5 100644
--- a/libswfdec/swfdec_color_as.c
+++ b/libswfdec/swfdec_color_as.c
@@ -57,7 +57,8 @@ swfdec_movie_color_init (SwfdecMovieColo
/*** AS CODE ***/
static void
-swfdec_movie_color_getRGB (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_movie_color_getRGB (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
int result;
SwfdecMovie *movie = SWFDEC_MOVIE_COLOR (obj)->movie;
@@ -81,7 +82,8 @@ add_variable (SwfdecAsObject *obj, const
}
static void
-swfdec_movie_color_getTransform (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_movie_color_getTransform (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecAsObject *ret;
SwfdecMovie *movie = SWFDEC_MOVIE_COLOR (obj)->movie;
@@ -89,7 +91,7 @@ swfdec_movie_color_getTransform (SwfdecA
if (movie == NULL)
return;
- ret = swfdec_as_object_new (obj->context);
+ ret = swfdec_as_object_new (cx);
if (ret == NULL)
return;
@@ -105,7 +107,8 @@ swfdec_movie_color_getTransform (SwfdecA
}
static void
-swfdec_movie_color_setRGB (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_movie_color_setRGB (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
guint color;
SwfdecMovie *movie = SWFDEC_MOVIE_COLOR (obj)->movie;
@@ -113,7 +116,7 @@ swfdec_movie_color_setRGB (SwfdecAsObjec
if (movie == NULL)
return;
- color = swfdec_as_value_to_integer (obj->context, &argv[0]);
+ color = swfdec_as_value_to_integer (cx, &argv[0]);
movie->color_transform.ra = 0;
movie->color_transform.rb = (color & 0xFF0000) >> 16;
@@ -141,7 +144,8 @@ parse_property (SwfdecAsObject *obj, con
}
static void
-swfdec_movie_color_setTransform (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_movie_color_setTransform (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecAsObject *parse;
SwfdecMovie *movie = SWFDEC_MOVIE_COLOR (obj)->movie;
@@ -164,7 +168,8 @@ swfdec_movie_color_setTransform (SwfdecA
}
static void
-swfdec_movie_color_construct (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_movie_color_construct (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovieColor *color = SWFDEC_MOVIE_COLOR (obj);
diff --git a/libswfdec/swfdec_mouse_as.c b/libswfdec/swfdec_mouse_as.c
index 01b6c9d..3a39619 100644
--- a/libswfdec/swfdec_mouse_as.c
+++ b/libswfdec/swfdec_mouse_as.c
@@ -27,9 +27,10 @@
#include "swfdec_player_internal.h"
static void
-swfdec_mouse_addListener (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *return_value)
+swfdec_mouse_addListener (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *return_value)
{
- SwfdecPlayer *player = SWFDEC_PLAYER (object->context);
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
return;
@@ -37,9 +38,10 @@ swfdec_mouse_addListener (SwfdecAsObject
}
static void
-swfdec_mouse_removeListener (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *return_value)
+swfdec_mouse_removeListener (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *return_value)
{
- SwfdecPlayer *player = SWFDEC_PLAYER (object->context);
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
return;
@@ -47,18 +49,20 @@ swfdec_mouse_removeListener (SwfdecAsObj
}
static void
-swfdec_mouse_show (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+swfdec_mouse_show (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
- SwfdecPlayer *player = SWFDEC_PLAYER (object->context);
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
SWFDEC_AS_VALUE_SET_INT (retval, player->mouse_visible ? 1 : 0);
player->mouse_visible = TRUE;
}
static void
-swfdec_mouse_hide (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+swfdec_mouse_hide (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
- SwfdecPlayer *player = SWFDEC_PLAYER (object->context);
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
SWFDEC_AS_VALUE_SET_INT (retval, player->mouse_visible ? 1 : 0);
player->mouse_visible = FALSE;
diff --git a/libswfdec/swfdec_net_connection.c b/libswfdec/swfdec_net_connection.c
index 22fadc1..47c9d0d 100644
--- a/libswfdec/swfdec_net_connection.c
+++ b/libswfdec/swfdec_net_connection.c
@@ -110,7 +110,8 @@ swfdec_net_connection_connect (SwfdecNet
/*** AS CODE ***/
static void
-swfdec_net_connection_do_connect (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_net_connection_do_connect (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecNetConnection *conn = SWFDEC_NET_CONNECTION (obj);
const char *url;
diff --git a/libswfdec/swfdec_player_as.c b/libswfdec/swfdec_player_as.c
index 9c1ec35..e983c6f 100644
--- a/libswfdec/swfdec_player_as.c
+++ b/libswfdec/swfdec_player_as.c
@@ -30,10 +30,10 @@
/*** INTERVALS ***/
static void
-swfdec_player_do_set_interval (gboolean repeat, SwfdecAsObject *obj, guint argc,
+swfdec_player_do_set_interval (gboolean repeat, SwfdecAsContext *cx, guint argc,
SwfdecAsValue *argv, SwfdecAsValue *rval)
{
- SwfdecPlayer *player = SWFDEC_PLAYER (obj->context);
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
SwfdecAsObject *object;
guint id, msecs;
#define MIN_INTERVAL_TIME 10
@@ -44,7 +44,7 @@ swfdec_player_do_set_interval (gboolean
}
object = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
if (SWFDEC_IS_AS_FUNCTION (object)) {
- msecs = swfdec_as_value_to_integer (obj->context, &argv[1]);
+ msecs = swfdec_as_value_to_integer (cx, &argv[1]);
if (msecs < MIN_INTERVAL_TIME) {
SWFDEC_INFO ("interval duration is %u, making it %u msecs", msecs, MIN_INTERVAL_TIME);
msecs = MIN_INTERVAL_TIME;
@@ -57,8 +57,8 @@ swfdec_player_do_set_interval (gboolean
SWFDEC_WARNING ("setInterval needs 3 arguments when not called with function");
return;
}
- name = swfdec_as_value_to_string (obj->context, &argv[1]);
- msecs = swfdec_as_value_to_integer (obj->context, &argv[2]);
+ name = swfdec_as_value_to_string (cx, &argv[1]);
+ msecs = swfdec_as_value_to_integer (cx, &argv[2]);
if (msecs < MIN_INTERVAL_TIME) {
SWFDEC_INFO ("interval duration is %u, making it %u msecs", msecs, MIN_INTERVAL_TIME);
msecs = MIN_INTERVAL_TIME;
@@ -69,18 +69,20 @@ swfdec_player_do_set_interval (gboolean
}
static void
-swfdec_player_setInterval (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_player_setInterval (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
- swfdec_player_do_set_interval (TRUE, obj, argc, argv, rval);
+ swfdec_player_do_set_interval (TRUE, cx, argc, argv, rval);
}
static void
-swfdec_player_clearInterval (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_player_clearInterval (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
- SwfdecPlayer *player = SWFDEC_PLAYER (obj->context);
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
guint id;
- id = swfdec_as_value_to_integer (obj->context, &argv[0]);
+ id = swfdec_as_value_to_integer (cx, &argv[0]);
swfdec_interval_remove (player, id);
}
@@ -152,18 +154,18 @@ static JSFunctionSpec global_methods[] =
#endif
static void
-swfdec_player_object_registerClass (SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_player_object_registerClass (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
const char *name;
- name = swfdec_as_value_to_string (object->context, &argv[0]);
+ name = swfdec_as_value_to_string (cx, &argv[0]);
if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[1])) {
SWFDEC_AS_VALUE_SET_BOOLEAN (rval, FALSE);
return;
}
- swfdec_player_set_export_class (SWFDEC_PLAYER (object->context), name,
+ swfdec_player_set_export_class (SWFDEC_PLAYER (cx), name,
SWFDEC_AS_VALUE_GET_OBJECT (&argv[1]));
SWFDEC_AS_VALUE_SET_BOOLEAN (rval, TRUE);
}
diff --git a/libswfdec/swfdec_sprite_movie_as.c b/libswfdec/swfdec_sprite_movie_as.c
index 6141dcc..c5a3c4c 100644
--- a/libswfdec/swfdec_sprite_movie_as.c
+++ b/libswfdec/swfdec_sprite_movie_as.c
@@ -34,19 +34,22 @@
#include "swfdec_swf_instance.h"
static void
-swfdec_sprite_movie_play (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_play (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SWFDEC_MOVIE (obj)->stopped = FALSE;
}
static void
-swfdec_sprite_movie_stop (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_stop (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SWFDEC_MOVIE (obj)->stopped = TRUE;
}
static void
-swfdec_sprite_movie_getBytesLoaded (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_getBytesLoaded (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
@@ -58,7 +61,8 @@ swfdec_sprite_movie_getBytesLoaded (Swfd
}
static void
-swfdec_sprite_movie_getBytesTotal (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_getBytesTotal (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
@@ -70,7 +74,8 @@ swfdec_sprite_movie_getBytesTotal (Swfde
}
static void
-swfdec_sprite_movie_getNextHighestDepth (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_getNextHighestDepth (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
int depth;
@@ -107,7 +112,8 @@ swfdec_sprite_movie_do_goto (SwfdecMovie
}
static void
-swfdec_sprite_movie_gotoAndPlay (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_gotoAndPlay (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
@@ -116,7 +122,8 @@ swfdec_sprite_movie_gotoAndPlay (SwfdecA
}
static void
-swfdec_sprite_movie_gotoAndStop (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_gotoAndStop (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
@@ -125,7 +132,8 @@ swfdec_sprite_movie_gotoAndStop (SwfdecA
}
static void
-swfdec_sprite_movie_nextFrame (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_nextFrame (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
@@ -135,7 +143,8 @@ swfdec_sprite_movie_nextFrame (SwfdecAsO
}
static void
-swfdec_sprite_movie_prevFrame (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_prevFrame (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
@@ -145,7 +154,8 @@ swfdec_sprite_movie_prevFrame (SwfdecAsO
}
static void
-swfdec_sprite_movie_hitTest (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_hitTest (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
@@ -204,21 +214,22 @@ swfdec_sprite_movie_hitTest (SwfdecAsObj
}
static void
-swfdec_sprite_movie_startDrag (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_startDrag (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
- SwfdecPlayer *player = SWFDEC_PLAYER (obj->context);
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
gboolean center = FALSE;
if (argc > 0) {
- center = swfdec_as_value_to_boolean (obj->context, &argv[0]);
+ center = swfdec_as_value_to_boolean (cx, &argv[0]);
}
if (argc >= 5) {
SwfdecRect rect;
- rect.x0 = swfdec_as_value_to_number (obj->context, &argv[1]);
- rect.y0 = swfdec_as_value_to_number (obj->context, &argv[2]);
- rect.x1 = swfdec_as_value_to_number (obj->context, &argv[3]);
- rect.y1 = swfdec_as_value_to_number (obj->context, &argv[4]);
+ rect.x0 = swfdec_as_value_to_number (cx, &argv[1]);
+ rect.y0 = swfdec_as_value_to_number (cx, &argv[2]);
+ rect.x1 = swfdec_as_value_to_number (cx, &argv[3]);
+ rect.y1 = swfdec_as_value_to_number (cx, &argv[4]);
swfdec_rect_scale (&rect, &rect, SWFDEC_TWIPS_SCALE_FACTOR);
swfdec_player_set_drag_movie (player, movie, center, &rect);
} else {
@@ -227,13 +238,15 @@ swfdec_sprite_movie_startDrag (SwfdecAsO
}
static void
-swfdec_sprite_movie_stopDrag (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_stopDrag (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
- swfdec_player_set_drag_movie (SWFDEC_PLAYER (obj->context), NULL, FALSE, NULL);
+ swfdec_player_set_drag_movie (SWFDEC_PLAYER (cx), NULL, FALSE, NULL);
}
static void
-swfdec_sprite_movie_swapDepths (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_swapDepths (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
SwfdecMovie *other;
@@ -248,7 +261,7 @@ swfdec_sprite_movie_swapDepths (SwfdecAs
depth = other->depth;
other->depth = movie->depth;
} else {
- depth = swfdec_as_value_to_integer (obj->context, &argv[0]);
+ depth = swfdec_as_value_to_integer (cx, &argv[0]);
other = swfdec_movie_find (movie->parent, depth);
if (other) {
swfdec_movie_invalidate (other);
@@ -278,7 +291,8 @@ swfdec_sprite_movie_init_from_object (Sw
}
static void
-swfdec_sprite_movie_attachMovie (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_attachMovie (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
SwfdecMovie *ret;
@@ -287,10 +301,10 @@ swfdec_sprite_movie_attachMovie (SwfdecA
SwfdecContent *content;
SwfdecGraphic *sprite;
- export = swfdec_as_value_to_string (obj->context, &argv[0]);
- name = swfdec_as_value_to_string (obj->context, &argv[1]);
+ export = swfdec_as_value_to_string (cx, &argv[0]);
+ name = swfdec_as_value_to_string (cx, &argv[1]);
if (argc > 3) {
- SWFDEC_WARNING ("attachMovie's initObject isn't implemented");
+ SWFDEC_FIXME ("attachMovie's initObject isn't implemented");
}
sprite = swfdec_swf_instance_get_export (movie->swf, export);
if (!SWFDEC_IS_SPRITE (sprite)) {
@@ -301,7 +315,7 @@ swfdec_sprite_movie_attachMovie (SwfdecA
}
return;
}
- depth = swfdec_as_value_to_integer (obj->context, &argv[2]);
+ depth = swfdec_as_value_to_integer (cx, &argv[2]);
if (swfdec_depth_classify (depth) == SWFDEC_DEPTH_CLASS_EMPTY)
return;
ret = swfdec_movie_find (movie, depth);
@@ -326,7 +340,8 @@ swfdec_sprite_movie_attachMovie (SwfdecA
}
static void
-swfdec_sprite_movie_duplicateMovieClip (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_duplicateMovieClip (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
SwfdecMovie *ret;
@@ -334,8 +349,8 @@ swfdec_sprite_movie_duplicateMovieClip (
int depth;
SwfdecContent *content;
- name = swfdec_as_value_to_string (obj->context, &argv[0]);
- depth = swfdec_as_value_to_integer (obj->context, &argv[1]);
+ name = swfdec_as_value_to_string (cx, &argv[0]);
+ depth = swfdec_as_value_to_integer (cx, &argv[1]);
if (swfdec_depth_classify (depth) == SWFDEC_DEPTH_CLASS_EMPTY)
return;
if (!movie->parent) {
@@ -364,7 +379,8 @@ swfdec_sprite_movie_duplicateMovieClip (
}
static void
-swfdec_sprite_movie_removeMovieClip (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_removeMovieClip (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
@@ -373,15 +389,16 @@ swfdec_sprite_movie_removeMovieClip (Swf
}
static void
-swfdec_sprite_movie_getURL (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_getURL (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
const char *url;
const char *target;
- url = swfdec_as_value_to_string (obj->context, &argv[0]);
+ url = swfdec_as_value_to_string (cx, &argv[0]);
if (argc > 1) {
- target = swfdec_as_value_to_string (obj->context, &argv[1]);
+ target = swfdec_as_value_to_string (cx, &argv[1]);
} else {
SWFDEC_ERROR ("what's the default target?");
target = NULL;
@@ -394,7 +411,8 @@ swfdec_sprite_movie_getURL (SwfdecAsObje
}
static void
-swfdec_sprite_movie_getDepth (SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+swfdec_sprite_movie_getDepth (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecMovie *movie = SWFDEC_MOVIE (obj);
More information about the Swfdec
mailing list