From 4e386c83ad1d5a233e1d9ce744b059c66957b561 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Fri, 16 May 2025 15:11:29 +0200 Subject: [PATCH 1/3] Regenerate enums --- src/DemandStyle.php | 1 + src/ForeignSaveable.php | 58 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/ForeignSaveable.php diff --git a/src/DemandStyle.php b/src/DemandStyle.php index 36970a2..395a404 100644 --- a/src/DemandStyle.php +++ b/src/DemandStyle.php @@ -53,4 +53,5 @@ abstract class DemandStyle const SMALLTILE = 'smalltile'; const FATSTRIP = 'fatstrip'; const THINSTRIP = 'thinstrip'; + const ANY = 'any'; } diff --git a/src/ForeignSaveable.php b/src/ForeignSaveable.php new file mode 100644 index 0000000..6300960 --- /dev/null +++ b/src/ForeignSaveable.php @@ -0,0 +1,58 @@ + + * @copyright 2016 John Cupitt + * @license https://opensource.org/licenses/MIT MIT + * @link https://github.com/jcupitt/php-vips + */ + +namespace Jcupitt\Vips; + +/** + * The ForeignSaveable flags. + * @category Images + * @package Jcupitt\Vips + * @author John Cupitt + * @copyright 2016 John Cupitt + * @license https://opensource.org/licenses/MIT MIT + * @link https://github.com/jcupitt/php-vips + */ +abstract class ForeignSaveable +{ + const ANY = 0; + const MONO = 1; + const RGB = 2; + const CMYK = 4; + const ALPHA = 8; + const ALL = 15; +} From f36f216724b83c85e7247773114ab24e07d68cc0 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Fri, 16 May 2025 15:11:03 +0200 Subject: [PATCH 2/3] Remove deprecated/redundant enums --- src/ForeignJpegSubsample.php | 55 ------------------------------- src/GsfOutputCsvQuotingMode.php | 54 ------------------------------ src/Saveable.php | 58 --------------------------------- 3 files changed, 167 deletions(-) delete mode 100644 src/ForeignJpegSubsample.php delete mode 100644 src/GsfOutputCsvQuotingMode.php delete mode 100644 src/Saveable.php diff --git a/src/ForeignJpegSubsample.php b/src/ForeignJpegSubsample.php deleted file mode 100644 index f87bfa7..0000000 --- a/src/ForeignJpegSubsample.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright 2016 John Cupitt - * @license https://opensource.org/licenses/MIT MIT - * @link https://github.com/jcupitt/php-vips - */ - -namespace Jcupitt\Vips; - -/** - * The ForeignJpegSubsample enum. - * @category Images - * @package Jcupitt\Vips - * @author John Cupitt - * @copyright 2016 John Cupitt - * @license https://opensource.org/licenses/MIT MIT - * @link https://github.com/jcupitt/php-vips - */ -abstract class ForeignJpegSubsample -{ - const AUTO = 'auto'; - const ON = 'on'; - const OFF = 'off'; -} diff --git a/src/GsfOutputCsvQuotingMode.php b/src/GsfOutputCsvQuotingMode.php deleted file mode 100644 index a8a08f0..0000000 --- a/src/GsfOutputCsvQuotingMode.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright 2016 John Cupitt - * @license https://opensource.org/licenses/MIT MIT - * @link https://github.com/jcupitt/php-vips - */ - -namespace Jcupitt\Vips; - -/** - * The GsfOutputCsvQuotingMode enum. - * @category Images - * @package Jcupitt\Vips - * @author John Cupitt - * @copyright 2016 John Cupitt - * @license https://opensource.org/licenses/MIT MIT - * @link https://github.com/jcupitt/php-vips - */ -abstract class GsfOutputCsvQuotingMode -{ - const NEVER = 'never'; - const AUTO = 'auto'; -} diff --git a/src/Saveable.php b/src/Saveable.php deleted file mode 100644 index 8558f9e..0000000 --- a/src/Saveable.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright 2016 John Cupitt - * @license https://opensource.org/licenses/MIT MIT - * @link https://github.com/jcupitt/php-vips - */ - -namespace Jcupitt\Vips; - -/** - * The Saveable enum. - * @category Images - * @package Jcupitt\Vips - * @author John Cupitt - * @copyright 2016 John Cupitt - * @license https://opensource.org/licenses/MIT MIT - * @link https://github.com/jcupitt/php-vips - */ -abstract class Saveable -{ - const MONO = 'mono'; - const RGB = 'rgb'; - const RGBA = 'rgba'; - const RGBA_ONLY = 'rgba-only'; - const RGB_CMYK = 'rgb-cmyk'; - const ANY = 'any'; -} From ac890c35db15b574da1a6ab32afcd1faee1188c2 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Sat, 17 May 2025 13:59:49 +0200 Subject: [PATCH 3/3] Avoid generating redundant enums --- examples/generate_phpdoc.py | 11 +------ src/FFI.php | 6 ---- src/ForeignSaveable.php | 58 ------------------------------------- 3 files changed, 1 insertion(+), 74 deletions(-) delete mode 100644 src/ForeignSaveable.php diff --git a/examples/generate_phpdoc.py b/examples/generate_phpdoc.py index 5b89216..2d52e35 100755 --- a/examples/generate_phpdoc.py +++ b/examples/generate_phpdoc.py @@ -3,7 +3,7 @@ # needs pyvips 2.2.3 or later from pyvips import Image, Introspect, GValue, Error, \ - ffi, enum_dict, flags_dict, vips_lib, gobject_lib, \ + ffi, enum_dict, flags_dict, gobject_lib, \ type_map, type_name, type_from_name, nickname_find # This file generates the phpdoc comments for the magic methods and properties. @@ -275,11 +275,6 @@ def add_nickname(gtype, a, b): def generate_enums(): - # otherwise we're missing some enums - vips_lib.vips_token_get_type() - vips_lib.vips_saveable_get_type() - vips_lib.vips_image_type_get_type() - all_enums = [] def add_enum(gtype, a, b): @@ -292,10 +287,6 @@ def add_enum(gtype, a, b): type_map(type_from_name('GEnum'), add_enum) - # Filter internal enums - blacklist = ['VipsImageType', 'VipsToken'] - all_enums = [name for name in all_enums if name not in blacklist] - for name in all_enums: gtype = type_from_name(name) php_name = remove_prefix(name) diff --git a/src/FFI.php b/src/FFI.php index f259f7b..bfbf94d 100644 --- a/src/FFI.php +++ b/src/FFI.php @@ -551,9 +551,6 @@ private static function init(): void GType vips_interpretation_get_type (void); GType vips_operation_flags_get_type (void); GType vips_band_format_get_type (void); -GType vips_token_get_type (void); -GType vips_saveable_get_type (void); -GType vips_image_type_get_type (void); void vips_image_set_progress (VipsImage* image, bool progress); void vips_image_set_kill (VipsImage* image, bool kill); @@ -822,9 +819,6 @@ private static function init(): void self::$vips->vips_interpretation_get_type(); self::$vips->vips_operation_flags_get_type(); self::$vips->vips_band_format_get_type(); - self::$vips->vips_token_get_type(); - self::$vips->vips_saveable_get_type(); - self::$vips->vips_image_type_get_type(); // look these up in advance self::$ctypes = [ diff --git a/src/ForeignSaveable.php b/src/ForeignSaveable.php deleted file mode 100644 index 6300960..0000000 --- a/src/ForeignSaveable.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright 2016 John Cupitt - * @license https://opensource.org/licenses/MIT MIT - * @link https://github.com/jcupitt/php-vips - */ - -namespace Jcupitt\Vips; - -/** - * The ForeignSaveable flags. - * @category Images - * @package Jcupitt\Vips - * @author John Cupitt - * @copyright 2016 John Cupitt - * @license https://opensource.org/licenses/MIT MIT - * @link https://github.com/jcupitt/php-vips - */ -abstract class ForeignSaveable -{ - const ANY = 0; - const MONO = 1; - const RGB = 2; - const CMYK = 4; - const ALPHA = 8; - const ALL = 15; -}