[Swfdec-commits] 3 commits - .gitignore swfdec/Makefile.am swfdec/swfdec_as_context.c swfdec/swfdec_as_strings.c tools/swfdec-extract.c

Benjamin Otte company at kemper.freedesktop.org
Tue Nov 4 03:23:25 PST 2008


 .gitignore                 |    2 ++
 swfdec/Makefile.am         |   10 ++++++++--
 swfdec/swfdec_as_context.c |    6 +++---
 swfdec/swfdec_as_strings.c |    4 ++--
 tools/swfdec-extract.c     |    2 +-
 5 files changed, 16 insertions(+), 8 deletions(-)

New commits:
commit f65f33e54aa5e08b1b74eb7986e2ecb0b1357265
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Nov 4 12:14:25 2008 +0100

    mark variable as unused
    
    This gets around a compiler warning if the code gets compiled without
    PDF and SVG surfaces

diff --git a/tools/swfdec-extract.c b/tools/swfdec-extract.c
index 24d2578..b864fef 100644
--- a/tools/swfdec-extract.c
+++ b/tools/swfdec-extract.c
@@ -147,7 +147,7 @@ export_sprite_sound (SwfdecSprite *sprite, const char *filename)
 static cairo_surface_t *
 surface_create_for_filename (const char *filename, int width, int height)
 {
-  guint len = strlen (filename);
+  G_GNUC_UNUSED guint len = strlen (filename);
   cairo_surface_t *surface;
   if (FALSE) {
 #ifdef CAIRO_HAS_PDF_SURFACE
commit e0fc8d1ec0615fd4926eea65cf6e5baed3a5d5bf
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Nov 4 12:12:58 2008 +0100

    update gitignore

diff --git a/.gitignore b/.gitignore
index 255ce62..39e029b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+m4/
+
 *~
 .cvsignore
 INSTALL
commit a2d5da6737b20ee70accae7220c111a87301abc6
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Nov 4 12:10:18 2008 +0100

    make our constant strings have a static length
    
    - solves alignment issues on ARM
    - removes lots of ugly magic from the code
    - makes the binary slightly larger
    The code contains checks that makes sure we don't accidentally add
    strings that are too large. That will cause a gcc warning.

diff --git a/swfdec/Makefile.am b/swfdec/Makefile.am
index 47bfcfc..f384cdd 100644
--- a/swfdec/Makefile.am
+++ b/swfdec/Makefile.am
@@ -433,10 +433,16 @@ swfdec_as_strings.h: swfdec_as_strings.c
 	  && echo "#define _SWFDEC_AS_STRINGS_H_" \
 	  && echo "#include <swfdec/swfdec_as_types.h>" \
 	  && echo "G_BEGIN_DECLS" \
-	  && echo "extern const SwfdecAsStringValue swfdec_as_strings[];" \
+	  && echo "#define SWFDEC_AS_CONSTANT_STRING_LENGTH_MAX 40" \
+	  && echo "typedef struct {" \
+	  && echo "  SwfdecAsStringValue *	next;" \
+	  && echo "  gsize			length;" \
+	  && echo "  char			string[SWFDEC_AS_CONSTANT_STRING_LENGTH_MAX];" \
+	  && echo "} SwfdecAsConstantStringValue;" \
+	  && echo "extern const SwfdecAsConstantStringValue swfdec_as_strings[];" \
 	  && grep "  SWFDEC_AS_CONSTANT_STRING" swfdec_as_strings.c \
 	  | sed "s/.*(\"\(.*\)\").*/\1/" \
-	  | LC_ALL="C" $(AWK) '{ if ($$0 == "") name = "EMPTY"; else if ($$0 == ",") name = "COMMA"; else if ($$0 == "/") name = "SLASH"; else name = $$0; gsub("[^a-zA-Z0-9]","_",name); print "#define SWFDEC_AS_STR_" name " (((SwfdecAsStringValue *) &((guint8 *) swfdec_as_strings)[" (x + 0) " * sizeof (SwfdecAsStringValue) + " (y + 0) "])->string)"; x = x + 1; y = y + length ($$0) + 1 }' \
+	  | LC_ALL="C" $(AWK) '{ if ($$0 == "") name = "EMPTY"; else if ($$0 == ",") name = "COMMA"; else if ($$0 == "/") name = "SLASH"; else name = $$0; gsub("[^a-zA-Z0-9]","_",name); print "#define SWFDEC_AS_STR_" name " (((SwfdecAsStringValue *) &swfdec_as_strings[" (x + 0) "])->string)"; x = x + 1; }' \
 	  && echo "G_END_DECLS" \
 	  && echo "#endif" ) > xgen-sas \
 	&& (cmp -s xgen-sas swfdec_as_strings.h || cp xgen-sas swfdec_as_strings.h ) \
diff --git a/swfdec/swfdec_as_context.c b/swfdec/swfdec_as_context.c
index 61af6b2..9f81253 100644
--- a/swfdec/swfdec_as_context.c
+++ b/swfdec/swfdec_as_context.c
@@ -579,7 +579,7 @@ swfdec_as_context_class_init (SwfdecAsContextClass *klass)
 static void
 swfdec_as_context_init (SwfdecAsContext *context)
 {
-  const SwfdecAsStringValue *s;
+  const SwfdecAsConstantStringValue *s;
 
   context->version = G_MAXUINT;
 
@@ -587,9 +587,9 @@ swfdec_as_context_init (SwfdecAsContext *context)
   context->objects = g_hash_table_new (g_direct_hash, g_direct_equal);
   context->constant_pools = g_hash_table_new (g_direct_hash, g_direct_equal);
 
-  for (s = swfdec_as_strings; s->next; s = (const SwfdecAsStringValue *) 
-      ((const guint8 *) (s + 1) + s->length + 1)) {
+  for (s = swfdec_as_strings; s->next; s++) {
     g_hash_table_insert (context->interned_strings, (gpointer) s->string, (gpointer) s);
+    g_print ("%s\n", s->string);
   }
   context->rand = g_rand_new ();
   g_get_current_time (&context->start_time);
diff --git a/swfdec/swfdec_as_strings.c b/swfdec/swfdec_as_strings.c
index 2d9eede..699a945 100644
--- a/swfdec/swfdec_as_strings.c
+++ b/swfdec/swfdec_as_strings.c
@@ -26,8 +26,8 @@
 #include "swfdec_as_gcable.h"
 
 
-#define SWFDEC_AS_CONSTANT_STRING(str) { GSIZE_TO_POINTER (SWFDEC_AS_GC_ROOT), sizeof (str) - 1, str },
-const SwfdecAsStringValue swfdec_as_strings[] = {
+#define SWFDEC_AS_CONSTANT_STRING(str) { GSIZE_TO_POINTER (SWFDEC_AS_GC_ROOT), sizeof (str) - 1, str "\0" },
+const SwfdecAsConstantStringValue swfdec_as_strings[] = {
   SWFDEC_AS_CONSTANT_STRING ("")
   SWFDEC_AS_CONSTANT_STRING ("__proto__")
   SWFDEC_AS_CONSTANT_STRING ("this")


More information about the Swfdec-commits mailing list