Add deprecations for public struct rb_io members. (#7916)

* Add deprecations for public struct rb_io members.
This commit is contained in:
Samuel Williams 2023-06-08 20:22:43 +09:00 committed by GitHub
parent d6bddcb013
commit 3fe09eba9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2023-06-08 11:23:12 +00:00
Merged-By: ioquatix <samuel@codeotaku.com>
4 changed files with 128 additions and 12 deletions

View File

@ -585,6 +585,7 @@ objspace_dump.o: $(top_srcdir)/internal/compilers.h
objspace_dump.o: $(top_srcdir)/internal/gc.h objspace_dump.o: $(top_srcdir)/internal/gc.h
objspace_dump.o: $(top_srcdir)/internal/hash.h objspace_dump.o: $(top_srcdir)/internal/hash.h
objspace_dump.o: $(top_srcdir)/internal/imemo.h objspace_dump.o: $(top_srcdir)/internal/imemo.h
objspace_dump.o: $(top_srcdir)/internal/io.h
objspace_dump.o: $(top_srcdir)/internal/sanitizers.h objspace_dump.o: $(top_srcdir)/internal/sanitizers.h
objspace_dump.o: $(top_srcdir)/internal/serial.h objspace_dump.o: $(top_srcdir)/internal/serial.h
objspace_dump.o: $(top_srcdir)/internal/static_assert.h objspace_dump.o: $(top_srcdir)/internal/static_assert.h

View File

@ -18,6 +18,7 @@
#include "internal/class.h" #include "internal/class.h"
#include "internal/gc.h" #include "internal/gc.h"
#include "internal/hash.h" #include "internal/hash.h"
#include "internal/io.h"
#include "internal/string.h" #include "internal/string.h"
#include "internal/sanitizers.h" #include "internal/sanitizers.h"
#include "symbol.h" #include "symbol.h"

View File

@ -137,40 +137,50 @@ struct rb_io_encoding {
VALUE ecopts; VALUE ecopts;
}; };
#ifndef HAVE_RB_IO_T
/** Ruby's IO, metadata and buffers. */ /** Ruby's IO, metadata and buffers. */
typedef struct rb_io { struct rb_io {
/** The IO's Ruby level counterpart. */ /** The IO's Ruby level counterpart. */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
VALUE self; VALUE self;
/** stdio ptr for read/write, if available. */ /** stdio ptr for read/write, if available. */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
FILE *stdio_file; FILE *stdio_file;
/** file descriptor. */ /** file descriptor. */
RBIMPL_ATTR_DEPRECATED(("rb_io_descriptor"))
int fd; int fd;
/** mode flags: FMODE_XXXs */ /** mode flags: FMODE_XXXs */
RBIMPL_ATTR_DEPRECATED(("rb_io_mode"))
int mode; int mode;
/** child's pid (for pipes) */ /** child's pid (for pipes) */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
rb_pid_t pid; rb_pid_t pid;
/** number of lines read */ /** number of lines read */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
int lineno; int lineno;
/** pathname for file */ /** pathname for file */
RBIMPL_ATTR_DEPRECATED(("rb_io_path"))
VALUE pathv; VALUE pathv;
/** finalize proc */ /** finalize proc */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
void (*finalize)(struct rb_io*,int); void (*finalize)(struct rb_io*,int);
/** Write buffer. */ /** Write buffer. */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
rb_io_buffer_t wbuf; rb_io_buffer_t wbuf;
/** /**
* (Byte) read buffer. Note also that there is a field called * (Byte) read buffer. Note also that there is a field called
* ::rb_io_t::cbuf, which also concerns read IO. * ::rb_io_t::cbuf, which also concerns read IO.
*/ */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
rb_io_buffer_t rbuf; rb_io_buffer_t rbuf;
/** /**
@ -178,20 +188,25 @@ typedef struct rb_io {
* *
* @see rb_io_set_write_io() * @see rb_io_set_write_io()
*/ */
RBIMPL_ATTR_DEPRECATED(("rb_io_get_write_io"))
VALUE tied_io_for_writing; VALUE tied_io_for_writing;
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
struct rb_io_encoding encs; /**< Decomposed encoding flags. */ struct rb_io_encoding encs; /**< Decomposed encoding flags. */
/** Encoding converter used when reading from this IO. */ /** Encoding converter used when reading from this IO. */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
rb_econv_t *readconv; rb_econv_t *readconv;
/** /**
* rb_io_ungetc() destination. This buffer is read before checking * rb_io_ungetc() destination. This buffer is read before checking
* ::rb_io_t::rbuf * ::rb_io_t::rbuf
*/ */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
rb_io_buffer_t cbuf; rb_io_buffer_t cbuf;
/** Encoding converter used when writing to this IO. */ /** Encoding converter used when writing to this IO. */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
rb_econv_t *writeconv; rb_econv_t *writeconv;
/** /**
@ -200,21 +215,25 @@ typedef struct rb_io {
* conversion from encoding X to encoding Y does not exist, Ruby finds an * conversion from encoding X to encoding Y does not exist, Ruby finds an
* encoding Z that bridges the two, so that X to Z to Y conversion happens. * encoding Z that bridges the two, so that X to Z to Y conversion happens.
*/ */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
VALUE writeconv_asciicompat; VALUE writeconv_asciicompat;
/** Whether ::rb_io_t::writeconv is already set up. */ /** Whether ::rb_io_t::writeconv is already set up. */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
int writeconv_initialized; int writeconv_initialized;
/** /**
* Value of ::rb_io_t::rb_io_enc_t::ecflags stored right before * Value of ::rb_io_t::rb_io_enc_t::ecflags stored right before
* initialising ::rb_io_t::writeconv. * initialising ::rb_io_t::writeconv.
*/ */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
int writeconv_pre_ecflags; int writeconv_pre_ecflags;
/** /**
* Value of ::rb_io_t::rb_io_enc_t::ecopts stored right before initialising * Value of ::rb_io_t::rb_io_enc_t::ecopts stored right before initialising
* ::rb_io_t::writeconv. * ::rb_io_t::writeconv.
*/ */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
VALUE writeconv_pre_ecopts; VALUE writeconv_pre_ecopts;
/** /**
@ -224,26 +243,22 @@ typedef struct rb_io {
* *
* This of course doesn't help inter-process IO interleaves, though. * This of course doesn't help inter-process IO interleaves, though.
*/ */
RBIMPL_ATTR_DEPRECATED(("with no replacement"))
VALUE write_lock; VALUE write_lock;
/** /**
* The timeout associated with this IO when performing blocking operations. * The timeout associated with this IO when performing blocking operations.
*/ */
RBIMPL_ATTR_DEPRECATED(("rb_io_timeout/rb_io_set_timeout"))
VALUE timeout; VALUE timeout;
} rb_io_t; };
#endif
typedef struct rb_io rb_io_t;
/** @alias{rb_io_enc_t} */ /** @alias{rb_io_enc_t} */
typedef struct rb_io_encoding rb_io_enc_t; typedef struct rb_io_encoding rb_io_enc_t;
/**
* @private
*
* @deprecated This macro once was a thing in the old days, but makes no sense
* any longer today. Exists here for backwards compatibility
* only. You can safely forget about it.
*/
#define HAVE_RB_IO_T 1
/** /**
* @name Possible flags for ::rb_io_t::mode * @name Possible flags for ::rb_io_t::mode
* *

View File

@ -9,8 +9,107 @@
* @brief Internal header for IO. * @brief Internal header for IO.
*/ */
#include "ruby/ruby.h" /* for VALUE */ #include "ruby/ruby.h" /* for VALUE */
#define HAVE_RB_IO_T
struct rb_io;
#include "ruby/io.h" /* for rb_io_t */ #include "ruby/io.h" /* for rb_io_t */
/** Ruby's IO, metadata and buffers. */
typedef struct rb_io {
/** The IO's Ruby level counterpart. */
VALUE self;
/** stdio ptr for read/write, if available. */
FILE *stdio_file;
/** file descriptor. */
int fd;
/** mode flags: FMODE_XXXs */
int mode;
/** child's pid (for pipes) */
rb_pid_t pid;
/** number of lines read */
int lineno;
/** pathname for file */
VALUE pathv;
/** finalize proc */
void (*finalize)(struct rb_io*,int);
/** Write buffer. */
rb_io_buffer_t wbuf;
/**
* (Byte) read buffer. Note also that there is a field called
* ::rb_io_t::cbuf, which also concerns read IO.
*/
rb_io_buffer_t rbuf;
/**
* Duplex IO object, if set.
*
* @see rb_io_set_write_io()
*/
VALUE tied_io_for_writing;
struct rb_io_encoding encs; /**< Decomposed encoding flags. */
/** Encoding converter used when reading from this IO. */
rb_econv_t *readconv;
/**
* rb_io_ungetc() destination. This buffer is read before checking
* ::rb_io_t::rbuf
*/
rb_io_buffer_t cbuf;
/** Encoding converter used when writing to this IO. */
rb_econv_t *writeconv;
/**
* This is, when set, an instance of ::rb_cString which holds the "common"
* encoding. Write conversion can convert strings twice... In case
* conversion from encoding X to encoding Y does not exist, Ruby finds an
* encoding Z that bridges the two, so that X to Z to Y conversion happens.
*/
VALUE writeconv_asciicompat;
/** Whether ::rb_io_t::writeconv is already set up. */
int writeconv_initialized;
/**
* Value of ::rb_io_t::rb_io_enc_t::ecflags stored right before
* initialising ::rb_io_t::writeconv.
*/
int writeconv_pre_ecflags;
/**
* Value of ::rb_io_t::rb_io_enc_t::ecopts stored right before initialising
* ::rb_io_t::writeconv.
*/
VALUE writeconv_pre_ecopts;
/**
* This is a Ruby level mutex. It avoids multiple threads to write to an
* IO at once; helps for instance rb_io_puts() to ensure newlines right
* next to its arguments.
*
* This of course doesn't help inter-process IO interleaves, though.
*/
VALUE write_lock;
/**
* The timeout associated with this IO when performing blocking operations.
*/
VALUE timeout;
} rb_io_t;
/* io.c */ /* io.c */
void ruby_set_inplace_mode(const char *); void ruby_set_inplace_mode(const char *);
void rb_stdio_set_default_encoding(void); void rb_stdio_set_default_encoding(void);