[macruby-changes] [3192] MacRuby/trunk/bridgesupport.cpp
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jan 5 16:59:27 PST 2010
Revision: 3192
http://trac.macosforge.org/projects/ruby/changeset/3192
Author: lsansonetti at 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:
--------------
MacRuby/trunk/bridgesupport.cpp
Modified: MacRuby/trunk/bridgesupport.cpp
===================================================================
--- 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",
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100105/3f4a4d66/attachment.html>
More information about the macruby-changes
mailing list