jashkenas
Junior Member
Offline
Posts: 67
Re: Questions regarding ruby-processing
Reply #2 - Jan 22nd , 2009, 7:37pm
Hi Mike. I'll try to add a page sometime soon on the wiki about Ruby-Processing internals, and I'll update this post when that happens, but for now here's a quick overview: When you run the rp5 command, it starts out in regular ruby, ensuring that your sketch exists, figuring out the command you want to run and generating any applets or applications if that's what you asked for... If rp5 determines that you want to run a sketch (either run, watch, or live), it replaces itself with a Java process that loads JRuby, and JRuby proceeds to load the Ruby-Processing codebase and start the sketch. Things get interesting inside of JRuby, though, because you're running a processing sketch inside of a class hierarchy that looks like this: processing.core.PApplet (Java Space) Processing::App (JRuby Space) YourSketch (JRuby Space) When you call methods inside of your sketch, JRuby may be calling methods in either JRuby or Java space, depending on whether the method is defined in the Processing::App or the processing.core.PApplet. For most methods defined in the Processing API, that means calling into Java, with JRuby taking care of converting all the arguments. However, some useful methods (like load_library and render_mode) are defined in Ruby. Hope that clears things up a bit. It's really just a thin skin between Processing and JRuby, and relies heavily on the fact that JRuby classes are able to subclass Java-defined classes. -- omygawshkenas