[macruby-changes] [3569] MacRuby/branches/icu/string.c

source_changes at macosforge.org source_changes at macosforge.org
Tue Feb 16 21:36:31 PST 2010


Revision: 3569
          http://trac.macosforge.org/projects/ruby/changeset/3569
Author:   lsansonetti at apple.com
Date:     2010-02-16 21:36:28 -0800 (Tue, 16 Feb 2010)
Log Message:
-----------
better code for the NSString primitives

Modified Paths:
--------------
    MacRuby/branches/icu/string.c

Modified: MacRuby/branches/icu/string.c
===================================================================
--- MacRuby/branches/icu/string.c	2010-02-17 05:15:59 UTC (rev 3568)
+++ MacRuby/branches/icu/string.c	2010-02-17 05:36:28 UTC (rev 3569)
@@ -1332,15 +1332,23 @@
 static CFIndex
 rstr_imp_length(void *rcv, SEL sel)
 {
-    return str_length(RSTR(rcv), false);
+    return str_length(RSTR(rcv), true);
 }
 
 static UniChar
 rstr_imp_characterAtIndex(void *rcv, SEL sel, CFIndex idx)
 {
-    rb_str_t *ret = str_get_character_at(RSTR(rcv), idx, true);
-    assert(ret != NULL);
-    return ret->data.bytes[0];
+    // XXX implement a function that returns a unichar at given index
+    // and use it here.
+    if (str_try_making_data_uchars(RSTR(rcv))) {
+	return RSTR(rcv)->data.uchars[idx];
+    }
+    else if (BINARY_ENC(RSTR(rcv)->encoding)) {
+	return RSTR(rcv)->data.bytes[idx];
+    }
+    else {
+	abort(); // TODO
+    }
 }
 
 void
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100216/d8d8bb4a/attachment.html>


More information about the macruby-changes mailing list