[autofit] Implement properties service framework.

No properties are added yet.

* src/autofit/afmodule.c: Include FT_SERVICE_PROPERTIES_H.
(af_property_set, af_property_get): New dummy functions.
(af_service_properties, af_services, af_get_interface): Provide
service setup.
(autofit_moduleclass): Add service interface.

* src/autofit/afpic.c: Add necessary forward declarations.
(autofit_module_class_pic_init): Add code for service addition.
(autofit_module_pic_free): Add code for service removal.
* src/autofit/afpic.h (AF_SERVICES_GET, AF_SERVICE_PROPERTIES_GET):
New macros which provide necessary syntactical sugar for PIC
support.
This commit is contained in:
Werner Lemberg 2012-08-31 00:20:29 +02:00
parent 0f8fd88e83
commit 7f316f22d1
4 changed files with 127 additions and 6 deletions

View File

@ -1,3 +1,22 @@
2012-08-31 Werner Lemberg <wl@gnu.org>
[autofit] Implement properties service framework.
No properties are added yet.
* src/autofit/afmodule.c: Include FT_SERVICE_PROPERTIES_H.
(af_property_set, af_property_get): New dummy functions.
(af_service_properties, af_services, af_get_interface): Provide
service setup.
(autofit_moduleclass): Add service interface.
* src/autofit/afpic.c: Add necessary forward declarations.
(autofit_module_class_pic_init): Add code for service addition.
(autofit_module_pic_free): Add code for service removal.
* src/autofit/afpic.h (AF_SERVICES_GET, AF_SERVICE_PROPERTIES_GET):
New macros which provide necessary syntactical sugar for PIC
support.
2012-08-30 Werner Lemberg <wl@gnu.org>
Implement properties to control FreeType modules.

View File

@ -28,6 +28,68 @@
#endif
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_PROPERTIES_H
FT_Error
af_property_set( FT_Library library,
const char* property_name,
const void* value )
{
FT_UNUSED( library );
FT_UNUSED( value );
FT_TRACE0(( "af_property_get: missing property `%s'\n",
property_name ));
return FT_Err_Missing_Property;
}
FT_Error
af_property_get( FT_Library library,
const char* property_name,
void* value )
{
FT_UNUSED( library );
FT_UNUSED( value );
FT_TRACE0(( "af_property_get: missing property `%s'\n",
property_name ));
return FT_Err_Missing_Property;
}
FT_DEFINE_SERVICE_PROPERTIESREC(
af_service_properties,
(FT_Properties_SetFunc)af_property_set,
(FT_Properties_GetFunc)af_property_get )
FT_DEFINE_SERVICEDESCREC1(
af_services,
FT_SERVICE_ID_PROPERTIES, &AF_SERVICE_PROPERTIES_GET )
FT_CALLBACK_DEF( FT_Module_Interface )
af_get_interface( FT_Module module,
const char* module_interface )
{
/* AF_SERVICES_GET derefers `library' in PIC mode */
#ifdef FT_CONFIG_OPTION_PIC
FT_Library library;
if ( !module )
return NULL;
library = module->library;
if ( !library )
return NULL;
#else
FT_UNUSED( module );
#endif
return ft_service_list_lookup( AF_SERVICES_GET, module_interface );
}
typedef struct FT_AutofitterRec_
@ -88,7 +150,7 @@
(FT_Module_Constructor)af_autofitter_init,
(FT_Module_Destructor) af_autofitter_done,
(FT_Module_Requester) NULL )
(FT_Module_Requester) af_get_interface )
/* END */

View File

@ -26,10 +26,22 @@
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from afmodule.c */
FT_Error
FT_Create_Class_af_services( FT_Library library,
FT_ServiceDescRec** output_class );
void
FT_Destroy_Class_af_services( FT_Library library,
FT_ServiceDescRec* clazz );
void
FT_Init_Class_af_service_properties( FT_Service_PropertiesRec* clazz );
void FT_Init_Class_af_autofitter_interface(
FT_Library library,
FT_AutoHinter_InterfaceRec* clazz );
/* forward declaration of PIC init functions from script classes */
#include "aflatin.h"
#ifdef FT_OPTION_AUTOFIT2
@ -49,7 +61,15 @@
if ( pic_container->autofit )
{
FT_FREE( pic_container->autofit );
AFModulePIC* container = (AFModulePIC*)pic_container->autofit;
if ( container->af_services )
FT_Destroy_Class_af_services( library,
container->af_services );
container->af_services = NULL;
FT_FREE( container );
pic_container->autofit = NULL;
}
}
@ -73,6 +93,13 @@
/* initialize pointer table - */
/* this is how the module usually expects this data */
error = FT_Create_Class_af_services( library,
&container->af_services );
if ( error )
goto Exit;
FT_Init_Class_af_service_properties( &container->af_service_properties );
for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ )
{
container->af_script_classes[ss] =
@ -98,8 +125,7 @@
FT_Init_Class_af_autofitter_interface(
library, &container->af_autofitter_interface );
/* Exit: */
Exit:
if ( error )
autofit_module_class_pic_free( library );
return error;

View File

@ -27,11 +27,17 @@ FT_BEGIN_HEADER
#ifndef FT_CONFIG_OPTION_PIC
#define AF_SCRIPT_CLASSES_GET af_script_classes
#define AF_INTERFACE_GET af_autofitter_interface
#define AF_SERVICES_GET af_services
#define AF_SERVICE_PROPERTIES_GET af_service_properties
#define AF_SCRIPT_CLASSES_GET af_script_classes
#define AF_INTERFACE_GET af_autofitter_interface
#else /* FT_CONFIG_OPTION_PIC */
/* some include files required for members of AFModulePIC */
#include FT_SERVICE_PROPERTIES_H
#include "aftypes.h"
/* increase these when you add new scripts, */
@ -47,6 +53,9 @@ FT_BEGIN_HEADER
typedef struct AFModulePIC_
{
FT_ServiceDescRec* af_services;
FT_Service_PropertiesRec af_service_properties;
AF_ScriptClass af_script_classes[AF_SCRIPT_CLASSES_COUNT];
AF_ScriptClassRec af_script_classes_rec[AF_SCRIPT_CLASSES_REC_COUNT];
FT_AutoHinter_InterfaceRec af_autofitter_interface;
@ -57,6 +66,11 @@ FT_BEGIN_HEADER
#define GET_PIC( lib ) \
( (AFModulePIC*)((lib)->pic_container.autofit) )
#define AF_SERVICES_GET \
( GET_PIC( library )->af_services )
#define AF_SERVICE_PROPERTIES_GET \
( GET_PIC( library)->af_service_properties )
#define AF_SCRIPT_CLASSES_GET \
( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_script_classes )
#define AF_INTERFACE_GET \