summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2011-10-26 12:33:43 +0200
committerMurray Cumming <murrayc@murrayc.com>2011-10-26 12:33:43 +0200
commita7588ae238134222cc193488e5447b86550ccf66 (patch)
tree1b7cffd86a5b633b30beaeb009a3e827cf877be1
parentc97f8e8681e550ebe09af9ac5a366273b6d98673 (diff)
downloadglibmm-a7588ae238134222cc193488e5447b86550ccf66.tar.gz
thread.h: Allow use of this without causing deprecation compiler warnings.
* glib/src/thread.hg: undef and then redefine G_DISABLE_DEPRECATED, and define GLIB_DISABLE_DEPRECATION_WARNINGS, if G_DISABLE_DEPRECATED is defined, so we can use the deprecated API in this header (though only in our own deprecated API). * tools/generate_wrap_init.pl.in: Include glibmm.h instead of glib.h so we can include thread.h first (via glibmm.h) instead of only later. This seems more logical than explicitly including thread.h in all (even non-glibmm) generated wrap_init.cc files. * tools/m4/base.m4: * glib/glibmm.h: * glib/glibmm/dispatcher.cc: * glib/glibmm/exceptionhandler.cc: * glib/glibmm/main.cc: * examples/thread/thread.cc: * examples/thread/threadpool.cc: Adjust the includes to include thread.h first.
-rw-r--r--ChangeLog23
-rw-r--r--examples/thread/thread.cc2
-rw-r--r--examples/thread/threadpool.cc2
-rw-r--r--glib/glibmm.h6
-rw-r--r--glib/glibmm/dispatcher.cc2
-rw-r--r--glib/glibmm/exceptionhandler.cc2
-rw-r--r--glib/glibmm/main.cc4
-rw-r--r--glib/src/thread.hg27
-rw-r--r--tools/generate_wrap_init.pl.in2
-rw-r--r--tools/m4/base.m43
10 files changed, 64 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 99ac8704..eba65981 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
2011-10-26 Murray Cumming <murrayc@murrayc.com>
+ thread.h: Allow use of this without causing deprecation compiler warnings.
+
+ * glib/src/thread.hg: undef and then redefine G_DISABLE_DEPRECATED, and
+ define GLIB_DISABLE_DEPRECATION_WARNINGS, if G_DISABLE_DEPRECATED is
+ defined, so we can use the deprecated API in this header (though only in
+ our own deprecated API).
+
+ * tools/generate_wrap_init.pl.in: Include glibmm.h instead of glib.h so
+ we can include thread.h first (via glibmm.h) instead of only later.
+ This seems more logical than explicitly including thread.h in all
+ (even non-glibmm) generated wrap_init.cc files.
+
+ * tools/m4/base.m4:
+ * glib/glibmm.h:
+ * glib/glibmm/dispatcher.cc:
+ * glib/glibmm/exceptionhandler.cc:
+ * glib/glibmm/main.cc:
+ * examples/thread/thread.cc:
+ * examples/thread/threadpool.cc: Adjust the includes to include thread.h
+ first.
+
+2011-10-26 Murray Cumming <murrayc@murrayc.com>
+
Move IOCondition from main.h to iochannel.h and autogenerate it.
* glib/src/iochannel.hg: Use _WRAP_ENUM() for IOCondition instead of
diff --git a/examples/thread/thread.cc b/examples/thread/thread.cc
index d1882069..1e26430e 100644
--- a/examples/thread/thread.cc
+++ b/examples/thread/thread.cc
@@ -1,8 +1,8 @@
#include <iostream>
#include <queue>
-#include <glibmm/random.h>
#include <glibmm/thread.h>
+#include <glibmm/random.h>
#include <glibmm/timer.h>
diff --git a/examples/thread/threadpool.cc b/examples/thread/threadpool.cc
index 8b36277d..542c5243 100644
--- a/examples/thread/threadpool.cc
+++ b/examples/thread/threadpool.cc
@@ -1,7 +1,7 @@
#include <iostream>
-#include <glibmm/random.h>
#include <glibmm/thread.h>
+#include <glibmm/random.h>
#include <glibmm/threadpool.h>
#include <glibmm/timer.h>
diff --git a/glib/glibmm.h b/glib/glibmm.h
index 4626fa2e..7cc5ad5c 100644
--- a/glib/glibmm.h
+++ b/glib/glibmm.h
@@ -81,6 +81,11 @@
#include <glibmmconfig.h>
//#include <glibmm/i18n.h> //This must be included by the application, after system headers such as <iostream>.
+
+//Include this first because we need it to be the first thing to include <glib.h>,
+//so we can do an undef trick to still use deprecated API in the header:
+#include <glibmm/thread.h>
+
#include <glibmm/arrayhandle.h>
#include <glibmm/balancedtree.h>
#include <glibmm/checksum.h>
@@ -122,7 +127,6 @@
#include <glibmm/slisthandle.h>
#include <glibmm/spawn.h>
#include <glibmm/stringutils.h>
-#include <glibmm/thread.h>
#include <glibmm/threadpool.h>
#include <glibmm/timer.h>
#include <glibmm/timeval.h>
diff --git a/glib/glibmm/dispatcher.cc b/glib/glibmm/dispatcher.cc
index 3a74591a..1be104eb 100644
--- a/glib/glibmm/dispatcher.cc
+++ b/glib/glibmm/dispatcher.cc
@@ -18,11 +18,11 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <glibmm/thread.h>
#include <glibmm/dispatcher.h>
#include <glibmm/exceptionhandler.h>
#include <glibmm/fileutils.h>
#include <glibmm/main.h>
-#include <glibmm/thread.h>
#include <cerrno>
#include <fcntl.h>
diff --git a/glib/glibmm/exceptionhandler.cc b/glib/glibmm/exceptionhandler.cc
index e9bec1a4..79f1a81c 100644
--- a/glib/glibmm/exceptionhandler.cc
+++ b/glib/glibmm/exceptionhandler.cc
@@ -20,9 +20,9 @@
*/
#include <glibmmconfig.h>
+#include <glibmm/thread.h>
#include <glibmm/error.h>
#include <glibmm/exceptionhandler.h>
-#include <glibmm/thread.h>
#include <glib.h>
#include <exception>
#include <list>
diff --git a/glib/glibmm/main.cc b/glib/glibmm/main.cc
index cf19d11c..a675ee6d 100644
--- a/glib/glibmm/main.cc
+++ b/glib/glibmm/main.cc
@@ -18,10 +18,12 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <glibmm/thread.h>
+
#undef G_DISABLE_DEPRECATED //So we can use newly-deprecated API, to preserve our API.
+
#include <glibmm/main.h>
#include <glibmm/exceptionhandler.h>
-#include <glibmm/thread.h>
#include <glibmm/wrap.h>
#include <glibmm/iochannel.h>
#include <algorithm>
diff --git a/glib/src/thread.hg b/glib/src/thread.hg
index 85e66f25..ed612a70 100644
--- a/glib/src/thread.hg
+++ b/glib/src/thread.hg
@@ -18,10 +18,35 @@
_DEFS(glibmm,glib)
#include <glibmmconfig.h>
+
+// We use GThreadFunctions in the (deprecated) API, so we must temporarily undef G_DISABLE_DEPRECATED.
+// Temporarily undef G_DISABLE_DEPRECATED, redefining it later if appropriate.
+#if defined(G_DISABLE_DEPRECATED) && !defined(GLIBMM_G_DISABLE_DEPRECATED_UNDEFED)
+
+//Stop the deprecation ifdef guards around the API declarations:
+#undef G_DISABLE_DEPRECATED
+
+//Stop the compiler warnings about using the deprecated API;
+#define GLIB_DISABLE_DEPRECATION_WARNINGS 1
+
+#define GLIBMM_G_DISABLE_DEPRECATED_UNDEFED 1
+
+#endif
+
+#include <glib.h>
+
+// Redefine G_DISABLE_DEPRECATED if it was defined before we temporarily undefed it:
+#if defined(GLIBMM_G_DISABLE_DEPRECATED_UNDEFED)
+#define G_DISABLE_DEPRECATED 1
+#undef GLIB_DISABLE_DEPRECATION_WARNINGS
+#undef GLIBMM_G_DISABLE_DEPRECATED_UNDEFED
+#endif
+
+
#include <glibmm/error.h>
#include <glibmm/timeval.h>
#include <sigc++/sigc++.h>
-#include <glib.h>
+
#include <cstddef>
/* Shadow THREAD_PRIORITY_NORMAL macro (from winbase.h).
diff --git a/tools/generate_wrap_init.pl.in b/tools/generate_wrap_init.pl.in
index 2d409c84..89f9165d 100644
--- a/tools/generate_wrap_init.pl.in
+++ b/tools/generate_wrap_init.pl.in
@@ -195,7 +195,7 @@ while ($ARGV[0])
print << "EOF";
-#include <glib.h>
+#include <glibmm.h>
// Disable the 'const' function attribute of the get_type() functions.
// GCC would optimize them out because we don't use the return value.
diff --git a/tools/m4/base.m4 b/tools/m4/base.m4
index 6594aa2a..68431253 100644
--- a/tools/m4/base.m4
+++ b/tools/m4/base.m4
@@ -311,11 +311,12 @@ _IMPORT(SECTION_CC_PRE_INCLUDES)
_DEPRECATE_IFDEF_CLASS_START
+#include <glibmm.h>
+
#include <__MODULE__/__FILE__.h>
#include <__MODULE__/private/__FILE__`'_p.h>
_IMPORT(SECTION_CC_INCLUDES)
-#include <glibmm.h>
_IMPORT(SECTION_SRC_CUSTOM)