pdb: properly handle enum types with acronyms and sort case-insensitively.

This will be used in particular for adding GimpTRCType to libgimp.
Otherwise it generates some broken gimp_TRCtype_get_type() function
name.

For this use case, we need to look-ahead a bit in the regular
expression.
This commit is contained in:
Jehan 2025-07-03 01:59:03 +02:00
parent 7189010f1e
commit 50e9f360f3
2 changed files with 9 additions and 9 deletions

View file

@ -45,11 +45,11 @@ static const GimpGetTypeFunc get_type_funcs[] =
gimp_message_handler_type_get_type,
gimp_offset_type_get_type,
gimp_orientation_type_get_type,
gimp_paint_application_mode_get_type,
gimp_path_stroke_type_get_type,
gimp_pdb_error_handler_get_type,
gimp_pdb_proc_type_get_type,
gimp_pdb_status_type_get_type,
gimp_paint_application_mode_get_type,
gimp_path_stroke_type_get_type,
gimp_precision_get_type,
gimp_progress_command_get_type,
gimp_repeat_mode_get_type,
@ -111,11 +111,11 @@ static const gchar * const type_names[] =
"GimpMessageHandlerType",
"GimpOffsetType",
"GimpOrientationType",
"GimpPaintApplicationMode",
"GimpPathStrokeType",
"GimpPDBErrorHandler",
"GimpPDBProcType",
"GimpPDBStatusType",
"GimpPaintApplicationMode",
"GimpPathStrokeType",
"GimpPrecision",
"GimpProgressCommand",
"GimpRepeatMode",

View file

@ -72,8 +72,8 @@ foreach (sort keys %enums) {
! $enums{$_}->{external}) {
my $gtype = $func = $_;
for ($gtype) { s/Gimp//; s/([A-Z][^A-Z]+)/\U$1\E_/g; s/_$// }
for ($func) { s/Gimp//; s/([A-Z][^A-Z]+)/\L$1\E_/g; s/_$// }
for ($gtype) { s/Gimp//; s/([A-Z][^A-Z]+|[A-Z]+(?=[A-Z]))/\U$1\E_/g; s/_$// }
for ($func) { s/Gimp//; s/([A-Z][^A-Z]+|[A-Z]+(?=[A-Z]))/\L$1\E_/g; s/_$// }
print ENUMFILE "\n#define GIMP_TYPE_$gtype (gimp_$func\_get_type ())\n\n";
print ENUMFILE "GType gimp_$func\_get_type (void) G_GNUC_CONST;\n\n";
@ -136,14 +136,14 @@ static const GimpGetTypeFunc get_type_funcs[] =
CODE
my $first = 1;
foreach (sort keys %enums) {
foreach (sort {uc($a) cmp uc($b)} keys %enums) {
if (! ($_ =~ /GimpUnit/)) {
my $enum = $enums{$_};
my $func = $_;
my $gegl_enum = ($func =~ /Gegl/);
for ($func) { s/Gimp//; s/Gegl//; s/PDB/Pdb/;
s/([A-Z][^A-Z]+)/\L$1\E_/g; s/_$// }
s/([A-Z][^A-Z]+|[A-Z]+(?=[A-Z]))/\L$1\E_/g; s/_$// }
print ENUMFILE ",\n" unless $first;
@ -166,7 +166,7 @@ static const gchar * const type_names[] =
CODE
$first = 1;
foreach (sort keys %enums) {
foreach (sort {uc($a) cmp uc($b)} keys %enums) {
if (! ($_ =~ /GimpUnit/)) {
my $enum = $enums{$_};
my $gtype = $_;