[Swfdec] 7 commits - configure.ac doc/swfdec-docs.sgml libswfdec/js libswfdec/swfdec_buffer.c libswfdec/swfdec_buffer.h libswfdec/swfdec_js_movie.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Thu Mar 22 12:44:17 PDT 2007


 configure.ac                |    2 
 doc/swfdec-docs.sgml        |    2 
 libswfdec/js/Makefile.am    |    2 
 libswfdec/swfdec_buffer.c   |  140 ++++++++++++++++++---
 libswfdec/swfdec_buffer.h   |    2 
 libswfdec/swfdec_js_movie.c |  292 +++++++++++++++++++++++++++++++-------------
 test/trace/Makefile.am      |    2 
 7 files changed, 341 insertions(+), 101 deletions(-)

New commits:
diff-tree f4f086e6ac5609cd476399e71f31a0408c771bb9 (from 7f3e84277e8625fd1d9de86988ac6401abb7a61b)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Mar 22 20:23:45 2007 +0100

    release 0.4.3

diff --git a/configure.ac b/configure.ac
index 2159631..7b68ddf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
 AC_PREREQ([2.58])
-AC_INIT(swfdec,0.4.2.1)
+AC_INIT(swfdec,0.4.3)
 
 [nano=$(echo $PACKAGE_VERSION | sed 's/[0-9]\.[0-9]\.[0-9][0-9]*\.*//')]
 if test x"$nano" = x1 ; then
diff-tree 7f3e84277e8625fd1d9de86988ac6401abb7a61b (from 6c6af82416ae35dfa7312a66077977a655862051)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Mar 22 19:51:14 2007 +0100

    fix include line to include the correct builddir

diff --git a/libswfdec/js/Makefile.am b/libswfdec/js/Makefile.am
index bdaf07f..9350a6d 100644
--- a/libswfdec/js/Makefile.am
+++ b/libswfdec/js/Makefile.am
@@ -89,7 +89,7 @@ jscpucfg_SOURCES = \
 	jscpucfg.c  \
 	jscpucfg.h
 
-libjs_la_CFLAGS = $(GLOBAL_CFLAGS) $(SWF_CFLAGS) $(GLIB_CFLAGS) -I. $(builddir) \
+libjs_la_CFLAGS = $(GLOBAL_CFLAGS) $(SWF_CFLAGS) $(GLIB_CFLAGS) -I. -I$(top_builddir)/libswfdec/js \
 	-DXP_UNIX -DDEBUG -fno-strict-aliasing
 libjs_la_LDFLAGS = -lm
 
diff-tree 6c6af82416ae35dfa7312a66077977a655862051 (from 9b3d71429f674fad30b0dfa1c9ae3f7d7452e8e4)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Mar 22 19:50:52 2007 +0100

    change all conversions JSObject->SwfdecMovie to not assert on failure but silently return

diff --git a/libswfdec/swfdec_js_movie.c b/libswfdec/swfdec_js_movie.c
index 2d9b1a1..3f6333c 100644
--- a/libswfdec/swfdec_js_movie.c
+++ b/libswfdec/swfdec_js_movie.c
@@ -116,7 +116,11 @@ mc_play (JSContext *cx, JSObject *obj, u
 {
   SwfdecMovie *movie;
 
-  movie = JS_GetPrivate(cx, obj);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
   g_assert (movie);
   movie->stopped = FALSE;
 
@@ -128,8 +132,11 @@ mc_stop (JSContext *cx, JSObject *obj, u
 {
   SwfdecMovie *movie;
 
-  movie = JS_GetPrivate(cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
   movie->stopped = TRUE;
 
   return JS_TRUE;
@@ -141,7 +148,11 @@ mc_getBytesLoaded (JSContext *cx, JSObje
   SwfdecMovie *movie;
   SwfdecDecoder *dec;
 
-  movie = JS_GetPrivate(cx, obj);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
   dec = SWFDEC_ROOT_MOVIE (movie->root)->decoder;
 
   *rval = INT_TO_JSVAL(MIN (dec->bytes_loaded, dec->bytes_total));
@@ -155,7 +166,11 @@ mc_getBytesTotal (JSContext *cx, JSObjec
   SwfdecMovie *movie;
   SwfdecDecoder *dec;
 
-  movie = JS_GetPrivate(cx, obj);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
   dec = SWFDEC_ROOT_MOVIE (movie->root)->decoder;
 
   *rval = INT_TO_JSVAL (dec->bytes_total);
@@ -169,7 +184,11 @@ mc_getNextHighestDepth (JSContext *cx, J
   SwfdecMovie *movie;
   int depth;
 
-  movie = JS_GetPrivate(cx, obj);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
   if (movie->list) {
     depth = SWFDEC_MOVIE (g_list_last (movie->list)->data)->depth + 1;
     if (depth < 0)
@@ -207,8 +226,11 @@ mc_gotoAndPlay (JSContext *cx, JSObject 
 {
   SwfdecMovie *movie;
 
-  movie = JS_GetPrivate(cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
   
   if (!mc_do_goto (cx, movie, argv[0]))
     return JS_FALSE;
@@ -221,8 +243,11 @@ mc_gotoAndStop (JSContext *cx, JSObject 
 {
   SwfdecMovie *movie;
 
-  movie = JS_GetPrivate(cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
   
   if (!mc_do_goto (cx, movie, argv[0]))
     return JS_FALSE;
@@ -236,8 +261,11 @@ swfdec_js_nextFrame (JSContext *cx, JSOb
   SwfdecMovie *movie;
   jsval frame;
 
-  movie = JS_GetPrivate(cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
   
   frame = INT_TO_JSVAL (movie->frame + 2); /* 1-indexed */
   if (!mc_do_goto (cx, movie, frame))
@@ -252,8 +280,11 @@ swfdec_js_prevFrame (JSContext *cx, JSOb
   SwfdecMovie *movie;
   jsval frame;
 
-  movie = JS_GetPrivate(cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
   
   if (movie->frame == 0)
     frame = INT_TO_JSVAL (movie->n_frames);
@@ -270,8 +301,11 @@ mc_hitTest (JSContext *cx, JSObject *obj
 {
   SwfdecMovie *movie;
 
-  movie = JS_GetPrivate(cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
   
   if (argc == 1) {
     SwfdecMovie *other;
@@ -366,8 +400,12 @@ swfdec_js_startDrag (JSContext *cx, JSOb
   JSBool center = JS_FALSE;
   SwfdecRect rect;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
+
   if (argc > 0) {
     if (!JS_ValueToBoolean (cx, argv[0], &center))
       return JS_FALSE;
@@ -395,8 +433,12 @@ swfdec_js_stopDrag (JSContext *cx, JSObj
   SwfdecMovie *movie;
   SwfdecPlayer *player;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
+
   player = SWFDEC_ROOT_MOVIE (movie->root)->player;
   swfdec_player_set_drag_movie (player, NULL, FALSE, NULL);
   return JS_TRUE;
@@ -409,8 +451,11 @@ swfdec_js_movie_swapDepths (JSContext *c
   SwfdecMovie *other;
   int depth;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   if (JSVAL_IS_OBJECT (argv[0])) {
     other = swfdec_scriptable_from_jsval (cx, argv[0], SWFDEC_TYPE_MOVIE);
@@ -462,8 +507,11 @@ swfdec_js_movie_attachMovie (JSContext *
   SwfdecContent *content;
   SwfdecGraphic *sprite;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   export = swfdec_js_to_string (cx, argv[0]);
   name = swfdec_js_to_string (cx, argv[1]);
@@ -518,8 +566,11 @@ swfdec_js_movie_duplicateMovieClip (JSCo
   int depth;
   SwfdecContent *content;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
 #if 0
   /* FIXME: is this still valid? */
@@ -589,8 +640,12 @@ swfdec_js_getURL (JSContext *cx, JSObjec
   const char *target;
   SwfdecMovie *movie;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
+
   url = swfdec_js_to_string (cx, argv[0]);
   if (!url)
     return FALSE;
@@ -615,9 +670,11 @@ swfdec_js_getDepth (JSContext *cx, JSObj
 {
   SwfdecMovie *movie;
 
-  movie = JS_GetPrivate (cx, obj);
-  if (!movie)
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
     return JS_TRUE;
+  }
 
   *rval = INT_TO_JSVAL (movie->depth);
   return JS_TRUE;
@@ -654,8 +711,11 @@ mc_x_get(JSContext *cx, JSObject *obj, j
   SwfdecMovie *movie;
   double d;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   d = SWFDEC_TWIPS_TO_DOUBLE (movie->matrix.x0);
   return JS_NewNumberValue (cx, d, vp);
@@ -667,8 +727,11 @@ mc_x_set(JSContext *cx, JSObject *obj, j
   SwfdecMovie *movie;
   double d;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   if (!JS_ValueToNumber (cx, *vp, &d))
     return JS_FALSE;
@@ -692,8 +755,11 @@ mc_y_get(JSContext *cx, JSObject *obj, j
   SwfdecMovie *movie;
   double d;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   swfdec_movie_update (movie);
   d = SWFDEC_TWIPS_TO_DOUBLE (movie->matrix.y0);
@@ -706,8 +772,11 @@ mc_y_set(JSContext *cx, JSObject *obj, j
   SwfdecMovie *movie;
   double d;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   if (!JS_ValueToNumber (cx, *vp, &d))
     return JS_FALSE;
@@ -731,8 +800,11 @@ mc_xscale_get (JSContext *cx, JSObject *
   SwfdecMovie *movie;
   double d;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   d = movie->xscale;
   return JS_NewNumberValue (cx, d, vp);
@@ -744,8 +816,11 @@ mc_xscale_set (JSContext *cx, JSObject *
   SwfdecMovie *movie;
   double d;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   if (!JS_ValueToNumber (cx, *vp, &d))
     return JS_FALSE;
@@ -779,8 +854,11 @@ mc_yscale_set (JSContext *cx, JSObject *
   SwfdecMovie *movie;
   double d;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   if (!JS_ValueToNumber (cx, *vp, &d))
     return JS_FALSE;
@@ -800,8 +878,11 @@ mc_currentframe (JSContext *cx, JSObject
 {
   SwfdecMovie *movie;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   *vp = INT_TO_JSVAL (movie->frame + 1);
 
@@ -814,8 +895,11 @@ mc_framesloaded (JSContext *cx, JSObject
   SwfdecMovie *movie;
   guint loaded;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   /* only root movies can be partially loaded */
   if (SWFDEC_IS_ROOT_MOVIE (movie)) {
@@ -836,8 +920,11 @@ mc_name_get (JSContext *cx, JSObject *ob
   SwfdecMovie *movie;
   JSString *string;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   if (movie->has_name)
     string = JS_NewStringCopyZ (cx, movie->name);
@@ -856,8 +943,11 @@ mc_name_set (JSContext *cx, JSObject *ob
   SwfdecMovie *movie;
   const char *str;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   str = swfdec_js_to_string (cx, *vp);
   if (str == NULL)
@@ -878,8 +968,11 @@ mc_totalframes (JSContext *cx, JSObject 
 {
   SwfdecMovie *movie;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   *vp = INT_TO_JSVAL (movie->n_frames);
 
@@ -892,8 +985,11 @@ mc_alpha_get (JSContext *cx, JSObject *o
   SwfdecMovie *movie;
   double d;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   d = movie->color_transform.aa * 100.0 / 256.0;
   return JS_NewNumberValue (cx, d, vp);
@@ -906,8 +1002,11 @@ mc_alpha_set (JSContext *cx, JSObject *o
   double d;
   int alpha;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   if (!JS_ValueToNumber (cx, *vp, &d))
     return JS_TRUE;
@@ -924,8 +1023,11 @@ mc_visible_get (JSContext *cx, JSObject 
 {
   SwfdecMovie *movie;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   *vp = BOOLEAN_TO_JSVAL (movie->visible ? JS_TRUE : JS_FALSE);
   return JS_TRUE;
@@ -937,8 +1039,11 @@ mc_visible_set (JSContext *cx, JSObject 
   SwfdecMovie *movie;
   JSBool b;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   if (!JS_ValueToBoolean (cx, *vp, &b))
     return JS_TRUE;
@@ -956,8 +1061,11 @@ mc_width_get (JSContext *cx, JSObject *o
   SwfdecMovie *movie;
   double d;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   swfdec_movie_update (movie);
   d = SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) (rint (movie->extents.x1 - movie->extents.x0)));
@@ -970,8 +1078,11 @@ mc_width_set (JSContext *cx, JSObject *o
   SwfdecMovie *movie;
   double d, cur;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   /* property was readonly in Flash 4 and before */
   if (SWFDEC_SWF_DECODER (SWFDEC_ROOT_MOVIE (movie->root)->decoder)->version < 5)
@@ -1002,8 +1113,11 @@ mc_height_get (JSContext *cx, JSObject *
   SwfdecMovie *movie;
   double d;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   swfdec_movie_update (movie);
   d = SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) (rint (movie->extents.y1 - movie->extents.y0)));
@@ -1016,8 +1130,11 @@ mc_height_set (JSContext *cx, JSObject *
   SwfdecMovie *movie;
   double d, cur;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   /* property was readonly in Flash 4 and before */
   if (SWFDEC_SWF_DECODER (SWFDEC_ROOT_MOVIE (movie->root)->decoder)->version < 5)
@@ -1047,8 +1164,11 @@ mc_rotation_get (JSContext *cx, JSObject
 {
   SwfdecMovie *movie;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   return JS_NewNumberValue (cx, movie->rotation, vp);
 }
@@ -1088,8 +1208,11 @@ mc_xmouse_get (JSContext *cx, JSObject *
   double x, y;
   SwfdecMovie *movie;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   swfdec_movie_get_mouse (movie, &x, &y);
   x = rint (x * SWFDEC_TWIPS_SCALE_FACTOR) / SWFDEC_TWIPS_SCALE_FACTOR;
@@ -1102,8 +1225,11 @@ mc_ymouse_get (JSContext *cx, JSObject *
   double x, y;
   SwfdecMovie *movie;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   swfdec_movie_get_mouse (movie, &x, &y);
   y = rint (y * SWFDEC_TWIPS_SCALE_FACTOR) / SWFDEC_TWIPS_SCALE_FACTOR;
@@ -1117,8 +1243,11 @@ mc_parent (JSContext *cx, JSObject *obj,
   SwfdecMovie *movie;
   JSObject *jsobj;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   /* FIXME: what do we do if we're the root movie? */
   if (movie->parent) {
@@ -1141,8 +1270,11 @@ mc_root (JSContext *cx, JSObject *obj, j
   SwfdecMovie *movie;
   JSObject *jsobj;
 
-  movie = JS_GetPrivate (cx, obj);
-  g_assert (movie);
+  movie = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_MOVIE);
+  if (movie == NULL) {
+    SWFDEC_WARNING ("not a movie");
+    return JS_TRUE;
+  }
 
   movie = movie->root;
   jsobj = swfdec_scriptable_get_object (SWFDEC_SCRIPTABLE (movie));
diff-tree 9b3d71429f674fad30b0dfa1c9ae3f7d7452e8e4 (from 05fd750c320d0da611f2268a94b24a2314300012)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Mar 22 17:41:08 2007 +0100

    use the right name for this file

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 9f66866..f11d827 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -130,7 +130,7 @@ EXTRA_DIST = \
 	netconnection.swf.trace \
 	netstream-onstatus.c \
 	netstream-onstatus.swf \
-	netstream-onstatus.trace \
+	netstream-onstatus.swf.trace \
 	netstream-onstatus-notfound.as \
 	netstream-onstatus-notfound.swf \
 	netstream-onstatus-notfound.swf.trace \
diff-tree 05fd750c320d0da611f2268a94b24a2314300012 (from e6438754381f1486ebe5413dacdd85cfc9ffcfaa)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Mar 22 17:40:46 2007 +0100

    Change name in title from SWFDEC to Swfdec

diff --git a/doc/swfdec-docs.sgml b/doc/swfdec-docs.sgml
index 95ec0ba..64e00e5 100644
--- a/doc/swfdec-docs.sgml
+++ b/doc/swfdec-docs.sgml
@@ -3,7 +3,7 @@
                "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
 <book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
   <bookinfo>
-    <title>SWFDEC Reference Manual</title>
+    <title>Swfdec Reference Manual</title>
   </bookinfo>
 
   <chapter>
diff-tree e6438754381f1486ebe5413dacdd85cfc9ffcfaa (from 8b7586468eb8be730794df33ef1dc3371fa28fe4)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Mar 22 17:40:12 2007 +0100

    OOps, update the header, too

diff --git a/libswfdec/swfdec_buffer.h b/libswfdec/swfdec_buffer.h
index f303295..81f6f66 100644
--- a/libswfdec/swfdec_buffer.h
+++ b/libswfdec/swfdec_buffer.h
@@ -50,7 +50,7 @@ struct _SwfdecBufferQueue
 SwfdecBuffer *swfdec_buffer_new (void);
 SwfdecBuffer *swfdec_buffer_new_and_alloc (unsigned int size);
 SwfdecBuffer *swfdec_buffer_new_and_alloc0 (unsigned int size);
-SwfdecBuffer *swfdec_buffer_new_with_data (void *data, int size);
+SwfdecBuffer *swfdec_buffer_new_for_data (unsigned char *data, unsigned int size);
 SwfdecBuffer *swfdec_buffer_new_subbuffer (SwfdecBuffer * buffer, unsigned int offset,
     unsigned int length);
 SwfdecBuffer *swfdec_buffer_new_from_file (const char *filename, GError **error);
diff-tree 8b7586468eb8be730794df33ef1dc3371fa28fe4 (from 78f8f60164ab0703da6ad2ade859b41ef1602d98)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Mar 22 17:29:19 2007 +0100

    update SwfdecBuffer to swfdec API standards
    
    - add g_return_(val_)if_fail to arguments
    - document functions

diff --git a/libswfdec/swfdec_buffer.c b/libswfdec/swfdec_buffer.c
index 5de5ac8..49d47e7 100644
--- a/libswfdec/swfdec_buffer.c
+++ b/libswfdec/swfdec_buffer.c
@@ -29,10 +29,41 @@
 #include <swfdec_debug.h>
 #include <liboil/liboil.h>
 
-static void swfdec_buffer_free_mem (SwfdecBuffer * buffer, void *);
-static void swfdec_buffer_free_subbuffer (SwfdecBuffer * buffer, void *priv);
+/*** gtk-doc ***/
 
+/**
+ * SECTION:SwfdecBuffer
+ * @title: SwfdecBuffer
+ * @short_description: memory region handling
+ *
+ * To allow for easy sharing of memory regions, #SwfdecBuffer was created. 
+ * Every buffer refers to a memory region and its size and takes care of 
+ * freeing that region when the buffer is no longer needed. They are 
+ * reference countedto make it easy to refer to the same region from various
+ * independant parts of your code. Buffers also support some advanced 
+ * functionalities like extracting parts of the buffer using 
+ * swfdec_buffer_new_subbuffer() or using mmapped files with 
+ * swfdec_buffer_new_from_file() without the need for a different API.
+ *
+ * A #SwfdecBufferQueue is a queue of continuous buffers that allows reading
+ * its data in chunks of pre-defined sizes. It is used to transform a data 
+ * stream that was provided by buffers of random sizes to buffers of the right
+ * size.
+ */
 
+/*** SwfdecBuffer ***/
+
+/**
+ * swfdec_buffer_new:
+ *
+ * Creates a new #SwfdecBuffer to be filled by the user. Use like this:
+ * <informalexample><programlisting>SwfdecBuffer *buffer = swfdec_buffer_new ();
+ * buffer->data = mydata;
+ * buffer->length = mydata_length;
+ * buffer->free = mydata_freefunc;</programlisting></informalexample>
+ *
+ * Returns: a new #SwfdecBuffer referencing nothing.
+ **/
 SwfdecBuffer *
 swfdec_buffer_new (void)
 {
@@ -43,6 +74,21 @@ swfdec_buffer_new (void)
   return buffer;
 }
 
+static void
+swfdec_buffer_free_mem (SwfdecBuffer * buffer, void *priv)
+{
+  g_free (buffer->data);
+}
+
+/**
+ * swfdec_buffer_new_and_alloc:
+ * @size: amount of bytes to allocate
+ *
+ * Creates a new buffer and allocates new memory of @size bytes to be used with 
+ * the buffer.
+ *
+ * Returns: a new #SwfdecBuffer with buffer->data pointing to new data
+ **/
 SwfdecBuffer *
 swfdec_buffer_new_and_alloc (unsigned int size)
 {
@@ -55,6 +101,15 @@ swfdec_buffer_new_and_alloc (unsigned in
   return buffer;
 }
 
+/**
+ * swfdec_buffer_new_and_alloc0:
+ * @size: amount of bytes to allocate
+ *
+ * Createsa new buffer just like swfdec_buffer_new_and_alloc(), but ensures 
+ * that the returned data gets initialized to be 0.
+ *
+ * Returns: a new #SwfdecBuffer with buffer->data pointing to new data
+ **/
 SwfdecBuffer *
 swfdec_buffer_new_and_alloc0 (unsigned int size)
 {
@@ -67,11 +122,24 @@ swfdec_buffer_new_and_alloc0 (unsigned i
   return buffer;
 }
 
+/**
+ * swfdec_buffer_new_for_data:
+ * @data: memory region allocated with g_malloc()
+ * @size: size of @data in bytes
+ *
+ * Takes ownership of @data and creates a new buffer managing it.
+ *
+ * Returns: a new #SwfdecBuffer pointing to @data
+ **/
 SwfdecBuffer *
-swfdec_buffer_new_with_data (void *data, int size)
+swfdec_buffer_new_for_data (unsigned char *data, unsigned int size)
 {
-  SwfdecBuffer *buffer = swfdec_buffer_new ();
+  SwfdecBuffer *buffer;
+  
+  g_return_val_if_fail (data != NULL, NULL);
+  g_return_val_if_fail (size > 0, NULL);
 
+  buffer = swfdec_buffer_new ();
   buffer->data = data;
   buffer->length = size;
   buffer->free = swfdec_buffer_free_mem;
@@ -79,11 +147,29 @@ swfdec_buffer_new_with_data (void *data,
   return buffer;
 }
 
+static void
+swfdec_buffer_free_subbuffer (SwfdecBuffer * buffer, void *priv)
+{
+  swfdec_buffer_unref (buffer->parent);
+}
+
+/**
+ * swfdec_buffer_new_subbuffer:
+ * @buffer: #SwfdecBuffer managing the region of memory
+ * @offset: starting offset into data
+ * @length: amount of bytes to manage
+ *
+ * Creates a #SwfdecBuffer for managing a partial section of the memory pointed
+ * to by @buffer.
+ *
+ * Returns: a new #SwfdecBuffer managing the indicated region.
+ **/
 SwfdecBuffer *
 swfdec_buffer_new_subbuffer (SwfdecBuffer * buffer, unsigned int offset, unsigned int length)
 {
   SwfdecBuffer *subbuffer;
   
+  g_return_val_if_fail (buffer != NULL, NULL);
   g_return_val_if_fail (offset + length <= buffer->length, NULL);
 
   subbuffer = swfdec_buffer_new ();
@@ -95,6 +181,7 @@ swfdec_buffer_new_subbuffer (SwfdecBuffe
     swfdec_buffer_ref (buffer);
     subbuffer->parent = buffer;
   }
+  g_assert (subbuffer->parent->parent == NULL);
   subbuffer->data = buffer->data + offset;
   subbuffer->length = length;
   subbuffer->free = swfdec_buffer_free_subbuffer;
@@ -108,6 +195,17 @@ swfdec_buffer_free_mapped (SwfdecBuffer 
   g_mapped_file_free (priv);
 }
 
+/**
+ * swfdec_buffer_new_from_file:
+ * @filename: file to read
+ * @error: return location for a #GError or %NULL
+ *
+ * Tries to create a buffer for the given @filename using a #GMappedFile. If
+ * the creation fails, %NULL is returned and @error is set. The error can be
+ * any of the errors that are valid from g_mapped_file_new().
+ *
+ * Returns: a new #SwfdecBuffer or %NULL on failure
+ **/
 SwfdecBuffer *
 swfdec_buffer_new_from_file (const char *filename, GError **error)
 {
@@ -130,16 +228,37 @@ swfdec_buffer_new_from_file (const char 
   return buffer;
 }
 
+/**
+ * swfdec_buffer_ref:
+ * @buffer: a #SwfdecBuffer
+ *
+ * increases the reference count of @buffer by one.
+ *
+ * Returns: The passed in @buffer.
+ **/
 SwfdecBuffer *
 swfdec_buffer_ref (SwfdecBuffer * buffer)
 {
+  g_return_val_if_fail (buffer != NULL, NULL);
+  g_return_val_if_fail (buffer->ref_count > 0, NULL);
+
   buffer->ref_count++;
   return buffer;
 }
 
+/**
+ * swfdec_buffer_unref:
+ * @buffer: a #SwfdecBuffer
+ *
+ * Decreases the reference count of @buffer by one. If no reference to this
+ * buffer exists anymore, the buffer and the memory it manages are freed.
+ **/
 void
 swfdec_buffer_unref (SwfdecBuffer * buffer)
 {
+  g_return_if_fail (buffer != NULL);
+  g_return_if_fail (buffer->ref_count > 0);
+
   buffer->ref_count--;
   if (buffer->ref_count == 0) {
     if (buffer->free)
@@ -148,18 +267,7 @@ swfdec_buffer_unref (SwfdecBuffer * buff
   }
 }
 
-static void
-swfdec_buffer_free_mem (SwfdecBuffer * buffer, void *priv)
-{
-  g_free (buffer->data);
-}
-
-static void
-swfdec_buffer_free_subbuffer (SwfdecBuffer * buffer, void *priv)
-{
-  swfdec_buffer_unref (buffer->parent);
-}
-
+/*** SwfdecBuffer ***/
 
 SwfdecBufferQueue *
 swfdec_buffer_queue_new (void)


More information about the Swfdec mailing list