Revision
3192
Author
lsansonetti@apple.com
Date
2010-01-05 16:59:27 -0800 (Tue, 05 Jan 2010)

Log Message

FFI::Library#attach_function: the first argument can also be a symbol

Modified Paths

Diff

Modified: MacRuby/trunk/bridgesupport.cpp (3191 => 3192)


--- MacRuby/trunk/bridgesupport.cpp	2010-01-06 00:46:47 UTC (rev 3191)
+++ MacRuby/trunk/bridgesupport.cpp	2010-01-06 00:59:27 UTC (rev 3192)
@@ -1342,7 +1342,14 @@
 static VALUE
 rb_ffi_attach_function(VALUE rcv, SEL sel, VALUE name, VALUE args, VALUE ret)
 {
-    const char *symname = StringValueCStr(name);
+    const char *symname;
+    if (TYPE(name) == T_SYMBOL) {
+	symname = rb_id2name(SYM2ID(name));
+    }
+    else {
+	StringValue(name);
+	symname = RSTRING_PTR(name);
+    }
     void *sym = dlsym(RTLD_DEFAULT, symname);
     if (sym == NULL) {
 	rb_raise(rb_eArgError, "given function `%s' could not be located",