[#1147] Copying RVALUE — why the lucky stiff <ruby-core@...>

Hello, everyone. Hope you are all doing well.

18 messages 2003/06/17
[#1155] Re: Copying RVALUE — matz@... (Yukihiro Matsumoto) 2003/06/20

Hi,

[#1157] Re: Copying RVALUE — why the lucky stiff <ruby-core@...> 2003/06/20

Yukihiro Matsumoto (matz@ruby-lang.org) wrote:

[#1173] class.c code cleanup (rb_class_*_instance_methods) — Matthew Dempsky <jivera@...>

Hi, I'm new to this mailing list so I don't know the procedure for

15 messages 2003/06/22
[#1174] Re: [Patch] class.c code cleanup (rb_class_*_instance_methods) — nobu.nokada@... 2003/06/22

Hi,

[#1175] Re: [Patch] class.c code cleanup (rb_class_*_instance_methods) — Matthew Dempsky <jivera@...> 2003/06/22

On Sun, 2003-06-22 at 05:36, nobu.nokada@softhome.net wrote:

[#1176] Re: [Patch] class.c code cleanup (rb_class_*_instance_methods) — nobu.nokada@... 2003/06/22

Hi,

[#1193] Re: [Patch] class.c code cleanup (rb_class_*_instance_methods) — Matthew Dempsky <jivera@...> 2003/06/25

On Sun, 2003-06-22 at 07:41, nobu.nokada@softhome.net wrote:

[#1177] Re: In 1.8.0 nil.to_s is not the same as "" — ts <decoux@...>

14 messages 2003/06/22

[Patch] class.c code cleanup (rb_class_*_instance_methods)

From: Matthew Dempsky <jivera@...>
Date: 2003-06-22 07:32:58 UTC
List: ruby-core #1173
Hi, I'm new to this mailing list so I don't know the procedure for
introducing new patches (I couldn't find anything about it on the
website), but I figured I'd write one up and just send it to the mailing
list and see where that gets me (of course I'll understand if it's
rejected).

This patch is just a simple refactoring of the
rb_class_*_instance_methods to use a single common function body, rather
than repeating it four separate times.  It introduces a new function,
rb_class_generic_instance_methods, with the same signature as the others
except taking an additional parameter of a function pointer.  (If you
would like to accept this patch but want me to rename the
function/parameter, I'd be willing to do so and resubmit.)

-jivera
-- 
Matthew Dempsky <jivera@flame.org>

Attachments (1)

cleanup.patch (2.14 KB, text/x-diff)
--- class-orig.c	2003-06-22 02:08:35.000000000 -0500
+++ class.c	2003-06-22 02:07:42.000000000 -0500
@@ -549,11 +549,12 @@
     return ary;
 }
 
-VALUE
-rb_class_instance_methods(argc, argv, mod)
+static VALUE
+rb_class_generic_instance_methods(argc, argv, mod, func)
     int argc;
     VALUE *argv;
     VALUE mod;
+    int (*func)();
 {
     VALUE recur;
 
@@ -565,26 +566,25 @@
 	recur = Qtrue;
 #endif
     }
-    return method_list(mod, RTEST(recur), ins_methods_i);
+    return method_list(mod, RTEST(recur), func);
 }
 
 VALUE
-rb_class_protected_instance_methods(argc, argv, mod)
+rb_class_instance_methods(argc, argv, mod)
     int argc;
     VALUE *argv;
     VALUE mod;
 {
-    VALUE recur;
+    return rb_class_generic_instance_methods(argc, argv, mod, ins_methods_i);
+}
 
-    rb_scan_args(argc, argv, "01", &recur);
-    if (argc == 0) {
-#if RUBY_VERSION_CODE < 181
-	rb_warn("protected_instance_methods parameter will default to 'true' after 1.8.1");
-#else
-	recur = Qtrue;
-#endif
-    }
-    return method_list(mod, RTEST(recur), ins_methods_prot_i);
+VALUE
+rb_class_protected_instance_methods(argc, argv, mod)
+    int argc;
+    VALUE *argv;
+    VALUE mod;
+{
+    return rb_class_generic_instance_methods(argc, argv, mod, ins_methods_prot_i);
 }
 
 VALUE
@@ -593,17 +593,7 @@
     VALUE *argv;
     VALUE mod;
 {
-    VALUE recur;
-
-    rb_scan_args(argc, argv, "01", &recur);
-    if (argc == 0) {
-#if RUBY_VERSION_CODE < 181
-	rb_warn("private_instance_methods parameter will default to 'true' after 1.8.1");
-#else
-	recur = Qtrue;
-#endif
-    }
-    return method_list(mod, RTEST(recur), ins_methods_priv_i);
+    return rb_class_generic_instance_methods(argc, argv, mod, ins_methods_priv_i);
 }
 
 VALUE
@@ -612,17 +602,7 @@
     VALUE *argv;
     VALUE mod;
 {
-    VALUE recur;
-
-    rb_scan_args(argc, argv, "01", &recur);
-    if (argc == 0) {
-#if RUBY_VERSION_CODE < 181
-	rb_warn("public_instance_methods parameter will default to 'true' after 1.8.1");
-#else
-	recur = Qtrue;
-#endif
-    }
-    return method_list(mod, RTEST(recur), ins_methods_pub_i);
+    return rb_class_generic_instance_methods(argc, argv, mod, ins_methods_pub_i);
 }
 
 VALUE

In This Thread

Prev Next