summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsuzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>2012-01-17 15:13:50 +0900
committersuzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>2012-01-17 15:13:50 +0900
commitc7c4d68bfb1158db1f78d68131aff5ba8973f9d6 (patch)
tree38b6cae06bb167087eac2a920279dc3f96139446
parent1749d8bc6af8108df5a6555a894ed474138f2552 (diff)
downloadfreetype2-c7c4d68bfb1158db1f78d68131aff5ba8973f9d6.tar.gz
[raccess] Modify for PIC build.
Based on the patch provided by Erik Dahlstrom <ed@opera.com>, http://lists.gnu.org/archive/html/freetype-devel/2012-01/msg00010.html Also `raccess_guess_table[]' and `raccess_rule_by_darwin_vfs()' are renamed with `ft_' suffixes. * src/base/ftbase.h: `raccess_rule_by_darwin_vfs()' is renamed to `ft_raccess_rule_by_darwin_vfs()'. * src/base/ftobjs.c: Ditto. * src/base/ftrfork.c: Declarations of FT_RFork_Rule, raccess_guess_rec, are moved to... * include/freetype/internal/ftrfork.h: Here. * include/freetype/internal/ftrfork.h: FT_RFORK_RULE_ARRAY_{BEGIN,ENTRY,END} macros are defined to replace raccess_guess_table[] in both of PIC and non-PIC modes. * src/base/ftrfork.c: raccess_guess_table[] array is rewritten by FT_RFORK_RULE_ARRAY_{BEGIN,ENTRY,END}. * src/base/basepic.h (BasePIC): Add `ft_raccess_guess_table' storage. (FT_RACCESS_GUESS_TABLE_GET): New macro to retrieve the function pointer from `ft_raccess_guess_table' storage in `BasePIC' structure. * src/base/ftrfork.c (FT_Raccess_Guess): Rewritten with FT_RACCESS_GUESS_TABLE_GET. (raccess_get_rule_type_from_rule_index): Add `library' as the first argument to the function, to retrieve the storage of `ft_raccess_guess_table' from it. Also `raccess_guess_table' is replaced by FT_RACCESS_GUESS_TABLE_GET. (ft_raccess_rule_by_darwin_vfs): Ditto.
-rw-r--r--ChangeLog37
-rw-r--r--include/freetype/internal/ftrfork.h51
-rw-r--r--src/base/basepic.c5
-rw-r--r--src/base/basepic.h14
-rw-r--r--src/base/ftbase.h2
-rw-r--r--src/base/ftobjs.c2
-rw-r--r--src/base/ftrfork.c78
7 files changed, 136 insertions, 53 deletions
diff --git a/ChangeLog b/ChangeLog
index 6b1170420..977a4a63b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,40 @@
+2012-01-17 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
+ [raccess] Modify for PIC build.
+
+ Based on the patch provided by Erik Dahlstrom <ed@opera.com>,
+ http://lists.gnu.org/archive/html/freetype-devel/2012-01/msg00010.html
+
+ Also `raccess_guess_table[]' and `raccess_rule_by_darwin_vfs()'
+ are renamed with `ft_' suffixes.
+
+ * src/base/ftbase.h: `raccess_rule_by_darwin_vfs()' is renamed
+ to `ft_raccess_rule_by_darwin_vfs()'.
+ * src/base/ftobjs.c: Ditto.
+
+ * src/base/ftrfork.c: Declarations of FT_RFork_Rule,
+ raccess_guess_rec, are moved to...
+ * include/freetype/internal/ftrfork.h: Here.
+
+ * include/freetype/internal/ftrfork.h:
+ FT_RFORK_RULE_ARRAY_{BEGIN,ENTRY,END} macros are defined
+ to replace raccess_guess_table[] in both of PIC and non-PIC
+ modes.
+ * src/base/ftrfork.c: raccess_guess_table[] array is rewritten
+ by FT_RFORK_RULE_ARRAY_{BEGIN,ENTRY,END}.
+
+ * src/base/basepic.h (BasePIC): Add `ft_raccess_guess_table'
+ storage. (FT_RACCESS_GUESS_TABLE_GET): New macro to retrieve
+ the function pointer from `ft_raccess_guess_table' storage in
+ `BasePIC' structure.
+ * src/base/ftrfork.c (FT_Raccess_Guess): Rewritten with
+ FT_RACCESS_GUESS_TABLE_GET.
+ (raccess_get_rule_type_from_rule_index): Add `library' as the
+ first argument to the function, to retrieve the storage of
+ `ft_raccess_guess_table' from it. Also `raccess_guess_table'
+ is replaced by FT_RACCESS_GUESS_TABLE_GET.
+ (ft_raccess_rule_by_darwin_vfs): Ditto.
+
2012-01-16 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
Remove trailing spaces.
diff --git a/include/freetype/internal/ftrfork.h b/include/freetype/internal/ftrfork.h
index aa573c870..77e10206a 100644
--- a/include/freetype/internal/ftrfork.h
+++ b/include/freetype/internal/ftrfork.h
@@ -48,6 +48,57 @@ FT_BEGIN_HEADER
} FT_RFork_Ref;
+#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
+ typedef FT_Error
+ (*ft_raccess_guess_func)( FT_Library library,
+ FT_Stream stream,
+ char *base_file_name,
+ char **result_file_name,
+ FT_Long *result_offset );
+
+ typedef enum FT_RFork_Rule_ {
+ FT_RFork_Rule_invalid = -2,
+ FT_RFork_Rule_uknown, /* -1 */
+ FT_RFork_Rule_apple_double,
+ FT_RFork_Rule_apple_single,
+ FT_RFork_Rule_darwin_ufs_export,
+ FT_RFork_Rule_darwin_newvfs,
+ FT_RFork_Rule_darwin_hfsplus,
+ FT_RFork_Rule_vfat,
+ FT_RFork_Rule_linux_cap,
+ FT_RFork_Rule_linux_double,
+ FT_RFork_Rule_linux_netatalk
+ } FT_RFork_Rule;
+
+ /* For fast translation between rule index and rule type,
+ * the macros FT_RFORK_xxx should be kept consistent with
+ * the raccess_guess_funcs table
+ */
+ typedef struct ft_raccess_guess_rec_ {
+ ft_raccess_guess_func func;
+ FT_RFork_Rule type;
+ } ft_raccess_guess_rec;
+
+#ifndef FT_CONFIG_OPTION_PIC
+ /* this array is a storage in non-PIC mode, so ; is needed in END */
+#define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \
+ const type name[] = {
+#define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \
+ { raccess_guess_##func_suffix, FT_RFork_Rule_##type_suffix },
+#define CONST_FT_RFORK_RULE_ARRAY_END };
+#else /* FT_CONFIG_OPTION_PIC */
+ /* this array is a function in PIC mode, so no ; is needed in END */
+#define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \
+ void FT_Init_##name ( type* storage ) { \
+ type *local = storage; \
+ int i = 0;
+#define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \
+ local[i].func = raccess_guess_##func_suffix; \
+ local[i].type = FT_RFork_Rule_##type_suffix; \
+ i++;
+#define CONST_FT_RFORK_RULE_ARRAY_END }
+#endif /* FT_CONFIG_OPTION_PIC */
+#endif /* FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
/*************************************************************************/
/* */
diff --git a/src/base/basepic.c b/src/base/basepic.c
index cc5fbbd65..d754eb1b0 100644
--- a/src/base/basepic.c
+++ b/src/base/basepic.c
@@ -27,6 +27,9 @@
void FT_Init_Class_ft_outline_glyph_class( FT_Glyph_Class* clazz );
void FT_Init_Class_ft_bitmap_glyph_class( FT_Glyph_Class* clazz );
+ /* forward declaration of PIC init function from ftrfork.c (not modularized) */
+ void FT_Init_Table_raccess_guess_table( ft_raccess_guess_rec* record );
+
/* forward declaration of PIC init functions from ftinit.c */
FT_Error
ft_create_default_module_classes( FT_Library library );
@@ -74,6 +77,8 @@
&container->ft_outline_glyph_class );
FT_Init_Class_ft_bitmap_glyph_class(
&container->ft_bitmap_glyph_class );
+ FT_Init_Table_raccess_guess_table(
+ (ft_raccess_guess_rec*)&container->ft_raccess_guess_table);
Exit:
if( error )
diff --git a/src/base/basepic.h b/src/base/basepic.h
index 0ed555448..bf90bef0b 100644
--- a/src/base/basepic.h
+++ b/src/base/basepic.h
@@ -28,22 +28,36 @@ FT_BEGIN_HEADER
#define FT_OUTLINE_GLYPH_CLASS_GET &ft_outline_glyph_class
#define FT_BITMAP_GLYPH_CLASS_GET &ft_bitmap_glyph_class
#define FT_DEFAULT_MODULES_GET ft_default_modules
+#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
+#define FT_RACCESS_GUESS_TABLE_GET ft_raccess_guess_table
+#endif
#else /* FT_CONFIG_OPTION_PIC */
#include FT_GLYPH_H
+#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
+#include FT_INTERNAL_RFORK_H
+#endif
+
+
typedef struct BasePIC_
{
FT_Module_Class** default_module_classes;
FT_Glyph_Class ft_outline_glyph_class;
FT_Glyph_Class ft_bitmap_glyph_class;
+#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
+ ft_raccess_guess_rec ft_raccess_guess_table[FT_RACCESS_N_RULES];
+#endif
} BasePIC;
#define GET_PIC(lib) ((BasePIC*)((lib)->pic_container.base))
#define FT_OUTLINE_GLYPH_CLASS_GET (&GET_PIC(library)->ft_outline_glyph_class)
#define FT_BITMAP_GLYPH_CLASS_GET (&GET_PIC(library)->ft_bitmap_glyph_class)
#define FT_DEFAULT_MODULES_GET (GET_PIC(library)->default_module_classes)
+#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
+#define FT_RACCESS_GUESS_TABLE_GET (GET_PIC(library)->ft_raccess_guess_table)
+#endif
/* see basepic.c for the implementation. */
void
diff --git a/src/base/ftbase.h b/src/base/ftbase.h
index cb5519774..51a1db18b 100644
--- a/src/base/ftbase.h
+++ b/src/base/ftbase.h
@@ -57,7 +57,7 @@ FT_BEGIN_HEADER
/* on Darwin VFS should be grouped and skip the rest methods after */
/* the case the resource is opened but found to lack a font in it. */
FT_LOCAL( FT_Bool )
- raccess_rule_by_darwin_vfs( FT_UInt rule_index );
+ ft_raccess_rule_by_darwin_vfs( FT_Library library, FT_UInt rule_index );
#endif
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 1a5a32765..b776a951b 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -1875,7 +1875,7 @@
for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
{
- is_darwin_vfs = raccess_rule_by_darwin_vfs( i );
+ is_darwin_vfs = ft_raccess_rule_by_darwin_vfs( library, i );
if ( is_darwin_vfs && vfs_rfork_has_no_font )
{
FT_TRACE3(( "Skip rule %d: darwin vfs resource fork"
diff --git a/src/base/ftrfork.c b/src/base/ftrfork.c
index e58d2fc3b..01d8625e6 100644
--- a/src/base/ftrfork.c
+++ b/src/base/ftrfork.c
@@ -28,7 +28,7 @@
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_RFORK_H
-
+#include "basepic.h"
#undef FT_COMPONENT
#define FT_COMPONENT trace_raccess
@@ -253,14 +253,6 @@
/*************************************************************************/
/*************************************************************************/
- typedef FT_Error
- (*raccess_guess_func)( FT_Library library,
- FT_Stream stream,
- char *base_file_name,
- char **result_file_name,
- FT_Long *result_offset );
-
-
static FT_Error
raccess_guess_apple_double( FT_Library library,
FT_Stream stream,
@@ -325,6 +317,20 @@
FT_Long *result_offset );
+ CONST_FT_RFORK_RULE_ARRAY_BEGIN(ft_raccess_guess_table,
+ ft_raccess_guess_rec)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(apple_double, apple_double)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(apple_single, apple_single)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_ufs_export, darwin_ufs_export)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_newvfs, darwin_newvfs)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_hfsplus, darwin_hfsplus)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(vfat, vfat)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_cap, linux_cap)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_double, linux_double)
+ CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_netatalk, linux_netatalk)
+ CONST_FT_RFORK_RULE_ARRAY_END
+
+
/*************************************************************************/
/**** ****/
/**** Helper functions ****/
@@ -348,43 +354,6 @@
const char *original_name,
const char *insertion );
-
- typedef enum FT_RFork_Rule_ {
- FT_RFork_Rule_invalid = -2,
- FT_RFork_Rule_uknown, /* -1 */
- FT_RFork_Rule_apple_double,
- FT_RFork_Rule_apple_single,
- FT_RFork_Rule_darwin_ufs_export,
- FT_RFork_Rule_darwin_newvfs,
- FT_RFork_Rule_darwin_hfsplus,
- FT_RFork_Rule_vfat,
- FT_RFork_Rule_linux_cap,
- FT_RFork_Rule_linux_double,
- FT_RFork_Rule_linux_netatalk
- } FT_RFork_Rule;
-
- /* For fast translation between rule index and rule type,
- * the macros FT_RFORK_xxx should be kept consistent with
- * the raccess_guess_funcs table
- */
- typedef struct raccess_guess_rec_ {
- raccess_guess_func func;
- FT_RFork_Rule type;
- } raccess_guess_rec;
-
- static raccess_guess_rec raccess_guess_table[FT_RACCESS_N_RULES] =
- {
- { raccess_guess_apple_double, FT_RFork_Rule_apple_double, },
- { raccess_guess_apple_single, FT_RFork_Rule_apple_single, },
- { raccess_guess_darwin_ufs_export, FT_RFork_Rule_darwin_ufs_export, },
- { raccess_guess_darwin_newvfs, FT_RFork_Rule_darwin_newvfs, },
- { raccess_guess_darwin_hfsplus, FT_RFork_Rule_darwin_hfsplus, },
- { raccess_guess_vfat, FT_RFork_Rule_vfat, },
- { raccess_guess_linux_cap, FT_RFork_Rule_linux_cap, },
- { raccess_guess_linux_double, FT_RFork_Rule_linux_double, },
- { raccess_guess_linux_netatalk, FT_RFork_Rule_linux_netatalk, },
- };
-
FT_BASE_DEF( void )
FT_Raccess_Guess( FT_Library library,
FT_Stream stream,
@@ -407,7 +376,7 @@
if ( errors[i] )
continue ;
- errors[i] = (raccess_guess_table[i].func)( library,
+ errors[i] = (FT_RACCESS_GUESS_TABLE_GET[i].func)( library,
stream, base_name,
&(new_names[i]),
&(offsets[i]) );
@@ -419,19 +388,26 @@
#ifndef FT_MACINTOSH
static FT_RFork_Rule
- raccess_get_rule_type_from_rule_index( FT_UInt rule_index )
+ raccess_get_rule_type_from_rule_index( FT_Library library,
+ FT_UInt rule_index )
{
+ FT_UNUSED( library );
+
if ( rule_index >= FT_RACCESS_N_RULES )
return FT_RFork_Rule_invalid;
- return raccess_guess_table[rule_index].type;
+ return FT_RACCESS_GUESS_TABLE_GET[rule_index].type;
}
+ /*
+ * For this function, refer ftbase.h.
+ */
FT_LOCAL_DEF( FT_Bool )
- raccess_rule_by_darwin_vfs( FT_UInt rule_index )
+ ft_raccess_rule_by_darwin_vfs( FT_Library library,
+ FT_UInt rule_index )
{
- switch( raccess_get_rule_type_from_rule_index( rule_index ) )
+ switch( raccess_get_rule_type_from_rule_index( library, rule_index ) )
{
case FT_RFork_Rule_darwin_newvfs:
case FT_RFork_Rule_darwin_hfsplus: