|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.luaj.vm2.Varargs
org.luaj.vm2.LuaValue
org.luaj.vm2.LuaFunction
org.luaj.vm2.lib.LibFunction
org.luaj.vm2.lib.VarArgFunction
org.luaj.vm2.lib.OsLib
public class OsLib
Subclass of LibFunction which implements the standard lua os library.
It is a usable base with simplified stub functions for library functions that cannot be implemented uniformly on Jse and Jme.
This can be installed as-is on either platform, or extended and refined to be used in a complete Jse implementation.
Because the nature of the os library is to encapsulate
os-specific features, the behavior of these functions varies considerably
from their counterparts in the C platform.
The following functions have limited implementations of features that are not supported well on Jme:
execute()remove()rename()tmpname()
Typically, this library is included as part of a call to either
JmePlatform#standardGlobals()
To instantiate and use it directly,
link it into your globals table via LuaValue.load(LuaValue) using code such as:
LuaTable _G = new LuaTable();
LuaThread.setGlobals(_G);
_G.load(new BaseLib());
_G.load(new PackageLib());
_G.load(new OsLib());
System.out.println( _G.get("os").get("time").call() );
Doing so will ensure the library is properly initialized
and loaded into the globals table.
LibFunction,
JseOsLib,
JsePlatform,
JmePlatform,
http://www.lua.org/manual/5.1/manual.html#5.8| Field Summary | |
|---|---|
static java.lang.String |
TMP_PREFIX
|
static java.lang.String |
TMP_SUFFIX
|
| Fields inherited from class org.luaj.vm2.lib.LibFunction |
|---|
name, opcode |
| Fields inherited from class org.luaj.vm2.LuaFunction |
|---|
env, s_metatable |
| Fields inherited from class org.luaj.vm2.LuaValue |
|---|
ADD, CALL, CONCAT, DIV, EMPTYSTRING, EQ, FALSE, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, NILS, NONE, NOVALS, ONE, POW, SUB, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TOSTRING, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, UNM, ZERO |
| Constructor Summary | |
|---|---|
OsLib()
Create and OsLib instance. |
|
| Method Summary | |
|---|---|
protected double |
clock()
|
protected java.lang.String |
date(java.lang.String format,
double time)
If the time argument is present, this is the time to be formatted (see the os.time function for a description of this value). |
protected double |
difftime(double t2,
double t1)
Returns the number of seconds from time t1 to time t2. |
protected int |
execute(java.lang.String command)
This function is equivalent to the C function system. |
protected void |
exit(int code)
Calls the C function exit, with an optional code, to terminate the host program. |
protected java.lang.String |
getenv(java.lang.String varname)
Returns the value of the process environment variable varname, or null if the variable is not defined. |
LuaValue |
init()
|
Varargs |
invoke(Varargs args)
Override and implement for the best performance. |
protected void |
remove(java.lang.String filename)
Deletes the file or directory with the given name. |
protected void |
rename(java.lang.String oldname,
java.lang.String newname)
Renames file or directory named oldname to newname. |
protected java.lang.String |
setlocale(java.lang.String locale,
java.lang.String category)
Sets the current locale of the program. |
protected long |
time(LuaTable table)
Returns the current time when called without arguments, or a time representing the date and time specified by the given table. |
protected java.lang.String |
tmpname()
Returns a string with a file name that can be used for a temporary file. |
| Methods inherited from class org.luaj.vm2.lib.VarArgFunction |
|---|
call, call, call, call, onInvoke |
| Methods inherited from class org.luaj.vm2.lib.LibFunction |
|---|
bind, bind, newupe, newupl, newupn, tojstring |
| Methods inherited from class org.luaj.vm2.LuaFunction |
|---|
checkfunction, getfenv, getmetatable, isfunction, optfunction, setfenv, type, typename |
| Methods inherited from class org.luaj.vm2.Varargs |
|---|
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, 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, subargs, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, type |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static java.lang.String TMP_PREFIX
public static java.lang.String TMP_SUFFIX
| Constructor Detail |
|---|
public OsLib()
| Method Detail |
|---|
public LuaValue init()
public Varargs invoke(Varargs args)
VarArgFunction
invoke in class 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)protected double clock()
protected double difftime(double t2,
double t1)
t2 - t1 -
protected java.lang.String date(java.lang.String format,
double time)
format - time - time since epoch, or -1 if not supplied
protected int execute(java.lang.String command)
command - command to pass to the systemprotected void exit(int code)
code - protected java.lang.String getenv(java.lang.String varname)
varname -
protected void remove(java.lang.String filename)
throws java.io.IOException
filename -
java.io.IOException - if it fails
protected void rename(java.lang.String oldname,
java.lang.String newname)
throws java.io.IOException
oldname - old file namenewname - new file name
java.io.IOException - if it fails
protected java.lang.String setlocale(java.lang.String locale,
java.lang.String category)
locale - category -
protected long time(LuaTable table)
table -
protected java.lang.String tmpname()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||