[Rubycocoa-devel 880] Re: using RBBundleInit in a plugin

Back to archive index

jeanp****@gmail***** jeanp****@gmail*****
Thu May 17 07:26:30 JST 2007


On 5/6/07, jeanp****@gmail***** <jeanp****@gmail*****> wrote:
>
>
> On 4/24/07, jeanp****@gmail***** <jeanp****@gmail*****> wrote:
> >
> > On 4/24/07, Fujimoto Hisa < hisa****@fobj*****> wrote:
> > >
> > > I'm not good for TextMate, but writing plugin enabler for it may be
> > > almost same as sample/VPRubyPluginEnabler.
> > >
> > >    * write plugin enabler (like sample/VPRubyPluginEnabler), it should
> > >      run in the TextMate process.
> > >    * the enabler should be written loading a ruby program as plugin.
> > >    * loaded ruby program should run in the same process, so it's
> > > enable
> > >      to access objects in the process.
> >
> >
> > hisa-san, i was hoping the textmate case might be similar to voodoopad
> > so i could study what you have done there. i have a VPRubyPluginEnabler-like
> > plugin for textmate, it simply loads a helper script that displays some
> > dialogues, calls NSBeep() and a few other assorted rubycocoa things. what i
> > now need to figure out is how to have it load the scripts (textmate
> > commands) so they are run in the same process.
> >
>
> i am still a bit stumped on this one.
>
> textmate plugins are normal NSObjects, so i am unsure how i can initialize
> my objc plugin to be fully rubycocoa savvy. calling RBBundleInit certainly
> allows me to call into ruby but after that returns, how do i call into ruby
> classes again? i think this is where rb_main usually kicks in and lets one
> repeatedly call in but i'm not really sure.
>
> i am thinking the easiest to accomplish a rubycocoa script running plugin
> in textmate would be to break the functionality in two. there will be a
> simple command line tool which uses some IPC to talk with the plugin to have
> it load and run[1] a script.
>
> kinda like this:
>   script (ruby) -> tool --IPC-> plugin (objc) -> helper (ruby) which evals
> the script
>
> i thought i could simply declare the interface to my helper class and the
> runtime would resolve it (after requiring it in RBBundleInit) but i get link
> errors. so what am i missing, why can i repeatedly call into ruby classes in
> a rubycocoa application / RBApplicationMain but not with an NSObject /
> RBBundleInit? i cheated and used NSClassFromString but this only allowed me
> to link and it crashed on execution.
>
> alternatively, i could run the other end of the IPC (DO actually) in the
> ruby helper as called by RBBundleInit but i can't create a second thread to
> spin its own runloop.
>

thought i'd post an update on my findings - vending an object via
distributed objects from rubycocoa currently isn't working, but in the
interim i can use a distributed notification from the runner tool to the
plugin to have the plugin eval the script - this works and allows scripts
making use of rubycocoa run in the right process.

for security reasons, i am still not thrilled with the thought of using IPC
to trigger an eval of code but i'll keep thinking. additionally, i'll need
to figure out how to get output back. maybe i need to create a
RubyMate/ScriptMate-like RubyCocoaMate which automatically uses the runner
tool to feed the plugin the code and still dumps output...

so its kinda setup like this:
[1] textmate (irrelevant) -> rubycocoa plugin (objc) -> rubycocoa helper
object (ruby) listens for notifications and evals
[2] runner tool (ruby) sends notification with path of script to run

cheers,
jean-pierre
-------------- next part --------------
An HTML attachment was scrubbed...
Descargar 


More information about the Rubycocoa-devel mailing list
Back to archive index