On Feb 10, 2009, at 8:37 PM, S. Woodside wrote:
On 2009-02-10, at 4:10 PM, Benjamin Stiglitz wrote:
I describe calling ruby side objects from the ObjC side. I can
make it work using dynamic classes but of course that generates
compiler warnings (like no '-baz' method found). Of course it
still works, but is there any way for my ObjC classes to know at
compile time what are the class names and methods on the ruby
classes?
Not really, since this list is potentially dynamic.
You mean like with define_method? Something like this could also
happen in ObjC anyway, using forwardInvocation: ... although that's
really more like method_missing. In fact I think I even used it that
way a few years ago :-)
Certainly it "looks" the same to the caller either way...
What Ben means I think is that methods in Ruby can be created on the
fly at runtime and that it might be hard to get an accurate list of
them at compilation time. You might need to process with evaluation.
The same is totally true in Objective-C, though it's not as frequent,
since you need to call the Objective-C runtime APIs.
Now, regarding your compiler warning, there are a few ways to work
around it (as you may already know), by either defining the methods
inside an informal protocol, recreating the Ruby classes/methods by
yourself, or using performSelector: or its variants.
That being said, it’d be nice if the runtime could dump a header
for the current state of a class, ScriptingBridge-style. I might
look into this.
That would be awesome. Something like sdef/sdp for Ruby classes
maybe those tools would be useful already.
Would be trivial to implement, maybe we could even introduce a
parameter to the macruby executable to do this post-evaluation! Ben,
wanna look at this? :-)
Laurent
_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel