From 0e6710be625966bb92c4c0552b20ab01d069e111 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Fri, 16 May 2025 12:43:55 +0200 Subject: [PATCH 1/4] enumtypes: skip generation of "last" members --- libvips/include/vips/almostdeprecated.h | 2 +- libvips/include/vips/arithmetic.h | 18 +++++++++--------- libvips/include/vips/basic.h | 2 +- libvips/include/vips/colour.h | 4 ++-- libvips/include/vips/conversion.h | 16 ++++++++-------- libvips/include/vips/convolution.h | 2 +- libvips/include/vips/create.h | 4 ++-- libvips/include/vips/draw.h | 2 +- libvips/include/vips/foreign.h | 24 ++++++++++++------------ libvips/include/vips/image.h | 8 ++++---- libvips/include/vips/morphology.h | 2 +- libvips/include/vips/region.h | 2 +- libvips/include/vips/resample.h | 4 ++-- 13 files changed, 45 insertions(+), 45 deletions(-) diff --git a/libvips/include/vips/almostdeprecated.h b/libvips/include/vips/almostdeprecated.h index fe25e7d4e2..7d9eee1802 100644 --- a/libvips/include/vips/almostdeprecated.h +++ b/libvips/include/vips/almostdeprecated.h @@ -370,7 +370,7 @@ typedef enum { VIPS_FOREIGN_JPEG_SUBSAMPLE_AUTO, VIPS_FOREIGN_JPEG_SUBSAMPLE_ON, VIPS_FOREIGN_JPEG_SUBSAMPLE_OFF, - VIPS_FOREIGN_JPEG_SUBSAMPLE_LAST + VIPS_FOREIGN_JPEG_SUBSAMPLE_LAST /*< skip >*/ } VipsForeignJpegSubsample; VIPS_DEPRECATED_FOR(vips_rawsave_target) diff --git a/libvips/include/vips/arithmetic.h b/libvips/include/vips/arithmetic.h index 7a039e9726..f7e45fa18f 100644 --- a/libvips/include/vips/arithmetic.h +++ b/libvips/include/vips/arithmetic.h @@ -79,7 +79,7 @@ typedef enum { VIPS_OPERATION_MATH_ASINH, VIPS_OPERATION_MATH_ACOSH, VIPS_OPERATION_MATH_ATANH, - VIPS_OPERATION_MATH_LAST + VIPS_OPERATION_MATH_LAST /*< skip >*/ } VipsOperationMath; /** @@ -94,7 +94,7 @@ typedef enum { VIPS_OPERATION_MATH2_POW, VIPS_OPERATION_MATH2_WOP, VIPS_OPERATION_MATH2_ATAN2, - VIPS_OPERATION_MATH2_LAST + VIPS_OPERATION_MATH2_LAST /*< skip >*/ } VipsOperationMath2; /** @@ -109,7 +109,7 @@ typedef enum { VIPS_OPERATION_ROUND_RINT, VIPS_OPERATION_ROUND_CEIL, VIPS_OPERATION_ROUND_FLOOR, - VIPS_OPERATION_ROUND_LAST + VIPS_OPERATION_ROUND_LAST /*< skip >*/ } VipsOperationRound; /** @@ -130,7 +130,7 @@ typedef enum { VIPS_OPERATION_RELATIONAL_LESSEQ, VIPS_OPERATION_RELATIONAL_MORE, VIPS_OPERATION_RELATIONAL_MOREEQ, - VIPS_OPERATION_RELATIONAL_LAST + VIPS_OPERATION_RELATIONAL_LAST /*< skip >*/ } VipsOperationRelational; /** @@ -149,7 +149,7 @@ typedef enum { VIPS_OPERATION_BOOLEAN_EOR, VIPS_OPERATION_BOOLEAN_LSHIFT, VIPS_OPERATION_BOOLEAN_RSHIFT, - VIPS_OPERATION_BOOLEAN_LAST + VIPS_OPERATION_BOOLEAN_LAST /*< skip >*/ } VipsOperationBoolean; /** @@ -164,7 +164,7 @@ typedef enum { VIPS_OPERATION_COMPLEX_POLAR, VIPS_OPERATION_COMPLEX_RECT, VIPS_OPERATION_COMPLEX_CONJ, - VIPS_OPERATION_COMPLEX_LAST + VIPS_OPERATION_COMPLEX_LAST /*< skip >*/ } VipsOperationComplex; /** @@ -174,8 +174,8 @@ typedef enum { * See also: [method@Image.complex2]. */ typedef enum { - VIPS_OPERATION_COMPLEX2_CROSS_PHASE, - VIPS_OPERATION_COMPLEX2_LAST + VIPS_OPERATION_COMPLEX2_CROSS_PHASE, /*< nick=cross-phase >*/ + VIPS_OPERATION_COMPLEX2_LAST /*< skip >*/ } VipsOperationComplex2; /** @@ -188,7 +188,7 @@ typedef enum { typedef enum { VIPS_OPERATION_COMPLEXGET_REAL, VIPS_OPERATION_COMPLEXGET_IMAG, - VIPS_OPERATION_COMPLEXGET_LAST + VIPS_OPERATION_COMPLEXGET_LAST /*< skip >*/ } VipsOperationComplexget; VIPS_API diff --git a/libvips/include/vips/basic.h b/libvips/include/vips/basic.h index e74deb48df..2f94f03688 100644 --- a/libvips/include/vips/basic.h +++ b/libvips/include/vips/basic.h @@ -97,7 +97,7 @@ typedef enum { VIPS_PRECISION_INTEGER, VIPS_PRECISION_FLOAT, VIPS_PRECISION_APPROXIMATE, - VIPS_PRECISION_LAST + VIPS_PRECISION_LAST /*< skip >*/ } VipsPrecision; #ifndef __GI_SCANNER__ diff --git a/libvips/include/vips/colour.h b/libvips/include/vips/colour.h index 5848249b83..b943e0db14 100644 --- a/libvips/include/vips/colour.h +++ b/libvips/include/vips/colour.h @@ -105,13 +105,13 @@ typedef enum { * four standard ones. */ VIPS_INTENT_AUTO = 32, - VIPS_INTENT_LAST + VIPS_INTENT_LAST /*< skip >*/ } VipsIntent; typedef enum { VIPS_PCS_LAB, VIPS_PCS_XYZ, - VIPS_PCS_LAST + VIPS_PCS_LAST /*< skip >*/ } VipsPCS; VIPS_API diff --git a/libvips/include/vips/conversion.h b/libvips/include/vips/conversion.h index 1eb5ad0690..afe4f1534e 100644 --- a/libvips/include/vips/conversion.h +++ b/libvips/include/vips/conversion.h @@ -45,7 +45,7 @@ typedef enum { VIPS_EXTEND_MIRROR, VIPS_EXTEND_WHITE, VIPS_EXTEND_BACKGROUND, - VIPS_EXTEND_LAST + VIPS_EXTEND_LAST /*< skip >*/ } VipsExtend; typedef enum { @@ -58,20 +58,20 @@ typedef enum { VIPS_COMPASS_DIRECTION_SOUTH_EAST, VIPS_COMPASS_DIRECTION_SOUTH_WEST, VIPS_COMPASS_DIRECTION_NORTH_WEST, - VIPS_COMPASS_DIRECTION_LAST + VIPS_COMPASS_DIRECTION_LAST /*< skip >*/ } VipsCompassDirection; typedef enum { VIPS_DIRECTION_HORIZONTAL, VIPS_DIRECTION_VERTICAL, - VIPS_DIRECTION_LAST + VIPS_DIRECTION_LAST /*< skip >*/ } VipsDirection; typedef enum { VIPS_ALIGN_LOW, VIPS_ALIGN_CENTRE, VIPS_ALIGN_HIGH, - VIPS_ALIGN_LAST + VIPS_ALIGN_LAST /*< skip >*/ } VipsAlign; typedef enum { @@ -79,7 +79,7 @@ typedef enum { VIPS_ANGLE_D90, VIPS_ANGLE_D180, VIPS_ANGLE_D270, - VIPS_ANGLE_LAST + VIPS_ANGLE_LAST /*< skip >*/ } VipsAngle; typedef enum { @@ -91,7 +91,7 @@ typedef enum { VIPS_ANGLE45_D225, VIPS_ANGLE45_D270, VIPS_ANGLE45_D315, - VIPS_ANGLE45_LAST + VIPS_ANGLE45_LAST /*< skip >*/ } VipsAngle45; typedef enum { @@ -102,7 +102,7 @@ typedef enum { VIPS_INTERESTING_LOW, VIPS_INTERESTING_HIGH, VIPS_INTERESTING_ALL, - VIPS_INTERESTING_LAST + VIPS_INTERESTING_LAST /*< skip >*/ } VipsInteresting; typedef enum { @@ -131,7 +131,7 @@ typedef enum { VIPS_BLEND_MODE_SOFT_LIGHT, VIPS_BLEND_MODE_DIFFERENCE, VIPS_BLEND_MODE_EXCLUSION, - VIPS_BLEND_MODE_LAST + VIPS_BLEND_MODE_LAST /*< skip >*/ } VipsBlendMode; VIPS_API diff --git a/libvips/include/vips/convolution.h b/libvips/include/vips/convolution.h index 7141446bf7..6da52f547b 100644 --- a/libvips/include/vips/convolution.h +++ b/libvips/include/vips/convolution.h @@ -42,7 +42,7 @@ typedef enum { VIPS_COMBINE_MAX, VIPS_COMBINE_SUM, VIPS_COMBINE_MIN, - VIPS_COMBINE_LAST + VIPS_COMBINE_LAST /*< skip >*/ } VipsCombine; VIPS_API diff --git a/libvips/include/vips/create.h b/libvips/include/vips/create.h index f7dd5242d5..27db923849 100644 --- a/libvips/include/vips/create.h +++ b/libvips/include/vips/create.h @@ -43,7 +43,7 @@ typedef enum { VIPS_TEXT_WRAP_CHAR, VIPS_TEXT_WRAP_WORD_CHAR, VIPS_TEXT_WRAP_NONE, - VIPS_TEXT_WRAP_LAST + VIPS_TEXT_WRAP_LAST /*< skip >*/ } VipsTextWrap; typedef enum { @@ -51,7 +51,7 @@ typedef enum { VIPS_SDF_SHAPE_BOX, VIPS_SDF_SHAPE_ROUNDED_BOX, VIPS_SDF_SHAPE_LINE, - VIPS_SDF_SHAPE_LAST + VIPS_SDF_SHAPE_LAST /*< skip >*/ } VipsSdfShape; VIPS_API diff --git a/libvips/include/vips/draw.h b/libvips/include/vips/draw.h index 486c90f282..1101b1258d 100644 --- a/libvips/include/vips/draw.h +++ b/libvips/include/vips/draw.h @@ -45,7 +45,7 @@ extern "C" { typedef enum { VIPS_COMBINE_MODE_SET, VIPS_COMBINE_MODE_ADD, - VIPS_COMBINE_MODE_LAST + VIPS_COMBINE_MODE_LAST /*< skip >*/ } VipsCombineMode; VIPS_API diff --git a/libvips/include/vips/foreign.h b/libvips/include/vips/foreign.h index f546f3af9a..6eefdbc09d 100644 --- a/libvips/include/vips/foreign.h +++ b/libvips/include/vips/foreign.h @@ -123,7 +123,7 @@ typedef enum { VIPS_FAIL_ON_TRUNCATED, VIPS_FAIL_ON_ERROR, VIPS_FAIL_ON_WARNING, - VIPS_FAIL_ON_LAST + VIPS_FAIL_ON_LAST /*< skip >*/ } VipsFailOn; #define VIPS_TYPE_FOREIGN_LOAD (vips_foreign_load_get_type()) @@ -468,7 +468,7 @@ typedef enum { VIPS_FOREIGN_SUBSAMPLE_AUTO, VIPS_FOREIGN_SUBSAMPLE_ON, VIPS_FOREIGN_SUBSAMPLE_OFF, - VIPS_FOREIGN_SUBSAMPLE_LAST + VIPS_FOREIGN_SUBSAMPLE_LAST /*< skip >*/ } VipsForeignSubsample; VIPS_API @@ -512,7 +512,7 @@ typedef enum { VIPS_FOREIGN_WEBP_PRESET_DRAWING, VIPS_FOREIGN_WEBP_PRESET_ICON, VIPS_FOREIGN_WEBP_PRESET_TEXT, - VIPS_FOREIGN_WEBP_PRESET_LAST + VIPS_FOREIGN_WEBP_PRESET_LAST /*< skip >*/ } VipsForeignWebpPreset; VIPS_API @@ -570,7 +570,7 @@ typedef enum { VIPS_FOREIGN_TIFF_COMPRESSION_WEBP, VIPS_FOREIGN_TIFF_COMPRESSION_ZSTD, VIPS_FOREIGN_TIFF_COMPRESSION_JP2K, - VIPS_FOREIGN_TIFF_COMPRESSION_LAST + VIPS_FOREIGN_TIFF_COMPRESSION_LAST /*< skip >*/ } VipsForeignTiffCompression; /** @@ -586,7 +586,7 @@ typedef enum { VIPS_FOREIGN_TIFF_PREDICTOR_NONE = 1, VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL = 2, VIPS_FOREIGN_TIFF_PREDICTOR_FLOAT = 3, - VIPS_FOREIGN_TIFF_PREDICTOR_LAST + VIPS_FOREIGN_TIFF_PREDICTOR_LAST /*< skip >*/ } VipsForeignTiffPredictor; /** @@ -599,7 +599,7 @@ typedef enum { typedef enum { VIPS_FOREIGN_TIFF_RESUNIT_CM, VIPS_FOREIGN_TIFF_RESUNIT_INCH, - VIPS_FOREIGN_TIFF_RESUNIT_LAST + VIPS_FOREIGN_TIFF_RESUNIT_LAST /*< skip >*/ } VipsForeignTiffResunit; VIPS_API @@ -763,7 +763,7 @@ typedef enum { VIPS_FOREIGN_PPM_FORMAT_PPM, VIPS_FOREIGN_PPM_FORMAT_PFM, VIPS_FOREIGN_PPM_FORMAT_PNM, - VIPS_FOREIGN_PPM_FORMAT_LAST + VIPS_FOREIGN_PPM_FORMAT_LAST /*< skip >*/ } VipsForeignPpmFormat; VIPS_API @@ -928,7 +928,7 @@ typedef enum { VIPS_FOREIGN_DZ_LAYOUT_GOOGLE, VIPS_FOREIGN_DZ_LAYOUT_IIIF, VIPS_FOREIGN_DZ_LAYOUT_IIIF3, - VIPS_FOREIGN_DZ_LAYOUT_LAST + VIPS_FOREIGN_DZ_LAYOUT_LAST /*< skip >*/ } VipsForeignDzLayout; /** @@ -943,7 +943,7 @@ typedef enum { VIPS_FOREIGN_DZ_DEPTH_ONEPIXEL, VIPS_FOREIGN_DZ_DEPTH_ONETILE, VIPS_FOREIGN_DZ_DEPTH_ONE, - VIPS_FOREIGN_DZ_DEPTH_LAST + VIPS_FOREIGN_DZ_DEPTH_LAST /*< skip >*/ } VipsForeignDzDepth; /** @@ -958,7 +958,7 @@ typedef enum { VIPS_FOREIGN_DZ_CONTAINER_FS, VIPS_FOREIGN_DZ_CONTAINER_ZIP, VIPS_FOREIGN_DZ_CONTAINER_SZI, - VIPS_FOREIGN_DZ_CONTAINER_LAST + VIPS_FOREIGN_DZ_CONTAINER_LAST /*< skip >*/ } VipsForeignDzContainer; VIPS_API @@ -987,7 +987,7 @@ typedef enum { VIPS_FOREIGN_HEIF_COMPRESSION_AVC = 2, VIPS_FOREIGN_HEIF_COMPRESSION_JPEG = 3, VIPS_FOREIGN_HEIF_COMPRESSION_AV1 = 4, - VIPS_FOREIGN_HEIF_COMPRESSION_LAST + VIPS_FOREIGN_HEIF_COMPRESSION_LAST /*< skip >*/ } VipsForeignHeifCompression; /** @@ -1009,7 +1009,7 @@ typedef enum { VIPS_FOREIGN_HEIF_ENCODER_RAV1E, VIPS_FOREIGN_HEIF_ENCODER_SVT, VIPS_FOREIGN_HEIF_ENCODER_X265, - VIPS_FOREIGN_HEIF_ENCODER_LAST + VIPS_FOREIGN_HEIF_ENCODER_LAST /*< skip >*/ } VipsForeignHeifEncoder; #ifdef __cplusplus diff --git a/libvips/include/vips/image.h b/libvips/include/vips/image.h index f9b91241c1..59c3d53a2f 100644 --- a/libvips/include/vips/image.h +++ b/libvips/include/vips/image.h @@ -112,7 +112,7 @@ typedef enum { VIPS_INTERPRETATION_MATRIX = 27, VIPS_INTERPRETATION_scRGB = 28, VIPS_INTERPRETATION_HSV = 29, - VIPS_INTERPRETATION_LAST = 30 + VIPS_INTERPRETATION_LAST = 30 /*< skip >*/ } VipsInterpretation; typedef enum { @@ -127,7 +127,7 @@ typedef enum { VIPS_FORMAT_COMPLEX = 7, VIPS_FORMAT_DOUBLE = 8, VIPS_FORMAT_DPCOMPLEX = 9, - VIPS_FORMAT_LAST = 10 + VIPS_FORMAT_LAST = 10 /*< skip >*/ } VipsBandFormat; typedef enum { @@ -135,14 +135,14 @@ typedef enum { VIPS_CODING_NONE = 0, VIPS_CODING_LABQ = 2, VIPS_CODING_RAD = 6, - VIPS_CODING_LAST = 7 + VIPS_CODING_LAST = 7 /*< skip >*/ } VipsCoding; typedef enum { VIPS_ACCESS_RANDOM, VIPS_ACCESS_SEQUENTIAL, VIPS_ACCESS_SEQUENTIAL_UNBUFFERED, - VIPS_ACCESS_LAST + VIPS_ACCESS_LAST /*< skip >*/ } VipsAccess; typedef void *(*VipsStartFn)(VipsImage *out, void *a, void *b); diff --git a/libvips/include/vips/morphology.h b/libvips/include/vips/morphology.h index 918b0ce3d4..7731120d05 100644 --- a/libvips/include/vips/morphology.h +++ b/libvips/include/vips/morphology.h @@ -41,7 +41,7 @@ extern "C" { typedef enum { VIPS_OPERATION_MORPHOLOGY_ERODE, VIPS_OPERATION_MORPHOLOGY_DILATE, - VIPS_OPERATION_MORPHOLOGY_LAST + VIPS_OPERATION_MORPHOLOGY_LAST /*< skip >*/ } VipsOperationMorphology; VIPS_API diff --git a/libvips/include/vips/region.h b/libvips/include/vips/region.h index d7f06c5746..b3b61e4291 100644 --- a/libvips/include/vips/region.h +++ b/libvips/include/vips/region.h @@ -80,7 +80,7 @@ typedef enum { VIPS_REGION_SHRINK_MAX, VIPS_REGION_SHRINK_MIN, VIPS_REGION_SHRINK_NEAREST, - VIPS_REGION_SHRINK_LAST + VIPS_REGION_SHRINK_LAST /*< skip >*/ } VipsRegionShrink; /* Sub-area of image. diff --git a/libvips/include/vips/resample.h b/libvips/include/vips/resample.h index d71a8de509..6f688488dd 100644 --- a/libvips/include/vips/resample.h +++ b/libvips/include/vips/resample.h @@ -47,7 +47,7 @@ typedef enum { VIPS_KERNEL_LANCZOS3, VIPS_KERNEL_MKS2013, VIPS_KERNEL_MKS2021, - VIPS_KERNEL_LAST + VIPS_KERNEL_LAST /*< skip >*/ } VipsKernel; typedef enum { @@ -55,7 +55,7 @@ typedef enum { VIPS_SIZE_UP, VIPS_SIZE_DOWN, VIPS_SIZE_FORCE, - VIPS_SIZE_LAST + VIPS_SIZE_LAST /*< skip >*/ } VipsSize; VIPS_API From 43e9cc9d22056fc202fffa2783aa7799acec8b7d Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Fri, 16 May 2025 13:01:08 +0200 Subject: [PATCH 2/4] Avoid subtracting `-1` from the number of possible enum values --- libvips/iofuncs/operation.c | 4 +--- libvips/iofuncs/util.c | 4 +--- tools/vips.c | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/libvips/iofuncs/operation.c b/libvips/iofuncs/operation.c index 2d7383feb2..5b740f4870 100644 --- a/libvips/iofuncs/operation.c +++ b/libvips/iofuncs/operation.c @@ -342,9 +342,7 @@ vips_operation_pspec_usage(VipsBuf *buf, GParamSpec *pspec) vips_buf_appendf(buf, "%s", _("allowed enums")); vips_buf_appendf(buf, ": "); - /* -1 since we always have a "last" member. - */ - for (i = 0; i < genum->n_values - 1; i++) { + for (i = 0; i < genum->n_values; i++) { if (i > 0) vips_buf_appends(buf, ", "); vips_buf_appends(buf, genum->values[i].value_nick); diff --git a/libvips/iofuncs/util.c b/libvips/iofuncs/util.c index 345e74ec65..ae4089a034 100644 --- a/libvips/iofuncs/util.c +++ b/libvips/iofuncs/util.c @@ -1774,9 +1774,7 @@ vips_enum_from_nick(const char *domain, GType type, const char *nick) if ((enum_value = g_enum_get_value_by_nick(genum, nick))) return enum_value->value; - /* -1 since we always have a "last" member. - */ - for (i = 0; i < genum->n_values - 1; i++) { + for (i = 0; i < genum->n_values; i++) { if (i > 0) vips_buf_appends(&buf, ", "); vips_buf_appends(&buf, genum->values[i].value_nick); diff --git a/tools/vips.c b/tools/vips.c index a8fa16c43d..4ec35c148e 100644 --- a/tools/vips.c +++ b/tools/vips.c @@ -230,9 +230,7 @@ list_operation_arg(VipsObjectClass *object_class, printf("word:"); - /* -1 since we always have a "last" member. - */ - for (i = 0; i < genum->n_values - 1; i++) { + for (i = 0; i < genum->n_values; i++) { if (i > 0) printf("|"); printf("%s", genum->values[i].value_nick); From b6fb66ee7e03897425270d07f82f6655996dba9e Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Fri, 16 May 2025 13:17:27 +0200 Subject: [PATCH 3/4] Remove redundant logic --- libvips/iofuncs/vips.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libvips/iofuncs/vips.c b/libvips/iofuncs/vips.c index 078e669e4a..565c486f62 100644 --- a/libvips/iofuncs/vips.c +++ b/libvips/iofuncs/vips.c @@ -359,13 +359,11 @@ vips__read_header_bytes(VipsImage *im, unsigned char *from) */ value = g_enum_get_value(g_type_class_ref(VIPS_TYPE_INTERPRETATION), im->Type); - if (!value || - strcmp(value->value_nick, "last") == 0) + if (!value) im->Type = VIPS_INTERPRETATION_ERROR; value = g_enum_get_value(g_type_class_ref(VIPS_TYPE_CODING), im->Coding); - if (!value || - strcmp(value->value_nick, "last") == 0) + if (!value) im->Coding = VIPS_CODING_ERROR; /* Offset, Res, etc. don't affect vips file layout, just From b54cd4feca47a501e6b784cfe9aa6bd492ffa65e Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 9 Jun 2025 14:45:06 +0200 Subject: [PATCH 4/4] Add compat for "last" members in `vips_enum_from_nick()` --- libvips/iofuncs/util.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libvips/iofuncs/util.c b/libvips/iofuncs/util.c index ae4089a034..b923fc0e12 100644 --- a/libvips/iofuncs/util.c +++ b/libvips/iofuncs/util.c @@ -1774,6 +1774,14 @@ vips_enum_from_nick(const char *domain, GType type, const char *nick) if ((enum_value = g_enum_get_value_by_nick(genum, nick))) return enum_value->value; + /* Compat for "last" members. Assumes all enums define a `_LAST` value; + * behaviour is undefined otherwise. Note that there could be potential + * gaps in enum values (e.g. VipsInterpretation), so we cannot return + * `genum->n_values` directly. + */ + if (nick && g_str_equal(nick, "last")) + return genum->values[genum->n_values - 1].value + 1; + for (i = 0; i < genum->n_values; i++) { if (i > 0) vips_buf_appends(&buf, ", ");