From 7b8a770aac3206c096c9a7a506df5a3660cdf274 Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Sun, 31 Aug 2025 07:28:32 -0400 Subject: [PATCH] [base] Make FT_Module_Class always const. All uses of FT_Module_Class are decorated with const now. Therefore, it make sense to declare it as such to begin with. * include/freetype/ftmodapi.h (FT_Module_Class): Decorate with const. * include/freetype/internal/ftobjs.h (FT_Module): Updated. * src/*: Update all other users. --- include/freetype/ftmodapi.h | 6 +-- include/freetype/internal/ftobjs.h | 60 +++++++++++++++--------------- src/base/ftinit.c | 14 +++---- src/base/ftobjs.c | 10 ++--- src/gxvalid/gxvmod.c | 2 +- src/gxvalid/gxvmod.h | 2 +- src/otvalid/otvmod.c | 2 +- src/otvalid/otvmod.h | 2 +- 8 files changed, 49 insertions(+), 49 deletions(-) diff --git a/include/freetype/ftmodapi.h b/include/freetype/ftmodapi.h index 0ee715898..75a803eb0 100644 --- a/include/freetype/ftmodapi.h +++ b/include/freetype/ftmodapi.h @@ -232,7 +232,7 @@ FT_BEGIN_HEADER * get_interface :: * The interface requesting function. */ - typedef struct FT_Module_Class_ + typedef const struct FT_Module_Class_ { FT_ULong module_flags; FT_Long module_size; @@ -273,8 +273,8 @@ FT_BEGIN_HEADER * if the module requires a version of FreeType that is too great. */ FT_EXPORT( FT_Error ) - FT_Add_Module( FT_Library library, - const FT_Module_Class* clazz ); + FT_Add_Module( FT_Library library, + FT_Module_Class* clazz ); /************************************************************************** diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h index 30d5247f3..71034a738 100644 --- a/include/freetype/internal/ftobjs.h +++ b/include/freetype/internal/ftobjs.h @@ -520,9 +520,9 @@ FT_BEGIN_HEADER */ typedef struct FT_ModuleRec_ { - const FT_Module_Class* clazz; - FT_Library library; - FT_Memory memory; + FT_Module_Class* clazz; + FT_Library library; + FT_Memory memory; } FT_ModuleRec; @@ -1190,7 +1190,7 @@ FT_BEGIN_HEADER */ #define FT_DECLARE_MODULE( class_ ) \ FT_CALLBACK_TABLE \ - const FT_Module_Class class_; + FT_Module_Class class_; #define FT_DEFINE_ROOT_MODULE( \ flags_, \ @@ -1217,32 +1217,32 @@ FT_BEGIN_HEADER get_interface_, \ }, -#define FT_DEFINE_MODULE( \ - class_, \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - FT_CALLBACK_TABLE_DEF \ - const FT_Module_Class class_ = \ - { \ - 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_, \ }; diff --git a/src/base/ftinit.c b/src/base/ftinit.c index 9a6c00e13..78295f1ca 100644 --- a/src/base/ftinit.c +++ b/src/base/ftinit.c @@ -56,18 +56,18 @@ #undef FT_USE_MODULE #ifdef __cplusplus -#define FT_USE_MODULE( type, x ) extern "C" const type x; +#define FT_USE_MODULE( type, x ) extern "C" type x; #else -#define FT_USE_MODULE( type, x ) extern const type x; +#define FT_USE_MODULE( type, x ) extern type x; #endif #include FT_CONFIG_MODULES_H #undef FT_USE_MODULE -#define FT_USE_MODULE( type, x ) (const FT_Module_Class*)&(x), +#define FT_USE_MODULE( type, x ) (FT_Module_Class*)&(x), static - const FT_Module_Class* const ft_default_modules[] = + FT_Module_Class* const ft_default_modules[] = { #include FT_CONFIG_MODULES_H 0 @@ -80,13 +80,13 @@ FT_Add_Default_Modules( FT_Library library ) { FT_Error error; - const FT_Module_Class* const* cur; + FT_Module_Class* const* cur; /* GCC 4.6 warns the type difference: - * FT_Module_Class** != const FT_Module_Class* const* + * FT_Module_Class** != FT_Module_Class* const* */ - cur = (const FT_Module_Class* const*)ft_default_modules; + cur = (FT_Module_Class* const*)ft_default_modules; /* test for valid `library' delayed to FT_Add_Module() */ while ( *cur ) diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 2f5204135..44f5d273c 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -5030,9 +5030,9 @@ static void Destroy_Module( FT_Module module ) { - const FT_Module_Class* clazz = module->clazz; - FT_Library library = module->library; - FT_Memory memory = module->memory; + FT_Module_Class* clazz = module->clazz; + FT_Library library = module->library; + FT_Memory memory = module->memory; if ( library && library->auto_hinter == module ) @@ -5058,8 +5058,8 @@ /* documentation is in ftmodapi.h */ FT_EXPORT_DEF( FT_Error ) - FT_Add_Module( FT_Library library, - const FT_Module_Class* clazz ) + FT_Add_Module( FT_Library library, + FT_Module_Class* clazz ) { FT_Error error; FT_Memory memory; diff --git a/src/gxvalid/gxvmod.c b/src/gxvalid/gxvmod.c index ce1e441eb..29bd82079 100644 --- a/src/gxvalid/gxvmod.c +++ b/src/gxvalid/gxvmod.c @@ -269,7 +269,7 @@ FT_CALLBACK_TABLE_DEF - const FT_Module_Class gxv_module_class = + FT_Module_Class gxv_module_class = { 0, sizeof ( FT_ModuleRec ), diff --git a/src/gxvalid/gxvmod.h b/src/gxvalid/gxvmod.h index 6def5c547..8f5d6281d 100644 --- a/src/gxvalid/gxvmod.h +++ b/src/gxvalid/gxvmod.h @@ -35,7 +35,7 @@ FT_BEGIN_HEADER - FT_EXPORT_VAR( const FT_Module_Class ) gxv_module_class; + FT_EXPORT_VAR( FT_Module_Class ) gxv_module_class; FT_END_HEADER diff --git a/src/otvalid/otvmod.c b/src/otvalid/otvmod.c index 74e50c787..c518246a5 100644 --- a/src/otvalid/otvmod.c +++ b/src/otvalid/otvmod.c @@ -262,7 +262,7 @@ FT_CALLBACK_TABLE_DEF - const FT_Module_Class otv_module_class = + FT_Module_Class otv_module_class = { 0, sizeof ( FT_ModuleRec ), diff --git a/src/otvalid/otvmod.h b/src/otvalid/otvmod.h index 245c78020..7d4afa149 100644 --- a/src/otvalid/otvmod.h +++ b/src/otvalid/otvmod.h @@ -27,7 +27,7 @@ FT_BEGIN_HEADER - FT_EXPORT_VAR( const FT_Module_Class ) otv_module_class; + FT_EXPORT_VAR( FT_Module_Class ) otv_module_class; FT_END_HEADER