Implement the same PLT reduction technique used in GTK+:
authorMatthias Clasen <mclasen@redhat.com>
Thu, 16 Sep 2004 18:52:40 +0000 (18:52 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 16 Sep 2004 18:52:40 +0000 (18:52 +0000)
2004-09-16  Matthias Clasen  <mclasen@redhat.com>

Implement the same PLT reduction technique used in GTK+:

* Makefile.am: Generate gobjectalias.h from gobject.symbols.
(BUILT_SOURCES): Add gobjectalias.h.

* makegobjectalias.pl: Script to generate gobjectalias.h.

* *.c: Include gobjectalias.h

18 files changed:
gobject/ChangeLog
gobject/Makefile.am
gobject/gboxed.c
gobject/gclosure.c
gobject/genums.c
gobject/gobject.c
gobject/gparam.c
gobject/gparamspecs.c
gobject/gsignal.c
gobject/gsourceclosure.c
gobject/gtype.c
gobject/gtypemodule.c
gobject/gtypeplugin.c
gobject/gvalue.c
gobject/gvaluearray.c
gobject/gvaluetransform.c
gobject/gvaluetypes.c
gobject/makegobjectalias.pl [new file with mode: 0755]

index 357b9e2..3b9e592 100644 (file)
@@ -1,12 +1,23 @@
 2004-09-16  Matthias Clasen  <mclasen@redhat.com>
 
+       Implement the same PLT reduction technique used in GTK+:
+
+       * Makefile.am: Generate gobjectalias.h from gobject.symbols.
+       (BUILT_SOURCES): Add gobjectalias.h.
+
+       * makegobjectalias.pl: Script to generate gobjectalias.h.
+
+       * *.c: Include gobjectalias.h
+
+2004-09-16  Matthias Clasen  <mclasen@redhat.com>
+
        Add ABI control using the same technique that is used in GTK+.
        
        * gobject.symbols: Master list of symbols.
 
        * gobject.def: Removed. It is now generated from gobject.symbols.
 
-       * Makefile.am (gobject.def): Generate from gobject.symbols.
+       * Makefile.am: Generate gobject.def from gobject.symbols.
        (TESTS): Add abicheck.sh
        (EXTRA_DIST): Add abicheck.sh
        (export_symbols): Don't export _-prefixed symbols.
index da2abf3..822aa68 100644 (file)
@@ -16,6 +16,9 @@ INCLUDES = \
 gobject.def: gobject.symbols
        (echo -e EXPORTS; cpp -P -DINCLUDE_VARIABLES -DINCLUDE_INTERNAL_SYMBOLS -DG_OS_WIN32 $(srcdir)/gobject.symbols | sed -e '/^$$/d' -e 's/^/\t/' | sort) > gobject.def
 
+gobjectalias.h: gobject.symbols
+       ./makegobjectalias.pl < $(srcdir)/gobject.symbols > gobjectalias.h
+
 if OS_UNIX
 TESTS = abicheck.sh
 endif
@@ -112,7 +115,7 @@ gobject_c_sources = \
        gvaluetypes.c
 
 # these sources (also mentioned above) are generated.
-BUILT_SOURCES = gmarshal.h gmarshal.c 
+BUILT_SOURCES = gmarshal.h gmarshal.c gobjectalias.h
 
 # non-header sources (headers should be specified in the above variables)
 # that don't serve as direct make target sources, i.e. they don't have
index 54a1b49..dc3339a 100644 (file)
@@ -16,6 +16,7 @@
  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  * Boston, MA 02111-1307, USA.
  */
+#include       "gobjectalias.h"
 #include       "gboxed.h"
 
 #include       "gbsearcharray.h"
@@ -108,7 +109,7 @@ gstring_free (gpointer boxed)
 }
 
 void
-g_boxed_type_init (void)  /* sync with gtype.c */
+g_boxed_type_init (void) 
 {
   static const GTypeInfo info = {
     0,                          /* class_size */
index 73f2b16..23299bf 100644 (file)
@@ -16,7 +16,7 @@
  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  * Boston, MA 02111-1307, USA.
  */
-
+#include       "gobjectalias.h"
 #include       "gclosure.h"
 
 #include       "gvalue.h"
index e0ecf5c..5bbc772 100644 (file)
@@ -23,6 +23,7 @@
 
 #include        <string.h>
 
+#include       "gobjectalias.h"
 #include       "genums.h"
 
 #include       "gvalue.h"
@@ -46,10 +47,9 @@ static gchar*        value_flags_enum_lcopy_value    (const GValue   *value,
                                                 GTypeCValue    *collect_values,
                                                 guint           collect_flags);
 
-
 /* --- functions --- */
 void
-g_enum_types_init (void)       /* sync with gtype.c */
+g_enum_types_init (void)
 {
   static gboolean initialized = FALSE;
   static const GTypeValueTable flags_enum_value_table = {
index e15ffdc..6429cdc 100644 (file)
@@ -16,6 +16,7 @@
  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  * Boston, MA 02111-1307, USA.
  */
+#include       "gobjectalias.h"
 #include       "gobject.h"
 
 /*
@@ -144,7 +145,7 @@ debug_objects_atexit (void)
 #endif /* G_ENABLE_DEBUG */
 
 void
-g_object_type_init (void)      /* sync with gtype.c */
+g_object_type_init (void)
 {
   static gboolean initialized = FALSE;
   static const GTypeFundamentalInfo finfo = {
index f2edcbb..282b8a4 100644 (file)
@@ -21,6 +21,7 @@
  * MT safe
  */
 
+#include       "gobjectalias.h"
 #include       "gparam.h"
 #include        "gparamspecs.h"
 
@@ -68,7 +69,7 @@ G_LOCK_DEFINE_STATIC (pspec_ref_count);
 
 /* --- functions --- */
 void
-g_param_type_init (void)       /* sync with gtype.c */
+g_param_type_init (void)
 {
   static const GTypeFundamentalInfo finfo = {
     (G_TYPE_FLAG_CLASSED |
index b4a71a3..7e40f7e 100644 (file)
@@ -23,6 +23,7 @@
 
 #include       "../config.h"
 
+#include       "gobjectalias.h"
 #include       "gparamspecs.h"
 
 #include       "gvaluecollector.h"
@@ -1019,7 +1020,7 @@ param_override_values_cmp (GParamSpec   *pspec,
 GType *g_param_spec_types = NULL;
 
 void
-g_param_spec_types_init (void) /* sync with gtype.c */
+g_param_spec_types_init (void) 
 {
   const guint n_types = 21;
   GType type, *spec_types, *spec_types_bound;
index 01b248d..9aa2dc3 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <config.h>
 
+#include       "gobjectalias.h"
 #include        "gsignal.h"
 #include        "gbsearcharray.h"
 #include        "gvaluecollector.h"
@@ -709,7 +710,7 @@ signal_key_cmp (gconstpointer node1,
 }
 
 void
-g_signal_init (void) /* sync with gtype.c */
+g_signal_init (void)
 {
   SIGNAL_LOCK ();
   if (!g_n_signal_nodes)
index 3db1317..7ff1680 100644 (file)
@@ -17,6 +17,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include "gobjectalias.h"
 #include "gsourceclosure.h"
 #include "gboxed.h"
 #include "genums.h"
index 9c50a51..6aaf87c 100644 (file)
@@ -17,6 +17,7 @@
  * Boston, MA 02111-1307, USA.
  */
 #include        <config.h>
+#include       "gobjectalias.h"
 #include       "gtype.h"
 
 /*
index 0c917c0..4ecb6ca 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <stdlib.h>
 
+#include "gobjectalias.h"
 #include "gtypeplugin.h"
 #include "gtypemodule.h"
 
index 5c4fcc0..99665cc 100644 (file)
@@ -16,6 +16,7 @@
  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  * Boston, MA 02111-1307, USA.
  */
+#include       "gobjectalias.h"
 #include       "gtypeplugin.h"
 
 
index 069f996..680122f 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <string.h>
 
+#include "gobjectalias.h"
 #include "gvalue.h"
 #include "gvaluecollector.h"
 #include "gbsearcharray.h"
@@ -52,7 +53,7 @@ static GBSearchConfig transform_bconfig = {
 
 /* --- functions --- */
 void
-g_value_c_init (void)  /* sync with gtype.c */
+g_value_c_init (void)
 {
   transform_array = g_bsearch_array_create (&transform_bconfig);
 }
index 9087242..54e0e11 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <config.h>
 
+#include       "gobjectalias.h"
 #include       "gvaluearray.h"
 #include       <string.h>
 #include       <stdlib.h>      /* qsort() */
index 20e473e..d4769fd 100644 (file)
@@ -18,6 +18,7 @@
  */
 #include        <string.h>
 
+#include       "gobjectalias.h"
 #include        "gvalue.h"
 #include        "genums.h"
 
@@ -242,7 +243,7 @@ value_transform_flags_string (const GValue *src_value,
 /* registration
  */
 void
-g_value_transforms_init (void)          /* sync with gtype.c */
+g_value_transforms_init (void)
 {
   /* some transformations are a bit questionable,
    * we currently skip those
index 4822786..3b73876 100644 (file)
@@ -21,6 +21,7 @@
  * MT safe
  */
 
+#include       "gobjectalias.h"
 #include       "gvaluetypes.h"
 
 #include       "gvaluecollector.h"
@@ -357,7 +358,7 @@ value_lcopy_pointer (const GValue *value,
 
 /* --- type initialization --- */
 void
-g_value_types_init (void)  /* sync with gtype.c */
+g_value_types_init (void)
 {
   GTypeInfo info = {
     0,                         /* class_size */
diff --git a/gobject/makegobjectalias.pl b/gobject/makegobjectalias.pl
new file mode 100755 (executable)
index 0000000..d115de2
--- /dev/null
@@ -0,0 +1,100 @@
+#!/usr/bin/perl -w
+
+print <<EOF;
+/* Generated by makegobjectalias.pl */
+
+#ifndef DISABLE_VISIBILITY
+
+#include "glibconfig.h"
+
+#ifdef G_HAVE_GNUC_VISIBILITY
+
+#ifdef  G_DISABLE_DEPRECATED
+#define WAS_NO_G_DEPR
+#endif
+#undef  G_DISABLE_DEPRECATED
+
+#include "glib-object.h"
+
+EOF
+
+my $in_comment = 0;
+my $in_skipped_section = 0;
+
+while (<>) {
+
+  # ignore empty lines
+  next if /^\s*$/;
+
+  # skip comments
+  if ($_ =~ /^\s*\/\*/)
+  {
+      $in_comment = 1;
+  }
+  
+  if ($in_comment)
+  {
+      if ($_ =~  /\*\/\s$/)
+      {
+         $in_comment = 0;
+      }
+      
+      next;
+  }
+
+  # handle ifdefs
+  if ($_ =~ /^\#endif/)
+  {
+      if (!$in_skipped_section)
+      {
+         print $_;
+      }
+
+      $in_skipped_section = 0;
+
+      next;
+  }
+
+  if ($_ =~ /^\#ifdef\s+(INCLUDE_VARIABLES|INCLUDE_INTERNAL_SYMBOLS)/)
+  {
+      $in_skipped_section = 1;
+  }
+
+  if ($in_skipped_section)
+  {
+      next;
+  }
+
+  if ($_ =~ /^\#ifdef\s+G/)
+  {
+      print $_;
+      
+      next;
+  }
+
+  my $str = $_;
+  chomp($str);
+  my $alias = "IA__".$str;
+  
+  print <<EOF
+extern __typeof ($str) $alias __attribute((visibility("hidden")));
+extern __typeof ($str) $str __attribute((alias("$alias"), visibility("default")));
+\#define $str $alias
+
+EOF
+}
+
+print <<EOF;
+
+#ifdef  WAS_NO_G_DEPR
+#define G_DISABLE_DEPRECATED
+#undef  WAS_NO_G_DEPR
+#endif
+
+#endif /* G_HAVE_GNUC_VISIBILITY */
+
+#endif /* DISABLE_VISIBILITY */
+EOF
+
+