Ruby  3.1.4p223 (2023-03-30 revision HEAD)
Data Structures | Data Fields
rb_io_t Struct Reference

Ruby's IO, metadata and buffers. More...

#include <io.h>

Data Structures

struct  rb_io_enc_t
 Decomposed encoding flags (e.g. More...
 

Data Fields

VALUE self
 The IO's Ruby level counterpart. More...
 
FILEstdio_file
 stdio ptr for read/write, if available. More...
 
int fd
 file descriptor. More...
 
int mode
 mode flags: FMODE_XXXs More...
 
rb_pid_t pid
 child's pid (for pipes) More...
 
int lineno
 number of lines read More...
 
VALUE pathv
 pathname for file More...
 
void(* finalize )(struct rb_io_t *, int)
 finalize proc More...
 
rb_io_buffer_t wbuf
 Write buffer. More...
 
rb_io_buffer_t rbuf
 (Byte) read buffer. More...
 
VALUE tied_io_for_writing
 Duplex IO object, if set. More...
 
struct rb_io_t::rb_io_enc_t encs
 Decomposed encoding flags. More...
 
rb_econv_treadconv
 Encoding converter used when reading from this IO. More...
 
rb_io_buffer_t cbuf
 rb_io_ungetc() destination. More...
 
rb_econv_twriteconv
 Encoding converter used when writing to this IO. More...
 
VALUE writeconv_asciicompat
 This is, when set, an instance of rb_cString which holds the "common" encoding. More...
 
int writeconv_initialized
 Whether rb_io_t::writeconv is already set up. More...
 
int writeconv_pre_ecflags
 Value of rb_io_t::rb_io_enc_t::ecflags stored right before initialising rb_io_t::writeconv. More...
 
VALUE writeconv_pre_ecopts
 Value of rb_io_t::rb_io_enc_t::ecopts stored right before initialising rb_io_t::writeconv. More...
 
VALUE write_lock
 This is a Ruby level mutex. More...
 

Detailed Description

Ruby's IO, metadata and buffers.

Definition at line 95 of file io.h.

Field Documentation

◆ cbuf

rb_io_buffer_t rb_io_t::cbuf

rb_io_ungetc() destination.

This buffer is read before checking rb_io_t::rbuf

Definition at line 175 of file io.h.

Referenced by rb_io_ungetc().

◆ encs

struct rb_io_t::rb_io_enc_t rb_io_t::encs

Decomposed encoding flags.

◆ fd

int rb_io_t::fd

◆ finalize

void(* rb_io_t::finalize) (struct rb_io_t *, int)

finalize proc

Definition at line 119 of file io.h.

◆ lineno

int rb_io_t::lineno

number of lines read

Definition at line 113 of file io.h.

◆ mode

int rb_io_t::mode

◆ pathv

VALUE rb_io_t::pathv

pathname for file

Definition at line 116 of file io.h.

Referenced by rb_file_size(), and rb_io_set_nonblock().

◆ pid

rb_pid_t rb_io_t::pid

child's pid (for pipes)

Definition at line 110 of file io.h.

◆ rbuf

rb_io_buffer_t rb_io_t::rbuf

(Byte) read buffer.

Note also that there is a field called rb_io_t::cbuf, which also concerns read IO.

Definition at line 128 of file io.h.

Referenced by rb_io_check_writable(), and rb_io_getbyte().

◆ readconv

rb_econv_t* rb_io_t::readconv

Encoding converter used when reading from this IO.

Definition at line 169 of file io.h.

Referenced by rb_io_binmode().

◆ self

VALUE rb_io_t::self

The IO's Ruby level counterpart.

Definition at line 98 of file io.h.

Referenced by rb_io_read_check().

◆ stdio_file

FILE* rb_io_t::stdio_file

stdio ptr for read/write, if available.

Definition at line 101 of file io.h.

Referenced by rb_io_stdio_file().

◆ tied_io_for_writing

VALUE rb_io_t::tied_io_for_writing

Duplex IO object, if set.

See also
rb_io_set_write_io()

Definition at line 135 of file io.h.

Referenced by rb_io_check_char_readable(), rb_io_get_write_io(), and rb_io_set_write_io().

◆ wbuf

rb_io_buffer_t rb_io_t::wbuf

Write buffer.

Definition at line 122 of file io.h.

Referenced by rb_io_check_char_readable().

◆ write_lock

VALUE rb_io_t::write_lock

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.

Definition at line 210 of file io.h.

◆ writeconv

rb_econv_t* rb_io_t::writeconv

Encoding converter used when writing to this IO.

Definition at line 178 of file io.h.

Referenced by rb_io_binmode().

◆ writeconv_asciicompat

VALUE rb_io_t::writeconv_asciicompat

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.

Definition at line 186 of file io.h.

◆ writeconv_initialized

int rb_io_t::writeconv_initialized

Whether rb_io_t::writeconv is already set up.

Definition at line 189 of file io.h.

◆ writeconv_pre_ecflags

int rb_io_t::writeconv_pre_ecflags

Value of rb_io_t::rb_io_enc_t::ecflags stored right before initialising rb_io_t::writeconv.

Definition at line 195 of file io.h.

Referenced by rb_io_binmode().

◆ writeconv_pre_ecopts

VALUE rb_io_t::writeconv_pre_ecopts

Value of rb_io_t::rb_io_enc_t::ecopts stored right before initialising rb_io_t::writeconv.

Definition at line 201 of file io.h.


The documentation for this struct was generated from the following file: