Improve string lib factoring, javadoc on lib loading functions.

This commit is contained in:
James Roseborough
2015-04-05 16:19:13 +00:00
parent 591de13a46
commit 878bf5ac78
12 changed files with 122 additions and 29 deletions

View File

@@ -71,7 +71,14 @@ import org.luaj.vm2.lib.ResourceFinder;
public class JseBaseLib extends org.luaj.vm2.lib.BaseLib {
/** Extend the library loading to set the default value for {@link Globals.STDIN} */
/** Perform one-time initialization on the library by creating a table
* containing the library functions, adding that table to the supplied environment,
* 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}
* @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.
*/
public LuaValue call(LuaValue modname, LuaValue env) {
super.call(modname, env);
env.checkglobals().STDIN = System.in;

View File

@@ -61,6 +61,15 @@ public class JseMathLib extends org.luaj.vm2.lib.MathLib {
public JseMathLib() {}
/** Perform one-time initialization on the library by creating a table
* containing the library functions, adding that table to the supplied environment,
* adding the table to package.loaded, and returning table as the return value.
* <P>Specifically, adds all library functions that can be implemented directly
* in JSE but not JME: acos, asin, atan, atan2, cosh, exp, log, pow, sinh, and tanh.
* @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.
*/
public LuaValue call(LuaValue modname, LuaValue env) {
super.call(modname, env);
LuaValue math = env.get("math");