public class ScriptContext extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
ScriptContext.CompiledScript
A compiled script for future call
|
class |
ScriptContext.Func |
| 构造器和说明 |
|---|
ScriptContext() |
ScriptContext(boolean importAllFunctions) |
ScriptContext(boolean importAllFunctions,
boolean localFunction) |
| 限定符和类型 | 方法和说明 |
|---|---|
ScriptContext |
addToLua(String name,
Object obj) |
ScriptContext |
addToLua(String name,
Object obj,
boolean local) |
ScriptContext |
addToLua(String luaName,
String memberName,
Object instOrType) |
ScriptContext |
addToLua(String luaName,
String memberName,
Object instOrType,
boolean local) |
ScriptContext |
addToLua(String luaName,
String memberName,
Object inst,
Class type,
boolean local) |
static <T> T |
changeCallSite(LuaFunction function,
Class<T> target)
change a lua function to a functional interface instance
|
ScriptContext.CompiledScript |
compile(File file) |
ScriptContext.CompiledScript |
compile(String script) |
static boolean |
equalsParameters(Class<?>[] params1,
Class<?>[] params2) |
protected void |
finalize() |
void |
flushLog()
flush log
|
Object |
get(String name) |
<T> void |
putIndexer(Class<T> target,
Indexer<? super T> indexer)
add an indexer for index or new index or length call
|
<T> void |
putIteratorFactory(Class<T> target,
IteratorFactory<? super T> factory)
add an iterator factory to generate a iterator for pairs call
|
<T,F extends T> |
putTableConverter(Class<T> type,
TableConverter<F> converter)
Take care if a converter exists
|
ScriptContext |
removeFromLua(String name)
remove a global value from lua state
|
Object[] |
run(File scriptFile,
Object... args) |
Object[] |
run(ScriptContext.CompiledScript script,
Object... args) |
Object[] |
run(String script,
Object... args) |
void |
setErrLogger(OutputStream errLogger) |
void |
setLogger(OutputStream outLogger,
OutputStream errLogger) |
void |
setOutLogger(OutputStream outLogger) |
public ScriptContext()
public ScriptContext(boolean importAllFunctions)
public ScriptContext(boolean importAllFunctions,
boolean localFunction)
importAllFunctions - whether to use short namelocalFunction - whether functions to be use only in current threadpublic static <T> T changeCallSite(LuaFunction function, Class<T> target)
public <T> void putIndexer(Class<T> target, Indexer<? super T> indexer)
T - relative typetarget - target classindexer - indexerpublic <T> void putIteratorFactory(Class<T> target, IteratorFactory<? super T> factory)
T - relative typetarget - target classfactory - factorypublic <T,F extends T> TableConverter putTableConverter(Class<T> type, TableConverter<F> converter)
T - type to convertF - sub type of Ttype - type to convertconverter - table converterpublic void setLogger(OutputStream outLogger, OutputStream errLogger)
outLogger - where output message writes inerrLogger - where error message writes inpublic void setErrLogger(OutputStream errLogger)
errLogger - where error message writes inpublic void setOutLogger(OutputStream outLogger)
outLogger - where output message writes inpublic void flushLog()
public ScriptContext.CompiledScript compile(String script)
script - script stringpublic ScriptContext.CompiledScript compile(File file)
file - script filepublic Object[] run(ScriptContext.CompiledScript script, Object... args)
script - scriptargs - script argumentspublic Object[] run(String script, Object... args)
script - scriptargs - script argumentspublic Object[] run(File scriptFile, Object... args)
scriptFile - scriptargs - script argumentspublic final ScriptContext removeFromLua(String name)
name - lua global namepublic final ScriptContext addToLua(String name, Object obj)
public final ScriptContext addToLua(String name, Object obj, boolean local)
name - lua global nameobj - value,null to remove the global valuelocal - false:the method to be added to all lua state,and will be added to new lua states.
true:the method to be added to only current state.If no running state, no operation.public ScriptContext addToLua(String luaName, String memberName, Object instOrType)
public ScriptContext addToLua(String luaName, String memberName, Object instOrType, boolean local)
luaName - lua global namememberName - member name in the classinstOrType - object for method or the declaring classlocal - false:the method to be added to all lua state,and will be added to new lua states,
true:the method to be added to only current state.If no running state, no operation.LuaException - if the member not foundpublic ScriptContext addToLua(String luaName, String memberName, Object inst, Class type, boolean local)
luaName - lua global namememberName - member name in the classinst - instance for the method. Must be null for static methodtype - type for the method,nullable for object methodlocal - false:the method to be added to all lua state,and will be added to new lua states,
true:the method to be added to only current state.If no running state, no operation.LuaException - if the member not found