|
116 | 116 | import static org.jruby.api.Create.*; |
117 | 117 | import static org.jruby.api.Define.defineClass; |
118 | 118 | import static org.jruby.api.Error.*; |
| 119 | +import static org.jruby.api.Warn.warn; |
119 | 120 | import static org.jruby.runtime.ThreadContext.*; |
120 | 121 | import static org.jruby.runtime.Visibility.*; |
121 | 122 | import static org.jruby.util.RubyStringBuilder.str; |
@@ -1381,7 +1382,7 @@ public IRubyObject syswrite(ThreadContext context, IRubyObject str) { |
1381 | 1382 |
|
1382 | 1383 | str = str.convertToString().newFrozen(); |
1383 | 1384 |
|
1384 | | - if (fptr.wbuf.len != 0) context.runtime.getWarnings().warn("syswrite for buffered IO"); |
| 1385 | + if (fptr.wbuf.len != 0) warn(context, "syswrite for buffered IO"); |
1385 | 1386 |
|
1386 | 1387 | ByteList strByteList = ((RubyString) str).getByteList(); |
1387 | 1388 | n = OpenFile.writeInternal(context, fptr, strByteList.unsafeBytes(), strByteList.begin(), strByteList.getRealSize()); |
@@ -2021,7 +2022,7 @@ public RubyFixnum sysseek(ThreadContext context, IRubyObject[] args) { |
2021 | 2022 | throw context.runtime.newIOError("sysseek for buffered IO"); |
2022 | 2023 | } |
2023 | 2024 | if (fptr.isWritable() && fptr.wbuf.len != 0) { |
2024 | | - context.runtime.getWarnings().warn("sysseek for buffered IO"); |
| 2025 | + warn(context, "sysseek for buffered IO"); |
2025 | 2026 | } |
2026 | 2027 | fptr.errno(null); |
2027 | 2028 | pos = fptr.posix.lseek(fptr.fd(), pos, whence); |
@@ -3593,7 +3594,7 @@ public IRubyObject each_byte(ThreadContext context, Block block) { |
3593 | 3594 | // rb_io_bytes |
3594 | 3595 | @JRubyMethod(name = "bytes") |
3595 | 3596 | public IRubyObject bytes(ThreadContext context, Block block) { |
3596 | | - context.runtime.getWarnings().warn("IO#bytes is deprecated; use #each_byte instead"); |
| 3597 | + warn(context, "IO#bytes is deprecated; use #each_byte instead"); |
3597 | 3598 | return each_byte(context, block); |
3598 | 3599 | } |
3599 | 3600 |
|
@@ -3630,13 +3631,13 @@ public IRubyObject each_char(ThreadContext context, Block block) { |
3630 | 3631 |
|
3631 | 3632 | @JRubyMethod(name = "chars") |
3632 | 3633 | public IRubyObject chars(ThreadContext context, Block block) { |
3633 | | - context.runtime.getWarnings().warn("IO#chars is deprecated; use #each_char instead"); |
| 3634 | + warn(context, "IO#chars is deprecated; use #each_char instead"); |
3634 | 3635 | return each_charInternal(context, block); |
3635 | 3636 | } |
3636 | 3637 |
|
3637 | 3638 | @JRubyMethod |
3638 | 3639 | public IRubyObject codepoints(ThreadContext context, Block block) { |
3639 | | - context.runtime.getWarnings().warn("IO#codepoints is deprecated; use #each_codepoint instead"); |
| 3640 | + warn(context, "IO#codepoints is deprecated; use #each_codepoint instead"); |
3640 | 3641 | return eachCodePointCommon(context, block, "each_codepoint"); |
3641 | 3642 | } |
3642 | 3643 |
|
@@ -3839,7 +3840,7 @@ public IRubyObject each_line(final ThreadContext context, IRubyObject[]args, fin |
3839 | 3840 |
|
3840 | 3841 | @JRubyMethod(name = "lines") |
3841 | 3842 | public IRubyObject lines(final ThreadContext context, Block block) { |
3842 | | - context.runtime.getWarnings().warn("IO#lines is deprecated; use #each_line instead"); |
| 3843 | + warn(context, "IO#lines is deprecated; use #each_line instead"); |
3843 | 3844 | return each_line(context, block); |
3844 | 3845 | } |
3845 | 3846 |
|
@@ -4217,7 +4218,7 @@ private static RubyIO ioOpenGeneric(ThreadContext context, IRubyObject recv, IRu |
4217 | 4218 | if ((filename instanceof RubyString name) && name.isEmpty()) throw context.runtime.newErrnoENOENTError(); |
4218 | 4219 |
|
4219 | 4220 | if ((recv == ioClass(context)) && (cmd = PopenExecutor.checkPipeCommand(context, filename)) != context.nil) { |
4220 | | - context.runtime.getWarnings().warn("IO process creation with a leading '|' is deprecated and will be removed in Ruby 4.0; use IO.popen instead"); |
| 4221 | + warn(context, "IO process creation with a leading '|' is deprecated and will be removed in Ruby 4.0; use IO.popen instead"); |
4221 | 4222 | if (PopenExecutor.nativePopenAvailable(context.runtime)) { |
4222 | 4223 | return (RubyIO) PopenExecutor.pipeOpen(context, cmd, OpenFile.ioOflagsModestr(context, oflags), fmode, convconfig); |
4223 | 4224 | } else { |
@@ -5327,9 +5328,7 @@ public static void checkPopenOptions(IRubyObject options) { |
5327 | 5328 |
|
5328 | 5329 | static void checkUnsupportedOptions(ThreadContext context, RubyHash opts, String[] unsupported, String error) { |
5329 | 5330 | for (String key : unsupported) { |
5330 | | - if (opts.fastARef(asSymbol(context, key)) != null) { |
5331 | | - context.runtime.getWarnings().warn(error + ": " + key); |
5332 | | - } |
| 5331 | + if (opts.fastARef(asSymbol(context, key)) != null) warn(context, error + ": " + key); |
5333 | 5332 | } |
5334 | 5333 | } |
5335 | 5334 |
|
|
0 commit comments