From: Zach Dennis Date: 2004-11-17T15:42:19+09:00 Subject: Ruby to C to another language (perhaps Java (I Don't Need JRuby)) This posting is more for a learning thing then anything else at this point. I've been playing with Java to C via JNI lately doing some pretty basic tests; calling methods, getting and settings fields, passing primitive types around, etc... A while back (a few months ago) I did some Ruby to C tests of pretty much the same caliber. I would like to combine the two approaches and share some objects between Ruby to C to Java and vise versa. I am not looking for the JVM to be able to process ruby code. (no JRuby) Has anyone had a similar approach (even if it wasn't Java) where they were able to wrap a few Objects and use C as the middle man to communicate? If so, did you have to embed the ruby compiler inside the *.so or *.dll file when running the interpretor of the other language (i presume yes?) and what was the level of difficulty (one word answers are fine. I can live with easy, hard, difficult, if you want to share a whole paragraph then please do)? Is it difficult to share data structures between three different languages. Again Ruby/C/"3rd Language"? What I am trying to get out of this is in the long run is to be able to have a few data structures that I can share between Ruby and Java, via C. I currently have java application and I feel I could code quicker certain aspects alot quicker in Ruby if only I could share a data structure/object. Ideally I would like to do something like: ---In My Ruby Code--- class StringProcessor def process_str( str ) #process return process_str end end ---In my Java Code---- class StringProcessor{ public native String _processString( String str ); public void processString( String str ){ this._processString( str ); } public static void main( String[] args ){ new StringProcessor().processString( aBigString ); } } -----In my C Code (pseudo)----- Java_StringProcessor__processString jstring ( jstring str ){ char c = jStringToCharArray( str ) c = Ruby_StringProcessor_processString( c ) return charToJString( c ) } jStringToCharArray char[] ( jstring str ){ char[] c //convert return c } charToJString jstring( char[] c ) jstring j //convert return j } Ruby_StringProcessor_processString char[] ( rstring str ){ char[] c; //Process return c; } This is not a well thought out example. It's just off the top of my head. So does anyone know if this is possible? Thanks, Zach