Skip to content

3 new Convert API methods#8295

Merged
enebo merged 1 commit intojruby:9.5-devfrom
enebo:api_convert_int
Jun 20, 2024
Merged

3 new Convert API methods#8295
enebo merged 1 commit intojruby:9.5-devfrom
enebo:api_convert_int

Conversation

@enebo
Copy link
Member

@enebo enebo commented Jun 20, 2024

checkToInteger - Same as TypeConverter but it replaces it integerAsInt - Works from knowing we have RubyInteger and bounds checks to
make sure we really have an int
integerAsLong - Works from knowing we have RubyInteger and bounds checks to
make sure we really have a long

Fallout from this is realizing we had two checkToInteger but whatever used the more generic form which allows to pass in converter is no longer used for anything but #to_int. This PR deprecated both versions.

In refactoring to use these I noticed in two places we were not even checking to see if the value was safely an int/long. The integerAs* provides this and is more direct/narrow in what it provides than num2int or num2long.

checkToInteger - Same as TypeConverter but it replaces it
integerAsInt - Works from knowing we have RubyInteger and bounds checks to
   make sure we really have an int
integerAsLong - Works from knowing we have RubyInteger and bounds checks to
   make sure we really have a long

Fallout from this is realizing we had two checkToInteger but whatever used
the more generic form which allows to pass in converter is no longer used
for anything but #to_int.  This PR deprecated both versions.

In refactoring to use these I noticed in two places we were not even checking
to see if the value was safely an int/long.  The integerAs* provides this and is
more direct/narrow in what it provides than num2int or num2long.
@enebo enebo added this to the JRuby 10.0.0.0 milestone Jun 20, 2024
@enebo enebo merged commit e9d5642 into jruby:9.5-dev Jun 20, 2024
@enebo enebo deleted the api_convert_int branch March 4, 2025 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant