That's the approach we've taken with Renjin and GNU R's C API. You can basically tell the compiler to map a C struct to a given java class, for example, mapping CRuby's VALUE to org.jruby.RubyBasicObject and import
GimpleCompiler compiler = new GimpleCompiler(); compiler.addRecordClass("__VALUE", RubyBasicObject.class); compiler.addMethod("TYPE", CRuby.class, "TYPE"); You can then define: class CRuby { public static int TYPE(RubyBasicObject obj) { if(obj instance of RubyBoolean) return 1; if(obj instance of RubyHash) return 2; // etc... } } We monkey with the GNU R header files to make replace macros with function declarations so they can mapped to JVM methods. -Alex On Monday, February 1, 2016 at 2:31:37 PM UTC+1, Charles Nutter wrote: > > Yay! I will have to look into this. We have an interest in compiling Ruby > C extensions to Java and providing a JVM-level implementation of Ruby's C > API. > > - Charlie (mobile) > On Feb 1, 2016 1:09 PM, "Alexander Bertram" <al...@bedatadriven.com > <javascript:>> wrote: > >> Hi all, >> >> I've finally gotten around to writing a bit about GCC-Bridge, the >> C/Fortran compiler used by Renjin to compile R packages with "native" code >> to the JVM. >> http://www.renjin.org/blog/2016-01-31-introducing-gcc-bridge.html >> >> The compiler's recently benefited from a near total rewrite to target >> Java 1.7 (including using MethodHandles for function pointers, which are a >> great fit) and >> we are looking to support C++ code in the near future, which is a >> actually not such a big step as we are using GCC as a frontend. >> >> We've been careful to keep gcc-bridge usable apart from Renjin, so would >> welcome collaboration with other J* languages interested in a better >> supporting native >> extensions/gems/modules! >> >> All the best, >> Alex >> >> -- >> You received this message because you are subscribed to the Google Groups >> "JVM Languages" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to jvm-language...@googlegroups.com <javascript:>. >> To post to this group, send email to jvm-la...@googlegroups.com >> <javascript:>. >> Visit this group at https://groups.google.com/group/jvm-languages. >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "JVM Languages" group. To unsubscribe from this group and stop receiving emails from it, send an email to jvm-languages+unsubscr...@googlegroups.com. To post to this group, send email to jvm-languages@googlegroups.com. Visit this group at https://groups.google.com/group/jvm-languages. For more options, visit https://groups.google.com/d/optout.