[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.
This commit is contained in:
suzuki toshiya 2012-01-17 15:13:50 +09:00
Родитель 1749d8bc6a
Коммит c7c4d68bfb
7 изменённых файлов: 136 добавлений и 53 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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 */
/*************************************************************************/
/* */

Просмотреть файл

@ -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 )

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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"

Просмотреть файл

@ -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: