Remove some declare/define macros (pt 1).

These macros were relics of PIC code removed some time ago. They only hid
the class initializations. We make those explicit again.

* include/freetype/internal/ftobjs.h (FT_DECLARE_MODULE, FT_DEFINE_MODULE,
FT_DECLARE_RENDERER, FT_DEFINE_RENDERER): Removed.
* include/freetype/internal/ftdrv.h (FT_DECLARE_DRIVER, FT_DEFINE_DRIVER):
Removed.
* src/*: Updated all former users.
This commit is contained in:
Alexei Podtelezhnikov 2025-09-01 17:53:13 -04:00
parent 1b6845d9b8
commit e08810da82
24 changed files with 117 additions and 331 deletions

View file

@ -192,95 +192,6 @@ FT_BEGIN_HEADER
} FT_Driver_Class, FT_Driver_ClassRec;
/**************************************************************************
*
* @macro:
* FT_DECLARE_DRIVER
*
* @description:
* Used to create a forward declaration of an FT_Driver_Class struct
* instance.
*
* @macro:
* FT_DEFINE_DRIVER
*
* @description:
* Used to initialize an instance of FT_Driver_Class struct.
*
* `ftinit.c` (ft_create_default_module_classes) already contains a
* mechanism to call these functions for the default modules described in
* `ftmodule.h`.
*
* The struct will be allocated in the global scope (or the scope where
* the macro is used).
*/
#define FT_DECLARE_DRIVER( class_ ) \
FT_CALLBACK_TABLE \
FT_Driver_Class class_;
#define FT_DEFINE_DRIVER( \
class_, \
flags_, \
size_, \
name_, \
version_, \
requires_, \
interface_, \
init_, \
done_, \
get_interface_, \
face_object_size_, \
size_object_size_, \
slot_object_size_, \
init_face_, \
done_face_, \
init_size_, \
done_size_, \
init_slot_, \
done_slot_, \
load_glyph_, \
get_kerning_, \
attach_file_, \
get_advances_, \
request_size_, \
select_size_ ) \
FT_CALLBACK_TABLE_DEF \
FT_Driver_Class class_ = \
{ \
FT_DEFINE_ROOT_MODULE( flags_, \
size_, \
name_, \
version_, \
requires_, \
interface_, \
init_, \
done_, \
get_interface_ ) \
\
face_object_size_, \
size_object_size_, \
slot_object_size_, \
\
init_face_, \
done_face_, \
\
init_size_, \
done_size_, \
\
init_slot_, \
done_slot_, \
\
load_glyph_, \
\
get_kerning_, \
attach_file_, \
get_advances_, \
\
request_size_, \
select_size_ \
};
FT_END_HEADER
#endif /* FTDRV_H_ */

View file

@ -1101,151 +1101,6 @@ FT_BEGIN_HEADER
};
/**************************************************************************
*
* @macro:
* FT_DECLARE_RENDERER
*
* @description:
* Used to create a forward declaration of a FT_Renderer_Class struct
* instance.
*
* @macro:
* FT_DEFINE_RENDERER
*
* @description:
* Used to initialize an instance of FT_Renderer_Class struct.
*
* The struct will be allocated in the global scope (or the scope where
* the macro is used).
*/
#define FT_DECLARE_RENDERER( class_ ) \
FT_EXPORT_VAR( FT_Renderer_Class ) class_;
#define FT_DEFINE_RENDERER( \
class_, \
flags_, \
size_, \
name_, \
version_, \
requires_, \
interface_, \
init_, \
done_, \
get_interface_, \
glyph_format_, \
render_glyph_, \
transform_glyph_, \
get_glyph_cbox_, \
set_mode_, \
raster_class_ ) \
FT_CALLBACK_TABLE_DEF \
FT_Renderer_Class class_ = \
{ \
FT_DEFINE_ROOT_MODULE( flags_, \
size_, \
name_, \
version_, \
requires_, \
interface_, \
init_, \
done_, \
get_interface_ ) \
glyph_format_, \
\
render_glyph_, \
transform_glyph_, \
get_glyph_cbox_, \
set_mode_, \
\
raster_class_ \
};
/**************************************************************************
*
* @macro:
* FT_DECLARE_MODULE
*
* @description:
* Used to create a forward declaration of a FT_Module_Class struct
* instance.
*
* @macro:
* FT_DEFINE_MODULE
*
* @description:
* Used to initialize an instance of an FT_Module_Class struct.
*
* The struct will be allocated in the global scope (or the scope where
* the macro is used).
*
* @macro:
* FT_DEFINE_ROOT_MODULE
*
* @description:
* Used to initialize an instance of an FT_Module_Class struct inside
* another struct that contains it or in a function that initializes that
* containing struct.
*/
#define FT_DECLARE_MODULE( class_ ) \
FT_CALLBACK_TABLE \
FT_Module_Class class_;
#define FT_DEFINE_ROOT_MODULE( \
flags_, \
size_, \
name_, \
version_, \
requires_, \
interface_, \
init_, \
done_, \
get_interface_ ) \
{ \
flags_, \
size_, \
\
name_, \
version_, \
requires_, \
\
interface_, \
\
init_, \
done_, \
get_interface_, \
},
#define FT_DEFINE_MODULE( \
class_, \
flags_, \
size_, \
name_, \
version_, \
requires_, \
interface_, \
init_, \
done_, \
get_interface_) \
FT_CALLBACK_TABLE_DEF \
FT_Module_Class class_ = \
{ \
flags_, \
size_, \
\
name_, \
version_, \
requires_, \
\
interface_, \
\
init_, \
done_, \
get_interface_, \
};
FT_END_HEADER
#endif /* FTOBJS_H_ */

View file

@ -516,9 +516,10 @@
af_autofitter_load_glyph /* FT_AutoHinter_GlyphLoadFunc load_glyph */
)
FT_DEFINE_MODULE(
autofit_module_class,
FT_CALLBACK_TABLE_DEF
FT_Module_Class autofit_module_class =
{
FT_MODULE_HINTER,
sizeof ( AF_ModuleRec ),
@ -531,7 +532,7 @@
af_autofitter_init, /* FT_Module_Constructor module_init */
af_autofitter_done, /* FT_Module_Destructor module_done */
af_get_interface /* FT_Module_Requester get_interface */
)
};
/* END */

View file

@ -50,7 +50,10 @@ FT_BEGIN_HEADER
FT_DECLARE_AUTOHINTER_INTERFACE( af_autofitter_interface )
FT_DECLARE_MODULE( autofit_module_class )
FT_CALLBACK_TABLE
FT_Module_Class autofit_module_class;
FT_END_HEADER

View file

@ -1179,9 +1179,10 @@
#define CFF_SIZE_SELECT 0
#endif
FT_DEFINE_DRIVER(
cff_driver_class,
FT_CALLBACK_TABLE_DEF
FT_Driver_Class cff_driver_class =
{
{
FT_MODULE_FONT_DRIVER |
FT_MODULE_DRIVER_SCALABLE |
FT_MODULE_DRIVER_HAS_HINTER |
@ -1196,7 +1197,8 @@
cff_driver_init, /* FT_Module_Constructor module_init */
cff_driver_done, /* FT_Module_Destructor module_done */
cff_get_interface, /* FT_Module_Requester get_interface */
cff_get_interface /* FT_Module_Requester get_interface */
},
sizeof ( TT_FaceRec ),
sizeof ( CFF_SizeRec ),
@ -1217,7 +1219,7 @@
cff_size_request, /* FT_Size_RequestFunc request_size */
CFF_SIZE_SELECT /* FT_Size_SelectFunc select_size */
)
};
/* END */

View file

@ -25,7 +25,8 @@
FT_BEGIN_HEADER
FT_DECLARE_DRIVER( cff_driver_class )
FT_CALLBACK_TABLE
FT_Driver_Class cff_driver_class;
FT_END_HEADER

View file

@ -170,9 +170,9 @@
};
FT_DEFINE_MODULE(
psaux_module_class,
FT_CALLBACK_TABLE_DEF
FT_Module_Class psaux_module_class =
{
0,
sizeof ( FT_ModuleRec ),
"psaux",
@ -184,7 +184,7 @@
(FT_Module_Constructor)NULL, /* module_init */
(FT_Module_Destructor) NULL, /* module_done */
(FT_Module_Requester) NULL /* get_interface */
)
};
/* END */

View file

@ -45,8 +45,8 @@ FT_BEGIN_HEADER
FT_CALLBACK_TABLE
const CFF_Decoder_FuncsRec cff_decoder_funcs;
FT_DECLARE_MODULE( psaux_module_class )
FT_CALLBACK_TABLE
FT_Module_Class psaux_module_class;
FT_END_HEADER

View file

@ -106,9 +106,9 @@
)
FT_DEFINE_MODULE(
pshinter_module_class,
FT_CALLBACK_TABLE_DEF
FT_Module_Class pshinter_module_class =
{
0,
sizeof ( PS_Hinter_ModuleRec ),
"pshinter",
@ -120,6 +120,6 @@
(FT_Module_Constructor)ps_hinter_init, /* module_init */
(FT_Module_Destructor) ps_hinter_done, /* module_done */
(FT_Module_Requester) NULL /* get_interface */
)
};
/* END */

View file

@ -25,9 +25,8 @@
FT_BEGIN_HEADER
FT_DECLARE_MODULE( pshinter_module_class )
FT_CALLBACK_TABLE
FT_Module_Class pshinter_module_class;
FT_END_HEADER

View file

@ -599,9 +599,9 @@
#define PUT_PS_NAMES_SERVICE( a ) a
#endif
FT_DEFINE_MODULE(
psnames_module_class,
FT_CALLBACK_TABLE_DEF
FT_Module_Class psnames_module_class =
{
0, /* this is not a font driver, nor a renderer */
sizeof ( FT_ModuleRec ),
@ -615,7 +615,7 @@
NULL, /* FT_Module_Constructor module_init */
NULL, /* FT_Module_Destructor module_done */
PUT_PS_NAMES_SERVICE( psnames_get_service ) /* FT_Module_Requester get_interface */
)
};
/* END */

View file

@ -25,9 +25,8 @@
FT_BEGIN_HEADER
FT_DECLARE_MODULE( psnames_module_class )
FT_CALLBACK_TABLE
FT_Module_Class psnames_module_class;
FT_END_HEADER

View file

@ -179,9 +179,10 @@
}
FT_DEFINE_RENDERER(
ft_raster1_renderer_class,
FT_CALLBACK_TABLE_DEF
FT_Renderer_Class ft_raster1_renderer_class =
{
{
FT_MODULE_RENDERER,
sizeof ( FT_RendererRec ),
@ -193,7 +194,8 @@
ft_raster1_init, /* FT_Module_Constructor module_init */
NULL, /* FT_Module_Destructor module_done */
NULL, /* FT_Module_Requester get_interface */
NULL /* FT_Module_Requester get_interface */
},
FT_GLYPH_FORMAT_OUTLINE,
@ -203,7 +205,7 @@
ft_raster1_set_mode, /* FT_Renderer_SetModeFunc set_mode */
&ft_standard_raster /* FT_Raster_Funcs* raster_class */
)
};
/* END */

View file

@ -25,9 +25,8 @@
FT_BEGIN_HEADER
FT_DECLARE_RENDERER( ft_raster1_renderer_class )
FT_CALLBACK_TABLE
FT_Renderer_Class ft_raster1_renderer_class;
FT_END_HEADER

View file

@ -424,21 +424,23 @@
}
FT_DEFINE_RENDERER(
ft_sdf_renderer_class,
FT_CALLBACK_TABLE_DEF
FT_Renderer_Class ft_sdf_renderer_class =
{
{
FT_MODULE_RENDERER,
sizeof ( SDF_Renderer_Module ),
FT_MODULE_RENDERER,
sizeof ( SDF_Renderer_Module ),
"sdf",
0x10000L,
0x20000L,
"sdf",
0x10000L,
0x20000L,
NULL,
NULL,
(FT_Module_Constructor)ft_sdf_init,
(FT_Module_Destructor) ft_sdf_done,
(FT_Module_Requester) ft_sdf_requester,
(FT_Module_Constructor)ft_sdf_init,
(FT_Module_Destructor) ft_sdf_done,
(FT_Module_Requester) ft_sdf_requester
},
FT_GLYPH_FORMAT_OUTLINE,
@ -448,7 +450,7 @@
(FT_Renderer_SetModeFunc) ft_sdf_set_mode, /* set_mode */
(FT_Raster_Funcs*)&ft_sdf_raster /* raster_class */
)
};
/*************************************************************************/
@ -573,21 +575,23 @@
}
FT_DEFINE_RENDERER(
ft_bitmap_sdf_renderer_class,
FT_CALLBACK_TABLE_DEF
FT_Renderer_Class ft_bitmap_sdf_renderer_class =
{
{
FT_MODULE_RENDERER,
sizeof ( SDF_Renderer_Module ),
FT_MODULE_RENDERER,
sizeof ( SDF_Renderer_Module ),
"bsdf",
0x10000L,
0x20000L,
"bsdf",
0x10000L,
0x20000L,
NULL,
NULL,
(FT_Module_Constructor)ft_sdf_init,
(FT_Module_Destructor) ft_sdf_done,
(FT_Module_Requester) ft_sdf_requester,
(FT_Module_Constructor)ft_sdf_init,
(FT_Module_Destructor) ft_sdf_done,
(FT_Module_Requester) ft_sdf_requester
},
FT_GLYPH_FORMAT_BITMAP,
@ -597,7 +601,7 @@
(FT_Renderer_SetModeFunc) ft_sdf_set_mode, /* set_mode */
(FT_Raster_Funcs*)&ft_bitmap_sdf_raster /* raster_class */
)
};
/* END */

View file

@ -91,7 +91,8 @@ FT_BEGIN_HEADER
* Renderer to convert @FT_Outline to signed distance fields.
*
*/
FT_DECLARE_RENDERER( ft_sdf_renderer_class )
FT_CALLBACK_TABLE
FT_Renderer_Class ft_sdf_renderer_class;
/**************************************************************************
@ -107,7 +108,8 @@ FT_BEGIN_HEADER
* This is not a separate module, it is part of the 'sdf' module.
*
*/
FT_DECLARE_RENDERER( ft_bitmap_sdf_renderer_class )
FT_CALLBACK_TABLE
FT_Renderer_Class ft_bitmap_sdf_renderer_class;
FT_END_HEADER

View file

@ -1363,9 +1363,9 @@
)
FT_DEFINE_MODULE(
sfnt_module_class,
FT_CALLBACK_TABLE_DEF
FT_Module_Class sfnt_module_class =
{
0, /* not a font driver or renderer */
sizeof ( FT_ModuleRec ),
@ -1378,7 +1378,7 @@
NULL, /* FT_Module_Constructor module_init */
NULL, /* FT_Module_Destructor module_done */
sfnt_get_interface /* FT_Module_Requester get_interface */
)
};
/* END */

View file

@ -25,7 +25,8 @@
FT_BEGIN_HEADER
FT_DECLARE_MODULE( sfnt_module_class )
FT_CALLBACK_TABLE
FT_Module_Class sfnt_module_class;
FT_END_HEADER

View file

@ -575,9 +575,10 @@
}
FT_DEFINE_RENDERER(
ft_smooth_renderer_class,
FT_CALLBACK_TABLE_DEF
FT_Renderer_Class ft_smooth_renderer_class =
{
{
FT_MODULE_RENDERER,
sizeof ( FT_RendererRec ),
@ -589,7 +590,8 @@
(FT_Module_Constructor)ft_smooth_init, /* module_init */
(FT_Module_Destructor) NULL, /* module_done */
(FT_Module_Requester) NULL, /* get_interface */
(FT_Module_Requester) NULL /* get_interface */
},
FT_GLYPH_FORMAT_OUTLINE,
@ -599,7 +601,7 @@
(FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */
(FT_Raster_Funcs*)&ft_grays_raster /* raster_class */
)
};
/* END */

View file

@ -25,9 +25,8 @@
FT_BEGIN_HEADER
FT_DECLARE_RENDERER( ft_smooth_renderer_class )
FT_CALLBACK_TABLE
FT_Renderer_Class ft_smooth_renderer_class;
FT_END_HEADER

View file

@ -326,9 +326,10 @@
#endif
FT_DEFINE_RENDERER(
ft_svg_renderer_class,
FT_CALLBACK_TABLE_DEF
FT_Renderer_Class ft_svg_renderer_class =
{
{
FT_MODULE_RENDERER,
sizeof ( SVG_RendererRec ),
@ -340,16 +341,17 @@
PUT_SVG_MODULE( ft_svg_init ), /* FT_Module_Constructor module_init */
PUT_SVG_MODULE( ft_svg_done ), /* FT_Module_Destructor module_done */
PUT_SVG_MODULE( ft_svg_get_interface ), /* FT_Module_Requester get_interface */
PUT_SVG_MODULE( ft_svg_get_interface ) /* FT_Module_Requester get_interface */
},
SVG_GLYPH_FORMAT,
SVG_GLYPH_FORMAT,
PUT_SVG_MODULE( ft_svg_render ), /* FT_Renderer_RenderFunc render_glyph */
PUT_SVG_MODULE( ft_svg_transform ), /* FT_Renderer_TransformFunc transform_glyph */
NULL, /* FT_Renderer_GetCBoxFunc get_glyph_cbox */
NULL, /* FT_Renderer_SetModeFunc set_mode */
NULL /* FT_Raster_Funcs* raster_class */
)
PUT_SVG_MODULE( ft_svg_render ), /* FT_Renderer_RenderFunc render_glyph */
PUT_SVG_MODULE( ft_svg_transform ), /* FT_Renderer_TransformFunc transform_glyph */
NULL, /* FT_Renderer_GetCBoxFunc get_glyph_cbox */
NULL, /* FT_Renderer_SetModeFunc set_mode */
NULL /* FT_Raster_Funcs* raster_class */
};
/* END */

View file

@ -25,7 +25,8 @@
FT_BEGIN_HEADER
FT_DECLARE_RENDERER( ft_svg_renderer_class )
FT_CALLBACK_TABLE
FT_Renderer_Class ft_svg_renderer_class;
FT_END_HEADER

View file

@ -660,9 +660,10 @@
#define TT_SIZE_SELECT 0
#endif
FT_DEFINE_DRIVER(
tt_driver_class,
FT_CALLBACK_TABLE_DEF
FT_Driver_Class tt_driver_class =
{
{
FT_MODULE_FONT_DRIVER |
FT_MODULE_DRIVER_SCALABLE |
TT_HINTER_FLAG,
@ -677,7 +678,8 @@
tt_driver_init, /* FT_Module_Constructor module_init */
tt_driver_done, /* FT_Module_Destructor module_done */
tt_get_interface, /* FT_Module_Requester get_interface */
tt_get_interface /* FT_Module_Requester get_interface */
},
sizeof ( TT_FaceRec ),
sizeof ( TT_SizeRec ),
@ -698,7 +700,7 @@
tt_size_request, /* FT_Size_RequestFunc request_size */
TT_SIZE_SELECT /* FT_Size_SelectFunc select_size */
)
};
/* END */

View file

@ -25,7 +25,8 @@
FT_BEGIN_HEADER
FT_DECLARE_DRIVER( tt_driver_class )
FT_CALLBACK_TABLE
FT_Driver_Class tt_driver_class;
FT_END_HEADER