diff options
author | suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> | 2012-01-17 15:13:50 +0900 |
---|---|---|
committer | suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> | 2012-01-17 15:13:50 +0900 |
commit | c7c4d68bfb1158db1f78d68131aff5ba8973f9d6 (patch) | |
tree | 38b6cae06bb167087eac2a920279dc3f96139446 /src/base/ftrfork.c | |
parent | 1749d8bc6af8108df5a6555a894ed474138f2552 (diff) | |
download | freetype2-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.
Diffstat (limited to 'src/base/ftrfork.c')
-rw-r--r-- | src/base/ftrfork.c | 78 |
1 files changed, 27 insertions, 51 deletions
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: |