Position Independent Code (PIC) support in pshinter module.

* include/freetype/internal/pshints.h add macros to init
instances of PSHinter_Interface.

* src/pshinter/pshmod.h declare pshinter_module_class
using macros from ftmodapi.h,
when FT_CONFIG_OPTION_PIC is defined create and destroy
functions will be declared.
* src/pshinter/pshmod.c when FT_CONFIG_OPTION_PIC is defined
pshinter_interface and pshinter_module_class structs
will have functions to init or create and destroy them
instead of being allocated in the global scope.
And macros will be used from pshpic.h in order to access them.

New Files:
* src/pshinter/pshpic.h declare struct to hold PIC globals for pshinter
module and macros to access them.
* src/pshinter/pshpic.c implement functions to allocate, destroy and
initialize PIC globals for pshinter module.

* src/pshinter/pshinter.c add new file to build: pshpic.c.
* src/pshinter/jamfile add new files to FT2_MULTI build: pshpic.c.
This commit is contained in:
Oran Agra 2009-04-05 18:20:16 +03:00
parent 24b110c6c6
commit 4e711be9f5
8 changed files with 180 additions and 12 deletions

View File

@ -1,3 +1,29 @@
2009-04-05 Oran Agra <oran@monfort.co.il>
Position Independent Code (PIC) support in pshinter module.
* include/freetype/internal/pshints.h add macros to init
instances of PSHinter_Interface.
* src/pshinter/pshmod.h declare pshinter_module_class
using macros from ftmodapi.h,
when FT_CONFIG_OPTION_PIC is defined create and destroy
functions will be declared.
* src/pshinter/pshmod.c when FT_CONFIG_OPTION_PIC is defined
pshinter_interface and pshinter_module_class structs
will have functions to init or create and destroy them
instead of being allocated in the global scope.
And macros will be used from pshpic.h in order to access them.
New Files:
* src/pshinter/pshpic.h declare struct to hold PIC globals for pshinter
module and macros to access them.
* src/pshinter/pshpic.c implement functions to allocate, destroy and
initialize PIC globals for pshinter module.
* src/pshinter/pshinter.c add new file to build: pshpic.c.
* src/pshinter/jamfile add new files to FT2_MULTI build: pshpic.c.
2009-04-05 Oran Agra <oran@monfort.co.il>
Position Independent Code (PIC) support in psnames module.

View File

@ -678,6 +678,30 @@ FT_BEGIN_HEADER
typedef PSHinter_Interface* PSHinter_Service;
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_PSHINTER_INTERFACE(class_, get_globals_funcs_, \
get_t1_funcs_, get_t2_funcs_) \
static const PSHinter_Interface class_ = \
{ \
get_globals_funcs_, get_t1_funcs_, get_t2_funcs_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_PSHINTER_INTERFACE(class_, get_globals_funcs_, \
get_t1_funcs_, get_t2_funcs_) \
void \
FT_Init_Class_##class_( FT_Library library, \
PSHinter_Interface* clazz) \
{ \
FT_UNUSED(library); \
clazz->get_globals_funcs = get_globals_funcs_; \
clazz->get_t1_funcs = get_t1_funcs_; \
clazz->get_t2_funcs = get_t2_funcs_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
FT_END_HEADER

View File

@ -16,7 +16,7 @@ SubDir FT2_TOP $(FT2_SRC_DIR) pshinter ;
if $(FT2_MULTI)
{
_sources = pshrec pshglob pshalgo pshmod ;
_sources = pshrec pshglob pshalgo pshmod pshpic ;
}
else
{

View File

@ -19,6 +19,7 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
#include "pshpic.c"
#include "pshrec.c"
#include "pshglob.c"
#include "pshalgo.c"

View File

@ -20,6 +20,7 @@
#include FT_INTERNAL_OBJECTS_H
#include "pshrec.h"
#include "pshalgo.h"
#include "pshpic.h"
/* the Postscript Hinter module structure */
@ -92,30 +93,26 @@
}
static
const PSHinter_Interface pshinter_interface =
{
FT_DEFINE_PSHINTER_INTERFACE(pshinter_interface,
pshinter_get_globals_funcs,
pshinter_get_t1_funcs,
pshinter_get_t2_funcs
};
)
FT_CALLBACK_TABLE_DEF
const FT_Module_Class pshinter_module_class =
{
FT_DEFINE_MODULE(pshinter_module_class,
0,
sizeof ( PS_Hinter_ModuleRec ),
"pshinter",
0x10000L,
0x20000L,
&pshinter_interface, /* module-specific interface */
&FTPSHINTER_INTERFACE_GET, /* module-specific interface */
(FT_Module_Constructor)ps_hinter_init,
(FT_Module_Destructor) ps_hinter_done,
(FT_Module_Requester) 0 /* no additional interface for now */
};
)
/* END */

View File

@ -27,7 +27,7 @@
FT_BEGIN_HEADER
FT_EXPORT_VAR( const FT_Module_Class ) pshinter_module_class;
FT_DECLARE_MODULE( pshinter_module_class )
FT_END_HEADER

67
src/pshinter/pshpic.c Normal file
View File

@ -0,0 +1,67 @@
/***************************************************************************/
/* */
/* pshpic.c */
/* */
/* The FreeType position independent code services for pshinter module. */
/* */
/* Copyright 2009 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "pshpic.h"
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from pshmod.c */
void FT_Init_Class_pshinter_interface( FT_Library, PSHinter_Interface*);
void
pshinter_module_class_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->pshinter )
{
FT_FREE( pic_container->pshinter );
pic_container->pshinter = NULL;
}
}
FT_Error
pshinter_module_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
PSHinterPIC* container;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof(*container) );
pic_container->pshinter = container;
/* add call to initialization function when you add new scripts */
FT_Init_Class_pshinter_interface(library, &container->pshinter_interface);
/*Exit:*/
if(error)
pshinter_module_class_pic_free(library);
return error;
}
#endif /* FT_CONFIG_OPTION_PIC */
/* END */

53
src/pshinter/pshpic.h Normal file
View File

@ -0,0 +1,53 @@
/***************************************************************************/
/* */
/* pshpic.h */
/* */
/* The FreeType position independent code services for pshinter module. */
/* */
/* Copyright 2009 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef __PSHPIC_H__
#define __PSHPIC_H__
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
#define FTPSHINTER_INTERFACE_GET pshinter_interface
#else /* FT_CONFIG_OPTION_PIC */
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
typedef struct PSHinterPIC_
{
PSHinter_Interface pshinter_interface;
} PSHinterPIC;
#define GET_PIC(lib) ((PSHinterPIC*)((lib)->pic_container.autofit))
#define FTPSHINTER_INTERFACE_GET (GET_PIC(library)->pshinter_interface)
#endif /* FT_CONFIG_OPTION_PIC */
/* */
FT_END_HEADER
#endif /* __PSHPIC_H__ */
/* END */