* README, builds/unix/configure, builds/unix/configure.ac,

docs/CHANGES, include/freetype/freetype.h:

          updating version numbers for 2.1.6, and removing obsolete
          warnings in the documentation

        * include/freetype/internal/ftcore.h,
        include/freetype/internal/ftexcept.h,
        include/freetype/internal/fthash.h,
        include/freetype/internal/ftobject.h:

          removing obsolete files
This commit is contained in:
David Turner 2003-09-11 19:58:19 +00:00
parent c313c50208
commit db3faffbcf
10 changed files with 33 additions and 1359 deletions

View File

@ -28,6 +28,20 @@
Maybe 2.1.6 will be called 2.2.0 after all :-)
* README, builds/unix/configure, builds/unix/configure.ac,
docs/CHANGES, include/freetype/freetype.h:
updating version numbers for 2.1.6, and removing obsolete
warnings in the documentation
* include/freetype/internal/ftcore.h,
include/freetype/internal/ftexcept.h,
include/freetype/internal/fthash.h,
include/freetype/internal/ftobject.h:
removing obsolete files
2003-09-09 David Turner <david@freetype.org>

29
README
View File

@ -1,32 +1,3 @@
=====================================================================
IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
During development that followed the 2.1.4 release, some
unfortunate changes to the source code did break *binary*
compatibility of the library with previous releases. This had the
potential to severely break any system where a version of FreeType
was installed from recent CVS sources.
We did undo the changes, and everything should be completely
compatible now. However, due to other subtleties too long to be
explained here, there may still be a tiny risk that the current
sources break some rare applications.
This package is thus FreeType 2.1.5 release candidate 1 and has
been released for testing. If you install it on your system, please
be certain to be able to install a previous version in the case
where something would go wrong.
We will make the official 2.1.5 release as soon as we're convinced
that it will not break anything.
IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
=====================================================================
Special notes to Unix users
===========================

View File

@ -1403,7 +1403,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_config_headers="$ac_config_headers ftconfig.h:ftconfig.in"
version_info='9:4:3'
version_info='9:5:3'
ft_version=`echo $version_info | tr : .`

View File

@ -10,7 +10,7 @@ dnl configuration file -- stay in 8.3 limit
AC_CONFIG_HEADER(ftconfig.h:ftconfig.in)
dnl Don't forget to update VERSION.DLL!
version_info='9:4:3'
version_info='9:5:3'
AC_SUBST(version_info)
ft_version=`echo $version_info | tr : .`
AC_SUBST(ft_version)

View File

@ -1,29 +1,20 @@
LATEST CHANGES BETWEEN 2.1.6 and 2.1.5
I. IMPORTANT BUG FIXES
- the PFR font driver didn't load kerning tables correctly,
and the functions in FT_PFR_H didn't work at all. Ugh !!
II. IMPORTANT CHANGES
- the internal module API has been heavily changed. In favor
of massive simplifications within the font engine. This
also means that authors of third-party modules will need
to adapt their code !!
=====================================================================
IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
During development that followed the 2.1.4 release, some
unfortunate changes to the source code did break *binary*
compatibility of the library with previous releases. This had the
potential to severely break any system where a version of FreeType
was installed from recent CVS sources.
We did undo the changes, and everything should be completely
compatible now. However, due to other subtleties too long to be
explained here, there may still be a tiny risk that the current
sources break some rare applications.
This package is thus FreeType 2.1.5 release candidate 1 and has
been released for testing. If you install it on your system, please
be certain to be able to install a previous version in the case
where something would go wrong.
We will make the official 2.1.5 release as soon as we're convinced
that it will not break anything.
IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
=====================================================================
LATEST CHANGES BETWEEN 2.1.5 and 2.1.4

View File

@ -35,7 +35,7 @@
/* */
#define FREETYPE_MAJOR 2
#define FREETYPE_MINOR 1
#define FREETYPE_PATCH 5
#define FREETYPE_PATCH 6
#include <ft2build.h>

View File

@ -1,185 +0,0 @@
#ifndef __FT_CORE_H__
#define __FT_CORE_H__
#include <ft2build.h>
#include FT_TYPES_H
#include FT_SYSTEM_MEMORY_H
FT_BEGIN_HEADER
/**************************************************************************/
/**************************************************************************/
/***** *****/
/***** C L E A N U P S T A C K *****/
/***** *****/
/**************************************************************************/
/**************************************************************************/
/************************************************************************
*
* @functype: FT_CleanupFunc
*
* @description:
* a function used to cleanup a given item on the cleanup stack
*
* @input:
* item :: target item pointer
* item_data :: optional argument to cleanup routine
*/
typedef void (*FT_CleanupFunc)( FT_Pointer item,
FT_Pointer item_data );
/************************************************************************
*
* @type: FT_XHandler
*
* @description:
* handle to an exception-handler structure for the FreeType
* exception sub-system
*
* @note:
* exception handlers are allocated on the stack within a
* @FT_XTRY macro. Do not try to access them directly.
*/
typedef struct FT_XHandlerRec_* FT_XHandler;
/* 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_CleanupItem limit;
FT_CleanupChunk chunk;
FT_CleanupChunkRec chunk_0; /* avoids stupid dynamic allocation */
FT_Memory memory;
} FT_CleanupStackRec, *FT_CleanupStack;
FT_BASE( void )
ft_cleanup_stack_push( FT_CleanupStack stack,
FT_Pointer item,
FT_CleanupFunc item_func,
FT_Pointer item_data );
FT_BASE( void )
ft_cleanup_stack_pop( FT_CleanupStack stack,
FT_Int destroy );
FT_BASE( FT_CleanupItem )
ft_cleanup_stack_peek( FT_CleanupStack stack );
FT_BASE( void )
ft_cleanup_throw( FT_CleanupStack stack,
FT_Error error );
/**************************************************************************/
/**************************************************************************/
/***** *****/
/***** M E M O R Y M A N A G E R *****/
/***** *****/
/**************************************************************************/
/**************************************************************************/
typedef struct FT_MemoryRec_
{
FT_Memory_AllocFunc mem_alloc; /* shortcut to funcs->mem_alloc */
FT_Memory_FreeFunc mem_free; /* shortcut to funcs->mem_free */
FT_Pointer mem_data;
const FT_Memory_Funcs mem_funcs;
FT_CleanupStackRec cleanup_stack;
FT_Pointer meta_class;
} FT_MemoryRec;
#define FT_MEMORY(x) ((FT_Memory)(x))
#define FT_MEMORY__ALLOC(x) FT_MEMORY(x)->mem_alloc
#define FT_MEMORY__FREE(x) FT_MEMORY(x)->mem_free
#define FT_MEMORY__REALLOC(x) FT_MEMORY(x)->mem_funcs->mem_realloc
#define FT_MEMORY__CLEANUP(x) (&FT_MEMORY(x)->cleanup_stack)
#define FT_MEMORY__META_CLASS(x) ((FT_MetaClass)(FT_MEMORY(x)->meta_class))
/**************************************************************************/
/**************************************************************************/
/***** *****/
/***** E X C E P T I O N H A N D L I N G *****/
/***** *****/
/**************************************************************************/
/**************************************************************************/
/************************************************************************
*
* @struct: FT_XHandlerRec
*
* @description:
* exception handler structure
*
* @fields:
* previous :: previous handler in chain.
* jum_buffer :: processor state used by setjmp/longjmp to implement
* exception control transfer
* error :: exception error code
* mark :: top of cleanup stack when @FT_XTRY is used
*/
typedef struct FT_XHandlerRec_
{
FT_XHandler previous;
ft_jmp_buf jump_buffer;
volatile FT_Error error;
FT_Pointer mark;
} FT_XHandlerRec;
FT_BASE( void )
ft_xhandler_enter( FT_XHandler xhandler,
FT_Memory memory );
FT_BASE( void )
ft_xhandler_exit( FT_XHandler xhandler );
FT_END_HEADER
#endif /* __FT_CORE_H__ */

View File

@ -1,82 +0,0 @@
#ifndef __FT_EXCEPT_H__
#define __FT_EXCEPT_H__
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
FT_BEGIN_HEADER
/* I can't find a better place for this for now */
<<<<<<< ftexcept.h
=======
/* 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_CleanupItem limit;
FT_CleanupChunk chunk;
FT_CleanupChunkRec chunk_0; /* avoids stupid dynamic allocation */
FT_Memory memory;
} FT_CleanupStackRec, *FT_CleanupStack;
FT_BASE( void )
ft_cleanup_stack_push( FT_CleanupStack stack,
FT_Pointer item,
FT_CleanupFunc item_func,
FT_Pointer item_data );
FT_BASE( void )
ft_cleanup_stack_pop( FT_CleanupStack stack,
FT_Int destroy );
FT_BASE( FT_CleanupItem )
ft_cleanup_stack_peek( FT_CleanupStack stack );
FT_BASE( void )
ft_xhandler_enter( FT_XHandler xhandler,
FT_Memory memory );
FT_BASE( void )
ft_xhandler_exit( FT_XHandler xhandler );
FT_BASE( void )
ft_cleanup_throw( FT_CleanupStack stack,
FT_Error error );
>>>>>>> 1.2
FT_END_HEADER
#endif /* __FT_EXCEPT_H__ */

View File

@ -1,502 +0,0 @@
/******************************************************************
*
* fthash.h - fast dynamic hash tables
*
* Copyright 2002 by
* David Turner, Robert Wilhelm, and Werner Lemberg
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*
* This header is used to define dynamic hash tables as described
* by the article "Main-Memory Linear Hashing - Some Enhancements
* of Larson's Algorithm" by Mikael Petterson.
*
* Basically, linear hashing prevents big "stalls" during
* resizes of the buckets array by only splitting one bucket
* at a time. This ensures excellent response time even when
* the table is frequently resized..
*
*
* Note that the use of the FT_Hash type is rather unusual in order
* to be as generic and efficient as possible. See the comments in the
* following definitions for more details.
*/
#ifndef __FT_HASH_H__
#define __FT_HASH_H__
#include <ft2build.h>
#include FT_TYPES_H
FT_BEGIN_HEADER
/***********************************************************
*
* @type: FT_Hash
*
* @description:
* handle to a @FT_HashRec structure used to model a
* dynamic hash table
*/
typedef struct FT_HashRec_* FT_Hash;
/***********************************************************
*
* @type: FT_HashNode
*
* @description:
* handle to a @FT_HashNodeRec structure used to model a
* single node of a hash table
*/
typedef struct FT_HashNodeRec_* FT_HashNode;
/***********************************************************
*
* @type: FT_HashLookup
*
* @description:
* handle to a @FT_HashNode pointer. This is returned by
* the @ft_hash_lookup function and can later be used by
* @ft_hash_add or @ft_hash_remove
*/
typedef FT_HashNode* FT_HashLookup;
/***********************************************************
*
* @type: FT_Hash_EqualFunc
*
* @description:
* a function used to compare two nodes of the hash table
*
* @input:
* node1 :: handle to first node
* node2 :: handle to second node
*
* @return:
* 1 iff the 'keys' in 'node1' and 'node2' are identical.
* 0 otherwise.
*/
typedef FT_Int (*FT_Hash_EqualFunc)( FT_HashNode node1,
FT_HashNode node2 );
/***********************************************************
*
* @struct: FT_HashRec
*
* @description:
* a structure used to model a dynamic hash table.
*
* @fields:
* memory :: memory manager used to allocate
* the buckets array and the hash nodes
*
* buckets :: array of hash buckets
*
* node_size :: size of node in bytes
* node_compare :: a function used to compare two nodes
* node_hash :: a function used to compute the hash
* value of a given node
* p ::
* mask ::
* slack ::
*
* @note:
* 'p', 'mask' and 'slack' are control values managed by
* the hash table. Do not try to interpret them directly.
*
* You can grab the hash table size by calling
* '@ft_hash_get_size'.
*/
typedef struct FT_HashRec_
{
FT_HashNode* buckets;
FT_UInt p;
FT_UInt mask; /* really maxp-1 */
FT_Long slack;
FT_Hash_EqualFunc node_equal;
FT_Memory memory;
} FT_HashRec;
/***********************************************************
*
* @struct: FT_HashNodeRec
*
* @description:
* a structure used to model the root fields of a dynamic
* hash table node.
*
* it's up to client applications to "sub-class" this
* structure to add relevant (key,value) definitions
*
* @fields:
* link :: pointer to next node in bucket's collision list
* hash :: 32-bit hash value for this node
*
* @note:
* it's up to client applications to "sub-class" this structure
* to add relevant (key,value) type definitions. For example,
* if we want to build a "string -> int" mapping, we could use
* something like:
*
* {
* typedef struct MyNodeRec_
* {
* FT_HashNodeRec hnode;
* const char* key;
* int value;
*
* } MyNodeRec, *MyNode;
* }
*
*/
typedef struct FT_HashNodeRec_
{
FT_HashNode link;
FT_UInt32 hash;
} FT_HashNodeRec;
/****************************************************************
*
* @function: ft_hash_init
*
* @description:
* initialize a dynamic hash table
*
* @input:
* table :: handle to target hash table structure
* node_equal :: node comparison function
* memory :: memory manager handle used to allocate the
* buckets array within the hash table
*
* @return:
* error code. 0 means success
*
* @note:
* the node comparison function should only compare node _keys_
* and ignore values !! with good hashing computation (which the
* user must perform itself), the comparison function should be
* pretty seldom called.
*
* here is a simple example:
*
* {
* static int my_equal( MyNode node1,
* MyNode node2 )
* {
* // compare keys of 'node1' and 'node2'
* return (strcmp( node1->key, node2->key ) == 0);
* }
*
* ....
*
* ft_hash_init( &hash, (FT_Hash_EqualFunc) my_compare, memory );
* ....
* }
*/
FT_BASE( FT_Error )
ft_hash_init( FT_Hash table,
FT_Hash_EqualFunc compare,
FT_Memory memory );
/****************************************************************
*
* @function: ft_hash_lookup
*
* @description:
* search a hash table to find a node corresponding to a given
* key.
*
* @input:
* table :: handle to target hash table structure
* keynode :: handle to a reference hash node that will be
* only used for key comparisons with the table's
* elements
*
* @return:
* a pointer-to-hash-node value, which must be used as followed:
*
* - if '*result' is NULL, the key wasn't found in the hash
* table. The value of 'result' can be used to add new elements
* through @ft_hash_add however..
*
* - if '*result' is not NULL, it's a handle to the first table
* node that corresponds to the search key. The value of 'result'
* can be used to remove this element through @ft_hash_remove
*
* @note:
* here is an example:
*
* {
* // maps a string to an integer with a hash table
* // returns -1 in case of failure
* //
* int my_lookup( FT_Hash table,
* const char* key )
* {
* MyNode* pnode;
* MyNodeRec noderec;
*
* // set-up key node. It's 'hash' and 'key' fields must
* // be set correctly.. we ignore 'link' and 'value'
* //
* noderec.hnode.hash = strhash( key );
* noderec.key = key;
*
* // perform search - return value
* //
* pnode = (MyNode) ft_hash_lookup( table, &noderec );
* if ( *pnode )
* {
* // we found it
* return (*pnode)->value;
* }
* return -1;
* }
* }
*/
FT_BASE_DEF( FT_HashLookup )
ft_hash_lookup( FT_Hash table,
FT_HashNode keynode );
/****************************************************************
*
* @function: ft_hash_add
*
* @description:
* add a new node to a dynamic hash table. the user must
* call @ft_hash_lookup and allocate a new node before calling
* this function.
*
* @input:
* table :: hash table handle
* lookup :: pointer-to-hash-node value returned by @ft_hash_lookup
* new_node :: handle to new hash node. All its fields must be correctly
* set, including 'hash'.
*
* @return:
* error code. 0 means success
*
* @note:
* this function should always be used _after_ a call to @ft_hash_lookup
* that returns a pointer to a NULL handle. Here's an example:
*
* {
* // sets the value corresponding to a given string key
* //
* void my_set( FT_Hash table,
* const char* key,
* int value )
* {
* MyNode* pnode;
* MyNodeRec noderec;
* MyNode node;
*
* // set-up key node. It's 'hash' and 'key' fields must
* // be set correctly..
* noderec.hnode.hash = strhash( key );
* noderec.key = key;
*
* // perform search - return value
* pnode = (MyNode) ft_hash_lookup( table, &noderec );
* if ( *pnode )
* {
* // we found it, simply replace the value in the node
* (*pnode)->value = value;
* return;
* }
*
* // allocate a new node - and set it up
* node = (MyNode) malloc( sizeof(*node) );
* if ( node == NULL ) .....
*
* node->hnode.hash = noderec.hnode.hash;
* node->key = key;
* node->value = value;
*
* // add it to the hash table
* error = ft_hash_add( table, pnode, node );
* if (error) ....
* }
*/
FT_BASE( FT_Error )
ft_hash_add( FT_Hash table,
FT_HashLookup lookup,
FT_HashNode new_node );
/****************************************************************
*
* @function: ft_hash_remove
*
* @description:
* try to remove the node corresponding to a given key from
* a hash table. This must be called after @ft_hash_lookup
*
* @input:
* table :: hash table handle
* lookup :: pointer-to-hash-node value returned by @ft_hash_lookup
*
* @note:
* this function doesn't free the node itself !! Here's an example:
*
* {
* // sets the value corresponding to a given string key
* //
* void my_remove( FT_Hash table,
* const char* key )
* {
* MyNodeRec noderec;
* MyNode node;
*
* noderec.hnode.hash = strhash(key);
* noderec.key = key;
* node = &noderec;
*
* pnode = ft_hash_lookup( table, &noderec );
* node = *pnode;
* if ( node != NULL )
* {
* error = ft_hash_remove( table, pnode );
* if ( !error )
* free( node );
* }
* }
* }
*/
FT_BASE( FT_Error )
ft_hash_remove( FT_Hash table,
FT_HashLookup lookup );
/****************************************************************
*
* @function: ft_hash_get_size
*
* @description:
* return the number of elements in a given hash table
*
* @input:
* table :: handle to target hash table structure
*
* @return:
* number of elements. 0 if empty
*/
FT_BASE( FT_UInt )
ft_hash_get_size( FT_Hash table );
/****************************************************************
*
* @functype: FT_Hash_ForeachFunc
*
* @description:
* a function used to iterate over all elements of a given
* hash table
*
* @input:
* node :: handle to target @FT_HashNodeRec node structure
* data :: optional argument to iteration routine
*
* @also: @ft_hash_foreach
*/
typedef void (*FT_Hash_ForeachFunc)( const FT_HashNode node,
const FT_Pointer data );
/****************************************************************
*
* @function: ft_hash_foreach
*
* @description:
* parse over all elements in a hash table
*
* @input:
* table :: handle to target hash table structure
* foreach_func :: iteration routine called for each element
* foreach_data :: optional argument to the iteration routine
*
* @note:
* this function is often used to release all elements from a
* hash table. See the example given for @ft_hash_done
*/
FT_BASE( void )
ft_hash_foreach( FT_Hash table,
FT_Hash_ForeachFunc foreach_func,
const FT_Pointer foreach_data );
/****************************************************************
*
* @function: ft_hash_done
*
* @description:
* finalize a given hash table
*
* @input:
* table :: handle to target hash table structure
* node_func :: optional iteration function pointer. this
* can be used to destroy all nodes explicitely
* node_data :: optional argument to the node iterator
*
* @note:
* this function simply frees the hash table's buckets.
* you probably will need to call @ft_hash_foreach to
* destroy all its elements before @ft_hash_done, as in
* the following example:
*
* {
* static void my_node_clear( const MyNode node )
* {
* free( node );
* }
*
* static void my_done( FT_Hash table )
* {
* ft_hash_done( table, (FT_Hash_ForeachFunc) my_node_clear, NULL );
* }
* }
*/
FT_BASE( void )
ft_hash_done( FT_Hash table,
FT_Hash_ForeachFunc item_func,
const FT_Pointer item_data );
/* */
/* compute bucket index from hash value in a dynamic hash table */
/* this is only used to break encapsulation to speed lookups in */
/* the FreeType cache manager !! */
/* */
#define FT_HASH_COMPUTE_INDEX(_table,_hash,_index) \
{ \
FT_UInt _mask = (_table)->mask; \
FT_UInt _hash0 = (_hash); \
\
(_index) = (FT_UInt)( (_hash0) & _mask ) ); \
if ( (_index) < (_table)->p ) \
(_index) = (FT_uInt)( (_hash0) & ( 2*_mask+1 ) ); \
}
FT_END_HEADER
#endif /* __FT_HASH_H__ */

View File

@ -1,533 +0,0 @@
#ifndef __FT_OBJECT_H__
#define __FT_OBJECT_H__
#include <ft2build.h>
#include FT_FREETYPE_H
FT_BEGIN_HEADER
/**************************************************************
*
* @type: FT_Object
*
* @description:
* handle to a FreeType Object. See @FT_ObjectRec
*/
typedef struct FT_ObjectRec_* FT_Object;
/**************************************************************
*
* @type: FT_Class
*
* @description:
* handle to a constant class handle to a FreeType Object.
*
* Note that a class is itself a @FT_Object and are dynamically
* allocated on the heap.
*
* @also:
* @FT_ClassRec, @FT_Object, @FT_ObjectRec, @FT_Type, @FT_TypeRec
*/
typedef const struct FT_ClassRec_* FT_Class;
/**************************************************************
*
* @type: FT_Type
*
* @description:
* handle to a constant structure (of type @FT_TypeRec) used
* to describe a given @FT_Class type to the FreeType object
* sub-system.
*/
typedef const struct FT_TypeRec_* FT_Type;
/**************************************************************
*
* @struct: FT_ObjectRec
*
* @description:
* a structure describing the root fields of all @FT_Object
* class instances in FreeType
*
* @fields:
* clazz :: handle to the object's class
* ref_count :: object's reference count. Starts at 1
*/
typedef struct FT_ObjectRec_
{
FT_Class clazz;
FT_Int ref_count;
} FT_ObjectRec;
/**************************************************************
*
* @macro: FT_OBJECT (x)
*
* @description:
* a useful macro to type-cast anything to a @FT_Object
* handle. No check performed..
*/
#define FT_OBJECT(x) ((FT_Object)(x))
/**************************************************************
*
* @macro: FT_OBJECT_P (x)
*
* @description:
* a useful macro to type-cast anything to a pointer to
* @FT_Object handle.
*/
#define FT_OBJECT_P(x) ((FT_Object*)(x))
/**************************************************************
*
* @macro: FT_OBJECT__CLASS (obj)
*
* @description:
* a useful macro to return the class of any object
*/
#define FT_OBJECT__CLASS(x) FT_OBJECT(x)->clazz
/**************************************************************
*
* @macro: FT_OBJECT__REF_COUNT (obj)
*
* @description:
* a useful macro to return the reference count of any object
*/
#define FT_OBJECT__REF_COUNT(x) FT_OBJECT(x)->ref_count
/**************************************************************
*
* @macro: FT_OBJECT__MEMORY (obj)
*
* @description:
* a useful macro to return a handle to the memory manager
* used to allocate a given object
*/
#define FT_OBJECT__MEMORY(x) FT_CLASS__MEMORY(FT_OBJECT(x)->clazz)
/**************************************************************
*
* @macro: FT_OBJECT__LIBRARY (obj)
*
* @description:
* a useful macro to return a handle to the library handle
* that owns the object
*/
#define FT_OBJECT__LIBRARY(x) FT_CLASS__LIBRARY(FT_OBJECT(x)->clazz)
/**************************************************************
*
* @functype: FT_Object_InitFunc
*
* @description:
* a function used to initialize a new object
*
* @input:
* object :: target object handle
* init_data :: optional pointer to initialization data
*
* @return:
* error code. 0 means success
*/
typedef FT_Error (*FT_Object_InitFunc)( FT_Object object,
FT_Pointer init_data );
/**************************************************************
*
* @functype: FT_Object_DoneFunc
*
* @description:
* a function used to finalize a given object
*
* @input:
* object :: handle to target object
*/
typedef void (*FT_Object_DoneFunc)( FT_Object object );
/**************************************************************
*
* @struct: FT_ClassRec
*
* @description:
* a structure used to describe a given object class within
* FreeType
*
* @fields:
* object :: root @FT_ObjectRec fields, since each class is
* itself an object. (it's an instance of the
* "metaclass", a special object of the FreeType
* object sub-system.)
*
* magic :: a 32-bit magic number used for decoding
* super :: pointer to super class
* type :: the @FT_Type descriptor of this class
* memory :: the current memory manager handle
* library :: the current library handle
* info :: an opaque pointer to class-specific information
* managed by the FreeType object sub-system
*
* class_done :: the class destructor function
*
* obj_size :: size of class instances in bytes
* obj_init :: class instance constructor
* obj_done :: class instance destructor
*/
typedef struct FT_ClassRec_
{
FT_ObjectRec object;
FT_UInt32 magic;
FT_Class super;
FT_Type type;
FT_Memory memory;
FT_Library library;
FT_Pointer info;
FT_Object_DoneFunc class_done;
FT_UInt obj_size;
FT_Object_InitFunc obj_init;
FT_Object_DoneFunc obj_done;
} FT_ClassRec;
/**************************************************************
*
* @macro: FT_CLASS (x)
*
* @description:
* a useful macro to convert anything to a class handle
* without checks
*/
#define FT_CLASS(x) ((FT_Class)(x))
/**************************************************************
*
* @macro: FT_CLASS_P (x)
*
* @description:
* a useful macro to convert anything to a pointer to a class
* handle without checks
*/
#define FT_CLASS_P(x) ((FT_Class*)(x))
/**************************************************************
*
* @macro: FT_CLASS__MEMORY (clazz)
*
* @description:
* a useful macro to return the memory manager handle of a
* given class
*/
#define FT_CLASS__MEMORY(x) FT_CLASS(x)->memory
/**************************************************************
*
* @macro: FT_CLASS__LIBRARY (clazz)
*
* @description:
* a useful macro to return the library handle of a
* given class
*/
#define FT_CLASS__LIBRARY(x) FT_CLASS(x)->library
/**************************************************************
*
* @macro: FT_CLASS__TYPE (clazz)
*
* @description:
* a useful macro to return the type of a given class
* given class
*/
#define FT_CLASS__TYPE(x) FT_CLASS(x)->type
/* */
#define FT_CLASS__INFO(x) FT_CLASS(x)->info
#define FT_CLASS__MAGIC(x) FT_CLASS(x)->magic
/**************************************************************
*
* @struct: FT_TypeRec
*
* @description:
* a structure used to describe a given class to the FreeType
* object sub-system.
*
* @fields:
* name :: class name. only used for debugging
* super :: type of super-class. NULL if none
*
* class_size :: size of class structure in bytes
* class_init :: class constructor
* class_done :: class finalizer
*
* obj_size :: instance size in bytes
* obj_init :: instance constructor. can be NULL
* obj_done :: instance destructor. can be NULL
*
* @note:
* if 'obj_init' is NULL, the class will use it's parent
* constructor, if any
*
* if 'obj_done' is NULL, the class will use it's parent
* finalizer, if any
*
* the object sub-system allocates a new class, copies
* the content of its super-class into the new structure,
* _then_ calls 'clazz_init'.
*
* 'class_init' and 'class_done' can be NULL, in which case
* the parent's class constructor and destructor wil be used
*/
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_TypeRec;
/**************************************************************
*
* @macro: FT_TYPE (x)
*
* @description:
* a useful macro to convert anything to a class type handle
* without checks
*/
#define FT_TYPE(x) ((FT_Type)(x))
/**************************************************************
*
* @function: ft_object_check
*
* @description:
* checks that a handle points to a valid @FT_Object
*
* @input:
* obj :: handle/pointer
*
* @return:
* 1 iff the handle points to a valid object. 0 otherwise
*/
FT_BASE( FT_Int )
ft_object_check( FT_Pointer obj );
/**************************************************************
*
* @function: ft_object_is_a
*
* @description:
* checks that a handle points to a valid @FT_Object that
* is an instance of a given class (or of any of its sub-classes)
*
* @input:
* obj :: handle/pointer
* clazz :: class handle to check
*
* @return:
* 1 iff the handle points to a valid 'clazz' instance. 0
* otherwise.
*/
FT_BASE( FT_Int )
ft_object_is_a( FT_Pointer obj,
FT_Class clazz );
/**************************************************************
*
* @function: ft_object_create
*
* @description:
* create a new object (class instance)
*
* @output:
* aobject :: new object handle. NULL in case of error
*
* @input:
* clazz :: object's class pointer
* init_data :: optional pointer to initialization data
*
* @return:
* error code. 0 means success
*/
FT_BASE( FT_Error )
ft_object_create( FT_Object *aobject,
FT_Class clazz,
FT_Pointer init_data );
/**************************************************************
*
* @function: ft_object_create_from_type
*
* @description:
* create a new object (class instance) from a @FT_Type
*
* @output:
* aobject :: new object handle. NULL in case of error
*
* @input:
* type :: object's type descriptor
* init_data :: optional pointer to initialization data
*
* @return:
* error code. 0 means success
*
* @note:
* this function is slower than @ft_object_create
*
* this is equivalent to calling @ft_class_from_type followed by
* @ft_object_create
*/
FT_BASE( FT_Error )
ft_object_create_from_type( FT_Object *aobject,
FT_Type type,
FT_Pointer init_data,
FT_Library library );
/**************************************************************
*
* @macro FT_OBJ_CREATE (object,class,init)
*
* @description:
* a convenient macro used to create new objects. see
* @ft_object_create for details
*/
#define FT_OBJ_CREATE( _obj, _clazz, _init ) \
ft_object_create( FT_OBJECT_P(&(_obj)), _clazz, _init )
/**************************************************************
*
* @macro FT_CREATE (object,class,init)
*
* @description:
* a convenient macro used to create new objects. It also
* sets an _implicit_ local variable named "error" to the error
* code returned by the object constructor.
*/
#define FT_CREATE( _obj, _clazz, _init ) \
FT_SET_ERROR( FT_OBJ_CREATE( _obj, _clazz, _init ) )
/**************************************************************
*
* @macro FT_OBJ_CREATE_FROM_TYPE (object,type,init)
*
* @description:
* a convenient macro used to create new objects. see
* @ft_object_create_from_type for details
*/
#define FT_OBJ_CREATE_FROM_TYPE( _obj, _type, _init, _lib ) \
ft_object_create_from_type( FT_OBJECT_P(&(_obj)), _type, _init, _lib )
/**************************************************************
*
* @macro FT_CREATE_FROM_TYPE (object,type,init)
*
* @description:
* a convenient macro used to create new objects. It also
* sets an _implicit_ local variable named "error" to the error
* code returned by the object constructor.
*/
#define FT_CREATE_FROM_TYPE( _obj, _type, _init, _lib ) \
FT_SET_ERROR( FT_OBJ_CREATE_FROM_TYPE( _obj, _type, _init, _lib ) )
/* */
/**************************************************************
*
* @function: ft_class_from_type
*
* @description:
* retrieves the class object corresponding to a given type
* descriptor. The class is created when needed
*
* @output:
* aclass :: handle to corresponding class object. NULL in
* case of error
*
* @input:
* type :: type descriptor handle
* library :: library handle
*
* @return:
* error code. 0 means success
*/
FT_BASE( FT_Error )
ft_class_from_type( FT_Class *aclass,
FT_Type type,
FT_Library library );
/* */
#include FT_INTERNAL_HASH_H
typedef struct FT_ClassHNodeRec_* FT_ClassHNode;
typedef struct FT_ClassHNodeRec_
{
FT_HashNodeRec hnode;
FT_Type type;
FT_Class clazz;
} FT_ClassHNodeRec;
typedef struct FT_MetaClassRec_
{
FT_ClassRec clazz; /* the meta-class is a class itself */
FT_HashRec type_to_class; /* the type => class hash table */
} FT_MetaClassRec, *FT_MetaClass;
/* initialize meta class */
FT_BASE( FT_Error )
ft_metaclass_init( FT_MetaClass meta,
FT_Library library );
/* finalize meta class - destroy all registered class objects */
FT_BASE( void )
ft_metaclass_done( FT_MetaClass meta );
/* */
FT_END_HEADER
#endif /* __FT_OBJECT_H__ */