diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2023-06-01 14:23:30 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-01 14:23:30 +0900 |
commit | a218ed569243e7544d8c4e3b348245a17f6c6a51 (patch) | |
tree | 6e439e7661b110bf2b3ee9fa6e2b8df54e72a92a /include | |
parent | 35da41b29bf0a1a8fd2cd7e1d7fcb036ca8c2c7c (diff) | |
download | ruby-a218ed569243e7544d8c4e3b348245a17f6c6a51.tar.gz |
Hide the usage of `rb_io_t` where possible. (#7880)
This retries the compatible parts of the previously reverted PR so we can continue to update related code without breaking backwards compatibility.
Diffstat (limited to 'include')
-rw-r--r-- | include/ruby/io.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/include/ruby/io.h b/include/ruby/io.h index 8be83a215c..9b05c7b164 100644 --- a/include/ruby/io.h +++ b/include/ruby/io.h @@ -331,7 +331,16 @@ typedef struct rb_io_enc_t rb_io_enc_t; * Setting this one and #FMODE_BINMODE at the same time is a contradiction. */ #define FMODE_TEXTMODE 0x00001000 -/* #define FMODE_PREP 0x00010000 */ +/** + * This flag means that an IO object is wrapping an "external" file descriptor, + * which is owned by something outside the Ruby interpreter (usually a C extension). + * Ruby will not close this file when the IO object is garbage collected. + * If this flag is set, then IO#autoclose? is false, and vice-versa. + * + * This flag was previously called FMODE_PREP internally. + */ +#define FMODE_EXTERNAL 0x00010000 + /* #define FMODE_SIGNAL_ON_EPIPE 0x00020000 */ /** @@ -346,6 +355,18 @@ typedef struct rb_io_enc_t rb_io_enc_t; /** @} */ /** + * Allocate a new IO object, with the given file descriptor. + */ +VALUE rb_io_open_descriptor(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, struct rb_io_enc_t *encoding); + +/** + * Returns whether or not the underlying IO is closed. + * + * @return Whether the underlying IO is closed. + */ +VALUE rb_io_closed_p(VALUE io); + +/** * Queries the underlying IO pointer. * * @param[in] obj An IO object. @@ -704,6 +725,12 @@ VALUE rb_io_set_write_io(VALUE io, VALUE w); void rb_io_set_nonblock(rb_io_t *fptr); /** + * Returns the path for the given IO. + * + */ +VALUE rb_io_path(VALUE io); + +/** * Returns an integer representing the numeric file descriptor for * <em>io</em>. * @@ -713,6 +740,12 @@ void rb_io_set_nonblock(rb_io_t *fptr); int rb_io_descriptor(VALUE io); /** + * Get the mode of the IO. + * + */ +int rb_io_mode(VALUE io); + +/** * This function breaks down the option hash that `IO#initialize` takes into * components. This is an implementation detail of rb_io_extract_modeenc() * today. People prefer that API instead. |