rbs 3.10.2 → 4.0.0.dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +2 -2
- data/.github/workflows/ruby.yml +24 -34
- data/.github/workflows/typecheck.yml +3 -1
- data/.github/workflows/windows.yml +2 -2
- data/.gitignore +0 -4
- data/CHANGELOG.md +0 -107
- data/README.md +1 -38
- data/Rakefile +20 -142
- data/Steepfile +1 -0
- data/config.yml +43 -1
- data/core/array.rbs +46 -96
- data/core/comparable.rbs +6 -13
- data/core/complex.rbs +25 -40
- data/core/dir.rbs +4 -4
- data/core/encoding.rbs +9 -6
- data/core/enumerable.rbs +3 -90
- data/core/enumerator.rbs +1 -43
- data/core/errno.rbs +0 -8
- data/core/errors.rbs +1 -28
- data/core/exception.rbs +2 -2
- data/core/fiber.rbs +20 -29
- data/core/file.rbs +19 -49
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +33 -224
- data/core/gc.rbs +281 -417
- data/core/hash.rbs +727 -1023
- data/core/integer.rbs +63 -104
- data/core/io/buffer.rbs +10 -21
- data/core/io/wait.rbs +33 -11
- data/core/io.rbs +12 -14
- data/core/kernel.rbs +51 -61
- data/core/marshal.rbs +1 -1
- data/core/match_data.rbs +1 -1
- data/core/math.rbs +3 -42
- data/core/method.rbs +25 -63
- data/core/module.rbs +23 -101
- data/core/nil_class.rbs +3 -3
- data/core/numeric.rbs +17 -25
- data/core/object.rbs +3 -3
- data/core/object_space.rbs +15 -21
- data/core/proc.rbs +24 -30
- data/core/process.rbs +2 -2
- data/core/ractor.rbs +509 -361
- data/core/range.rbs +8 -7
- data/core/rational.rbs +34 -56
- data/core/rbs/unnamed/argf.rbs +2 -2
- data/core/rbs/unnamed/env_class.rbs +1 -1
- data/core/rbs/unnamed/random.rbs +2 -4
- data/core/regexp.rbs +20 -25
- data/core/ruby_vm.rbs +4 -6
- data/core/rubygems/errors.rbs +70 -3
- data/core/rubygems/rubygems.rbs +79 -11
- data/core/rubygems/version.rbs +3 -2
- data/core/set.rbs +359 -488
- data/core/signal.rbs +14 -24
- data/core/string.rbs +1236 -3165
- data/core/struct.rbs +1 -1
- data/core/symbol.rbs +11 -17
- data/core/thread.rbs +33 -95
- data/core/time.rbs +9 -35
- data/core/trace_point.rbs +4 -7
- data/core/unbound_method.rbs +6 -14
- data/docs/collection.md +2 -2
- data/docs/gem.md +1 -0
- data/docs/sigs.md +3 -3
- data/ext/rbs_extension/ast_translation.c +1077 -944
- data/ext/rbs_extension/ast_translation.h +0 -7
- data/ext/rbs_extension/class_constants.c +83 -71
- data/ext/rbs_extension/class_constants.h +7 -4
- data/ext/rbs_extension/extconf.rb +2 -24
- data/ext/rbs_extension/legacy_location.c +172 -173
- data/ext/rbs_extension/legacy_location.h +3 -8
- data/ext/rbs_extension/main.c +289 -239
- data/ext/rbs_extension/rbs_extension.h +0 -3
- data/ext/rbs_extension/rbs_string_bridging.h +0 -4
- data/include/rbs/ast.h +98 -37
- data/include/rbs/defines.h +12 -38
- data/include/rbs/lexer.h +114 -126
- data/include/rbs/location.h +14 -14
- data/include/rbs/parser.h +37 -21
- data/include/rbs/string.h +5 -3
- data/include/rbs/util/rbs_allocator.h +19 -40
- data/include/rbs/util/rbs_assert.h +1 -12
- data/include/rbs/util/rbs_constant_pool.h +3 -3
- data/include/rbs/util/rbs_encoding.h +1 -3
- data/include/rbs/util/rbs_unescape.h +1 -2
- data/lib/rbs/ast/ruby/annotations.rb +119 -0
- data/lib/rbs/ast/ruby/comment_block.rb +221 -0
- data/lib/rbs/ast/ruby/declarations.rb +86 -0
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +24 -0
- data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
- data/lib/rbs/ast/ruby/members.rb +213 -0
- data/lib/rbs/buffer.rb +104 -24
- data/lib/rbs/cli/validate.rb +40 -35
- data/lib/rbs/cli.rb +5 -6
- data/lib/rbs/collection/config/lockfile_generator.rb +0 -8
- data/lib/rbs/collection.rb +0 -1
- data/lib/rbs/definition.rb +6 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +65 -62
- data/lib/rbs/definition_builder/method_builder.rb +45 -30
- data/lib/rbs/definition_builder.rb +44 -9
- data/lib/rbs/environment/class_entry.rb +69 -0
- data/lib/rbs/environment/module_entry.rb +66 -0
- data/lib/rbs/environment.rb +244 -218
- data/lib/rbs/environment_loader.rb +8 -2
- data/lib/rbs/errors.rb +5 -4
- data/lib/rbs/inline_parser/comment_association.rb +117 -0
- data/lib/rbs/inline_parser.rb +206 -0
- data/lib/rbs/location_aux.rb +35 -3
- data/lib/rbs/parser_aux.rb +11 -6
- data/lib/rbs/prototype/runtime.rb +2 -2
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +38 -124
- data/lib/rbs/source.rb +99 -0
- data/lib/rbs/subtractor.rb +5 -6
- data/lib/rbs/test/type_check.rb +0 -14
- data/lib/rbs/types.rb +1 -3
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +13 -1
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +1 -1
- data/rbs.gemspec +1 -0
- data/sig/ancestor_builder.rbs +1 -1
- data/sig/ast/ruby/annotations.rbs +110 -0
- data/sig/ast/ruby/comment_block.rbs +119 -0
- data/sig/ast/ruby/declarations.rbs +60 -0
- data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
- data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
- data/sig/ast/ruby/members.rbs +72 -0
- data/sig/buffer.rbs +63 -5
- data/sig/definition.rbs +1 -0
- data/sig/definition_builder.rbs +1 -1
- data/sig/environment/class_entry.rbs +50 -0
- data/sig/environment/module_entry.rbs +50 -0
- data/sig/environment.rbs +28 -133
- data/sig/errors.rbs +13 -6
- data/sig/inline_parser/comment_association.rbs +71 -0
- data/sig/inline_parser.rbs +87 -0
- data/sig/location.rbs +32 -7
- data/sig/manifest.yaml +1 -0
- data/sig/method_builder.rbs +7 -4
- data/sig/parser.rbs +16 -20
- data/sig/resolver/type_name_resolver.rbs +7 -38
- data/sig/source.rbs +48 -0
- data/sig/types.rbs +1 -4
- data/src/ast.c +290 -201
- data/src/lexer.c +2813 -2902
- data/src/lexer.re +4 -0
- data/src/lexstate.c +155 -169
- data/src/location.c +40 -40
- data/src/parser.c +2665 -2433
- data/src/string.c +48 -0
- data/src/util/rbs_allocator.c +76 -92
- data/src/util/rbs_assert.c +10 -10
- data/src/util/rbs_buffer.c +2 -2
- data/src/util/rbs_constant_pool.c +15 -13
- data/src/util/rbs_encoding.c +4062 -20097
- data/src/util/rbs_unescape.c +48 -85
- data/stdlib/bigdecimal/0/big_decimal.rbs +82 -100
- data/stdlib/bigdecimal-math/0/big_math.rbs +8 -169
- data/stdlib/cgi/0/core.rbs +393 -9
- data/stdlib/cgi/0/manifest.yaml +0 -1
- data/stdlib/coverage/0/coverage.rbs +1 -3
- data/stdlib/date/0/date.rbs +59 -67
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/delegate/0/delegator.rbs +7 -10
- data/stdlib/erb/0/erb.rbs +347 -737
- data/stdlib/fileutils/0/fileutils.rbs +13 -18
- data/stdlib/forwardable/0/forwardable.rbs +0 -3
- data/stdlib/json/0/json.rbs +48 -68
- data/stdlib/net-http/0/net-http.rbs +0 -3
- data/stdlib/objspace/0/objspace.rbs +4 -9
- data/stdlib/open-uri/0/open-uri.rbs +0 -40
- data/stdlib/openssl/0/openssl.rbs +228 -331
- data/stdlib/optparse/0/optparse.rbs +3 -3
- data/stdlib/pathname/0/pathname.rbs +1380 -10
- data/stdlib/psych/0/psych.rbs +3 -3
- data/stdlib/rdoc/0/rdoc.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +68 -25
- data/stdlib/ripper/0/ripper.rbs +2 -5
- data/stdlib/singleton/0/singleton.rbs +0 -3
- data/stdlib/socket/0/socket.rbs +1 -13
- data/stdlib/socket/0/tcp_socket.rbs +2 -10
- data/stdlib/stringio/0/stringio.rbs +85 -1176
- data/stdlib/strscan/0/string_scanner.rbs +31 -31
- data/stdlib/tempfile/0/tempfile.rbs +3 -3
- data/stdlib/time/0/time.rbs +1 -1
- data/stdlib/timeout/0/timeout.rbs +7 -63
- data/stdlib/tsort/0/cyclic.rbs +0 -3
- data/stdlib/uri/0/common.rbs +2 -11
- data/stdlib/uri/0/file.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +16 -17
- data/stdlib/uri/0/rfc2396_parser.rbs +7 -6
- data/stdlib/zlib/0/zstream.rbs +0 -1
- metadata +39 -12
- data/.clang-format +0 -74
- data/.clangd +0 -2
- data/.github/workflows/c-check.yml +0 -54
- data/core/pathname.rbs +0 -1272
- data/core/ruby.rbs +0 -53
- data/docs/aliases.md +0 -79
- data/docs/encoding.md +0 -56
- data/ext/rbs_extension/compat.h +0 -10
- data/stdlib/cgi-escape/0/escape.rbs +0 -171
data/core/integer.rbs
CHANGED
|
@@ -146,9 +146,9 @@ class Integer < Numeric
|
|
|
146
146
|
|
|
147
147
|
# <!--
|
|
148
148
|
# rdoc-file=numeric.c
|
|
149
|
-
# - self % other ->
|
|
149
|
+
# - self % other -> real_number
|
|
150
150
|
# -->
|
|
151
|
-
# Returns `self` modulo `other` as a real
|
|
151
|
+
# Returns `self` modulo `other` as a real number.
|
|
152
152
|
#
|
|
153
153
|
# For integer `n` and real number `r`, these expressions are equivalent:
|
|
154
154
|
#
|
|
@@ -193,13 +193,13 @@ class Integer < Numeric
|
|
|
193
193
|
|
|
194
194
|
# <!--
|
|
195
195
|
# rdoc-file=numeric.c
|
|
196
|
-
# - self *
|
|
196
|
+
# - self * numeric -> numeric_result
|
|
197
197
|
# -->
|
|
198
|
-
#
|
|
198
|
+
# Performs multiplication:
|
|
199
199
|
#
|
|
200
200
|
# 4 * 2 # => 8
|
|
201
|
-
# -4 * 2 # => -8
|
|
202
201
|
# 4 * -2 # => -8
|
|
202
|
+
# -4 * 2 # => -8
|
|
203
203
|
# 4 * 2.0 # => 8.0
|
|
204
204
|
# 4 * Rational(1, 3) # => (4/3)
|
|
205
205
|
# 4 * Complex(2, 0) # => (8+0i)
|
|
@@ -211,47 +211,17 @@ class Integer < Numeric
|
|
|
211
211
|
|
|
212
212
|
# <!--
|
|
213
213
|
# rdoc-file=numeric.c
|
|
214
|
-
# - self **
|
|
214
|
+
# - self ** numeric -> numeric_result
|
|
215
215
|
# -->
|
|
216
|
-
#
|
|
217
|
-
#
|
|
218
|
-
#
|
|
219
|
-
# 2 **
|
|
220
|
-
# 2 **
|
|
221
|
-
# 2 **
|
|
222
|
-
# 2 ** 3
|
|
223
|
-
#
|
|
224
|
-
#
|
|
225
|
-
# 2 ** -3 # => (1/8)
|
|
226
|
-
# -2 ** -3 # => (-1/8)
|
|
227
|
-
#
|
|
228
|
-
# # Result for Float exponent is Float.
|
|
229
|
-
# 2 ** 0.0 # => 1.0
|
|
230
|
-
# 2 ** 1.0 # => 2.0
|
|
231
|
-
# 2 ** 2.0 # => 4.0
|
|
232
|
-
# 2 ** 3.0 # => 8.0
|
|
233
|
-
# -2 ** 3.0 # => -8.0
|
|
234
|
-
# 2 ** -3.0 # => 0.125
|
|
235
|
-
# -2 ** -3.0 # => -0.125
|
|
236
|
-
#
|
|
237
|
-
# # Result for non-negative Complex exponent is Complex with Integer parts.
|
|
238
|
-
# 2 ** Complex(0, 0) # => (1+0i)
|
|
239
|
-
# 2 ** Complex(1, 0) # => (2+0i)
|
|
240
|
-
# 2 ** Complex(2, 0) # => (4+0i)
|
|
241
|
-
# 2 ** Complex(3, 0) # => (8+0i)
|
|
242
|
-
# -2 ** Complex(3, 0) # => (-8+0i)
|
|
243
|
-
# # Result for negative Complex exponent is Complex with Rational parts.
|
|
244
|
-
# 2 ** Complex(-3, 0) # => ((1/8)+(0/1)*i)
|
|
245
|
-
# -2 ** Complex(-3, 0) # => ((-1/8)+(0/1)*i)
|
|
246
|
-
#
|
|
247
|
-
# # Result for Rational exponent is Rational.
|
|
248
|
-
# 2 ** Rational(0, 1) # => (1/1)
|
|
249
|
-
# 2 ** Rational(1, 1) # => (2/1)
|
|
250
|
-
# 2 ** Rational(2, 1) # => (4/1)
|
|
251
|
-
# 2 ** Rational(3, 1) # => (8/1)
|
|
252
|
-
# -2 ** Rational(3, 1) # => (-8/1)
|
|
253
|
-
# 2 ** Rational(-3, 1) # => (1/8)
|
|
254
|
-
# -2 ** Rational(-3, 1) # => (-1/8)
|
|
216
|
+
# Raises `self` to the power of `numeric`:
|
|
217
|
+
#
|
|
218
|
+
# 2 ** 3 # => 8
|
|
219
|
+
# 2 ** -3 # => (1/8)
|
|
220
|
+
# -2 ** 3 # => -8
|
|
221
|
+
# -2 ** -3 # => (-1/8)
|
|
222
|
+
# 2 ** 3.3 # => 9.849155306759329
|
|
223
|
+
# 2 ** Rational(3, 1) # => (8/1)
|
|
224
|
+
# 2 ** Complex(3, 0) # => (8+0i)
|
|
255
225
|
#
|
|
256
226
|
def **: (Integer) -> Numeric
|
|
257
227
|
| (Float) -> Numeric
|
|
@@ -260,20 +230,16 @@ class Integer < Numeric
|
|
|
260
230
|
|
|
261
231
|
# <!--
|
|
262
232
|
# rdoc-file=numeric.c
|
|
263
|
-
# - self +
|
|
233
|
+
# - self + numeric -> numeric_result
|
|
264
234
|
# -->
|
|
265
|
-
#
|
|
266
|
-
#
|
|
267
|
-
# 1 + 1 # => 2
|
|
268
|
-
# 1 + -1 # => 0
|
|
269
|
-
# 1 + 0 # => 1
|
|
270
|
-
# 1 + -2 # => -1
|
|
271
|
-
# 1 + Complex(1, 0) # => (2+0i)
|
|
272
|
-
# 1 + Rational(1, 1) # => (2/1)
|
|
273
|
-
#
|
|
274
|
-
# For a computation involving Floats, the result may be inexact (see Float#+):
|
|
235
|
+
# Performs addition:
|
|
275
236
|
#
|
|
276
|
-
#
|
|
237
|
+
# 2 + 2 # => 4
|
|
238
|
+
# -2 + 2 # => 0
|
|
239
|
+
# -2 + -2 # => -4
|
|
240
|
+
# 2 + 2.0 # => 4.0
|
|
241
|
+
# 2 + Rational(2, 1) # => (4/1)
|
|
242
|
+
# 2 + Complex(2, 0) # => (4+0i)
|
|
277
243
|
#
|
|
278
244
|
def +: (Integer) -> Integer
|
|
279
245
|
| (Float) -> Float
|
|
@@ -284,9 +250,9 @@ class Integer < Numeric
|
|
|
284
250
|
|
|
285
251
|
# <!--
|
|
286
252
|
# rdoc-file=numeric.c
|
|
287
|
-
# - self -
|
|
253
|
+
# - self - numeric -> numeric_result
|
|
288
254
|
# -->
|
|
289
|
-
#
|
|
255
|
+
# Performs subtraction:
|
|
290
256
|
#
|
|
291
257
|
# 4 - 2 # => 2
|
|
292
258
|
# -4 - 2 # => -6
|
|
@@ -302,34 +268,28 @@ class Integer < Numeric
|
|
|
302
268
|
|
|
303
269
|
# <!--
|
|
304
270
|
# rdoc-file=numeric.rb
|
|
305
|
-
# - -
|
|
271
|
+
# - -int -> integer
|
|
306
272
|
# -->
|
|
307
|
-
# Returns `self`, negated
|
|
308
|
-
#
|
|
309
|
-
# -1 # => -1
|
|
310
|
-
# -(-1) # => 1
|
|
311
|
-
# -0 # => 0
|
|
273
|
+
# Returns `self`, negated.
|
|
312
274
|
#
|
|
313
275
|
def -@: () -> Integer
|
|
314
276
|
|
|
315
277
|
# <!--
|
|
316
278
|
# rdoc-file=numeric.c
|
|
317
|
-
# - self /
|
|
279
|
+
# - self / numeric -> numeric_result
|
|
318
280
|
# -->
|
|
319
|
-
#
|
|
320
|
-
#
|
|
321
|
-
# For integer `other`, truncates the result to an integer:
|
|
281
|
+
# Performs division; for integer `numeric`, truncates the result to an integer:
|
|
322
282
|
#
|
|
323
|
-
#
|
|
324
|
-
#
|
|
325
|
-
#
|
|
326
|
-
#
|
|
283
|
+
# 4 / 3 # => 1
|
|
284
|
+
# 4 / -3 # => -2
|
|
285
|
+
# -4 / 3 # => -2
|
|
286
|
+
# -4 / -3 # => 1
|
|
327
287
|
#
|
|
328
|
-
#
|
|
288
|
+
# For other +numeric+, returns non-integer result:
|
|
329
289
|
#
|
|
330
|
-
#
|
|
331
|
-
#
|
|
332
|
-
#
|
|
290
|
+
# 4 / 3.0 # => 1.3333333333333333
|
|
291
|
+
# 4 / Rational(3, 1) # => (4/3)
|
|
292
|
+
# 4 / Complex(3, 0) # => ((4/3)+0i)
|
|
333
293
|
#
|
|
334
294
|
def /: (Integer) -> Integer
|
|
335
295
|
| (Float) -> Float
|
|
@@ -340,14 +300,15 @@ class Integer < Numeric
|
|
|
340
300
|
# rdoc-file=numeric.c
|
|
341
301
|
# - self < other -> true or false
|
|
342
302
|
# -->
|
|
343
|
-
# Returns
|
|
344
|
-
# must be numeric, but may not be Complex:
|
|
303
|
+
# Returns `true` if the value of `self` is less than that of `other`:
|
|
345
304
|
#
|
|
346
|
-
#
|
|
347
|
-
#
|
|
348
|
-
#
|
|
349
|
-
#
|
|
350
|
-
#
|
|
305
|
+
# 1 < 0 # => false
|
|
306
|
+
# 1 < 1 # => false
|
|
307
|
+
# 1 < 2 # => true
|
|
308
|
+
# 1 < 0.5 # => false
|
|
309
|
+
# 1 < Rational(1, 2) # => false
|
|
310
|
+
#
|
|
311
|
+
# Raises an exception if the comparison cannot be made.
|
|
351
312
|
#
|
|
352
313
|
def <: (Numeric) -> bool
|
|
353
314
|
|
|
@@ -370,46 +331,44 @@ class Integer < Numeric
|
|
|
370
331
|
|
|
371
332
|
# <!--
|
|
372
333
|
# rdoc-file=numeric.c
|
|
373
|
-
# - self <=
|
|
334
|
+
# - self <= real -> true or false
|
|
374
335
|
# -->
|
|
375
|
-
# Returns
|
|
376
|
-
# `other
|
|
336
|
+
# Returns `true` if the value of `self` is less than or equal to that of
|
|
337
|
+
# `other`:
|
|
377
338
|
#
|
|
378
|
-
#
|
|
379
|
-
#
|
|
380
|
-
#
|
|
381
|
-
#
|
|
382
|
-
#
|
|
339
|
+
# 1 <= 0 # => false
|
|
340
|
+
# 1 <= 1 # => true
|
|
341
|
+
# 1 <= 2 # => true
|
|
342
|
+
# 1 <= 0.5 # => false
|
|
343
|
+
# 1 <= Rational(1, 2) # => false
|
|
383
344
|
#
|
|
384
|
-
#
|
|
345
|
+
# Raises an exception if the comparison cannot be made.
|
|
385
346
|
#
|
|
386
347
|
def <=: (Numeric) -> bool
|
|
387
348
|
|
|
388
349
|
# <!--
|
|
389
350
|
# rdoc-file=numeric.c
|
|
390
|
-
# - self <=> other
|
|
351
|
+
# - self <=> other -> -1, 0, +1, or nil
|
|
391
352
|
# -->
|
|
392
|
-
# Compares `self` and `other`.
|
|
393
|
-
#
|
|
394
353
|
# Returns:
|
|
395
354
|
#
|
|
396
|
-
# *
|
|
397
|
-
# *
|
|
398
|
-
# *
|
|
355
|
+
# * -1, if `self` is less than `other`.
|
|
356
|
+
# * 0, if `self` is equal to `other`.
|
|
357
|
+
# * 1, if `self` is greater then `other`.
|
|
399
358
|
# * `nil`, if `self` and `other` are incomparable.
|
|
400
359
|
#
|
|
401
360
|
# Examples:
|
|
402
361
|
#
|
|
403
362
|
# 1 <=> 2 # => -1
|
|
404
363
|
# 1 <=> 1 # => 0
|
|
364
|
+
# 1 <=> 0 # => 1
|
|
365
|
+
# 1 <=> 'foo' # => nil
|
|
366
|
+
#
|
|
405
367
|
# 1 <=> 1.0 # => 0
|
|
406
368
|
# 1 <=> Rational(1, 1) # => 0
|
|
407
369
|
# 1 <=> Complex(1, 0) # => 0
|
|
408
|
-
# 1 <=> 0 # => 1
|
|
409
|
-
# 1 <=> 'foo' # => nil
|
|
410
370
|
#
|
|
411
|
-
#
|
|
412
|
-
# Integer#<=> for comparison.
|
|
371
|
+
# This method is the basis for comparisons in module Comparable.
|
|
413
372
|
#
|
|
414
373
|
def <=>: (Integer | Rational) -> Integer
|
|
415
374
|
| (untyped) -> Integer?
|
|
@@ -996,7 +955,7 @@ class Integer < Numeric
|
|
|
996
955
|
def magnitude: () -> Integer
|
|
997
956
|
|
|
998
957
|
# <!-- rdoc-file=numeric.c -->
|
|
999
|
-
# Returns `self` modulo `other` as a real
|
|
958
|
+
# Returns `self` modulo `other` as a real number.
|
|
1000
959
|
#
|
|
1001
960
|
# For integer `n` and real number `r`, these expressions are equivalent:
|
|
1002
961
|
#
|
data/core/io/buffer.rbs
CHANGED
|
@@ -64,9 +64,9 @@ class IO
|
|
|
64
64
|
#
|
|
65
65
|
# File.write('test.txt', 'test data')
|
|
66
66
|
# # => 9
|
|
67
|
-
# buffer = IO::Buffer.map(File.open('test.txt')
|
|
67
|
+
# buffer = IO::Buffer.map(File.open('test.txt'))
|
|
68
68
|
# # =>
|
|
69
|
-
# # #<IO::Buffer 0x00007f3f0768c000+9
|
|
69
|
+
# # #<IO::Buffer 0x00007f3f0768c000+9 MAPPED IMMUTABLE>
|
|
70
70
|
# # ...
|
|
71
71
|
# buffer.get_string(5, 2) # read 2 bytes, starting from offset 5
|
|
72
72
|
# # => "da"
|
|
@@ -113,7 +113,7 @@ class IO
|
|
|
113
113
|
# buffer.get_string(0, 1)
|
|
114
114
|
# # => "t"
|
|
115
115
|
# string
|
|
116
|
-
# # => "
|
|
116
|
+
# # => "best"
|
|
117
117
|
#
|
|
118
118
|
# buffer.resize(100)
|
|
119
119
|
# # in `resize': Cannot resize external buffer! (IO::Buffer::AccessError)
|
|
@@ -131,25 +131,18 @@ class IO
|
|
|
131
131
|
# - IO::Buffer.map(file, [size, [offset, [flags]]]) -> io_buffer
|
|
132
132
|
# -->
|
|
133
133
|
# Create an IO::Buffer for reading from `file` by memory-mapping the file.
|
|
134
|
-
# `
|
|
135
|
-
#
|
|
136
|
-
# Optional `size` and `offset` of mapping can be specified. Trying to map an
|
|
137
|
-
# empty file or specify `size` of 0 will raise an error. Valid values for
|
|
138
|
-
# `offset` are system-dependent.
|
|
134
|
+
# `file_io` should be a `File` instance, opened for reading.
|
|
139
135
|
#
|
|
140
|
-
#
|
|
141
|
-
# also shared, so several processes can use the same mapping.
|
|
136
|
+
# Optional `size` and `offset` of mapping can be specified.
|
|
142
137
|
#
|
|
143
|
-
#
|
|
144
|
-
#
|
|
145
|
-
#
|
|
146
|
-
# impact other processes or the underlying file. It also allows updating a
|
|
147
|
-
# buffer created from a read-only file.
|
|
138
|
+
# By default, the buffer would be immutable (read only); to create a writable
|
|
139
|
+
# mapping, you need to open a file in read-write mode, and explicitly pass
|
|
140
|
+
# `flags` argument without IO::Buffer::IMMUTABLE.
|
|
148
141
|
#
|
|
149
142
|
# File.write('test.txt', 'test')
|
|
150
143
|
#
|
|
151
144
|
# buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY)
|
|
152
|
-
# # => #<IO::Buffer 0x00000001014a0000+4
|
|
145
|
+
# # => #<IO::Buffer 0x00000001014a0000+4 MAPPED READONLY>
|
|
153
146
|
#
|
|
154
147
|
# buffer.readonly? # => true
|
|
155
148
|
#
|
|
@@ -157,7 +150,7 @@ class IO
|
|
|
157
150
|
# # => "test"
|
|
158
151
|
#
|
|
159
152
|
# buffer.set_string('b', 0)
|
|
160
|
-
# #
|
|
153
|
+
# # `set_string': Buffer is not writable! (IO::Buffer::AccessError)
|
|
161
154
|
#
|
|
162
155
|
# # create read/write mapping: length 4 bytes, offset 0, flags 0
|
|
163
156
|
# buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 4, 0)
|
|
@@ -389,10 +382,6 @@ class IO
|
|
|
389
382
|
# * `:U64`: unsigned integer, 8 bytes, big-endian
|
|
390
383
|
# * `:s64`: signed integer, 8 bytes, little-endian
|
|
391
384
|
# * `:S64`: signed integer, 8 bytes, big-endian
|
|
392
|
-
# * `:u128`: unsigned integer, 16 bytes, little-endian
|
|
393
|
-
# * `:U128`: unsigned integer, 16 bytes, big-endian
|
|
394
|
-
# * `:s128`: signed integer, 16 bytes, little-endian
|
|
395
|
-
# * `:S128`: signed integer, 16 bytes, big-endian
|
|
396
385
|
# * `:f32`: float, 4 bytes, little-endian
|
|
397
386
|
# * `:F32`: float, 4 bytes, big-endian
|
|
398
387
|
# * `:f64`: double, 8 bytes, little-endian
|
data/core/io/wait.rbs
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
%a{annotate:rdoc:skip}
|
|
2
2
|
class IO
|
|
3
3
|
# <!--
|
|
4
|
-
# rdoc-file=io.c
|
|
4
|
+
# rdoc-file=ext/io/wait/wait.c
|
|
5
|
+
# - io.nread -> int
|
|
6
|
+
# -->
|
|
7
|
+
# Returns number of bytes that can be read without blocking. Returns zero if no
|
|
8
|
+
# information available.
|
|
9
|
+
#
|
|
10
|
+
# You must require 'io/wait' to use this method.
|
|
11
|
+
#
|
|
12
|
+
def nread: () -> Integer
|
|
13
|
+
|
|
14
|
+
# <!--
|
|
15
|
+
# rdoc-file=ext/io/wait/wait.c
|
|
16
|
+
# - io.ready? -> truthy or falsy
|
|
17
|
+
# -->
|
|
18
|
+
# Returns a truthy value if input available without blocking, or a falsy value.
|
|
19
|
+
#
|
|
20
|
+
# You must require 'io/wait' to use this method.
|
|
21
|
+
#
|
|
22
|
+
def ready?: () -> boolish
|
|
23
|
+
|
|
24
|
+
# <!--
|
|
25
|
+
# rdoc-file=ext/io/wait/wait.c
|
|
5
26
|
# - io.wait(events, timeout) -> event mask, false or nil
|
|
6
|
-
# - io.wait(
|
|
27
|
+
# - io.wait(timeout = nil, mode = :read) -> self, true, or false
|
|
7
28
|
# -->
|
|
8
29
|
# Waits until the IO becomes ready for the specified events and returns the
|
|
9
30
|
# subset of events that become ready, or a falsy value when times out.
|
|
@@ -11,14 +32,11 @@ class IO
|
|
|
11
32
|
# The events can be a bit mask of `IO::READABLE`, `IO::WRITABLE` or
|
|
12
33
|
# `IO::PRIORITY`.
|
|
13
34
|
#
|
|
14
|
-
# Returns
|
|
15
|
-
# available.
|
|
35
|
+
# Returns a truthy value immediately when buffered data is available.
|
|
16
36
|
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
# order of the arguments is arbitrary, and returns `io` if any of the events is
|
|
21
|
-
# ready.
|
|
37
|
+
# Optional parameter `mode` is one of `:read`, `:write`, or `:read_write`.
|
|
38
|
+
#
|
|
39
|
+
# You must require 'io/wait' to use this method.
|
|
22
40
|
#
|
|
23
41
|
def wait: (Integer events, ?Time::_Timeout timeout) -> (Integer | false | nil)
|
|
24
42
|
| (?Time::_Timeout? timeout, *wait_mode mode) -> (self | true | false)
|
|
@@ -26,7 +44,7 @@ class IO
|
|
|
26
44
|
type wait_mode = :read | :r | :readable | :write | :w | :writable | :read_write | :rw | :readable_writable
|
|
27
45
|
|
|
28
46
|
# <!--
|
|
29
|
-
# rdoc-file=io.c
|
|
47
|
+
# rdoc-file=ext/io/wait/wait.c
|
|
30
48
|
# - io.wait_readable -> truthy or falsy
|
|
31
49
|
# - io.wait_readable(timeout) -> truthy or falsy
|
|
32
50
|
# -->
|
|
@@ -34,15 +52,19 @@ class IO
|
|
|
34
52
|
# times out. Returns a truthy value immediately when buffered data is
|
|
35
53
|
# available.
|
|
36
54
|
#
|
|
55
|
+
# You must require 'io/wait' to use this method.
|
|
56
|
+
#
|
|
37
57
|
def wait_readable: (?Time::_Timeout? timeout) -> boolish
|
|
38
58
|
|
|
39
59
|
# <!--
|
|
40
|
-
# rdoc-file=io.c
|
|
60
|
+
# rdoc-file=ext/io/wait/wait.c
|
|
41
61
|
# - io.wait_writable -> truthy or falsy
|
|
42
62
|
# - io.wait_writable(timeout) -> truthy or falsy
|
|
43
63
|
# -->
|
|
44
64
|
# Waits until IO is writable and returns a truthy value or a falsy value when
|
|
45
65
|
# times out.
|
|
46
66
|
#
|
|
67
|
+
# You must require 'io/wait' to use this method.
|
|
68
|
+
#
|
|
47
69
|
def wait_writable: (?Time::_Timeout? timeout) -> boolish
|
|
48
70
|
end
|
data/core/io.rbs
CHANGED
|
@@ -1373,7 +1373,7 @@ class IO < Object
|
|
|
1373
1373
|
# Formats and writes `objects` to the stream.
|
|
1374
1374
|
#
|
|
1375
1375
|
# For details on `format_string`, see [Format
|
|
1376
|
-
# Specifications](rdoc-ref:
|
|
1376
|
+
# Specifications](rdoc-ref:format_specifications.rdoc).
|
|
1377
1377
|
#
|
|
1378
1378
|
def printf: (String format_string, *untyped objects) -> nil
|
|
1379
1379
|
|
|
@@ -2276,7 +2276,7 @@ class IO < Object
|
|
|
2276
2276
|
#
|
|
2277
2277
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2278
2278
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2279
|
-
# [Command Injection](rdoc-ref:
|
|
2279
|
+
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2280
2280
|
#
|
|
2281
2281
|
def self.binread: (String name, ?Integer? length, ?Integer offset) -> String
|
|
2282
2282
|
|
|
@@ -2289,7 +2289,7 @@ class IO < Object
|
|
|
2289
2289
|
#
|
|
2290
2290
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2291
2291
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2292
|
-
# [Command Injection](rdoc-ref:
|
|
2292
|
+
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2293
2293
|
#
|
|
2294
2294
|
def self.binwrite: (String name, _ToS string, ?Integer offset, ?mode: String mode) -> Integer
|
|
2295
2295
|
|
|
@@ -2354,16 +2354,15 @@ class IO < Object
|
|
|
2354
2354
|
# connected to a new stream `io`.
|
|
2355
2355
|
#
|
|
2356
2356
|
# This method has potential security vulnerabilities if called with untrusted
|
|
2357
|
-
# input; see [Command Injection](rdoc-ref:
|
|
2357
|
+
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2358
2358
|
#
|
|
2359
2359
|
# If no block is given, returns the new stream, which depending on given `mode`
|
|
2360
2360
|
# may be open for reading, writing, or both. The stream should be explicitly
|
|
2361
2361
|
# closed (eventually) to avoid resource leaks.
|
|
2362
2362
|
#
|
|
2363
2363
|
# If a block is given, the stream is passed to the block (again, open for
|
|
2364
|
-
# reading, writing, or both); when the block exits, the stream is closed,
|
|
2365
|
-
# block's value is
|
|
2366
|
-
# exit status.
|
|
2364
|
+
# reading, writing, or both); when the block exits, the stream is closed, and
|
|
2365
|
+
# the block's value is assigned to global variable `$?` and returned.
|
|
2367
2366
|
#
|
|
2368
2367
|
# Optional argument `mode` may be any valid IO mode. See [Access
|
|
2369
2368
|
# Modes](rdoc-ref:File@Access+Modes).
|
|
@@ -2392,7 +2391,7 @@ class IO < Object
|
|
|
2392
2391
|
# * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
|
|
2393
2392
|
# * Options for Kernel#spawn.
|
|
2394
2393
|
#
|
|
2395
|
-
# **Forked Process**
|
|
2394
|
+
# **Forked \Process**
|
|
2396
2395
|
#
|
|
2397
2396
|
# When argument `cmd` is the 1-character string `'-'`, causes the process to
|
|
2398
2397
|
# fork:
|
|
@@ -2529,7 +2528,7 @@ class IO < Object
|
|
|
2529
2528
|
#
|
|
2530
2529
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2531
2530
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2532
|
-
# [Command Injection](rdoc-ref:
|
|
2531
|
+
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2533
2532
|
#
|
|
2534
2533
|
# The first argument must be a string that is the path to a file.
|
|
2535
2534
|
#
|
|
@@ -2686,7 +2685,7 @@ class IO < Object
|
|
|
2686
2685
|
#
|
|
2687
2686
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2688
2687
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2689
|
-
# [Command Injection](rdoc-ref:
|
|
2688
|
+
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2690
2689
|
#
|
|
2691
2690
|
# The first argument must be a string that is the path to a file.
|
|
2692
2691
|
#
|
|
@@ -2729,7 +2728,7 @@ class IO < Object
|
|
|
2729
2728
|
#
|
|
2730
2729
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2731
2730
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2732
|
-
# [Command Injection](rdoc-ref:
|
|
2731
|
+
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2733
2732
|
#
|
|
2734
2733
|
# The first argument must be a string that is the path to a file.
|
|
2735
2734
|
#
|
|
@@ -2786,8 +2785,7 @@ class IO < Object
|
|
|
2786
2785
|
# IO objects.
|
|
2787
2786
|
#
|
|
2788
2787
|
# Argument `timeout` is a numeric value (such as integer or float) timeout
|
|
2789
|
-
# interval in seconds.
|
|
2790
|
-
# and `Float::INFINITY` means no timeout.
|
|
2788
|
+
# interval in seconds.
|
|
2791
2789
|
#
|
|
2792
2790
|
# The method monitors the IO objects given in all three arrays, waiting for some
|
|
2793
2791
|
# to be ready; returns a 3-element array whose elements are:
|
|
@@ -2954,7 +2952,7 @@ class IO < Object
|
|
|
2954
2952
|
#
|
|
2955
2953
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2956
2954
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2957
|
-
# [Command Injection](rdoc-ref:
|
|
2955
|
+
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2958
2956
|
#
|
|
2959
2957
|
# The first argument must be a string that is the path to a file.
|
|
2960
2958
|
#
|