raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Samuel Williams <samuel.williams@oriontransfer.co.nz>
To: raindrops-public@yhbt.net
Cc: Samuel Williams <samuel.williams@oriontransfer.co.nz>
Subject: [PATCH] Improve compatibility with Ruby 3.3+
Date: Fri,  9 Jun 2023 19:48:05 +0900	[thread overview]
Message-ID: <20230609104805.39022-1-samuel.williams@oriontransfer.co.nz> (raw)

Prefer to use `rb_io_descriptor` in my_fileno if it is available. This
function was introduced in Ruby 3.1. Ruby 3.3 will deprecate access to
all internal fields of `rb_io_t`.
 ext/raindrops/extconf.rb  | 1 +
 ext/raindrops/my_fileno.h | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/ext/raindrops/extconf.rb b/ext/raindrops/extconf.rb
index 792e509..1733703 100644
--- a/ext/raindrops/extconf.rb
+++ b/ext/raindrops/extconf.rb
@@ -4,6 +4,7 @@
 have_func('mmap', 'sys/mman.h') or abort 'mmap() not found'
 have_func('munmap', 'sys/mman.h') or abort 'munmap() not found'
 have_func('mremap', 'sys/mman.h')
diff --git a/ext/raindrops/my_fileno.h b/ext/raindrops/my_fileno.h
index 4c8ffba..00c5d29 100644
--- a/ext/raindrops/my_fileno.h
+++ b/ext/raindrops/my_fileno.h
@@ -3,6 +3,12 @@
 static int my_fileno(VALUE io)
+	if (TYPE(io) != T_FILE)
+		io = rb_convert_type(io, T_FILE, "IO", "to_io");
+	return rb_io_descriptor(io);
 	rb_io_t *fptr;
 	if (TYPE(io) != T_FILE)
@@ -12,4 +18,5 @@ static int my_fileno(VALUE io)
 	if (fptr->fd < 0)
 		rb_raise(rb_eIOError, "closed stream");
 	return fptr->fd;
2.39.2 (Apple Git-143)

             reply	other threads:[~2023-06-09 10:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09 10:48 Samuel Williams [this message]
2023-06-09 10:53 ` [PATCH] Improve compatibility with Ruby 3.3+ Samuel Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: http://yhbt.net/raindrops/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230609104805.39022-1-samuel.williams@oriontransfer.co.nz \
    --to=samuel.williams@oriontransfer.co.nz \
    --cc=raindrops-public@yhbt.net \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).