[macruby-changes] [144] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Apr 16 18:17:02 PDT 2008


Revision: 144
          http://trac.macosforge.org/projects/ruby/changeset/144
Author:   lsansonetti at apple.com
Date:     2008-04-16 18:14:09 -0700 (Wed, 16 Apr 2008)

Log Message:
-----------
fixing more regressions, do not leak CF-created objects anymore

Modified Paths:
--------------
    MacRuby/trunk/array.c
    MacRuby/trunk/bignum.c
    MacRuby/trunk/compile.c
    MacRuby/trunk/hash.c
    MacRuby/trunk/insns.def
    MacRuby/trunk/parse.y
    MacRuby/trunk/ruby.c
    MacRuby/trunk/signal.c
    MacRuby/trunk/string.c
    MacRuby/trunk/thread.c
    MacRuby/trunk/time.c
    MacRuby/trunk/util.c
    MacRuby/trunk/variable.c
    MacRuby/trunk/vm.c
    MacRuby/trunk/vm_dump.c
    MacRuby/trunk/vm_insnhelper.c

Modified: MacRuby/trunk/array.c
===================================================================
--- MacRuby/trunk/array.c	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/array.c	2008-04-17 01:14:09 UTC (rev 144)
@@ -225,6 +225,8 @@
     if (klass != 0 && klass != rb_cArray && klass != rb_cArrayRuby)
         *(Class *)ary = RCLASS_OCID(klass);
 
+    CFMakeCollectable((CFTypeRef)ary);
+
     return ary;
 #else
     NEWOBJ(ary, struct RArray);

Modified: MacRuby/trunk/bignum.c
===================================================================
--- MacRuby/trunk/bignum.c	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/bignum.c	2008-04-17 01:14:09 UTC (rev 144)
@@ -582,10 +582,10 @@
 	s = StringValueCStr(str);
     }
     else {
-	s = RSTRING_PTR(str);
+	s = RSTRING_CPTR(str);
     }
     if (s) {
-	len = RSTRING_LEN(str);
+	len = RSTRING_CLEN(str);
 	if (s[len]) {		/* no sentinel somehow */
 	    char *p = ALLOCA_N(char, len+1);
 
@@ -880,8 +880,8 @@
 
     if (FIXNUM_P(x)) {
         VALUE str = rb_fix2str(x, base);
-        char* str_ptr = RSTRING_PTR(str);
-        long str_len = RSTRING_LEN(str);
+        char* str_ptr = RSTRING_CPTR(str);
+        long str_len = RSTRING_CLEN(str);
         if (trim) {
             if (FIX2INT(x) == 0) return 0;
             MEMCPY(ptr, str_ptr, char, str_len);
@@ -940,7 +940,7 @@
     n2 = big2str_find_n1(x, base);
     n1 = (n2 + 1) / 2;
     ss = rb_usascii_str_new(0, n2 + 1); /* plus one for sign */
-    ptr = RSTRING_PTR(ss);
+    ptr = RSTRING_PTR(ss); /* ok */
     ptr[0] = RBIGNUM_SIGN(x) ? '+' : '-';
 
     hbase = base*base;
@@ -960,6 +960,7 @@
 
     ptr[len] = '\0';
     rb_str_resize(ss, len);
+    RSTRING_SYNC(ss);
 
     return ss;
 }

Modified: MacRuby/trunk/compile.c
===================================================================
--- MacRuby/trunk/compile.c	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/compile.c	2008-04-17 01:14:09 UTC (rev 144)
@@ -1025,7 +1025,7 @@
 	  default:
 	    dump_disasm_list(FIRST_ELEMENT(anchor));
 	    dump_disasm_list(list);
-	    rb_compile_error(RSTRING_PTR(iseq->filename), line,
+	    rb_compile_error(RSTRING_CPTR(iseq->filename), line,
 			     "error: set_sequence");
 	    break;
 	}
@@ -1066,7 +1066,7 @@
 		/* operand check */
 		if (iobj->operand_size != len - 1) {
 		    dump_disasm_list(list);
-		    rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
+		    rb_compile_error(RSTRING_CPTR(iseq->filename), iobj->line_no,
 				     "operand size miss! (%d for %d)",
 				     iobj->operand_size, len - 1);
 		    return 0;
@@ -1081,7 +1081,7 @@
 			    /* label(destination position) */
 			    lobj = (LABEL *)operands[j];
 			    if (lobj->set != Qtrue) {
-				rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
+				rb_compile_error(RSTRING_CPTR(iseq->filename), iobj->line_no,
 						 "unknown label");
 			    }
 			    if (lobj->sp == -1) {
@@ -1106,7 +1106,7 @@
 				lobj = (LABEL *)(lv & ~1);
 
 				if (lobj->set != Qtrue) {
-				    rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
+				    rb_compile_error(RSTRING_CPTR(iseq->filename), iobj->line_no,
 						     "unknown label");
 				}
 				rb_hash_aset(map, obj, INT2FIX(lobj->position - (pos+len)));
@@ -1156,7 +1156,7 @@
 			}
 			break;
 		      default:
-			rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
+			rb_compile_error(RSTRING_CPTR(iseq->filename), iobj->line_no,
 					 "unknown operand type: %c", type);
 			return 0;
 		    }
@@ -1225,7 +1225,7 @@
 #if 0 /* XXX */
     /* this check need dead code elimination */
     if (sp != 1) {
-	rb_bug("SP is not 0 on %s (%d)\n", RSTRING_PTR(iseq->name), sp);
+	rb_bug("SP is not 0 on %s (%d)\n", RSTRING_CPTR(iseq->name), sp);
     }
 #endif
 
@@ -1726,7 +1726,7 @@
 		dump_disasm_list((LINK_ELEMENT *)iobj);
 		dump_disasm_list((LINK_ELEMENT *)lobj);
 		printf("\n-- %d, %d\n", lobj->sc_state, nstate);
-		rb_compile_error(RSTRING_PTR(iseq->filename), iobj->lineno,
+		rb_compile_error(RSTRING_CPTR(iseq->filename), iobj->lineno,
 				 "insn_set_sc_state error\n");
 		return 0;
 	    }
@@ -1828,7 +1828,7 @@
 			  case SCS_XX:
 			    goto normal_insn;
 			  default:
-			    rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
+			    rb_compile_error(RSTRING_CPTR(iseq->filename), iobj->line_no,
 					     "unreachable");
 			}
 			/* remove useless pop */
@@ -2522,7 +2522,7 @@
 make_name_for_block(rb_iseq_t *iseq)
 {
     if (iseq->parent_iseq == 0) {
-	return rb_sprintf("block in %s", RSTRING_PTR(iseq->name));
+	return rb_sprintf("block in %s", RSTRING_CPTR(iseq->name));
     }
     else {
 	int level = 1;
@@ -2531,7 +2531,7 @@
 	    ip = ip->parent_iseq;
 	    level++;
 	}
-	return rb_sprintf("block (%d levels) in %s", level, RSTRING_PTR(ip->name));
+	return rb_sprintf("block (%d levels) in %s", level, RSTRING_CPTR(ip->name));
     }
 }
 
@@ -4391,7 +4391,7 @@
 	LABEL *lfin = NEW_LABEL(nd_line(node));
 	LABEL *ltrue = NEW_LABEL(nd_line(node));
 	VALUE key = rb_sprintf("flipflag/%s-%p-%d",
-			       RSTRING_PTR(iseq->name), iseq,
+			       RSTRING_CPTR(iseq->name), iseq,
 			       iseq->compile_data->flip_cnt++);
 
 	iseq_add_mark_object_compile_time(iseq, key);
@@ -4770,7 +4770,7 @@
     if (sym == symRedo)   return  CATCH_TYPE_REDO;
     if (sym == symNext)   return CATCH_TYPE_NEXT;
     rb_raise(rb_eSyntaxError, "invalid exception symbol: %s",
-	     RSTRING_PTR(rb_inspect(sym)));
+	     RSTRING_CPTR(rb_inspect(sym)));
     return 0;
 }
 
@@ -4848,12 +4848,12 @@
 	    if (st_lookup(insn_table, insn, &insn_id) == 0) {
 		/* TODO: exception */
 		RB_GC_GUARD(insn) = rb_inspect(insn);
-		rb_compile_error(RSTRING_PTR(iseq->filename), line_no,
-				 "unknown instruction: %s", RSTRING_PTR(insn));
+		rb_compile_error(RSTRING_CPTR(iseq->filename), line_no,
+				 "unknown instruction: %s", RSTRING_CPTR(insn));
 	    }
 
 	    if (argc != insn_len(insn_id)-1) {
-		rb_compile_error(RSTRING_PTR(iseq->filename), line_no,
+		rb_compile_error(RSTRING_CPTR(iseq->filename), line_no,
 				 "operand size mismatch");
 	    }
 

Modified: MacRuby/trunk/hash.c
===================================================================
--- MacRuby/trunk/hash.c	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/hash.c	2008-04-17 01:14:09 UTC (rev 144)
@@ -390,6 +390,8 @@
     if (klass != 0 && klass != rb_cHash && klass != rb_cHashRuby)
 	*(Class *)hash = RCLASS_OCID(klass);
 
+    CFMakeCollectable((CFTypeRef)hash);
+
     return hash;
 #else
     NEWOBJ(hash, struct RHash);

Modified: MacRuby/trunk/insns.def
===================================================================
--- MacRuby/trunk/insns.def	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/insns.def	2008-04-17 01:14:09 UTC (rev 144)
@@ -254,7 +254,7 @@
       default: {
 	volatile VALUE tmp = rb_obj_as_string(klass);
 	rb_raise(rb_eTypeError, "%s is not a class/module",
-		 RSTRING_PTR(tmp));
+		 RSTRING_CPTR(tmp));
       }
     }
 

Modified: MacRuby/trunk/parse.y
===================================================================
--- MacRuby/trunk/parse.y	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/parse.y	2008-04-17 01:14:09 UTC (rev 144)
@@ -4815,6 +4815,7 @@
     }
     v = (VALUE)CFStringCreateWithSubstring(NULL, (CFStringRef)s, 
 	CFRangeMake(beg, lex_gets_ptr - beg));
+    CFMakeCollectable((CFTypeRef)v);
     return v;
 #else
     const char *cptr, *beg, *end, *pend;
@@ -5396,14 +5397,11 @@
 static void
 dispose_string(VALUE str)
 {
-#if WITH_OBJC
-    /* TODO: should use another API? */
-    CFRelease((CFTypeRef)str);
-#else
+#if !WITH_OBJC
     if (RBASIC(str)->flags & RSTRING_NOEMBED)
 	xfree(RSTRING_PTR(str));
-    rb_gc_force_recycle(str);
 #endif
+    rb_gc_force_recycle(str);
 }
 
 static int
@@ -8681,7 +8679,7 @@
     err = rb_reg_check_preprocess(str);
     if (err != Qnil) {
         err = rb_obj_as_string(err);
-        compile_error(PARSER_ARG "%s", RSTRING_PTR(err));
+        compile_error(PARSER_ARG "%s", RSTRING_CPTR(err));
 	RB_GC_GUARD(err);
     }
 }
@@ -8782,7 +8780,7 @@
 	    rb_str_append(rb_str_cat(rb_attr_get(err, mesg), "\n", 1), m);
 	}
 	else {
-	    compile_error(PARSER_ARG "%s", RSTRING_PTR(m));
+	    compile_error(PARSER_ARG "%s", RSTRING_CPTR(m));
 	}
 	return Qnil;
     }
@@ -9972,7 +9970,7 @@
     parser_initialize(parser);
 
     parser->parser_ruby_sourcefile_string = fname2;
-    parser->parser_ruby_sourcefile = RSTRING_PTR(fname2)+1;
+    parser->parser_ruby_sourcefile = RSTRING_CPTR(fname2)+1;
     parser->parser_ruby_sourceline = NIL_P(lineno) ? 0 : NUM2INT(lineno) - 1;
 
     return Qnil;
@@ -10083,7 +10081,7 @@
 {
     StringValue(msg);
     if (obj == Qundef) {
-        rb_raise(rb_eArgError, "%s", RSTRING_PTR(msg));
+        rb_raise(rb_eArgError, "%s", RSTRING_CPTR(msg));
     }
     return Qnil;
 }

Modified: MacRuby/trunk/ruby.c
===================================================================
--- MacRuby/trunk/ruby.c	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/ruby.c	2008-04-17 01:14:09 UTC (rev 144)
@@ -207,10 +207,11 @@
 	return rb_str_new(s, l);
     }
     ret = rb_str_new(0, l + newl - oldl);
-    ptr = RSTRING_PTR(ret);
+    ptr = RSTRING_CPTR(ret); /* ok */
     memcpy(ptr, newp, newl);
     memcpy(ptr + newl, s + oldl, l - oldl);
     ptr[l + newl - oldl] = 0;
+    RSTRING_SYNC(ret);
     return ret;
 }
 
@@ -260,11 +261,12 @@
 	if (*s) {
 	    if (!buf) {
 		buf = rb_str_new(p, len);
-		p = RSTRING_PTR(buf);
+		p = RSTRING_CPTR(buf);
 	    }
 	    else {
 		rb_str_resize(buf, len);
-		p = strncpy(RSTRING_PTR(buf), p, len);
+		p = strncpy(RSTRING_PTR(buf), p, len); /* ok */
+		RSTRING_SYNC(buf);
 	    }
 	}
 	if (cygwin_conv_to_posix_path(p, rubylib) == 0)
@@ -301,7 +303,7 @@
 static VALUE
 expand_include_path(VALUE path)
 {
-    char *p = RSTRING_PTR(path);
+    char *p = RSTRING_CPTR(path);
     if (!p)
 	return path;
     if (*p == '.' && p[1] == '/')
@@ -927,7 +929,7 @@
 static int
 opt_enc_index(VALUE enc_name)
 {
-    const char *s = RSTRING_PTR(enc_name);
+    const char *s = RSTRING_CPTR(enc_name);
     int i = rb_enc_find_index(s);
 
     if (i < 0) {
@@ -1159,10 +1161,11 @@
 	    opt->xflag = Qfalse;
 	    while (!NIL_P(line = rb_io_gets(f))) {
 		line_start++;
-		if (RSTRING_LEN(line) > 2
-		    && RSTRING_PTR(line)[0] == '#'
-		    && RSTRING_PTR(line)[1] == '!') {
-		    if ((p = strstr(RSTRING_PTR(line), "ruby")) != 0) {
+		const char *lineptr = RSTRING_CPTR(line);
+		if (RSTRING_CLEN(line) > 2
+		    && lineptr[0] == '#'
+		    && lineptr[1] == '!') {
+		    if ((p = strstr(lineptr, "ruby")) != 0) {
 			goto start_read;
 		    }
 		}
@@ -1178,7 +1181,7 @@
 		if (NIL_P(line))
 		    return 0;
 
-		if ((p = strstr(RSTRING_PTR(line), "ruby")) == 0) {
+		if ((p = strstr(RSTRING_CPTR(line), "ruby")) == 0) {
 		    /* not ruby script, kick the program */
 		    char **argv;
 		    char *path;
@@ -1327,8 +1330,8 @@
     if (origarg.argv == 0)
 	rb_raise(rb_eRuntimeError, "$0 not initialized");
     StringValue(val);
-    s = RSTRING_PTR(val);
-    i = RSTRING_LEN(val);
+    s = RSTRING_CPTR(val);
+    i = RSTRING_CLEN(val);
 #if defined(PSTAT_SETCMD)
     if (i > PST_CLEN) {
 	union pstun un;

Modified: MacRuby/trunk/signal.c
===================================================================
--- MacRuby/trunk/signal.c	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/signal.c	2008-04-17 01:14:09 UTC (rev 144)
@@ -330,7 +330,7 @@
 	goto str_signal;
 
       case T_STRING:
-	s = RSTRING_PTR(argv[0]);
+	s = RSTRING_CPTR(argv[0]);
 	if (s[0] == '-') {
 	    negative++;
 	    s++;
@@ -351,7 +351,7 @@
 
 	    str = rb_check_string_type(argv[0]);
 	    if (!NIL_P(str)) {
-		s = RSTRING_PTR(str);
+		s = RSTRING_CPTR(str);
 		goto str_signal;
 	    }
 	    rb_raise(rb_eArgError, "bad signal type %s",
@@ -719,40 +719,40 @@
                 goto sig_ign;
 		break;
               case 14:
-		if (strncmp(RSTRING_PTR(command), "SYSTEM_DEFAULT", 14) == 0) {
+		if (strncmp(RSTRING_CPTR(command), "SYSTEM_DEFAULT", 14) == 0) {
                     func = SIG_DFL;
                     *cmd = 0;
 		}
                 break;
 	      case 7:
-		if (strncmp(RSTRING_PTR(command), "SIG_IGN", 7) == 0) {
+		if (strncmp(RSTRING_CPTR(command), "SIG_IGN", 7) == 0) {
 sig_ign:
                     func = SIG_IGN;
                     *cmd = 0;
 		}
-		else if (strncmp(RSTRING_PTR(command), "SIG_DFL", 7) == 0) {
+		else if (strncmp(RSTRING_CPTR(command), "SIG_DFL", 7) == 0) {
 sig_dfl:
                     func = default_handler(sig);
                     *cmd = 0;
 		}
-		else if (strncmp(RSTRING_PTR(command), "DEFAULT", 7) == 0) {
+		else if (strncmp(RSTRING_CPTR(command), "DEFAULT", 7) == 0) {
                     goto sig_dfl;
 		}
 		break;
 	      case 6:
-		if (strncmp(RSTRING_PTR(command), "IGNORE", 6) == 0) {
+		if (strncmp(RSTRING_CPTR(command), "IGNORE", 6) == 0) {
                     goto sig_ign;
 		}
 		break;
 	      case 4:
-		if (strncmp(RSTRING_PTR(command), "EXIT", 4) == 0) {
+		if (strncmp(RSTRING_CPTR(command), "EXIT", 4) == 0) {
 		    func = sighandler;
 		    *cmd = Qundef;
 		}
 		break;
 	    }
 	    if (func == wrong_trap) {
-		rb_raise(rb_eArgError, "wrong trap - %s", RSTRING_PTR(command));
+		rb_raise(rb_eArgError, "wrong trap - %s", RSTRING_CPTR(command));
 	    }
 	}
 	else {

Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/string.c	2008-04-17 01:14:09 UTC (rev 144)
@@ -444,6 +444,7 @@
     if (klass != 0 && klass != rb_cString && klass != rb_cStringRuby 
 	&& klass != rb_cSymbol)
 	*(Class *)str = RCLASS_OCID(klass);
+    CFMakeCollectable((CFTypeRef)str);
 #else
     NEWOBJ(str, struct RString);
     OBJSETUP(str, klass, T_STRING);
@@ -3805,7 +3806,7 @@
  *     s.replace "world"   #=> "world"
  */
 
-static VALUE
+VALUE
 rb_str_replace(VALUE str, VALUE str2)
 {
     long len;

Modified: MacRuby/trunk/thread.c
===================================================================
--- MacRuby/trunk/thread.c	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/thread.c	2008-04-17 01:14:09 UTC (rev 144)
@@ -440,7 +440,7 @@
         if (!proc || !RTEST(loc = rb_proc_location(proc))) {
             rb_raise(rb_eThreadError, "already initialized thread");
         }
-	file = RSTRING_PTR(RARRAY_AT(loc, 0));
+	file = RSTRING_CPTR(RARRAY_AT(loc, 0));
 	if (NIL_P(line = RARRAY_AT(loc, 1))) {
 	    rb_raise(rb_eThreadError, "already initialized thread - %s",
 		     file);

Modified: MacRuby/trunk/time.c
===================================================================
--- MacRuby/trunk/time.c	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/time.c	2008-04-17 01:14:09 UTC (rev 144)
@@ -418,14 +418,14 @@
 	if (!NIL_P(s)) {
 	    tm->tm_mon = -1;
 	    for (i=0; i<12; i++) {
-		if (RSTRING_LEN(s) == 3 &&
-		    STRCASECMP(months[i], RSTRING_PTR(s)) == 0) {
+		if (RSTRING_CLEN(s) == 3 &&
+		    STRCASECMP(months[i], RSTRING_CPTR(s)) == 0) {
 		    tm->tm_mon = i;
 		    break;
 		}
 	    }
 	    if (tm->tm_mon == -1) {
-		char c = RSTRING_PTR(s)[0];
+		char c = RSTRING_CPTR(s)[0];
 
 		if ('0' <= c && c <= '9') {
 		    tm->tm_mon = obj2long(s)-1;
@@ -2082,8 +2082,8 @@
 	rb_raise(rb_eArgError, "format should have ASCII compatible encoding");
     }
     format = rb_str_new4(format);
-    fmt = RSTRING_PTR(format);
-    len = RSTRING_LEN(format);
+    fmt = RSTRING_CPTR(format);
+    len = RSTRING_CLEN(format);
     if (len == 0) {
 	rb_warning("strftime called with empty format string");
     }
@@ -2106,7 +2106,7 @@
 	return str;
     }
     else {
-	len = rb_strftime(&buf, RSTRING_PTR(format), &tobj->tm);
+	len = rb_strftime(&buf, RSTRING_CPTR(format), &tobj->tm);
     }
     str = rb_str_new(buf, len);
     if (buf != buffer) free(buf);
@@ -2226,7 +2226,7 @@
     rb_copy_generic_ivar(time, str);
 
     StringValue(str);
-    buf = (unsigned char *)RSTRING_PTR(str);
+    buf = (unsigned char *)RSTRING_PTR(str); /* ok */
     if (RSTRING_LEN(str) != 8) {
 	rb_raise(rb_eTypeError, "marshaled time format differ");
     }

Modified: MacRuby/trunk/util.c
===================================================================
--- MacRuby/trunk/util.c	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/util.c	2008-04-17 01:14:09 UTC (rev 144)
@@ -290,7 +290,7 @@
 #if defined(DJGPP)
     if (_USE_LFN) return;
 #else
-    if (valid_filename(RSTRING_PTR(str))) return;
+    if (valid_filename(RSTRING_CPTR(str))) return;
 #endif
 
     /* Fooey, style 0 failed.  Fix str before continuing. */
@@ -298,7 +298,7 @@
 #endif
 
     slen = extlen;
-    t = buf; baselen = 0; s = RSTRING_PTR(str);
+    t = buf; baselen = 0; s = RSTRING_CPTR(str);
     while ((*t = *s) && *s != '.') {
 	baselen++;
 	if (*s == '\\' || *s == '/') baselen = 0;
@@ -335,8 +335,7 @@
 fallback:
 	(void)memcpy(p, strEQ(ext, suffix1) ? suffix2 : suffix1, 5);
     }
-    rb_str_resize(str, strlen(buf));
-    memcpy(RSTRING_PTR(str), buf, RSTRING_LEN(str));
+    rb_str_replace(str, rb_str_new(buf, strlen(buf)));
 }
 
 #if defined(__CYGWIN32__) || defined(_WIN32)

Modified: MacRuby/trunk/variable.c
===================================================================
--- MacRuby/trunk/variable.c	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/variable.c	2008-04-17 01:14:09 UTC (rev 144)
@@ -232,7 +232,7 @@
     OBJ_FREEZE(str);
     rb_ivar_set(klass, classpath, str);
 #if WITH_OBJC
-    rb_objc_rename_class(klass, RSTRING_PTR(str));
+    rb_objc_rename_class(klass, RSTRING_CPTR(str));
 #endif
 }
 
@@ -287,7 +287,7 @@
 char *
 rb_class2name(VALUE klass)
 {
-    return RSTRING_PTR(rb_class_name(klass));
+    return RSTRING_CPTR(rb_class_name(klass));
 }
 
 char *
@@ -1341,7 +1341,7 @@
 #endif
 	RDATA(av)->dfree != (RUBY_DATA_FUNC)st_free_table) {
 	VALUE desc = rb_inspect(av);
-	rb_raise(rb_eTypeError, "wrong autoload table: %s", RSTRING_PTR(desc));
+	rb_raise(rb_eTypeError, "wrong autoload table: %s", RSTRING_CPTR(desc));
     }
     return (struct st_table *)DATA_PTR(av);
 }
@@ -1413,7 +1413,7 @@
     VALUE file;
     NODE *load = autoload_delete(klass, id);
 
-    if (!load || !(file = load->nd_lit) || rb_provided(RSTRING_PTR(file))) {
+    if (!load || !(file = load->nd_lit) || rb_provided(RSTRING_CPTR(file))) {
 	return Qfalse;
     }
     return rb_require_safe(file, load->nd_nth);
@@ -1432,10 +1432,10 @@
     }
     file = ((NODE *)load)->nd_lit;
     Check_Type(file, T_STRING);
-    if (!RSTRING_PTR(file)) {
+    if (RSTRING_CLEN(file) == 0) {
 	rb_raise(rb_eArgError, "empty file name");
     }
-    if (!rb_provided(RSTRING_PTR(file))) {
+    if (!rb_provided(RSTRING_CPTR(file))) {
 	return file;
     }
 

Modified: MacRuby/trunk/vm.c
===================================================================
--- MacRuby/trunk/vm.c	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/vm.c	2008-04-17 01:14:09 UTC (rev 144)
@@ -721,7 +721,7 @@
 vm_backtrace_each(rb_thread_t *th,
 		  rb_control_frame_t *limit_cfp,
 		  rb_control_frame_t *cfp,
-		  char *file, int line_no, VALUE ary)
+		  const char *file, int line_no, VALUE ary)
 {
     VALUE str;
 
@@ -732,9 +732,9 @@
 		rb_iseq_t *iseq = cfp->iseq;
 
 		line_no = vm_get_sourceline(cfp);
-		file = RSTRING_PTR(iseq->filename);
+		file = RSTRING_CPTR(iseq->filename);
 		str = rb_sprintf("%s:%d:in `%s'",
-				 file, line_no, RSTRING_PTR(iseq->name));
+				 file, line_no, RSTRING_CPTR(iseq->name));
 		rb_ary_push(ary, str);
 	    }
 	}
@@ -1409,14 +1409,14 @@
 	if (cfp->pc != 0) {
 	    rb_iseq_t *iseq = cfp->iseq;
 	    int line_no = vm_get_sourceline(cfp);
-	    char *file = RSTRING_PTR(iseq->filename);
+	    const char *file = RSTRING_CPTR(iseq->filename);
 	    str = rb_sprintf("%s:%d:in `%s'",
-			     file, line_no, RSTRING_PTR(iseq->name));
+			     file, line_no, RSTRING_CPTR(iseq->name));
 	}
     }
     else if (cfp->method_id) {
 	str = rb_sprintf("`%s#%s' (cfunc)",
-			 RSTRING_PTR(rb_class_name(cfp->method_class)),
+			 RSTRING_CPTR(rb_class_name(cfp->method_class)),
 			 rb_id2name(cfp->method_id));
     }
 

Modified: MacRuby/trunk/vm_dump.c
===================================================================
--- MacRuby/trunk/vm_dump.c	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/vm_dump.c	2008-04-17 01:14:09 UTC (rev 144)
@@ -98,11 +98,11 @@
 	}
 	else {
 	    pc = cfp->pc - cfp->iseq->iseq_encoded;
-	    iseq_name = RSTRING_PTR(cfp->iseq->name);
+	    iseq_name = RSTRING_CPTR(cfp->iseq->name);
 	    line = vm_get_sourceline(cfp);
 	    if (line) {
 		char fn[MAX_POSBUF+1];
-		snprintf(fn, MAX_POSBUF, "%s", RSTRING_PTR(cfp->iseq->filename));
+		snprintf(fn, MAX_POSBUF, "%s", RSTRING_CPTR(cfp->iseq->filename));
 		snprintf(posbuf, MAX_POSBUF, "%s:%d", fn, line);
 	    }
 	}
@@ -257,7 +257,7 @@
     else {
 	argc = iseq->argc;
 	local_size = iseq->local_size;
-	name = RSTRING_PTR(iseq->name);
+	name = RSTRING_CPTR(iseq->name);
     }
 
     /* stack trace header */

Modified: MacRuby/trunk/vm_insnhelper.c
===================================================================
--- MacRuby/trunk/vm_insnhelper.c	2008-04-16 20:54:11 UTC (rev 143)
+++ MacRuby/trunk/vm_insnhelper.c	2008-04-17 01:14:09 UTC (rev 144)
@@ -1045,7 +1045,7 @@
 	    break;
 	  default:
 	    rb_raise(rb_eTypeError, "%s is not a class/module",
-		     RSTRING_PTR(rb_obj_as_string(klass)));
+		     RSTRING_CPTR(rb_obj_as_string(klass)));
 	}
 	if (is_defined) {
 	    return rb_const_defined(klass, id);

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080417/c6bd9a06/attachment.html


More information about the macruby-changes mailing list