[MacRuby-devel] How to create loadable MacRuby bundle
Laurent Sansonetti
lsansonetti at apple.com
Mon Oct 13 22:42:57 PDT 2008
Hi Antonin,
On Oct 13, 2008, at 6:59 PM, Antonin Hildebrand wrote:
> Hi,
>
> Is it possible to create loadable MacRuby bundle to be loaded into
> another MacRuby application?
>
> I'm looking for replacement for RBBundleInit as described for
> RubyCocoa here:
> http://threeve.org/blog/2007/12/loadable-bundles-using-rubycocoa.html
>
> I'm loading bundles into my MacRuby app via:
> NSBundle.bundleWithPath(path).load
trunk has a preliminary Objective-C API that allows pure Objective-C
apps to initialize and use MacRuby (look at the MacRuby class defined
in the objc.h file in trunk), and RBBundleInit could therefore be
implemented based on that.
Could you give more details about what you are trying to do exactly?
Loading a MacRuby bundle in a MacRuby app looks weird, you could just
require the Ruby scripts.
If you want to load a .bundle that contains native code in a MacRuby
app, you can use the NSBundle API. You could also generate a dynamic
library and "require" it (assuming you have an Init_xxx exported
function).
If you want to load a .bundle that contains MacRuby code in a non-
MacRuby application, you will need the new Objective-C API (or use the
standard C API) to prepare the bundle. I could work on a sample code
that illustrates this if needed. The bundle could theoretically be
loaded in MacRuby apps as well, thought it would be a little bit
overkill since you could just directly "require" the Ruby scripts.
Laurent
More information about the MacRuby-devel
mailing list