00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef __FTCMRU_H__
00044 #define __FTCMRU_H__
00045
00046
00047 #include <ft2build.h>
00048 #include FT_FREETYPE_H
00049
00050 #ifdef FREETYPE_H
00051 #error "freetype.h of FreeType 1 has been loaded!"
00052 #error "Please fix the directory search order for header files"
00053 #error "so that freetype.h of FreeType 2 is found first."
00054 #endif
00055
00056 #define xxFT_DEBUG_ERROR
00057 #define FTC_INLINE
00058
00059 FT_BEGIN_HEADER
00060
00061 typedef struct FTC_MruNodeRec_* FTC_MruNode;
00062
00063 typedef struct FTC_MruNodeRec_
00064 {
00065 FTC_MruNode next;
00066 FTC_MruNode prev;
00067
00068 } FTC_MruNodeRec;
00069
00070
00071 FT_LOCAL( void )
00072 FTC_MruNode_Prepend( FTC_MruNode *plist,
00073 FTC_MruNode node );
00074
00075 FT_LOCAL( void )
00076 FTC_MruNode_Up( FTC_MruNode *plist,
00077 FTC_MruNode node );
00078
00079 FT_LOCAL( void )
00080 FTC_MruNode_Remove( FTC_MruNode *plist,
00081 FTC_MruNode node );
00082
00083
00084 typedef struct FTC_MruListRec_* FTC_MruList;
00085
00086 typedef struct FTC_MruListClassRec_ const * FTC_MruListClass;
00087
00088
00089 typedef FT_Bool
00090 (*FTC_MruNode_CompareFunc)( FTC_MruNode node,
00091 FT_Pointer key );
00092
00093 typedef FT_Error
00094 (*FTC_MruNode_InitFunc)( FTC_MruNode node,
00095 FT_Pointer key,
00096 FT_Pointer data );
00097
00098 typedef FT_Error
00099 (*FTC_MruNode_ResetFunc)( FTC_MruNode node,
00100 FT_Pointer key,
00101 FT_Pointer data );
00102
00103 typedef void
00104 (*FTC_MruNode_DoneFunc)( FTC_MruNode node,
00105 FT_Pointer data );
00106
00107
00108 typedef struct FTC_MruListClassRec_
00109 {
00110 FT_Offset node_size;
00111 FTC_MruNode_CompareFunc node_compare;
00112 FTC_MruNode_InitFunc node_init;
00113 FTC_MruNode_ResetFunc node_reset;
00114 FTC_MruNode_DoneFunc node_done;
00115
00116 } FTC_MruListClassRec;
00117
00118 typedef struct FTC_MruListRec_
00119 {
00120 FT_UInt num_nodes;
00121 FT_UInt max_nodes;
00122 FTC_MruNode nodes;
00123 FT_Pointer data;
00124 FTC_MruListClassRec clazz;
00125 FT_Memory memory;
00126
00127 } FTC_MruListRec;
00128
00129
00130 FT_LOCAL( void )
00131 FTC_MruList_Init( FTC_MruList list,
00132 FTC_MruListClass clazz,
00133 FT_UInt max_nodes,
00134 FT_Pointer data,
00135 FT_Memory memory );
00136
00137 FT_LOCAL( void )
00138 FTC_MruList_Reset( FTC_MruList list );
00139
00140
00141 FT_LOCAL( void )
00142 FTC_MruList_Done( FTC_MruList list );
00143
00144
00145 FT_LOCAL( FT_Error )
00146 FTC_MruList_New( FTC_MruList list,
00147 FT_Pointer key,
00148 FTC_MruNode *anode );
00149
00150 FT_LOCAL( void )
00151 FTC_MruList_Remove( FTC_MruList list,
00152 FTC_MruNode node );
00153
00154 FT_LOCAL( void )
00155 FTC_MruList_RemoveSelection( FTC_MruList list,
00156 FTC_MruNode_CompareFunc selection,
00157 FT_Pointer key );
00158
00159
00160 #ifdef FTC_INLINE
00161
00162 #define FTC_MRULIST_LOOKUP_CMP( list, key, compare, node, error ) \
00163 FT_BEGIN_STMNT \
00164 FTC_MruNode* _pfirst = &(list)->nodes; \
00165 FTC_MruNode_CompareFunc _compare = (FTC_MruNode_CompareFunc)(compare); \
00166 FTC_MruNode _first, _node; \
00167 \
00168 \
00169 error = 0; \
00170 _first = *(_pfirst); \
00171 _node = NULL; \
00172 \
00173 if ( _first ) \
00174 { \
00175 _node = _first; \
00176 do \
00177 { \
00178 if ( _compare( _node, (key) ) ) \
00179 { \
00180 if ( _node != _first ) \
00181 FTC_MruNode_Up( _pfirst, _node ); \
00182 \
00183 node = _node; \
00184 goto _MruOk; \
00185 } \
00186 _node = _node->next; \
00187 \
00188 } while ( _node != _first) ; \
00189 } \
00190 \
00191 error = FTC_MruList_New( (list), (key), (FTC_MruNode*)(void*)&(node) ); \
00192 _MruOk: \
00193 ; \
00194 FT_END_STMNT
00195
00196 #define FTC_MRULIST_LOOKUP( list, key, node, error ) \
00197 FTC_MRULIST_LOOKUP_CMP( list, key, (list)->clazz.node_compare, node, error )
00198
00199 #else
00200
00201 FT_LOCAL( FTC_MruNode )
00202 FTC_MruList_Find( FTC_MruList list,
00203 FT_Pointer key );
00204
00205 FT_LOCAL( FT_Error )
00206 FTC_MruList_Lookup( FTC_MruList list,
00207 FT_Pointer key,
00208 FTC_MruNode *pnode );
00209
00210 #define FTC_MRULIST_LOOKUP( list, key, node, error ) \
00211 error = FTC_MruList_Lookup( (list), (key), (FTC_MruNode*)&(node) )
00212
00213 #endif
00214
00215
00216 #define FTC_MRULIST_LOOP( list, node ) \
00217 FT_BEGIN_STMNT \
00218 FTC_MruNode _first = (list)->nodes; \
00219 \
00220 \
00221 if ( _first ) \
00222 { \
00223 FTC_MruNode _node = _first; \
00224 \
00225 \
00226 do \
00227 { \
00228 *(FTC_MruNode*)&(node) = _node;
00229
00230
00231 #define FTC_MRULIST_LOOP_END() \
00232 _node = _node->next; \
00233 \
00234 } while ( _node != _first ); \
00235 } \
00236 FT_END_STMNT
00237
00238
00239
00240 FT_END_HEADER
00241
00242
00243 #endif
00244
00245
00246