Hi,

Good catch, the Method structure is likely clashing with the Ruby Method class :) I'm not sure if we should try to make it work, as it's surely an edge case. Maybe #load_bridge_support_file should accept a Module object where the constants should be defined, as a second, optional, argument?

As for calling the runtime from MacRuby, I think that most runtime functions are already used in MacRuby somehow and exposed through the Ruby API. 

For example, #methods(true, true) calls class_copyMethodList().

Laurent

On Jan 6, 2011, at 12:17 PM, kyossi wrote:

Hi,

MacRuby support bridgesupport .You can call any C-function,
See "Accessing Static APIs" in
http://www.macruby.org/documentation/tutorial.html


but..I cannot load bridgesupport file for runtime.h

$ cd /Developer/SDKs/MacOSX10.6.sdk/usr/include/objc
$ gen_bridge_metadata -c '-I.' runtime.h > ~/Desktop/runtime.bridgesupport
$ macirb
irb > load_bridge_support_file "/Users/kyossi/Desktop/runtime.bridgesupport"
NameError: Method is already defined

It seems like one line in runtime.bridgesupport conflict with Method
class in ruby.
<opaque name='Method' type='^{objc_method=}'/>

When I tried with comment out above line, load_bridge_support_file()
succeeded and could call some function.

irb > load_bridge_support_file "/Users/kyossi/Desktop/runtime.bridgesupport"
=> main
irb > class_getName(NSString)
=> "NSString"

I could not go further.



2011/1/7 Garett Shulman <garett.shulman@gmail.com>:
I'm guessing this is documented somewhere but have not been able to find it
yet... How can objective C runtime methods such as class_copyMethodList be
called from MacRuby?  Thanks! -Garett

_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel