adding new experimental header files

This commit is contained in:
David Turner 2002-04-17 22:54:02 +00:00
parent 0b12544efd
commit d833d4c12d
4 changed files with 321 additions and 0 deletions

View File

@ -0,0 +1,69 @@
#ifndef __FT_SYSTEM_IO_H__
#define __FT_SYSTEM_IO_H__
#include <ft2build.h>
#include FT_INTERNAL_OBJECT_H
FT_BEGIN_HEADER
/* handle to a FT_Stream object */
typedef struct FT_StreamRec_* FT_Stream;
/* handle to the FT_Stream class */
typedef const struct FT_Stream_ClassRec_* FT_Stream_Class;
/* a method used to read data from a stream into a buffer */
typedef FT_ULong (*FT_Stream_ReadFunc)( FT_Stream stream,
FT_Byte* buffer,
FT_ULong size );
/* a method used to seek to a new position within a stream */
/* position is always relative to the start */
typedef FT_Error (*FT_Stream_SeekFunc)( FT_Stream stream,
FT_ULong pos );
/* the stream class structure + some useful macros */
typedef struct FT_Stream_ClassRec_
{
FT_ClassRec clazz;
FT_Stream_ReadFunc stream_read;
FT_Stream_SeekFunc stream_seek;
} FT_Stream_ClassRec;
#define FT_STREAM_CLASS(x) ((FT_Stream_Class)(x))
#define FT_STREAM_CLASS__READ(x) FT_STREAM_CLASS(x)->stream_read
#define FT_STREAM_CLASS__SEEK(x) FT_STREAM_CLASS(x)->stream_seek;
/* the base FT_Stream object structure */
typedef struct FT_StreamRec_
{
FT_ObjectRec object;
FT_ULong size;
FT_ULong pos;
const FT_Byte* base;
const FT_Byte* cursor;
const FT_Byte* limit;
} FT_StreamRec;
/* some useful macros */
#define FT_STREAM(x) ((FT_Stream)(x))
#define FT_STREAM_P(x) ((FT_Stream*)(x))
#define FT_STREAM__READ(x) FT_STREAM_CLASS__READ(FT_OBJECT__CLASS(x))
#define FT_STREAM__SEEK(x) FT_STREAM_CLASS__SEEK(FT_OBJECT__CLASS(x))
#define FT_STREAM_IS_BASED(x) ( FT_STREAM(x)->base != NULL )
#if 0
#endif
/* */
FT_END_HEADER
#endif /* __FT_SYSTEM_STREAM_H__ */

View File

@ -0,0 +1,67 @@
#ifndef __FT_SYSTEM_MEMORY_H__
#define __FT_SYSTEM_MEMORY_H__
#include <ft2build.h>
FT_BEGIN_HEADER
/* handle to memory structure */
typedef struct FT_MemoryRec_* FT_Memory;
/* a function used to allocate a new block of memory from a heap */
typedef FT_Pointer (*FT_Memory_AllocFunc)( FT_ULong size,
FT_Memory memory );
/* a function used to free a block of memory */
typedef void (*FT_Memory_FreeFunc) ( FT_Pointer block,
FT_Memory memory );
/* a function used to reallocate a given memory block to a new size */
typedef FT_Pointer (*FT_Memory_ReallocFunc)( FT_Pointer block,
FT_ULong new_size,
FT_ULong cur_size,
FT_Memory memory );
/* a function called to allocate a new structure of 'size' bytes that */
/* will be used for a new FT_Memory object.. */
/* */
typedef FT_Pointer (*FT_Memory_CreateFunc)( FT_UInt size,
FT_Pointer init_data );
/* a function used to destroy a FT_Memory object */
typedef void (*FT_Memory_DestroyFunc)( FT_Memory memory );
/* a structure holding the functions used to describe a given FT_Memory */
/* implementation.. */
/* */
typedef struct FT_Memory_FuncsRec_
{
FT_Memory_AllocFunc mem_alloc;
FT_Memory_FreeFunc mem_free;
FT_Memory_ReallocFunc mem_realloc;
FT_Memory_CreateFunc mem_create;
FT_Memory_DestroyFunc mem_destroy;
} FT_Memory_FuncsRec, *FT_Memory_Funcs;
/* a function used to create a new custom FT_Memory object */
/* */
FT_BASE_DEF( FT_Memory )
ft_memory_new( FT_Memory_Funcs mem_funcs,
FT_Pointer mem_init_data );
/* a function used to destroy a custom FT_Memory object */
FT_BASE_DEF( void )
ft_memory_destroy( FT_Memory memory );
/* a pointer to the default memory functions used by FreeType in a */
/* given build. By default, uses the ISO C malloc/free/realloc */
/* */
FT_APIVAR( const FT_MemoryFuncs ) ft_memory_funcs_default;
/* */
FT_END_HEADER
#endif /* __FT_SYSTEM_MEMORY_H__ */

View File

@ -0,0 +1,83 @@
#ifndef __FT_EXCEPT_H__
#define __FT_EXCEPT_H__
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
FT_BEGIN_HEADER
typedef struct FT_XHandlerRec_* FT_XHandler;
typedef struct FT_XHandlerRec_
{
FT_XHandler previous;
ft_jmp_buf jump_buffer;
volatile FT_Error error;
FT_Pointer cleanup;
} FT_XHandlerRec;
typedef void (*FT_CleanupFunc)( FT_Pointer item,
FT_Pointer item_data );
/* the size of a cleanup chunk in bytes is FT_CLEANUP_CHUNK_SIZE*12 + 4 */
/* this must be a small power of 2 whenever possible.. */
/* */
/* with a value of 5, we have a byte size of 64 bytes per chunk.. */
/* */
#define FT_CLEANUP_CHUNK_SIZE 5
typedef struct FT_CleanupItemRec_
{
FT_Pointer item;
FT_CleanupFunc item_func;
FT_Pointer item_data;
} FT_CleanupItemRec;
typedef struct FT_CleanupChunkRec_* FT_CleanupChunk;
typedef struct FT_CleanupChunkRec_
{
FT_CleanupChunk link;
FT_CleanupItemRec items[ FT_CLEANUP_CHUNK_SIZE ];
} FT_CleanupChunkRec;
typedef struct FT_CleanupStackRec_
{
FT_CleanupItem top;
FT_CleanupChunk chunk;
FT_Memory memory;
} FT_CleanupStackRec, *FT_CleanupStack;
FT_BASE_DEF( void )
ft_cleanup_stack_push( FT_CleanupStack stack,
FT_Pointer item,
FT_CleanupFunc item_func,
FT_Pointer item_data );
FT_BASE_DEF( void )
ft_cleanup_stack_pop( FT_CleanupStack stack,
FT_Int destroy );
FT_BASE_DEF( FT_Pointer )
ft_cleanup_stack_peek( FT_CleanupStack stack );
FT_BASE_DEF( void )
ft_xhandler_enter( FT_XHandler xhandler,
FT_Memory memory );
FT_BASE_DEF( void )
ft_xhandler_exit( FT_XHandler xhandler );
FT_END_HEADER
#endif /* __FT_EXCEPT_H__ */

View File

@ -0,0 +1,102 @@
#ifndef __FT_OBJECT_H__
#define __FT_OBJECT_H__
#include <ft2build.h>
#include FT_FREETYPE_H
FT_BEGIN_HEADER
typedef struct FT_ObjectRec_* FT_Object;
typedef const struct FT_ClassRec_* FT_Class;
typedef const struct FT_TypeRec_* FT_Type;
typedef struct FT_ObjectRec_
{
FT_Class clazz;
FT_Int ref_count;
} FT_ObjectRec;
#define FT_OBJECT(x) ((FT_Object)(x))
#define FT_OBJECT_P(x) ((FT_Object*)(x))
#define FT_OBJECT__CLASS(x) FT_OBJECT(x)->clazz
#define FT_OBJECT__REF_COUNT(x) FT_OBJECT(x)->ref_count
#define FT_OBJECT__MEMORY(x) FT_CLASS__MEMORY(FT_OBJECT(x)->clazz)
#define FT_OBJECT__LIBRARY(x) FT_CLASS__LIBRARY(FT_OBJECT(x)->clazz)
typedef void (*FT_Object_InitFunc)( FT_Object object,
FT_Pointer init_data );
typedef void (*FT_Object_DoneFunc)( FT_Object object );
typedef void (*FT_Object_CopyFunc)( FT_Object target,
FT_Object source );
typedef struct FT_ClassRec_
{
FT_ObjectRec object;
FT_UInt32 magic;
FT_Type type;
FT_Memory memory;
FT_Library library;
FT_Pointer info;
FT_Pointer data;
FT_UInt obj_size;
FT_Object_InitFunc obj_init;
FT_Object_DoneFunc obj_done;
FT_Object_CopyFunc obj_copy;
} FT_ClassRec;
#define FT_CLASS(x) ((FT_Class)(x))
#define FT_CLASS_P(x) ((FT_Class*)(x))
#define FT_CLASS__MEMORY(x) FT_CLASS(x)->memory
#define FT_CLASS__LIBRARY(x) FT_CLASS(x)->library
#define FT_CLASS__MAGIC(x) FT_CLASS(x)->magic
#define FT_CLASS__TYPE(x) FT_CLASS(x)->type
#define FT_CLASS__DATA(x) FT_CLASS(x)->data
#define FT_CLASS__INFO(x) FT_CLASS(x)->info
typedef struct FT_TypeRec_
{
const char* name;
FT_Type super;
FT_UInt class_size;
FT_Object_InitFunc class_init;
FT_Object_DoneFunc class_done;
FT_UInt obj_size;
FT_Object_InitFunc obj_init;
FT_Object_DoneFunc obj_done;
FT_Object_CopyFunc obj_copy;
} FT_TypeRec;
#define FT_TYPE(x) ((FT_Type)(x))
/* check that a handle points to a valid object */
FT_BASE_DEF( FT_Int )
ft_object_check( FT_Pointer obj );
/* check that an object is of a given class */
FT_BASE_DEF( FT_Int )
ft_object_is_a( FT_Pointer obj,
FT_Class clazz );
FT_BASE_DEF( FT_Object )
ft_object_new( FT_Class clazz,
FT_Pointer init_data );
FT_END_HEADER
#endif /* __FT_OBJECT_H__ */