feat: add minimum and maximum range metadata to option introspection - #106
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add minimum and maximum range metadata to libvips option introspection.
This is groundwork for a possible vipsgen v2 options API. The current generated options API uses zero values to decide whether an option should be passed to libvips. This means valid explicit values such as
0can be skipped and replaced by the libvips default.For example, an integer or floating-point option may need pointer semantics when:
0is within the parameter rangeThis metadata can help vipsgen make that decision mechanically instead of maintaining operation-specific allowlists.
The same idea can be applied to other types:
0exists and the default is non-zerotrue, so explicitfalsemust be preservedThis PR only adds the introspection metadata. It does not change generated option types or generation behavior yet.
The v2 design is expected to use pointers only where they are needed to distinguish omission from an explicitly supplied zero value. Other fields can keep normal Go value types, which are cleaner and more idiomatic.
Related fixes
effort=0for HEIF and WebPcompression=0for PNGintent=0for ICC and thumbnail operationsThese fixes exposed the broader issue in the original options API design.
Notes
Some libvips parameters have unbounded ranges, so range metadata may eventually need to represent whether each bound exists rather than serializing infinity as a numeric JSON value. Flags, 64-bit values, arrays, and operation-specific semantics may also need separate metadata treatment.
This PR is intended as the metadata-first step before changing the generated v2 API.