diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2008-09-20 17:20:36 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2008-09-20 17:20:36 -0400 |
commit | fee72c26afff2120315ebbab32708520307e7a5e (patch) | |
tree | d9d09053fdaec65c3c54692a875490579460ef6f /src | |
parent | e00565fa3c9579566abb31b71af3f13f44c45139 (diff) |
Make sure feature macros are checked using #if, not #ifdef; add a test for it
This is more robust to cases where people want to assign 0 to those variables.
(win32/alternate build systems, etc)
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 6 | ||||
-rw-r--r-- | src/cairo-atomic-private.h | 4 | ||||
-rw-r--r-- | src/cairo-atomic.c | 2 | ||||
-rw-r--r-- | src/cairo-directfb.h | 2 | ||||
-rw-r--r-- | src/cairo-mutex-list-private.h | 2 | ||||
-rw-r--r-- | src/cairo-quartz-private.h | 11 | ||||
-rw-r--r-- | src/cairo-quartz.h | 4 | ||||
-rw-r--r-- | src/cairo-win32.h | 8 | ||||
-rw-r--r-- | src/cairoint.h | 13 | ||||
-rwxr-xr-x | src/check-preprocessor-syntax.sh (renamed from src/check-includes.sh) | 9 |
10 files changed, 38 insertions, 23 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 9c434500..4b6d86b5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -70,10 +70,10 @@ TESTS_ENVIRONMENT = \ $(NULL) TESTS_SH = \ check-def.sh \ - check-plt.sh \ - check-headers.sh \ - check-includes.sh \ check-doc-syntax.sh\ + check-headers.sh \ + check-plt.sh \ + check-preprocessor-syntax.sh \ $(NULL) TESTS += $(TESTS_SH) if CROSS_COMPILING diff --git a/src/cairo-atomic-private.h b/src/cairo-atomic-private.h index fb5e60de..2914a022 100644 --- a/src/cairo-atomic-private.h +++ b/src/cairo-atomic-private.h @@ -47,7 +47,7 @@ CAIRO_BEGIN_DECLS #if HAVE_INTEL_ATOMIC_PRIMITIVES -#define CAIRO_HAS_ATOMIC_OPS 1 +#define HAS_ATOMIC_OPS 1 typedef int cairo_atomic_int_t; @@ -58,7 +58,7 @@ typedef int cairo_atomic_int_t; #endif -#ifndef CAIRO_HAS_ATOMIC_OPS +#ifndef HAS_ATOMIC_OPS typedef int cairo_atomic_int_t; diff --git a/src/cairo-atomic.c b/src/cairo-atomic.c index 9fe53e62..c569000c 100644 --- a/src/cairo-atomic.c +++ b/src/cairo-atomic.c @@ -36,7 +36,7 @@ #include "cairo-atomic-private.h" #include "cairo-mutex-private.h" -#ifndef CAIRO_HAS_ATOMIC_OPS +#ifndef HAS_ATOMIC_OPS void _cairo_atomic_int_inc (int *x) { diff --git a/src/cairo-directfb.h b/src/cairo-directfb.h index 6b3fcbdf..0396cb13 100644 --- a/src/cairo-directfb.h +++ b/src/cairo-directfb.h @@ -49,7 +49,7 @@ #include "cairo.h" -#ifdef CAIRO_HAS_DIRECTFB_SURFACE +#if CAIRO_HAS_DIRECTFB_SURFACE #include <directfb.h> diff --git a/src/cairo-mutex-list-private.h b/src/cairo-mutex-list-private.h index 49f29db1..6fdb389a 100644 --- a/src/cairo-mutex-list-private.h +++ b/src/cairo-mutex-list-private.h @@ -51,7 +51,7 @@ CAIRO_MUTEX_DECLARE (_cairo_ft_unscaled_font_map_mutex) CAIRO_MUTEX_DECLARE (_cairo_xlib_display_mutex) #endif -#if !defined (CAIRO_HAS_ATOMIC_OPS) || defined (ATOMIC_OP_NEEDS_MEMORY_BARRIER) +#if !defined (HAS_ATOMIC_OPS) || defined (ATOMIC_OP_NEEDS_MEMORY_BARRIER) CAIRO_MUTEX_DECLARE (_cairo_atomic_mutex) #endif diff --git a/src/cairo-quartz-private.h b/src/cairo-quartz-private.h index f321c5b6..8ba89687 100644 --- a/src/cairo-quartz-private.h +++ b/src/cairo-quartz-private.h @@ -40,7 +40,7 @@ #include "cairoint.h" -#ifdef CAIRO_HAS_QUARTZ_SURFACE +#if CAIRO_HAS_QUARTZ_SURFACE #include "cairo-quartz.h" typedef struct cairo_quartz_surface { @@ -95,11 +95,10 @@ _cairo_quartz_create_cgimage (cairo_format_t format, CGFontRef _cairo_quartz_scaled_font_get_cg_font_ref (cairo_scaled_font_t *sfont); -#endif /* CAIRO_HAS_QUARTZ_SURFACE */ +#else -#if CAIRO_HAS_CGFONT_FONT -CGFontRef -_cairo_cgfont_scaled_font_get_cg_font_ref (cairo_scaled_font_t *sfont); -#endif /* CAIRO_HAS_CGFONT_FONT */ +# error Cairo was not compiled with support for the quartz backend + +#endif /* CAIRO_HAS_QUARTZ_SURFACE */ #endif /* CAIRO_QUARTZ_PRIVATE_H */ diff --git a/src/cairo-quartz.h b/src/cairo-quartz.h index d34cca6c..769b29f4 100644 --- a/src/cairo-quartz.h +++ b/src/cairo-quartz.h @@ -57,12 +57,12 @@ cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext, cairo_public CGContextRef cairo_quartz_surface_get_cg_context (cairo_surface_t *surface); +#if CAIRO_HAS_QUARTZ_FONT + /* * Quartz font support */ -#ifdef CAIRO_HAS_QUARTZ_FONT - cairo_public cairo_font_face_t * cairo_quartz_font_face_create_for_cgfont (CGFontRef font); diff --git a/src/cairo-win32.h b/src/cairo-win32.h index 8bd7a974..cb517bc8 100644 --- a/src/cairo-win32.h +++ b/src/cairo-win32.h @@ -68,6 +68,12 @@ cairo_win32_surface_get_dc (cairo_surface_t *surface); cairo_public cairo_surface_t * cairo_win32_surface_get_image (cairo_surface_t *surface); +#if CAIRO_HAS_WIN32_FONT + +/* + * Win32 font support + */ + cairo_public cairo_font_face_t * cairo_win32_font_face_create_for_logfontw (LOGFONTW *logfont); @@ -95,6 +101,8 @@ cairo_public void cairo_win32_scaled_font_get_device_to_logical (cairo_scaled_font_t *scaled_font, cairo_matrix_t *device_to_logical); +#endif /* CAIRO_HAS_WIN32_FONT */ + CAIRO_END_DECLS #else /* CAIRO_HAS_WIN32_SURFACE */ diff --git a/src/cairoint.h b/src/cairoint.h index a032c12f..793f99fc 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -68,11 +68,20 @@ #include "cairo-compiler-private.h" -#if defined(CAIRO_HAS_PS_SURFACE) || defined(CAIRO_HAS_PDF_SURFACE) || defined(CAIRO_HAS_SVG_SURFACE) +#if CAIRO_HAS_PS_SURFACE +#define CAIRO_HAS_FONT_SUBSET 1 +#endif +#if CAIRO_HAS_PDF_SURFACE +#define CAIRO_HAS_FONT_SUBSET 1 +#endif +#if CAIRO_HAS_SVG_SURFACE #define CAIRO_HAS_FONT_SUBSET 1 #endif -#if defined(CAIRO_HAS_PS_SURFACE) || defined(CAIRO_HAS_PDF_SURFACE) +#if CAIRO_HAS_PS_SURFACE +#define CAIRO_HAS_PDF_OPERATORS 1 +#endif +#if CAIRO_HAS_PDF_SURFACE #define CAIRO_HAS_PDF_OPERATORS 1 #endif diff --git a/src/check-includes.sh b/src/check-preprocessor-syntax.sh index 8cfa260f..12577eb5 100755 --- a/src/check-includes.sh +++ b/src/check-preprocessor-syntax.sh @@ -16,6 +16,7 @@ test "x$PRIVATE" = x && PRIVATE=`find . -name 'cairo*-private.h' -or -name 'cair SOURCES=$all_cairo_sources test "x$SOURCES" = x && SOURCES=`find . -name 'cairo*.c' -or -name 'cairo*.cpp'` +ALL="/dev/null $HEADERS $PRIVATE $SOURCES" echo 'Checking that public header files #include "cairo.h" first (or none)' @@ -47,12 +48,10 @@ grep . && stat=1 echo 'Checking that there is no #include <cairo.*.h>' - -for x in $HEADERS $PRIVATE $SOURCES; do - grep '\<include\>.*<.*cairo' "$x" /dev/null -done | -grep . && stat=1 +grep '\<include\>.*<.*cairo' $ALL && stat=1 +echo 'Checking that feature conditionals are used with #if only (not #ifdef)' +grep '#if.*CAIRO_HAS_' $ALL | grep def && stat=1 exit $stat |