Skip to content

Commit

Permalink
Remove need for Natalie patches
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Apr 25, 2024
1 parent 6a95573 commit 7fc7e13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rake/extensiontask"
require "rake/clean"

task default: %i[compile test]
Expand All @@ -27,14 +26,16 @@ task build: [:check_manifest, :templates]
task "compile:prism" => ["templates"] # must be before the ExtensionTask is created

if RUBY_ENGINE == "ruby" and !ENV["PRISM_FFI_BACKEND"]
require "rake/extensiontask"

Rake::ExtensionTask.new(:compile) do |ext|
ext.name = "prism"
ext.ext_dir = "ext/prism"
ext.lib_dir = "lib/prism"
ext.gem_spec = Gem::Specification.load("prism.gemspec")
end
elsif RUBY_ENGINE == "jruby"
require 'rake/javaextensiontask'
require "rake/javaextensiontask"

# This compiles java to make sure any templating changes produces valid code.
Rake::JavaExtensionTask.new(:compile) do |ext|
Expand Down
6 changes: 4 additions & 2 deletions lib/prism/polyfill/string.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

# Polyfill for String#unpack1 with the offset parameter.
if String.instance_method(:unpack1).parameters.none? { |_, name| name == :offset }
# Polyfill for String#unpack1 with the offset parameter. Not all Ruby engines
# have Method#parameters implemented, so we check the arity instead if
# necessary.
if (unpack1 = String.instance_method(:unpack1)).respond_to?(:parameters) ? unpack1.parameters.none? { |_, name| name == :offset } : (unpack1.arity == 1)
String.prepend(
Module.new {
def unpack1(format, offset: 0) # :nodoc:
Expand Down

0 comments on commit 7fc7e13

Please sign in to comment.