[Swfdec] 2 commits - libswfdec/swfdec_as_array.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_object.h libswfdec/swfdec_as_super.c libswfdec/swfdec_as_with.c libswfdec/swfdec_movie.c libswfdec/swfdec_player.c libswfdec/swfdec_sprite_movie.c libswfdec/swfdec_video_movie.c
Benjamin Otte
company at kemper.freedesktop.org
Sun Aug 19 11:17:05 PDT 2007
libswfdec/swfdec_as_array.c | 9 ++---
libswfdec/swfdec_as_object.c | 62 ++++++++++++++++++----------------------
libswfdec/swfdec_as_object.h | 14 +++++----
libswfdec/swfdec_as_super.c | 2 -
libswfdec/swfdec_as_with.c | 4 +-
libswfdec/swfdec_movie.c | 4 +-
libswfdec/swfdec_player.c | 2 -
libswfdec/swfdec_sprite_movie.c | 2 -
libswfdec/swfdec_video_movie.c | 2 -
9 files changed, 50 insertions(+), 51 deletions(-)
New commits:
diff-tree 4e35fceb28469c2bc9ee49c9ec71573d6df8861e (from cb77cc43c823c4f3260d6341cf5ed04b65783deb)
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Aug 19 20:16:59 2007 +0200
SwfdecAsObject->set() now takes a default_flags parameter
This parameter is used to set the default set of flags, when a variable
is newly created. Now we don't have the need to call set_flags() after
every init function
diff --git a/libswfdec/swfdec_as_array.c b/libswfdec/swfdec_as_array.c
index a64b165..495bff1 100644
--- a/libswfdec/swfdec_as_array.c
+++ b/libswfdec/swfdec_as_array.c
@@ -332,7 +332,7 @@ swfdec_as_array_add (SwfdecAsObject *obj
static void
swfdec_as_array_set (SwfdecAsObject *object, const char *variable,
- const SwfdecAsValue *val)
+ const SwfdecAsValue *val, guint flags)
{
char *end;
gboolean indexvar = TRUE;
@@ -353,7 +353,7 @@ swfdec_as_array_set (SwfdecAsObject *obj
}
SWFDEC_AS_OBJECT_CLASS (swfdec_as_array_parent_class)->set (object, variable,
- val);
+ val, flags);
// if we added new value outside the current length, set a bigger length
if (indexvar) {
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index 2150244..811be98 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -157,7 +157,7 @@ swfdec_as_object_hash_lookup (SwfdecAsOb
}
static inline SwfdecAsVariable *
-swfdec_as_object_hash_create (SwfdecAsObject *object, const char *variable)
+swfdec_as_object_hash_create (SwfdecAsObject *object, const char *variable, guint flags)
{
SwfdecAsVariable *var;
@@ -166,6 +166,7 @@ swfdec_as_object_hash_create (SwfdecAsOb
if (!swfdec_as_variable_name_is_valid (variable))
return NULL;
var = g_slice_new0 (SwfdecAsVariable);
+ var->flags = flags;
g_hash_table_insert (object->properties, (gpointer) variable, var);
return var;
@@ -194,20 +195,9 @@ swfdec_as_object_do_get (SwfdecAsObject
return TRUE;
}
-static SwfdecAsVariable *
-swfdec_as_object_lookup_variable (SwfdecAsObject *object, const char *variable)
-{
- SwfdecAsVariable *var;
-
- var = swfdec_as_object_hash_lookup (object, variable);
- if (var == NULL)
- var = swfdec_as_object_hash_create (object, variable);
- return var;
-}
-
static void
swfdec_as_object_do_set (SwfdecAsObject *object, const char *variable,
- const SwfdecAsValue *val)
+ const SwfdecAsValue *val, guint flags)
{
SwfdecAsVariable *var;
@@ -241,7 +231,7 @@ swfdec_as_object_do_set (SwfdecAsObject
}
}
if (var == NULL) {
- var = swfdec_as_object_hash_create (object, variable);
+ var = swfdec_as_object_hash_create (object, variable, flags);
if (var == NULL)
return;
}
@@ -549,12 +539,25 @@ swfdec_as_object_collect (SwfdecAsObject
* @value: value to set the variable to
*
* Sets a variable on @object. It is not guaranteed that getting the variable
- * after setting it results in the same value, as some variables can be
- * read-only or require a specific type.
+ * after setting it results in the same value. This is a mcaro that calls
+ * swfdec_as_object_set_variable_and_flags()
+ **/
+/**
+ * swfdec_as_object_set_variable:
+ * @object: a #SwfdecAsObject
+ * @variable: garbage-collected name of the variable to set
+ * @value: value to set the variable to
+ * @default_flags: flags to use if creating the variable anew - the flags will
+ * be ignored if the property already exists.
+ *
+ * Sets a variable on @object. It is not guaranteed that getting the variable
+ * after setting it results in the same value, because various mechanisms (like
+ * the Actionscript Object.addProperty function or constant variables) can
+ * avoid this.
**/
void
-swfdec_as_object_set_variable (SwfdecAsObject *object,
- const char *variable, const SwfdecAsValue *value)
+swfdec_as_object_set_variable_and_flags (SwfdecAsObject *object,
+ const char *variable, const SwfdecAsValue *value, guint default_flags)
{
SwfdecAsObjectClass *klass;
@@ -563,7 +566,7 @@ swfdec_as_object_set_variable (SwfdecAsO
g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
- klass->set (object, variable, value);
+ klass->set (object, variable, value, default_flags);
}
/**
@@ -987,12 +990,13 @@ swfdec_as_object_add_variable (SwfdecAsO
g_return_if_fail (SWFDEC_IS_AS_FUNCTION (get));
g_return_if_fail (set == NULL || SWFDEC_IS_AS_FUNCTION (set));
- var = swfdec_as_object_lookup_variable (object, variable);
+ var = swfdec_as_object_hash_lookup (object, variable);
+ if (var == NULL)
+ var = swfdec_as_object_hash_create (object, variable, 0);
if (var == NULL)
return;
var->get = get;
var->set = set;
- var->flags = 0;
if (set == NULL)
var->flags |= SWFDEC_AS_VARIABLE_CONSTANT;
}
diff --git a/libswfdec/swfdec_as_object.h b/libswfdec/swfdec_as_object.h
index 5baec7d..1109110 100644
--- a/libswfdec/swfdec_as_object.h
+++ b/libswfdec/swfdec_as_object.h
@@ -72,7 +72,8 @@ struct _SwfdecAsObjectClass {
/* set the variable - and return it (or NULL on error) */
void (* set) (SwfdecAsObject * object,
const char * variable,
- const SwfdecAsValue * val);
+ const SwfdecAsValue * val,
+ guint default_flags);
/* set flags of a variable */
void (* set_flags) (SwfdecAsObject * object,
const char * variable,
@@ -109,9 +110,13 @@ void swfdec_as_object_add (SwfdecAsObj
/* I'd like to name these [gs]et_property, but binding authors will complain
* about overlap with g_object_[gs]et_property then */
-void swfdec_as_object_set_variable (SwfdecAsObject * object,
+#define swfdec_as_object_set_variable(object, variable, value) \
+ swfdec_as_object_set_variable_and_flags (object, variable, value, 0)
+void swfdec_as_object_set_variable_and_flags
+ (SwfdecAsObject * object,
const char * variable,
- const SwfdecAsValue * value);
+ const SwfdecAsValue * value,
+ guint default_flags);
void swfdec_as_object_add_variable (SwfdecAsObject * object,
const char * variable,
SwfdecAsFunction * get,
diff --git a/libswfdec/swfdec_as_super.c b/libswfdec/swfdec_as_super.c
index 653c30a..aa75a0b 100644
--- a/libswfdec/swfdec_as_super.c
+++ b/libswfdec/swfdec_as_super.c
@@ -88,7 +88,7 @@ swfdec_as_super_get (SwfdecAsObject *obj
}
static void
-swfdec_as_super_set (SwfdecAsObject *object, const char *variable, const SwfdecAsValue *val)
+swfdec_as_super_set (SwfdecAsObject *object, const char *variable, const SwfdecAsValue *val, guint flags)
{
/* This seems to be ignored completely */
}
diff --git a/libswfdec/swfdec_as_with.c b/libswfdec/swfdec_as_with.c
index 62af9b8..a6b032e 100644
--- a/libswfdec/swfdec_as_with.c
+++ b/libswfdec/swfdec_as_with.c
@@ -60,12 +60,12 @@ swfdec_as_with_get (SwfdecAsObject *obje
static void
swfdec_as_with_set (SwfdecAsObject *object, const char *variable,
- const SwfdecAsValue *val)
+ const SwfdecAsValue *val, guint flags)
{
SwfdecAsWith *with = SWFDEC_AS_WITH (object);
SwfdecAsObjectClass *klass = SWFDEC_AS_OBJECT_GET_CLASS (with->object);
- klass->set (with->object, variable, val);
+ klass->set (with->object, variable, val, flags);
}
static void
diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 3bac79f..0ddb8ff 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -875,7 +875,7 @@ swfdec_movie_get_variable (SwfdecAsObjec
static void
swfdec_movie_set_variable (SwfdecAsObject *object, const char *variable,
- const SwfdecAsValue *val)
+ const SwfdecAsValue *val, guint flags)
{
SwfdecMovie *movie = SWFDEC_MOVIE (object);
@@ -883,7 +883,7 @@ swfdec_movie_set_variable (SwfdecAsObjec
return;
if (swfdec_movie_set_asprop (movie, variable, val))
return;
- SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->set (object, variable, val);
+ SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->set (object, variable, val, flags);
}
static char *
diff-tree cb77cc43c823c4f3260d6341cf5ed04b65783deb (from 5d29f9261756c094b4d0f9a80da05fb6892094bf)
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Aug 19 20:01:22 2007 +0200
remove the third argument from swfdec_as_object_set_constructor()
It was FALSE every time
diff --git a/libswfdec/swfdec_as_array.c b/libswfdec/swfdec_as_array.c
index 9d245c3..a64b165 100644
--- a/libswfdec/swfdec_as_array.c
+++ b/libswfdec/swfdec_as_array.c
@@ -400,7 +400,7 @@ swfdec_as_array_new (SwfdecAsContext *co
return FALSE;
ret = g_object_new (SWFDEC_TYPE_AS_ARRAY, NULL);
swfdec_as_object_add (ret, context, sizeof (SwfdecAsArray));
- swfdec_as_object_set_constructor (ret, context->Array, FALSE);
+ swfdec_as_object_set_constructor (ret, context->Array);
return ret;
}
@@ -1052,8 +1052,7 @@ swfdec_as_array_construct (SwfdecAsConte
swfdec_as_object_add (object, cx, sizeof (SwfdecAsArray));
swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_Array, &val);
if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
- swfdec_as_object_set_constructor (object,
- SWFDEC_AS_VALUE_GET_OBJECT (&val), FALSE);
+ swfdec_as_object_set_constructor (object, SWFDEC_AS_VALUE_GET_OBJECT (&val));
} else {
SWFDEC_INFO ("\"Array\" is not an object");
}
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index 8d4df41..2150244 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -921,7 +921,7 @@ swfdec_as_object_create (SwfdecAsFunctio
return;
new = g_object_new (type, NULL);
swfdec_as_object_add (new, context, size);
- swfdec_as_object_set_constructor (new, SWFDEC_AS_OBJECT (fun), FALSE);
+ swfdec_as_object_set_constructor (new, SWFDEC_AS_OBJECT (fun));
swfdec_as_function_call (fun, new, n_args, args, NULL);
context->frame->construct = TRUE;
}
@@ -930,9 +930,6 @@ swfdec_as_object_create (SwfdecAsFunctio
* swfdec_as_object_set_constructor:
* @object: a #SwfdecAsObject
* @construct: the constructor of @object
- * @scripted: %TRUE if this object was created by a script. Flash sets the
- * property named "__constructor__" on script-created objects, but
- * "constructor" on native ones.
*
* Sets the constructor variables for @object. Most objects get these
* variables set automatically, but for objects you created yourself, you want
@@ -942,8 +939,7 @@ swfdec_as_object_create (SwfdecAsFunctio
* object.__proto__ = construct.prototype; ]|
**/
void
-swfdec_as_object_set_constructor (SwfdecAsObject *object,
- SwfdecAsObject *construct, gboolean scripted)
+swfdec_as_object_set_constructor (SwfdecAsObject *object, SwfdecAsObject *construct)
{
SwfdecAsValue val;
SwfdecAsObject *proto;
@@ -964,12 +960,8 @@ swfdec_as_object_set_constructor (Swfdec
swfdec_as_object_set_variable_flags (object, SWFDEC_AS_STR___proto__,
SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
SWFDEC_AS_VALUE_SET_OBJECT (&val, construct);
- swfdec_as_object_set_variable (object,
- scripted ? SWFDEC_AS_STR_constructor : SWFDEC_AS_STR___constructor__,
- &val);
- swfdec_as_object_set_variable_flags (object,
- scripted ? SWFDEC_AS_STR_constructor : SWFDEC_AS_STR___constructor__,
- SWFDEC_AS_VARIABLE_HIDDEN);
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR___constructor__, &val);
+ swfdec_as_object_set_variable_flags (object, SWFDEC_AS_STR___constructor__, SWFDEC_AS_VARIABLE_HIDDEN);
}
/**
diff --git a/libswfdec/swfdec_as_object.h b/libswfdec/swfdec_as_object.h
index 55bfc05..5baec7d 100644
--- a/libswfdec/swfdec_as_object.h
+++ b/libswfdec/swfdec_as_object.h
@@ -99,8 +99,7 @@ void swfdec_as_object_create (SwfdecAs
guint n_args,
const SwfdecAsValue * args);
void swfdec_as_object_set_constructor(SwfdecAsObject * object,
- SwfdecAsObject * construct,
- gboolean scripted);
+ SwfdecAsObject * construct);
SwfdecAsObject *swfdec_as_object_resolve (SwfdecAsObject * object);
char * swfdec_as_object_get_debug (SwfdecAsObject * object);
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 39a1cb1..942dadf 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -1444,7 +1444,7 @@ swfdec_player_initialize (SwfdecPlayer *
}
if (context->state == SWFDEC_AS_CONTEXT_NEW) {
context->state = SWFDEC_AS_CONTEXT_RUNNING;
- swfdec_as_object_set_constructor (player->roots->data, player->MovieClip, FALSE);
+ swfdec_as_object_set_constructor (player->roots->data, player->MovieClip);
}
}
SWFDEC_INFO ("initializing player to size %ux%u", width, height);
diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
index 4f9067d..9af9370 100644
--- a/libswfdec/swfdec_sprite_movie.c
+++ b/libswfdec/swfdec_sprite_movie.c
@@ -583,7 +583,7 @@ swfdec_sprite_movie_init_movie (SwfdecMo
if (constructor == NULL)
constructor = SWFDEC_PLAYER (context)->MovieClip;
- swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie), constructor, FALSE);
+ swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie), constructor);
swfdec_sprite_movie_goto (movie, 1);
if (!swfdec_sprite_movie_iterate_end (mov)) {
g_assert_not_reached ();
diff --git a/libswfdec/swfdec_video_movie.c b/libswfdec/swfdec_video_movie.c
index 60676e0..eeb137c 100644
--- a/libswfdec/swfdec_video_movie.c
+++ b/libswfdec/swfdec_video_movie.c
@@ -100,7 +100,7 @@ swfdec_video_movie_init_movie (SwfdecMov
{
SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
- swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie), player->Video, FALSE);
+ swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie), player->Video);
}
static void
More information about the Swfdec
mailing list