[macruby-changes] [3655] MacRuby/branches/icu/symbol.c

source_changes at macosforge.org source_changes at macosforge.org
Sat Feb 27 22:06:59 PST 2010


Revision: 3655
          http://trac.macosforge.org/projects/ruby/changeset/3655
Author:   lsansonetti at apple.com
Date:     2010-02-27 22:06:58 -0800 (Sat, 27 Feb 2010)
Log Message:
-----------
added NSString primitives to Symbol

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

Modified: MacRuby/branches/icu/symbol.c
===================================================================
--- MacRuby/branches/icu/symbol.c	2010-02-28 06:00:59 UTC (rev 3654)
+++ MacRuby/branches/icu/symbol.c	2010-02-28 06:06:58 UTC (rev 3655)
@@ -14,6 +14,7 @@
 #include "symbol.h"
 #include "ruby/node.h"
 #include "vm.h"
+#include "objc.h"
 
 VALUE rb_cSymbol;
 
@@ -344,6 +345,18 @@
     return sym;
 }
 
+static CFIndex
+rsym_imp_length(void *rcv, SEL sel)
+{
+    return CFStringGetLength((CFStringRef)RSYM(rcv)->str);
+}
+
+static UniChar
+rsym_imp_characterAtIndex(void *rcv, SEL sel, CFIndex idx)
+{
+    return CFStringGetCharacterAtIndex((CFStringRef)RSYM(rcv)->str, idx);
+}
+
 void
 Init_Symbol(void)
 {
@@ -366,4 +379,10 @@
     rb_objc_define_method(rb_cSymbol, "description", rsym_to_s, 0);
     rb_objc_define_method(rb_cSymbol, "intern", rsym_to_sym, 0);
     rb_objc_define_method(rb_cSymbol, "to_sym", rsym_to_sym, 0);
+
+    // Cocoa primitives.
+    rb_objc_install_method2((Class)rb_cSymbol, "length",
+	    (IMP)rsym_imp_length);
+    rb_objc_install_method2((Class)rb_cSymbol, "characterAtIndex:",
+	    (IMP)rsym_imp_characterAtIndex);
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100227/7a43438a/attachment.html>


More information about the macruby-changes mailing list