Enforcing #include <glib-gobject.h>
- From: Owen Taylor <otaylor redhat com>
- To: timj gtk org
- Cc: gtk-devel-list gnome org
- Subject: Enforcing #include <glib-gobject.h>
- Date: 17 Nov 2001 14:26:11 -0500
Here's my attempt at making including any include of a
gobject include file directly (not through glib-object.h)
die with an #error, thus enforcing the existing policy.
The only tricky part was gvaluecollector.h -- currently
you have to include glib-object.h _then_ gvaluecollector.h.
Believing that forcing includes to be ordered in a certain
way is evil, I think there are only two possibilities:
A) Include gvaluecollector.h from glib-object.h
B) Make gvaluecollector.h pull in glib-object.h
The patch below implements B).
Regards,
Owen
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/glib/ChangeLog,v
retrieving revision 1.932
diff -u -p -r1.932 ChangeLog
--- ChangeLog 2001/11/15 23:03:20 1.932
+++ ChangeLog 2001/11/17 19:17:11
@@ -1,3 +1,17 @@
+Sat Nov 17 14:10:35 2001 Owen Taylor <otaylor redhat com>
+
+ * glib/gbsearcharray.h: Include gtypes.h not gobject/gtype.h
+
+ * glib/glib-object.h gobject/*.h: Prevent headers from
+ being included directly except when compiling GObject.
+
+ * glib/gvaluecollector.h: Include glib-object.h so that
+ this file can be included directly, since we don't
+ include it _from_ glib-object.h.
+
+ * glib/gtype.c: Remove hack since we now simply inclue
+ glib/gvaluecollector.h.
+
2001-11-15 Matthias Clasen <matthiasc poet de>
* glib/giochannel.c: Documentation fixes.
Index: glib/gbsearcharray.h
===================================================================
RCS file: /cvs/gnome/glib/glib/gbsearcharray.h,v
retrieving revision 1.6
diff -u -p -r1.6 gbsearcharray.h
--- glib/gbsearcharray.h 2001/06/19 12:13:22 1.6
+++ glib/gbsearcharray.h 2001/11/17 19:17:11
@@ -21,7 +21,10 @@
#ifndef __G_BSEARCH_ARRAY_H__
#define __G_BSEARCH_ARRAY_H__
-#include <gobject/gtype.h>
+#include <glib/gtypes.h>
+#include <glib/gutils.h>
+#include <glib/gmem.h>
+#include <glib/gmessages.h>
G_BEGIN_DECLS
Index: glib/glib-object.h
===================================================================
RCS file: /cvs/gnome/glib/glib/glib-object.h,v
retrieving revision 1.8
diff -u -p -r1.8 glib-object.h
--- glib/glib-object.h 2001/09/08 18:23:04 1.8
+++ glib/glib-object.h 2001/11/17 19:17:11
@@ -19,6 +19,8 @@
#ifndef __GLIB_GOBJECT_H__
#define __GLIB_GOBJECT_H__
+#define __GLIB_GOBJECT_H_INSIDE__
+
/* topmost include file for GObject header files */
#include <gobject/gboxed.h>
#include <gobject/genums.h>
@@ -34,5 +36,6 @@
#include <gobject/gvaluearray.h>
#include <gobject/gvaluetypes.h>
+#undef __GLIB_GOBJECT_H_INSIDE__
#endif /* __GLIB_GOBJECT_H__ */
Index: gobject/Makefile.am
===================================================================
RCS file: /cvs/gnome/glib/gobject/Makefile.am,v
retrieving revision 1.43
diff -u -p -r1.43 Makefile.am
--- gobject/Makefile.am 2001/11/14 03:02:21 1.43
+++ gobject/Makefile.am 2001/11/17 19:17:11
@@ -9,6 +9,7 @@ INCLUDES = @STRIP_BEGIN@ \
-I$(top_srcdir)/glib \
-I$(top_builddir) \
@GLIB_DEBUG_FLAGS@ \
+ -DGOBJECT_COMPILATION \
-DG_DISABLE_CONST_RETURNS \
@STRIP_END@
Index: gobject/gboxed.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gboxed.h,v
retrieving revision 1.8
diff -u -p -r1.8 gboxed.h
--- gobject/gboxed.h 2001/11/14 03:02:21 1.8
+++ gobject/gboxed.h 2001/11/17 19:17:11
@@ -19,6 +19,10 @@
#ifndef __G_BOXED_H__
#define __G_BOXED_H__
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
+
#include <gobject/gtype.h>
G_BEGIN_DECLS
Index: gobject/gclosure.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gclosure.h,v
retrieving revision 1.11
diff -u -p -r1.11 gclosure.h
--- gobject/gclosure.h 2001/11/14 03:02:21 1.11
+++ gobject/gclosure.h 2001/11/17 19:17:14
@@ -19,6 +19,9 @@
#ifndef __G_CLOSURE_H__
#define __G_CLOSURE_H__
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
#include <gobject/gtype.h>
Index: gobject/genums.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/genums.h,v
retrieving revision 1.8
diff -u -p -r1.8 genums.h
--- gobject/genums.h 2001/03/09 21:39:50 1.8
+++ gobject/genums.h 2001/11/17 19:17:14
@@ -19,6 +19,10 @@
#ifndef __G_ENUMS_H__
#define __G_ENUMS_H__
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
+
#include <gobject/gtype.h>
G_BEGIN_DECLS
Index: gobject/gobject.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gobject.h,v
retrieving revision 1.20
diff -u -p -r1.20 gobject.h
--- gobject/gobject.h 2001/11/05 17:58:43 1.20
+++ gobject/gobject.h 2001/11/17 19:17:14
@@ -19,6 +19,10 @@
#ifndef __G_OBJECT_H__
#define __G_OBJECT_H__
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
+
#include <gobject/gtype.h>
#include <gobject/gvalue.h>
#include <gobject/gparam.h>
Index: gobject/gparam.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gparam.h,v
retrieving revision 1.18
diff -u -p -r1.18 gparam.h
--- gobject/gparam.h 2001/11/14 03:02:21 1.18
+++ gobject/gparam.h 2001/11/17 19:17:15
@@ -21,6 +21,9 @@
#ifndef __G_PARAM_H__
#define __G_PARAM_H__
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
#include <gobject/gvalue.h>
Index: gobject/gparamspecs.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gparamspecs.h,v
retrieving revision 1.17
diff -u -p -r1.17 gparamspecs.h
--- gobject/gparamspecs.h 2001/11/14 03:02:21 1.17
+++ gobject/gparamspecs.h 2001/11/17 19:17:15
@@ -21,6 +21,9 @@
#ifndef __G_PARAMSPECS_H__
#define __G_PARAMSPECS_H__
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
#include <gobject/gvalue.h>
#include <gobject/genums.h>
Index: gobject/gsignal.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gsignal.h,v
retrieving revision 1.27
diff -u -p -r1.27 gsignal.h
--- gobject/gsignal.h 2001/11/14 03:02:22 1.27
+++ gobject/gsignal.h 2001/11/17 19:17:15
@@ -19,6 +19,9 @@
#ifndef __G_SIGNAL_H__
#define __G_SIGNAL_H__
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
#include <gobject/gclosure.h>
#include <gobject/gvalue.h>
Index: gobject/gsourceclosure.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gsourceclosure.h,v
retrieving revision 1.1
diff -u -p -r1.1 gsourceclosure.h
--- gobject/gsourceclosure.h 2001/09/03 22:13:16 1.1
+++ gobject/gsourceclosure.h 2001/11/17 19:17:15
@@ -19,6 +19,10 @@
#ifndef __G_SOURCECLOSURE_H__
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
+
#include <gobject/gclosure.h>
G_BEGIN_DECLS
Index: gobject/gtype.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gtype.c,v
retrieving revision 1.37
diff -u -p -r1.37 gtype.c
--- gobject/gtype.c 2001/11/14 03:02:22 1.37
+++ gobject/gtype.c 2001/11/17 19:17:50
@@ -137,10 +137,6 @@ static IFaceHolder* type_iface_peek_ho
/* --- structures --- */
-struct _GValue /* kludge, keep in sync with gvalue.h */
-{
- GType g_type;
-};
struct _TypeNode
{
GTypePlugin *plugin;
Index: gobject/gtype.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gtype.h,v
retrieving revision 1.35
diff -u -p -r1.35 gtype.h
--- gobject/gtype.h 2001/11/14 03:02:22 1.35
+++ gobject/gtype.h 2001/11/17 19:17:50
@@ -19,6 +19,10 @@
#ifndef __G_TYPE_H__
#define __G_TYPE_H__
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
+
#include <glib.h>
G_BEGIN_DECLS
Index: gobject/gtypemodule.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gtypemodule.h,v
retrieving revision 1.1
diff -u -p -r1.1 gtypemodule.h
--- gobject/gtypemodule.h 2000/11/11 06:46:30 1.1
+++ gobject/gtypemodule.h 2001/11/17 19:17:50
@@ -20,6 +20,10 @@
#ifndef __G_TYPE_MODULE_H__
#define __G_TYPE_MODULE_H__
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
+
#include <gobject/gobject.h>
G_BEGIN_DECLS
Index: gobject/gtypeplugin.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gtypeplugin.h,v
retrieving revision 1.2
diff -u -p -r1.2 gtypeplugin.h
--- gobject/gtypeplugin.h 2001/03/09 21:39:51 1.2
+++ gobject/gtypeplugin.h 2001/11/17 19:17:50
@@ -19,6 +19,9 @@
#ifndef __G_TYPE_PLUGIN_H__
#define __G_TYPE_PLUGIN_H__
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
#include <gobject/gtype.h>
Index: gobject/gvalue.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvalue.h,v
retrieving revision 1.12
diff -u -p -r1.12 gvalue.h
--- gobject/gvalue.h 2001/10/11 02:43:04 1.12
+++ gobject/gvalue.h 2001/11/17 19:17:50
@@ -21,6 +21,9 @@
#ifndef __G_VALUE_H__
#define __G_VALUE_H__
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
#include <gobject/gtype.h>
Index: gobject/gvaluearray.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvaluearray.h,v
retrieving revision 1.2
diff -u -p -r1.2 gvaluearray.h
--- gobject/gvaluearray.h 2001/08/12 00:55:38 1.2
+++ gobject/gvaluearray.h 2001/11/17 19:17:50
@@ -21,6 +21,9 @@
#ifndef __G_VALUE_ARRAY_H__
#define __G_VALUE_ARRAY_H__
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
#include <gobject/gvalue.h>
Index: gobject/gvaluecollector.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvaluecollector.h,v
retrieving revision 1.9
diff -u -p -r1.9 gvaluecollector.h
--- gobject/gvaluecollector.h 2001/10/12 16:42:48 1.9
+++ gobject/gvaluecollector.h 2001/11/17 19:17:50
@@ -21,6 +21,8 @@
#ifndef __G_VALUE_COLLECTOR_H__
#define __G_VALUE_COLLECTOR_H__
+#include <glib-object.h>
+
G_BEGIN_DECLS
/* we may want to add aggregate types here some day, if requested
Index: gobject/gvaluetypes.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvaluetypes.h,v
retrieving revision 1.13
diff -u -p -r1.13 gvaluetypes.h
--- gobject/gvaluetypes.h 2001/11/04 19:02:10 1.13
+++ gobject/gvaluetypes.h 2001/11/17 19:17:50
@@ -21,6 +21,9 @@
#ifndef __G_VALUETYPES_H__
#define __G_VALUETYPES_H__
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
#include <gobject/gvalue.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]