Posted 06 October 2013 - 08:04 PM
For the past day or so I've been working on binding the incredibly fast LuaJIT to Java instead of LuaJ. Progress is available on github.
For now I'm calling this JLuaJIT (creative, right?). JLuaJIT is dependent on Java Native Access aka JNA (not Java Native Interface aka JNI) and a code generator called JNAerator, which generates JNA java classes for given C headers. JNA is an easy way to interface with a native shared library file on any platform as long as you provide the shared library for that platform.
The JLuaJIT build.xml script downloads JNA, JNAerator, and LuaJIT, builds LuaJIT, and moves the library file into the native/os-arch/ folder. If you would like to re-JNAerate the java files, run ant clean, then ant jnaerate.
In eclipse or intellij, just make sure native and jluajit are all referenced as source folders, download/jna-4.0.0.jar is in the classpath, and test is a test source.
Ok now for why the title says "attempting." I've only written one test so far, and it fails. luaL_newstate(); works just fine (equivalent to lua_open(), which is actually just #define lua_open() luaL_newstate()), but everything after that causes an error.
EDIT: Ok so newstate returns null in the event of a memory allocation error. But I'm not getting an error message if I only call newstate
EDIT2: I tried doing this whole setup entirely in 32 bit, and it works fine that way. I'm on OS X so if anyone can tell me whether it works in 32 or 64 bit on linux and windows, that'd be helpful.
For now I'm calling this JLuaJIT (creative, right?). JLuaJIT is dependent on Java Native Access aka JNA (not Java Native Interface aka JNI) and a code generator called JNAerator, which generates JNA java classes for given C headers. JNA is an easy way to interface with a native shared library file on any platform as long as you provide the shared library for that platform.
The JLuaJIT build.xml script downloads JNA, JNAerator, and LuaJIT, builds LuaJIT, and moves the library file into the native/os-arch/ folder. If you would like to re-JNAerate the java files, run ant clean, then ant jnaerate.
In eclipse or intellij, just make sure native and jluajit are all referenced as source folders, download/jna-4.0.0.jar is in the classpath, and test is a test source.
Ok now for why the title says "attempting." I've only written one test so far, and it fails. luaL_newstate(); works just fine (equivalent to lua_open(), which is actually just #define lua_open() luaL_newstate()), but everything after that causes an error.
Invalid memory access of location 0x8 rip=0x7fff04c58d1c
I believe the error is caused by the fact that luaL_newstate returns null. Not sure why it does that though.EDIT: Ok so newstate returns null in the event of a memory allocation error. But I'm not getting an error message if I only call newstate
EDIT2: I tried doing this whole setup entirely in 32 bit, and it works fine that way. I'm on OS X so if anyone can tell me whether it works in 32 or 64 bit on linux and windows, that'd be helpful.