From d1c9eb458c843215da8df84b596bfae51fee135b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 12 Apr 2012 13:17:44 -0400 Subject: [PATCH] Make it an error to include non-top-level headers Users should #include (or hb-ft.h, hb-glib.h, etc), but never things like hb-shape.h directly. This makes it easier to refactor headers later on without breaking compatibility. --- src/hb-blob.h | 4 ++++ src/hb-buffer.h | 4 ++++ src/hb-common.h | 4 ++++ src/hb-font.h | 4 ++++ src/hb-ft.h | 2 -- src/hb-glib.h | 1 + src/hb-gobject.h | 1 + src/hb-graphite2.h | 5 +++-- src/hb-icu.h | 1 + src/hb-ot-layout.h | 8 +++++--- src/hb-ot-shape.h | 9 +++++---- src/hb-ot-tag.h | 6 +++++- src/hb-ot.h | 2 ++ src/hb-private.hh | 5 ++++- src/hb-shape.h | 4 ++++ src/hb-unicode.h | 4 ++++ src/hb-uniscribe.h | 3 +-- src/hb-version.h.in | 4 ++++ src/hb.h | 2 ++ 19 files changed, 58 insertions(+), 15 deletions(-) diff --git a/src/hb-blob.h b/src/hb-blob.h index 50c9ae3b..360310b4 100644 --- a/src/hb-blob.h +++ b/src/hb-blob.h @@ -24,6 +24,10 @@ * Red Hat Author(s): Behdad Esfahbod */ +#ifndef HB_H_IN +#error "Include instead." +#endif + #ifndef HB_BLOB_H #define HB_BLOB_H diff --git a/src/hb-buffer.h b/src/hb-buffer.h index 9582ebee..ca1bbf47 100644 --- a/src/hb-buffer.h +++ b/src/hb-buffer.h @@ -27,6 +27,10 @@ * Google Author(s): Behdad Esfahbod */ +#ifndef HB_H_IN +#error "Include instead." +#endif + #ifndef HB_BUFFER_H #define HB_BUFFER_H diff --git a/src/hb-common.h b/src/hb-common.h index 4265bb36..df929eaf 100644 --- a/src/hb-common.h +++ b/src/hb-common.h @@ -26,6 +26,10 @@ * Google Author(s): Behdad Esfahbod */ +#ifndef HB_H_IN +#error "Include instead." +#endif + #ifndef HB_COMMON_H #define HB_COMMON_H diff --git a/src/hb-font.h b/src/hb-font.h index 8a9dda59..7e645158 100644 --- a/src/hb-font.h +++ b/src/hb-font.h @@ -24,6 +24,10 @@ * Red Hat Author(s): Behdad Esfahbod */ +#ifndef HB_H_IN +#error "Include instead." +#endif + #ifndef HB_FONT_H #define HB_FONT_H diff --git a/src/hb-ft.h b/src/hb-ft.h index c1772ac1..696251e1 100644 --- a/src/hb-ft.h +++ b/src/hb-ft.h @@ -29,8 +29,6 @@ #include "hb.h" -#include "hb-font.h" - #include #include FT_FREETYPE_H diff --git a/src/hb-glib.h b/src/hb-glib.h index 3bc3ebf1..63a9d336 100644 --- a/src/hb-glib.h +++ b/src/hb-glib.h @@ -30,6 +30,7 @@ #define HB_GLIB_H #include "hb.h" + #include HB_BEGIN_DECLS diff --git a/src/hb-gobject.h b/src/hb-gobject.h index 25fc9418..4f23fdd3 100644 --- a/src/hb-gobject.h +++ b/src/hb-gobject.h @@ -28,6 +28,7 @@ #define HB_GOBJECT_H #include "hb.h" + #include HB_BEGIN_DECLS diff --git a/src/hb-graphite2.h b/src/hb-graphite2.h index 68bd0195..3eba9e0b 100644 --- a/src/hb-graphite2.h +++ b/src/hb-graphite2.h @@ -26,8 +26,7 @@ #ifndef HB_GRAPHITE2_H #define HB_GRAPHITE2_H -#include "hb-common.h" -#include "hb-shape.h" +#include "hb.h" HB_BEGIN_DECLS @@ -41,6 +40,8 @@ hb_graphite_shape (hb_font_t *font, unsigned int num_features, const char * const *shaper_options); +/* TODO add gr_font/face etc getters and other glue API */ + HB_END_DECLS #endif /* HB_GRAPHITE2_H */ diff --git a/src/hb-icu.h b/src/hb-icu.h index ecabec29..d22a8e1f 100644 --- a/src/hb-icu.h +++ b/src/hb-icu.h @@ -30,6 +30,7 @@ #define HB_ICU_H #include "hb.h" + #include diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h index 447e35db..430e54c3 100644 --- a/src/hb-ot-layout.h +++ b/src/hb-ot-layout.h @@ -24,12 +24,14 @@ * Red Hat Author(s): Behdad Esfahbod */ +#ifndef HB_OT_H_IN +#error "Include instead." +#endif + #ifndef HB_OT_LAYOUT_H #define HB_OT_LAYOUT_H -#include "hb-common.h" -#include "hb-buffer.h" -#include "hb-font.h" +#include "hb.h" #include "hb-ot-tag.h" diff --git a/src/hb-ot-shape.h b/src/hb-ot-shape.h index 1897e845..cc18be68 100644 --- a/src/hb-ot-shape.h +++ b/src/hb-ot-shape.h @@ -24,15 +24,16 @@ * Red Hat Author(s): Behdad Esfahbod */ +#ifndef HB_OT_H_IN +#error "Include instead." +#endif + #ifndef HB_OT_SHAPE_H #define HB_OT_SHAPE_H -#include "hb-common.h" -#include "hb-shape.h" - - HB_BEGIN_DECLS +#include "hb.h" hb_bool_t hb_ot_shape (hb_font_t *font, diff --git a/src/hb-ot-tag.h b/src/hb-ot-tag.h index 427a0695..1bf12ab3 100644 --- a/src/hb-ot-tag.h +++ b/src/hb-ot-tag.h @@ -24,10 +24,14 @@ * Red Hat Author(s): Behdad Esfahbod */ +#ifndef HB_OT_H_IN +#error "Include instead." +#endif + #ifndef HB_OT_TAG_H #define HB_OT_TAG_H -#include "hb-common.h" +#include "hb.h" HB_BEGIN_DECLS diff --git a/src/hb-ot.h b/src/hb-ot.h index fd6dd58e..a825a86a 100644 --- a/src/hb-ot.h +++ b/src/hb-ot.h @@ -26,6 +26,7 @@ #ifndef HB_OT_H #define HB_OT_H +#define HB_OT_H_IN #include "hb.h" @@ -36,4 +37,5 @@ HB_BEGIN_DECLS HB_END_DECLS +#undef HB_OT_H_IN #endif /* HB_OT_H */ diff --git a/src/hb-private.hh b/src/hb-private.hh index c757e2dc..f561260c 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -33,7 +33,10 @@ #include "config.h" #endif -#include "hb-common.h" +#include "hb.h" +#include "hb-ot.h" +#define HB_H_IN +#define HB_OT_H_IN #include #include diff --git a/src/hb-shape.h b/src/hb-shape.h index 685b11d4..99c24abf 100644 --- a/src/hb-shape.h +++ b/src/hb-shape.h @@ -24,6 +24,10 @@ * Red Hat Author(s): Behdad Esfahbod */ +#ifndef HB_H_IN +#error "Include instead." +#endif + #ifndef HB_SHAPE_H #define HB_SHAPE_H diff --git a/src/hb-unicode.h b/src/hb-unicode.h index 13886dfb..205e4c7f 100644 --- a/src/hb-unicode.h +++ b/src/hb-unicode.h @@ -28,6 +28,10 @@ * Google Author(s): Behdad Esfahbod */ +#ifndef HB_H_IN +#error "Include instead." +#endif + #ifndef HB_UNICODE_H #define HB_UNICODE_H diff --git a/src/hb-uniscribe.h b/src/hb-uniscribe.h index dbcacd7f..7bf80907 100644 --- a/src/hb-uniscribe.h +++ b/src/hb-uniscribe.h @@ -27,8 +27,7 @@ #ifndef HB_UNISCRIBE_H #define HB_UNISCRIBE_H -#include "hb-common.h" -#include "hb-shape.h" +#include "hb.h" #define _WIN32_WINNT 0x0500 #include diff --git a/src/hb-version.h.in b/src/hb-version.h.in index 47a9b300..43634f91 100644 --- a/src/hb-version.h.in +++ b/src/hb-version.h.in @@ -24,6 +24,10 @@ * Google Author(s): Behdad Esfahbod */ +#ifndef HB_H_IN +#error "Include instead." +#endif + #ifndef HB_VERSION_H #define HB_VERSION_H diff --git a/src/hb.h b/src/hb.h index 0a2ebd9e..996dc912 100644 --- a/src/hb.h +++ b/src/hb.h @@ -26,6 +26,7 @@ #ifndef HB_H #define HB_H +#define HB_H_IN #include "hb-blob.h" #include "hb-buffer.h" @@ -38,4 +39,5 @@ HB_BEGIN_DECLS HB_END_DECLS +#undef HB_H_IN #endif /* HB_H */ -- GitLab