Fix links in javadoc

This commit is contained in:
James Roseborough
2015-04-16 04:56:03 +00:00
parent f3fb9a7fde
commit 70f7859cee
37 changed files with 292 additions and 247 deletions

View File

@@ -28,6 +28,7 @@ import java.io.Reader;
import org.luaj.vm2.lib.BaseLib; import org.luaj.vm2.lib.BaseLib;
import org.luaj.vm2.lib.DebugLib; import org.luaj.vm2.lib.DebugLib;
import org.luaj.vm2.lib.IoLib;
import org.luaj.vm2.lib.PackageLib; import org.luaj.vm2.lib.PackageLib;
import org.luaj.vm2.lib.ResourceFinder; import org.luaj.vm2.lib.ResourceFinder;
@@ -37,7 +38,8 @@ import org.luaj.vm2.lib.ResourceFinder;
* *
* <h3>Constructing and Initializing Instances</h3> * <h3>Constructing and Initializing Instances</h3>
* Typically, this is constructed indirectly by a call to * Typically, this is constructed indirectly by a call to
* {@link JsePlatform.standardGlobasl()} or {@link JmePlatform.standardGlobals()}, * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()} or
* {@link org.luaj.vm2.lib.jme.JmePlatform#standardGlobals()},
* and then used to load lua scripts for execution as in the following example. * and then used to load lua scripts for execution as in the following example.
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
@@ -64,30 +66,30 @@ import org.luaj.vm2.lib.ResourceFinder;
* <ul> * <ul>
* <li>find the resource using the platform's {@link ResourceFinder} * <li>find the resource using the platform's {@link ResourceFinder}
* <li>compile lua to lua bytecode using {@link Compiler} * <li>compile lua to lua bytecode using {@link Compiler}
* <li>load lua bytecode to a {@link LuaPrototpye} using {@link Undumper} * <li>load lua bytecode to a {@link Prototype} using {@link Undumper}
* <li>construct {@link LuaClosure} from {@link Prototype} with {@link Globals} using {@link Loader} * <li>construct {@link LuaClosure} from {@link Prototype} with {@link Globals} using {@link Loader}
* </ul> * </ul>
* <p> * <p>
* There are alternate flows when the direct lua-to-Java bytecode compiling {@link LuaJC} is used. * There are alternate flows when the direct lua-to-Java bytecode compiling {@link org.luaj.vm2.luajc.LuaJC} is used.
* <ul> * <ul>
* <li>compile lua to lua bytecode using {@link Compiler} or load precompiled code using {@link Undumper} * <li>compile lua to lua bytecode using {@link Compiler} or load precompiled code using {@link Undumper}
* <li>convert lua bytecode to equivalent Java bytecode using {@link LuaJC} that implements {@link Loader} directly * <li>convert lua bytecode to equivalent Java bytecode using {@link org.luaj.vm2.luajc.LuaJC} that implements {@link Loader} directly
* </ul> * </ul>
* *
* <h3>Java Field</h3> * <h3>Java Field</h3>
* Certain public fields are provided that contain the current values of important global state: * Certain public fields are provided that contain the current values of important global state:
* <ul> * <ul>
* <li>{@link STDIN} Current value for standard input in the laaded IoLib, if any. * <li>{@link #STDIN} Current value for standard input in the laaded {@link IoLib}, if any.
* <li>{@link STDOUT} Current value for standard output in the loaded IoLib, if any. * <li>{@link #STDOUT} Current value for standard output in the loaded {@link IoLib}, if any.
* <li>{@link STDERR} Current value for standard error in the loaded IoLib, if any. * <li>{@link #STDERR} Current value for standard error in the loaded {@link IoLib}, if any.
* <li>{@link finder} Current loaded {@link ResourceFinder}, if any. * <li>{@link #finder} Current loaded {@link ResourceFinder}, if any.
* <li>{@link compiler} Current loaded {@link Compiler}, if any. * <li>{@link #compiler} Current loaded {@link Compiler}, if any.
* <li>{@link undumper} Current loaded {@link Undumper}, if any. * <li>{@link #undumper} Current loaded {@link Undumper}, if any.
* <li>{@link loader} Current loaded {@link Loader}, if any. * <li>{@link #loader} Current loaded {@link Loader}, if any.
* </ul> * </ul>
* *
* <h3>Lua Environment Variables</h3> * <h3>Lua Environment Variables</h3>
* When using {@link JsePlatform} or {@link JmePlatform}, * When using {@link org.luaj.vm2.lib.jse.JsePlatform} or {@link org.luaj.vm2.lib.jme.JmePlatform},
* these environment variables are created within the Globals. * these environment variables are created within the Globals.
* <ul> * <ul>
* <li>"_G" Pointer to this Globals. * <li>"_G" Pointer to this Globals.
@@ -107,8 +109,8 @@ import org.luaj.vm2.lib.ResourceFinder;
* @see Loader * @see Loader
* @see Undumper * @see Undumper
* @see ResourceFinder * @see ResourceFinder
* @see LuaC * @see org.luaj.vm2.compiler.LuaC
* @see LuaJC * @see org.luaj.vm2.luajc.LuaJC
*/ */
public class Globals extends LuaTable { public class Globals extends LuaTable {
@@ -218,7 +220,7 @@ public class Globals extends LuaTable {
/** Load the content form a reader as a text file. Must be lua source. /** Load the content form a reader as a text file. Must be lua source.
* The source is converted to UTF-8, so any characters appearing in quoted literals * The source is converted to UTF-8, so any characters appearing in quoted literals
* above the range 128 will be converted into multiple bytes. * above the range 128 will be converted into multiple bytes.
* @param script Contents of a lua script, such as "print 'hello, world.'" * @param reader Reader containing text of a lua script, such as "print 'hello, world.'"
* @param chunkname Name that will be used within the chunk as the source. * @param chunkname Name that will be used within the chunk as the source.
* @return LuaValue that may be executed via .call(), .invoke(), or .method() calls. * @return LuaValue that may be executed via .call(), .invoke(), or .method() calls.
* @throws LuaError if the script could not be compiled. * @throws LuaError if the script could not be compiled.
@@ -231,7 +233,7 @@ public class Globals extends LuaTable {
* Must be lua source. The source is converted to UTF-8, so any characters * Must be lua source. The source is converted to UTF-8, so any characters
* appearing in quoted literals above the range 128 will be converted into * appearing in quoted literals above the range 128 will be converted into
* multiple bytes. * multiple bytes.
* @param script Contents of a lua script, such as "print 'hello, world.'" * @param reader Reader containing text of a lua script, such as "print 'hello, world.'"
* @param chunkname Name that will be used within the chunk as the source. * @param chunkname Name that will be used within the chunk as the source.
* @param environment LuaTable to be used as the environment for the loaded function. * @param environment LuaTable to be used as the environment for the loaded function.
* @return LuaValue that may be executed via .call(), .invoke(), or .method() calls. * @return LuaValue that may be executed via .call(), .invoke(), or .method() calls.
@@ -242,7 +244,7 @@ public class Globals extends LuaTable {
} }
/** Load the content form an input stream as a binary chunk or text file. /** Load the content form an input stream as a binary chunk or text file.
* @param is Input stream containing a lua script or compiled lua" * @param is InputStream containing a lua script or compiled lua"
* @param chunkname Name that will be used within the chunk as the source. * @param chunkname Name that will be used within the chunk as the source.
* @param mode String containing 'b' or 't' or both to control loading as binary or text or either. * @param mode String containing 'b' or 't' or both to control loading as binary or text or either.
* @param environment LuaTable to be used as the environment for the loaded function. * @param environment LuaTable to be used as the environment for the loaded function.

View File

@@ -25,15 +25,14 @@ import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import org.luaj.vm2.compiler.DumpState;
/** /**
* Class to undump compiled lua bytecode into a {@link Prototype} instances. * Class to undump compiled lua bytecode into a {@link Prototype} instances.
* <p> * <p>
* The {@link LoadState} class implements {@link Globals#Undumper} * The {@link LoadState} class provides the default {@link Globals.Undumper}
* which is used to undump a string of bytes that represent a lua binary file * which is used to undump a string of bytes that represent a lua binary file
* using either the C-based lua compiler, or luaj's {@link DumpState#dump} function. * using either the C-based lua compiler, or luaj's
* {@link org.luaj.vm2.compiler.LuaC} compiler.
* <p> * <p>
* The canonical method to load and execute code is done * The canonical method to load and execute code is done
* indirectly using the Globals: * indirectly using the Globals:
@@ -42,24 +41,27 @@ import org.luaj.vm2.compiler.DumpState;
* LuaValue chunk = globasl.load("print('hello, world')", "main.lua"); * LuaValue chunk = globasl.load("print('hello, world')", "main.lua");
* chunk.call(); * chunk.call();
* } </pre> * } </pre>
* This should work regardless of which {@link Globals.Compiler} * This should work regardless of which {@link Globals.Compiler} or {@link Globals.Undumper}
* has been installed. * have been installed.
* <p> * <p>
* By default, when using {@link JsePlatform} or {@JmePlatform} * By default, when using {@link org.luaj.vm2.lib.jse.JsePlatform} or
* to construct globals, the {@link LoadState} is installed * {@link org.luaj.vm2.lib.jme.JmePlatform}
* as the default {@link Globals#undumper}. * to construct globals, the {@link LoadState} default undumper is installed
* as the default {@link Globals.Undumper}.
* <p> * <p>
* *
* A lua binary file is created via {@link DumpState#dump}: * A lua binary file is created via the {@link org.luaj.vm2.compiler.DumpState} class
:
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* Prototype p = globals.compilePrototype(new StringReader("print('hello, world')"), "main.lua"); * Prototype p = globals.compilePrototype(new StringReader("print('hello, world')"), "main.lua");
* ByteArrayOutputStream o = new ByteArrayOutputStream(); * ByteArrayOutputStream o = new ByteArrayOutputStream();
* DumpState.dump(p, o, false); * org.luaj.vm2.compiler.DumpState.dump(p, o, false);
* byte[] lua_binary_file_bytes = o.toByteArray(); * byte[] lua_binary_file_bytes = o.toByteArray();
* } </pre> * } </pre>
* *
* The {@link LoadState} may be used directly to undump these bytes: * The {@link LoadState}'s default undumper {@link #instance}
* may be used directly to undump these bytes:
* <pre> {@code * <pre> {@code
* Prototypep = LoadState.instance.undump(new ByteArrayInputStream(lua_binary_file_bytes), "main.lua"); * Prototypep = LoadState.instance.undump(new ByteArrayInputStream(lua_binary_file_bytes), "main.lua");
* LuaClosure c = new LuaClosure(p, globals); * LuaClosure c = new LuaClosure(p, globals);
@@ -67,20 +69,21 @@ import org.luaj.vm2.compiler.DumpState;
* } </pre> * } </pre>
* *
* *
* More commonly, the {@link Globals#undumper} may be used to undump them: * More commonly, the {@link Globals.Undumper} may be used to undump them:
* <pre> {@code * <pre> {@code
* Prototype p = globals.loadPrototype(new ByteArrayInputStream(lua_binary_file_bytes), "main.lua", "b"); * Prototype p = globals.loadPrototype(new ByteArrayInputStream(lua_binary_file_bytes), "main.lua", "b");
* LuaClosure c = new LuaClosure(p, globals); * LuaClosure c = new LuaClosure(p, globals);
* c.call(); * c.call();
* } </pre> * } </pre>
* *
* @see LuaCompiler * @see Globals.Compiler
* @see Globals.Undumper
* @see LuaClosure * @see LuaClosure
* @see LuaFunction * @see LuaFunction
* @see LoadState#compiler * @see org.luaj.vm2.compiler.LuaC
* @see LoadState#load(InputStream, String, LuaValue) * @see org.luaj.vm2.luajc.LuaJC
* @see LuaC * @see Globals#compiler
* @see LuaJC * @see Globals#load(InputStream, String, LuaValue)
*/ */
public class LoadState { public class LoadState {
@@ -383,7 +386,7 @@ public class LoadState {
/** /**
* Load input stream as a lua binary chunk if the first 4 bytes are the lua binary signature. * Load input stream as a lua binary chunk if the first 4 bytes are the lua binary signature.
* @param stream InputStream to read, after having read the first byte already * @param stream InputStream to read, after having read the first byte already
* @param name Name to apply to the loaded chunk * @param chunkname Name to apply to the loaded chunk
* @return {@link Prototype} that was loaded, or null if the first 4 bytes were not the lua signature. * @return {@link Prototype} that was loaded, or null if the first 4 bytes were not the lua signature.
* @throws IOException if an IOException occurs * @throws IOException if an IOException occurs
*/ */

View File

@@ -27,7 +27,7 @@ package org.luaj.vm2;
* These instance are not instantiated directly by clients. * These instance are not instantiated directly by clients.
* Instead, there are exactly twon instances of this class, * Instead, there are exactly twon instances of this class,
* {@link LuaValue#TRUE} and {@link LuaValue#FALSE} * {@link LuaValue#TRUE} and {@link LuaValue#FALSE}
* representing the lua values {@code true} and {@link false}. * representing the lua values {@code true} and {@code false}.
* The function {@link LuaValue#valueOf(boolean)} will always * The function {@link LuaValue#valueOf(boolean)} will always
* return one of these two values. * return one of these two values.
* <p> * <p>

View File

@@ -33,11 +33,12 @@ package org.luaj.vm2;
* There are three main ways {@link LuaClosure} instances are created: * There are three main ways {@link LuaClosure} instances are created:
* <ul> * <ul>
* <li>Construct an instance using {@link #LuaClosure(Prototype, LuaValue)}</li> * <li>Construct an instance using {@link #LuaClosure(Prototype, LuaValue)}</li>
* <li>Construct it indirectly by loading a chunk via {@link Globals#load(java.io.Reader, String, LuaValue)} * <li>Construct it indirectly by loading a chunk via {@link Globals#load(java.io.Reader, String)}
* <li>Execute the lua bytecode {@link Lua#OP_CLOSURE} as part of bytecode processing * <li>Execute the lua bytecode {@link Lua#OP_CLOSURE} as part of bytecode processing
* </ul> * </ul>
* <p> * <p>
* To construct it directly, the {@link Prototype} is typically created via a compiler such as {@link LuaC}: * To construct it directly, the {@link Prototype} is typically created via a compiler such as
* {@link org.luaj.vm2.compiler.LuaC}:
* <pre> {@code * <pre> {@code
* String script = "print( 'hello, world' )"; * String script = "print( 'hello, world' )";
* InputStream is = new ByteArrayInputStream(script.getBytes()); * InputStream is = new ByteArrayInputStream(script.getBytes());
@@ -47,7 +48,7 @@ package org.luaj.vm2;
* f.call(); * f.call();
* }</pre> * }</pre>
* <p> * <p>
* To construct it indirectly, the {@link Globals#load} method may be used: * To construct it indirectly, the {@link Globals#load(java.io.Reader, String)} method may be used:
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* LuaFunction f = globals.load(new StringReader(script), "script"); * LuaFunction f = globals.load(new StringReader(script), "script");
@@ -78,7 +79,7 @@ package org.luaj.vm2;
* @see LuaValue#checkclosure() * @see LuaValue#checkclosure()
* @see LuaValue#optclosure(LuaClosure) * @see LuaValue#optclosure(LuaClosure)
* @see LoadState * @see LoadState
* @see LoadState#compiler * @see Globals#compiler
*/ */
public class LuaClosure extends LuaFunction { public class LuaClosure extends LuaFunction {
private static final UpValue[] NOUPVALUES = new UpValue[0]; private static final UpValue[] NOUPVALUES = new UpValue[0];

View File

@@ -110,8 +110,7 @@ public class LuaError extends RuntimeException {
/** /**
* Construct a LuaError with a LuaValue as the message object, * Construct a LuaError with a LuaValue as the message object,
* and level to draw line number information from. * and level to draw line number information from.
* @param message message to supply * @param message_object message string or object to supply
* @param level where to supply line info from in call stack
*/ */
public LuaError(LuaValue message_object) { public LuaError(LuaValue message_object) {
super( message_object.tojstring() ); super( message_object.tojstring() );

View File

@@ -21,16 +21,18 @@
******************************************************************************/ ******************************************************************************/
package org.luaj.vm2; package org.luaj.vm2;
/** /**
* Base class for functions implemented in Java. * Base class for functions implemented in Java.
* <p> * <p>
* Direct subclass include {@link LibFunction} which is the base class for * Direct subclass include {@link org.luaj.vm2.lib.LibFunction}
* which is the base class for
* all built-in library functions coded in Java, * all built-in library functions coded in Java,
* and {@link LuaClosure}, which represents a lua closure * and {@link LuaClosure}, which represents a lua closure
* whose bytecode is interpreted when the function is invoked. * whose bytecode is interpreted when the function is invoked.
* @see LuaValue * @see LuaValue
* @see LibFunction
* @see LuaClosure * @see LuaClosure
* @see org.luaj.vm2.lib.LibFunction
*/ */
abstract abstract
public class LuaFunction extends LuaValue { public class LuaFunction extends LuaValue {

View File

@@ -33,14 +33,12 @@ import java.lang.ref.WeakReference;
* <p> * <p>
* The threads must be initialized with the globals, so that * The threads must be initialized with the globals, so that
* the global environment may be passed along according to rules of lua. * the global environment may be passed along according to rules of lua.
* This is done via a call to {@link #setGlobals(LuaValue)} * This is done via the constructor arguments {@link #LuaThread(Globals)} or
* at some point during globals initialization. * {@link #LuaThread(Globals, LuaValue)}.
* See {@link BaseLib} for additional documentation and example code.
* <p> * <p>
* The utility classes {@link JsePlatform} and {@link JmePlatform} * The utility classes {@link org.luaj.vm2.lib.jse.JsePlatform} and
* see to it that this initialization is done properly. * {@link org.luaj.vm2.lib.jme.JmePlatform}
* For this reason it is highly recommended to use one of these classes * see to it that this {@link Globals} are initialized properly.
* when initializing globals.
* <p> * <p>
* The behavior of coroutine threads matches closely the behavior * The behavior of coroutine threads matches closely the behavior
* of C coroutine library. However, because of the use of Java threads * of C coroutine library. However, because of the use of Java threads
@@ -50,17 +48,29 @@ import java.lang.ref.WeakReference;
* to determine if it can ever be resumed. If not, it throws * to determine if it can ever be resumed. If not, it throws
* {@link OrphanedThread} which is an {@link java.lang.Error}. * {@link OrphanedThread} which is an {@link java.lang.Error}.
* Applications should not catch {@link OrphanedThread}, because it can break * Applications should not catch {@link OrphanedThread}, because it can break
* the thread safety of luaj. * the thread safety of luaj. The value controlling the polling interval
* is {@link #thread_orphan_check_interval} and may be set by the user.
* <p>
* There are two main ways to abandon a coroutine. The first is to call
* {@code yield()} from lua, or equivalently {@link Globals#yield(Varargs)},
* and arrange to have it never resumed possibly by values passed to yield.
* The second is to throw {@link OrphanedThread}, which should put the thread
* in a dead state. In either case all references to the thread must be
* dropped, and the garbage collector must run for the thread to be
* garbage collected.
*
* *
* @see LuaValue * @see LuaValue
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see CoroutineLib * @see org.luaj.vm2.lib.CoroutineLib
*/ */
public class LuaThread extends LuaValue { public class LuaThread extends LuaValue {
/** Shared metatable for lua threads. */
public static LuaValue s_metatable; public static LuaValue s_metatable;
/** The current number of coroutines. Should not be set. */
public static int coroutine_count = 0; public static int coroutine_count = 0;
/** Polling interval, in milliseconds, which each thread uses while waiting to /** Polling interval, in milliseconds, which each thread uses while waiting to

View File

@@ -59,7 +59,7 @@ import org.luaj.vm2.Varargs;
* } </pre> * } </pre>
* <p> * <p>
* To supply variable arguments or get multiple return values, use * To supply variable arguments or get multiple return values, use
* {@link invoke(Varargs)} or {@link invokemethod(LuaValue, Varargs)} methods: * {@link #invoke(Varargs)} or {@link #invokemethod(LuaValue, Varargs)} methods:
* <pre> {@code * <pre> {@code
* LuaValue modf = globals.get("math").get("modf"); * LuaValue modf = globals.get("math").get("modf");
* Varargs r = modf.invoke( d ); * Varargs r = modf.invoke( d );
@@ -77,7 +77,7 @@ import org.luaj.vm2.Varargs;
* } </pre> * } </pre>
* For this to work the file must be in the current directory, or in the class path, * For this to work the file must be in the current directory, or in the class path,
* dependening on the platform. * dependening on the platform.
* See {@link JsePlatform} and {@link JmePlatform} for details. * See {@link org.luaj.vm2.lib.jse.JsePlatform} and {@link org.luaj.vm2.lib.jme.JmePlatform} for details.
* <p> * <p>
* In general a {@link LuaError} may be thrown on any operation when the * In general a {@link LuaError} may be thrown on any operation when the
* types supplied to any operation are illegal from a lua perspective. * types supplied to any operation are illegal from a lua perspective.
@@ -92,19 +92,19 @@ import org.luaj.vm2.Varargs;
* </ul> * </ul>
* <p> * <p>
* Predefined constants exist for the standard lua type constants * Predefined constants exist for the standard lua type constants
* {@link #TNIL}, {@link #TBOOLEAN}, {@link TLIGHTUSERDATA}, {@link #TNUMBER}, {@link #TSTRING}, * {@link #TNIL}, {@link #TBOOLEAN}, {@link #TLIGHTUSERDATA}, {@link #TNUMBER}, {@link #TSTRING},
* {@link #TTABLE}, {@link #TFUNCTION}, {@link #TUSERDATA}, {@link #TTHREAD}, * {@link #TTABLE}, {@link #TFUNCTION}, {@link #TUSERDATA}, {@link #TTHREAD},
* and extended lua type constants * and extended lua type constants
* {@link TINT}, {@link #TNONE}, {@link TVALUE} * {@link #TINT}, {@link #TNONE}, {@link #TVALUE}
* <p> * <p>
* Predefined constants exist for all strings used as metatags: * Predefined constants exist for all strings used as metatags:
* {@link #INDEX}, {@link #NEWINDEX}, {@link #CALL}, {@link MODE}, {@link METATABLE}, * {@link #INDEX}, {@link #NEWINDEX}, {@link #CALL}, {@link #MODE}, {@link #METATABLE},
* {@link #ADD}, {@link #SUB}, {@link #DIV}, {@link #MUL}, {@link #POW}, * {@link #ADD}, {@link #SUB}, {@link #DIV}, {@link #MUL}, {@link #POW},
* {@link MOD}, {@link #UNM}, {@link #LEN}, {@link #EQ}, {@link #LT}, * {@link #MOD}, {@link #UNM}, {@link #LEN}, {@link #EQ}, {@link #LT},
* {@link #LE}, {@link #TOSTRING}, and {@link #CONCAT}. * {@link #LE}, {@link #TOSTRING}, and {@link #CONCAT}.
* *
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see LoadState * @see LoadState
* @see Varargs * @see Varargs
*/ */
@@ -292,7 +292,7 @@ public class LuaValue extends Varargs {
* @see #toboolean() * @see #toboolean()
* @see #checkboolean() * @see #checkboolean()
* @see #optboolean(boolean) * @see #optboolean(boolean)
* @see #TOBOLEAN * @see #TBOOLEAN
*/ */
public boolean isboolean() { return false; } public boolean isboolean() { return false; }
@@ -310,7 +310,7 @@ public class LuaValue extends Varargs {
* @return true if this is a {@code function}, otherwise false * @return true if this is a {@code function}, otherwise false
* @see #isclosure() * @see #isclosure()
* @see #checkfunction() * @see #checkfunction()
* @see #optfunciton(LuaFunction) * @see #optfunction(LuaFunction)
* @see #TFUNCTION * @see #TFUNCTION
*/ */
public boolean isfunction() { return false; } public boolean isfunction() { return false; }
@@ -426,7 +426,7 @@ public class LuaValue extends Varargs {
* @see #isuserdata() * @see #isuserdata()
* @see #touserdata(Class) * @see #touserdata(Class)
* @see #checkuserdata(Class) * @see #checkuserdata(Class)
* @see #optuserdata(Object,Class) * @see #optuserdata(Class, Object)
* @see #TUSERDATA * @see #TUSERDATA
*/ */
public boolean isuserdata(Class c) { return false; } public boolean isuserdata(Class c) { return false; }
@@ -444,7 +444,6 @@ public class LuaValue extends Varargs {
* @return Value cast to byte if number or string convertible to number, otherwise 0 * @return Value cast to byte if number or string convertible to number, otherwise 0
* @see #toint() * @see #toint()
* @see #todouble() * @see #todouble()
* @see #optbyte(byte)
* @see #checknumber() * @see #checknumber()
* @see #isnumber() * @see #isnumber()
* @see #TNUMBER * @see #TNUMBER
@@ -455,7 +454,6 @@ public class LuaValue extends Varargs {
* @return Value cast to char if number or string convertible to number, otherwise 0 * @return Value cast to char if number or string convertible to number, otherwise 0
* @see #toint() * @see #toint()
* @see #todouble() * @see #todouble()
* @see #optchar(char)
* @see #checknumber() * @see #checknumber()
* @see #isnumber() * @see #isnumber()
* @see #TNUMBER * @see #TNUMBER
@@ -481,7 +479,6 @@ public class LuaValue extends Varargs {
* @return Value cast to float if number or string convertible to number, otherwise 0 * @return Value cast to float if number or string convertible to number, otherwise 0
* @see #toint() * @see #toint()
* @see #todouble() * @see #todouble()
* @see #optfloat(float)
* @see #checknumber() * @see #checknumber()
* @see #isnumber() * @see #isnumber()
* @see #TNUMBER * @see #TNUMBER
@@ -520,7 +517,6 @@ public class LuaValue extends Varargs {
* @return Value cast to short if number or string convertible to number, otherwise 0 * @return Value cast to short if number or string convertible to number, otherwise 0
* @see #toint() * @see #toint()
* @see #todouble() * @see #todouble()
* @see #optshort(short)
* @see #checknumber() * @see #checknumber()
* @see #isnumber() * @see #isnumber()
* @see #TNUMBER * @see #TNUMBER
@@ -609,7 +605,7 @@ public class LuaValue extends Varargs {
/** Check that optional argument is a boolean and return its boolean value /** Check that optional argument is a boolean and return its boolean value
* @param defval boolean value to return if {@code this} is nil or none * @param defval boolean value to return if {@code this} is nil or none
* @return {@code this} cast to boolean if a {@LuaBoolean}, * @return {@code this} cast to boolean if a {@link LuaBoolean},
* {@code defval} if nil or none, * {@code defval} if nil or none,
* throws {@link LuaError} otherwise * throws {@link LuaError} otherwise
* @throws LuaError if was not a boolean or nil or none. * @throws LuaError if was not a boolean or nil or none.
@@ -621,7 +617,7 @@ public class LuaValue extends Varargs {
/** Check that optional argument is a closure and return as {@link LuaClosure} /** Check that optional argument is a closure and return as {@link LuaClosure}
* <p> * <p>
* A {@link LuaClosure} is a {@LuaFunction} that executes lua byteccode. * A {@link LuaClosure} is a {@link LuaFunction} that executes lua byteccode.
* @param defval {@link LuaClosure} to return if {@code this} is nil or none * @param defval {@link LuaClosure} to return if {@code this} is nil or none
* @return {@code this} cast to {@link LuaClosure} if a function, * @return {@code this} cast to {@link LuaClosure} if a function,
* {@code defval} if nil or none, * {@code defval} if nil or none,
@@ -836,7 +832,7 @@ public class LuaValue extends Varargs {
/** Check that the value is a {@link LuaClosure} , /** Check that the value is a {@link LuaClosure} ,
* or throw {@link LuaError} if not * or throw {@link LuaError} if not
* <p> * <p>
* {@link LuaClosure} is a subclass of {@LuaFunction} that interprets lua bytecode. * {@link LuaClosure} is a subclass of {@link LuaFunction} that interprets lua bytecode.
* @return {@code this} cast as {@link LuaClosure} * @return {@code this} cast as {@link LuaClosure}
* @throws LuaError if not a {@link LuaClosure} * @throws LuaError if not a {@link LuaClosure}
* @see #checkfunction() * @see #checkfunction()
@@ -876,7 +872,7 @@ public class LuaValue extends Varargs {
/** Check that the value is a Globals instance, or throw {@link LuaError} if not /** Check that the value is a Globals instance, or throw {@link LuaError} if not
* <p> * <p>
* {@link Globals} are a special {@link LuaTable} that establish the default global environment. * {@link Globals} are a special {@link LuaTable} that establish the default global environment.
* @return {@code this} if if an instance fof {@Globals} * @return {@code this} if if an instance fof {@link Globals}
* @throws LuaError if not a {@link Globals} instance. * @throws LuaError if not a {@link Globals} instance.
*/ */
public Globals checkglobals() { argerror("globals"); return null; } public Globals checkglobals() { argerror("globals"); return null; }
@@ -1046,8 +1042,10 @@ public class LuaValue extends Varargs {
/** /**
* Assert a condition is true, or throw a {@link LuaError} if not * Assert a condition is true, or throw a {@link LuaError} if not
* Returns no value when b is true, throws {@link #error(String)} with {@code msg} as argument
* and does not return if b is false.
* @param b condition to test * @param b condition to test
* @return returns no value when b is true, throws error not return if b is false * @param msg String message to produce on failure
* @throws LuaError if b is not true * @throws LuaError if b is not true
*/ */
public static void assert_(boolean b,String msg) { if(!b) throw new LuaError(msg); } public static void assert_(boolean b,String msg) { if(!b) throw new LuaError(msg); }
@@ -1320,7 +1318,7 @@ public class LuaValue extends Varargs {
* or {@link #NIL} if there are no more. * or {@link #NIL} if there are no more.
* @throws LuaError if {@code this} is not a table, or the supplied key is invalid. * @throws LuaError if {@code this} is not a table, or the supplied key is invalid.
* @see LuaTable * @see LuaTable
* @see #inext() * @see #inext(LuaValue)
* @see #valueOf(int) * @see #valueOf(int)
* @see Varargs#arg1() * @see Varargs#arg1()
* @see Varargs#arg(int) * @see Varargs#arg(int)
@@ -1345,10 +1343,10 @@ public class LuaValue extends Varargs {
* @param index {@link LuaInteger} value identifying a key to start from, * @param index {@link LuaInteger} value identifying a key to start from,
* or {@link #NIL} to start at the beginning * or {@link #NIL} to start at the beginning
* @return {@link Varargs} containing {@code (key,value)} for the next entry, * @return {@link Varargs} containing {@code (key,value)} for the next entry,
* or {@link NONE} if there are no more. * or {@link #NONE} if there are no more.
* @throws LuaError if {@code this} is not a table, or the supplied key is invalid. * @throws LuaError if {@code this} is not a table, or the supplied key is invalid.
* @see LuaTable * @see LuaTable
* @see #next() * @see #next(LuaValue)
* @see #valueOf(int) * @see #valueOf(int)
* @see Varargs#arg1() * @see Varargs#arg1()
* @see Varargs#arg(int) * @see Varargs#arg(int)
@@ -1361,7 +1359,6 @@ public class LuaValue extends Varargs {
* and this Globals as the environment. This is normally used to iniitalize the * and this Globals as the environment. This is normally used to iniitalize the
* library instance and which may install itself into these globals. * library instance and which may install itself into these globals.
* @param library The callable {@link LuaValue} to load into {@code this} * @param library The callable {@link LuaValue} to load into {@code this}
* @param string
* @return {@link LuaValue} returned by the initialization call. * @return {@link LuaValue} returned by the initialization call.
*/ */
public LuaValue load(LuaValue library) { return library.call(EMPTYSTRING, this); } public LuaValue load(LuaValue library) { return library.call(EMPTYSTRING, this); }
@@ -1446,7 +1443,7 @@ public class LuaValue extends Varargs {
* @see #call() * @see #call()
* @see #call(LuaValue,LuaValue) * @see #call(LuaValue,LuaValue)
* @see #call(LuaValue, LuaValue, LuaValue) * @see #call(LuaValue, LuaValue, LuaValue)
* @see #invoke(LuaValue) * @see #invoke(Varargs)
* @see #method(String,LuaValue) * @see #method(String,LuaValue)
* @see #method(LuaValue,LuaValue) * @see #method(LuaValue,LuaValue)
*/ */
@@ -1480,7 +1477,7 @@ public class LuaValue extends Varargs {
* @see #call() * @see #call()
* @see #call(LuaValue) * @see #call(LuaValue)
* @see #call(LuaValue, LuaValue, LuaValue) * @see #call(LuaValue, LuaValue, LuaValue)
* @see #invoke(LuaValue,LuaValue) * @see #invoke(LuaValue, Varargs)
* @see #method(String,LuaValue,LuaValue) * @see #method(String,LuaValue,LuaValue)
* @see #method(LuaValue,LuaValue,LuaValue) * @see #method(LuaValue,LuaValue,LuaValue)
*/ */
@@ -1508,7 +1505,7 @@ public class LuaValue extends Varargs {
* @see #call() * @see #call()
* @see #call(LuaValue) * @see #call(LuaValue)
* @see #call(LuaValue, LuaValue) * @see #call(LuaValue, LuaValue)
* @see #invoke(LuaValue,LuaValue, LuaValue) * @see #invoke(LuaValue, LuaValue, Varargs)
* @see #invokemethod(String,Varargs) * @see #invokemethod(String,Varargs)
* @see #invokemethod(LuaValue,Varargs) * @see #invokemethod(LuaValue,Varargs)
*/ */
@@ -1586,9 +1583,9 @@ public class LuaValue extends Varargs {
* or the invoked function throws a {@link LuaError} * or the invoked function throws a {@link LuaError}
* or the invoked closure throw a lua {@code error} * or the invoked closure throw a lua {@code error}
* @see #call(LuaValue) * @see #call(LuaValue)
* @see #invoke(LuaValue) * @see #invoke(Varargs)
* @see #method(LuaValue,LuaValue)
* @see #method(String) * @see #method(String)
* @see #method(LuaValue)
* @see #method(String,LuaValue,LuaValue) * @see #method(String,LuaValue,LuaValue)
*/ */
public LuaValue method(String name, LuaValue arg) { return this.get(name).call(this,arg); } public LuaValue method(String name, LuaValue arg) { return this.get(name).call(this,arg); }
@@ -1613,7 +1610,7 @@ public class LuaValue extends Varargs {
* or the invoked function throws a {@link LuaError} * or the invoked function throws a {@link LuaError}
* or the invoked closure throw a lua {@code error} * or the invoked closure throw a lua {@code error}
* @see #call(LuaValue) * @see #call(LuaValue)
* @see #invoke(LuaValue) * @see #invoke(Varargs)
* @see #method(String,LuaValue) * @see #method(String,LuaValue)
* @see #method(LuaValue) * @see #method(LuaValue)
* @see #method(LuaValue,LuaValue,LuaValue) * @see #method(LuaValue,LuaValue,LuaValue)
@@ -1838,7 +1835,10 @@ public class LuaValue extends Varargs {
* @see #invoke() * @see #invoke()
* @see #method(String) * @see #method(String)
* @see #invokemethod(LuaValue) * @see #invokemethod(LuaValue)
* @see #invokemethod(String,LuaValue) * @see #invokemethod(String, LuaValue[])
* @see #invokemethod(String, Varargs)
* @see #invokemethod(LuaValue, LuaValue[])
* @see #invokemethod(LuaValue, Varargs)
*/ */
public Varargs invokemethod(String name) { return get(name).invoke(this); } public Varargs invokemethod(String name) { return get(name).invoke(this); }
@@ -1863,7 +1863,10 @@ public class LuaValue extends Varargs {
* @see #invoke() * @see #invoke()
* @see #method(LuaValue) * @see #method(LuaValue)
* @see #invokemethod(String) * @see #invokemethod(String)
* @see #invokemethod(LuaValue,LuaValue) * @see #invokemethod(String, LuaValue[])
* @see #invokemethod(String, Varargs)
* @see #invokemethod(LuaValue, LuaValue[])
* @see #invokemethod(LuaValue, Varargs)
*/ */
public Varargs invokemethod(LuaValue name) { return get(name).invoke(this); } public Varargs invokemethod(LuaValue name) { return get(name).invoke(this); }
@@ -1888,8 +1891,11 @@ public class LuaValue extends Varargs {
* @see #call() * @see #call()
* @see #invoke(Varargs) * @see #invoke(Varargs)
* @see #method(String) * @see #method(String)
* @see #invokemethod(LuaValue,Varargs) * @see #invokemethod(String)
* @see #invokemethod(String,LuaValue[]) * @see #invokemethod(LuaValue)
* @see #invokemethod(String, LuaValue[])
* @see #invokemethod(LuaValue, LuaValue[])
* @see #invokemethod(LuaValue, Varargs)
*/ */
public Varargs invokemethod(String name, Varargs args) { return get(name).invoke(varargsOf(this,args)); } public Varargs invokemethod(String name, Varargs args) { return get(name).invoke(varargsOf(this,args)); }
@@ -1914,8 +1920,11 @@ public class LuaValue extends Varargs {
* @see #call() * @see #call()
* @see #invoke(Varargs) * @see #invoke(Varargs)
* @see #method(String) * @see #method(String)
* @see #invokemethod(String,Varargs) * @see #invokemethod(String)
* @see #invokemethod(LuaValue,LuaValue[]) * @see #invokemethod(LuaValue)
* @see #invokemethod(String, LuaValue[])
* @see #invokemethod(String, Varargs)
* @see #invokemethod(LuaValue, LuaValue[])
*/ */
public Varargs invokemethod(LuaValue name, Varargs args) { return get(name).invoke(varargsOf(this,args)); } public Varargs invokemethod(LuaValue name, Varargs args) { return get(name).invoke(varargsOf(this,args)); }
@@ -1940,8 +1949,11 @@ public class LuaValue extends Varargs {
* @see #call() * @see #call()
* @see #invoke(Varargs) * @see #invoke(Varargs)
* @see #method(String) * @see #method(String)
* @see #invokemethod(LuaValue,LuaValue[]) * @see #invokemethod(String)
* @see #invokemethod(String,Varargs) * @see #invokemethod(LuaValue)
* @see #invokemethod(String, Varargs)
* @see #invokemethod(LuaValue, LuaValue[])
* @see #invokemethod(LuaValue, Varargs)
* @see LuaValue#varargsOf(LuaValue[]) * @see LuaValue#varargsOf(LuaValue[])
*/ */
public Varargs invokemethod(String name, LuaValue[] args) { return get(name).invoke(varargsOf(this,varargsOf(args))); } public Varargs invokemethod(String name, LuaValue[] args) { return get(name).invoke(varargsOf(this,varargsOf(args))); }
@@ -1967,8 +1979,11 @@ public class LuaValue extends Varargs {
* @see #call() * @see #call()
* @see #invoke(Varargs) * @see #invoke(Varargs)
* @see #method(String) * @see #method(String)
* @see #invokemethod(String,LuaValue[]) * @see #invokemethod(String)
* @see #invokemethod(LuaValue,Varargs) * @see #invokemethod(LuaValue)
* @see #invokemethod(String, LuaValue[])
* @see #invokemethod(String, Varargs)
* @see #invokemethod(LuaValue, Varargs)
* @see LuaValue#varargsOf(LuaValue[]) * @see LuaValue#varargsOf(LuaValue[])
*/ */
public Varargs invokemethod(LuaValue name, LuaValue[] args) { return get(name).invoke(varargsOf(this,varargsOf(args))); } public Varargs invokemethod(LuaValue name, LuaValue[] args) { return get(name).invoke(varargsOf(this,varargsOf(args))); }
@@ -1989,7 +2004,7 @@ public class LuaValue extends Varargs {
/** Unary minus: return negative value {@code (-this)} as defined by lua unary minus operator /** Unary minus: return negative value {@code (-this)} as defined by lua unary minus operator
* @return boolean inverse as {@link LuaBoolean} if boolean or nil, * @return boolean inverse as {@link LuaBoolean} if boolean or nil,
* numeric inverse as {@LuaNumber} if numeric, * numeric inverse as {@link LuaNumber} if numeric,
* or metatag processing result if {@link #UNM} metatag is defined * or metatag processing result if {@link #UNM} metatag is defined
* @throws LuaError if {@code this} is not a table or string, and has no {@link #UNM} metatag * @throws LuaError if {@code this} is not a table or string, and has no {@link #UNM} metatag
*/ */
@@ -2442,7 +2457,7 @@ public class LuaValue extends Varargs {
* @return value of {@code (this % rhs)} if both are numeric, * @return value of {@code (this % rhs)} if both are numeric,
* or {@link LuaValue} if metatag processing occurs * or {@link LuaValue} if metatag processing occurs
* @throws LuaError if either operand is not a number or string convertible to number, * @throws LuaError if either operand is not a number or string convertible to number,
* and neither has the {@link MOD} metatag defined * and neither has the {@link #MOD} metatag defined
* @see #arithmt(LuaValue, LuaValue) * @see #arithmt(LuaValue, LuaValue)
*/ */
public LuaValue mod( LuaValue rhs ) { return arithmt(MOD,rhs); } public LuaValue mod( LuaValue rhs ) { return arithmt(MOD,rhs); }
@@ -2956,7 +2971,7 @@ public class LuaValue extends Varargs {
* Finds the supplied metatag value and invokes it, * Finds the supplied metatag value and invokes it,
* or throws {@link LuaError} if none applies. * or throws {@link LuaError} if none applies.
* @param tag The metatag to look up * @param tag The metatag to look up
* @param rhs The right-hand-side value to perform the operation with * @param op1 The operand with which to to perform the operation
* @return {@link LuaValue} resulting from metatag processing * @return {@link LuaValue} resulting from metatag processing
* @throws LuaError if metatag was not defined for either operand, * @throws LuaError if metatag was not defined for either operand,
* or if the operands are not the same type, * or if the operands are not the same type,
@@ -2983,7 +2998,7 @@ public class LuaValue extends Varargs {
* each operand must derive from {@link LuaString}. * each operand must derive from {@link LuaString}.
* *
* @param rhs The right-hand-side value to perform the comparison with * @param rhs The right-hand-side value to perform the comparison with
* @returns int < 0 for {@code (this < rhs)}, int > 0 for {@code (this > rhs)}, or 0 when same string. * @return int < 0 for {@code (this < rhs)}, int > 0 for {@code (this > rhs)}, or 0 when same string.
* @throws LuaError if either operand is not a string * @throws LuaError if either operand is not a string
*/ */
public int strcmp( LuaValue rhs ) { error("attempt to compare "+typename()); return 0; } public int strcmp( LuaValue rhs ) { error("attempt to compare "+typename()); return 0; }
@@ -2996,7 +3011,7 @@ public class LuaValue extends Varargs {
* each operand must derive from {@link LuaString}. * each operand must derive from {@link LuaString}.
* *
* @param rhs The right-hand-side value to perform the comparison with * @param rhs The right-hand-side value to perform the comparison with
* @returns int < 0 for {@code (this < rhs)}, int > 0 for {@code (this > rhs)}, or 0 when same string. * @return int < 0 for {@code (this < rhs)}, int > 0 for {@code (this > rhs)}, or 0 when same string.
* @throws LuaError if this is not a string * @throws LuaError if this is not a string
*/ */
public int strcmp( LuaString rhs ) { error("attempt to compare "+typename()); return 0; } public int strcmp( LuaString rhs ) { error("attempt to compare "+typename()); return 0; }
@@ -3008,7 +3023,7 @@ public class LuaValue extends Varargs {
* each operand must derive from {@link LuaString} or {@link LuaNumber}. * each operand must derive from {@link LuaString} or {@link LuaNumber}.
* *
* @param rhs The right-hand-side value to perform the operation with * @param rhs The right-hand-side value to perform the operation with
* @returns {@link LuaValue} resulting from concatenation of {@code (this .. rhs)} * @return {@link LuaValue} resulting from concatenation of {@code (this .. rhs)}
* @throws LuaError if either operand is not of an appropriate type, * @throws LuaError if either operand is not of an appropriate type,
* such as nil or a table * such as nil or a table
*/ */
@@ -3023,7 +3038,7 @@ public class LuaValue extends Varargs {
* each operand must derive from {@link LuaString} or {@link LuaNumber}. * each operand must derive from {@link LuaString} or {@link LuaNumber}.
* *
* @param lhs The left-hand-side value onto which this will be concatenated * @param lhs The left-hand-side value onto which this will be concatenated
* @returns {@link LuaValue} resulting from concatenation of {@code (lhs .. this)} * @return {@link LuaValue} resulting from concatenation of {@code (lhs .. this)}
* @throws LuaError if either operand is not of an appropriate type, * @throws LuaError if either operand is not of an appropriate type,
* such as nil or a table * such as nil or a table
* @see #concat(LuaValue) * @see #concat(LuaValue)
@@ -3039,7 +3054,7 @@ public class LuaValue extends Varargs {
* each operand must derive from {@link LuaString} or {@link LuaNumber}. * each operand must derive from {@link LuaString} or {@link LuaNumber}.
* *
* @param lhs The left-hand-side value onto which this will be concatenated * @param lhs The left-hand-side value onto which this will be concatenated
* @returns {@link LuaValue} resulting from concatenation of {@code (lhs .. this)} * @return {@link LuaValue} resulting from concatenation of {@code (lhs .. this)}
* @throws LuaError if either operand is not of an appropriate type, * @throws LuaError if either operand is not of an appropriate type,
* such as nil or a table * such as nil or a table
* @see #concat(LuaValue) * @see #concat(LuaValue)
@@ -3055,7 +3070,7 @@ public class LuaValue extends Varargs {
* each operand must derive from {@link LuaString} or {@link LuaNumber}. * each operand must derive from {@link LuaString} or {@link LuaNumber}.
* *
* @param lhs The left-hand-side value onto which this will be concatenated * @param lhs The left-hand-side value onto which this will be concatenated
* @returns {@link LuaValue} resulting from concatenation of {@code (lhs .. this)} * @return {@link LuaValue} resulting from concatenation of {@code (lhs .. this)}
* @throws LuaError if either operand is not of an appropriate type, * @throws LuaError if either operand is not of an appropriate type,
* such as nil or a table * such as nil or a table
* @see #concat(LuaValue) * @see #concat(LuaValue)
@@ -3327,7 +3342,6 @@ public class LuaValue extends Varargs {
* Get particular metatag, or return {@link LuaValue#NIL} if it doesn't exist * Get particular metatag, or return {@link LuaValue#NIL} if it doesn't exist
* @param tag Metatag name to look up, typically a string such as * @param tag Metatag name to look up, typically a string such as
* {@link LuaValue#INDEX} or {@link LuaValue#NEWINDEX} * {@link LuaValue#INDEX} or {@link LuaValue#NEWINDEX}
* @param reason Description of error when tag lookup fails.
* @return {@link LuaValue} for tag {@code reason}, or {@link LuaValue#NIL} * @return {@link LuaValue} for tag {@code reason}, or {@link LuaValue#NIL}
*/ */
public LuaValue metatag(LuaValue tag) { public LuaValue metatag(LuaValue tag) {
@@ -3382,7 +3396,6 @@ public class LuaValue extends Varargs {
/** Construct a {@link Varargs} around an array of {@link LuaValue}s. /** Construct a {@link Varargs} around an array of {@link LuaValue}s.
* *
* @param v The array of {@link LuaValue}s * @param v The array of {@link LuaValue}s
* @param more {@link Varargs} contain values to include at the end
* @return {@link Varargs} wrapping the supplied values. * @return {@link Varargs} wrapping the supplied values.
* @see LuaValue#varargsOf(LuaValue, Varargs) * @see LuaValue#varargsOf(LuaValue, Varargs)
* @see LuaValue#varargsOf(LuaValue[], int, int) * @see LuaValue#varargsOf(LuaValue[], int, int)
@@ -3399,7 +3412,7 @@ public class LuaValue extends Varargs {
/** Construct a {@link Varargs} around an array of {@link LuaValue}s. /** Construct a {@link Varargs} around an array of {@link LuaValue}s.
* *
* @param v The array of {@link LuaValue}s * @param v The array of {@link LuaValue}s
* @param more {@link Varargs} contain values to include at the end * @param r {@link Varargs} contain values to include at the end
* @return {@link Varargs} wrapping the supplied values. * @return {@link Varargs} wrapping the supplied values.
* @see LuaValue#varargsOf(LuaValue[]) * @see LuaValue#varargsOf(LuaValue[])
* @see LuaValue#varargsOf(LuaValue[], int, int, Varargs) * @see LuaValue#varargsOf(LuaValue[], int, int, Varargs)
@@ -3466,8 +3479,8 @@ public class LuaValue extends Varargs {
* This can be used to wrap exactly 2 values, or a list consisting of 1 initial value * This can be used to wrap exactly 2 values, or a list consisting of 1 initial value
* followed by another variable list of remaining values. * followed by another variable list of remaining values.
* *
* @param v1 First {@link LuaValue} in the {@link Varargs} * @param v First {@link LuaValue} in the {@link Varargs}
* @param v2 {@link LuaValue} supplying the 2rd value, * @param r {@link LuaValue} supplying the 2rd value,
* or {@link Varargs}s supplying all values beyond the first * or {@link Varargs}s supplying all values beyond the first
* @return {@link Varargs} wrapping the supplied values. * @return {@link Varargs} wrapping the supplied values.
*/ */

View File

@@ -29,7 +29,7 @@ package org.luaj.vm2;
* {@link LuaThread} being used as a coroutine that could not possibly be * {@link LuaThread} being used as a coroutine that could not possibly be
* resumed again because there are no more references to the LuaThread with * resumed again because there are no more references to the LuaThread with
* which it is associated. Rather than locking up resources forever, this error * which it is associated. Rather than locking up resources forever, this error
* is thrown, and should fall through all the way to the thread's {@link Thread.run}() method. * is thrown, and should fall through all the way to the thread's {@link Thread#run()} method.
* <p> * <p>
* Java code mixed with the luaj vm should not catch this error because it may * Java code mixed with the luaj vm should not catch this error because it may
* occur when the coroutine is not running, so any processing done during error * occur when the coroutine is not running, so any processing done during error

View File

@@ -29,32 +29,33 @@ package org.luaj.vm2;
* and the main data structure for execution of compiled lua bytecode. * and the main data structure for execution of compiled lua bytecode.
* *
* <p> * <p>
* Generally, the {@link Protoytpe} is not constructed directly is an intermediate result * Generally, the {@link Prototype} is not constructed directly is an intermediate result
* as lua code is loaded using {@link Globals.load}: * as lua code is loaded using {@link Globals#load(java.io.Reader, String)}:
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* globals.load( new StringReader("print 'hello'"), "main.lua" ).call(); * globals.load( new StringReader("print 'hello'"), "main.lua" ).call();
* } </pre> * } </pre>
* *
* <p> * <p>
* To create a {@link Prototype} directly, a compiler such as {@link LuaC} may be used: * To create a {@link Prototype} directly, a compiler such as
* {@link org.luaj.vm2.compiler.LuaC} may be used:
* <pre> {@code * <pre> {@code
* InputStream is = new ByteArrayInputStream("print('hello,world')".getBytes()); * InputStream is = new ByteArrayInputStream("print('hello,world')".getBytes());
* Prototype p = LuaC.instance.compile(is, "script"); * Prototype p = LuaC.instance.compile(is, "script");
* }</pre> * }</pre>
* *
* To simplify loading, the {@link Globals#compilePrototype} method may be used: * To simplify loading, the {@link Globals#compilePrototype(java.io.InputStream, String)} method may be used:
* <pre> {@code * <pre> {@code
* Prototype p = globals.compileProtoytpe(is, "script"); * Prototype p = globals.compileProtoytpe(is, "script");
* }</pre> * }</pre>
* *
* It may also be loaded from a {@link java.io.Reader} : * It may also be loaded from a {@link java.io.Reader} via {@link Globals#compilePrototype(java.io.Reader, String)}:
* <pre> {@code * <pre> {@code
* Prototype p = globals.compileProtoytpe(new StringReader(script), "script"); * Prototype p = globals.compileProtoytpe(new StringReader(script), "script");
* }</pre> * }</pre>
* *
* To un-dump a binary file known to be a binary lua file that has been dumped to a string, * To un-dump a binary file known to be a binary lua file that has been dumped to a string,
* the {@link Globals#Undumper} interface may be used: * the {@link Globals.Undumper} interface may be used:
* <pre> {@code * <pre> {@code
* FileInputStream lua_binary_file = new FileInputStream("foo.lc"); // Known to be compiled lua. * FileInputStream lua_binary_file = new FileInputStream("foo.lc"); // Known to be compiled lua.
* Prototype p = globals.undumper.undump(lua_binary_file, "foo.lua"); * Prototype p = globals.undumper.undump(lua_binary_file, "foo.lua");
@@ -76,8 +77,8 @@ package org.luaj.vm2;
* *
* @see LuaClosure * @see LuaClosure
* @see Globals * @see Globals
* @see Globals#Undumper * @see Globals#undumper
* @see Globasl#Compiler * @see Globals#compiler
* @see Print#print * @see Print#print
*/ */

View File

@@ -38,7 +38,7 @@ package org.luaj.vm2;
* details of this mechanism, as it is built into the core * details of this mechanism, as it is built into the core
* execution framework. * execution framework.
* @see Prototype * @see Prototype
* @see LuaJC * @see org.luaj.vm2.luajc.LuaJC
*/ */
public class TailcallVarargs extends Varargs { public class TailcallVarargs extends Varargs {

View File

@@ -65,7 +65,7 @@ public final class UpValue {
/** /**
* Set the value of the upvalue * Set the value of the upvalue
* @param the {@link LuaValue} to set it to * @param value the {@link LuaValue} to set it to
*/ */
public final void setValue( LuaValue value ) { public final void setValue( LuaValue value ) {
array[index] = value; array[index] = value;

View File

@@ -386,11 +386,12 @@ public abstract class Varargs {
* */ * */
public LuaValue checknotnil(int i) { return arg(i).checknotnil(); } public LuaValue checknotnil(int i) { return arg(i).checknotnil(); }
/** Return argument i as a LuaValue when a user-supplied assertion passes, or throw an error. /** Performs test on argument i as a LuaValue when a user-supplied assertion passes, or throw an error.
* Returns normally if the value of {@code test} is {@code true}, otherwise throws and argument error with
* the supplied message, {@code msg}.
* @param test user supplied assertion to test against * @param test user supplied assertion to test against
* @param i the index to report in any error message * @param i the index to report in any error message
* @param msg the error message to use when the test fails * @param msg the error message to use when the test fails
* @return LuaValue value if the value of {@code test} is {@code true}
* @exception LuaError if the the value of {@code test} is {@code false} * @exception LuaError if the the value of {@code test} is {@code false}
* */ * */
public void argcheck(boolean test, int i, String msg) { if (!test) LuaValue.argerror(i,msg); } public void argcheck(boolean test, int i, String msg) { if (!test) LuaValue.argerror(i,msg); }

View File

@@ -38,18 +38,18 @@ import org.luaj.vm2.lib.BaseLib;
* *
* <p> * <p>
* Compiles lua source files into lua bytecode within a {@link Prototype}, * Compiles lua source files into lua bytecode within a {@link Prototype},
* loads lua binary files directly into a{@link Prototype}, * loads lua binary files directly into a {@link Prototype},
* and optionaly instantiates a {@link LuaClosure} around the result * and optionaly instantiates a {@link LuaClosure} around the result
* using a user-supplied environment. * using a user-supplied environment.
* *
* <p> * <p>
* Implements the {@link Globals.Compiler} interface for loading * Implements the {@link org.luaj.vm2.Globals.Compiler} interface for loading
* initialized chunks, which is an interface common to * initialized chunks, which is an interface common to
* lua bytecode compiling and java bytecode compiling. * lua bytecode compiling and java bytecode compiling.
* *
* <p> * <p>
* The {@link LuaC} compiler is installed by default by both the * The {@link LuaC} compiler is installed by default by both the
* {@link JsePlatform} and {@link JmePlatform} classes, * {@link org.luaj.vm2.lib.jse.JsePlatform} and {@link org.luaj.vm2.lib.jme.JmePlatform} classes,
* so in the following example, the default {@link LuaC} compiler * so in the following example, the default {@link LuaC} compiler
* will be used: * will be used:
* <pre> {@code * <pre> {@code
@@ -62,15 +62,14 @@ import org.luaj.vm2.lib.BaseLib;
* LuaC.install(globals); * LuaC.install(globals);
* } </pre> * } </pre>
* *
* @see LuaC#install(Globals) * @see #install(Globals)
* @see Globals#Compiler * @see Globals#compiler
* @see Globals#Loader * @see Globals#loader
* @see LuaJC * @see org.luaj.vm2.luajc.LuaJC
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see BaseLib * @see BaseLib
* @see LuaValue * @see LuaValue
* @see LuaCompiler
* @see Prototype * @see Prototype
*/ */
public class LuaC extends Constants implements Globals.Compiler, Globals.Loader { public class LuaC extends Constants implements Globals.Compiler, Globals.Loader {

View File

@@ -38,18 +38,18 @@ import org.luaj.vm2.Varargs;
* <p> * <p>
* This contains all library functions listed as "basic functions" in the lua documentation for JME. * This contains all library functions listed as "basic functions" in the lua documentation for JME.
* The functions dofile and loadfile use the * The functions dofile and loadfile use the
* {@link #finder} instance to find resource files. * {@link Globals#finder} instance to find resource files.
* Since JME has no file system by default, {@link BaseLib} implements * Since JME has no file system by default, {@link BaseLib} implements
* {@link ResourceFinder} using {@link Class#getResource(String)}, * {@link ResourceFinder} using {@link Class#getResource(String)},
* which is the closest equivalent on JME. * which is the closest equivalent on JME.
* The default loader chain in {@link PackageLib} will use these as well. * The default loader chain in {@link PackageLib} will use these as well.
* <p> * <p>
* To use basic library functions that include a {@link ResourceFinder} based on * To use basic library functions that include a {@link ResourceFinder} based on
* directory lookup, use {@link JseBaseLib} instead. * directory lookup, use {@link org.luaj.vm2.lib.jse.JseBaseLib} instead.
* <p> * <p>
* Typically, this library is included as part of a call to either * Typically, this library is included as part of a call to either
* {@link JsePlatform#standardGlobals()} or * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()} or
* {@link JmePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jme.JmePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* globals.get("print").call(LuaValue.valueOf("hello, world")); * globals.get("print").call(LuaValue.valueOf("hello, world"));
@@ -67,12 +67,12 @@ import org.luaj.vm2.Varargs;
* and loaded into the globals table. * and loaded into the globals table.
* <p> * <p>
* This is a direct port of the corresponding library in C. * This is a direct port of the corresponding library in C.
* @see JseBaseLib * @see org.luaj.vm2.lib.jse.JseBaseLib
* @see ResourceFinder * @see ResourceFinder
* @see #finder * @see Globals#finder
* @see LibFunction * @see LibFunction
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.1">Lua 5.2 Base Lib Reference</a> * @see <a href="http://www.lua.org/manual/5.2/manual.html#6.1">Lua 5.2 Base Lib Reference</a>
*/ */
public class BaseLib extends TwoArgFunction implements ResourceFinder { public class BaseLib extends TwoArgFunction implements ResourceFinder {

View File

@@ -29,7 +29,7 @@ import org.luaj.vm2.Varargs;
* Subclass of LibFunction that implements the Lua standard {@code bit32} library. * Subclass of LibFunction that implements the Lua standard {@code bit32} library.
* <p> * <p>
* Typically, this library is included as part of a call to either * Typically, this library is included as part of a call to either
* {@link JsePlatform#standardGlobals()} or {@link JmePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()} or {@link org.luaj.vm2.lib.jme.JmePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* System.out.println( globals.get("bit32").get("bnot").call( LuaValue.valueOf(2) ) ); * System.out.println( globals.get("bit32").get("bnot").call( LuaValue.valueOf(2) ) );
@@ -47,8 +47,8 @@ import org.luaj.vm2.Varargs;
* <p> * <p>
* This has been implemented to match as closely as possible the behavior in the corresponding library in C. * This has been implemented to match as closely as possible the behavior in the corresponding library in C.
* @see LibFunction * @see LibFunction
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.7">Lua 5.2 Bitwise Operation Lib Reference</a> * @see <a href="http://www.lua.org/manual/5.2/manual.html#6.7">Lua 5.2 Bitwise Operation Lib Reference</a>
*/ */
public class Bit32Lib extends TwoArgFunction { public class Bit32Lib extends TwoArgFunction {

View File

@@ -39,7 +39,7 @@ import org.luaj.vm2.Varargs;
* may not be collected by the garbage collector. * may not be collected by the garbage collector.
* <p> * <p>
* Typically, this library is included as part of a call to either * Typically, this library is included as part of a call to either
* {@link JsePlatform#standardGlobals()} or {@link JmePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()} or {@link org.luaj.vm2.lib.jme.JmePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* System.out.println( globals.get("coroutine").get("running").call() ); * System.out.println( globals.get("coroutine").get("running").call() );
@@ -56,8 +56,8 @@ import org.luaj.vm2.Varargs;
* } </pre> * } </pre>
* <p> * <p>
* @see LibFunction * @see LibFunction
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.2">Lua 5.2 Coroutine Lib Reference</a> * @see <a href="http://www.lua.org/manual/5.2/manual.html#6.2">Lua 5.2 Coroutine Lib Reference</a>
*/ */
public class CoroutineLib extends TwoArgFunction { public class CoroutineLib extends TwoArgFunction {

View File

@@ -46,11 +46,12 @@ import org.luaj.vm2.Varargs;
* To do this, it must maintain a separate stack of calls to {@link LuaClosure} and {@link LibFunction} * To do this, it must maintain a separate stack of calls to {@link LuaClosure} and {@link LibFunction}
* instances. * instances.
* Especially when lua-to-java bytecode compiling is being used * Especially when lua-to-java bytecode compiling is being used
* via a {@link LuaCompiler} such as {@link LuaJC}, * via a {@link org.luaj.vm2.Globals.Compiler} such as {@link org.luaj.vm2.luajc.LuaJC},
* this cannot be done in all cases. * this cannot be done in all cases.
* <p> * <p>
* Typically, this library is included as part of a call to either * Typically, this library is included as part of a call to either
* {@link JsePlatform#debugGlobals()} or {@link JmePlatform#debugGlobals()} * {@link org.luaj.vm2.lib.jse.JsePlatform#debugGlobals()} or
* {@link org.luaj.vm2.lib.jme.JmePlatform#debugGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.debugGlobals(); * Globals globals = JsePlatform.debugGlobals();
* System.out.println( globals.get("debug").get("traceback").call() ); * System.out.println( globals.get("debug").get("traceback").call() );
@@ -71,8 +72,8 @@ import org.luaj.vm2.Varargs;
* in a shared server environment. * in a shared server environment.
* *
* @see LibFunction * @see LibFunction
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.10">Lua 5.2 Debug Lib Reference</a> * @see <a href="http://www.lua.org/manual/5.2/manual.html#6.10">Lua 5.2 Debug Lib Reference</a>
*/ */
public class DebugLib extends TwoArgFunction { public class DebugLib extends TwoArgFunction {

View File

@@ -46,14 +46,14 @@ import org.luaj.vm2.Varargs;
* which are difficult to support properly on JME. * which are difficult to support properly on JME.
* <p> * <p>
* Typically, this library is included as part of a call to either * Typically, this library is included as part of a call to either
* {@link JsePlatform#standardGlobals()} or {@link JmePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()} or {@link org.luaj.vm2.lib.jme.JmePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* globals.get("io").get("write").call(LuaValue.valueOf("hello, world\n")); * globals.get("io").get("write").call(LuaValue.valueOf("hello, world\n"));
* } </pre> * } </pre>
* In this example the platform-specific {@link JseIoLib} library will be loaded, which will include * In this example the platform-specific {@link org.luaj.vm2.lib.jse.JseIoLib} library will be loaded, which will include
* the base functionality provided by this class, whereas the {@link JsePlatform} would load the * the base functionality provided by this class, whereas the {@link org.luaj.vm2.lib.jse.JsePlatform} would load the
* {@link JseIoLib}. * {@link org.luaj.vm2.lib.jse.JseIoLib}.
* <p> * <p>
* To instantiate and use it directly, * To instantiate and use it directly,
* link it into your globals table via {@link LuaValue#load(LuaValue)} using code such as: * link it into your globals table via {@link LuaValue#load(LuaValue)} using code such as:
@@ -67,10 +67,10 @@ import org.luaj.vm2.Varargs;
* <p> * <p>
* This has been implemented to match as closely as possible the behavior in the corresponding library in C. * This has been implemented to match as closely as possible the behavior in the corresponding library in C.
* @see LibFunction * @see LibFunction
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see JseIoLib * @see org.luaj.vm2.lib.jse.JseIoLib
* @see JmeIoLib * @see org.luaj.vm2.lib.jme.JmeIoLib
* @see <a href="http://www.lua.org/manual/5.1/manual.html#5.7">http://www.lua.org/manual/5.1/manual.html#5.7</a> * @see <a href="http://www.lua.org/manual/5.1/manual.html#5.7">http://www.lua.org/manual/5.1/manual.html#5.7</a>
*/ */
abstract abstract

View File

@@ -51,12 +51,14 @@ import org.luaj.vm2.Varargs;
* hand for JME, so will be slower and less accurate than when executed on the JSE platform. * hand for JME, so will be slower and less accurate than when executed on the JSE platform.
* <p> * <p>
* Typically, this library is included as part of a call to either * Typically, this library is included as part of a call to either
* {@link JsePlatform#standardGlobals()} or {@link JmePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()} or
* {@link org.luaj.vm2.lib.jme.JmePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* System.out.println( globals.get("math").get("sqrt").call( LuaValue.valueOf(2) ) ); * System.out.println( globals.get("math").get("sqrt").call( LuaValue.valueOf(2) ) );
* } </pre> * } </pre>
* When using {@link JsePlaform} as in this example, the subclass {@link JseMathLib} will * When using {@link org.luaj.vm2.lib.jse.JsePlatform} as in this example,
* the subclass {@link org.luaj.vm2.lib.jse.JseMathLib} will
* be included, which also includes this base functionality. * be included, which also includes this base functionality.
* <p> * <p>
* To instantiate and use it directly, * To instantiate and use it directly,
@@ -73,9 +75,9 @@ import org.luaj.vm2.Varargs;
* <p> * <p>
* This has been implemented to match as closely as possible the behavior in the corresponding library in C. * This has been implemented to match as closely as possible the behavior in the corresponding library in C.
* @see LibFunction * @see LibFunction
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see JseMathLib * @see org.luaj.vm2.lib.jse.JseMathLib
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.6">Lua 5.2 Math Lib Reference</a> * @see <a href="http://www.lua.org/manual/5.2/manual.html#6.6">Lua 5.2 Math Lib Reference</a>
*/ */
public class MathLib extends TwoArgFunction { public class MathLib extends TwoArgFunction {

View File

@@ -55,12 +55,12 @@ import org.luaj.vm2.Varargs;
* </ul> * </ul>
* <p> * <p>
* Typically, this library is included as part of a call to either * Typically, this library is included as part of a call to either
* {@link JsePlatform#standardGlobals()} or {@link JmePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()} or {@link org.luaj.vm2.lib.jme.JmePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* System.out.println( globals.get("os").get("time").call() ); * System.out.println( globals.get("os").get("time").call() );
* } </pre> * } </pre>
* In this example the platform-specific {@link JseOsLib} library will be loaded, which will include * In this example the platform-specific {@link org.luaj.vm2.lib.jse.JseOsLib} library will be loaded, which will include
* the base functionality provided by this class. * the base functionality provided by this class.
* <p> * <p>
* To instantiate and use it directly, * To instantiate and use it directly,
@@ -74,9 +74,9 @@ import org.luaj.vm2.Varargs;
* } </pre> * } </pre>
* <p> * <p>
* @see LibFunction * @see LibFunction
* @see JseOsLib * @see org.luaj.vm2.lib.jse.JseOsLib
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see <a href="http://www.lua.org/manual/5.1/manual.html#5.8">http://www.lua.org/manual/5.1/manual.html#5.8</a> * @see <a href="http://www.lua.org/manual/5.1/manual.html#5.8">http://www.lua.org/manual/5.1/manual.html#5.8</a>
*/ */
public class OsLib extends TwoArgFunction { public class OsLib extends TwoArgFunction {

View File

@@ -51,7 +51,7 @@ import org.luaj.vm2.Varargs;
* *
* <h3>Loading</h3> * <h3>Loading</h3>
* Typically, this library is included as part of a call to either * Typically, this library is included as part of a call to either
* {@link JsePlatform#standardGlobals()} or {@link JmePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()} or {@link org.luaj.vm2.lib.jme.JmePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* System.out.println( globals.get("require").call"foo") ); * System.out.println( globals.get("require").call"foo") );
@@ -68,13 +68,13 @@ import org.luaj.vm2.Varargs;
* <h3>Limitations</h3> * <h3>Limitations</h3>
* This library has been implemented to match as closely as possible the behavior in the corresponding library in C. * This library has been implemented to match as closely as possible the behavior in the corresponding library in C.
* However, the default filesystem search semantics are different and delegated to the bas library * However, the default filesystem search semantics are different and delegated to the bas library
* as outlined in the {@link BaseLib} and {@link JseBaseLib} documentation. * as outlined in the {@link BaseLib} and {@link org.luaj.vm2.lib.jse.JseBaseLib} documentation.
* <p> * <p>
* @see LibFunction * @see LibFunction
* @see BaseLib * @see BaseLib
* @see JseBaseLib * @see org.luaj.vm2.lib.jse.JseBaseLib
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.3">Lua 5.2 Package Lib Reference</a> * @see <a href="http://www.lua.org/manual/5.2/manual.html#6.3">Lua 5.2 Package Lib Reference</a>
*/ */
public class PackageLib extends TwoArgFunction { public class PackageLib extends TwoArgFunction {
@@ -105,7 +105,7 @@ public class PackageLib extends TwoArgFunction {
/** The table for this package. */ /** The table for this package. */
LuaTable package_; LuaTable package_;
/** Loader that loads from {@link preload} table if found there */ /** Loader that loads from {@code preload} table if found there */
public preload_searcher preload_searcher; public preload_searcher preload_searcher;
/** Loader that loads as a lua script using the lua path currently in {@link path} */ /** Loader that loads as a lua script using the lua path currently in {@link path} */

View File

@@ -23,6 +23,8 @@ package org.luaj.vm2.lib;
import java.io.InputStream; import java.io.InputStream;
import org.luaj.vm2.Globals;
/** /**
* Interface for opening application resource files such as scripts sources. * Interface for opening application resource files such as scripts sources.
* <p> * <p>
@@ -32,15 +34,15 @@ import java.io.InputStream;
* <p> * <p>
* The Jme version of base lib {@link BaseLib} * The Jme version of base lib {@link BaseLib}
* implements {@link Globals#finder} via {@link Class#getResourceAsStream(String)}, * implements {@link Globals#finder} via {@link Class#getResourceAsStream(String)},
* while the Jse version {@link JseBaseLib} implements it using {@link java.io.File#File(String)}. * while the Jse version {@link org.luaj.vm2.lib.jse.JseBaseLib} implements it using {@link java.io.File#File(String)}.
* <p> * <p>
* The io library does not use this API for file manipulation. * The io library does not use this API for file manipulation.
* <p> * <p>
* @see BaseLib * @see BaseLib
* @see Globals#finder * @see Globals#finder
* @see JseBaseLib * @see org.luaj.vm2.lib.jse.JseBaseLib
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
*/ */
public interface ResourceFinder { public interface ResourceFinder {

View File

@@ -37,7 +37,7 @@ import org.luaj.vm2.compiler.DumpState;
* library. * library.
* <p> * <p>
* Typically, this library is included as part of a call to either * Typically, this library is included as part of a call to either
* {@link JsePlatform#standardGlobals()} or {@link JmePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()} or {@link org.luaj.vm2.lib.jme.JmePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* System.out.println( globals.get("string").get("upper").call( LuaValue.valueOf("abcde") ) ); * System.out.println( globals.get("string").get("upper").call( LuaValue.valueOf("abcde") ) );
@@ -55,8 +55,8 @@ import org.luaj.vm2.compiler.DumpState;
* <p> * <p>
* This is a direct port of the corresponding library in C. * This is a direct port of the corresponding library in C.
* @see LibFunction * @see LibFunction
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.4">Lua 5.2 String Lib Reference</a> * @see <a href="http://www.lua.org/manual/5.2/manual.html#6.4">Lua 5.2 String Lib Reference</a>
*/ */
public class StringLib extends TwoArgFunction { public class StringLib extends TwoArgFunction {

View File

@@ -31,7 +31,7 @@ import org.luaj.vm2.Varargs;
* *
* <p> * <p>
* Typically, this library is included as part of a call to either * Typically, this library is included as part of a call to either
* {@link JsePlatform#standardGlobals()} or {@link JmePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()} or {@link org.luaj.vm2.lib.jme.JmePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* System.out.println( globals.get("table").get("length").call( LuaValue.tableOf() ) ); * System.out.println( globals.get("table").get("length").call( LuaValue.tableOf() ) );
@@ -49,8 +49,8 @@ import org.luaj.vm2.Varargs;
* <p> * <p>
* This has been implemented to match as closely as possible the behavior in the corresponding library in C. * This has been implemented to match as closely as possible the behavior in the corresponding library in C.
* @see LibFunction * @see LibFunction
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.5">Lua 5.2 Table Lib Reference</a> * @see <a href="http://www.lua.org/manual/5.2/manual.html#6.5">Lua 5.2 Table Lib Reference</a>
*/ */
public class TableLib extends TwoArgFunction { public class TableLib extends TwoArgFunction {

View File

@@ -31,7 +31,7 @@ import org.luaj.vm2.Varargs;
* simplifying development. * simplifying development.
* All other uses of {@link #call(LuaValue)}, {@link #invoke()},etc, * All other uses of {@link #call(LuaValue)}, {@link #invoke()},etc,
* are routed through this method by this class, * are routed through this method by this class,
* converting arguments to {@linnk Varargs} and * converting arguments to {@link Varargs} and
* dropping or extending return values with {@code nil} values as required. * dropping or extending return values with {@code nil} values as required.
* <p> * <p>
* If between one and three arguments are required, and only one return value is returned, * If between one and three arguments are required, and only one return value is returned,

View File

@@ -28,6 +28,7 @@ import java.io.OutputStream;
import javax.microedition.io.Connector; import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection; import javax.microedition.io.StreamConnection;
import org.luaj.vm2.Globals;
import org.luaj.vm2.LuaString; import org.luaj.vm2.LuaString;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
import org.luaj.vm2.lib.IoLib; import org.luaj.vm2.lib.IoLib;
@@ -41,7 +42,7 @@ import org.luaj.vm2.lib.LibFunction;
* However, seek is not supported. * However, seek is not supported.
* <p> * <p>
* Typically, this library is included as part of a call to * Typically, this library is included as part of a call to
* {@link JmePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jme.JmePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JmePlatform.standardGlobals(); * Globals globals = JmePlatform.standardGlobals();
* globals.get("io").get("write").call(LuaValue.valueOf("hello, world\n")); * globals.get("io").get("write").call(LuaValue.valueOf("hello, world\n"));
@@ -62,9 +63,9 @@ import org.luaj.vm2.lib.LibFunction;
* This has been implemented to match as closely as possible the behavior in the corresponding library in C. * This has been implemented to match as closely as possible the behavior in the corresponding library in C.
* @see LibFunction * @see LibFunction
* @see org.luaj.vm2.lib.jse.JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see IoLib * @see IoLib
* @see JseIoLib * @see org.luaj.vm2.lib.jse.JseIoLib
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.8">Lua 5.2 I/O Lib Reference</a> * @see <a href="http://www.lua.org/manual/5.2/manual.html#6.8">Lua 5.2 I/O Lib Reference</a>
*/ */
public class JmeIoLib extends IoLib { public class JmeIoLib extends IoLib {

View File

@@ -21,11 +21,11 @@
******************************************************************************/ ******************************************************************************/
package org.luaj.vm2.lib.jme; package org.luaj.vm2.lib.jme;
import org.luaj.vm2.compiler.LuaC;
import org.luaj.vm2.Globals; import org.luaj.vm2.Globals;
import org.luaj.vm2.LoadState; import org.luaj.vm2.LoadState;
import org.luaj.vm2.LuaThread; import org.luaj.vm2.LuaThread;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
import org.luaj.vm2.compiler.LuaC;
import org.luaj.vm2.lib.BaseLib; import org.luaj.vm2.lib.BaseLib;
import org.luaj.vm2.lib.Bit32Lib; import org.luaj.vm2.lib.Bit32Lib;
import org.luaj.vm2.lib.CoroutineLib; import org.luaj.vm2.lib.CoroutineLib;
@@ -33,10 +33,11 @@ import org.luaj.vm2.lib.DebugLib;
import org.luaj.vm2.lib.MathLib; import org.luaj.vm2.lib.MathLib;
import org.luaj.vm2.lib.OsLib; import org.luaj.vm2.lib.OsLib;
import org.luaj.vm2.lib.PackageLib; import org.luaj.vm2.lib.PackageLib;
import org.luaj.vm2.lib.ResourceFinder;
import org.luaj.vm2.lib.StringLib; import org.luaj.vm2.lib.StringLib;
import org.luaj.vm2.lib.TableLib; import org.luaj.vm2.lib.TableLib;
/** The {@link JmePlatform} class is a convenience class to standardize /** The {@link org.luaj.vm2.lib.jme.JmePlatform} class is a convenience class to standardize
* how globals tables are initialized for the JME platform. * how globals tables are initialized for the JME platform.
* <p> * <p>
* The JME platform, being limited, cannot implement all libraries in all aspects. The main limitations are * The JME platform, being limited, cannot implement all libraries in all aspects. The main limitations are
@@ -44,8 +45,8 @@ import org.luaj.vm2.lib.TableLib;
* <li>Some math functions are not implemented, see {@link MathLib} for details</li> * <li>Some math functions are not implemented, see {@link MathLib} for details</li>
* <li>Scripts are loaded via Class.getResourceAsStream(), see {@link BaseLib} for details</li> * <li>Scripts are loaded via Class.getResourceAsStream(), see {@link BaseLib} for details</li>
* <li>OS functions execute(), remove(), rename(), and tmpname() vary, see {@link OsLib} for details</li> * <li>OS functions execute(), remove(), rename(), and tmpname() vary, see {@link OsLib} for details</li>
* <li>I/O seek is not implemented, see {@link JmeIoLib} for details</li> * <li>I/O seek is not implemented, see {@link org.luaj.vm2.lib.jme.JmeIoLib} for details</li>
* <li>luajava is not available, see {@link LuajavaLib} for details</li> * <li>luajava is not available, see {@link org.luaj.vm2.lib.jse.LuajavaLib} for details</li>
* </ul> * </ul>
* <p> * <p>
* It is used to allocate either a set of standard globals using * It is used to allocate either a set of standard globals using
@@ -79,7 +80,7 @@ import org.luaj.vm2.lib.TableLib;
* <li>{@link StringLib}</li> * <li>{@link StringLib}</li>
* <li>{@link CoroutineLib}</li> * <li>{@link CoroutineLib}</li>
* <li>{@link MathLib}</li> * <li>{@link MathLib}</li>
* <li>{@link JmeIoLib}</li> * <li>{@link org.luaj.vm2.lib.jme.JmeIoLib}</li>
* <li>{@link OsLib}</li> * <li>{@link OsLib}</li>
* </ul> * </ul>
* In addition, the {@link LuaC} compiler is installed so lua files may be loaded in their source form. * In addition, the {@link LuaC} compiler is installed so lua files may be loaded in their source form.
@@ -87,10 +88,10 @@ import org.luaj.vm2.lib.TableLib;
* The debug globals are simply the standard globals plus the {@code debug} library {@link DebugLib}. * The debug globals are simply the standard globals plus the {@code debug} library {@link DebugLib}.
* <p> * <p>
* <p> * <p>
* The class ensures that initialization is done in the correct order, * The class ensures that initialization is done in the correct order.
* and that linkage is made to {@link LuaThread#setGlobals(LuaValue)}. *
* @see JsePlatform * @see Globals
* @see LoadState * @see org.luaj.vm2.lib.jse.JsePlatform
*/ */
public class JmePlatform { public class JmePlatform {
@@ -99,8 +100,8 @@ public class JmePlatform {
* *
* @return Table of globals initialized with the standard JME libraries * @return Table of globals initialized with the standard JME libraries
* @see #debugGlobals() * @see #debugGlobals()
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
*/ */
public static Globals standardGlobals() { public static Globals standardGlobals() {
Globals globals = new Globals(); Globals globals = new Globals();
@@ -118,12 +119,12 @@ public class JmePlatform {
return globals; return globals;
} }
/** Create standard globals including the {@link debug} library. /** Create standard globals including the {@link DebugLib} library.
* *
* @return Table of globals initialized with the standard JSE and debug libraries * @return Table of globals initialized with the standard JSE and debug libraries
* @see #standarsGlobals() * @see #standardGlobals()
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see DebugLib * @see DebugLib
*/ */
public static Globals debugGlobals() { public static Globals debugGlobals() {

View File

@@ -33,7 +33,7 @@ import org.luaj.vm2.LuaValue;
/** /**
* Helper class to coerce values from Java to lua within the luajava library. * Helper class to coerce values from Java to lua within the luajava library.
* <p> * <p>
* This class is primarily used by the {@link LuajavaLib}, * This class is primarily used by the {@link org.luaj.vm2.lib.jse.LuajavaLib},
* but can also be used directly when working with Java/lua bindings. * but can also be used directly when working with Java/lua bindings.
* <p> * <p>
* To coerce scalar types, the various, generally the {@code valueOf(type)} methods * To coerce scalar types, the various, generally the {@code valueOf(type)} methods
@@ -59,7 +59,7 @@ import org.luaj.vm2.LuaValue;
* table, or table of tables. * table, or table of tables.
* *
* @see CoerceJavaToLua#coerce(Object) * @see CoerceJavaToLua#coerce(Object)
* @see LuajavaLib * @see org.luaj.vm2.lib.jse.LuajavaLib
*/ */
public class CoerceJavaToLua { public class CoerceJavaToLua {

View File

@@ -33,7 +33,7 @@ import org.luaj.vm2.LuaValue;
/** /**
* Helper class to coerce values from lua to Java within the luajava library. * Helper class to coerce values from lua to Java within the luajava library.
* <p> * <p>
* This class is primarily used by the {@link LuajavaLib}, * This class is primarily used by the {@link org.luaj.vm2.lib.jse.LuajavaLib},
* but can also be used directly when working with Java/lua bindings. * but can also be used directly when working with Java/lua bindings.
* <p> * <p>
* To coerce to specific Java values, generally the {@code toType()} methods * To coerce to specific Java values, generally the {@code toType()} methods
@@ -54,7 +54,7 @@ import org.luaj.vm2.LuaValue;
* For data in lua tables, the various methods on {@link LuaTable} can be used directly * For data in lua tables, the various methods on {@link LuaTable} can be used directly
* to convert data to something more useful. * to convert data to something more useful.
* *
* @see LuajavaLib * @see org.luaj.vm2.lib.jse.LuajavaLib
* @see CoerceJavaToLua * @see CoerceJavaToLua
*/ */
public class CoerceLuaToJava { public class CoerceLuaToJava {

View File

@@ -26,6 +26,7 @@ import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import org.luaj.vm2.Globals;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
import org.luaj.vm2.lib.BaseLib; import org.luaj.vm2.lib.BaseLib;
import org.luaj.vm2.lib.LibFunction; import org.luaj.vm2.lib.LibFunction;
@@ -33,16 +34,16 @@ import org.luaj.vm2.lib.ResourceFinder;
/** /**
* Subclass of {@link BaseLib} and {@link LibFunction} which implements the lua basic library functions * Subclass of {@link BaseLib} and {@link LibFunction} which implements the lua basic library functions
* and provides a directory based {@link ResourceFinder} as the {@link #finder}. * and provides a directory based {@link ResourceFinder} as the {@link Globals#finder}.
* <p> * <p>
* Since JME has no file system by default, {@link BaseLib} implements * Since JME has no file system by default, {@link BaseLib} implements
* {@link ResourceFinder} using {@link Class#getResource(String)}. * {@link ResourceFinder} using {@link Class#getResource(String)}.
* The {@link JseBaseLib} implements {@link finder} by scanning the current directory * The {@link org.luaj.vm2.lib.jse.JseBaseLib} implements {@link Globals#finder} by scanning the current directory
* first, then falling back to {@link Class#getResource(String)} if that fails. * first, then falling back to {@link Class#getResource(String)} if that fails.
* Otherwise, the behavior is the same as that of {@link BaseLib}. * Otherwise, the behavior is the same as that of {@link BaseLib}.
* <p> * <p>
* Typically, this library is included as part of a call to * Typically, this library is included as part of a call to
* {@link JsePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* globals.get("print").call(LuaValue.valueOf("hello, world")); * globals.get("print").call(LuaValue.valueOf("hello, world"));
@@ -62,9 +63,9 @@ import org.luaj.vm2.lib.ResourceFinder;
* @see Globals * @see Globals
* @see BaseLib * @see BaseLib
* @see ResourceFinder * @see ResourceFinder
* @see {@link Globals.finder} * @see Globals#finder
* @see LibFunction * @see LibFunction
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see org.luaj.vm2.lib.jme.JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.1">Lua 5.2 Base Lib Reference</a> * @see <a href="http://www.lua.org/manual/5.2/manual.html#6.1">Lua 5.2 Base Lib Reference</a>
*/ */
@@ -75,7 +76,7 @@ public class JseBaseLib extends org.luaj.vm2.lib.BaseLib {
/** Perform one-time initialization on the library by creating a table /** Perform one-time initialization on the library by creating a table
* containing the library functions, adding that table to the supplied environment, * containing the library functions, adding that table to the supplied environment,
* adding the table to package.loaded, and returning table as the return value. * adding the table to package.loaded, and returning table as the return value.
* <P>Specifically, extend the library loading to set the default value for {@link Globals.STDIN} * <P>Specifically, extend the library loading to set the default value for {@link Globals#STDIN}
* @param modname the module name supplied if this is loaded via 'require'. * @param modname the module name supplied if this is loaded via 'require'.
* @param env the environment to load into, which must be a Globals instance. * @param env the environment to load into, which must be a Globals instance.
*/ */

View File

@@ -29,6 +29,7 @@ import java.io.OutputStream;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import org.luaj.vm2.Globals;
import org.luaj.vm2.LuaError; import org.luaj.vm2.LuaError;
import org.luaj.vm2.LuaString; import org.luaj.vm2.LuaString;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
@@ -42,7 +43,7 @@ import org.luaj.vm2.lib.LibFunction;
* It uses RandomAccessFile to implement seek on files. * It uses RandomAccessFile to implement seek on files.
* <p> * <p>
* Typically, this library is included as part of a call to * Typically, this library is included as part of a call to
* {@link JsePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* globals.get("io").get("write").call(LuaValue.valueOf("hello, world\n")); * globals.get("io").get("write").call(LuaValue.valueOf("hello, world\n"));
@@ -62,10 +63,10 @@ import org.luaj.vm2.lib.LibFunction;
* <p> * <p>
* This has been implemented to match as closely as possible the behavior in the corresponding library in C. * This has been implemented to match as closely as possible the behavior in the corresponding library in C.
* @see LibFunction * @see LibFunction
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see org.luaj.vm2.lib.jme.JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see IoLib * @see IoLib
* @see JmeIoLib * @see org.luaj.vm2.lib.jme.JmeIoLib
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.8">Lua 5.2 I/O Lib Reference</a> * @see <a href="http://www.lua.org/manual/5.2/manual.html#6.8">Lua 5.2 I/O Lib Reference</a>
*/ */
public class JseIoLib extends IoLib { public class JseIoLib extends IoLib {

View File

@@ -21,6 +21,7 @@
******************************************************************************/ ******************************************************************************/
package org.luaj.vm2.lib.jse; package org.luaj.vm2.lib.jse;
import org.luaj.vm2.Globals;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
import org.luaj.vm2.lib.LibFunction; import org.luaj.vm2.lib.LibFunction;
@@ -29,10 +30,10 @@ import org.luaj.vm2.lib.LibFunction;
* library. * library.
* <p> * <p>
* It contains all lua math functions, including those not available on the JME platform. * It contains all lua math functions, including those not available on the JME platform.
* See {@link org.luaj.lib.MathLib} for the exception list. * See {@link org.luaj.vm2.lib.MathLib} for the exception list.
* <p> * <p>
* Typically, this library is included as part of a call to * Typically, this library is included as part of a call to
* {@link JsePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* System.out.println( globals.get("math").get("sqrt").call( LuaValue.valueOf(2) ) ); * System.out.println( globals.get("math").get("sqrt").call( LuaValue.valueOf(2) ) );
@@ -52,9 +53,9 @@ import org.luaj.vm2.lib.LibFunction;
* <p> * <p>
* This has been implemented to match as closely as possible the behavior in the corresponding library in C. * This has been implemented to match as closely as possible the behavior in the corresponding library in C.
* @see LibFunction * @see LibFunction
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see org.luaj.vm2.lib.jme.JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see JseMathLib * @see org.luaj.vm2.lib.jse.JseMathLib
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.6">Lua 5.2 Math Lib Reference</a> * @see <a href="http://www.lua.org/manual/5.2/manual.html#6.6">Lua 5.2 Math Lib Reference</a>
*/ */
public class JseMathLib extends org.luaj.vm2.lib.MathLib { public class JseMathLib extends org.luaj.vm2.lib.MathLib {

View File

@@ -24,9 +24,11 @@ package org.luaj.vm2.lib.jse;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.luaj.vm2.Globals;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
import org.luaj.vm2.Varargs; import org.luaj.vm2.Varargs;
import org.luaj.vm2.lib.LibFunction; import org.luaj.vm2.lib.LibFunction;
import org.luaj.vm2.lib.OsLib;
/** /**
* Subclass of {@link LibFunction} which implements the standard lua {@code os} library. * Subclass of {@link LibFunction} which implements the standard lua {@code os} library.
@@ -45,7 +47,7 @@ import org.luaj.vm2.lib.LibFunction;
* from their counterparts in the C platform. * from their counterparts in the C platform.
* <p> * <p>
* Typically, this library is included as part of a call to * Typically, this library is included as part of a call to
* {@link JsePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* System.out.println( globals.get("os").get("time").call() ); * System.out.println( globals.get("os").get("time").call() );
@@ -65,7 +67,7 @@ import org.luaj.vm2.lib.LibFunction;
* <p> * <p>
* @see LibFunction * @see LibFunction
* @see OsLib * @see OsLib
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see org.luaj.vm2.lib.jme.JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see <a href="http://www.lua.org/manual/5.2/manual.html#6.9">Lua 5.2 OS Lib Reference</a> * @see <a href="http://www.lua.org/manual/5.2/manual.html#6.9">Lua 5.2 OS Lib Reference</a>
*/ */

View File

@@ -34,7 +34,7 @@ import org.luaj.vm2.lib.ResourceFinder;
import org.luaj.vm2.lib.StringLib; import org.luaj.vm2.lib.StringLib;
import org.luaj.vm2.lib.TableLib; import org.luaj.vm2.lib.TableLib;
/** The {@link JsePlatform} class is a convenience class to standardize /** The {@link org.luaj.vm2.lib.jse.JsePlatform} class is a convenience class to standardize
* how globals tables are initialized for the JSE platform. * how globals tables are initialized for the JSE platform.
* <p> * <p>
* It is used to allocate either a set of standard globals using * It is used to allocate either a set of standard globals using
@@ -56,29 +56,30 @@ import org.luaj.vm2.lib.TableLib;
* globals.get("require").call(LuaValue.valueOf("main")); * globals.get("require").call(LuaValue.valueOf("main"));
* } </pre> * } </pre>
* For this to succeed, the file "main.lua" must be in the current directory or a resource. * For this to succeed, the file "main.lua" must be in the current directory or a resource.
* See {@link JseBaseLib} for details on finding scripts using {@link ResourceFinder}. * See {@link org.luaj.vm2.lib.jse.JseBaseLib} for details on finding scripts using {@link ResourceFinder}.
* <p> * <p>
* The standard globals will contain all standard libraries plus {@code luajava}: * The standard globals will contain all standard libraries plus {@code luajava}:
* <ul> * <ul>
* <li>{@link Globals}</li> * <li>{@link Globals}</li>
* <li>{@link JseBaseLib}</li> * <li>{@link org.luaj.vm2.lib.jse.JseBaseLib}</li>
* <li>{@link PackageLib}</li> * <li>{@link PackageLib}</li>
* <li>{@link Bit32Lib}</li> * <li>{@link Bit32Lib}</li>
* <li>{@link TableLib}</li> * <li>{@link TableLib}</li>
* <li>{@link StringLib}</li> * <li>{@link StringLib}</li>
* <li>{@link CoroutineLib}</li> * <li>{@link CoroutineLib}</li>
* <li>{@link JseMathLib}</li> * <li>{@link org.luaj.vm2.lib.jse.JseMathLib}</li>
* <li>{@link JseIoLib}</li> * <li>{@link org.luaj.vm2.lib.jse.JseIoLib}</li>
* <li>{@link JseOsLib}</li> * <li>{@link org.luaj.vm2.lib.jse.JseOsLib}</li>
* <li>{@link LuajavaLib}</li> * <li>{@link org.luaj.vm2.lib.jse.LuajavaLib}</li>
* </ul> * </ul>
* In addition, the {@link LuaC} compiler is installed so lua files may be loaded in their source form. * In addition, the {@link LuaC} compiler is installed so lua files may be loaded in their source form.
* <p> * <p>
* The debug globals are simply the standard globals plus the {@code debug} library {@link DebugLib}. * The debug globals are simply the standard globals plus the {@code debug} library {@link DebugLib}.
* <p> * <p>
* The class ensures that initialization is done in the correct order, * The class ensures that initialization is done in the correct order.
* and that linkage is made to {@link LuaThread#setGlobals(LuaValue)}. *
* @see JmePlatform * @see Globals
* @see org.luaj.vm2.lib.jme.JmePlatform
*/ */
public class JsePlatform { public class JsePlatform {
@@ -87,8 +88,8 @@ public class JsePlatform {
* *
* @return Table of globals initialized with the standard JSE libraries * @return Table of globals initialized with the standard JSE libraries
* @see #debugGlobals() * @see #debugGlobals()
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
*/ */
public static Globals standardGlobals() { public static Globals standardGlobals() {
Globals globals = new Globals(); Globals globals = new Globals();
@@ -107,12 +108,12 @@ public class JsePlatform {
return globals; return globals;
} }
/** Create standard globals including the {@link debug} library. /** Create standard globals including the {@link DebugLib} library.
* *
* @return Table of globals initialized with the standard JSE and debug libraries * @return Table of globals initialized with the standard JSE and debug libraries
* @see #standardGlobals() * @see #standardGlobals()
* @see JsePlatform * @see org.luaj.vm2.lib.jse.JsePlatform
* @see JmePlatform * @see org.luaj.vm2.lib.jme.JmePlatform
* @see DebugLib * @see DebugLib
*/ */
public static Globals debugGlobals() { public static Globals debugGlobals() {

View File

@@ -28,6 +28,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import org.luaj.vm2.Globals;
import org.luaj.vm2.LuaError; import org.luaj.vm2.LuaError;
import org.luaj.vm2.LuaTable; import org.luaj.vm2.LuaTable;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
@@ -45,7 +46,7 @@ import org.luaj.vm2.lib.VarArgFunction;
* *
* <p> * <p>
* Typically, this library is included as part of a call to * Typically, this library is included as part of a call to
* {@link JsePlatform#standardGlobals()} * {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()}
* <pre> {@code * <pre> {@code
* Globals globals = JsePlatform.standardGlobals(); * Globals globals = JsePlatform.standardGlobals();
* System.out.println( globals.get("luajava").get("bindClass").call( LuaValue.valueOf("java.lang.System") ).invokeMethod("currentTimeMillis") ); * System.out.println( globals.get("luajava").get("bindClass").call( LuaValue.valueOf("java.lang.System") ).invokeMethod("currentTimeMillis") );
@@ -65,7 +66,7 @@ import org.luaj.vm2.lib.VarArgFunction;
* <p> * <p>
* *
* The {@code luajava} library is available * The {@code luajava} library is available
* on all JSE platforms via the call to {@link JsePlatform#standardGlobals()} * on all JSE platforms via the call to {@link org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()}
* and the luajava api's are simply invoked from lua. * and the luajava api's are simply invoked from lua.
* Because it makes extensive use of Java's reflection API, it is not available * Because it makes extensive use of Java's reflection API, it is not available
* on JME, but can be used in Android applications. * on JME, but can be used in Android applications.

View File

@@ -27,18 +27,18 @@ import java.io.Reader;
import java.util.Hashtable; import java.util.Hashtable;
import org.luaj.vm2.Globals; import org.luaj.vm2.Globals;
import org.luaj.vm2.LoadState; import org.luaj.vm2.LuaClosure;
import org.luaj.vm2.LuaFunction; import org.luaj.vm2.LuaFunction;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
import org.luaj.vm2.Prototype; import org.luaj.vm2.Prototype;
import org.luaj.vm2.compiler.LuaC; import org.luaj.vm2.compiler.LuaC;
import org.luaj.vm2.lib.BaseLib;
/** /**
* Implementation of {@link LuaCompiler} which does direct * Implementation of {@link org.luaj.vm2.Globals.Compiler} which does direct
* lua-to-java-bytecode compiling. * lua-to-java-bytecode compiling.
* <p> * <p>
* By default, when using {@link JsePlatform} or {@JmePlatform} * By default, when using {@link org.luaj.vm2.lib.jse.JsePlatform} or
* {@link org.luaj.vm2.lib.jme.JmePlatform}
* to construct globals, the plain compiler {@link LuaC} is installed and lua code * to construct globals, the plain compiler {@link LuaC} is installed and lua code
* will only be compiled into lua bytecode and execute as {@link LuaClosure}. * will only be compiled into lua bytecode and execute as {@link LuaClosure}.
* <p> * <p>
@@ -57,9 +57,9 @@ import org.luaj.vm2.lib.BaseLib;
* If the library is not found, the default {@link LuaC} lua-to-lua-bytecode * If the library is not found, the default {@link LuaC} lua-to-lua-bytecode
* compiler will be used. * compiler will be used.
* *
* @see LuaCompiler * @see Globals#compiler
* @see LuaC * @see #install(Globals)
* @see BaseLib * @see org.luaj.vm2.compiler.LuaC
* @see LuaValue * @see LuaValue
*/ */
public class LuaJC implements Globals.Loader { public class LuaJC implements Globals.Loader {