The Java Frontend has been updated to work with the Giws JNI wrapper generator, this lets you create Java objects and call their methods from C++, and also from Rusthon when using the C++ backend. Giws supports all of Java's primitive types like numbers, strings, and arrays; one problem is class constructors see this git hub issue.
The new syntax is documented in the wiki, here. Java source that you embed in the markdown is compiled with javac, xml source in the markdown that is marked with @giws will run giws and generate the c++ wrappers. In rusthon code using import jvm will link the final exe to libjvm.so and also create an instance of the JavaVM.
Jython Hello World
source code: giws_jython.mdSee the source code in giws_jython.md to see the xml wrapper code the exposes Jython's PythonInterpreter, this simple example only wraps the exec method.
rusthon input
import jvm jvm.load( 'jython.jar' ) jvm.namespace('org.python.util') def main(): interp = jvm( PythonInterpreter() ) script = "print 'hello world'" interp.__exec__(cstr(script))
c++ output
using namespace org_python_util; int main() { auto interp = std::make_shared(__javavm__); auto script = std::string("print 'hello world'"); interp->exec(cstr(script)); return 0; }
Similar projects that allow Java to be used in CPython: Py4J, and Jpype.
I am wondering which one is better between PythonJS and Coffeescript.
ReplyDeleteOne of the major features of Rusthon is having a single meta-language, write once and translate to the language you need. CoffeeScript, is not typed, and only targets JavaScript.
ReplyDelete