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.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -2
  3. data/.github/workflows/ruby.yml +24 -34
  4. data/.github/workflows/typecheck.yml +3 -1
  5. data/.github/workflows/windows.yml +2 -2
  6. data/.gitignore +0 -4
  7. data/CHANGELOG.md +0 -107
  8. data/README.md +1 -38
  9. data/Rakefile +20 -142
  10. data/Steepfile +1 -0
  11. data/config.yml +43 -1
  12. data/core/array.rbs +46 -96
  13. data/core/comparable.rbs +6 -13
  14. data/core/complex.rbs +25 -40
  15. data/core/dir.rbs +4 -4
  16. data/core/encoding.rbs +9 -6
  17. data/core/enumerable.rbs +3 -90
  18. data/core/enumerator.rbs +1 -43
  19. data/core/errno.rbs +0 -8
  20. data/core/errors.rbs +1 -28
  21. data/core/exception.rbs +2 -2
  22. data/core/fiber.rbs +20 -29
  23. data/core/file.rbs +19 -49
  24. data/core/file_test.rbs +1 -1
  25. data/core/float.rbs +33 -224
  26. data/core/gc.rbs +281 -417
  27. data/core/hash.rbs +727 -1023
  28. data/core/integer.rbs +63 -104
  29. data/core/io/buffer.rbs +10 -21
  30. data/core/io/wait.rbs +33 -11
  31. data/core/io.rbs +12 -14
  32. data/core/kernel.rbs +51 -61
  33. data/core/marshal.rbs +1 -1
  34. data/core/match_data.rbs +1 -1
  35. data/core/math.rbs +3 -42
  36. data/core/method.rbs +25 -63
  37. data/core/module.rbs +23 -101
  38. data/core/nil_class.rbs +3 -3
  39. data/core/numeric.rbs +17 -25
  40. data/core/object.rbs +3 -3
  41. data/core/object_space.rbs +15 -21
  42. data/core/proc.rbs +24 -30
  43. data/core/process.rbs +2 -2
  44. data/core/ractor.rbs +509 -361
  45. data/core/range.rbs +8 -7
  46. data/core/rational.rbs +34 -56
  47. data/core/rbs/unnamed/argf.rbs +2 -2
  48. data/core/rbs/unnamed/env_class.rbs +1 -1
  49. data/core/rbs/unnamed/random.rbs +2 -4
  50. data/core/regexp.rbs +20 -25
  51. data/core/ruby_vm.rbs +4 -6
  52. data/core/rubygems/errors.rbs +70 -3
  53. data/core/rubygems/rubygems.rbs +79 -11
  54. data/core/rubygems/version.rbs +3 -2
  55. data/core/set.rbs +359 -488
  56. data/core/signal.rbs +14 -24
  57. data/core/string.rbs +1236 -3165
  58. data/core/struct.rbs +1 -1
  59. data/core/symbol.rbs +11 -17
  60. data/core/thread.rbs +33 -95
  61. data/core/time.rbs +9 -35
  62. data/core/trace_point.rbs +4 -7
  63. data/core/unbound_method.rbs +6 -14
  64. data/docs/collection.md +2 -2
  65. data/docs/gem.md +1 -0
  66. data/docs/sigs.md +3 -3
  67. data/ext/rbs_extension/ast_translation.c +1077 -944
  68. data/ext/rbs_extension/ast_translation.h +0 -7
  69. data/ext/rbs_extension/class_constants.c +83 -71
  70. data/ext/rbs_extension/class_constants.h +7 -4
  71. data/ext/rbs_extension/extconf.rb +2 -24
  72. data/ext/rbs_extension/legacy_location.c +172 -173
  73. data/ext/rbs_extension/legacy_location.h +3 -8
  74. data/ext/rbs_extension/main.c +289 -239
  75. data/ext/rbs_extension/rbs_extension.h +0 -3
  76. data/ext/rbs_extension/rbs_string_bridging.h +0 -4
  77. data/include/rbs/ast.h +98 -37
  78. data/include/rbs/defines.h +12 -38
  79. data/include/rbs/lexer.h +114 -126
  80. data/include/rbs/location.h +14 -14
  81. data/include/rbs/parser.h +37 -21
  82. data/include/rbs/string.h +5 -3
  83. data/include/rbs/util/rbs_allocator.h +19 -40
  84. data/include/rbs/util/rbs_assert.h +1 -12
  85. data/include/rbs/util/rbs_constant_pool.h +3 -3
  86. data/include/rbs/util/rbs_encoding.h +1 -3
  87. data/include/rbs/util/rbs_unescape.h +1 -2
  88. data/lib/rbs/ast/ruby/annotations.rb +119 -0
  89. data/lib/rbs/ast/ruby/comment_block.rb +221 -0
  90. data/lib/rbs/ast/ruby/declarations.rb +86 -0
  91. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +24 -0
  92. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  93. data/lib/rbs/ast/ruby/members.rb +213 -0
  94. data/lib/rbs/buffer.rb +104 -24
  95. data/lib/rbs/cli/validate.rb +40 -35
  96. data/lib/rbs/cli.rb +5 -6
  97. data/lib/rbs/collection/config/lockfile_generator.rb +0 -8
  98. data/lib/rbs/collection.rb +0 -1
  99. data/lib/rbs/definition.rb +6 -1
  100. data/lib/rbs/definition_builder/ancestor_builder.rb +65 -62
  101. data/lib/rbs/definition_builder/method_builder.rb +45 -30
  102. data/lib/rbs/definition_builder.rb +44 -9
  103. data/lib/rbs/environment/class_entry.rb +69 -0
  104. data/lib/rbs/environment/module_entry.rb +66 -0
  105. data/lib/rbs/environment.rb +244 -218
  106. data/lib/rbs/environment_loader.rb +8 -2
  107. data/lib/rbs/errors.rb +5 -4
  108. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  109. data/lib/rbs/inline_parser.rb +206 -0
  110. data/lib/rbs/location_aux.rb +35 -3
  111. data/lib/rbs/parser_aux.rb +11 -6
  112. data/lib/rbs/prototype/runtime.rb +2 -2
  113. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  114. data/lib/rbs/resolver/type_name_resolver.rb +38 -124
  115. data/lib/rbs/source.rb +99 -0
  116. data/lib/rbs/subtractor.rb +5 -6
  117. data/lib/rbs/test/type_check.rb +0 -14
  118. data/lib/rbs/types.rb +1 -3
  119. data/lib/rbs/version.rb +1 -1
  120. data/lib/rbs.rb +13 -1
  121. data/lib/rdoc/discover.rb +1 -1
  122. data/lib/rdoc_plugin/parser.rb +1 -1
  123. data/rbs.gemspec +1 -0
  124. data/sig/ancestor_builder.rbs +1 -1
  125. data/sig/ast/ruby/annotations.rbs +110 -0
  126. data/sig/ast/ruby/comment_block.rbs +119 -0
  127. data/sig/ast/ruby/declarations.rbs +60 -0
  128. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  129. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  130. data/sig/ast/ruby/members.rbs +72 -0
  131. data/sig/buffer.rbs +63 -5
  132. data/sig/definition.rbs +1 -0
  133. data/sig/definition_builder.rbs +1 -1
  134. data/sig/environment/class_entry.rbs +50 -0
  135. data/sig/environment/module_entry.rbs +50 -0
  136. data/sig/environment.rbs +28 -133
  137. data/sig/errors.rbs +13 -6
  138. data/sig/inline_parser/comment_association.rbs +71 -0
  139. data/sig/inline_parser.rbs +87 -0
  140. data/sig/location.rbs +32 -7
  141. data/sig/manifest.yaml +1 -0
  142. data/sig/method_builder.rbs +7 -4
  143. data/sig/parser.rbs +16 -20
  144. data/sig/resolver/type_name_resolver.rbs +7 -38
  145. data/sig/source.rbs +48 -0
  146. data/sig/types.rbs +1 -4
  147. data/src/ast.c +290 -201
  148. data/src/lexer.c +2813 -2902
  149. data/src/lexer.re +4 -0
  150. data/src/lexstate.c +155 -169
  151. data/src/location.c +40 -40
  152. data/src/parser.c +2665 -2433
  153. data/src/string.c +48 -0
  154. data/src/util/rbs_allocator.c +76 -92
  155. data/src/util/rbs_assert.c +10 -10
  156. data/src/util/rbs_buffer.c +2 -2
  157. data/src/util/rbs_constant_pool.c +15 -13
  158. data/src/util/rbs_encoding.c +4062 -20097
  159. data/src/util/rbs_unescape.c +48 -85
  160. data/stdlib/bigdecimal/0/big_decimal.rbs +82 -100
  161. data/stdlib/bigdecimal-math/0/big_math.rbs +8 -169
  162. data/stdlib/cgi/0/core.rbs +393 -9
  163. data/stdlib/cgi/0/manifest.yaml +0 -1
  164. data/stdlib/coverage/0/coverage.rbs +1 -3
  165. data/stdlib/date/0/date.rbs +59 -67
  166. data/stdlib/date/0/date_time.rbs +1 -1
  167. data/stdlib/delegate/0/delegator.rbs +7 -10
  168. data/stdlib/erb/0/erb.rbs +347 -737
  169. data/stdlib/fileutils/0/fileutils.rbs +13 -18
  170. data/stdlib/forwardable/0/forwardable.rbs +0 -3
  171. data/stdlib/json/0/json.rbs +48 -68
  172. data/stdlib/net-http/0/net-http.rbs +0 -3
  173. data/stdlib/objspace/0/objspace.rbs +4 -9
  174. data/stdlib/open-uri/0/open-uri.rbs +0 -40
  175. data/stdlib/openssl/0/openssl.rbs +228 -331
  176. data/stdlib/optparse/0/optparse.rbs +3 -3
  177. data/stdlib/pathname/0/pathname.rbs +1380 -10
  178. data/stdlib/psych/0/psych.rbs +3 -3
  179. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  180. data/stdlib/resolv/0/resolv.rbs +68 -25
  181. data/stdlib/ripper/0/ripper.rbs +2 -5
  182. data/stdlib/singleton/0/singleton.rbs +0 -3
  183. data/stdlib/socket/0/socket.rbs +1 -13
  184. data/stdlib/socket/0/tcp_socket.rbs +2 -10
  185. data/stdlib/stringio/0/stringio.rbs +85 -1176
  186. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  187. data/stdlib/tempfile/0/tempfile.rbs +3 -3
  188. data/stdlib/time/0/time.rbs +1 -1
  189. data/stdlib/timeout/0/timeout.rbs +7 -63
  190. data/stdlib/tsort/0/cyclic.rbs +0 -3
  191. data/stdlib/uri/0/common.rbs +2 -11
  192. data/stdlib/uri/0/file.rbs +1 -1
  193. data/stdlib/uri/0/generic.rbs +16 -17
  194. data/stdlib/uri/0/rfc2396_parser.rbs +7 -6
  195. data/stdlib/zlib/0/zstream.rbs +0 -1
  196. metadata +39 -12
  197. data/.clang-format +0 -74
  198. data/.clangd +0 -2
  199. data/.github/workflows/c-check.yml +0 -54
  200. data/core/pathname.rbs +0 -1272
  201. data/core/ruby.rbs +0 -53
  202. data/docs/aliases.md +0 -79
  203. data/docs/encoding.md +0 -56
  204. data/ext/rbs_extension/compat.h +0 -10
  205. 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 -> real_numeric
149
+ # - self % other -> real_number
150
150
  # -->
151
- # Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
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 * other -> numeric
196
+ # - self * numeric -> numeric_result
197
197
  # -->
198
- # Returns the numeric product of `self` and `other`:
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 ** exponent -> numeric
214
+ # - self ** numeric -> numeric_result
215
215
  # -->
216
- # Returns `self` raised to the power `exponent`:
217
- #
218
- # # Result for non-negative Integer exponent is Integer.
219
- # 2 ** 0 # => 1
220
- # 2 ** 1 # => 2
221
- # 2 ** 2 # => 4
222
- # 2 ** 3 # => 8
223
- # -2 ** 3 # => -8
224
- # # Result for negative Integer exponent is Rational, not Float.
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 + other -> numeric
233
+ # - self + numeric -> numeric_result
264
234
  # -->
265
- # Returns the sum of `self` and `other`:
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
- # 1 + 3.14 # => 4.140000000000001
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 - other -> numeric
253
+ # - self - numeric -> numeric_result
288
254
  # -->
289
- # Returns the difference of `self` and `other`:
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
- # - -self -> integer
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 / other -> numeric
279
+ # - self / numeric -> numeric_result
318
280
  # -->
319
- # Returns the quotient of `self` and `other`.
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
- # 4 / 3 # => 1
324
- # 4 / -3 # => -2
325
- # -4 / 3 # => -2
326
- # -4 / -3 # => 1
283
+ # 4 / 3 # => 1
284
+ # 4 / -3 # => -2
285
+ # -4 / 3 # => -2
286
+ # -4 / -3 # => 1
327
287
  #
328
- # For non-integer `other`, returns a non-integer result:
288
+ # For other +numeric+, returns non-integer result:
329
289
  #
330
- # 4 / 3.0 # => 1.3333333333333333
331
- # 4 / Rational(3, 1) # => (4/3)
332
- # 4 / Complex(3, 0) # => ((4/3)+0i)
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 whether the value of `self` is less than the value of `other`; `other`
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
- # 1 < 0 # => false
347
- # 1 < 1 # => false
348
- # 1 < 2 # => true
349
- # 1 < 0.5 # => false
350
- # 1 < Rational(1, 2) # => false
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 <= other -> true or false
334
+ # - self <= real -> true or false
374
335
  # -->
375
- # Returns whether the value of `self` is less than or equal to the value of
376
- # `other`; `other` must be numeric, but may not be Complex:
336
+ # Returns `true` if the value of `self` is less than or equal to that of
337
+ # `other`:
377
338
  #
378
- # 1 <= 0 # => false
379
- # 1 <= 1 # => true
380
- # 1 <= 2 # => true
381
- # 1 <= 0.5 # => false
382
- # 1 <= Rational(1, 2) # => false
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
- # Raises an exception if the comparison cannot be made.
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 -> -1, 0, 1, or nil
351
+ # - self <=> other -> -1, 0, +1, or nil
391
352
  # -->
392
- # Compares `self` and `other`.
393
- #
394
353
  # Returns:
395
354
  #
396
- # * `-1`, if `self` is less than `other`.
397
- # * `0`, if `self` is equal to `other`.
398
- # * `1`, if `self` is greater then `other`.
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
- # Class Integer includes module Comparable, each of whose methods uses
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 numeric (Integer, Float, or Rational).
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'), nil, 0, IO::Buffer::READONLY)
67
+ # buffer = IO::Buffer.map(File.open('test.txt'))
68
68
  # # =>
69
- # # #<IO::Buffer 0x00007f3f0768c000+9 EXTERNAL MAPPED FILE SHARED READONLY>
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
- # # => "test"
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
- # `file` should be a `File` instance, opened for reading or reading and writing.
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
- # By default, the buffer is writable and expects the file to be writable. It is
141
- # also shared, so several processes can use the same mapping.
136
+ # Optional `size` and `offset` of mapping can be specified.
142
137
  #
143
- # You can pass IO::Buffer::READONLY in `flags` argument to make a read-only
144
- # buffer; this allows to work with files opened only for reading. Specifying
145
- # IO::Buffer::PRIVATE in `flags` creates a private mapping, which will not
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 EXTERNAL MAPPED FILE SHARED READONLY>
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
- # # 'IO::Buffer#set_string': Buffer is not writable! (IO::Buffer::AccessError)
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(*event_symbols[, timeout]) -> self, true, or false
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 an event mask (truthy value) immediately when buffered data is
15
- # available.
35
+ # Returns a truthy value immediately when buffered data is available.
16
36
  #
17
- # The second form: if one or more event symbols (`:read`, `:write`, or
18
- # `:read_write`) are passed, the event mask is the bit OR of the bitmask
19
- # corresponding to those symbols. In this form, `timeout` is optional, the
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:language/format_specifications.rdoc).
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:security/command_injection.rdoc).
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:security/command_injection.rdoc).
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:security/command_injection.rdoc).
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, the
2365
- # block's value is returned, and the global variable `$?` is set to the child's
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:security/command_injection.rdoc).
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:security/command_injection.rdoc).
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:security/command_injection.rdoc).
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. `timeout` can also be `nil` or `Float::INFINITY`. `nil`
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:security/command_injection.rdoc).
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
  #