Package com.prineside.luaj.lib.jse
Class CoerceJavaToLua
java.lang.Object
com.prineside.luaj.lib.jse.CoerceJavaToLua
Helper class to coerce values from Java to lua within the luajava library.
This class is primarily used by the org.luaj.vm2.lib.jse.LuajavaLib, but can also be used directly when working with Java/lua bindings.
To coerce scalar types, the various, generally the valueOf(type)
methods
on LuaValue
may be used:
LuaValue.valueOf(boolean)
LuaValue.valueOf(byte[])
LuaValue.valueOf(double)
LuaValue.valueOf(int)
LuaValue.valueOf(String)
To coerce arrays of objects and lists, the listOf(..)
and tableOf(...)
methods
on LuaValue
may be used:
coerce(Object)
looks as the type and dimesioning
of the argument and tries to guess the best fit for corrsponding lua scalar,
table, or table of tables.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static final class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
instanceCoercion
-
-
Constructor Details
-
CoerceJavaToLua
public CoerceJavaToLua()
-
-
Method Details
-
coerce
Coerse a Java object to a corresponding lua value.Integral types
boolean
,byte
,char
, andint
will become ;long
,float
, anddouble
will become ;String
andbyte[]
will becomeLuaString
; types inheriting fromLuaValue
will be returned without coercion; other types will becomeLuaUserdata
.- Parameters:
o
- Java object needing conversion- Returns:
LuaValue
corresponding to the supplied Java value.- See Also:
-