Formatting; adding some tracing code.

This commit is contained in:
Werner Lemberg 2000-06-02 21:31:32 +00:00
parent 91e52d416a
commit 9a754ce32b
9 changed files with 130 additions and 59 deletions

View File

@ -1,6 +1,6 @@
/************************************************************************** /**************************************************************************
* *
* ftsystem.h 1.0 * ftsystem.c 1.0
* *
* Unix-specific FreeType low-level system interface * Unix-specific FreeType low-level system interface
* *
@ -9,7 +9,7 @@
* as thread synchronisation. * as thread synchronisation.
* *
* *
* Copyright 1996-1999 by * Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg * David Turner, Robert Wilhelm, and Werner Lemberg
* *
* This file is part of the FreeType project, and may only be used * This file is part of the FreeType project, and may only be used
@ -208,14 +208,14 @@
if (file < 0) if (file < 0)
{ {
FT_ERROR(( "FT.Unix.Open:" )); FT_ERROR(( "FT.Unix.Open:" ));
FT_ERROR(( " could not open '%s'\n", filepathname )); FT_ERROR(( " could not open `%s'\n", filepathname ));
return FT_Err_Cannot_Open_Stream; return FT_Err_Cannot_Open_Stream;
} }
if (fstat( file, &stat_buf ) < 0) if (fstat( file, &stat_buf ) < 0)
{ {
FT_ERROR(( "FT.Unix.Open:" )); FT_ERROR(( "FT.Unix.Open:" ));
FT_ERROR(( " could not 'fstat' file '%s'\n", filepathname )); FT_ERROR(( " could not `fstat' file `%s'\n", filepathname ));
goto Fail_Map; goto Fail_Map;
} }
@ -231,7 +231,7 @@
if ( (long)stream->base == -1 ) if ( (long)stream->base == -1 )
{ {
FT_ERROR(( "FT.Unix.Open:" )); FT_ERROR(( "FT.Unix.Open:" ));
FT_ERROR(( " Could not map file '%s'\n", filepathname )); FT_ERROR(( " Could not map file `%s'\n", filepathname ));
goto Fail_Map; goto Fail_Map;
} }
@ -244,7 +244,7 @@
stream->read = 0; stream->read = 0;
FT_TRACE1(( "FT.Unix.Open:" )); FT_TRACE1(( "FT.Unix.Open:" ));
FT_TRACE1(( " opened '%s' (%d bytes) succesfully\n", FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
filepathname, stream->size )); filepathname, stream->size ));
return FT_Err_Ok; return FT_Err_Ok;

View File

@ -206,8 +206,8 @@
/* */ /* */
/* Don't define any of these macros to compile in `release' mode. */ /* Don't define any of these macros to compile in `release' mode. */
/* */ /* */
#undef FT_DEBUG_LEVEL_ERROR #define FT_DEBUG_LEVEL_ERROR
#undef FT_DEBUG_LEVEL_TRACE #define FT_DEBUG_LEVEL_TRACE
/*************************************************************************/ /*************************************************************************/

View File

@ -41,12 +41,13 @@
#define SQRT_64( z ) FT_Sqrt64( z ) #define SQRT_64( z ) FT_Sqrt64( z )
FT_EXPORT_DEF(FT_Int32) FT_Sqrt64( FT_Int64 x ); FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt64( FT_Int64 l );
#endif /* OLD_CALCS */ #endif /* OLD_CALCS */
#else /* LONG64 */ #else /* LONG64 */
typedef struct FT_Int64_ typedef struct FT_Int64_
{ {
FT_Word32 lo; FT_Word32 lo;
@ -58,17 +59,22 @@
#define MUL_64( x, y, z ) FT_MulTo64( x, y, &z ) #define MUL_64( x, y, z ) FT_MulTo64( x, y, &z )
#define DIV_64( x, y ) FT_Div64by32( &x, y ) #define DIV_64( x, y ) FT_Div64by32( &x, y )
FT_EXPORT_DEF(void) FT_Add64 ( FT_Int64* x, FT_Int64* y, FT_Int64* z ); FT_EXPORT_DEF( void ) FT_Add64 ( FT_Int64* x,
FT_Int64* y,
FT_Int64* z );
FT_EXPORT_DEF(void) FT_MulTo64 ( FT_Int32 x, FT_Int32 y, FT_Int64* z ); FT_EXPORT_DEF( void ) FT_MulTo64 ( FT_Int32 x,
FT_Int32 y,
FT_Int64* z );
FT_EXPORT_DEF(FT_Int32) FT_Div64by32( FT_Int64* x, FT_Int32 y ); FT_EXPORT_DEF( FT_Int32 ) FT_Div64by32( FT_Int64* x,
FT_Int32 y );
#ifdef FT_CONFIG_OPTION_OLD_CALCS #ifdef FT_CONFIG_OPTION_OLD_CALCS
#define SQRT_64( z ) FT_Sqrt64( &z ) #define SQRT_64( z ) FT_Sqrt64( &z )
FT_EXPORT_DEF(FT_Int32) FT_Sqrt64( FT_Int64* x ); FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt64( FT_Int64* x );
#endif /* OLD_CALC */ #endif /* OLD_CALC */
@ -77,10 +83,12 @@
#ifndef FT_CONFIG_OPTION_OLD_CALCS #ifndef FT_CONFIG_OPTION_OLD_CALCS
#define SQRT_32( x ) FT_Sqrt32( x ) #define SQRT_32( x ) FT_Sqrt32( x )
BASE_DEF(FT_Int32) FT_Sqrt32( FT_Int32 x );
#endif /* FT_CONFIG_OPTION_OLD_CALCS */
BASE_DEF(FT_Int32) FT_Sqrt32( FT_Int32 l );
#endif
/*************************************************************************/ /*************************************************************************/
/* */ /* */
@ -95,8 +103,8 @@
#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 ) #define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 )
#define FLOAT_TO_FIXED( x ) ( (FT_Long)(x * 65536.0) ) #define FLOAT_TO_FIXED( x ) ( (FT_Long)(x * 65536.0) )
#define ROUND_F26DOT6( x ) ( x >= 0 ? ( ((x) + 32) & -64) \ #define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \
: ( -((32 - (x)) & -64) ) ) : ( -( ( 32 - (x) ) & -64 ) ) )
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -15,46 +15,28 @@
/* */ /* */
/***************************************************************************/ /***************************************************************************/
/*************************************************************************/
/* */
/* This component contains various macros and functions used to ease the */
/* debugging of the FreeType engine. Its main purpose is in assertion */
/* checking, tracing, and error detection. */
/* */
/* There are now three debugging modes: */
/* */
/* - trace mode */
/* */
/* Error and trace messages are sent to the log file (which can be the */
/* standard error output). */
/* */
/* - error mode */
/* */
/* Only error messages are generated. */
/* */
/* - release mode: */
/* */
/* No error message is sent or generated. The code is free from any */
/* debugging parts. */
/* */
/*************************************************************************/
#ifndef FTDEBUG_H #ifndef FTDEBUG_H
#define FTDEBUG_H #define FTDEBUG_H
#include <freetype/config/ftconfig.h> /* for FT_DEBUG_LEVEL_TRACE, FT_DEBUG_LEVEL_ERROR */ #include <freetype/config/ftconfig.h> /* for FT_DEBUG_LEVEL_TRACE, */
/* FT_DEBUG_LEVEL_ERROR */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* A very stupid pre-processor trick. See K&R version 2 */ /* A very stupid pre-processor trick. See K&R version 2 */
/* section A12.3 for details.. */ /* section A12.3 for details... */
#define FT_CAT(x,y) x ## y /* */
#define FT_XCAT(x,y) FT_CAT(x,y) /* It is also described in the section `Separate */
/* Expansion of Macro Arguments' in the info file */
/* `cpp.info', describing GNU cpp. */
/* */
#define FT_CAT( x, y ) x ## y
#define FT_XCAT( x, y ) FT_CAT( x, y )
#ifdef FT_DEBUG_LEVEL_TRACE #ifdef FT_DEBUG_LEVEL_TRACE
@ -64,15 +46,14 @@
/* the first level must always be `trace_any' */ /* the first level must always be `trace_any' */
trace_any = 0, trace_any = 0,
/* first, define an enum for each common component */ /* we start with an enum for each common component */
trace_io, /* in ftsys */ trace_io, /* i/o monitoring -- see ftsystem.c */
trace_memory, /* in ftsys */ trace_memory, /* memory manager -- see ftobjs.c */
trace_sync, /* in ftsys */ trace_stream, /* stream manager -- see ftstream.c */
trace_stream, /* stream manager - see ftstream.c */ trace_calc, /* computations -- see ftcalc.c */
trace_calc, /* computations - see ftcalc.c */ trace_raster, /* raster -- see ftraster.c */
trace_raster, /* raster - see ftraster.c */ trace_list, /* list manager -- see ftlist.c */
trace_list, /* list manager - see ftlist.c */ trace_objs, /* base objects -- see ftobjs.c */
trace_objs, /* base objects - see ftobjs.c */
/* then define an enum for each TrueType driver component */ /* then define an enum for each TrueType driver component */
trace_ttobjs, trace_ttobjs,
@ -92,6 +73,7 @@
/* other trace levels */ /* other trace levels */
trace_init, trace_init,
trace_extend,
/* the last level must always be `trace_max' */ /* the last level must always be `trace_max' */
trace_max trace_max

View File

@ -16,6 +16,31 @@
/***************************************************************************/ /***************************************************************************/
/*************************************************************************/
/* */
/* This component contains various macros and functions used to ease the */
/* debugging of the FreeType engine. Its main purpose is in assertion */
/* checking, tracing, and error detection. */
/* */
/* There are now three debugging modes: */
/* */
/* - trace mode */
/* */
/* Error and trace messages are sent to the log file (which can be the */
/* standard error output). */
/* */
/* - error mode */
/* */
/* Only error messages are generated. */
/* */
/* - release mode: */
/* */
/* No error message is sent or generated. The code is free from any */
/* debugging parts. */
/* */
/*************************************************************************/
#include <freetype/internal/ftdebug.h> #include <freetype/internal/ftdebug.h>
#ifdef FT_DEBUG_LEVEL_TRACE #ifdef FT_DEBUG_LEVEL_TRACE

View File

@ -27,7 +27,13 @@
#include <freetype/internal/ftextend.h> #include <freetype/internal/ftextend.h>
/* required by the tracing mode */
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT #undef FT_COMPONENT
#define FT_COMPONENT trace_extend #define FT_COMPONENT trace_extend
@ -71,6 +77,8 @@
registry->cur_offset = 0; registry->cur_offset = 0;
driver->extensions = registry; driver->extensions = registry;
FT_TRACE2(( "FT_Init_Extensions: success" ));
return FT_Err_Ok; return FT_Err_Ok;
} }
@ -144,6 +152,9 @@
registry->num_extensions++; registry->num_extensions++;
registry->cur_offset += ( cur->size + FT_ALIGNMENT-1 ) & -FT_ALIGNMENT; registry->cur_offset += ( cur->size + FT_ALIGNMENT-1 ) & -FT_ALIGNMENT;
FT_TRACE1(( "FT_Register_Extension: `%s' successfully registered",
cur->id ));
} }
return FT_Err_Ok; return FT_Err_Ok;
@ -192,12 +203,17 @@
if ( strcmp( cur->id, extension_id ) == 0 ) if ( strcmp( cur->id, extension_id ) == 0 )
{ {
*extension_interface = cur->interface; *extension_interface = cur->interface;
FT_TRACE1(( "FT_Get_Extension: got `%s'", extension_id ));
return (void*)((char*)face->extensions + cur->offset); return (void*)((char*)face->extensions + cur->offset);
} }
} }
/* could not find the extension id */ /* could not find the extension id */
FT_ERROR(( "FT_Get_Extension: couldn't find `%s'", extension_id ));
*extension_interface = 0; *extension_interface = 0;
return 0; return 0;

View File

@ -42,6 +42,13 @@
#include <freetype/internal/ftdebug.h> #include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftdriver.h> #include <freetype/internal/ftdriver.h>
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT #undef FT_COMPONENT
#define FT_COMPONENT trace_init #define FT_COMPONENT trace_init

View File

@ -19,6 +19,13 @@
#include <freetype/internal/ftstream.h> #include <freetype/internal/ftstream.h>
#include <freetype/internal/ftdebug.h> #include <freetype/internal/ftdebug.h>
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT #undef FT_COMPONENT
#define FT_COMPONENT trace_stream #define FT_COMPONENT trace_stream

View File

@ -1,6 +1,6 @@
/***************************************************************************/ /***************************************************************************/
/* */ /* */
/* ftsystem.h */ /* ftsystem.c */
/* */ /* */
/* ANSI-specific FreeType low-level system interface (body). */ /* ANSI-specific FreeType low-level system interface (body). */
/* */ /* */
@ -26,6 +26,7 @@
#include <freetype/config/ftconfig.h> #include <freetype/config/ftconfig.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/ftsystem.h> #include <freetype/ftsystem.h>
#include <freetype/fterrors.h> #include <freetype/fterrors.h>
#include <freetype/fttypes.h> #include <freetype/fttypes.h>
@ -137,6 +138,17 @@
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_io
/* We use the macro STREAM_FILE for convenience to extract the */
/* system-specific stream handle from a given FreeType stream object */
#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer ) #define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer )
@ -155,6 +167,10 @@
void ft_close_stream( FT_Stream stream ) void ft_close_stream( FT_Stream stream )
{ {
fclose( STREAM_FILE( stream ) ); fclose( STREAM_FILE( stream ) );
stream->descriptor.pointer = NULL;
stream->size = 0;
stream->base = 0;
} }
@ -220,18 +236,28 @@
file = fopen( filepathname, "rb" ); file = fopen( filepathname, "rb" );
if ( !file ) if ( !file )
{
FT_ERROR(( "FT_New_Stream:" ));
FT_ERROR(( " could not open `%s'\n", filepathname ));
return FT_Err_Cannot_Open_Resource; return FT_Err_Cannot_Open_Resource;
}
fseek( file, 0, SEEK_END ); fseek( file, 0, SEEK_END );
stream->size = ftell( file ); stream->size = ftell( file );
fseek( file, 0, SEEK_SET ); fseek( file, 0, SEEK_SET );
stream->descriptor.pointer = file; stream->descriptor.pointer = file;
stream->pathname.pointer = (char*)filepathname;
stream->pos = 0; stream->pos = 0;
stream->read = ft_io_stream; stream->read = ft_io_stream;
stream->close = ft_close_stream; stream->close = ft_close_stream;
FT_TRACE1(( "FT_New_Stream:" ));
FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
filepathname, stream->size ));
return FT_Err_Ok; return FT_Err_Ok;
} }