From c7b1d818a887cb148fb9071ffe3c8e3977668be7 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 19 Jun 2001 13:41:59 +0000 Subject: [PATCH] * include/freetype/fterrors.h: updated some of the error macros to simplify Werner's latest tricks :o) --- ChangeLog | 12 ++++++ include/freetype/fterrors.h | 81 +++++++++++++++++++++++++------------ include/freetype/ftmoderr.h | 57 +++++++++++++++++--------- src/autohint/aherrors.h | 9 +---- src/cache/ftcerror.h | 9 +---- src/cff/cfferrs.h | 8 +--- src/cid/ciderrs.h | 9 +---- src/pcf/pcferror.h | 9 +---- src/psaux/psauxerr.h | 9 +---- src/psnames/psnamerr.h | 9 +---- src/raster/rasterrs.h | 9 +---- src/sfnt/sferrors.h | 9 +---- src/sfnt/ttsbit.c | 4 +- src/smooth/ftsmerrs.h | 9 +---- src/truetype/tterrors.h | 9 +---- src/type1/t1errors.h | 9 +---- src/winfonts/fnterrs.h | 9 +---- 17 files changed, 134 insertions(+), 136 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e672d499..47f9291b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2001-06-19 David Turner + + * include/freetype/fterrors.h: updated some of the error macros to + simplify Werner's latest tricks :o) + + * include/freetype/freetype.h (FT_New_Memory_Face): updated docs + + Removing _lots_ of compiler warnings when the most pedantic warning + levels of Visual C++ and Borland C++ are used. Too many files to be + listed here.., but FT2 now compiles without warnings with VC++ and + the "/W4" warning level (lint-style) + 2001-06-18 Werner Lemberg Minor cleanups to remove compiler warnings. diff --git a/include/freetype/fterrors.h b/include/freetype/fterrors.h index bdfc8b016..3228f91f9 100644 --- a/include/freetype/fterrors.h +++ b/include/freetype/fterrors.h @@ -85,6 +85,8 @@ #ifndef __FTERRORS_H__ #define __FTERRORS_H__ +/* include module base error codes */ +#include FT_MODULE_ERRORS_H /*******************************************************************/ /*******************************************************************/ @@ -93,37 +95,59 @@ /***** *****/ /*******************************************************************/ /*******************************************************************/ + +#undef FT_NEED_EXTERN_C +#define FT_ERR_XCAT(x,y) x ## y +#define FT_ERR_CAT(x,y) FT_ERR_XCAT(x,y) -#include FT_MODULE_ERRORS_H -#undef FT_NEED_EXTERN_C +/* FT_ERR_PREFIX is used as a prefix for error identifiers */ +/* by default, we use "FT_Err_" */ +/* */ +#ifndef FT_ERR_PREFIX +# define FT_ERR_PREFIX FT_Err_ +#endif + + + +/* FT_ERR_BASE is used as the base for module-specific errors */ +/* */ +#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS +# ifndef FT_ERR_BASE +# define FT_ERR_BASE FT_Mod_Err_Base +# endif +#else +# define FT_ERR_BASE 0 +#endif + + + +/* if FT_ERRORDEF is not defined, we need to define a simple enumeration */ +/* type.. */ +/* */ #ifndef FT_ERRORDEF # define FT_ERRORDEF( e, v, s ) e = v, +# define FT_ERROR_START_LIST enum { +# define FT_ERROR_END_LIST FT_ERR_CAT(FT_ERR_PREFIX,Max) }; # ifdef __cplusplus -# define FT_NEED_EXTERN_C +# define FT_NEED_EXTERN_C extern "C" { # endif #endif /* !FT_ERRORDEF */ -#ifndef FT_ERROR_START_LIST -# define FT_ERROR_START_LIST enum { -#endif - -#ifndef FT_ERROR_END_LIST -# define FT_ERROR_END_LIST FT_Err_Max }; -#endif +/* this macro is used to define an error */ +# define FT_ERRORDEF_( e, v, s ) \ + FT_ERRORDEF( FT_ERR_CAT(FT_ERR_PREFIX,e), v + FT_ERR_BASE, s ) +/* this is only used for FT_Err_Ok, which must be 0 !! */ +# define FT_NOERRORDEF_( e, v, s ) \ + FT_ERRORDEF( FT_ERR_CAT(FT_ERR_PREFIX,e), v, s ) -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( FT_Err_ ## e, v + FT_Mod_Err_Base, s ) - -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( FT_Err_ ## e, v, s ) /*******************************************************************/ @@ -134,8 +158,9 @@ /*******************************************************************/ /*******************************************************************/ +#ifdef FT_ERROR_START_LIST FT_ERROR_START_LIST - +#endif /* generic errors */ @@ -313,8 +338,9 @@ "argument stack underflow" ) +#ifdef FT_ERROR_END_LIST FT_ERROR_END_LIST - +#endif /*******************************************************************/ /*******************************************************************/ @@ -324,17 +350,22 @@ /*******************************************************************/ /*******************************************************************/ -#undef FT_ERROR_START_LIST -#undef FT_ERROR_END_LIST -#undef FT_ERRORDEF -#undef FT_ERRORDEF_ -#undef FT_NOERRORDEF_ - - #ifdef FT_NEED_EXTERN_C } #endif -#endif /* __FT_ERRORS_H__ */ +#undef FT_ERROR_START_LIST +#undef FT_ERROR_END_LIST + +#undef FT_ERRORDEF +#undef FT_ERRORDEF_ +#undef FT_NOERRORDEF_ + +#undef FT_NEED_EXTERN_C +#undef FT_ERR_PREFIX +#undef FT_ERR_BASE +#undef FT_ERR_CONCAT + +#endif /* __FTERRORS_H__ */ /* END */ diff --git a/include/freetype/ftmoderr.h b/include/freetype/ftmoderr.h index 71252a1cc..0ebbc6984 100644 --- a/include/freetype/ftmoderr.h +++ b/include/freetype/ftmoderr.h @@ -58,29 +58,40 @@ #define __FTMODERR_H__ -#undef FT_NEED_EXTERN_C - - - + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** SETUP MACROS *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ +#undef FT_NEED_EXTERN_C #ifndef FT_MODERRDEF -#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS -#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = v, -#else -#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = 0, -#endif +# ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS +# define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = v, +# else +# define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = 0, +# endif -#define FT_MODERR_START_LIST enum { -#define FT_MODERR_END_LIST FT_Mod_Err_Max }; +# define FT_MODERR_START_LIST enum { +# define FT_MODERR_END_LIST FT_Mod_Err_Max }; -#ifdef __cplusplus -#define FT_NEED_EXTERN_C +# ifdef __cplusplus +# define FT_NEED_EXTERN_C extern "C" { -#endif +# endif #endif /* !FT_MODERRDEF */ + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** LIST MODULE ERROR BASES *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ #ifdef FT_MODERR_START_LIST FT_MODERR_START_LIST @@ -107,16 +118,24 @@ FT_MODERR_END_LIST #endif - -#undef FT_MODERR_START_LIST -#undef FT_MODERR_END_LIST -#undef FT_MODERRDEF - + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** CLEANUP *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ #ifdef FT_NEED_EXTERN_C } #endif +#undef FT_MODERR_START_LIST +#undef FT_MODERR_END_LIST +#undef FT_MODERRDEF +#undef FT_NEED_EXTERN_C + + #endif /* __FTMODERR_H__ */ diff --git a/src/autohint/aherrors.h b/src/autohint/aherrors.h index b236a64e8..0965d1f94 100644 --- a/src/autohint/aherrors.h +++ b/src/autohint/aherrors.h @@ -30,13 +30,8 @@ #undef __FTERRORS_H__ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( AH_Err_ ## e, v + FT_Mod_Err_Autohint, s ) -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( AH_Err_ ## e, v, s ) - -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST AH_Err_Max }; +#define FT_ERR_PREFIX AH_Err_ +#define FT_ERR_BASE FT_Mod_Err_Autohint #include FT_ERRORS_H diff --git a/src/cache/ftcerror.h b/src/cache/ftcerror.h index 3da42b3ea..dc0a5c615 100644 --- a/src/cache/ftcerror.h +++ b/src/cache/ftcerror.h @@ -30,13 +30,8 @@ #undef __FTERRORS_H__ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( FTC_Err_ ## e, v + FT_Mod_Err_Cache, s ) -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( FTC_Err_ ## e, v, s ) - -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST FTC_Err_Max }; +#define FT_ERR_PREFIX FTC_Err_ +#define FT_ERR_BASE FT_Mod_Err_Cache #include FT_ERRORS_H diff --git a/src/cff/cfferrs.h b/src/cff/cfferrs.h index 0ae0a3ded..0eb704f1c 100644 --- a/src/cff/cfferrs.h +++ b/src/cff/cfferrs.h @@ -29,13 +29,9 @@ #undef __FTERRORS_H__ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( CFF_Err_ ## e, v + FT_Mod_Err_CFF, s ) -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( CFF_Err_ ## e, v, s ) +#define FT_ERR_PREFIX CFF_Err_ +#define FT_ERR_BASE FT_Mod_Err_CFF -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST CFF_Err_Max }; #include FT_ERRORS_H diff --git a/src/cid/ciderrs.h b/src/cid/ciderrs.h index 9aa2f38e4..c019e4758 100644 --- a/src/cid/ciderrs.h +++ b/src/cid/ciderrs.h @@ -29,13 +29,8 @@ #undef __FTERRORS_H__ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( CID_Err_ ## e, v + FT_Mod_Err_CID, s ) -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( CID_Err_ ## e, v, s ) - -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST CID_Err_Max }; +#define FT_ERR_PREFIX CID_Err_ +#define FT_ERR_BASE FT_Mod_Err_CID #include FT_ERRORS_H diff --git a/src/pcf/pcferror.h b/src/pcf/pcferror.h index 2404ea975..6e0e8d9c0 100644 --- a/src/pcf/pcferror.h +++ b/src/pcf/pcferror.h @@ -29,13 +29,8 @@ #undef __FTERRORS_H__ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( PCF_Err_ ## e, v + FT_Mod_Err_PCF, s ) -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( PCF_Err_ ## e, v, s ) - -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST PCF_Err_Max }; +#define FT_ERR_PREFIX PCF_Err_ +#define FT_ERR_BASE FT_Mod_Err_PCF #include FT_ERRORS_H diff --git a/src/psaux/psauxerr.h b/src/psaux/psauxerr.h index 2533277f2..f76365357 100644 --- a/src/psaux/psauxerr.h +++ b/src/psaux/psauxerr.h @@ -30,13 +30,8 @@ #undef __FTERRORS_H__ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( PSaux_Err_ ## e, v + FT_Mod_Err_PSaux, s ) -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( PSaux_Err_ ## e, v, s ) - -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST PSaux_Err_Max }; +#define FT_ERR_PREFIX PSaux_Err_ +#define FT_ERR_BASE FT_Mod_Err_PSaux #include FT_ERRORS_H diff --git a/src/psnames/psnamerr.h b/src/psnames/psnamerr.h index c620a879d..134845a1c 100644 --- a/src/psnames/psnamerr.h +++ b/src/psnames/psnamerr.h @@ -30,13 +30,8 @@ #undef __FTERRORS_H__ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( PSnames_Err_ ## e, v + FT_Mod_Err_PSnames, s ) -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( PSnames_Err_ ## e, v, s ) - -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST PSnames_Err_Max }; +#define FT_ERR_PREFIX PSnames_Err_ +#define FT_ERR_BASE FT_Mod_Err_PSnames #include FT_ERRORS_H diff --git a/src/raster/rasterrs.h b/src/raster/rasterrs.h index a9b380520..3e4d5fe0c 100644 --- a/src/raster/rasterrs.h +++ b/src/raster/rasterrs.h @@ -30,13 +30,8 @@ #undef __FTERRORS_H__ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( Raster_Err_ ## e, v + FT_Mod_Err_Raster, s ) -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( Raster_Err_ ## e, v, s ) - -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST Raster_Err_Max }; +#define FT_ERR_PREFIX Raster_Err_ +#define FT_ERR_BASE FT_Mod_Err_Raster #include FT_ERRORS_H diff --git a/src/sfnt/sferrors.h b/src/sfnt/sferrors.h index fefd160de..d9c4f7665 100644 --- a/src/sfnt/sferrors.h +++ b/src/sfnt/sferrors.h @@ -29,13 +29,8 @@ #undef __FTERRORS_H__ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( SFNT_Err_ ## e, v + FT_Mod_Err_SFNT, s ) -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( SFNT_Err_ ## e, v, s ) - -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST SFNT_Err_Max }; +#define FT_ERR_PREFIX SFNT_Err_ +#define FT_ERR_BASE FT_Mod_Err_SFNT #include FT_ERRORS_H diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c index 8850c6af6..f3b8eec25 100644 --- a/src/sfnt/ttsbit.c +++ b/src/sfnt/ttsbit.c @@ -105,7 +105,7 @@ for ( height = target->rows; height > 0; height-- ) { FT_Byte* cur = line_buff; /* current write cursor */ - FT_UInt count = line_bits; /* # of bits to extract per line */ + FT_Int count = line_bits; /* # of bits to extract per line */ FT_Byte shift = (FT_Byte)(x_offset & 7); /* current write shift */ FT_Byte space = (FT_Byte)(8 - shift); @@ -156,7 +156,7 @@ /* ensure that there are at least `count' bits in the accumulator */ - if ( loaded < count ) + if ( (FT_Int)loaded < count ) { acc |= (FT_UShort)*source++ << ( 8 - loaded ); loaded += 8; diff --git a/src/smooth/ftsmerrs.h b/src/smooth/ftsmerrs.h index 0eb4062b0..9f06bbc2c 100644 --- a/src/smooth/ftsmerrs.h +++ b/src/smooth/ftsmerrs.h @@ -30,13 +30,8 @@ #undef __FTERRORS_H__ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( Smooth_Err_ ## e, v + FT_Mod_Err_Smooth, s ) -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( Smooth_Err_ ## e, v, s ) - -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST Smooth_Err_Max }; +#define FT_ERR_PREFIX Smooth_Err_ +#define FT_ERR_BASE FT_Mod_Err_Smooth #include FT_ERRORS_H diff --git a/src/truetype/tterrors.h b/src/truetype/tterrors.h index bb611b5b7..bf67190af 100644 --- a/src/truetype/tterrors.h +++ b/src/truetype/tterrors.h @@ -30,13 +30,8 @@ #undef __FTERRORS_H__ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( TT_Err_ ## e, v + FT_Mod_Err_TrueType, s ) -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( TT_Err_ ## e, v, s ) - -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST TT_Err_Max }; +#define FT_ERR_PREFIX TT_Err_ +#define FT_ERR_BASE FT_Mod_Err_TrueType #include FT_ERRORS_H diff --git a/src/type1/t1errors.h b/src/type1/t1errors.h index cf5c8b689..90f65e60f 100644 --- a/src/type1/t1errors.h +++ b/src/type1/t1errors.h @@ -29,13 +29,8 @@ #undef __FTERRORS_H__ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( T1_Err_ ## e, v + FT_Mod_Err_Type1, s ) -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( T1_Err_ ## e, v, s ) - -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST T1_Err_Max }; +#define FT_ERR_PREFIX T1_Err_ +#define FT_ERR_BASE FT_Mod_Err_Type1 #include FT_ERRORS_H diff --git a/src/winfonts/fnterrs.h b/src/winfonts/fnterrs.h index 730d4ead3..a05a7e9be 100644 --- a/src/winfonts/fnterrs.h +++ b/src/winfonts/fnterrs.h @@ -30,13 +30,8 @@ #undef __FTERRORS_H__ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( FNT_Err_ ## e, v + FT_Mod_Err_Winfonts, s ) -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( FNT_Err_ ## e, v, s ) - -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST FNT_Err_Max }; +#define FT_ERR_PREFIX FNT_Err_ +#define FT_ERR_BASE FT_Mod_Err_Winfonts #include FT_ERRORS_H