[gjs] headers: Require single include, don't warn for internal uses



commit 2621b7ed11d36cdae16f3820ea871526f53318a9
Author: Colin Walters <walters verbum org>
Date:   Thu Sep 16 16:37:47 2010 -0400

    headers: Require single include, don't warn for internal uses
    
    The previous approach of "Warn when including an individual header"
    is obviously lame, since the warnings weren't being fixed.
    
    The better way here is to do what all the rest of the G stack does;
    disallow single includes externally, allow them internally via a
    GJS_COMPILATION flag.

 Makefile-gi.am      |    1 +
 Makefile-modules.am |    1 +
 Makefile.am         |    3 ++-
 gjs/byteArray.h     |    4 ++++
 gjs/context.h       |    4 ++--
 gjs/importer.h      |    4 ++--
 gjs/jsapi-util.h    |    4 ++--
 gjs/mem.h           |    4 ++--
 gjs/native.h        |    4 ++--
 9 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/Makefile-gi.am b/Makefile-gi.am
index 1d2b3d2..61d2864 100644
--- a/Makefile-gi.am
+++ b/Makefile-gi.am
@@ -4,6 +4,7 @@ lib_LTLIBRARIES += libgjs-gi.la
 
 libgjs_gi_la_CFLAGS =			\
         $(AM_CFLAGS)			\
+	-DGJS_COMPILATION		\
         $(GJS_GI_CFLAGS)
 libgjs_gi_la_LIBADD =			\
         libgjs.la			\
diff --git a/Makefile-modules.am b/Makefile-modules.am
index 17ae1ca..c43b2d8 100644
--- a/Makefile-modules.am
+++ b/Makefile-modules.am
@@ -16,6 +16,7 @@ gjsnative_LTLIBRARIES += console.la debugger.la gi.la langNative.la mainloop.la
 
 JS_NATIVE_MODULE_CFLAGS =	\
         $(AM_CFLAGS)		\
+	-DGJS_COMPILATION	\
         $(GJS_CFLAGS)
 JS_NATIVE_MODULE_LIBADD =	\
         libgjs.la		\
diff --git a/Makefile.am b/Makefile.am
index 71e6a81..9b52b1c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -57,7 +57,8 @@ lib_LTLIBRARIES += libgjs.la
 libgjs_la_CPPFLAGS =		\
 	$(AM_CPPFLAGS)		\
 	$(GJS_CFLAGS)		\
-	$(gjs_directory_defines)
+	$(gjs_directory_defines)\
+	-DGJS_COMPILATION
 libgjs_la_CFLAGS = 		\
 	$(AM_CFLAGS)
 libgjs_la_LDFLAGS = 		\
diff --git a/gjs/byteArray.h b/gjs/byteArray.h
index 1ea0c2e..e0a8ae4 100644
--- a/gjs/byteArray.h
+++ b/gjs/byteArray.h
@@ -24,6 +24,10 @@
 #ifndef __GJS_BYTE_ARRAY_H__
 #define __GJS_BYTE_ARRAY_H__
 
+#if !defined (__GJS_GJS_H__) && !defined (GJS_COMPILATION)
+#error "Only <gjs/gjs.h> can be included directly."
+#endif
+
 #include <glib.h>
 
 #include <jsapi.h>
diff --git a/gjs/context.h b/gjs/context.h
index eba36e3..460d23a 100644
--- a/gjs/context.h
+++ b/gjs/context.h
@@ -24,8 +24,8 @@
 #ifndef __GJS_CONTEXT_H__
 #define __GJS_CONTEXT_H__
 
-#if !defined(__GJS_GJS_H__)
-#warning Include <gjs/gjs.h> instead of <gjs/context.h>
+#if !defined (__GJS_GJS_H__) && !defined (GJS_COMPILATION)
+#error "Only <gjs/gjs.h> can be included directly."
 #endif
 
 #include <glib-object.h>
diff --git a/gjs/importer.h b/gjs/importer.h
index ef71868..2bd99e0 100644
--- a/gjs/importer.h
+++ b/gjs/importer.h
@@ -24,8 +24,8 @@
 #ifndef __GJS_IMPORTER_H__
 #define __GJS_IMPORTER_H__
 
-#ifndef __GJS_GJS_H__
-#warning Include <gjs/gjs.h> instead of <gjs/importer.h>
+#if !defined (__GJS_GJS_H__) && !defined (GJS_COMPILATION)
+#error "Only <gjs/gjs.h> can be included directly."
 #endif
 
 #include <glib.h>
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index d451166..9921805 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -24,8 +24,8 @@
 #ifndef __GJS_JSAPI_UTIL_H__
 #define __GJS_JSAPI_UTIL_H__
 
-#ifndef __GJS_GJS_H__
-#warning Include <gjs/gjs.h> instead of <gjs/jsapi-util.h>
+#if !defined (__GJS_GJS_H__) && !defined (GJS_COMPILATION)
+#error "Only <gjs/gjs.h> can be included directly."
 #endif
 
 #include <jsapi.h>
diff --git a/gjs/mem.h b/gjs/mem.h
index f06befd..35c8f86 100644
--- a/gjs/mem.h
+++ b/gjs/mem.h
@@ -24,8 +24,8 @@
 #ifndef __GJS_MEM_H__
 #define __GJS_MEM_H__
 
-#ifndef __GJS_GJS_H__
-#warning Include <gjs/gjs.h> instead of <gjs/mem.h>
+#if !defined (__GJS_GJS_H__) && !defined (GJS_COMPILATION)
+#error "Only <gjs/gjs.h> can be included directly."
 #endif
 
 #include <glib.h>
diff --git a/gjs/native.h b/gjs/native.h
index a1fa21c..7d9d9fb 100644
--- a/gjs/native.h
+++ b/gjs/native.h
@@ -24,8 +24,8 @@
 #ifndef __GJS_NATIVE_H__
 #define __GJS_NATIVE_H__
 
-#ifndef __GJS_GJS_H__
-#warning Include <gjs/gjs.h> instead of <gjs/native.h>
+#if !defined (__GJS_GJS_H__) && !defined (GJS_COMPILATION)
+#error "Only <gjs/gjs.h> can be included directly."
 #endif
 
 #include <glib.h>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]