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

ruby-changes:34878

From: nobu <ko1@a...>
Date: Sun, 27 Jul 2014 01:13:38 +0900 (JST)
Subject: [ruby-changes:34878] nobu:r46961 (trunk): eval_error.c: rb_print_inaccessible

nobu	2014-07-27 01:13:21 +0900 (Sun, 27 Jul 2014)

  New Revision: 46961

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46961

  Log:
    eval_error.c: rb_print_inaccessible
    
    * eval_error.c (rb_print_inaccessible): exract from mnew_from_me()
      in proc.c

  Modified files:
    trunk/eval_error.c
    trunk/eval_intern.h
    trunk/proc.c
Index: eval_intern.h
===================================================================
--- eval_intern.h	(revision 46960)
+++ eval_intern.h	(revision 46961)
@@ -238,6 +238,7 @@ NORETURN(void rb_fiber_start(void)); https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L238
 
 NORETURN(void rb_print_undef(VALUE, ID, int));
 NORETURN(void rb_print_undef_str(VALUE, VALUE));
+NORETURN(void rb_print_inaccessible(VALUE, ID, int));
 NORETURN(void rb_vm_localjump_error(const char *,VALUE, int));
 NORETURN(void rb_vm_jump_tag_but_local_jump(int));
 NORETURN(void rb_raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv,
Index: eval_error.c
===================================================================
--- eval_error.c	(revision 46960)
+++ eval_error.c	(revision 46961)
@@ -208,8 +208,8 @@ ruby_error_print(void) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L208
     error_print();
 }
 
-void
-rb_print_undef(VALUE klass, ID id, int scope)
+static const char *
+method_scope_name(int scope)
 {
     const char *v;
 
@@ -219,6 +219,13 @@ rb_print_undef(VALUE klass, ID id, int s https://github.com/ruby/ruby/blob/trunk/eval_error.c#L219
       case NOEX_PRIVATE: v = " private"; break;
       case NOEX_PROTECTED: v = " protected"; break;
     }
+    return v;
+}
+
+void
+rb_print_undef(VALUE klass, ID id, int scope)
+{
+    const char *v = method_scope_name(scope);
     rb_name_error(id, "undefined%s method `%"PRIsVALUE"' for %s `%"PRIsVALUE"'", v,
 		  QUOTE_ID(id),
 		  (RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
@@ -234,6 +241,17 @@ rb_print_undef_str(VALUE klass, VALUE na https://github.com/ruby/ruby/blob/trunk/eval_error.c#L241
 		      rb_class_name(klass));
 }
 
+void
+rb_print_inaccessible(VALUE klass, ID id, int scope)
+{
+    const char *v = method_scope_name(scope);
+    rb_name_error(id, "method `%s' for %s `% "PRIsVALUE"' is %s",
+		  rb_id2name(id),
+		  (RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
+		  rb_class_name(klass),
+		  v);
+}
+
 static int
 sysexit_status(VALUE err)
 {
Index: proc.c
===================================================================
--- proc.c	(revision 46960)
+++ proc.c	(revision 46961)
@@ -1219,16 +1219,7 @@ mnew_from_me(rb_method_entry_t *me, VALU https://github.com/ruby/ruby/blob/trunk/proc.c#L1219
     if (flag == NOEX_UNDEF) {
 	flag = me->flag;
 	if (scope && (flag & NOEX_MASK) != NOEX_PUBLIC) {
-	    const char *v = "";
-	    switch (flag & NOEX_MASK) {
-		case NOEX_PRIVATE: v = "private"; break;
-		case NOEX_PROTECTED: v = "protected"; break;
-	    }
-	    rb_name_error(id, "method `%s' for %s `% "PRIsVALUE"' is %s",
-			  rb_id2name(id),
-			  (RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
-			  rb_class_name(klass),
-			  v);
+	    rb_print_inaccessible(klass, id, flag & NOEX_MASK);
 	}
     }
     if (def && def->type == VM_METHOD_TYPE_ZSUPER) {

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

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