public class LuajavaLib extends VarArgFunction
LibFunction which implements the features of the luajava package.
Luajava is an approach to mixing lua and java using simple functions that bind java classes and methods to lua dynamically. The API is documented on the luajava documentation pages.
Typically, this library is included as part of a call to
JsePlatform.standardGlobals()
Globals globals = JsePlatform.standardGlobals();
System.out.println( globals.get("luajava").get("bindClass").call( LuaValue.valueOf("java.lang.System") ).invokeMethod("currentTimeMillis") );
To instantiate and use it directly,
link it into your globals table via Globals.load(java.lang.String, java.lang.String) using code such as:
Globals globals = new Globals();
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new LuajavaLib());
globals.load(
"sys = luajava.bindClass('java.lang.System')\n"+
"print ( sys:currentTimeMillis() )\n", "main.lua" ).call();
The luajava library is available
on all JSE platforms via the call to JsePlatform.standardGlobals()
and the luajava api's are simply invoked from lua.
Because it makes extensive use of Java's reflection API, it is not available
on JME, but can be used in Android applications.
This has been implemented to match as closely as possible the behavior in the corresponding library in C.
LibFunction,
JsePlatform,
org.luaj.vm2.lib.jme.JmePlatform,
LuaC,
CoerceJavaToLua,
CoerceLuaToJava,
http://www.keplerproject.org/luajava/manual.html#luareferencename, opcodes_metatableADD, BAND, BNOT, BOR, BXOR, CALL, CONCAT, DIV, EMPTYSTRING, ENV, EQ, FALSE, IDIV, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, NILS, NONE, NOVALS, ONE, POW, SHL, SHR, SUB, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TOSTRING, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, UNM, uservalue, ZERO| 构造器和说明 |
|---|
LuajavaLib() |
| 限定符和类型 | 方法和说明 |
|---|---|
static LuaValue |
asTable(boolean dep,
Object obj) |
static LuaValue |
asTable(Object obj) |
static org.luaj.vm2.lib.jse.JavaClass |
bindClassForName(String name) |
protected Class<?> |
classForName(String name) |
static LuaUserdata |
createProxy(Class clazz,
LuaValue lobj) |
Varargs |
invoke(Varargs args)
Subclass responsibility.
|
checkfunction, classnamestub, getfenv, getmetatable, isfunction, name, optfunction, setfenv, strvalue, type, typenameadd, add, add, and, arg, arg1, argerror, argerror, aritherror, aritherror, arithmt, arithmtwith, assert_, band, band, bnot, bor, bor, buffer, bxor, bxor, call, callmt, checkboolean, checkclosure, checkdouble, checkglobals, checkint, checkinteger, checkjstring, checklong, checkmetatag, checknotnil, checknumber, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, compareerror, compareerror, comparemt, concat, concat, concatmt, concatTo, concatTo, concatTo, div, div, div, divInto, eq_b, eq, eqmtcall, equals, error, get, get, get, gettable, getuservalue, gt_b, gt_b, gt_b, gt, gt, gt, gteq_b, gteq_b, gteq_b, gteq, gteq, gteq, idiv, idiv, illegal, inext, initupvalue1, invoke, invoke, invoke, invoke, invoke, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, isboolean, isclosure, isint, isinttype, islong, isnil, isnumber, isstring, istable, isthread, isuserdata, isuserdata, isvalidkey, jcall, jget, jset, len, lenerror, length, listOf, listOf, load, lt_b, lt_b, lt_b, lt, lt, lt, lteq_b, lteq_b, lteq_b, lteq, lteq, lteq, metatableOf, metatag, method, method, method, method, method, method, mod, mod, mod, modFrom, mul, mul, mul, narg, neg, neq_b, neq, next, not, optboolean, optclosure, optdouble, optint, optinteger, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, or, pow, pow, pow, powWith, powWith, presize, raweq, raweq, raweq, raweq, raweq, rawget, rawget, rawget, rawlen, rawset, rawset, rawset, rawset, rawset, rawset, rawset, rawsetlist, set, set, set, set, set, set, set, setmetatable, settable, setuservalue, shl, shl, shr, shr, strcmp, strcmp, strongvalue, sub, sub, sub, subargs, subFrom, subFrom, tableOf, tableOf, tableOf, tableOf, tableOf, tableOf, tailcallOf, testfor_b, toboolean, tobyte, tochar, todouble, tofloat, toint, tolong, tonumber, toshort, tostring, toString, touserdata, touserdata, typerror, unimplemented, userdataOf, userdataOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOfargcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, dealias, eval, isfunction, isnil, isnoneornil, isnumber, isstring, istable, isTailcall, isthread, isuserdata, isvalue, optboolean, optclosure, optdouble, optfunction, optint, optinteger, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, typepublic Varargs invoke(Varargs args)
VarArgFunctioninvoke 在类中 VarArgFunctionargs - the arguments to the function call.Varargs instance.LuaValue.varargsOf(LuaValue[]),
LuaValue.call(LuaValue),
LuaValue.invoke(),
LuaValue.invoke(LuaValue,Varargs),
LuaValue.invokemethod(String,Varargs),
LuaValue.invokemethod(LuaValue,Varargs)public static LuaUserdata createProxy(Class clazz, LuaValue lobj)
protected Class<?> classForName(String name) throws ClassNotFoundException
public static org.luaj.vm2.lib.jse.JavaClass bindClassForName(String name) throws ClassNotFoundException
Copyright © 2020. All rights reserved.