Rename Globals.FINDER to Globals.finder.
This commit is contained in:
@@ -921,6 +921,8 @@ Files are no longer hosted at LuaForge.
|
||||
<li>Add sample code for Applet that uses luaj.</li>
|
||||
<li>Fix balanced match for empty string (fixes issue #23).</li>
|
||||
<li>Pass user-supplied ScriptContext to script engine evaluation (fixes issue #21).</li>
|
||||
<li>Autoflush and encode written bytes in script contexts (fixes issue #20).</li>
|
||||
<li>Rename Globals.FINDER to Globals.finder.</li>
|
||||
|
||||
</ul></td></tr>
|
||||
</table></td></tr></table>
|
||||
|
||||
@@ -21,7 +21,7 @@ public class LuajView extends View implements ResourceFinder {
|
||||
public LuajView(Context context) {
|
||||
super(context);
|
||||
this.globals = JsePlatform.standardGlobals();
|
||||
this.globals.FINDER = this;
|
||||
this.globals.finder = this;
|
||||
}
|
||||
|
||||
// Implement a finder that loads from the assets directory.
|
||||
|
||||
@@ -86,7 +86,7 @@ public class SampleApplet extends Applet implements ResourceFinder {
|
||||
LuaC.install(globals);
|
||||
|
||||
// Use custom resource finder.
|
||||
globals.FINDER = this;
|
||||
globals.finder = this;
|
||||
|
||||
// Look up and save the handy pcall method.
|
||||
pcall = globals.get("pcall");
|
||||
|
||||
@@ -80,7 +80,7 @@ import org.luaj.vm2.lib.ResourceFinder;
|
||||
* <li>{@link STDIN} Current value for standard input in the laaded IoLib, if any.
|
||||
* <li>{@link STDOUT} Current value for standard output in the loaded IoLib, if any.
|
||||
* <li>{@link STDERR} Current value for standard error in the loaded 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 undumper} Current loaded {@link Undumper}, if any.
|
||||
* <li>{@link loader} Current loaded {@link Loader}, if any.
|
||||
@@ -122,7 +122,7 @@ public class Globals extends LuaTable {
|
||||
public PrintStream STDERR = System.err;
|
||||
|
||||
/** The installed ResourceFinder for looking files by name. */
|
||||
public ResourceFinder FINDER;
|
||||
public ResourceFinder finder;
|
||||
|
||||
/** The currently running thread. Should not be changed by non-library code. */
|
||||
public LuaThread running = new LuaThread(this);
|
||||
@@ -178,7 +178,7 @@ public class Globals extends LuaTable {
|
||||
*/
|
||||
public LuaValue loadfile(String filename) {
|
||||
try {
|
||||
return load(FINDER.findResource(filename), "@"+filename, "bt", this);
|
||||
return load(finder.findResource(filename), "@"+filename, "bt", this);
|
||||
} catch (Exception e) {
|
||||
return error("load "+filename+": "+e);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.luaj.vm2.Varargs;
|
||||
* <p>
|
||||
* This contains all library functions listed as "basic functions" in the lua documentation for JME.
|
||||
* The functions dofile and loadfile use the
|
||||
* {@link #FINDER} instance to find resource files.
|
||||
* {@link #finder} instance to find resource files.
|
||||
* Since JME has no file system by default, {@link BaseLib} implements
|
||||
* {@link ResourceFinder} using {@link Class#getResource(String)},
|
||||
* which is the closest equivalent on JME.
|
||||
@@ -69,7 +69,7 @@ import org.luaj.vm2.Varargs;
|
||||
* This is a direct port of the corresponding library in C.
|
||||
* @see JseBaseLib
|
||||
* @see ResourceFinder
|
||||
* @see #FINDER
|
||||
* @see #finder
|
||||
* @see LibFunction
|
||||
* @see JsePlatform
|
||||
* @see JmePlatform
|
||||
@@ -81,7 +81,7 @@ public class BaseLib extends TwoArgFunction implements ResourceFinder {
|
||||
|
||||
public LuaValue call(LuaValue modname, LuaValue env) {
|
||||
globals = env.checkglobals();
|
||||
globals.FINDER = this;
|
||||
globals.finder = this;
|
||||
globals.baselib = this;
|
||||
env.set( "_G", env );
|
||||
env.set( "_VERSION", Lua._VERSION );
|
||||
@@ -424,7 +424,7 @@ public class BaseLib extends TwoArgFunction implements ResourceFinder {
|
||||
* @return Varargs containing chunk, or NIL,error-text on error
|
||||
*/
|
||||
public Varargs loadFile(String filename, String mode, LuaValue env) {
|
||||
InputStream is = globals.FINDER.findResource(filename);
|
||||
InputStream is = globals.finder.findResource(filename);
|
||||
if ( is == null )
|
||||
return varargsOf(NIL, valueOf("cannot open "+filename+": No such file or directory"));
|
||||
try {
|
||||
|
||||
@@ -299,7 +299,7 @@ public class PackageLib extends TwoArgFunction {
|
||||
}
|
||||
|
||||
// try opening the file
|
||||
InputStream is = globals.FINDER.findResource(filename);
|
||||
InputStream is = globals.finder.findResource(filename);
|
||||
if (is != null) {
|
||||
try { is.close(); } catch ( java.io.IOException ioe ) {}
|
||||
return valueOf(filename);
|
||||
|
||||
@@ -31,13 +31,13 @@ import java.io.InputStream;
|
||||
* for both the Jme and Jse platforms.
|
||||
* <p>
|
||||
* The Jme version of base lib {@link BaseLib}
|
||||
* implements {@link BaseLib#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)}.
|
||||
* <p>
|
||||
* The io library does not use this API for file manipulation.
|
||||
* <p>
|
||||
* @see BaseLib
|
||||
* @see BaseLib#FINDER
|
||||
* @see Globals#finder
|
||||
* @see JseBaseLib
|
||||
* @see JmePlatform
|
||||
* @see JsePlatform
|
||||
|
||||
@@ -33,11 +33,11 @@ import org.luaj.vm2.lib.ResourceFinder;
|
||||
|
||||
/**
|
||||
* 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 #finder}.
|
||||
* <p>
|
||||
* Since JME has no file system by default, {@link BaseLib} implements
|
||||
* {@link ResourceFinder} using {@link Class#getResource(String)}.
|
||||
* The {@link JseBaseLib} implements {@link FINDER} by scanning the current directory
|
||||
* The {@link JseBaseLib} implements {@link finder} by scanning the current directory
|
||||
* first, then falling back to {@link Class#getResource(String)} if that fails.
|
||||
* Otherwise, the behavior is the same as that of {@link BaseLib}.
|
||||
* <p>
|
||||
@@ -62,7 +62,7 @@ import org.luaj.vm2.lib.ResourceFinder;
|
||||
* @see Globals
|
||||
* @see BaseLib
|
||||
* @see ResourceFinder
|
||||
* @see {@link Globals.FINDER}
|
||||
* @see {@link Globals.finder}
|
||||
* @see LibFunction
|
||||
* @see JsePlatform
|
||||
* @see org.luaj.vm2.lib.jme.JmePlatform
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.luaj.vm2.lib.jse.JsePlatform;
|
||||
import org.luaj.vm2.luajc.LuaJC;
|
||||
|
||||
public class TestLuaJC {
|
||||
// This file will be loaded using the FINDER as a resource, provided it is in the
|
||||
// This file will be loaded using the finder as a resource, provided it is in the
|
||||
// build path. This allows the debugger to find the file when stepping into the function.
|
||||
public static String filename = "perf/nsieve.lua";
|
||||
|
||||
@@ -79,7 +79,7 @@ public class TestLuaJC {
|
||||
// create the chunk
|
||||
String destdir = ".";
|
||||
|
||||
InputStream is = globals.FINDER.findResource(filename);
|
||||
InputStream is = globals.finder.findResource(filename);
|
||||
Hashtable t = LuaJC.instance.compileAll(is, filename, filename, globals, true);
|
||||
|
||||
// write out the chunk
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ScriptDrivenTest extends TestCase implements ResourceFinder {
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
initGlobals();
|
||||
globals.FINDER = this;
|
||||
globals.finder = this;
|
||||
}
|
||||
|
||||
// ResourceFinder implementation.
|
||||
|
||||
Reference in New Issue
Block a user