Charlie, I will definitely look up the presentation, and I appreciate yourself possibly repeating yourself here. I will throw up a wiki page to help other padawans like myself.
Jon 2011/10/18 Charles Oliver Nutter <head...@headius.com> > I thought for sure I wrote up all this at one point, but perhaps not. > > Last year at RubyConf, Tom and I presented a hacking guide for JRuby > that might have some information useful to you. I'll answer your > specific questions below. > > In that jruby-spymemcached lib I linked, there's a Ruby file with an > example of loading a JRuby extension. These days, I prefer the method > I use there. There's a way to also get .jar files to be > autodiscovered, but it's flaky and weird and not as explicit as it > could be. > > WRT arguments: > > * ThreadContext is optional. The binding will detect if you want it or > not. You can always get it from thread locals > (getRuntime().getCurrentContext()) but passing it eliminates the > threadlocal hit. > * You can split methods up by how many args they take, using any > combination from zero to 3 args. Above that, you specify it as an > IRubyObject[] and include required/optional/rest counts in the > extensions. Splitting up by arity greatly reduces the invocation cost, > since we don't have to box argument lists. > * Block is optional; if you want to call it, you need to declare it. > If you don't declare it, it's hard or impossible to get at any passed > block (so passed blocks are generally ignored). > > That should help you on your way. If you start a wiki page I'll help > fill it out. > > - Charlie > > On Tue, Oct 18, 2011 at 11:56 PM, Jonathan Coveney <jcove...@gmail.com> > wrote: > > A possibly related question: > > > > I want to implement list for a custom object...for guidance I am looking > at > > RubyArray's implementation. The method signature for each is: > > public IRubyObject each(ThreadContext context, Block block) { > > return block.isGiven() ? eachCommon(context, block) : > > enumeratorize(context.getRuntime(), this, "each"); > > } > > > > What controls which methods receive a ThreadContext and which do not? I > look > > in the method declarations and some do, some do not. If I have a method > that > > needs the runtime, is there a way that I can get it? > > > > Thanks for your help, I promise I'll try and pay it forward :) > > Jon > > > > 2011/10/18 Jonathan Coveney <jcove...@gmail.com> > >> > >> Charlie, > >> > >> Thanks for your guidance. > >> > >> It makes sense that you need to have this binding, but I'm not sure > about > >> how to implement Library. What action causes load to be invoked? A > require > >> statement? > >> > >> Thanks > >> > >> 2011/10/18 Charles Oliver Nutter <head...@headius.com> > >>> > >>> Hmm, not really any good docs. Along with annotating, you need to > >>> define the extension classes and tell them to bind annotated methods. > >>> A good example extension would be jruby-spymemcached: > >>> > >>> https://github.com/headius/jruby-spymemcached > >>> > >>> Key details are clsOrMod.defineAnnotatedMethods(Something.class) and > >>> not shown in this extension is the constant version > >>> clsOrMod.defineAnnotatedConstants(Something.class). > >>> > >>> - Charlie > >>> > >>> On Tue, Oct 18, 2011 at 11:34 PM, Jonathan Coveney <jcove...@gmail.com > > > >>> wrote: > >>> > Adding to this, I tried including @JRubyMethod tags and whatnot as > per > >>> > the > >>> > instructions, and I compiled my project and it didn't seem like they > >>> > got > >>> > picked up...is there something special I need to do? > >>> > > >>> > Thanks again. I am really intrigued by this project. > >>> > > >>> > 2011/10/18 Jonathan Coveney <jcove...@gmail.com> > >>> >> > >>> >> Is there any documentation on using @JRubyMethod, @JRubyClass, that > >>> >> sort > >>> >> of thing, and the arguments that they accept? I can sort of figure > it > >>> >> out > >>> >> from the source but it is all uncommented and I can't find anything > in > >>> >> the > >>> >> wiki. In the same vein, any tips on extending RubyObject would be > >>> >> lovely. > >>> >> > >>> >> Thanks! > >>> >> Jon > >>> > > >>> > > >>> > >>> --------------------------------------------------------------------- > >>> To unsubscribe from this list, please visit: > >>> > >>> http://xircles.codehaus.org/manage_email > >>> > >>> > >> > > > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > >