[macruby-changes] [3723] MacRuby/branches/icu/string.c
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 9 17:54:21 PST 2010
Revision: 3723
http://trac.macosforge.org/projects/ruby/changeset/3723
Author: lsansonetti at apple.com
Date: 2010-03-09 17:54:21 -0800 (Tue, 09 Mar 2010)
Log Message:
-----------
added NSData#to_str as a convenience method
Modified Paths:
--------------
MacRuby/branches/icu/string.c
Modified: MacRuby/branches/icu/string.c
===================================================================
--- MacRuby/branches/icu/string.c 2010-03-10 01:53:55 UTC (rev 3722)
+++ MacRuby/branches/icu/string.c 2010-03-10 01:54:21 UTC (rev 3723)
@@ -5226,6 +5226,15 @@
str_splice(RSTR(rcv), range.location, range.length, spat, true);
}
+// :nodoc:
+static VALUE
+nsdata_to_str(VALUE data, SEL sel)
+{
+ CFDataRef dataref = (CFDataRef)data;
+ return rb_bstr_new_with_data(CFDataGetBytePtr(dataref),
+ CFDataGetLength(dataref));
+}
+
void
Init_String(void)
{
@@ -5373,6 +5382,11 @@
rb_fs = Qnil;
rb_define_variable("$;", &rb_fs);
rb_define_variable("$-F", &rb_fs);
+
+ // NSData extensions.
+ VALUE NSData = (VALUE)objc_getClass("NSData");
+ assert(NSData != 0);
+ rb_objc_define_method(NSData, "to_str", nsdata_to_str, 0);
}
bool
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100309/d87ca770/attachment.html>
More information about the macruby-changes
mailing list