[前][次][番号順一覧][スレッド一覧]

ruby-changes:57372

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Thu, 29 Aug 2019 18:43:50 +0900 (JST)
Subject: [ruby-changes:57372] 卜部昌平: 3df37259d8 (master): drop-in type check for rb_define_singleton_method

https://git.ruby-lang.org/ruby.git/commit/?id=3df37259d8

From 3df37259d81d9fc71f8b4f0b8d45dc9d0af81ab4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Thu, 29 Aug 2019 11:47:20 +0900
Subject: drop-in type check for rb_define_singleton_method

We can check the function pointer passed to
rb_define_singleton_method like how we do so in rb_define_method.
Doing so revealed many arity mismatches.

diff --git a/class.c b/class.c
index 0714f54..2e87101 100644
--- a/class.c
+++ b/class.c
@@ -1746,6 +1746,9 @@ rb_singleton_class(VALUE obj) https://github.com/ruby/ruby/blob/trunk/class.c#L1746
  * \{
  */
 
+#ifdef rb_define_singleton_method
+#undef rb_define_singleton_method
+#endif
 /*!
  * Defines a singleton method for \a obj.
  * \param obj    an arbitrary object
diff --git a/eval.c b/eval.c
index bde02d5..614bb04 100644
--- a/eval.c
+++ b/eval.c
@@ -355,7 +355,7 @@ ruby_exec_node(void *n) https://github.com/ruby/ruby/blob/trunk/eval.c#L355
  */
 
 static VALUE
-rb_mod_nesting(void)
+rb_mod_nesting(VALUE _)
 {
     VALUE ary = rb_ary_new();
     const rb_cref_t *cref = rb_vm_cref();
@@ -1614,7 +1614,7 @@ used_modules_i(VALUE _, VALUE mod, VALUE ary) https://github.com/ruby/ruby/blob/trunk/eval.c#L1614
  *     [B, A]
  */
 static VALUE
-rb_mod_s_used_modules(void)
+rb_mod_s_used_modules(VALUE _)
 {
     const rb_cref_t *cref = rb_vm_cref();
     VALUE ary = rb_ary_new();
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index ad0bd4e..b686f99 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -1382,7 +1382,7 @@ readline_s_set_basic_word_break_characters(VALUE self, VALUE str) https://github.com/ruby/ruby/blob/trunk/ext/readline/readline.c#L1382
  * Raises NotImplementedError if the using readline library does not support.
  */
 static VALUE
-readline_s_get_basic_word_break_characters(VALUE self, VALUE str)
+readline_s_get_basic_word_break_characters(VALUE self)
 {
     if (rl_basic_word_break_characters == NULL)
         return Qnil;
@@ -1437,7 +1437,7 @@ readline_s_set_completer_word_break_characters(VALUE self, VALUE str) https://github.com/ruby/ruby/blob/trunk/ext/readline/readline.c#L1437
  * Raises NotImplementedError if the using readline library does not support.
  */
 static VALUE
-readline_s_get_completer_word_break_characters(VALUE self, VALUE str)
+readline_s_get_completer_word_break_characters(VALUE self)
 {
     if (rl_completer_word_break_characters == NULL)
         return Qnil;
@@ -1552,7 +1552,7 @@ readline_s_set_basic_quote_characters(VALUE self, VALUE str) https://github.com/ruby/ruby/blob/trunk/ext/readline/readline.c#L1552
  * Raises NotImplementedError if the using readline library does not support.
  */
 static VALUE
-readline_s_get_basic_quote_characters(VALUE self, VALUE str)
+readline_s_get_basic_quote_characters(VALUE self)
 {
     if (rl_basic_quote_characters == NULL)
         return Qnil;
@@ -1608,7 +1608,7 @@ readline_s_set_completer_quote_characters(VALUE self, VALUE str) https://github.com/ruby/ruby/blob/trunk/ext/readline/readline.c#L1608
  * Raises NotImplementedError if the using readline library does not support.
  */
 static VALUE
-readline_s_get_completer_quote_characters(VALUE self, VALUE str)
+readline_s_get_completer_quote_characters(VALUE self)
 {
     if (rl_completer_quote_characters == NULL)
         return Qnil;
@@ -1662,7 +1662,7 @@ readline_s_set_filename_quote_characters(VALUE self, VALUE str) https://github.com/ruby/ruby/blob/trunk/ext/readline/readline.c#L1662
  * Raises NotImplementedError if the using readline library does not support.
  */
 static VALUE
-readline_s_get_filename_quote_characters(VALUE self, VALUE str)
+readline_s_get_filename_quote_characters(VALUE self)
 {
     if (rl_filename_quote_characters == NULL)
         return Qnil;
diff --git a/ext/socket/basicsocket.c b/ext/socket/basicsocket.c
index 1371672..fb5beed 100644
--- a/ext/socket/basicsocket.c
+++ b/ext/socket/basicsocket.c
@@ -672,7 +672,7 @@ bsock_recv_nonblock(VALUE sock, VALUE len, VALUE flg, VALUE str, VALUE ex) https://github.com/ruby/ruby/blob/trunk/ext/socket/basicsocket.c#L672
  *   BasicSocket.do_not_reverse_lookup  #=> false
  */
 static VALUE
-bsock_do_not_rev_lookup(void)
+bsock_do_not_rev_lookup(VALUE _)
 {
     return rsock_do_not_reverse_lookup?Qtrue:Qfalse;
 }
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 0059595..f101791 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1042,7 +1042,7 @@ sock_s_gethostbyname(VALUE obj, VALUE host) https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L1042
  *
  */
 static VALUE
-sock_s_gethostbyaddr(int argc, VALUE *argv)
+sock_s_gethostbyaddr(int argc, VALUE *argv, VALUE _)
 {
     VALUE addr, family;
     struct hostent *h;
@@ -1104,7 +1104,7 @@ sock_s_gethostbyaddr(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L1104
  *   Socket.getservbyname("syslog", "udp") #=> 514
  */
 static VALUE
-sock_s_getservbyname(int argc, VALUE *argv)
+sock_s_getservbyname(int argc, VALUE *argv, VALUE _)
 {
     VALUE service, proto;
     struct servent *sp;
@@ -1145,7 +1145,7 @@ sock_s_getservbyname(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L1145
  *
  */
 static VALUE
-sock_s_getservbyport(int argc, VALUE *argv)
+sock_s_getservbyport(int argc, VALUE *argv, VALUE _)
 {
     VALUE port, proto;
     struct servent *sp;
@@ -1203,7 +1203,7 @@ sock_s_getservbyport(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L1203
  * If Addrinfo object is preferred, use Addrinfo.getaddrinfo.
  */
 static VALUE
-sock_s_getaddrinfo(int argc, VALUE *argv)
+sock_s_getaddrinfo(int argc, VALUE *argv, VALUE _)
 {
     VALUE host, port, family, socktype, protocol, flags, ret, revlookup;
     struct addrinfo hints;
@@ -1257,7 +1257,7 @@ sock_s_getaddrinfo(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L1257
  * If Addrinfo object is preferred, use Addrinfo#getnameinfo.
  */
 static VALUE
-sock_s_getnameinfo(int argc, VALUE *argv)
+sock_s_getnameinfo(int argc, VALUE *argv, VALUE _)
 {
     VALUE sa, af = Qnil, host = Qnil, port = Qnil, flags, tmp;
     char *hptr, *pptr;
diff --git a/file.c b/file.c
index b33b5f6..b1ba4c3 100644
--- a/file.c
+++ b/file.c
@@ -2538,7 +2538,7 @@ chmod_internal(const char *path, void *mode) https://github.com/ruby/ruby/blob/trunk/file.c#L2538
  */
 
 static VALUE
-rb_file_s_chmod(int argc, VALUE *argv)
+rb_file_s_chmod(int argc, VALUE *argv, VALUE _)
 {
     mode_t mode;
 
@@ -2610,7 +2610,7 @@ lchmod_internal(const char *path, void *mode) https://github.com/ruby/ruby/blob/trunk/file.c#L2610
  */
 
 static VALUE
-rb_file_s_lchmod(int argc, VALUE *argv)
+rb_file_s_lchmod(int argc, VALUE *argv, VALUE _)
 {
     mode_t mode;
 
@@ -2669,7 +2669,7 @@ chown_internal(const char *path, void *arg) https://github.com/ruby/ruby/blob/trunk/file.c#L2669
  */
 
 static VALUE
-rb_file_s_chown(int argc, VALUE *argv)
+rb_file_s_chown(int argc, VALUE *argv, VALUE _)
 {
     struct chown_args arg;
 
@@ -2741,7 +2741,7 @@ lchown_internal(const char *path, void *arg) https://github.com/ruby/ruby/blob/trunk/file.c#L2741
  */
 
 static VALUE
-rb_file_s_lchown(int argc, VALUE *argv)
+rb_file_s_lchown(int argc, VALUE *argv, VALUE _)
 {
     struct chown_args arg;
 
@@ -2919,7 +2919,7 @@ utime_internal_i(int argc, VALUE *argv, int follow) https://github.com/ruby/ruby/blob/trunk/file.c#L2919
  */
 
 static VALUE
-rb_file_s_utime(int argc, VALUE *argv)
+rb_file_s_utime(int argc, VALUE *argv, VALUE _)
 {
     return utime_internal_i(argc, argv, FALSE);
 }
@@ -2938,7 +2938,7 @@ rb_file_s_utime(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/file.c#L2938
  */
 
 static VALUE
-rb_file_s_lutime(int argc, VALUE *argv)
+rb_file_s_lutime(int argc, VALUE *argv, VALUE _)
 {
     return utime_internal_i(argc, argv, TRUE);
 }
@@ -3217,7 +3217,7 @@ rb_file_s_rename(VALUE klass, VALUE from, VALUE to) https://github.com/ruby/ruby/blob/trunk/file.c#L3217
  */
 
 static VALUE
-rb_file_s_umask(int argc, VALUE *argv)
+rb_file_s_umask(int argc, VALUE *argv, VALUE _)
 {
     mode_t omask = 0;
 
@@ -4032,6 +4032,13 @@ rb_file_expand_path_fast(VALUE fname, VALUE dname) https://github.com/ruby/ruby/blob/trunk/file.c#L4032
     return expand_path(fname, dname, 0, 0, EXPAND_PATH_BUFFER());
 }
 
+VALUE
+rb_file_s_expand_path(int argc, const VALUE *argv)
+{
+    rb_check_arity(argc, 1, 2);
+    return rb_file_expand_path(argv[0], argc > 1 ? argv[1] : Qnil);
+}
+
 /*
  *  call-seq:
  *     File.expand_path(file_name [, dir_string] )  ->  abs_file_name
@@ -4060,11 +4067,10 @@ rb_file_expand_path_fast(VALUE fname, VALUE dname) https://github.com/ruby/ruby/blob/trunk/file.c#L4067
  *  parent, the root of the project and appends +lib/mygem.rb+.
  */
 
-VALUE
-rb_file_s_expand_path(int argc, const VALUE *argv)
+static VALUE
+s_expand_path(int c, const VALUE * v, VALUE _)
 {
-    rb_check_arity(argc, 1, 2);
-    return rb_file_expand_path(argv[0], argc > 1 ? argv[1] : Qnil);
+    return rb_file_s_expand_path(c, v);
 }
 
 VALUE
@@ -4074,6 +4080,13 @@ rb_file_absolute_path(VALUE fname, VALUE dname) https://github.com/ruby/ruby/blob/trunk/file.c#L4080
     return expand_path(fname, dname, 1, 1, EXPAND_PATH_BUFFER());
 }
 
+VALUE
+rb_file_s_absolute_path(int argc, const VALUE *argv)
+{
+    rb_check_arity(argc, 1, 2);
+    return rb_file_absolute_path(argv[0], argc > 1 ? argv[1] : Qnil);
+}
+
 /*
  *  call-seq:
  *     File.absolute_path(file_name [, dir_string] )  ->  abs_file_name
@@ -4087,11 +4100,10 @@ rb_file_absolute_path(VALUE fname, VALUE dname) https://github.com/ruby/ruby/blob/trunk/file.c#L4100
  *     File.absolute_path("~oracle/bin")       #=> "<relative_path>/~oracle/bin"
  */
 
-VALUE
-rb_file_s_absolute_path(int argc, const VALUE *argv)
+static VALUE
+s_absolute_path(int c, const VALUE * v, VALUE _)
 {
-    rb_check_arity(argc, 1, 2);
-    return rb_file_absolute_path(argv (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]