Skip to content

Commit 63aadc2

Browse files
committed
[Feature #16254] Use Primitive.func style
1 parent 49f0fd2 commit 63aadc2

File tree

9 files changed

+58
-58
lines changed

9 files changed

+58
-58
lines changed

array.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Array
1313
#
1414
# a.shuffle!(random: Random.new(1)) #=> [1, 3, 2]
1515
def shuffle!(random: Random)
16-
__builtin.rb_ary_shuffle_bang(random)
16+
Primitive.rb_ary_shuffle_bang(random)
1717
end
1818

1919
# call-seq:
@@ -30,7 +30,7 @@ def shuffle!(random: Random)
3030
#
3131
# a.shuffle(random: Random.new(1)) #=> [1, 3, 2]
3232
def shuffle(random: Random)
33-
__builtin.rb_ary_shuffle(random)
33+
Primitive.rb_ary_shuffle(random)
3434
end
3535

3636
# call-seq:
@@ -57,6 +57,6 @@ def shuffle(random: Random)
5757
# a.sample(random: Random.new(1)) #=> 6
5858
# a.sample(4, random: Random.new(1)) #=> [6, 10, 9, 2]
5959
def sample(n = (ary = false), random: Random)
60-
__builtin.rb_ary_sample(random, n, ary)
60+
Primitive.rb_ary_sample(random, n, ary)
6161
end
6262
end

ast.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module AbstractSyntaxTree
3232
# RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
3333
# # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-1:9>
3434
def self.parse string
35-
__builtin.ast_s_parse string
35+
Primitive.ast_s_parse string
3636
end
3737

3838
# call-seq:
@@ -47,7 +47,7 @@ def self.parse string
4747
# RubyVM::AbstractSyntaxTree.parse_file("my-app/app.rb")
4848
# # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-31:3>
4949
def self.parse_file pathname
50-
__builtin.ast_s_parse_file pathname
50+
Primitive.ast_s_parse_file pathname
5151
end
5252

5353
# call-seq:
@@ -66,7 +66,7 @@ def self.parse_file pathname
6666
# RubyVM::AbstractSyntaxTree.of(method(:hello))
6767
# # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-3:3>
6868
def self.of body
69-
__builtin.ast_s_of body
69+
Primitive.ast_s_of body
7070
end
7171

7272
# RubyVM::AbstractSyntaxTree::Node instances are created by parse methods in
@@ -88,39 +88,39 @@ class Node
8888
# call = lasgn.children[1]
8989
# call.type # => :OPCALL
9090
def type
91-
__builtin.ast_node_type
91+
Primitive.ast_node_type
9292
end
9393

9494
# call-seq:
9595
# node.first_lineno -> integer
9696
#
9797
# The line number in the source code where this AST's text began.
9898
def first_lineno
99-
__builtin.ast_node_first_lineno
99+
Primitive.ast_node_first_lineno
100100
end
101101

102102
# call-seq:
103103
# node.first_column -> integer
104104
#
105105
# The column number in the source code where this AST's text began.
106106
def first_column
107-
__builtin.ast_node_first_column
107+
Primitive.ast_node_first_column
108108
end
109109

110110
# call-seq:
111111
# node.last_lineno -> integer
112112
#
113113
# The line number in the source code where this AST's text ended.
114114
def last_lineno
115-
__builtin.ast_node_last_lineno
115+
Primitive.ast_node_last_lineno
116116
end
117117

118118
# call-seq:
119119
# node.last_column -> integer
120120
#
121121
# The column number in the source code where this AST's text ended.
122122
def last_column
123-
__builtin.ast_node_last_column
123+
Primitive.ast_node_last_column
124124
end
125125

126126
# call-seq:
@@ -131,15 +131,15 @@ def last_column
131131
#
132132
# The returned array may contain other nodes or <code>nil</code>.
133133
def children
134-
__builtin.ast_node_children
134+
Primitive.ast_node_children
135135
end
136136

137137
# call-seq:
138138
# node.inspect -> string
139139
#
140140
# Returns debugging information about this node as a string.
141141
def inspect
142-
__builtin.ast_node_inspect
142+
Primitive.ast_node_inspect
143143
end
144144
end
145145
end

dir.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ class Dir
1212
# directory is closed at the end of the block, and Dir::open returns
1313
# the value of the block.
1414
def self.open(name, encoding: nil, &block)
15-
dir = __builtin.dir_s_open(name, encoding)
15+
dir = Primitive.dir_s_open(name, encoding)
1616
if block
1717
begin
1818
yield dir
1919
ensure
20-
__builtin.dir_s_close(dir)
20+
Primitive.dir_s_close(dir)
2121
end
2222
else
2323
dir
@@ -32,15 +32,15 @@ def self.open(name, encoding: nil, &block)
3232
# The optional <i>encoding</i> keyword argument specifies the encoding of the directory.
3333
# If not specified, the filesystem encoding is used.
3434
def initialize(name, encoding: nil)
35-
__builtin.dir_initialize(name, encoding)
35+
Primitive.dir_initialize(name, encoding)
3636
end
3737

3838
# Dir[ string [, string ...] [, base: path] [, sort: true] ] -> array
3939
#
4040
# Equivalent to calling
4141
# <code>Dir.glob([</code><i>string,...</i><code>], 0)</code>.
4242
def self.[](*args, base: nil, sort: true)
43-
__builtin.dir_s_aref(args, base, sort)
43+
Primitive.dir_s_aref(args, base, sort)
4444
end
4545

4646
# Dir.glob( pattern, [flags], [base: path] [, sort: true] ) -> array
@@ -133,6 +133,6 @@ def self.[](*args, base: nil, sort: true)
133133
# librbfiles = File.join("**", "lib", "*.rb")
134134
# Dir.glob(librbfiles) #=> ["lib/song.rb"]
135135
def self.glob(pattern, _flags = 0, flags: _flags, base: nil, sort: true)
136-
__builtin.dir_s_glob(pattern, flags, base, sort)
136+
Primitive.dir_s_glob(pattern, flags, base, sort)
137137
end
138138
end

gc.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ module GC
3131
# are not guaranteed to be future-compatible, and may be ignored if the
3232
# underlying implementation does not support them.
3333
def self.start full_mark: true, immediate_mark: true, immediate_sweep: true
34-
__builtin.gc_start_internal full_mark, immediate_mark, immediate_sweep
34+
Primitive.gc_start_internal full_mark, immediate_mark, immediate_sweep
3535
end
3636

3737
def garbage_collect full_mark: true, immediate_mark: true, immediate_sweep: true
38-
__builtin.gc_start_internal full_mark, immediate_mark, immediate_sweep
38+
Primitive.gc_start_internal full_mark, immediate_mark, immediate_sweep
3939
end
4040

4141
# call-seq:
@@ -49,7 +49,7 @@ def garbage_collect full_mark: true, immediate_mark: true, immediate_sweep: true
4949
# GC.enable #=> false
5050
#
5151
def self.enable
52-
__builtin.gc_enable
52+
Primitive.gc_enable
5353
end
5454

5555
# call-seq:
@@ -61,15 +61,15 @@ def self.enable
6161
# GC.disable #=> false
6262
# GC.disable #=> true
6363
def self.disable
64-
__builtin.gc_disable
64+
Primitive.gc_disable
6565
end
6666

6767
# call-seq:
6868
# GC.stress -> integer, true or false
6969
#
7070
# Returns current status of GC stress mode.
7171
def self.stress
72-
__builtin.gc_stress_get
72+
Primitive.gc_stress_get
7373
end
7474

7575
# call-seq:
@@ -87,7 +87,7 @@ def self.stress
8787
# 0x02:: no immediate sweep
8888
# 0x04:: full mark after malloc/calloc/realloc
8989
def self.stress=(flag)
90-
__builtin.gc_stress_set_m flag
90+
Primitive.gc_stress_set_m flag
9191
end
9292

9393
# call-seq:
@@ -97,7 +97,7 @@ def self.stress=(flag)
9797
#
9898
# It returns the number of times GC occurred since the process started.
9999
def self.count
100-
__builtin.gc_count
100+
Primitive.gc_count
101101
end
102102

103103
# call-seq:
@@ -146,7 +146,7 @@ def self.count
146146
#
147147
# This method is only expected to work on C Ruby.
148148
def self.stat hash_or_key = nil
149-
__builtin.gc_stat hash_or_key
149+
Primitive.gc_stat hash_or_key
150150
end
151151

152152
# call-seq:
@@ -160,11 +160,11 @@ def self.stat hash_or_key = nil
160160
# it is overwritten and returned.
161161
# This is intended to avoid probe effect.
162162
def self.latest_gc_info hash_or_key = nil
163-
__builtin.gc_latest_gc_info hash_or_key
163+
Primitive.gc_latest_gc_info hash_or_key
164164
end
165165

166166
def self.compact
167-
__builtin.rb_gc_compact
167+
Primitive.rb_gc_compact
168168
end
169169

170170
# call-seq:
@@ -182,13 +182,13 @@ def self.compact
182182
# object, that object should be pushed on the mark stack, and will
183183
# make a SEGV.
184184
def self.verify_compaction_references(toward: nil, double_heap: false)
185-
__builtin.gc_verify_compaction_references(toward, double_heap)
185+
Primitive.gc_verify_compaction_references(toward, double_heap)
186186
end
187187
end
188188

189189
module ObjectSpace
190190
def garbage_collect full_mark: true, immediate_mark: true, immediate_sweep: true
191-
__builtin.gc_start_internal full_mark, immediate_mark, immediate_sweep
191+
Primitive.gc_start_internal full_mark, immediate_mark, immediate_sweep
192192
end
193193

194194
module_function :garbage_collect

io.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class IO
6060
# return the symbol +:wait_readable+ instead. At EOF, it will return nil
6161
# instead of raising EOFError.
6262
def read_nonblock(len, buf = nil, exception: true)
63-
__builtin.io_read_nonblock(len, buf, exception)
63+
Primitive.io_read_nonblock(len, buf, exception)
6464
end
6565

6666
# call-seq:
@@ -118,6 +118,6 @@ def read_nonblock(len, buf = nil, exception: true)
118118
# that write_nonblock should not raise an IO::WaitWritable exception, but
119119
# return the symbol +:wait_writable+ instead.
120120
def write_nonblock(buf, exception: true)
121-
__builtin.io_write_nonblock(buf, exception)
121+
Primitive.io_write_nonblock(buf, exception)
122122
end
123123
end

kernel.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Kernel
2424
# the class.
2525
#
2626
def clone(freeze: nil)
27-
__builtin.rb_obj_clone2(freeze)
27+
Primitive.rb_obj_clone2(freeze)
2828
end
2929

3030
module_function
@@ -48,6 +48,6 @@ def clone(freeze: nil)
4848
# Float("123.0_badstring", exception: false) #=> nil
4949
#
5050
def Float(arg, exception: true)
51-
__builtin.rb_f_float(arg, exception)
51+
Primitive.rb_f_float(arg, exception)
5252
end
5353
end

pack.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class Array
131131
# X | --- | back up a byte
132132
# x | --- | null byte
133133
def pack(fmt, buffer: nil)
134-
__builtin.pack_pack(fmt, buffer)
134+
Primitive.pack_pack(fmt, buffer)
135135
end
136136
end
137137

@@ -254,7 +254,7 @@ class String
254254
# * Q_, Q!, q_, and q! are available since Ruby 2.1.
255255
# * I!<, i!<, I!>, and i!> are available since Ruby 1.9.3.
256256
def unpack(fmt)
257-
__builtin.pack_unpack(fmt)
257+
Primitive.pack_unpack(fmt)
258258
end
259259

260260
# call-seq:
@@ -278,6 +278,6 @@ def unpack(fmt)
278278
# Thus unpack1 is convenient, makes clear the intention and signals
279279
# the expected return value to those reading the code.
280280
def unpack1(fmt)
281-
__builtin.pack_unpack1(fmt)
281+
Primitive.pack_unpack1(fmt)
282282
end
283283
end

0 commit comments

Comments
 (0)