Prefer C linkage

This commit is contained in:
Behdad Esfahbod 2010-07-23 15:11:18 -04:00
parent cc6d52279d
commit acdba3f90b
48 changed files with 214 additions and 20 deletions

View File

@ -113,6 +113,7 @@ main_CPPFLAGS = $(HBCFLAGS)
main_LDADD = libharfbuzz.la $(HBLIBS)
TESTS = \
check-c-linkage-decls.sh \
check-header-guards.sh \
check-internal-symbols.sh \
$(NULL)

18
src/check-c-linkage-decls.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
LC_ALL=C
export LC_ALL
test -z "$srcdir" && srcdir=.
stat=0
cd "$srcdir"
for x in *.c *.cc *.h *.hh ; do
if ! grep -q HB_BEGIN_DECLS "$x" || ! grep -q HB_END_DECLS "$x"; then
echo "Ouch, file $x does not HB_BEGIN_DECLS / HB_END_DECLS"
stat=1
fi
done
exit $stat

View File

@ -33,6 +33,7 @@
HB_BEGIN_DECLS
struct _hb_blob_t {
hb_reference_count_t ref_count;
@ -52,6 +53,7 @@ struct _hb_blob_t {
extern HB_INTERNAL hb_blob_t _hb_blob_nil;
HB_END_DECLS
#endif /* HB_BLOB_PRIVATE_H */

View File

@ -35,13 +35,16 @@
#include <sys/mman.h>
#endif /* HAVE_SYS_MMAN_H */
#include <stdio.h>
#include <errno.h>
HB_BEGIN_DECLS
#ifndef HB_DEBUG_BLOB
#define HB_DEBUG_BLOB HB_DEBUG+0
#endif
#include <stdio.h>
#include <errno.h>
hb_blob_t _hb_blob_nil = {
HB_REFERENCE_COUNT_INVALID, /* ref_count */
@ -273,7 +276,7 @@ _try_make_writable_inplace_unix_locked (hb_blob_t *blob)
}
static void
_try_writable_inplace_locked (hb_blob_t *blob)
try_writable_inplace_locked (hb_blob_t *blob)
{
if (HB_DEBUG_BLOB)
fprintf (stderr, "%p %s: making writable\n", blob, __FUNCTION__);
@ -301,7 +304,7 @@ hb_blob_try_writable_inplace (hb_blob_t *blob)
hb_mutex_lock (blob->lock);
if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE)
_try_writable_inplace_locked (blob);
try_writable_inplace_locked (blob);
mode = blob->mode;
@ -321,7 +324,7 @@ hb_blob_try_writable (hb_blob_t *blob)
hb_mutex_lock (blob->lock);
if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE)
_try_writable_inplace_locked (blob);
try_writable_inplace_locked (blob);
if (blob->mode == HB_MEMORY_MODE_READONLY)
{
@ -354,3 +357,6 @@ done:
return mode == HB_MEMORY_MODE_WRITABLE;
}
HB_END_DECLS

View File

@ -31,6 +31,7 @@
HB_BEGIN_DECLS
typedef enum {
HB_MEMORY_MODE_DUPLICATE,
HB_MEMORY_MODE_READONLY,
@ -82,6 +83,7 @@ hb_blob_try_writable_inplace (hb_blob_t *blob);
hb_bool_t
hb_blob_try_writable (hb_blob_t *blob);
HB_END_DECLS
#endif /* HB_BLOB_H */

View File

@ -34,6 +34,7 @@
HB_BEGIN_DECLS
#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF

View File

@ -29,6 +29,8 @@
#include <string.h>
HB_BEGIN_DECLS
static hb_buffer_t _hb_buffer_nil = {
HB_REFERENCE_COUNT_INVALID, /* ref_count */
@ -96,7 +98,7 @@ _hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
return likely (size <= buffer->allocated) ? TRUE : _hb_buffer_enlarge (buffer, size);
}
static hb_bool_t
static inline hb_bool_t
_hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size)
{
if (unlikely (!_hb_buffer_ensure (buffer, size))) return FALSE;
@ -692,3 +694,6 @@ hb_buffer_add_utf32 (hb_buffer_t *buffer,
ADD_UTF (uint32_t);
#undef UTF_NEXT
}
HB_END_DECLS

View File

@ -34,6 +34,7 @@
HB_BEGIN_DECLS
typedef struct _hb_buffer_t hb_buffer_t;
typedef struct _hb_glyph_info_t {

View File

@ -26,6 +26,9 @@
#include "hb-private.h"
HB_BEGIN_DECLS
hb_tag_t
hb_tag_from_string (const char *s)
{
@ -39,3 +42,6 @@ hb_tag_from_string (const char *s)
return HB_TAG_STR (tag);
}
HB_END_DECLS

View File

@ -27,6 +27,17 @@
#ifndef HB_COMMON_H
#define HB_COMMON_H
# ifdef __cplusplus
# define HB_BEGIN_DECLS extern "C" {
# define HB_END_DECLS }
# else /* !__cplusplus */
# define HB_BEGIN_DECLS
# define HB_END_DECLS
# endif /* !__cplusplus */
HB_BEGIN_DECLS
#ifdef _MSC_VER
#define _HB__STR2__(x) #x
#define _HB__STR1__(x) _HB__STR2__(x)
@ -47,14 +58,6 @@ typedef unsigned long long uint64_t;
#include <stdint.h>
#endif
# ifdef __cplusplus
# define HB_BEGIN_DECLS extern "C" {
# define HB_END_DECLS }
# else /* !__cplusplus */
# define HB_BEGIN_DECLS
# define HB_END_DECLS
# endif /* !__cplusplus */
typedef int hb_bool_t;
typedef uint32_t hb_tag_t;
@ -88,4 +91,6 @@ typedef enum _hb_direction_t {
#define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1))
HB_END_DECLS
#endif /* HB_COMMON_H */

View File

@ -33,6 +33,7 @@
HB_BEGIN_DECLS
/*
* hb_font_funcs_t
*/

View File

@ -34,6 +34,8 @@
#include <string.h>
HB_BEGIN_DECLS
/*
* hb_font_funcs_t
@ -467,3 +469,5 @@ hb_font_set_ppem (hb_font_t *font,
font->y_ppem = y_ppem;
}
HB_END_DECLS

View File

@ -32,6 +32,7 @@
HB_BEGIN_DECLS
typedef struct _hb_face_t hb_face_t;
typedef struct _hb_font_t hb_font_t;

View File

@ -33,6 +33,9 @@
#include FT_TRUETYPE_TABLES_H
HB_BEGIN_DECLS
static hb_codepoint_t
hb_ft_get_glyph (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
@ -145,7 +148,7 @@ hb_ft_get_font_funcs (void)
static hb_blob_t *
_get_table (hb_tag_t tag, void *user_data)
get_table (hb_tag_t tag, void *user_data)
{
FT_Face ft_face = (FT_Face) user_data;
FT_Byte *buffer;
@ -191,7 +194,7 @@ hb_ft_face_create (FT_Face ft_face,
face = hb_face_create_for_data (blob, ft_face->face_index);
hb_blob_destroy (blob);
} else {
face = hb_face_create_for_tables (_get_table, destroy, ft_face);
face = hb_face_create_for_tables (get_table, destroy, ft_face);
}
return face;
@ -238,3 +241,6 @@ hb_ft_font_create (FT_Face ft_face,
return font;
}
HB_END_DECLS

View File

@ -36,6 +36,7 @@
HB_BEGIN_DECLS
hb_font_funcs_t *
hb_ft_get_font_funcs (void);
@ -51,6 +52,7 @@ hb_font_t *
hb_ft_font_create (FT_Face ft_face,
hb_destroy_func_t destroy);
HB_END_DECLS
#endif /* HB_FT_H */

View File

@ -32,6 +32,9 @@
#include <glib.h>
HB_BEGIN_DECLS
static hb_codepoint_t hb_glib_get_mirroring (hb_codepoint_t unicode) { g_unichar_get_mirror_char (unicode, &unicode); return unicode; }
static hb_category_t hb_glib_get_general_category (hb_codepoint_t unicode) { return g_unichar_type (unicode); }
static hb_script_t hb_glib_get_script (hb_codepoint_t unicode) { return g_unichar_get_script (unicode); }
@ -56,3 +59,6 @@ hb_glib_get_unicode_funcs (void)
{
return &glib_ufuncs;
}
HB_END_DECLS

View File

@ -31,9 +31,11 @@
HB_BEGIN_DECLS
hb_unicode_funcs_t *
hb_glib_get_unicode_funcs (void);
HB_END_DECLS
#endif /* HB_GLIB_H */

View File

@ -33,6 +33,9 @@
#include "hb-graphite.h"
#include <map>
HB_BEGIN_DECLS
namespace TtfUtil
{
extern int FontAscent(const void *pOS2);
@ -302,3 +305,6 @@ hb_graphite_shape (hb_font_t *font,
delete[] firsts;
delete[] flags;
}
HB_END_DECLS

View File

@ -30,9 +30,9 @@
#include "hb-shape.h"
HB_BEGIN_DECLS
#define HB_GRAPHITE_TAG_Silf HB_TAG('S','i','l','f')
void hb_graphite_shape (hb_font_t *font,
@ -41,6 +41,7 @@ void hb_graphite_shape (hb_font_t *font,
hb_feature_t *features,
unsigned int num_features);
HB_END_DECLS
#endif /* HB_GRAPHITE_H */

View File

@ -35,6 +35,9 @@
#include <unicode/uchar.h>
#include <unicode/uscript.h>
HB_BEGIN_DECLS
static hb_codepoint_t hb_icu_get_mirroring (hb_codepoint_t unicode) { return u_charMirror(unicode); }
static unsigned int hb_icu_get_combining_class (hb_codepoint_t unicode) { return u_getCombiningClass (unicode); }
@ -246,3 +249,6 @@ hb_icu_get_unicode_funcs (void)
{
return &icu_ufuncs;
}
HB_END_DECLS

View File

@ -31,9 +31,11 @@
HB_BEGIN_DECLS
hb_unicode_funcs_t *
hb_icu_get_unicode_funcs (void);
HB_END_DECLS
#endif /* HB_ICU_H */

View File

@ -28,6 +28,9 @@
#include "hb-language.h"
HB_BEGIN_DECLS
static const char canon_map[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -113,3 +116,5 @@ hb_language_to_string (hb_language_t language)
return (const char *) language;
}
HB_END_DECLS

View File

@ -31,6 +31,7 @@
HB_BEGIN_DECLS
typedef const void *hb_language_t;
hb_language_t
@ -39,6 +40,7 @@ hb_language_from_string (const char *str);
const char *
hb_language_to_string (hb_language_t language);
HB_END_DECLS
#endif /* HB_LANGUAGE_H */

View File

@ -32,6 +32,7 @@
#include "hb-private.h"
HB_BEGIN_DECLS
/* Encapsulate operations on the object's reference count */
@ -135,5 +136,6 @@ _hb_trace_object (const void *obj,
} HB_STMT_END
HB_END_DECLS
#endif /* HB_OBJECT_PRIVATE_H */

View File

@ -29,6 +29,8 @@
#include "hb-open-type-private.hh"
HB_BEGIN_DECLS
/*
*
@ -251,4 +253,6 @@ struct OpenTypeFontFile
};
HB_END_DECLS
#endif /* HB_OPEN_FILE_PRIVATE_HH */

View File

@ -31,6 +31,8 @@
#include "hb-blob.h"
HB_BEGIN_DECLS
HB_END_DECLS
/*
@ -728,4 +730,7 @@ struct SortedArrayOf : ArrayOf<Type> {
};
HB_BEGIN_DECLS
HB_END_DECLS
#endif /* HB_OPEN_TYPE_PRIVATE_HH */

View File

@ -29,6 +29,9 @@
#include "hb-open-type-private.hh"
HB_BEGIN_DECLS
/*
* head
*/
@ -125,4 +128,6 @@ struct head
};
HB_END_DECLS
#endif /* HB_OT_HEAD_PRIVATE_HH */

View File

@ -36,6 +36,9 @@
#define NOT_COVERED ((unsigned int) 0x110000)
#define MAX_NESTING_LEVEL 8
HB_BEGIN_DECLS
HB_END_DECLS
/*
*
@ -574,4 +577,7 @@ struct Device
};
HB_BEGIN_DECLS
HB_END_DECLS
#endif /* HB_OT_LAYOUT_COMMON_PRIVATE_HH */

View File

@ -31,6 +31,8 @@
#include "hb-font-private.h"
HB_BEGIN_DECLS
/*
* Attachment List Table
@ -397,4 +399,6 @@ struct GDEF
};
HB_END_DECLS
#endif /* HB_OT_LAYOUT_GDEF_PRIVATE_HH */

View File

@ -29,6 +29,8 @@
#include "hb-ot-layout-gsubgpos-private.hh"
HB_BEGIN_DECLS
#define HB_OT_LAYOUT_GPOS_NO_LAST ((unsigned int) -1)
@ -1373,7 +1375,9 @@ struct MarkMarkPos
};
HB_BEGIN_DECLS
static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index);
HB_END_DECLS
struct ContextPos : Context
{
@ -1627,4 +1631,6 @@ static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_i
}
HB_END_DECLS
#endif /* HB_OT_LAYOUT_GPOS_PRIVATE_HH */

View File

@ -29,6 +29,8 @@
#include "hb-ot-layout-gsubgpos-private.hh"
HB_BEGIN_DECLS
struct SingleSubstFormat1
{
@ -541,8 +543,9 @@ struct LigatureSubst
};
HB_BEGIN_DECLS
static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index);
HB_END_DECLS
struct ContextSubst : Context
{
@ -936,4 +939,6 @@ static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup
}
HB_END_DECLS
#endif /* HB_OT_LAYOUT_GSUB_PRIVATE_HH */

View File

@ -30,6 +30,8 @@
#include "hb-buffer-private.hh"
#include "hb-ot-layout-gdef-private.hh"
HB_BEGIN_DECLS
#ifndef HB_DEBUG_APPLY
#define HB_DEBUG_APPLY HB_DEBUG+0
@ -39,6 +41,8 @@
hb_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", HB_FUNC, this); \
HB_BEGIN_DECLS
struct hb_apply_context_t
{
unsigned int debug_depth;
@ -164,6 +168,8 @@ static inline bool match_lookahead (hb_apply_context_t *c,
return true;
}
HB_END_DECLS
struct LookupRecord
{
@ -180,6 +186,9 @@ struct LookupRecord
DEFINE_SIZE_STATIC (4);
};
HB_BEGIN_DECLS
static inline bool apply_lookup (hb_apply_context_t *c,
unsigned int count, /* Including the first glyph */
unsigned int lookupCount,
@ -236,6 +245,8 @@ static inline bool apply_lookup (hb_apply_context_t *c,
return true;
}
HB_END_DECLS
/* Contextual lookups */
@ -939,4 +950,6 @@ struct GSUBGPOS
};
HB_END_DECLS
#endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */

View File

@ -35,9 +35,9 @@
#include "hb-font-private.h"
#include "hb-buffer-private.hh"
HB_BEGIN_DECLS
typedef unsigned int hb_ot_layout_class_t;
/*
@ -119,6 +119,7 @@ _hb_ot_layout_skip_mark (hb_face_t *face,
unsigned int lookup_flags,
unsigned int *property);
HB_END_DECLS
#endif /* HB_OT_LAYOUT_PRIVATE_HH */

View File

@ -38,6 +38,8 @@
#include <stdlib.h>
#include <string.h>
HB_BEGIN_DECLS
hb_ot_layout_t *
_hb_ot_layout_new (hb_face_t *face)
@ -644,3 +646,6 @@ hb_ot_layout_position_finish (hb_font_t *font HB_UNUSED,
}
}
}
HB_END_DECLS

View File

@ -35,6 +35,7 @@
HB_BEGIN_DECLS
#define HB_OT_TAG_GDEF HB_TAG('G','D','E','F')
#define HB_OT_TAG_GSUB HB_TAG('G','S','U','B')
#define HB_OT_TAG_GPOS HB_TAG('G','P','O','S')

View File

@ -32,6 +32,9 @@
#include "hb-ot-layout.h"
HB_BEGIN_DECLS
/* XXX vertical */
hb_tag_t default_features[] = {
HB_TAG('c','a','l','t'),
@ -625,3 +628,6 @@ hb_ot_shape (hb_font_t *font,
buffer->direction = original_direction;
}
HB_END_DECLS

View File

@ -32,6 +32,7 @@
HB_BEGIN_DECLS
void
hb_ot_shape (hb_font_t *font,
hb_face_t *face,
@ -39,6 +40,7 @@ hb_ot_shape (hb_font_t *font,
hb_feature_t *features,
unsigned int num_features);
HB_END_DECLS
#endif /* HB_OT_SHAPE_H */

View File

@ -29,6 +29,8 @@
#include <string.h>
HB_BEGIN_DECLS
/*
* Complete list at:
@ -694,3 +696,6 @@ hb_ot_tag_to_language (hb_tag_t tag)
buf[10] = '\0';
return hb_language_from_string ((char *) buf);
}
HB_END_DECLS

View File

@ -32,6 +32,7 @@
HB_BEGIN_DECLS
#define HB_OT_TAG_DEFAULT_SCRIPT HB_TAG ('D', 'F', 'L', 'T')
#define HB_OT_TAG_DEFAULT_LANGUAGE HB_TAG ('d', 'f', 'l', 't')
@ -47,6 +48,7 @@ hb_ot_tag_from_language (hb_language_t language);
hb_language_t
hb_ot_tag_to_language (hb_tag_t tag);
HB_END_DECLS
#endif /* HB_OT_TAG_H */

View File

@ -33,4 +33,7 @@
#include "hb-ot-shape.h"
#include "hb-ot-tag.h"
HB_BEGIN_DECLS
HB_END_DECLS
#endif /* HB_OT_H */

View File

@ -44,6 +44,8 @@
#include <stdio.h>
#include <errno.h>
HB_BEGIN_DECLS
/* Essentials */
@ -259,4 +261,7 @@ _hb_trace (const char *what,
#include "hb-object-private.h"
HB_END_DECLS
#endif /* HB_PRIVATE_H */

View File

@ -36,6 +36,8 @@
#include "hb-graphite.h"
#endif
HB_BEGIN_DECLS
void
hb_shape (hb_font_t *font,
@ -58,3 +60,6 @@ hb_shape (hb_font_t *font,
hb_ot_shape (font, face, buffer, features, num_features);
}
HB_END_DECLS

View File

@ -33,6 +33,7 @@
HB_BEGIN_DECLS
typedef struct _hb_feature_t {
hb_tag_t tag;
uint32_t value;

View File

@ -33,6 +33,7 @@
HB_BEGIN_DECLS
/*
* hb_unicode_funcs_t
*/

View File

@ -28,6 +28,9 @@
#include "hb-unicode-private.h"
HB_BEGIN_DECLS
/*
* hb_unicode_funcs_t
*/
@ -313,3 +316,6 @@ _hb_script_get_horizontal_direction (hb_script_t script)
return horiz_dir[script];
}
HB_END_DECLS

View File

@ -31,6 +31,7 @@
HB_BEGIN_DECLS
/* Unicode General Category property */
typedef enum
{

View File

@ -35,4 +35,7 @@
#include "hb-shape.h"
#include "hb-unicode.h"
HB_BEGIN_DECLS
HB_END_DECLS
#endif /* HB_H */

View File

@ -35,6 +35,9 @@
#include <stdlib.h>
#include <stdio.h>
HB_BEGIN_DECLS
int
main (int argc, char **argv)
{
@ -188,3 +191,6 @@ main (int argc, char **argv)
return 0;
}
HB_END_DECLS