Ryan Davis
Posts: 651
Nickname: zenspider
Registered: Oct, 2004
Ryan Davis is a ruby nerd.
Inline::ObjC
Posted: Dec 14, 2005 4:56 AM
This post originated from an RSS feed registered with Ruby Buzz
by Ryan Davis.
Original Post: Inline::ObjC
Feed Title: Polishing Ruby
Feed URL: http://blog.zenspider.com/index.rdf
Feed Description: Musings on Ruby and the Ruby Community...
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Ryan Davis
Latest Posts From Polishing Ruby
Advertisement
Nuno Cruces provided me the following gem (hacked up by yours truly):
require 'inline'
class Inline::ObjC < Inline::C
def initialize(mod)
super(mod)
end
def import(header)
@src << "#import #{header}"
end
end
class MyClass
inline(:ObjC) do |builder|
builder.import "<Foundation/NSString.h>"
builder.add_compile_flags '-x objective-c', '-framework Foundation'
builder.c %q{
void test() {
printf("%s\n", [@"Hello World!" cString]);
}
}
end
end
MyClass.new.test
I love it... OSX hackers, have at it...
Read: Inline::ObjC