Skip to content

Commit 7404589

Browse files
authored
Merge pull request #29 from ruby-go-gem/exclude_ruby_3.4_removed_methods
Exclude removed methods in Ruby 3.4
2 parents 4a8f395 + 6e8edc4 commit 7404589

File tree

9 files changed

+25
-9
lines changed

9 files changed

+25
-9
lines changed

CONFIG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ enum:
4545
```
4646
4747
## Full configuration file
48-
[config/default.yml](config/default.yml) is used by https://github.com/ruby-go-gem/go-gem-wrapper to generate bindings for Go.
48+
[config/default.yml.erb](config/default.yml.erb) is used by https://github.com/ruby-go-gem/go-gem-wrapper to generate bindings for Go.
4949
5050
## `function.include_name`, `struct.include_name`, `type.include_name`, `enum.include_name`
5151
Return functions and structures that match the condition with a [RubyHeaderParser::Parser](lib/ruby_header_parser/parser.rb)

config/default.yml renamed to config/default.yml.erb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ function:
6868
# FIXME: Workaround for "undefined reference to `rb_class_descendants'" on GitHub Actions (Ubuntu 22.04)
6969
- rb_class_descendants
7070

71+
<% if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create("3.4.0") %>
72+
# Removed since ruby 3.4+
73+
- rb_data_object_make
74+
- rb_newobj
75+
- rb_newobj_of
76+
- rb_st_init_existing_table_with_size
77+
- rb_st_replace
78+
<% end %>
79+
7180
pointer_hint:
7281
RSTRING_PTR:
7382
self: raw

lib/ruby_header_parser.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require "yaml"
44
require "tmpdir"
5+
require "erb"
56

67
require_relative "ruby_header_parser/version"
78

lib/ruby_header_parser/config.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class Config
1111
#
1212
# @note See [CONFIG.md](../file.CONFIG.html) for config file details
1313
def initialize(config_file)
14-
yaml = File.read(config_file)
14+
erb = File.read(config_file)
15+
yaml = ERB.new(erb).result
1516
@data = YAML.safe_load(yaml, aliases: true, permitted_classes: [Regexp])
1617
end
1718

lib/ruby_header_parser/parser.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Parser # rubocop:disable Metrics/ClassLength
3030
# @param include_paths [Array<String>]
3131
# @param dist_preprocessed_header_file [String,nil] Destination path to the output of preprocessed ruby.h.
3232
# (default: `"#{Dir.tmpdir}/ruby_preprocessed.h"`)
33-
# @param config_file [String,nil] Path to config file (default: `config/default.yml`)
33+
# @param config_file [String,nil] Path to config file (default: `config/default.yml.erb`)
3434
#
3535
# @note `dist_preprocessed_header_file` is used as the output destination for temporary files when the parser
3636
# is executed
@@ -42,7 +42,7 @@ def initialize(dist_preprocessed_header_file: nil, header_file: DEFAULT_HEADER_F
4242
@include_paths = include_paths
4343
@dist_preprocessed_header_file = dist_preprocessed_header_file || File.join(Dir.tmpdir, "ruby_preprocessed.h")
4444

45-
config_file ||= File.expand_path("../../config/default.yml", __dir__.to_s)
45+
config_file ||= File.expand_path("../../config/default.yml.erb", __dir__.to_s)
4646
@config = Config.new(config_file)
4747
end
4848

rbs_collection.lock.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ gems:
2929
revision: '09beb2100db10cbf4773ed0e71ddf79280a2f275'
3030
remote: https://github.com/ruby/gem_rbs_collection.git
3131
repo_dir: gems
32+
- name: erb
33+
version: '0'
34+
source:
35+
type: stdlib
3236
- name: fileutils
3337
version: '0'
3438
source:

rbs_collection.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ gems:
2525

2626
- name: yaml
2727
- name: tmpdir
28+
- name: erb

spec/ruby_header_parser/config_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
describe "#function_arg_pointer_hint" do
77
subject { config.function_arg_pointer_hint(function_name:, pos:) }
88

9-
context "found in config/default.yml" do
9+
context "found in config/default.yml.erb" do
1010
let(:function_name) { "rb_funcallv" }
1111
let(:pos) { 4 }
1212

1313
it { should eq :array }
1414
end
1515

16-
context "not found in config/default.yml" do
16+
context "not found in config/default.yml.erb" do
1717
let(:function_name) { "rb_funcallv" }
1818
let(:pos) { 5 }
1919

@@ -24,13 +24,13 @@
2424
describe "#function_self_pointer_hint" do
2525
subject { config.function_self_pointer_hint(function_name) }
2626

27-
context "found in default.yml" do
27+
context "found in default.yml.erb" do
2828
let(:function_name) { "RSTRING_PTR" }
2929

3030
it { should eq :raw }
3131
end
3232

33-
context "not found in config/default.yml" do
33+
context "not found in config/default.yml.erb" do
3434
let(:function_name) { "rb_class2name" }
3535

3636
it { should eq :ref }

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929

3030
# @return [String]
3131
def default_config_file
32-
File.expand_path("../config/default.yml", __dir__)
32+
File.expand_path("../config/default.yml.erb", __dir__)
3333
end

0 commit comments

Comments
 (0)