shithub: freetype+ttf2subf

Download patch

ref: 46333a118f0cb18f86ddda323cec6220809c130e
parent: 013efd14103cbe453714749c1abe16258385d911
author: Werner Lemberg <[email protected]>
date: Wed Sep 17 15:20:02 EDT 2003

* include/freetype/internal/ftserv.h (FT_FACE_FIND_SERVICE,
FT_FACE_LOOKUP_SERVICE): Add parameter to pass pointer type.
Ugly, I know, but this is needed for compilation with C++ --
maybe someone knows a better solution?
Updated all callers.

* src/base/ftobjs.c (FT_Get_Name_Index, FT_Get_Glyph_Name): Remove
C++ compiler warnings.

* src/base/ftbdf.c (FT_Get_BDF_Charset_ID, FT_Get_BDF_Property):
Fix order of arguments passed to FT_FACE_FIND_SERVICE.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,20 @@
+2003-09-16  Werner Lemberg  <[email protected]>
+
+	* include/freetype/internal/ftserv.h (FT_FACE_FIND_SERVICE,
+	FT_FACE_LOOKUP_SERVICE): Add parameter to pass pointer type.
+	Ugly, I know, but this is needed for compilation with C++ --
+	maybe someone knows a better solution?
+	Updated all callers.
+
+	* src/base/ftobjs.c (FT_Get_Name_Index, FT_Get_Glyph_Name): Remove
+	C++ compiler warnings.
+
+	* src/base/ftbdf.c (FT_Get_BDF_Charset_ID, FT_Get_BDF_Property):
+	Fix order of arguments passed to FT_FACE_FIND_SERVICE.
+
 2003-09-15  Werner Lemberg  <[email protected]>
+
+	Avoid header files with identical names.
 
 	* include/freetype/internal/services/bdf.h: Renamed to...
 	* include/freetype/internal/services/svbdf.h: This.
--- a/include/freetype/internal/ftserv.h
+++ b/include/freetype/internal/ftserv.h
@@ -22,8 +22,8 @@
   /*  generally corresponds to a structure containing function pointers.   */
   /*                                                                       */
   /*  Note that a service's data cannot be a mere function pointer because */
-  /*  in C it is possible that function pointers might are implemented     */
-  /*  differently from data pointers (e.g. 48 bits instead of 32).         */
+  /*  in C it is possible that function pointers might be implemented      */
+  /*  differently than data pointers (e.g. 48 bits instead of 32).         */
   /*                                                                       */
   /*************************************************************************/
 
@@ -35,35 +35,39 @@
 FT_BEGIN_HEADER
 
 
- /*
-  * @macro:
-  *   FT_FACE_FIND_SERVICE
-  *
-  * @description:
-  *   This macro is used to lookup a service from a face's driver module.
-  *
-  * @input:
-  *   id ::
-  *     A string describing the service as defined in the service's
-  *     header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to
-  *     `multi-masters').
-  *
-  *   face ::
-  *     The source face handle.
-  *
-  * @output:
-  *   ptr ::
-  *     A variable that receives the service pointer.  Will be NULL
-  *     if not found.
-  */
-#define FT_FACE_FIND_SERVICE( ptr, face, id )               \
-  FT_BEGIN_STMNT                                            \
-    FT_Module  module = FT_MODULE( FT_FACE(face)->driver ); \
-                                                            \
-                                                            \
-    (ptr) = NULL;                                           \
-    if ( module->clazz->get_interface )                     \
-      (ptr) = module->clazz->get_interface( module, id );   \
+  /*
+   * @macro:
+   *   FT_FACE_FIND_SERVICE
+   *
+   * @description:
+   *   This macro is used to lookup a service from a face's driver module.
+   *
+   * @input:
+   *   id ::
+   *     A string describing the service as defined in the service's
+   *     header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to
+   *     `multi-masters').
+   *
+   *   face ::
+   *     The source face handle.
+   *
+   *   ptrtype ::
+   *     The pointer type of `ptr'.  This is needed to make FreeType
+   *     compile cleanly with C++.
+   *
+   * @output:
+   *   ptr ::
+   *     A variable that receives the service pointer.  Will be NULL
+   *     if not found.
+   */
+#define FT_FACE_FIND_SERVICE( ptrtype, ptr, face, id )             \
+  FT_BEGIN_STMNT                                                   \
+    FT_Module  module = FT_MODULE( FT_FACE(face)->driver );        \
+                                                                   \
+                                                                   \
+    (ptr) = NULL;                                                  \
+    if ( module->clazz->get_interface )                            \
+      (ptr) = (ptrtype)module->clazz->get_interface( module, id ); \
   FT_END_STMNT
 
 
@@ -152,18 +156,22 @@
    *   id ::
    *     The service ID.
    *
+   *   ptrtype ::
+   *     The pointer type of `ptr'.  This is needed to make FreeType
+   *     compile cleanly with C++.
+   *
    * @output:
    *   ptr ::
    *     A variable receiving the service data.  NULL if not available.
    */
-#define FT_FACE_LOOKUP_SERVICE( face, ptr, field, id )          \
+#define FT_FACE_LOOKUP_SERVICE( face, ptrtype, ptr, field, id ) \
   FT_BEGIN_STMNT                                                \
-    (ptr) = FT_FACE(face)->internal->services.field ;           \
+    (ptr) = (ptrtype)FT_FACE(face)->internal->services.field ;  \
     if ( (ptr) == FT_SERVICE_UNAVAILABLE )                      \
       (ptr) = NULL;                                             \
     else if ( (ptr) == NULL )                                   \
     {                                                           \
-      FT_FACE_FIND_SERVICE( ptr, face, id );                    \
+      FT_FACE_FIND_SERVICE( ptrtype, ptr, face, id );           \
                                                                 \
       FT_FACE(face)->internal->services.field =                 \
         (FT_Pointer)( (ptr) != NULL ? (ptr)                     \
--- a/src/base/ftbdf.c
+++ b/src/base/ftbdf.c
@@ -39,7 +39,9 @@
       FT_Service_BDF  service;
       
 
-      FT_FACE_FIND_SERVICE( service, face, FT_SERVICE_ID_BDF );
+      FT_FACE_FIND_SERVICE( FT_Service_BDF, service,
+                            face,
+                            FT_SERVICE_ID_BDF );
       
       if ( service && service->get_charset_id )
         error = service->get_charset_id( face, &encoding, &registry );
@@ -72,7 +74,9 @@
       FT_Service_BDF  service;
       
 
-      FT_FACE_FIND_SERVICE( service, face, FT_SERVICE_ID_BDF );
+      FT_FACE_FIND_SERVICE( FT_Service_BDF, service,
+                            face,
+                            FT_SERVICE_ID_BDF );
       
       if ( service && service->get_property )
         error = service->get_property( face, prop_name, aproperty );
--- a/src/base/ftmm.c
+++ b/src/base/ftmm.c
@@ -48,7 +48,8 @@
     
     if ( FT_HAS_MULTIPLE_MASTERS( face ) )
     {
-      FT_FACE_LOOKUP_SERVICE( face, *aservice,
+      FT_FACE_LOOKUP_SERVICE( face,
+                              FT_Service_MultiMasters, *aservice,
                               multi_masters,
                               FT_SERVICE_ID_MULTI_MASTERS );
     }
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -2401,13 +2401,14 @@
 
 #if 0
 
-      FT_FACE_LOOKUP_SERVICE( face, service,
+      FT_FACE_LOOKUP_SERVICE( face,
+                              FT_Service_GlyphDict, service,
                               glyph_dict,
                               FT_SERVICE_ID_GLYPH_DICT );
 
 #else
 
-      service = face->internal->services.glyph_dict;
+      service = (FT_Service_GlyphDict)face->internal->services.glyph_dict;
       if ( service == FT_SERVICE_UNAVAILABLE )
         service = NULL;
       else if ( service == NULL )
@@ -2416,11 +2417,11 @@
 
        
         if ( module->clazz->get_interface )
-          service = module->clazz->get_interface( module,
-                                                  FT_SERVICE_ID_GLYPH_DICT );
+          service = (FT_Service_GlyphDict)module->clazz->get_interface(
+                      module, FT_SERVICE_ID_GLYPH_DICT );
      
         face->internal->services.glyph_dict =
-          service != NULL ? service
+          service != NULL ? (FT_Pointer)service
                           : FT_SERVICE_UNAVAILABLE;
       }
 
@@ -2456,7 +2457,8 @@
       FT_Service_GlyphDict  service;
 
 
-      FT_FACE_LOOKUP_SERVICE( face, service,
+      FT_FACE_LOOKUP_SERVICE( face,
+                              FT_Service_GlyphDict, service,
                               glyph_dict,
                               FT_SERVICE_ID_GLYPH_DICT );
 
@@ -2484,7 +2486,8 @@
       FT_Service_PsName  service;
 
 
-      FT_FACE_LOOKUP_SERVICE( face, service,
+      FT_FACE_LOOKUP_SERVICE( face,
+                              FT_Service_PsName, service,
                               postscript_name,
                               FT_SERVICE_ID_POSTSCRIPT_NAME );
 
@@ -2509,7 +2512,9 @@
 
     if ( face && FT_IS_SFNT( face ) )
     {
-      FT_FACE_FIND_SERVICE( face, service, FT_SERVICE_ID_SFNT_TABLE );
+      FT_FACE_FIND_SERVICE( FT_Service_SFNT_Table, service,
+                            face,
+                            FT_SERVICE_ID_SFNT_TABLE );
       if ( service != NULL )
         table = service->get_table( face, tag );
     }
@@ -2533,7 +2538,9 @@
     if ( !face || !FT_IS_SFNT( face ) )
       return FT_Err_Invalid_Face_Handle;
 
-    FT_FACE_FIND_SERVICE( face, service, FT_SERVICE_ID_SFNT_TABLE );
+    FT_FACE_FIND_SERVICE( FT_Service_SFNT_Table, service,
+                          face,
+                          FT_SERVICE_ID_SFNT_TABLE );
     if ( service == NULL )
       return FT_Err_Unimplemented_Feature;
       
--- a/src/base/ftxf86.c
+++ b/src/base/ftxf86.c
@@ -26,8 +26,10 @@
   {
     const char*  result = NULL;
 
+
     if ( face )
-      FT_FACE_FIND_SERVICE( result, face, FT_SERVICE_ID_XF86_NAME );
+      FT_FACE_FIND_SERVICE( const char*, result,
+                            face, FT_SERVICE_ID_XF86_NAME );
 
     return result;
   }