Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into digest-raap
Browse files Browse the repository at this point in the history
  • Loading branch information
ksss committed Jun 17, 2024
2 parents 80a3042 + 9188d9f commit af017a5
Show file tree
Hide file tree
Showing 18 changed files with 325 additions and 53 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,3 @@ jobs:
- name: Run test
run: |
bundle exec rake ${{ matrix.job }}
windows:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2019, windows-2022]
ruby: [ucrt, mswin]
steps:
- uses: actions/checkout@v4
- name: load ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: rake-compiler
run: gem install rake-compiler
- name: compile
run: rake compile
26 changes: 26 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Ruby on Windows

on:
push:
branches:
- master
pull_request: {}
merge_group: {}

jobs:
compile:
runs-on: "windows-latest"
strategy:
fail-fast: false
matrix:
ruby: ['3.2', '3.3', ucrt, mswin]
steps:
- uses: actions/checkout@v4
- name: load ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: rake-compiler
run: gem install rake-compiler
- name: compile
run: rake compile
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# CHANGELOG

## 3.5.1 (2024-06-07)

### Library changes

* Add explicit dependency on the `logger` gem ([#1865](https://github.com/ruby/rbs/pull/1865))
* Make c99, c23 compatible ([#1870](https://github.com/ruby/rbs/pull/1870))

### Miscellaneous

* Don't try to sign git commits when running tests ([#1867](https://github.com/ruby/rbs/pull/1867))

## 3.5.0 (2024-06-06)

### Signature updates
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ group :minitest do
end

group :typecheck_test do
gem "steep", "~> 1.7.0.dev", require: false
gem "steep", "~> 1.7.1", require: false
end
27 changes: 14 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
PATH
remote: .
specs:
rbs (3.5.0)
rbs (3.5.1)
logger

PATH
remote: test/assets/test-gem
Expand All @@ -28,7 +29,7 @@ GEM
base64 (0.2.0)
benchmark-ips (2.13.0)
bigdecimal (3.1.8)
concurrent-ruby (1.3.1)
concurrent-ruby (1.3.3)
connection_pool (2.4.1)
csv (3.3.0)
dbm (1.1.0)
Expand All @@ -54,23 +55,23 @@ GEM
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.0)
marcel (1.0.4)
memory_profiler (1.0.1)
memory_profiler (1.0.2)
minitest (5.23.1)
mutex_m (0.2.0)
net-protocol (0.2.2)
timeout
net-smtp (0.5.0)
net-protocol
nkf (0.2.0)
parallel (1.24.0)
parser (3.3.2.0)
parallel (1.25.1)
parser (3.3.3.0)
ast (~> 2.4.1)
racc
power_assert (2.0.3)
psych (4.0.6)
stringio
public_suffix (5.0.5)
raap (0.7.0)
public_suffix (5.1.0)
raap (0.8.0)
rbs (~> 3.0)
timeout (~> 0.4)
racc (1.8.0)
Expand All @@ -84,15 +85,15 @@ GEM
rdoc (6.6.3.1)
psych (>= 4.0.0)
regexp_parser (2.9.2)
rexml (3.2.8)
strscan (>= 3.0.9)
rexml (3.3.0)
strscan
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
rspec-expectations (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
Expand All @@ -117,7 +118,7 @@ GEM
ruby-progressbar (1.13.0)
securerandom (0.3.1)
stackprof (0.2.26)
steep (1.7.0.dev.4)
steep (1.7.1)
activesupport (>= 5.1)
concurrent-ruby (>= 1.1.10)
csv (>= 3.0.9)
Expand All @@ -132,7 +133,7 @@ GEM
securerandom (>= 0.1)
strscan (>= 1.0.0)
terminal-table (>= 2, < 4)
stringio (3.1.0)
stringio (3.1.1)
strong_json (2.1.2)
strscan (3.1.0)
tempfile (0.2.1)
Expand Down Expand Up @@ -176,7 +177,7 @@ DEPENDENCIES
rubocop
rubocop-rubycw
stackprof
steep (~> 1.7.0.dev)
steep (~> 1.7.1)
tempfile
test-unit

Expand Down
66 changes: 66 additions & 0 deletions core/rubygems/errors.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,72 @@
#
# -The RubyGems Team
#
# <!-- rdoc-file=lib/rubygems/deprecate.rb -->
# Provides 3 methods for declaring when something is going away.
#
# +deprecate(name, repl, year, month)+:
# Indicate something may be removed on/after a certain date.
#
# +rubygems_deprecate(name, replacement=:none)+:
# Indicate something will be removed in the next major RubyGems version,
# and (optionally) a replacement for it.
#
# `rubygems_deprecate_command`:
# Indicate a RubyGems command (in +lib/rubygems/commands/*.rb+) will be
# removed in the next RubyGems version.
#
# Also provides `skip_during` for temporarily turning off deprecation warnings.
# This is intended to be used in the test suite, so deprecation warnings don't
# cause test failures if you need to make sure stderr is otherwise empty.
#
# Example usage of `deprecate` and `rubygems_deprecate`:
#
# class Legacy
# def self.some_class_method
# # ...
# end
#
# def some_instance_method
# # ...
# end
#
# def some_old_method
# # ...
# end
#
# extend Gem::Deprecate
# deprecate :some_instance_method, "X.z", 2011, 4
# rubygems_deprecate :some_old_method, "Modern#some_new_method"
#
# class << self
# extend Gem::Deprecate
# deprecate :some_class_method, :none, 2011, 4
# end
# end
#
# Example usage of `rubygems_deprecate_command`:
#
# class Gem::Commands::QueryCommand < Gem::Command
# extend Gem::Deprecate
# rubygems_deprecate_command
#
# # ...
# end
#
# Example usage of `skip_during`:
#
# class TestSomething < Gem::Testcase
# def test_some_thing_with_deprecations
# Gem::Deprecate.skip_during do
# actual_stdout, actual_stderr = capture_output do
# Gem.something_deprecated
# end
# assert_empty actual_stdout
# assert_equal(expected, actual_stderr)
# end
# end
# end
#
module Gem
# <!-- rdoc-file=lib/rubygems/errors.rb -->
# Raised when RubyGems is unable to load or activate a gem. Contains the name
Expand Down
66 changes: 66 additions & 0 deletions core/rubygems/rubygems.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,72 @@
#
# -The RubyGems Team
#
# <!-- rdoc-file=lib/rubygems/deprecate.rb -->
# Provides 3 methods for declaring when something is going away.
#
# +deprecate(name, repl, year, month)+:
# Indicate something may be removed on/after a certain date.
#
# +rubygems_deprecate(name, replacement=:none)+:
# Indicate something will be removed in the next major RubyGems version,
# and (optionally) a replacement for it.
#
# `rubygems_deprecate_command`:
# Indicate a RubyGems command (in +lib/rubygems/commands/*.rb+) will be
# removed in the next RubyGems version.
#
# Also provides `skip_during` for temporarily turning off deprecation warnings.
# This is intended to be used in the test suite, so deprecation warnings don't
# cause test failures if you need to make sure stderr is otherwise empty.
#
# Example usage of `deprecate` and `rubygems_deprecate`:
#
# class Legacy
# def self.some_class_method
# # ...
# end
#
# def some_instance_method
# # ...
# end
#
# def some_old_method
# # ...
# end
#
# extend Gem::Deprecate
# deprecate :some_instance_method, "X.z", 2011, 4
# rubygems_deprecate :some_old_method, "Modern#some_new_method"
#
# class << self
# extend Gem::Deprecate
# deprecate :some_class_method, :none, 2011, 4
# end
# end
#
# Example usage of `rubygems_deprecate_command`:
#
# class Gem::Commands::QueryCommand < Gem::Command
# extend Gem::Deprecate
# rubygems_deprecate_command
#
# # ...
# end
#
# Example usage of `skip_during`:
#
# class TestSomething < Gem::Testcase
# def test_some_thing_with_deprecations
# Gem::Deprecate.skip_during do
# actual_stdout, actual_stderr = capture_output do
# Gem.something_deprecated
# end
# assert_empty actual_stdout
# assert_equal(expected, actual_stderr)
# end
# end
# end
#
module Gem
interface _HashLike[K, V]
def each_pair: () { ([ K, V ]) -> untyped } -> self
Expand Down
9 changes: 5 additions & 4 deletions ext/rbs_extension/location.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#define RBS_LOC_REQUIRED_P(loc, i) ((loc)->children->required_p & (1 << (i)))
#define RBS_LOC_OPTIONAL_P(loc, i) (!RBS_LOC_REQUIRED_P((loc), (i)))
#define RBS_LOC_CHILDREN_SIZE(cap) (sizeof(rbs_loc_children) + sizeof(rbs_loc_entry) * ((cap) - 1))

VALUE RBS_Location;

Expand All @@ -25,7 +26,7 @@ static void check_children_max(unsigned short n) {
void rbs_loc_alloc_children(rbs_loc *loc, unsigned short cap) {
check_children_max(cap);

size_t s = sizeof(rbs_loc_children) + sizeof(rbs_loc_entry) * cap;
size_t s = RBS_LOC_CHILDREN_SIZE(cap);
loc->children = malloc(s);

loc->children->len = 0;
Expand All @@ -39,7 +40,7 @@ static void check_children_cap(rbs_loc *loc) {
} else {
if (loc->children->len == loc->children->cap) {
check_children_max(loc->children->cap + 1);
size_t s = sizeof(rbs_loc_children) + sizeof(rbs_loc_entry) * (++loc->children->cap);
size_t s = RBS_LOC_CHILDREN_SIZE(++loc->children->cap);
loc->children = realloc(loc->children, s);
}
}
Expand Down Expand Up @@ -85,7 +86,7 @@ static size_t rbs_loc_memsize(const void *ptr) {
if (loc->children == NULL) {
return sizeof(rbs_loc);
} else {
return sizeof(rbs_loc) + sizeof(rbs_loc_children) + sizeof(rbs_loc_entry) * loc->children->cap;
return sizeof(rbs_loc) + RBS_LOC_CHILDREN_SIZE(loc->children->cap);
}
}

Expand Down Expand Up @@ -129,7 +130,7 @@ static VALUE location_initialize_copy(VALUE self, VALUE other) {
self_loc->rg = other_loc->rg;
if (other_loc->children != NULL) {
rbs_loc_alloc_children(self_loc, other_loc->children->cap);
memcpy(self_loc->children, other_loc->children, sizeof(rbs_loc_children) + sizeof(rbs_loc_entry) * other_loc->children->cap);
memcpy(self_loc->children, other_loc->children, RBS_LOC_CHILDREN_SIZE(other_loc->children->cap));
}

return Qnil;
Expand Down
6 changes: 4 additions & 2 deletions ext/rbs_extension/location.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ typedef struct {

typedef unsigned int rbs_loc_entry_bitmap;

// The flexible array always allocates, but it's okay.
// This struct is not allocated when the `rbs_loc` doesn't have children.
typedef struct {
unsigned short len;
unsigned short cap;
rbs_loc_entry_bitmap required_p;
rbs_loc_entry entries[0];
rbs_loc_entry entries[1];
} rbs_loc_children;

typedef struct {
VALUE buffer;
range rg;
rbs_loc_children *children;
rbs_loc_children *children; // NULL when no children is allocated
} rbs_loc;

/**
Expand Down
Loading

0 comments on commit af017a5

Please sign in to comment.