From 29a90e2610ad5dc93ae4fc24e37a74bbe751f834 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Thu, 3 Aug 2000 00:03:08 +0000 Subject: [PATCH] Updating unix/ftconfig.in to recent config/ftconfig.h changes. More C++ fixes: Introducing LOCAL_FUNC_X for local functions used in function pointers (there are no local anonymous functions in C++) and FT_CPLUSPLUS (instead of FT_EXPORT_VAR) to define linkage of structures which contain function pointers. --- builds/unix/ftconfig.in | 97 +++++++++++++++++++++++++----- builds/unix/ftsystem.c | 8 +-- include/freetype/config/ftconfig.h | 21 +++++++ src/autohint/ahmodule.c | 10 +-- src/cff/t2driver.c | 2 +- src/cid/cidload.c | 6 +- src/cid/cidriver.c | 2 +- src/psnames/psmodule.c | 4 +- src/raster1/ftrend1.c | 4 +- src/sfnt/sfdriver.c | 4 +- src/sfnt/ttcmap.c | 24 ++++---- src/smooth/ftsmooth.c | 2 +- src/truetype/ttdriver.c | 2 +- src/truetype/ttgload.c | 10 +-- src/type1/t1driver.c | 2 +- src/type1z/z1afm.c | 2 +- src/type1z/z1driver.c | 2 +- src/winfonts/winfnt.c | 2 +- 18 files changed, 145 insertions(+), 59 deletions(-) diff --git a/builds/unix/ftconfig.in b/builds/unix/ftconfig.in index e1c02b098..f73804a22 100644 --- a/builds/unix/ftconfig.in +++ b/builds/unix/ftconfig.in @@ -144,33 +144,98 @@ #ifdef FT_MAKE_OPTION_SINGLE_OBJECT -#define LOCAL_DEF static -#define LOCAL_FUNC static + +#define LOCAL_DEF static +#define LOCAL_FUNC static + #else -#define LOCAL_DEF extern -#define LOCAL_FUNC /* nothing */ -#endif -#ifdef FT_MAKE_OPTION_SINGLE_LIBRARY_OBJECT -#define BASE_DEF( x ) static x -#define BASE_FUNC( x ) static x +#ifdef __cplusplus +#define LOCAL_DEF extern "C" +#define LOCAL_FUNC extern "C" #else -#define BASE_DEF( x ) extern x -#define BASE_FUNC( x ) extern x +#define LOCAL_DEF extern +#define LOCAL_FUNC extern #endif -#ifndef FT_EXPORT_DEF -#define FT_EXPORT_DEF( x ) extern x +#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */ + + +#ifndef BASE_DEF + +#ifdef __cplusplus +#define BASE_DEF( x ) extern "C" x +#else +#define BASE_DEF( x ) extern x #endif -#ifndef FT_EXPORT_FUNC -#define FT_EXPORT_FUNC( x ) extern x +#endif /* !BASE_DEF */ + + +#ifndef BASE_FUNC + +#ifdef __cplusplus +#define BASE_FUNC( x ) extern "C" x +#else +#define BASE_FUNC( x ) extern x #endif -#ifndef FT_EXPORT_VAR -#define FT_EXPORT_VAR( x ) extern x +#endif /* !BASE_FUNC */ + + +#ifndef FT_EXPORT_DEF + +#ifdef __cplusplus +#define FT_EXPORT_DEF( x ) extern "C" x +#else +#define FT_EXPORT_DEF( x ) extern x #endif +#endif /* !FT_EXPORT_DEF */ + + +#ifndef FT_EXPORT_FUNC + +#ifdef __cplusplus +#define FT_EXPORT_FUNC( x ) extern "C" x +#else +#define FT_EXPORT_FUNC( x ) extern x +#endif + +#endif /* !FT_EXPORT_FUNC */ + + +#ifndef FT_EXPORT_VAR + +#ifdef __cplusplus +#define FT_EXPORT_VAR( x ) extern "C" x +#else +#define FT_EXPORT_VAR( x ) extern x +#endif + +#endif /* !FT_EXPORT_VAR */ + + + /* This is special. Within C++, you must specify `extern "C"' for */ + /* functions which are used via function pointers, and you also */ + /* must do that for structures which contain function pointers to */ + /* assure C linkage -- it's not possible to have (local) anonymous */ + /* functions which are accessed by (global) function pointers. */ + /* */ +#ifdef __cplusplus + +#define LOCAL_FUNC_X extern "C" + +#define FT_CPLUSPLUS( x ) extern "C" x + +#else + +#define LOCAL_FUNC_X static + +#define FT_CPLUSPLUS( x ) x + +#endif /* __cplusplus */ + #ifdef __cplusplus } diff --git a/builds/unix/ftsystem.c b/builds/unix/ftsystem.c index ceeff3f7c..570afa1dc 100644 --- a/builds/unix/ftsystem.c +++ b/builds/unix/ftsystem.c @@ -92,7 +92,7 @@ /* */ /* block :: The address of newly allocated block. */ /* */ - static + LOCAL_FUNC_X void* ft_alloc( FT_Memory memory, long size ) { @@ -122,7 +122,7 @@ /* */ /* The address of the reallocated memory block. */ /* */ - static + LOCAL_FUNC_X void* ft_realloc( FT_Memory memory, long cur_size, long new_size, @@ -148,7 +148,7 @@ /* */ /* block :: The address of block in memory to be freed. */ /* */ - static + LOCAL_FUNC_X void ft_free( FT_Memory memory, void* block ) { @@ -190,7 +190,7 @@ /* */ /* stream :: A pointer to the stream object. */ /* */ - static + LOCAL_FUNC_X void ft_close_stream( FT_Stream stream ) { munmap( (MUNMAP_ARG_CAST)stream->descriptor.pointer, stream->size ); diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h index a2e984249..11e697e83 100644 --- a/include/freetype/config/ftconfig.h +++ b/include/freetype/config/ftconfig.h @@ -231,6 +231,27 @@ #endif /* !FT_EXPORT_VAR */ + /* This is special. Within C++, you must specify `extern "C"' for */ + /* functions which are used via function pointers, and you also */ + /* must do that for structures which contain function pointers to */ + /* assure C linkage -- it's not possible to have (local) anonymous */ + /* functions which are accessed by (global) function pointers. */ + /* */ +#ifdef __cplusplus + +#define LOCAL_FUNC_X extern "C" + +#define FT_CPLUSPLUS( x ) extern "C" x + +#else + +#define LOCAL_FUNC_X static + +#define FT_CPLUSPLUS( x ) x + +#endif /* __cplusplus */ + + #ifdef __cplusplus } #endif diff --git a/src/autohint/ahmodule.c b/src/autohint/ahmodule.c index 255d542d9..20a37ef94 100644 --- a/src/autohint/ahmodule.c +++ b/src/autohint/ahmodule.c @@ -55,7 +55,7 @@ } - static + LOCAL_FUNC_X FT_Error ft_autohinter_load( FT_AutoHinter module, FT_GlyphSlot slot, FT_Size size, @@ -67,7 +67,7 @@ } - static + LOCAL_FUNC_X void ft_autohinter_reset( FT_AutoHinter module, FT_Face face ) { @@ -78,7 +78,7 @@ } - static + LOCAL_FUNC_X void ft_autohinter_get_globals( FT_AutoHinter module, FT_Face face, void** global_hints, @@ -89,7 +89,7 @@ } - static + LOCAL_FUNC_X void ft_autohinter_done_globals( FT_AutoHinter module, void* global_hints ) { @@ -107,7 +107,7 @@ }; - FT_EXPORT_VAR( const FT_Module_Class ) autohint_module_class = + FT_CPLUSPLUS( const FT_Module_Class ) autohint_module_class = { ft_module_hinter, sizeof ( FT_AutoHinterRec ), diff --git a/src/cff/t2driver.c b/src/cff/t2driver.c index ab6c20f9a..9e3ca4811 100644 --- a/src/cff/t2driver.c +++ b/src/cff/t2driver.c @@ -302,7 +302,7 @@ /* The FT_DriverInterface structure is defined in ftdriver.h. */ - FT_EXPORT_VAR( const FT_Driver_Class ) cff_driver_class = + FT_CPLUSPLUS( const FT_Driver_Class ) cff_driver_class = { /* begin with the FT_Module_Class fields */ { diff --git a/src/cid/cidload.c b/src/cid/cidload.c index 59eeb0b7d..b512bef03 100644 --- a/src/cid/cidload.c +++ b/src/cid/cidload.c @@ -163,7 +163,7 @@ } - static + LOCAL_FUNC_X FT_Error parse_font_bbox( CID_Face face, CID_Parser* parser ) { @@ -182,7 +182,7 @@ } - static + LOCAL_FUNC_X FT_Error parse_font_matrix( CID_Face face, CID_Parser* parser ) { @@ -208,7 +208,7 @@ } - static + LOCAL_FUNC_X FT_Error parse_fd_array( CID_Face face, CID_Parser* parser ) { diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c index b4f0fd7d6..224b0c69d 100644 --- a/src/cid/cidriver.c +++ b/src/cid/cidriver.c @@ -182,7 +182,7 @@ } - FT_EXPORT_VAR( const FT_Driver_Class ) t1cid_driver_class = + FT_CPLUSPLUS( const FT_Driver_Class ) t1cid_driver_class = { /* first of all, the FT_Module_Class fields */ { diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c index 448ea18a6..7bd5349e2 100644 --- a/src/psnames/psmodule.c +++ b/src/psnames/psmodule.c @@ -139,7 +139,7 @@ /* qsort callback to sort the unicode map */ - static + LOCAL_FUNC_X int compare_uni_maps( const void* a, const void* b ) { @@ -296,7 +296,7 @@ #endif /* !FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES */ - FT_EXPORT_VAR( const FT_Module_Class ) psnames_module_class = + FT_CPLUSPLUS( const FT_Module_Class ) psnames_module_class = { 0, /* this is not a font driver, nor a renderer */ sizeof( FT_ModuleRec ), diff --git a/src/raster1/ftrend1.c b/src/raster1/ftrend1.c index 9364864c7..891610556 100644 --- a/src/raster1/ftrend1.c +++ b/src/raster1/ftrend1.c @@ -213,7 +213,7 @@ } - FT_EXPORT_VAR( const FT_Renderer_Class ) ft_raster1_renderer_class = + FT_CPLUSPLUS( const FT_Renderer_Class ) ft_raster1_renderer_class = { { ft_module_renderer, @@ -245,7 +245,7 @@ /* to register it by hand in your application. It should only be */ /* used for backwards-compatibility with FT 1.x anyway. */ /* */ - FT_EXPORT_VAR( const FT_Renderer_Class ) ft_raster5_renderer_class = + FT_CPLUSPLUS( const FT_Renderer_Class ) ft_raster5_renderer_class = { { ft_module_renderer, diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c index dfeb7116a..908e09e5f 100644 --- a/src/sfnt/sfdriver.c +++ b/src/sfnt/sfdriver.c @@ -122,7 +122,7 @@ #endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */ - static + LOCAL_FUNC_X FT_Module_Interface SFNT_Get_Interface( FT_Module module, const char* interface ) { @@ -204,7 +204,7 @@ }; - FT_EXPORT_VAR( const FT_Module_Class ) sfnt_module_class = + FT_CPLUSPLUS( const FT_Module_Class ) sfnt_module_class = { 0, /* not a font driver or renderer */ sizeof( FT_ModuleRec ), diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c index 87ad04f01..0a3024e23 100644 --- a/src/sfnt/ttcmap.c +++ b/src/sfnt/ttcmap.c @@ -43,14 +43,14 @@ #define FT_COMPONENT trace_ttcmap - static FT_UInt code_to_index0( TT_CMapTable* charmap, - FT_ULong char_code ); - static FT_UInt code_to_index2( TT_CMapTable* charmap, - FT_ULong char_code ); - static FT_UInt code_to_index4( TT_CMapTable* charmap, - FT_ULong char_code ); - static FT_UInt code_to_index6( TT_CMapTable* charmap, - FT_ULong char_code ); + LOCAL_FUNC_X FT_UInt code_to_index0( TT_CMapTable* charmap, + FT_ULong char_code ); + LOCAL_FUNC_X FT_UInt code_to_index2( TT_CMapTable* charmap, + FT_ULong char_code ); + LOCAL_FUNC_X FT_UInt code_to_index4( TT_CMapTable* charmap, + FT_ULong char_code ); + LOCAL_FUNC_X FT_UInt code_to_index6( TT_CMapTable* charmap, + FT_ULong char_code ); /*************************************************************************/ @@ -355,7 +355,7 @@ /* */ /* Glyph index into the glyphs array. 0 if the glyph does not exist. */ /* */ - static + LOCAL_FUNC_X FT_UInt code_to_index0( TT_CMapTable* cmap, FT_ULong charCode ) { @@ -381,7 +381,7 @@ /* */ /* Glyph index into the glyphs array. 0 if the glyph does not exist. */ /* */ - static + LOCAL_FUNC_X FT_UInt code_to_index2( TT_CMapTable* cmap, FT_ULong charCode ) { @@ -445,7 +445,7 @@ /* */ /* Glyph index into the glyphs array. 0 if the glyph does not exist. */ /* */ - static + LOCAL_FUNC_X FT_UInt code_to_index4( TT_CMapTable* cmap, FT_ULong charCode ) { @@ -528,7 +528,7 @@ /* */ /* Glyph index into the glyphs array. 0 if the glyph does not exist. */ /* */ - static + LOCAL_FUNC_X FT_UInt code_to_index6( TT_CMapTable* cmap, FT_ULong charCode ) { diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c index f0408468f..e0a6785b7 100644 --- a/src/smooth/ftsmooth.c +++ b/src/smooth/ftsmooth.c @@ -189,7 +189,7 @@ } - FT_EXPORT_VAR( const FT_Renderer_Class ) ft_smooth_renderer_class = + FT_CPLUSPLUS( const FT_Renderer_Class ) ft_smooth_renderer_class = { { ft_module_renderer, diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c index 9e19f28e5..522df0b05 100644 --- a/src/truetype/ttdriver.c +++ b/src/truetype/ttdriver.c @@ -430,7 +430,7 @@ /* The FT_DriverInterface structure is defined in ftdriver.h. */ - FT_EXPORT_VAR( const FT_Driver_Class ) tt_driver_class = + FT_CPLUSPLUS( const FT_Driver_Class ) tt_driver_class = { { ft_module_font_driver | diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index 963ecd645..8adaf581d 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -207,7 +207,7 @@ /* */ /*************************************************************************/ - static + LOCAL_FUNC_X FT_Error TT_Access_Glyph_Frame( TT_Loader* loader, FT_UInt glyph_index, FT_ULong offset, @@ -227,7 +227,7 @@ } - static + LOCAL_FUNC_X void TT_Forget_Glyph_Frame( TT_Loader* loader ) { FT_Stream stream = loader->stream; @@ -237,7 +237,7 @@ } - static + LOCAL_FUNC_X FT_Error TT_Load_Glyph_Header( TT_Loader* loader ) { FT_Stream stream = loader->stream; @@ -260,7 +260,7 @@ } - static + LOCAL_FUNC_X FT_Error TT_Load_Simple_Glyph( TT_Loader* load ) { FT_Error error; @@ -419,7 +419,7 @@ } - static + LOCAL_FUNC_X FT_Error TT_Load_Composite_Glyph( TT_Loader* loader ) { FT_Error error; diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c index 603546c97..764f0806f 100644 --- a/src/type1/t1driver.c +++ b/src/type1/t1driver.c @@ -324,7 +324,7 @@ - FT_EXPORT_VAR( const FT_Driver_Class ) t1_driver_class = + FT_CPLUSPLUS( const FT_Driver_Class ) t1_driver_class = { { ft_module_font_driver | ft_module_driver_scalable, diff --git a/src/type1z/z1afm.c b/src/type1z/z1afm.c index b329cd347..e47349c49 100644 --- a/src/type1z/z1afm.c +++ b/src/type1z/z1afm.c @@ -149,7 +149,7 @@ /* compare two kerning pairs */ - static + LOCAL_FUNC_X int compare_kern_pairs( const void* a, const void* b ) { diff --git a/src/type1z/z1driver.c b/src/type1z/z1driver.c index ef6570d1e..11990d870 100644 --- a/src/type1z/z1driver.c +++ b/src/type1z/z1driver.c @@ -283,7 +283,7 @@ } - FT_EXPORT_VAR( const FT_Driver_Class ) t1_driver_class = + FT_CPLUSPLUS( const FT_Driver_Class ) t1_driver_class = { { ft_module_font_driver | ft_module_driver_scalable, diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c index 99f29e866..7e467ed0a 100644 --- a/src/winfonts/winfnt.c +++ b/src/winfonts/winfnt.c @@ -588,7 +588,7 @@ } - FT_EXPORT_VAR( const FT_Driver_Class ) winfnt_driver_class = + FT_CPLUSPLUS( const FT_Driver_Class ) winfnt_driver_class = { { ft_module_font_driver,