vrshoot

diff libs/ft2static/freetype/internal/ftserv.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/ft2static/freetype/internal/ftserv.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,620 @@
     1.4 +/***************************************************************************/
     1.5 +/*                                                                         */
     1.6 +/*  ftserv.h                                                               */
     1.7 +/*                                                                         */
     1.8 +/*    The FreeType services (specification only).                          */
     1.9 +/*                                                                         */
    1.10 +/*  Copyright 2003, 2004, 2005, 2006, 2007 by                              */
    1.11 +/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
    1.12 +/*                                                                         */
    1.13 +/*  This file is part of the FreeType project, and may only be used,       */
    1.14 +/*  modified, and distributed under the terms of the FreeType project      */
    1.15 +/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
    1.16 +/*  this file you indicate that you have read the license and              */
    1.17 +/*  understand and accept it fully.                                        */
    1.18 +/*                                                                         */
    1.19 +/***************************************************************************/
    1.20 +
    1.21 +  /*************************************************************************/
    1.22 +  /*                                                                       */
    1.23 +  /*  Each module can export one or more `services'.  Each service is      */
    1.24 +  /*  identified by a constant string and modeled by a pointer; the latter */
    1.25 +  /*  generally corresponds to a structure containing function pointers.   */
    1.26 +  /*                                                                       */
    1.27 +  /*  Note that a service's data cannot be a mere function pointer because */
    1.28 +  /*  in C it is possible that function pointers might be implemented      */
    1.29 +  /*  differently than data pointers (e.g. 48 bits instead of 32).         */
    1.30 +  /*                                                                       */
    1.31 +  /*************************************************************************/
    1.32 +
    1.33 +
    1.34 +#ifndef __FTSERV_H__
    1.35 +#define __FTSERV_H__
    1.36 +
    1.37 +
    1.38 +FT_BEGIN_HEADER
    1.39 +
    1.40 +#if defined( _MSC_VER )      /* Visual C++ (and Intel C++) */
    1.41 +
    1.42 +  /* we disable the warning `conditional expression is constant' here */
    1.43 +  /* in order to compile cleanly with the maximum level of warnings   */
    1.44 +#pragma warning( disable : 4127 )
    1.45 +
    1.46 +#endif /* _MSC_VER */
    1.47 +
    1.48 +  /*
    1.49 +   * @macro:
    1.50 +   *   FT_FACE_FIND_SERVICE
    1.51 +   *
    1.52 +   * @description:
    1.53 +   *   This macro is used to look up a service from a face's driver module.
    1.54 +   *
    1.55 +   * @input:
    1.56 +   *   face ::
    1.57 +   *     The source face handle.
    1.58 +   *
    1.59 +   *   id ::
    1.60 +   *     A string describing the service as defined in the service's
    1.61 +   *     header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to
    1.62 +   *     `multi-masters').  It is automatically prefixed with
    1.63 +   *     `FT_SERVICE_ID_'.
    1.64 +   *
    1.65 +   * @output:
    1.66 +   *   ptr ::
    1.67 +   *     A variable that receives the service pointer.  Will be NULL
    1.68 +   *     if not found.
    1.69 +   */
    1.70 +#ifdef __cplusplus
    1.71 +
    1.72 +#define FT_FACE_FIND_SERVICE( face, ptr, id )                               \
    1.73 +  FT_BEGIN_STMNT                                                            \
    1.74 +    FT_Module    module = FT_MODULE( FT_FACE( face )->driver );             \
    1.75 +    FT_Pointer   _tmp_  = NULL;                                             \
    1.76 +    FT_Pointer*  _pptr_ = (FT_Pointer*)&(ptr);                              \
    1.77 +                                                                            \
    1.78 +                                                                            \
    1.79 +    if ( module->clazz->get_interface )                                     \
    1.80 +      _tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
    1.81 +    *_pptr_ = _tmp_;                                                        \
    1.82 +  FT_END_STMNT
    1.83 +
    1.84 +#else /* !C++ */
    1.85 +
    1.86 +#define FT_FACE_FIND_SERVICE( face, ptr, id )                               \
    1.87 +  FT_BEGIN_STMNT                                                            \
    1.88 +    FT_Module   module = FT_MODULE( FT_FACE( face )->driver );              \
    1.89 +    FT_Pointer  _tmp_  = NULL;                                              \
    1.90 +                                                                            \
    1.91 +    if ( module->clazz->get_interface )                                     \
    1.92 +      _tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
    1.93 +    ptr = _tmp_;                                                            \
    1.94 +  FT_END_STMNT
    1.95 +
    1.96 +#endif /* !C++ */
    1.97 +
    1.98 +  /*
    1.99 +   * @macro:
   1.100 +   *   FT_FACE_FIND_GLOBAL_SERVICE
   1.101 +   *
   1.102 +   * @description:
   1.103 +   *   This macro is used to look up a service from all modules.
   1.104 +   *
   1.105 +   * @input:
   1.106 +   *   face ::
   1.107 +   *     The source face handle.
   1.108 +   *
   1.109 +   *   id ::
   1.110 +   *     A string describing the service as defined in the service's
   1.111 +   *     header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to
   1.112 +   *     `multi-masters').  It is automatically prefixed with
   1.113 +   *     `FT_SERVICE_ID_'.
   1.114 +   *
   1.115 +   * @output:
   1.116 +   *   ptr ::
   1.117 +   *     A variable that receives the service pointer.  Will be NULL
   1.118 +   *     if not found.
   1.119 +   */
   1.120 +#ifdef __cplusplus
   1.121 +
   1.122 +#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id )               \
   1.123 +  FT_BEGIN_STMNT                                                   \
   1.124 +    FT_Module    module = FT_MODULE( FT_FACE( face )->driver );    \
   1.125 +    FT_Pointer   _tmp_;                                            \
   1.126 +    FT_Pointer*  _pptr_ = (FT_Pointer*)&(ptr);                     \
   1.127 +                                                                   \
   1.128 +                                                                   \
   1.129 +    _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \
   1.130 +    *_pptr_ = _tmp_;                                               \
   1.131 +  FT_END_STMNT
   1.132 +
   1.133 +#else /* !C++ */
   1.134 +
   1.135 +#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id )               \
   1.136 +  FT_BEGIN_STMNT                                                   \
   1.137 +    FT_Module   module = FT_MODULE( FT_FACE( face )->driver );     \
   1.138 +    FT_Pointer  _tmp_;                                             \
   1.139 +                                                                   \
   1.140 +                                                                   \
   1.141 +    _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \
   1.142 +    ptr   = _tmp_;                                                 \
   1.143 +  FT_END_STMNT
   1.144 +
   1.145 +#endif /* !C++ */
   1.146 +
   1.147 +
   1.148 +  /*************************************************************************/
   1.149 +  /*************************************************************************/
   1.150 +  /*****                                                               *****/
   1.151 +  /*****         S E R V I C E   D E S C R I P T O R S                 *****/
   1.152 +  /*****                                                               *****/
   1.153 +  /*************************************************************************/
   1.154 +  /*************************************************************************/
   1.155 +
   1.156 +  /*
   1.157 +   *  The following structure is used to _describe_ a given service
   1.158 +   *  to the library.  This is useful to build simple static service lists.
   1.159 +   */
   1.160 +  typedef struct  FT_ServiceDescRec_
   1.161 +  {
   1.162 +    const char*  serv_id;     /* service name         */
   1.163 +    const void*  serv_data;   /* service pointer/data */
   1.164 +
   1.165 +  } FT_ServiceDescRec;
   1.166 +
   1.167 +  typedef const FT_ServiceDescRec*  FT_ServiceDesc;
   1.168 +
   1.169 +  /*************************************************************************/
   1.170 +  /*                                                                       */
   1.171 +  /* <Macro>                                                               */
   1.172 +  /*    FT_DEFINE_SERVICEDESCREC1 .. FT_DEFINE_SERVICEDESCREC6             */
   1.173 +  /*                                                                       */
   1.174 +  /* <Description>                                                         */
   1.175 +  /*    Used to initialize an array of FT_ServiceDescRec structs.          */
   1.176 +  /*                                                                       */
   1.177 +  /*    When FT_CONFIG_OPTION_PIC is defined a Create funtion will need    */
   1.178 +  /*    to called with a pointer where the allocated array is returned.    */
   1.179 +  /*    And when it is no longer needed a Destroy function needs           */
   1.180 +  /*    to be called to release that allocation.                           */
   1.181 +  /*                                                                       */
   1.182 +  /*    These functions should be manyally called from the pic_init and    */
   1.183 +  /*    pic_free functions of your module (see FT_DEFINE_MODULE)           */
   1.184 +  /*                                                                       */
   1.185 +  /*    When FT_CONFIG_OPTION_PIC is not defined the array will be         */
   1.186 +  /*    allocated in the global scope (or the scope where the macro        */
   1.187 +  /*    is used).                                                          */
   1.188 +  /*                                                                       */
   1.189 +#ifndef FT_CONFIG_OPTION_PIC
   1.190 +
   1.191 +#define FT_DEFINE_SERVICEDESCREC1(class_, serv_id_1, serv_data_1)            \
   1.192 +  static const FT_ServiceDescRec class_[] =                                  \
   1.193 +  {                                                                          \
   1.194 +  {serv_id_1, serv_data_1},                                                  \
   1.195 +  {NULL, NULL}                                                               \
   1.196 +  };
   1.197 +#define FT_DEFINE_SERVICEDESCREC2(class_, serv_id_1, serv_data_1,            \
   1.198 +        serv_id_2, serv_data_2)                                              \
   1.199 +  static const FT_ServiceDescRec class_[] =                                  \
   1.200 +  {                                                                          \
   1.201 +  {serv_id_1, serv_data_1},                                                  \
   1.202 +  {serv_id_2, serv_data_2},                                                  \
   1.203 +  {NULL, NULL}                                                               \
   1.204 +  };
   1.205 +#define FT_DEFINE_SERVICEDESCREC3(class_, serv_id_1, serv_data_1,            \
   1.206 +        serv_id_2, serv_data_2, serv_id_3, serv_data_3)                      \
   1.207 +  static const FT_ServiceDescRec class_[] =                                  \
   1.208 +  {                                                                          \
   1.209 +  {serv_id_1, serv_data_1},                                                  \
   1.210 +  {serv_id_2, serv_data_2},                                                  \
   1.211 +  {serv_id_3, serv_data_3},                                                  \
   1.212 +  {NULL, NULL}                                                               \
   1.213 +  };
   1.214 +#define FT_DEFINE_SERVICEDESCREC4(class_, serv_id_1, serv_data_1,            \
   1.215 +        serv_id_2, serv_data_2, serv_id_3, serv_data_3,                      \
   1.216 +        serv_id_4, serv_data_4)                                              \
   1.217 +  static const FT_ServiceDescRec class_[] =                                  \
   1.218 +  {                                                                          \
   1.219 +  {serv_id_1, serv_data_1},                                                  \
   1.220 +  {serv_id_2, serv_data_2},                                                  \
   1.221 +  {serv_id_3, serv_data_3},                                                  \
   1.222 +  {serv_id_4, serv_data_4},                                                  \
   1.223 +  {NULL, NULL}                                                               \
   1.224 +  };
   1.225 +#define FT_DEFINE_SERVICEDESCREC5(class_, serv_id_1, serv_data_1,            \
   1.226 +        serv_id_2, serv_data_2, serv_id_3, serv_data_3,                      \
   1.227 +        serv_id_4, serv_data_4, serv_id_5, serv_data_5)                      \
   1.228 +  static const FT_ServiceDescRec class_[] =                                  \
   1.229 +  {                                                                          \
   1.230 +  {serv_id_1, serv_data_1},                                                  \
   1.231 +  {serv_id_2, serv_data_2},                                                  \
   1.232 +  {serv_id_3, serv_data_3},                                                  \
   1.233 +  {serv_id_4, serv_data_4},                                                  \
   1.234 +  {serv_id_5, serv_data_5},                                                  \
   1.235 +  {NULL, NULL}                                                               \
   1.236 +  };
   1.237 +#define FT_DEFINE_SERVICEDESCREC6(class_, serv_id_1, serv_data_1,            \
   1.238 +        serv_id_2, serv_data_2, serv_id_3, serv_data_3,                      \
   1.239 +        serv_id_4, serv_data_4, serv_id_5, serv_data_5,                      \
   1.240 +        serv_id_6, serv_data_6)                                              \
   1.241 +  static const FT_ServiceDescRec class_[] =                                  \
   1.242 +  {                                                                          \
   1.243 +  {serv_id_1, serv_data_1},                                                  \
   1.244 +  {serv_id_2, serv_data_2},                                                  \
   1.245 +  {serv_id_3, serv_data_3},                                                  \
   1.246 +  {serv_id_4, serv_data_4},                                                  \
   1.247 +  {serv_id_5, serv_data_5},                                                  \
   1.248 +  {serv_id_6, serv_data_6},                                                  \
   1.249 +  {NULL, NULL}                                                               \
   1.250 +  };
   1.251 +
   1.252 +#else /* FT_CONFIG_OPTION_PIC */ 
   1.253 +
   1.254 +#define FT_DEFINE_SERVICEDESCREC1(class_, serv_id_1, serv_data_1)            \
   1.255 +  void                                                                       \
   1.256 +  FT_Destroy_Class_##class_( FT_Library library,                             \
   1.257 +                             FT_ServiceDescRec* clazz )                      \
   1.258 +  {                                                                          \
   1.259 +    FT_Memory memory = library->memory;                                      \
   1.260 +    if ( clazz )                                                             \
   1.261 +      FT_FREE( clazz );                                                      \
   1.262 +  }                                                                          \
   1.263 +                                                                             \
   1.264 +  FT_Error                                                                   \
   1.265 +  FT_Create_Class_##class_( FT_Library library,                              \
   1.266 +                            FT_ServiceDescRec** output_class)                \
   1.267 +  {                                                                          \
   1.268 +    FT_ServiceDescRec*  clazz;                                               \
   1.269 +    FT_Error          error;                                                 \
   1.270 +    FT_Memory memory = library->memory;                                      \
   1.271 +                                                                             \
   1.272 +    if ( FT_ALLOC( clazz, sizeof(*clazz)*2 ) )                               \
   1.273 +      return error;                                                          \
   1.274 +    clazz[0].serv_id = serv_id_1;                                            \
   1.275 +    clazz[0].serv_data = serv_data_1;                                        \
   1.276 +    clazz[1].serv_id = NULL;                                                 \
   1.277 +    clazz[1].serv_data = NULL;                                               \
   1.278 +    *output_class = clazz;                                                   \
   1.279 +    return FT_Err_Ok;                                                        \
   1.280 +  } 
   1.281 +
   1.282 +#define FT_DEFINE_SERVICEDESCREC2(class_, serv_id_1, serv_data_1,            \
   1.283 +        serv_id_2, serv_data_2)                                              \
   1.284 +  void                                                                       \
   1.285 +  FT_Destroy_Class_##class_( FT_Library library,                             \
   1.286 +                             FT_ServiceDescRec* clazz )                      \
   1.287 +  {                                                                          \
   1.288 +    FT_Memory memory = library->memory;                                      \
   1.289 +    if ( clazz )                                                             \
   1.290 +      FT_FREE( clazz );                                                      \
   1.291 +  }                                                                          \
   1.292 +                                                                             \
   1.293 +  FT_Error                                                                   \
   1.294 +  FT_Create_Class_##class_( FT_Library library,                              \
   1.295 +                            FT_ServiceDescRec** output_class)                \
   1.296 +  {                                                                          \
   1.297 +    FT_ServiceDescRec*  clazz;                                               \
   1.298 +    FT_Error          error;                                                 \
   1.299 +    FT_Memory memory = library->memory;                                      \
   1.300 +                                                                             \
   1.301 +    if ( FT_ALLOC( clazz, sizeof(*clazz)*3 ) )                               \
   1.302 +      return error;                                                          \
   1.303 +    clazz[0].serv_id = serv_id_1;                                            \
   1.304 +    clazz[0].serv_data = serv_data_1;                                        \
   1.305 +    clazz[1].serv_id = serv_id_2;                                            \
   1.306 +    clazz[1].serv_data = serv_data_2;                                        \
   1.307 +    clazz[2].serv_id = NULL;                                                 \
   1.308 +    clazz[2].serv_data = NULL;                                               \
   1.309 +    *output_class = clazz;                                                   \
   1.310 +    return FT_Err_Ok;                                                        \
   1.311 +  } 
   1.312 +
   1.313 +#define FT_DEFINE_SERVICEDESCREC3(class_, serv_id_1, serv_data_1,            \
   1.314 +        serv_id_2, serv_data_2, serv_id_3, serv_data_3)                      \
   1.315 +  void                                                                       \
   1.316 +  FT_Destroy_Class_##class_( FT_Library library,                             \
   1.317 +                             FT_ServiceDescRec* clazz )                      \
   1.318 +  {                                                                          \
   1.319 +    FT_Memory memory = library->memory;                                      \
   1.320 +    if ( clazz )                                                             \
   1.321 +      FT_FREE( clazz );                                                      \
   1.322 +  }                                                                          \
   1.323 +                                                                             \
   1.324 +  FT_Error                                                                   \
   1.325 +  FT_Create_Class_##class_( FT_Library library,                              \
   1.326 +                            FT_ServiceDescRec** output_class)                \
   1.327 +  {                                                                          \
   1.328 +    FT_ServiceDescRec*  clazz;                                               \
   1.329 +    FT_Error          error;                                                 \
   1.330 +    FT_Memory memory = library->memory;                                      \
   1.331 +                                                                             \
   1.332 +    if ( FT_ALLOC( clazz, sizeof(*clazz)*4 ) )                               \
   1.333 +      return error;                                                          \
   1.334 +    clazz[0].serv_id = serv_id_1;                                            \
   1.335 +    clazz[0].serv_data = serv_data_1;                                        \
   1.336 +    clazz[1].serv_id = serv_id_2;                                            \
   1.337 +    clazz[1].serv_data = serv_data_2;                                        \
   1.338 +    clazz[2].serv_id = serv_id_3;                                            \
   1.339 +    clazz[2].serv_data = serv_data_3;                                        \
   1.340 +    clazz[3].serv_id = NULL;                                                 \
   1.341 +    clazz[3].serv_data = NULL;                                               \
   1.342 +    *output_class = clazz;                                                   \
   1.343 +    return FT_Err_Ok;                                                        \
   1.344 +  } 
   1.345 +
   1.346 +#define FT_DEFINE_SERVICEDESCREC4(class_, serv_id_1, serv_data_1,            \
   1.347 +        serv_id_2, serv_data_2, serv_id_3, serv_data_3,                      \
   1.348 +        serv_id_4, serv_data_4)                                              \
   1.349 +  void                                                                       \
   1.350 +  FT_Destroy_Class_##class_( FT_Library library,                             \
   1.351 +                             FT_ServiceDescRec* clazz )                      \
   1.352 +  {                                                                          \
   1.353 +    FT_Memory memory = library->memory;                                      \
   1.354 +    if ( clazz )                                                             \
   1.355 +      FT_FREE( clazz );                                                      \
   1.356 +  }                                                                          \
   1.357 +                                                                             \
   1.358 +  FT_Error                                                                   \
   1.359 +  FT_Create_Class_##class_( FT_Library library,                              \
   1.360 +                            FT_ServiceDescRec** output_class)                \
   1.361 +  {                                                                          \
   1.362 +    FT_ServiceDescRec*  clazz;                                               \
   1.363 +    FT_Error          error;                                                 \
   1.364 +    FT_Memory memory = library->memory;                                      \
   1.365 +                                                                             \
   1.366 +    if ( FT_ALLOC( clazz, sizeof(*clazz)*5 ) )                               \
   1.367 +      return error;                                                          \
   1.368 +    clazz[0].serv_id = serv_id_1;                                            \
   1.369 +    clazz[0].serv_data = serv_data_1;                                        \
   1.370 +    clazz[1].serv_id = serv_id_2;                                            \
   1.371 +    clazz[1].serv_data = serv_data_2;                                        \
   1.372 +    clazz[2].serv_id = serv_id_3;                                            \
   1.373 +    clazz[2].serv_data = serv_data_3;                                        \
   1.374 +    clazz[3].serv_id = serv_id_4;                                            \
   1.375 +    clazz[3].serv_data = serv_data_4;                                        \
   1.376 +    clazz[4].serv_id = NULL;                                                 \
   1.377 +    clazz[4].serv_data = NULL;                                               \
   1.378 +    *output_class = clazz;                                                   \
   1.379 +    return FT_Err_Ok;                                                        \
   1.380 +  } 
   1.381 +
   1.382 +#define FT_DEFINE_SERVICEDESCREC5(class_, serv_id_1, serv_data_1,            \
   1.383 +        serv_id_2, serv_data_2, serv_id_3, serv_data_3, serv_id_4,           \
   1.384 +        serv_data_4, serv_id_5, serv_data_5)                                 \
   1.385 +  void                                                                       \
   1.386 +  FT_Destroy_Class_##class_( FT_Library library,                             \
   1.387 +                             FT_ServiceDescRec* clazz )                      \
   1.388 +  {                                                                          \
   1.389 +    FT_Memory memory = library->memory;                                      \
   1.390 +    if ( clazz )                                                             \
   1.391 +      FT_FREE( clazz );                                                      \
   1.392 +  }                                                                          \
   1.393 +                                                                             \
   1.394 +  FT_Error                                                                   \
   1.395 +  FT_Create_Class_##class_( FT_Library library,                              \
   1.396 +                            FT_ServiceDescRec** output_class)                \
   1.397 +  {                                                                          \
   1.398 +    FT_ServiceDescRec*  clazz;                                               \
   1.399 +    FT_Error          error;                                                 \
   1.400 +    FT_Memory memory = library->memory;                                      \
   1.401 +                                                                             \
   1.402 +    if ( FT_ALLOC( clazz, sizeof(*clazz)*6 ) )                               \
   1.403 +      return error;                                                          \
   1.404 +    clazz[0].serv_id = serv_id_1;                                            \
   1.405 +    clazz[0].serv_data = serv_data_1;                                        \
   1.406 +    clazz[1].serv_id = serv_id_2;                                            \
   1.407 +    clazz[1].serv_data = serv_data_2;                                        \
   1.408 +    clazz[2].serv_id = serv_id_3;                                            \
   1.409 +    clazz[2].serv_data = serv_data_3;                                        \
   1.410 +    clazz[3].serv_id = serv_id_4;                                            \
   1.411 +    clazz[3].serv_data = serv_data_4;                                        \
   1.412 +    clazz[4].serv_id = serv_id_5;                                            \
   1.413 +    clazz[4].serv_data = serv_data_5;                                        \
   1.414 +    clazz[5].serv_id = NULL;                                                 \
   1.415 +    clazz[5].serv_data = NULL;                                               \
   1.416 +    *output_class = clazz;                                                   \
   1.417 +    return FT_Err_Ok;                                                        \
   1.418 +  } 
   1.419 +
   1.420 +#define FT_DEFINE_SERVICEDESCREC6(class_, serv_id_1, serv_data_1,            \
   1.421 +        serv_id_2, serv_data_2, serv_id_3, serv_data_3,                      \
   1.422 +        serv_id_4, serv_data_4, serv_id_5, serv_data_5,                      \
   1.423 +        serv_id_6, serv_data_6)                                              \
   1.424 +  void                                                                       \
   1.425 +  FT_Destroy_Class_##class_( FT_Library library,                             \
   1.426 +                             FT_ServiceDescRec* clazz )                      \
   1.427 +  {                                                                          \
   1.428 +    FT_Memory memory = library->memory;                                      \
   1.429 +    if ( clazz )                                                             \
   1.430 +      FT_FREE( clazz );                                                      \
   1.431 +  }                                                                          \
   1.432 +                                                                             \
   1.433 +  FT_Error                                                                   \
   1.434 +  FT_Create_Class_##class_( FT_Library library,                              \
   1.435 +                            FT_ServiceDescRec** output_class)                \
   1.436 +  {                                                                          \
   1.437 +    FT_ServiceDescRec*  clazz;                                               \
   1.438 +    FT_Error          error;                                                 \
   1.439 +    FT_Memory memory = library->memory;                                      \
   1.440 +                                                                             \
   1.441 +    if ( FT_ALLOC( clazz, sizeof(*clazz)*7 ) )                               \
   1.442 +      return error;                                                          \
   1.443 +    clazz[0].serv_id = serv_id_1;                                            \
   1.444 +    clazz[0].serv_data = serv_data_1;                                        \
   1.445 +    clazz[1].serv_id = serv_id_2;                                            \
   1.446 +    clazz[1].serv_data = serv_data_2;                                        \
   1.447 +    clazz[2].serv_id = serv_id_3;                                            \
   1.448 +    clazz[2].serv_data = serv_data_3;                                        \
   1.449 +    clazz[3].serv_id = serv_id_4;                                            \
   1.450 +    clazz[3].serv_data = serv_data_4;                                        \
   1.451 +    clazz[4].serv_id = serv_id_5;                                            \
   1.452 +    clazz[4].serv_data = serv_data_5;                                        \
   1.453 +    clazz[5].serv_id = serv_id_6;                                            \
   1.454 +    clazz[5].serv_data = serv_data_6;                                        \
   1.455 +    clazz[6].serv_id = NULL;                                                 \
   1.456 +    clazz[6].serv_data = NULL;                                               \
   1.457 +    *output_class = clazz;                                                   \
   1.458 +    return FT_Err_Ok;                                                        \
   1.459 +  } 
   1.460 +#endif /* FT_CONFIG_OPTION_PIC */ 
   1.461 +
   1.462 +  /*
   1.463 +   *  Parse a list of FT_ServiceDescRec descriptors and look for
   1.464 +   *  a specific service by ID.  Note that the last element in the
   1.465 +   *  array must be { NULL, NULL }, and that the function should
   1.466 +   *  return NULL if the service isn't available.
   1.467 +   *
   1.468 +   *  This function can be used by modules to implement their
   1.469 +   *  `get_service' method.
   1.470 +   */
   1.471 +  FT_BASE( FT_Pointer )
   1.472 +  ft_service_list_lookup( FT_ServiceDesc  service_descriptors,
   1.473 +                          const char*     service_id );
   1.474 +
   1.475 +
   1.476 +  /*************************************************************************/
   1.477 +  /*************************************************************************/
   1.478 +  /*****                                                               *****/
   1.479 +  /*****             S E R V I C E S   C A C H E                       *****/
   1.480 +  /*****                                                               *****/
   1.481 +  /*************************************************************************/
   1.482 +  /*************************************************************************/
   1.483 +
   1.484 +  /*
   1.485 +   *  This structure is used to store a cache for several frequently used
   1.486 +   *  services.  It is the type of `face->internal->services'.  You
   1.487 +   *  should only use FT_FACE_LOOKUP_SERVICE to access it.
   1.488 +   *
   1.489 +   *  All fields should have the type FT_Pointer to relax compilation
   1.490 +   *  dependencies.  We assume the developer isn't completely stupid.
   1.491 +   *
   1.492 +   *  Each field must be named `service_XXXX' where `XXX' corresponds to
   1.493 +   *  the correct FT_SERVICE_ID_XXXX macro.  See the definition of
   1.494 +   *  FT_FACE_LOOKUP_SERVICE below how this is implemented.
   1.495 +   *
   1.496 +   */
   1.497 +  typedef struct  FT_ServiceCacheRec_
   1.498 +  {
   1.499 +    FT_Pointer  service_POSTSCRIPT_FONT_NAME;
   1.500 +    FT_Pointer  service_MULTI_MASTERS;
   1.501 +    FT_Pointer  service_GLYPH_DICT;
   1.502 +    FT_Pointer  service_PFR_METRICS;
   1.503 +    FT_Pointer  service_WINFNT;
   1.504 +
   1.505 +  } FT_ServiceCacheRec, *FT_ServiceCache;
   1.506 +
   1.507 +
   1.508 +  /*
   1.509 +   *  A magic number used within the services cache.
   1.510 +   */
   1.511 +#define FT_SERVICE_UNAVAILABLE  ((FT_Pointer)-2)  /* magic number */
   1.512 +
   1.513 +
   1.514 +  /*
   1.515 +   * @macro:
   1.516 +   *   FT_FACE_LOOKUP_SERVICE
   1.517 +   *
   1.518 +   * @description:
   1.519 +   *   This macro is used to lookup a service from a face's driver module
   1.520 +   *   using its cache.
   1.521 +   *
   1.522 +   * @input:
   1.523 +   *   face::
   1.524 +   *     The source face handle containing the cache.
   1.525 +   *
   1.526 +   *   field ::
   1.527 +   *     The field name in the cache.
   1.528 +   *
   1.529 +   *   id ::
   1.530 +   *     The service ID.
   1.531 +   *
   1.532 +   * @output:
   1.533 +   *   ptr ::
   1.534 +   *     A variable receiving the service data.  NULL if not available.
   1.535 +   */
   1.536 +#ifdef __cplusplus
   1.537 +
   1.538 +#define FT_FACE_LOOKUP_SERVICE( face, ptr, id )                \
   1.539 +  FT_BEGIN_STMNT                                               \
   1.540 +    FT_Pointer   svc;                                          \
   1.541 +    FT_Pointer*  Pptr = (FT_Pointer*)&(ptr);                   \
   1.542 +                                                               \
   1.543 +                                                               \
   1.544 +    svc = FT_FACE( face )->internal->services. service_ ## id; \
   1.545 +    if ( svc == FT_SERVICE_UNAVAILABLE )                       \
   1.546 +      svc = NULL;                                              \
   1.547 +    else if ( svc == NULL )                                    \
   1.548 +    {                                                          \
   1.549 +      FT_FACE_FIND_SERVICE( face, svc, id );                   \
   1.550 +                                                               \
   1.551 +      FT_FACE( face )->internal->services. service_ ## id =    \
   1.552 +        (FT_Pointer)( svc != NULL ? svc                        \
   1.553 +                                  : FT_SERVICE_UNAVAILABLE );  \
   1.554 +    }                                                          \
   1.555 +    *Pptr = svc;                                               \
   1.556 +  FT_END_STMNT
   1.557 +
   1.558 +#else /* !C++ */
   1.559 +
   1.560 +#define FT_FACE_LOOKUP_SERVICE( face, ptr, id )                \
   1.561 +  FT_BEGIN_STMNT                                               \
   1.562 +    FT_Pointer  svc;                                           \
   1.563 +                                                               \
   1.564 +                                                               \
   1.565 +    svc = FT_FACE( face )->internal->services. service_ ## id; \
   1.566 +    if ( svc == FT_SERVICE_UNAVAILABLE )                       \
   1.567 +      svc = NULL;                                              \
   1.568 +    else if ( svc == NULL )                                    \
   1.569 +    {                                                          \
   1.570 +      FT_FACE_FIND_SERVICE( face, svc, id );                   \
   1.571 +                                                               \
   1.572 +      FT_FACE( face )->internal->services. service_ ## id =    \
   1.573 +        (FT_Pointer)( svc != NULL ? svc                        \
   1.574 +                                  : FT_SERVICE_UNAVAILABLE );  \
   1.575 +    }                                                          \
   1.576 +    ptr = svc;                                                 \
   1.577 +  FT_END_STMNT
   1.578 +
   1.579 +#endif /* !C++ */
   1.580 +
   1.581 +  /*
   1.582 +   *  A macro used to define new service structure types.
   1.583 +   */
   1.584 +
   1.585 +#define FT_DEFINE_SERVICE( name )            \
   1.586 +  typedef struct FT_Service_ ## name ## Rec_ \
   1.587 +    FT_Service_ ## name ## Rec ;             \
   1.588 +  typedef struct FT_Service_ ## name ## Rec_ \
   1.589 +    const * FT_Service_ ## name ;            \
   1.590 +  struct FT_Service_ ## name ## Rec_
   1.591 +
   1.592 +  /* */
   1.593 +
   1.594 +  /*
   1.595 +   *  The header files containing the services.
   1.596 +   */
   1.597 +
   1.598 +#define FT_SERVICE_BDF_H                <freetype/internal/services/svbdf.h>
   1.599 +#define FT_SERVICE_CID_H                <freetype/internal/services/svcid.h>
   1.600 +#define FT_SERVICE_GLYPH_DICT_H         <freetype/internal/services/svgldict.h>
   1.601 +#define FT_SERVICE_GX_VALIDATE_H        <freetype/internal/services/svgxval.h>
   1.602 +#define FT_SERVICE_KERNING_H            <freetype/internal/services/svkern.h>
   1.603 +#define FT_SERVICE_MULTIPLE_MASTERS_H   <freetype/internal/services/svmm.h>
   1.604 +#define FT_SERVICE_OPENTYPE_VALIDATE_H  <freetype/internal/services/svotval.h>
   1.605 +#define FT_SERVICE_PFR_H                <freetype/internal/services/svpfr.h>
   1.606 +#define FT_SERVICE_POSTSCRIPT_CMAPS_H   <freetype/internal/services/svpscmap.h>
   1.607 +#define FT_SERVICE_POSTSCRIPT_INFO_H    <freetype/internal/services/svpsinfo.h>
   1.608 +#define FT_SERVICE_POSTSCRIPT_NAME_H    <freetype/internal/services/svpostnm.h>
   1.609 +#define FT_SERVICE_SFNT_H               <freetype/internal/services/svsfnt.h>
   1.610 +#define FT_SERVICE_TRUETYPE_ENGINE_H    <freetype/internal/services/svtteng.h>
   1.611 +#define FT_SERVICE_TT_CMAP_H            <freetype/internal/services/svttcmap.h>
   1.612 +#define FT_SERVICE_WINFNT_H             <freetype/internal/services/svwinfnt.h>
   1.613 +#define FT_SERVICE_XFREE86_NAME_H       <freetype/internal/services/svxf86nm.h>
   1.614 +#define FT_SERVICE_TRUETYPE_GLYF_H      <freetype/internal/services/svttglyf.h>
   1.615 +
   1.616 + /* */
   1.617 +
   1.618 +FT_END_HEADER
   1.619 +
   1.620 +#endif /* __FTSERV_H__ */
   1.621 +
   1.622 +
   1.623 +/* END */