source: OGRE/trunk/ogrenew/Dependencies/include/freetype/internal/ftserv.h @ 657

Revision 657, 13.7 KB checked in by mattausch, 18 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1/***************************************************************************/
2/*                                                                         */
3/*  ftserv.h                                                               */
4/*                                                                         */
5/*    The FreeType services (specification only).                          */
6/*                                                                         */
7/*  Copyright 2003, 2004, 2005 by                                          */
8/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
9/*                                                                         */
10/*  This file is part of the FreeType project, and may only be used,       */
11/*  modified, and distributed under the terms of the FreeType project      */
12/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
13/*  this file you indicate that you have read the license and              */
14/*  understand and accept it fully.                                        */
15/*                                                                         */
16/***************************************************************************/
17
18  /*************************************************************************/
19  /*                                                                       */
20  /*  Each module can export one or more `services'.  Each service is      */
21  /*  identified by a constant string and modeled by a pointer; the latter */
22  /*  generally corresponds to a structure containing function pointers.   */
23  /*                                                                       */
24  /*  Note that a service's data cannot be a mere function pointer because */
25  /*  in C it is possible that function pointers might be implemented      */
26  /*  differently than data pointers (e.g. 48 bits instead of 32).         */
27  /*                                                                       */
28  /*************************************************************************/
29
30
31#ifndef __FTSERV_H__
32#define __FTSERV_H__
33
34
35FT_BEGIN_HEADER
36
37#if defined( _MSC_VER )      /* Visual C++ (and Intel C++) */
38
39  /* we disable the warning `conditional expression is constant' here */
40  /* in order to compile cleanly with the maximum level of warnings   */
41#pragma warning( disable : 4127 )
42
43#endif /* _MSC_VER */
44
45  /*
46   * @macro:
47   *   FT_FACE_FIND_SERVICE
48   *
49   * @description:
50   *   This macro is used to look up a service from a face's driver module.
51   *
52   * @input:
53   *   face ::
54   *     The source face handle.
55   *
56   *   id ::
57   *     A string describing the service as defined in the service's
58   *     header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to
59   *     `multi-masters').  It is automatically prefixed with
60   *     `FT_SERVICE_ID_'.
61   *
62   * @output:
63   *   ptr ::
64   *     A variable that receives the service pointer.  Will be NULL
65   *     if not found.
66   */
67#ifdef __cplusplus
68
69#define FT_FACE_FIND_SERVICE( face, ptr, id )                               \
70  FT_BEGIN_STMNT                                                            \
71    FT_Module    module = FT_MODULE( FT_FACE( face )->driver );             \
72    FT_Pointer   _tmp_  = NULL;                                             \
73    FT_Pointer*  _pptr_ = (FT_Pointer*)&(ptr);                              \
74                                                                            \
75                                                                            \
76    if ( module->clazz->get_interface )                                     \
77      _tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
78    *_pptr_ = _tmp_;                                                        \
79  FT_END_STMNT
80
81#else /* !C++ */
82
83#define FT_FACE_FIND_SERVICE( face, ptr, id )                               \
84  FT_BEGIN_STMNT                                                            \
85    FT_Module   module = FT_MODULE( FT_FACE( face )->driver );              \
86    FT_Pointer  _tmp_  = NULL;                                              \
87                                                                            \
88    if ( module->clazz->get_interface )                                     \
89      _tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
90    ptr = _tmp_;                                                            \
91  FT_END_STMNT
92
93#endif /* !C++ */
94
95  /*
96   * @macro:
97   *   FT_FACE_FIND_GLOBAL_SERVICE
98   *
99   * @description:
100   *   This macro is used to look up a service from all modules.
101   *
102   * @input:
103   *   face ::
104   *     The source face handle.
105   *
106   *   id ::
107   *     A string describing the service as defined in the service's
108   *     header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to
109   *     `multi-masters').  It is automatically prefixed with
110   *     `FT_SERVICE_ID_'.
111   *
112   * @output:
113   *   ptr ::
114   *     A variable that receives the service pointer.  Will be NULL
115   *     if not found.
116   */
117#ifdef __cplusplus
118
119#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id )               \
120  FT_BEGIN_STMNT                                                   \
121    FT_Module    module = FT_MODULE( FT_FACE( face )->driver );    \
122    FT_Pointer   _tmp_;                                            \
123    FT_Pointer*  _pptr_ = (FT_Pointer*)&(ptr);                     \
124                                                                   \
125                                                                   \
126    _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \
127    *_pptr_ = _tmp_;                                               \
128  FT_END_STMNT
129
130#else /* !C++ */
131
132#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id )               \
133  FT_BEGIN_STMNT                                                   \
134    FT_Module   module = FT_MODULE( FT_FACE( face )->driver );     \
135    FT_Pointer  _tmp_;                                             \
136                                                                   \
137                                                                   \
138    _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \
139    ptr   = _tmp_;                                                 \
140  FT_END_STMNT
141
142#endif /* !C++ */
143
144
145  /*************************************************************************/
146  /*************************************************************************/
147  /*****                                                               *****/
148  /*****         S E R V I C E   D E S C R I P T O R S                 *****/
149  /*****                                                               *****/
150  /*************************************************************************/
151  /*************************************************************************/
152
153  /*
154   *  The following structure is used to _describe_ a given service
155   *  to the library.  This is useful to build simple static service lists.
156   */
157  typedef struct  FT_ServiceDescRec_
158  {
159    const char*  serv_id;     /* service name         */
160    const void*  serv_data;   /* service pointer/data */
161
162  } FT_ServiceDescRec;
163
164  typedef const FT_ServiceDescRec*  FT_ServiceDesc;
165
166
167  /*
168   *  Parse a list of FT_ServiceDescRec descriptors and look for
169   *  a specific service by ID.  Note that the last element in the
170   *  array must be { NULL, NULL }, and that the function should
171   *  return NULL if the service isn't available.
172   *
173   *  This function can be used by modules to implement their
174   *  `get_service' method.
175   */
176  FT_BASE( FT_Pointer )
177  ft_service_list_lookup( FT_ServiceDesc  service_descriptors,
178                          const char*     service_id );
179
180
181  /*************************************************************************/
182  /*************************************************************************/
183  /*****                                                               *****/
184  /*****             S E R V I C E S   C A C H E                       *****/
185  /*****                                                               *****/
186  /*************************************************************************/
187  /*************************************************************************/
188
189  /*
190   *  This structure is used to store a cache for several frequently used
191   *  services.  It is the type of `face->internal->services'.  You
192   *  should only use FT_FACE_LOOKUP_SERVICE to access it.
193   *
194   *  All fields should have the type FT_Pointer to relax compilation
195   *  dependencies.  We assume the developer isn't completely stupid.
196   *
197   *  Each field must be named `service_XXXX' where `XXX' corresponds to
198   *  the correct FT_SERVICE_ID_XXXX macro.  See the definition of
199   *  FT_FACE_LOOKUP_SERVICE below how this is implemented.
200   *
201   */
202  typedef struct  FT_ServiceCacheRec_
203  {
204    FT_Pointer  service_POSTSCRIPT_FONT_NAME;
205    FT_Pointer  service_MULTI_MASTERS;
206    FT_Pointer  service_GLYPH_DICT;
207    FT_Pointer  service_PFR_METRICS;
208    FT_Pointer  service_WINFNT;
209
210  } FT_ServiceCacheRec, *FT_ServiceCache;
211
212
213  /*
214   *  A magic number used within the services cache.
215   */
216#define FT_SERVICE_UNAVAILABLE  ((FT_Pointer)-2)  /* magic number */
217
218
219  /*
220   * @macro:
221   *   FT_FACE_LOOKUP_SERVICE
222   *
223   * @description:
224   *   This macro is used to lookup a service from a face's driver module
225   *   using its cache.
226   *
227   * @input:
228   *   face::
229   *     The source face handle containing the cache.
230   *
231   *   field ::
232   *     The field name in the cache.
233   *
234   *   id ::
235   *     The service ID.
236   *
237   * @output:
238   *   ptr ::
239   *     A variable receiving the service data.  NULL if not available.
240   */
241#ifdef __cplusplus
242
243#define FT_FACE_LOOKUP_SERVICE( face, ptr, id )                \
244  FT_BEGIN_STMNT                                               \
245    FT_Pointer   svc;                                          \
246    FT_Pointer*  Pptr = (FT_Pointer*)&(ptr);                   \
247                                                               \
248                                                               \
249    svc = FT_FACE( face )->internal->services. service_ ## id; \
250    if ( svc == FT_SERVICE_UNAVAILABLE )                       \
251      svc = NULL;                                              \
252    else if ( svc == NULL )                                    \
253    {                                                          \
254      FT_FACE_FIND_SERVICE( face, svc, id );                   \
255                                                               \
256      FT_FACE( face )->internal->services. service_ ## id =    \
257        (FT_Pointer)( svc != NULL ? svc                        \
258                                  : FT_SERVICE_UNAVAILABLE );  \
259    }                                                          \
260    *Pptr = svc;                                               \
261  FT_END_STMNT
262
263#else /* !C++ */
264
265#define FT_FACE_LOOKUP_SERVICE( face, ptr, id )                \
266  FT_BEGIN_STMNT                                               \
267    FT_Pointer  svc;                                           \
268                                                               \
269                                                               \
270    svc = FT_FACE( face )->internal->services. service_ ## id; \
271    if ( svc == FT_SERVICE_UNAVAILABLE )                       \
272      svc = NULL;                                              \
273    else if ( svc == NULL )                                    \
274    {                                                          \
275      FT_FACE_FIND_SERVICE( face, svc, id );                   \
276                                                               \
277      FT_FACE( face )->internal->services. service_ ## id =    \
278        (FT_Pointer)( svc != NULL ? svc                        \
279                                  : FT_SERVICE_UNAVAILABLE );  \
280    }                                                          \
281    ptr = svc;                                                 \
282  FT_END_STMNT
283
284#endif /* !C++ */
285
286  /*
287   *  A macro used to define new service structure types.
288   */
289
290#define FT_DEFINE_SERVICE( name )            \
291  typedef struct FT_Service_ ## name ## Rec_ \
292    FT_Service_ ## name ## Rec ;             \
293  typedef struct FT_Service_ ## name ## Rec_ \
294    const * FT_Service_ ## name ;            \
295  struct FT_Service_ ## name ## Rec_
296
297  /* */
298
299  /*
300   *  The header files containing the services.
301   */
302
303#define FT_SERVICE_BDF_H                <freetype/internal/services/svbdf.h>
304#define FT_SERVICE_GLYPH_DICT_H         <freetype/internal/services/svgldict.h>
305#define FT_SERVICE_MULTIPLE_MASTERS_H   <freetype/internal/services/svmm.h>
306#define FT_SERVICE_OPENTYPE_VALIDATE_H  <freetype/internal/services/svotval.h>
307#define FT_SERVICE_PFR_H                <freetype/internal/services/svpfr.h>
308#define FT_SERVICE_POSTSCRIPT_CMAPS_H   <freetype/internal/services/svpscmap.h>
309#define FT_SERVICE_POSTSCRIPT_INFO_H    <freetype/internal/services/svpsinfo.h>
310#define FT_SERVICE_POSTSCRIPT_NAME_H    <freetype/internal/services/svpostnm.h>
311#define FT_SERVICE_SFNT_H               <freetype/internal/services/svsfnt.h>
312#define FT_SERVICE_GX_VALIDATE_H        <freetype/internal/services/svgxval.h>
313#define FT_SERVICE_TT_CMAP_H            <freetype/internal/services/svttcmap.h>
314#define FT_SERVICE_WINFNT_H             <freetype/internal/services/svwinfnt.h>
315#define FT_SERVICE_XFREE86_NAME_H       <freetype/internal/services/svxf86nm.h>
316
317 /* */
318
319FT_END_HEADER
320
321#endif /* __FTSERV_H__ */
322
323
324/* END */
Note: See TracBrowser for help on using the repository browser.