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

ruby-changes:36493

From: nobu <ko1@a...>
Date: Wed, 26 Nov 2014 03:44:38 +0900 (JST)
Subject: [ruby-changes:36493] nobu:r48575 (trunk): rb_id2str over rb_id2name

nobu	2014-11-26 03:44:22 +0900 (Wed, 26 Nov 2014)

  New Revision: 48575

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

  Log:
    rb_id2str over rb_id2name

  Modified files:
    trunk/class.c
    trunk/compile.c
    trunk/debug.c
    trunk/error.c
    trunk/eval_error.c
    trunk/gc.c
    trunk/vm.c
Index: debug.c
===================================================================
--- debug.c	(revision 48574)
+++ debug.c	(revision 48575)
@@ -115,7 +115,7 @@ ID https://github.com/ruby/ruby/blob/trunk/debug.c#L115
 ruby_debug_print_id(int level, int debug_level, const char *header, ID id)
 {
     if (level < debug_level) {
-	fprintf(stderr, "DBG> %s: %s\n", header, rb_id2name(id));
+	fprintf(stderr, "DBG> %s: %"PRIsVALUE"\n", header, rb_id2str(id));
 	fflush(stderr);
     }
     return id;
Index: eval_error.c
===================================================================
--- eval_error.c	(revision 48574)
+++ eval_error.c	(revision 48575)
@@ -22,20 +22,20 @@ warn_printf(const char *fmt, ...) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L22
 static void
 error_pos(void)
 {
-    const char *sourcefile = rb_sourcefile();
+    VALUE sourcefile = rb_sourcefilename();
     int sourceline = rb_sourceline();
 
     if (sourcefile) {
 	ID caller_name;
 	if (sourceline == 0) {
-	    warn_printf("%s", sourcefile);
+	    warn_printf("%"PRIsVALUE, sourcefile);
 	}
 	else if ((caller_name = rb_frame_callee()) != 0) {
-	    warn_printf("%s:%d:in `%s'", sourcefile, sourceline,
-			rb_id2name(caller_name));
+	    warn_printf("%"PRIsVALUE":%d:in `%"PRIsVALUE"'", sourcefile, sourceline,
+			rb_id2str(caller_name));
 	}
 	else {
-	    warn_printf("%s:%d", sourcefile, sourceline);
+	    warn_printf("%"PRIsVALUE":%d", sourcefile, sourceline);
 	}
     }
 }
Index: compile.c
===================================================================
--- compile.c	(revision 48574)
+++ compile.c	(revision 48575)
@@ -444,7 +444,8 @@ validate_label(st_data_t name, st_data_t https://github.com/ruby/ruby/blob/trunk/compile.c#L444
 	do {
 	    int ret;
 	    COMPILE_ERROR((ruby_sourcefile, lobj->position,
-			   "%s: undefined label", rb_id2name((ID)name)));
+			   "%"PRIsVALUE": undefined label",
+			   rb_id2str((ID)name)));
 	    if (ret) break;
 	} while (0);
     }
@@ -3960,7 +3961,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L3961
 	ID id = node->nd_vid;
 	int idx = iseq->local_iseq->local_size - get_local_var_idx(iseq, id);
 
-	debugs("lvar: %s idx: %d\n", rb_id2name(id), idx);
+	debugs("lvar: %"PRIsVALUE" idx: %d\n", rb_id2str(id), idx);
 	COMPILE(ret, "rvalue", node->nd_value);
 
 	if (!poped) {
@@ -3974,7 +3975,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L3975
       case NODE_DASGN_CURR:{
 	int idx, lv, ls;
 	COMPILE(ret, "dvalue", node->nd_value);
-	debugp_param("dassn id", rb_str_new2(rb_id2name(node->nd_vid) ? rb_id2name(node->nd_vid) : "*"));
+	debugi("dassn id", rb_id2str(node->nd_vid) ? node->nd_vid : '*');
 
 	if (!poped) {
 	    ADD_INSN(ret, line, dup);
@@ -3983,7 +3984,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L3984
 	idx = get_dyna_var_idx(iseq, node->nd_vid, &lv, &ls);
 
 	if (idx < 0) {
-	    rb_bug("NODE_DASGN(_CURR): unknown id (%s)", rb_id2name(node->nd_vid));
+	    rb_bug("NODE_DASGN(_CURR): unknown id (%"PRIsVALUE")", rb_id2str(node->nd_vid));
 	}
 
 	ADD_INSN2(ret, line, setlocal, INT2FIX(ls - idx), INT2FIX(lv));
@@ -4758,7 +4759,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L4759
 	    ID id = node->nd_vid;
 	    int idx = iseq->local_iseq->local_size - get_local_var_idx(iseq, id);
 
-	    debugs("id: %s idx: %d\n", rb_id2name(id), idx);
+	    debugs("id: %"PRIsVALUE" idx: %d\n", rb_id2str(id), idx);
 	    ADD_INSN2(ret, line, getlocal, INT2FIX(idx), INT2FIX(get_lvar_level(iseq)));
 	}
 	break;
@@ -4769,7 +4770,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L4770
 	if (!poped) {
 	    idx = get_dyna_var_idx(iseq, node->nd_vid, &lv, &ls);
 	    if (idx < 0) {
-		rb_bug("unknown dvar (%s)", rb_id2name(node->nd_vid));
+		rb_bug("unknown dvar (%"PRIsVALUE")", rb_id2str(node->nd_vid));
 	    }
 	    ADD_INSN2(ret, line, getlocal, INT2FIX(ls - idx), INT2FIX(lv));
 	}
@@ -5076,7 +5077,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5077
 	VALUE iseqval =
 	    NEW_CHILD_ISEQVAL(
 		node->nd_body,
-		rb_sprintf("<class:%s>", rb_id2name(node->nd_cpath->nd_mid)),
+		rb_sprintf("<class:%"PRIsVALUE">", rb_id2str(node->nd_cpath->nd_mid)),
 		ISEQ_TYPE_CLASS, line);
 	VALUE noscope = compile_cpath(ret, iseq, node->nd_cpath);
 	int flags = VM_DEFINECLASS_TYPE_CLASS;
@@ -5094,7 +5095,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5095
       case NODE_MODULE:{
 	VALUE iseqval = NEW_CHILD_ISEQVAL(
 	    node->nd_body,
-	    rb_sprintf("<module:%s>", rb_id2name(node->nd_cpath->nd_mid)),
+	    rb_sprintf("<module:%"PRIsVALUE">", rb_id2str(node->nd_cpath->nd_mid)),
 	    ISEQ_TYPE_CLASS, line);
 
 	VALUE noscope = compile_cpath(ret, iseq, node->nd_cpath);
@@ -5558,7 +5559,7 @@ insn_data_to_s_detail(INSN *iobj) https://github.com/ruby/ruby/blob/trunk/compile.c#L5559
 		{
 		    struct rb_global_entry *entry = (struct rb_global_entry *)
 		      (OPERAND_AT(iobj, j) & (~1));
-		    rb_str_cat2(str, rb_id2name(entry->id));
+		    rb_str_append(str, rb_id2str(entry->id));
 		    break;
 		}
 	      case TS_IC:	/* inline cache */
@@ -5567,7 +5568,10 @@ insn_data_to_s_detail(INSN *iobj) https://github.com/ruby/ruby/blob/trunk/compile.c#L5568
 	      case TS_CALLINFO: /* call info */
 		{
 		    rb_call_info_t *ci = (rb_call_info_t *)OPERAND_AT(iobj, j);
-		    rb_str_catf(str, "<callinfo:%s, %d>", ci->mid ? rb_id2name(ci->mid) : "", ci->orig_argc);
+		    rb_str_cat2(str, "<callinfo:");
+		    if (ci->mid)
+			rb_str_catf(str, "%"PRIsVALUE, rb_id2str(ci->mid));
+		    rb_str_catf(str, ", %d>", ci->orig_argc);
 		    break;
 		}
 	      case TS_CDHASH:	/* case/when condition cache */
Index: gc.c
===================================================================
--- gc.c	(revision 48574)
+++ gc.c	(revision 48575)
@@ -2717,7 +2717,7 @@ id2ref(VALUE obj, VALUE objid) https://github.com/ruby/ruby/blob/trunk/gc.c#L2717
 
     if ((ptr % sizeof(RVALUE)) == (4 << 2)) {
         ID symid = ptr / sizeof(RVALUE);
-        if (rb_id2name(symid) == 0)
+        if (rb_id2str(symid) == 0)
 	    rb_raise(rb_eRangeError, "%p is not symbol id value", p0);
 	return ID2SYM(symid);
     }
Index: class.c
===================================================================
--- class.c	(revision 48574)
+++ class.c	(revision 48575)
@@ -699,16 +699,16 @@ rb_define_class_id_under(VALUE outer, ID https://github.com/ruby/ruby/blob/trunk/class.c#L699
     if (rb_const_defined_at(outer, id)) {
 	klass = rb_const_get_at(outer, id);
 	if (!RB_TYPE_P(klass, T_CLASS)) {
-	    rb_raise(rb_eTypeError, "%s is not a class", rb_id2name(id));
+	    rb_raise(rb_eTypeError, "%"PRIsVALUE" is not a class", rb_id2str(id));
 	}
 	if (rb_class_real(RCLASS_SUPER(klass)) != super) {
-	    rb_name_error(id, "%s is already defined", rb_id2name(id));
+	    rb_name_error(id, "%"PRIsVALUE" is already defined", rb_id2str(id));
 	}
 	return klass;
     }
     if (!super) {
-	rb_warn("no super class for `%s::%s', Object assumed",
-		rb_class2name(outer), rb_id2name(id));
+	rb_warn("no super class for `%"PRIsVALUE"::%"PRIsVALUE"', Object assumed",
+		rb_class_path(outer), rb_id2str(id));
     }
     klass = rb_define_class_id(id, super);
     rb_set_class_path_string(klass, outer, rb_id2str(id));
Index: error.c
===================================================================
--- error.c	(revision 48574)
+++ error.c	(revision 48575)
@@ -1952,8 +1952,8 @@ void https://github.com/ruby/ruby/blob/trunk/error.c#L1952
 rb_notimplement(void)
 {
     rb_raise(rb_eNotImpError,
-	     "%s() function is unimplemented on this machine",
-	     rb_id2name(rb_frame_this_func()));
+	     "%"PRIsVALUE"() function is unimplemented on this machine",
+	     rb_id2str(rb_frame_this_func()));
 }
 
 void
Index: vm.c
===================================================================
--- vm.c	(revision 48574)
+++ vm.c	(revision 48575)
@@ -1729,15 +1729,14 @@ rb_thread_current_status(const rb_thread https://github.com/ruby/ruby/blob/trunk/vm.c#L1729
 	if (cfp->pc != 0) {
 	    rb_iseq_t *iseq = cfp->iseq;
 	    int line_no = rb_vm_get_sourceline(cfp);
-	    char *file = RSTRING_PTR(iseq->location.path);
-	    str = rb_sprintf("%s:%d:in `%s'",
-			     file, line_no, RSTRING_PTR(iseq->location.label));
+	    str = rb_sprintf("%"PRIsVALUE":%d:in `%"PRIsVALUE"'",
+			     iseq->location.path, line_no, iseq->location.label);
 	}
     }
     else if (cfp->me->def->original_id) {
-	str = rb_sprintf("`%s#%s' (cfunc)",
-			 rb_class2name(cfp->me->klass),
-			 rb_id2name(cfp->me->def->original_id));
+	str = rb_sprintf("`%"PRIsVALUE"#%"PRIsVALUE"' (cfunc)",
+			 rb_class_path(cfp->me->klass),
+			 rb_id2str(cfp->me->def->original_id));
     }
 
     return str;

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

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