Hi Luke,
On Nov 25, 2008, at 2:57 PM, Luke Evans wrote:
Hi,
Thanks for MacRuby, I'm going to follow its development closely.
While I wouldn't use Ruby (without static typing) for large-scale
development, IMHO, it is my favourite scripting language for those
"little jobs", and I'm currently interested in it as an embedded
language in my app.
Given the interest, I thought I would try creating a mini obj-c
project, including the MacRuby framework, to attempt some simple
interactions with ruby from obj-c. Accordingly, I created some toy
code:
- (void)awakeFromNib {
ruby_init();
rb_eval_string("puts 'hello world'");
ruby_finalize();
}
Running my little app, results in a series of messages of the form"
warning: Could not find object file "/private/tmp/trunk/xxxxx.o" -
no debug information available for "xxxxx.c"
where xxxxx are things like "array", "bignum", "class",
"compar", ... etc.
The app then crashes with a stack walk back containing a huge number
of nested exceptions (it seems).
Now, it's quite possible that I'm just not driving this right (to
date I've always scripted in Ruby, and never attempted to drive it
from C). Equally, I'd imagine that it's possible that the 0.3
version of the framework isn't up to this yet.
If I can get past this point, I can see the objective-c interfacing
functions in the header file, so things might be peachy from then
on :-)
Can anyone enlighten me?
MacRuby trunk ships an Objective-C API that you can use to communicate
with the interpreter.
See the include/ruby/objc.h file for the API:
http://www.macruby.org/trac/browser/MacRuby/trunk/include/ruby/objc.h
And the sample-macruby/EmbeddedMacRuby project for an example:
http://www.macruby.org/trac/browser/MacRuby/trunk/sample-macruby/EmbeddedMacRuby
Note that there are currently 2 known bugs about this "feature". These
will be fixed for 0.4 (the next release).
http://www.macruby.org/trac/ticket/164
http://www.macruby.org/trac/ticket/165
Laurent
_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel