On 6/12/07, Ola Bini <[EMAIL PROTECTED]> wrote:
So, anyone who have looked at our code knows that an annoying part of
the setup of each Ruby class is a long list of CallbackFactory calls.
Brixen of Rubinius just showed me part of their FFI, which would make
total sense for our purposes. What the example looks like is this:

s = Compression::ZLib.deflate("test")
Compression::ZLib.inflate(s)
module F
 attach_function nil, "compress_inflate", :inflate, [:state, :string], :object
end
F.inflate(nil, s)

In our case, we could have a part of Kernel look like this:

module Kernel
  attach_method "org.jruby.RubyKernel", "new_array", :Array, [:object]
  attach_method "org.jruby.RubyKernel", "new_float", :Float, [:object]
end

I think that would be much better than our current solution, and also
easier for third party extension developers.

I agree, I like this a lot.  The logical extension of this is to get
rid of the need for all the *Library classes and have a foo_library.rb
file in the root of foo.jar that contains the above code along with
any java classes for implementing the library.

Actually, the other crazy extension of this is to implement RubyInline
for Java, which I've had on my list for a while, but that's not
completely on-topic.

/Nick

---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to