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>Add sample code for Applet that uses luaj.</li>
|
||||||
<li>Fix balanced match for empty string (fixes issue #23).</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>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>
|
</ul></td></tr>
|
||||||
</table></td></tr></table>
|
</table></td></tr></table>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class LuajView extends View implements ResourceFinder {
|
|||||||
public LuajView(Context context) {
|
public LuajView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
this.globals = JsePlatform.standardGlobals();
|
this.globals = JsePlatform.standardGlobals();
|
||||||
this.globals.FINDER = this;
|
this.globals.finder = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement a finder that loads from the assets directory.
|
// Implement a finder that loads from the assets directory.
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public class SampleApplet extends Applet implements ResourceFinder {
|
|||||||
LuaC.install(globals);
|
LuaC.install(globals);
|
||||||
|
|
||||||
// Use custom resource finder.
|
// Use custom resource finder.
|
||||||
globals.FINDER = this;
|
globals.finder = this;
|
||||||
|
|
||||||
// Look up and save the handy pcall method.
|
// Look up and save the handy pcall method.
|
||||||
pcall = globals.get("pcall");
|
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 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 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 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 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.
|
||||||
@@ -122,7 +122,7 @@ public class Globals extends LuaTable {
|
|||||||
public PrintStream STDERR = System.err;
|
public PrintStream STDERR = System.err;
|
||||||
|
|
||||||
/** The installed ResourceFinder for looking files by name. */
|
/** 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. */
|
/** The currently running thread. Should not be changed by non-library code. */
|
||||||
public LuaThread running = new LuaThread(this);
|
public LuaThread running = new LuaThread(this);
|
||||||
@@ -178,7 +178,7 @@ public class Globals extends LuaTable {
|
|||||||
*/
|
*/
|
||||||
public LuaValue loadfile(String filename) {
|
public LuaValue loadfile(String filename) {
|
||||||
try {
|
try {
|
||||||
return load(FINDER.findResource(filename), "@"+filename, "bt", this);
|
return load(finder.findResource(filename), "@"+filename, "bt", this);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return error("load "+filename+": "+e);
|
return error("load "+filename+": "+e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ 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 #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.
|
||||||
@@ -69,7 +69,7 @@ import org.luaj.vm2.Varargs;
|
|||||||
* 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 JseBaseLib
|
||||||
* @see ResourceFinder
|
* @see ResourceFinder
|
||||||
* @see #FINDER
|
* @see #finder
|
||||||
* @see LibFunction
|
* @see LibFunction
|
||||||
* @see JsePlatform
|
* @see JsePlatform
|
||||||
* @see JmePlatform
|
* @see JmePlatform
|
||||||
@@ -81,7 +81,7 @@ public class BaseLib extends TwoArgFunction implements ResourceFinder {
|
|||||||
|
|
||||||
public LuaValue call(LuaValue modname, LuaValue env) {
|
public LuaValue call(LuaValue modname, LuaValue env) {
|
||||||
globals = env.checkglobals();
|
globals = env.checkglobals();
|
||||||
globals.FINDER = this;
|
globals.finder = this;
|
||||||
globals.baselib = this;
|
globals.baselib = this;
|
||||||
env.set( "_G", env );
|
env.set( "_G", env );
|
||||||
env.set( "_VERSION", Lua._VERSION );
|
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
|
* @return Varargs containing chunk, or NIL,error-text on error
|
||||||
*/
|
*/
|
||||||
public Varargs loadFile(String filename, String mode, LuaValue env) {
|
public Varargs loadFile(String filename, String mode, LuaValue env) {
|
||||||
InputStream is = globals.FINDER.findResource(filename);
|
InputStream is = globals.finder.findResource(filename);
|
||||||
if ( is == null )
|
if ( is == null )
|
||||||
return varargsOf(NIL, valueOf("cannot open "+filename+": No such file or directory"));
|
return varargsOf(NIL, valueOf("cannot open "+filename+": No such file or directory"));
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ public class PackageLib extends TwoArgFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try opening the file
|
// try opening the file
|
||||||
InputStream is = globals.FINDER.findResource(filename);
|
InputStream is = globals.finder.findResource(filename);
|
||||||
if (is != null) {
|
if (is != null) {
|
||||||
try { is.close(); } catch ( java.io.IOException ioe ) {}
|
try { is.close(); } catch ( java.io.IOException ioe ) {}
|
||||||
return valueOf(filename);
|
return valueOf(filename);
|
||||||
|
|||||||
@@ -31,13 +31,13 @@ import java.io.InputStream;
|
|||||||
* for both the Jme and Jse platforms.
|
* for both the Jme and Jse platforms.
|
||||||
* <p>
|
* <p>
|
||||||
* The Jme version of base lib {@link BaseLib}
|
* 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)}.
|
* while the Jse version {@link 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 BaseLib#FINDER
|
* @see Globals#finder
|
||||||
* @see JseBaseLib
|
* @see JseBaseLib
|
||||||
* @see JmePlatform
|
* @see JmePlatform
|
||||||
* @see JsePlatform
|
* @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
|
* 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>
|
* <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 JseBaseLib} implements {@link 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>
|
||||||
@@ -62,7 +62,7 @@ import org.luaj.vm2.lib.ResourceFinder;
|
|||||||
* @see Globals
|
* @see Globals
|
||||||
* @see BaseLib
|
* @see BaseLib
|
||||||
* @see ResourceFinder
|
* @see ResourceFinder
|
||||||
* @see {@link Globals.FINDER}
|
* @see {@link Globals.finder}
|
||||||
* @see LibFunction
|
* @see LibFunction
|
||||||
* @see JsePlatform
|
* @see JsePlatform
|
||||||
* @see org.luaj.vm2.lib.jme.JmePlatform
|
* @see org.luaj.vm2.lib.jme.JmePlatform
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import org.luaj.vm2.lib.jse.JsePlatform;
|
|||||||
import org.luaj.vm2.luajc.LuaJC;
|
import org.luaj.vm2.luajc.LuaJC;
|
||||||
|
|
||||||
public class TestLuaJC {
|
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.
|
// build path. This allows the debugger to find the file when stepping into the function.
|
||||||
public static String filename = "perf/nsieve.lua";
|
public static String filename = "perf/nsieve.lua";
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public class TestLuaJC {
|
|||||||
// create the chunk
|
// create the chunk
|
||||||
String destdir = ".";
|
String destdir = ".";
|
||||||
|
|
||||||
InputStream is = globals.FINDER.findResource(filename);
|
InputStream is = globals.finder.findResource(filename);
|
||||||
Hashtable t = LuaJC.instance.compileAll(is, filename, filename, globals, true);
|
Hashtable t = LuaJC.instance.compileAll(is, filename, filename, globals, true);
|
||||||
|
|
||||||
// write out the chunk
|
// write out the chunk
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class ScriptDrivenTest extends TestCase implements ResourceFinder {
|
|||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
initGlobals();
|
initGlobals();
|
||||||
globals.FINDER = this;
|
globals.finder = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResourceFinder implementation.
|
// ResourceFinder implementation.
|
||||||
|
|||||||
Reference in New Issue
Block a user