[macruby-changes] [3902] MacRuby/trunk/string.c

source_changes at macosforge.org source_changes at macosforge.org
Thu Apr 1 17:53:55 PDT 2010


Revision: 3902
          http://trac.macosforge.org/projects/ruby/changeset/3902
Author:   lsansonetti at apple.com
Date:     2010-04-01 17:53:53 -0700 (Thu, 01 Apr 2010)
Log Message:
-----------
implemented NSString version of some MRI primitives

Modified Paths:
--------------
    MacRuby/trunk/string.c

Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c	2010-04-01 22:10:02 UTC (rev 3901)
+++ MacRuby/trunk/string.c	2010-04-02 00:53:53 UTC (rev 3902)
@@ -6003,7 +6003,8 @@
 	str_concat_string(RSTR(str), RSTR(substr));
     }
     else {
-	abort(); // TODO	
+	abort(); // TODO
+	
     }
     return str;
 }
@@ -6117,7 +6118,10 @@
     if (TYPE(str) == T_SYMBOL) {
 	return rb_sym_to_s(str);
     }
-    abort(); // TODO
+    CFMutableStringRef copy
+	= CFStringCreateMutableCopy(NULL, 0, (CFStringRef)str);
+    CFMakeCollectable(copy);
+    return (VALUE)copy;
 }
 
 // Unicode characters hashing function, copied from CoreFoundation.
@@ -6190,22 +6194,21 @@
 }
 
 VALUE
-rb_str_inspect(VALUE rcv)
+rb_str_inspect(VALUE str)
 {
-    if (RSTR(rcv)) {
-	return rstr_inspect(rcv, 0);
+    if (!IS_RSTR(str)) {
+	str = (VALUE)str_need_string(str);
     }
-    // TODO
-    return rcv;
+    return rstr_inspect(str, 0);
 }
 
 VALUE
 rb_str_subseq(VALUE str, long beg, long len)
 {
-    if (IS_RSTR(str)) {
-	return rstr_substr(str, beg, len);
+    if (!IS_RSTR(str)) {
+	str = (VALUE)str_need_string(str);
     }
-    abort(); // TODO
+    return rstr_substr(str, beg, len);
 }
 
 VALUE
@@ -6221,7 +6224,8 @@
 	rstr_splice(str, beg, len, val);
     }
     else {
-	abort(); // TODO
+	CFStringReplace((CFMutableStringRef)str, CFRangeMake(beg, len),
+		(CFStringRef)val);
     }
 }
 
@@ -6232,7 +6236,7 @@
 	str_delete(RSTR(str), beg, len, false);
     }
     else {
-	abort(); // TODO
+	CFStringDelete((CFMutableStringRef)str, CFRangeMake(beg, len));
     }
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100401/06a53298/attachment.html>


More information about the macruby-changes mailing list