Simplify/modernize `vips_crop_get_type()` (#2940)

This commit is contained in:
Kleis Auke Wolthuizen 2022-07-23 11:14:03 +02:00 committed by GitHub
parent a846de017d
commit e93f56c8bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 17 deletions

View File

@ -174,9 +174,9 @@ vips_extract_area_build( VipsObject *object )
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
static void static void
vips_crop_class_init_adapter( VipsExtractAreaClass *class, void *dummy ) vips_crop_class_intern_init_adapter( gpointer class, void *dummy )
{ {
vips_extract_area_class_init( class ); vips_extract_area_class_intern_init( class );
} }
#endif #endif
@ -284,34 +284,29 @@ vips_extract_area( VipsImage *in, VipsImage **out,
GType GType
vips_crop_get_type( void ) vips_crop_get_type( void )
{ {
static GType type = 0; static gsize gtype_id = 0;
if( !type ) { if( g_once_init_enter( &gtype_id ) ) {
static const GTypeInfo info = { GType new_type = g_type_register_static_simple( VIPS_TYPE_CONVERSION,
g_intern_static_string( "crop" ),
sizeof( VipsExtractAreaClass ), sizeof( VipsExtractAreaClass ),
NULL, /* base_init */
NULL, /* base_finalize */
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
(GClassInitFunc) vips_crop_class_init_adapter, (GClassInitFunc) vips_crop_class_intern_init_adapter,
#else #else
(GClassInitFunc) vips_extract_area_class_init, (GClassInitFunc)(void (*)(void)) vips_extract_area_class_intern_init,
#endif #endif
NULL, /* class_finalize */
NULL, /* class_data */
sizeof( VipsExtractArea ), sizeof( VipsExtractArea ),
32, /* n_preallocs */
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
(GInstanceInitFunc) vips_crop_init_adapter, (GInstanceInitFunc) vips_crop_init_adapter,
#else #else
(GInstanceInitFunc) vips_extract_area_init, (GInstanceInitFunc)(void (*)(void)) vips_extract_area_init,
#endif #endif
}; (GTypeFlags) 0 );
type = g_type_register_static( VIPS_TYPE_CONVERSION, g_once_init_leave( &gtype_id, new_type );
"crop", &info, 0 );
} }
return( type ); return( (GType) gtype_id );
} }
/** /**