[Swfdec-commits] 7 commits - swfdec/swfdec_as_interpret.c swfdec/swfdec_audio_decoder_adpcm.c swfdec/swfdec_audio_decoder.c swfdec/swfdec_audio_decoder_uncompressed.c swfdec/swfdec_movie_asprops.c swfdec/swfdec_movie.c swfdec/swfdec_movie.h swfdec/swfdec_sprite_movie.c test/sound test/trace
Benjamin Otte
company at kemper.freedesktop.org
Wed Jun 4 02:02:34 PDT 2008
swfdec/swfdec_as_interpret.c | 44 ++----
swfdec/swfdec_audio_decoder.c | 2
swfdec/swfdec_audio_decoder_adpcm.c | 3
swfdec/swfdec_audio_decoder_uncompressed.c | 3
swfdec/swfdec_movie.c | 46 +++++-
swfdec/swfdec_movie.h | 46 ++++++
swfdec/swfdec_movie_asprops.c | 128 ++++++-------------
swfdec/swfdec_sprite_movie.c | 22 +++
test/sound/sound.c | 5
test/trace/Makefile.am | 9 +
test/trace/movieclip-property-priorities-5.swf |binary
test/trace/movieclip-property-priorities-5.swf.trace | 6
test/trace/movieclip-property-priorities-6.swf |binary
test/trace/movieclip-property-priorities-6.swf.trace | 6
test/trace/movieclip-property-priorities-7.swf |binary
test/trace/movieclip-property-priorities-7.swf.trace | 6
test/trace/movieclip-property-priorities-8.swf |binary
test/trace/movieclip-property-priorities-8.swf.trace | 6
test/trace/movieclip-property-priorities.as | 21 +++
19 files changed, 222 insertions(+), 131 deletions(-)
New commits:
commit fb88c9e29a2f3886d20c4f0797ede57e795625f1
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 4 10:17:18 2008 +0200
add testcase for recent property fixes
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 3211504..c4dd3f9 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -1902,6 +1902,15 @@ EXTRA_DIST = \
movieclip-lockroot-loadmovie-7.swf.trace \
movieclip-lockroot-loadmovie-8.swf \
movieclip-lockroot-loadmovie-8.swf.trace \
+ movieclip-property-priorities-5.swf \
+ movieclip-property-priorities-5.swf.trace \
+ movieclip-property-priorities-6.swf \
+ movieclip-property-priorities-6.swf.trace \
+ movieclip-property-priorities-7.swf \
+ movieclip-property-priorities-7.swf.trace \
+ movieclip-property-priorities-8.swf \
+ movieclip-property-priorities-8.swf.trace \
+ movieclip-property-priorities.as \
movieclip-set-prototype.c \
movieclip-set-prototype-5.swf \
movieclip-set-prototype-5.swf.trace \
diff --git a/test/trace/movieclip-property-priorities-5.swf b/test/trace/movieclip-property-priorities-5.swf
new file mode 100644
index 0000000..03a60a3
Binary files /dev/null and b/test/trace/movieclip-property-priorities-5.swf differ
diff --git a/test/trace/movieclip-property-priorities-5.swf.trace b/test/trace/movieclip-property-priorities-5.swf.trace
new file mode 100644
index 0000000..6dd1233
--- /dev/null
+++ b/test/trace/movieclip-property-priorities-5.swf.trace
@@ -0,0 +1,6 @@
+0
+0
+0
+0
+0
+100
diff --git a/test/trace/movieclip-property-priorities-6.swf b/test/trace/movieclip-property-priorities-6.swf
new file mode 100644
index 0000000..1264dbd
Binary files /dev/null and b/test/trace/movieclip-property-priorities-6.swf differ
diff --git a/test/trace/movieclip-property-priorities-6.swf.trace b/test/trace/movieclip-property-priorities-6.swf.trace
new file mode 100644
index 0000000..d2fc52a
--- /dev/null
+++ b/test/trace/movieclip-property-priorities-6.swf.trace
@@ -0,0 +1,6 @@
+_level0._x
+got me!
+0
+got me
+got me
+100
diff --git a/test/trace/movieclip-property-priorities-7.swf b/test/trace/movieclip-property-priorities-7.swf
new file mode 100644
index 0000000..4620eb6
Binary files /dev/null and b/test/trace/movieclip-property-priorities-7.swf differ
diff --git a/test/trace/movieclip-property-priorities-7.swf.trace b/test/trace/movieclip-property-priorities-7.swf.trace
new file mode 100644
index 0000000..d2fc52a
--- /dev/null
+++ b/test/trace/movieclip-property-priorities-7.swf.trace
@@ -0,0 +1,6 @@
+_level0._x
+got me!
+0
+got me
+got me
+100
diff --git a/test/trace/movieclip-property-priorities-8.swf b/test/trace/movieclip-property-priorities-8.swf
new file mode 100644
index 0000000..40a5287
Binary files /dev/null and b/test/trace/movieclip-property-priorities-8.swf differ
diff --git a/test/trace/movieclip-property-priorities-8.swf.trace b/test/trace/movieclip-property-priorities-8.swf.trace
new file mode 100644
index 0000000..d2fc52a
--- /dev/null
+++ b/test/trace/movieclip-property-priorities-8.swf.trace
@@ -0,0 +1,6 @@
+_level0._x
+got me!
+0
+got me
+got me
+100
diff --git a/test/trace/movieclip-property-priorities.as b/test/trace/movieclip-property-priorities.as
new file mode 100644
index 0000000..4d1b804
--- /dev/null
+++ b/test/trace/movieclip-property-priorities.as
@@ -0,0 +1,21 @@
+// makeswf -v 7 -s 200x150 -r 1 -o movieclip-property-priorities.swf movieclip-property-priorities.as
+
+createEmptyMovieClip ("_x", 0);
+trace (_x);
+addProperty ("_x", function () { return "got me!"; }, null);
+trace (_x);
+asm {
+ push "", 0
+ getproperty
+ trace
+};
+
+addProperty ("_y", function () { return "got me"; }, null);
+trace (_y);
+createEmptyMovieClip ("_y", 0);
+trace (_y);
+
+this.__proto__.addProperty ("_xscale", function () { return "hi kid"; }, null);
+trace (_xscale);
+
+getURL ("fscommand:quit", "");
commit 413625225790e05354a08f9e2200ad46e23e44d2
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 4 09:57:47 2008 +0200
move sprite movie proeprties to sprite move
diff --git a/swfdec/swfdec_movie_asprops.c b/swfdec/swfdec_movie_asprops.c
index c6a4718..0b82f0c 100644
--- a/swfdec/swfdec_movie_asprops.c
+++ b/swfdec/swfdec_movie_asprops.c
@@ -154,31 +154,6 @@ mc_name_set (SwfdecMovie *movie, const SwfdecAsValue *val)
}
static void
-mc_currentframe (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- g_assert (SWFDEC_IS_SPRITE_MOVIE (movie));
- SWFDEC_AS_VALUE_SET_NUMBER (rval, SWFDEC_SPRITE_MOVIE (movie)->frame);
-}
-
-static void
-mc_framesloaded (SwfdecMovie *mov, SwfdecAsValue *rval)
-{
- SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
-
- SWFDEC_AS_VALUE_SET_INT (rval,
- swfdec_sprite_movie_get_frames_loaded (movie));
-}
-
-static void
-mc_totalframes (SwfdecMovie *mov, SwfdecAsValue *rval)
-{
- SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
-
- SWFDEC_AS_VALUE_SET_INT (rval,
- swfdec_sprite_movie_get_frames_total (movie));
-}
-
-static void
mc_alpha_get (SwfdecMovie *movie, SwfdecAsValue *rval)
{
SWFDEC_AS_VALUE_SET_NUMBER (rval,
@@ -479,35 +454,34 @@ mc_focusrect_set (SwfdecMovie *movie, const SwfdecAsValue *val)
}
struct {
- gboolean needs_movie;
const char *name;
void (* get) (SwfdecMovie *movie, SwfdecAsValue *ret);
void (* set) (SwfdecMovie *movie, const SwfdecAsValue *val);
} swfdec_movieclip_props[] = {
- { 0, SWFDEC_AS_STR__x, mc_x_get, mc_x_set },
- { 0, SWFDEC_AS_STR__y, mc_y_get, mc_y_set },
- { 0, SWFDEC_AS_STR__xscale, mc_xscale_get, mc_xscale_set },
- { 0, SWFDEC_AS_STR__yscale, mc_yscale_get, mc_yscale_set },
- { 1, SWFDEC_AS_STR__currentframe, mc_currentframe, NULL },
- { 1, SWFDEC_AS_STR__totalframes, mc_totalframes, NULL },
- { 0, SWFDEC_AS_STR__alpha, mc_alpha_get, mc_alpha_set },
- { 0, SWFDEC_AS_STR__visible, mc_visible_get, mc_visible_set },
- { 0, SWFDEC_AS_STR__width, mc_width_get, mc_width_set },
- { 0, SWFDEC_AS_STR__height, mc_height_get, mc_height_set },
- { 0, SWFDEC_AS_STR__rotation, mc_rotation_get, mc_rotation_set },
- { 1, SWFDEC_AS_STR__target, mc_target_get, NULL },
- { 1, SWFDEC_AS_STR__framesloaded, mc_framesloaded, NULL},
- { 0, SWFDEC_AS_STR__name, mc_name_get, mc_name_set },
- { 1, SWFDEC_AS_STR__droptarget, NULL, NULL }, //"_droptarget"
- { 0, SWFDEC_AS_STR__url, mc_url_get, NULL },
- { 0, SWFDEC_AS_STR__highquality, NULL, NULL }, //"_highquality"
- { 0, SWFDEC_AS_STR__focusrect, mc_focusrect_get, mc_focusrect_set }, //"_focusrect"
- { 0, SWFDEC_AS_STR__soundbuftime, NULL, NULL }, //"_soundbuftime"
- { 0, SWFDEC_AS_STR__quality, NULL, NULL }, //"_quality"
- { 0, SWFDEC_AS_STR__xmouse, mc_xmouse_get, NULL },
- { 0, SWFDEC_AS_STR__ymouse, mc_ymouse_get, NULL },
- { 0, SWFDEC_AS_STR__parent, mc_parent, NULL },
- { 0, SWFDEC_AS_STR__root, mc_root, NULL },
+ { SWFDEC_AS_STR__x, mc_x_get, mc_x_set },
+ { SWFDEC_AS_STR__y, mc_y_get, mc_y_set },
+ { SWFDEC_AS_STR__xscale, mc_xscale_get, mc_xscale_set },
+ { SWFDEC_AS_STR__yscale, mc_yscale_get, mc_yscale_set },
+ { SWFDEC_AS_STR__currentframe,NULL, NULL },
+ { SWFDEC_AS_STR__totalframes, NULL, NULL },
+ { SWFDEC_AS_STR__alpha, mc_alpha_get, mc_alpha_set },
+ { SWFDEC_AS_STR__visible, mc_visible_get, mc_visible_set },
+ { SWFDEC_AS_STR__width, mc_width_get, mc_width_set },
+ { SWFDEC_AS_STR__height, mc_height_get, mc_height_set },
+ { SWFDEC_AS_STR__rotation, mc_rotation_get, mc_rotation_set },
+ { SWFDEC_AS_STR__target, mc_target_get, NULL },
+ { SWFDEC_AS_STR__framesloaded,NULL, NULL},
+ { SWFDEC_AS_STR__name, mc_name_get, mc_name_set },
+ { SWFDEC_AS_STR__droptarget, NULL, NULL }, //"_droptarget"
+ { SWFDEC_AS_STR__url, mc_url_get, NULL },
+ { SWFDEC_AS_STR__highquality, NULL, NULL }, //"_highquality"
+ { SWFDEC_AS_STR__focusrect, mc_focusrect_get, mc_focusrect_set }, //"_focusrect"
+ { SWFDEC_AS_STR__soundbuftime,NULL, NULL }, //"_soundbuftime"
+ { SWFDEC_AS_STR__quality, NULL, NULL }, //"_quality"
+ { SWFDEC_AS_STR__xmouse, mc_xmouse_get, NULL },
+ { SWFDEC_AS_STR__ymouse, mc_ymouse_get, NULL },
+ { SWFDEC_AS_STR__parent, mc_parent, NULL },
+ { SWFDEC_AS_STR__root, mc_root, NULL },
};
guint
diff --git a/swfdec/swfdec_sprite_movie.c b/swfdec/swfdec_sprite_movie.c
index f2bc22e..90ba1dc 100644
--- a/swfdec/swfdec_sprite_movie.c
+++ b/swfdec/swfdec_sprite_movie.c
@@ -748,6 +748,27 @@ swfdec_sprite_movie_mark (SwfdecAsObject *object)
}
static void
+swfdec_sprite_movie_property_get (SwfdecMovie *mov, guint prop_id, SwfdecAsValue *val)
+{
+ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
+
+ switch (prop_id) {
+ case SWFDEC_MOVIE_PROPERTY_CURRENTFRAME:
+ SWFDEC_AS_VALUE_SET_INT (val, movie->frame);
+ break;
+ case SWFDEC_MOVIE_PROPERTY_FRAMESLOADED:
+ SWFDEC_AS_VALUE_SET_INT (val, swfdec_sprite_movie_get_frames_loaded (movie));
+ break;
+ case SWFDEC_MOVIE_PROPERTY_TOTALFRAMES:
+ SWFDEC_AS_VALUE_SET_INT (val, swfdec_sprite_movie_get_frames_total (movie));
+ break;
+ default:
+ SWFDEC_MOVIE_CLASS (swfdec_sprite_movie_parent_class)->property_get (mov, prop_id, val);
+ break;
+ }
+}
+
+static void
swfdec_sprite_movie_class_init (SwfdecSpriteMovieClass * g_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (g_class);
@@ -762,6 +783,7 @@ swfdec_sprite_movie_class_init (SwfdecSpriteMovieClass * g_class)
movie_class->init_movie = swfdec_sprite_movie_init_movie;
movie_class->finish_movie = swfdec_sprite_movie_finish_movie;
+ movie_class->property_get = swfdec_sprite_movie_property_get;
actor_class->iterate_start = swfdec_sprite_movie_iterate;
}
commit f9776a81258b7faf5207279cdf7c2a24640f12d5
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 4 09:57:08 2008 +0200
properly initialize the output queues of the decoders
diff --git a/swfdec/swfdec_audio_decoder_adpcm.c b/swfdec/swfdec_audio_decoder_adpcm.c
index bbaf222..257fb23 100644
--- a/swfdec/swfdec_audio_decoder_adpcm.c
+++ b/swfdec/swfdec_audio_decoder_adpcm.c
@@ -193,7 +193,8 @@ swfdec_audio_decoder_adpcm_class_init (SwfdecAudioDecoderAdpcmClass *klass)
}
static void
-swfdec_audio_decoder_adpcm_init (SwfdecAudioDecoderAdpcm *audio_decoder_adpcm)
+swfdec_audio_decoder_adpcm_init (SwfdecAudioDecoderAdpcm *dec)
{
+ dec->queue = swfdec_buffer_queue_new ();
}
diff --git a/swfdec/swfdec_audio_decoder_uncompressed.c b/swfdec/swfdec_audio_decoder_uncompressed.c
index edd8f8e..b9be106 100644
--- a/swfdec/swfdec_audio_decoder_uncompressed.c
+++ b/swfdec/swfdec_audio_decoder_uncompressed.c
@@ -139,7 +139,8 @@ swfdec_audio_decoder_uncompressed_class_init (SwfdecAudioDecoderUncompressedClas
}
static void
-swfdec_audio_decoder_uncompressed_init (SwfdecAudioDecoderUncompressed *audio_decoder_uncompressed)
+swfdec_audio_decoder_uncompressed_init (SwfdecAudioDecoderUncompressed *dec)
{
+ dec->queue = swfdec_buffer_queue_new ();
}
commit 9093073f98a73326a588adbd46b30c42d59384e5
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 4 09:54:05 2008 +0200
switch on codec, not on format (oops)
diff --git a/swfdec/swfdec_audio_decoder.c b/swfdec/swfdec_audio_decoder.c
index 6f7f0e7..eee4ecc 100644
--- a/swfdec/swfdec_audio_decoder.c
+++ b/swfdec/swfdec_audio_decoder.c
@@ -43,7 +43,7 @@ swfdec_audio_decoder_init (SwfdecAudioDecoder *audio_decoder)
static SwfdecAudioDecoder *
swfdec_audio_decoder_builtin_new (guint codec, SwfdecAudioFormat format)
{
- switch (format) {
+ switch (codec) {
case SWFDEC_AUDIO_CODEC_UNDEFINED:
case SWFDEC_AUDIO_CODEC_UNCOMPRESSED:
return g_object_new (SWFDEC_TYPE_AUDIO_DECODER_UNCOMPRESSED, NULL);
commit 85cc554fe6ce59c578e3c228e0a877101bd1b9ad
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 4 09:52:38 2008 +0200
update to new API of swfdec_audio_render()
diff --git a/test/sound/sound.c b/test/sound/sound.c
index 07e2148..67bc6f3 100644
--- a/test/sound/sound.c
+++ b/test/sound/sound.c
@@ -193,8 +193,9 @@ render_all_streams (SwfdecPlayer *player, guint msecs, guint n_samples, TestData
for (walk = data->streams; walk; walk = walk->next) {
TestStream *stream = walk->data;
- SwfdecBuffer *buffer = swfdec_buffer_new0 (n_samples * 4);
- swfdec_audio_render (stream->audio, (gint16 *) buffer->data, 0, n_samples);
+ SwfdecBuffer *buffer = swfdec_buffer_new (n_samples * 4);
+ n_samples = swfdec_audio_render (stream->audio, (gint16 *) buffer->data, 0, n_samples);
+ buffer->length = n_samples * 4;
swfdec_buffer_queue_push (stream->queue, buffer);
}
}
commit 7a2b9d0db4a520a025467e3fb178d6262139cccb
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 4 08:34:03 2008 +0200
make [GS]etProperty set the properties directly and not use [gs]et_variable
diff --git a/swfdec/swfdec_as_interpret.c b/swfdec/swfdec_as_interpret.c
index bcdda37..e9ec454 100644
--- a/swfdec/swfdec_as_interpret.c
+++ b/swfdec/swfdec_as_interpret.c
@@ -663,13 +663,6 @@ swfdec_action_set_variable (SwfdecAsContext *cx, guint action, const guint8 *dat
swfdec_as_stack_pop_n (cx, 2);
}
-/* FIXME: this sucks */
-extern struct {
- gboolean needs_movie;
- const char * name; /* GC'd */
- void (* get) (SwfdecMovie *movie, SwfdecAsValue *ret);
- void (* set) (SwfdecMovie *movie, const SwfdecAsValue *val);
-} swfdec_movieclip_props[];
static void
swfdec_action_get_property (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
{
@@ -679,25 +672,21 @@ swfdec_action_get_property (SwfdecAsContext *cx, guint action, const guint8 *dat
id = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1));
if (!SWFDEC_IS_PLAYER (cx)) {
SWFDEC_INFO ("tried using GetProperty in a non-SwfdecPlayer context");
- goto error;
+ movie = NULL;
} else {
movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx),
swfdec_as_stack_peek (cx, 2));
- if (movie == NULL)
- goto error;
}
- if (id > (cx->version > 4 ? 21 : 18)) {
+ if (movie == NULL) {
+ SWFDEC_ERROR ("calling GetProperty not on a movieclip object");
+ SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 2));
+ } else if (id > (cx->version > 4 ? 21 : 18)) {
SWFDEC_WARNING ("trying to GetProperty %u, doesn't exist", id);
- goto error;
+ SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 2));
+ } else {
+ swfdec_movie_property_get (movie, id, swfdec_as_stack_peek (cx, 2));
}
- swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (movie), swfdec_movieclip_props[id].name,
- swfdec_as_stack_peek (cx, 2));
- swfdec_as_stack_pop (cx);
- return;
-
-error :
swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 1));
}
static void
@@ -709,23 +698,18 @@ swfdec_action_set_property (SwfdecAsContext *cx, guint action, const guint8 *dat
id = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 2));
if (!SWFDEC_IS_PLAYER (cx)) {
SWFDEC_INFO ("tried using GetProperty in a non-SwfdecPlayer context");
- goto error;
+ movie = NULL;
} else {
movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx),
swfdec_as_stack_peek (cx, 3));
- if (movie == NULL)
- goto error;
}
- if (id > (cx->version > 4 ? 21 : 18)) {
+ if (movie == NULL) {
+ SWFDEC_ERROR ("calling GetProperty not on a movieclip object");
+ } else if (id > (cx->version > 4 ? 21 : 18)) {
SWFDEC_WARNING ("trying to SetProperty %u, doesn't exist", id);
- goto error;
+ } else {
+ swfdec_movie_property_set (movie, id, swfdec_as_stack_peek (cx, 1));
}
- swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (movie), swfdec_movieclip_props[id].name,
- swfdec_as_stack_peek (cx, 1));
- swfdec_as_stack_pop_n (cx, 3);
- return;
-
-error :
swfdec_as_stack_pop_n (cx, 3);
}
commit 0796fc2f20b478aaa65dbad61c539537fa3adc84
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Jun 3 21:44:00 2008 +0200
improve properties API
THis makes it possible to override properties in subclasses
diff --git a/swfdec/swfdec_movie.c b/swfdec/swfdec_movie.c
index 19c43fe..9af35e8 100644
--- a/swfdec/swfdec_movie.c
+++ b/swfdec/swfdec_movie.c
@@ -1024,6 +1024,7 @@ swfdec_movie_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig,
const char *variable, SwfdecAsValue *val, guint *flags)
{
SwfdecMovie *movie, *ret;
+ guint prop_id;
movie = SWFDEC_MOVIE (object);
movie = swfdec_movie_resolve (movie);
@@ -1034,11 +1035,6 @@ swfdec_movie_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig,
if (SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->get (object, orig, variable, val, flags))
return TRUE;
- if (swfdec_movie_get_asprop (movie, variable, val)) {
- *flags = 0;
- return TRUE;
- }
-
/* FIXME: check that this is correct */
if (object->context->version > 5 && variable == SWFDEC_AS_STR__global) {
SWFDEC_AS_VALUE_SET_OBJECT (val, SWFDEC_AS_OBJECT (movie->resource->sandbox));
@@ -1052,6 +1048,14 @@ swfdec_movie_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig,
*flags = 0;
return TRUE;
}
+
+ prop_id = swfdec_movie_property_lookup (variable);
+ if (prop_id != G_MAXUINT) {
+ swfdec_movie_property_get (movie, prop_id, val);
+ *flags = 0;
+ return TRUE;
+ }
+
return FALSE;
}
@@ -1126,14 +1130,18 @@ swfdec_movie_set_variable (SwfdecAsObject *object, const char *variable,
const SwfdecAsValue *val, guint flags)
{
SwfdecMovie *movie = SWFDEC_MOVIE (object);
+ guint prop_id;
movie = swfdec_movie_resolve (movie);
if (movie == NULL)
return;
object = SWFDEC_AS_OBJECT (movie);
- if (swfdec_movie_set_asprop (movie, variable, val))
+ prop_id = swfdec_movie_property_lookup (variable);
+ if (prop_id != G_MAXUINT) {
+ swfdec_movie_property_set (movie, prop_id, val);
return;
+ }
swfdec_movie_call_variable_listeners (movie, variable, val);
@@ -1313,6 +1321,8 @@ swfdec_movie_class_init (SwfdecMovieClass * movie_class)
movie_class->render = swfdec_movie_do_render;
movie_class->invalidate = swfdec_movie_do_invalidate;
movie_class->contains = swfdec_movie_do_contains;
+ movie_class->property_get = swfdec_movie_property_do_get;
+ movie_class->property_set = swfdec_movie_property_do_set;
}
void
@@ -1657,3 +1667,27 @@ swfdec_movie_get_own_resource (SwfdecMovie *movie)
return movie->resource;
}
+void
+swfdec_movie_property_set (SwfdecMovie *movie, guint id, const SwfdecAsValue *val)
+{
+ SwfdecMovieClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (val != NULL);
+
+ klass = SWFDEC_MOVIE_GET_CLASS (movie);
+ klass->property_set (movie, id, val);
+}
+
+void
+swfdec_movie_property_get (SwfdecMovie *movie, guint id, SwfdecAsValue *val)
+{
+ SwfdecMovieClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (val != NULL);
+
+ klass = SWFDEC_MOVIE_GET_CLASS (movie);
+ klass->property_get (movie, id, val);
+}
+
diff --git a/swfdec/swfdec_movie.h b/swfdec/swfdec_movie.h
index 0ef2a01..455c747 100644
--- a/swfdec/swfdec_movie.h
+++ b/swfdec/swfdec_movie.h
@@ -53,6 +53,31 @@ typedef enum {
SWFDEC_FLASH_NO
} SwfdecFlashBool;
+typedef enum {
+ SWFDEC_MOVIE_PROPERTY_X = 0,
+ SWFDEC_MOVIE_PROPERTY_Y = 1,
+ SWFDEC_MOVIE_PROPERTY_XSCALE = 2,
+ SWFDEC_MOVIE_PROPERTY_YSCALE = 3,
+ SWFDEC_MOVIE_PROPERTY_CURRENTFRAME = 4,
+ SWFDEC_MOVIE_PROPERTY_TOTALFRAMES = 5,
+ SWFDEC_MOVIE_PROPERTY_ALPHA = 6,
+ SWFDEC_MOVIE_PROPERTY_VISIBLE = 7,
+ SWFDEC_MOVIE_PROPERTY_WIDTH = 8,
+ SWFDEC_MOVIE_PROPERTY_HEIGHT = 9,
+ SWFDEC_MOVIE_PROPERTY_ROTATION = 10,
+ SWFDEC_MOVIE_PROPERTY_TARGET = 11,
+ SWFDEC_MOVIE_PROPERTY_FRAMESLOADED = 12,
+ SWFDEC_MOVIE_PROPERTY_NAME = 13,
+ SWFDEC_MOVIE_PROPERTY_DROPTARGET = 14,
+ SWFDEC_MOVIE_PROPERTY_URL = 15,
+ SWFDEC_MOVIE_PROPERTY_HIGHQUALITY = 16,
+ SWFDEC_MOVIE_PROPERTY_FOCUSRECT = 17,
+ SWFDEC_MOVIE_PROPERTY_SOUNDBUFTIME = 18,
+ SWFDEC_MOVIE_PROPERTY_QUALITY = 19,
+ SWFDEC_MOVIE_PROPERTY_XMOUSE = 20,
+ SWFDEC_MOVIE_PROPERTY_YMOUSE = 21
+} SwfdecMovieProperty;
+
#define SWFDEC_BLEND_MODE_NORMAL 1
#define SWFDEC_BLEND_MODE_LAYER 2
#define SWFDEC_BLEND_MODE_MULTIPLY 3
@@ -157,6 +182,12 @@ struct _SwfdecMovieClass {
/* general vfuncs */
void (* init_movie) (SwfdecMovie * movie);
void (* finish_movie) (SwfdecMovie * movie);
+ void (* property_get) (SwfdecMovie * movie,
+ guint prop_id,
+ SwfdecAsValue * value);
+ void (* property_set) (SwfdecMovie * movie,
+ guint prop_id,
+ const SwfdecAsValue * value);
void (* replace) (SwfdecMovie * movie,
SwfdecGraphic * graphic);
void (* set_ratio) (SwfdecMovie * movie);
@@ -194,6 +225,12 @@ SwfdecMovie * swfdec_movie_get_by_name (SwfdecMovie * movie,
const char * name,
gboolean unnamed);
SwfdecMovie * swfdec_movie_get_root (SwfdecMovie * movie);
+void swfdec_movie_property_set (SwfdecMovie * movie,
+ guint id,
+ const SwfdecAsValue * val);
+void swfdec_movie_property_get (SwfdecMovie * movie,
+ guint id,
+ SwfdecAsValue * val);
void swfdec_movie_remove (SwfdecMovie * movie);
void swfdec_movie_destroy (SwfdecMovie * movie);
void swfdec_movie_set_static_properties
@@ -260,11 +297,12 @@ SwfdecDepthClass
swfdec_depth_classify (int depth);
/* in swfdec_movie_asprops.c */
-gboolean swfdec_movie_set_asprop (SwfdecMovie * movie,
- const char * name,
+guint swfdec_movie_property_lookup (const char * name);
+void swfdec_movie_property_do_set (SwfdecMovie * movie,
+ guint id,
const SwfdecAsValue * val);
-gboolean swfdec_movie_get_asprop (SwfdecMovie * movie,
- const char * name,
+void swfdec_movie_property_do_get (SwfdecMovie * movie,
+ guint id,
SwfdecAsValue * val);
void swfdec_movie_add_variable_listener (SwfdecMovie * movie,
diff --git a/swfdec/swfdec_movie_asprops.c b/swfdec/swfdec_movie_asprops.c
index 0724557..c6a4718 100644
--- a/swfdec/swfdec_movie_asprops.c
+++ b/swfdec/swfdec_movie_asprops.c
@@ -510,55 +510,37 @@ struct {
{ 0, SWFDEC_AS_STR__root, mc_root, NULL },
};
-static int
-swfdec_movie_get_asprop_index (SwfdecMovie *movie, const char *name)
+guint
+swfdec_movie_property_lookup (const char *name)
{
guint i;
- if (name < SWFDEC_AS_STR__x || name > SWFDEC_AS_STR__root)
- return -1;
-
for (i = 0; i < G_N_ELEMENTS (swfdec_movieclip_props); i++) {
- if (swfdec_movieclip_props[i].name == name) {
- if (swfdec_movieclip_props[i].needs_movie && !SWFDEC_IS_SPRITE_MOVIE (movie))
- return -1;
- if (swfdec_movieclip_props[i].get == NULL) {
- SWFDEC_FIXME ("property %s not implemented", name);
- }
+ if (swfdec_movieclip_props[i].name == name)
return i;
- }
}
- g_assert_not_reached ();
- return -1;
+ return G_MAXUINT;
}
-gboolean
-swfdec_movie_set_asprop (SwfdecMovie *movie, const char *name, const SwfdecAsValue *val)
+void
+swfdec_movie_property_do_get (SwfdecMovie *movie, guint id,
+ SwfdecAsValue *val)
{
- int i;
-
- i = swfdec_movie_get_asprop_index (movie, name);
- if (i == -1)
- return FALSE;
- if (swfdec_movieclip_props[i].set != NULL) {
- swfdec_movieclip_props[i].set (movie, val);
+ if (id >= G_N_ELEMENTS (swfdec_movieclip_props) ||
+ swfdec_movieclip_props[id].get == NULL) {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (val);
+ } else {
+ swfdec_movieclip_props[id].get (movie, val);
}
- return TRUE;
}
-gboolean
-swfdec_movie_get_asprop (SwfdecMovie *movie, const char *name, SwfdecAsValue *val)
+void
+swfdec_movie_property_do_set (SwfdecMovie *movie, guint id,
+ const SwfdecAsValue *val)
{
- int i;
-
- i = swfdec_movie_get_asprop_index (movie, name);
- if (i == -1)
- return FALSE;
- if (swfdec_movieclip_props[i].get != NULL) {
- swfdec_movieclip_props[i].get (movie, val);
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (val);
+ if (id < G_N_ELEMENTS (swfdec_movieclip_props) &&
+ swfdec_movieclip_props[id].set != NULL) {
+ swfdec_movieclip_props[id].set (movie, val);
}
- return TRUE;
}
More information about the Swfdec-commits
mailing list