public final class ModuleLib extends Object
require.
Everything else is exported in a table package.| Modifier and Type | Method and Description |
|---|---|
static void |
install(org.classdump.luna.Table env,
String modName,
Object value)
Register the given module in _G and mark it as loaded in package.loaded.
|
static void |
installInto(org.classdump.luna.StateContext context,
org.classdump.luna.Table env,
RuntimeEnvironment runtimeEnvironment,
org.classdump.luna.load.ChunkLoader chunkLoader,
ClassLoader classLoader)
Installs the package library to the global environment
env in the state
context context. |
static org.classdump.luna.runtime.LuaFunction |
searchpath(FileSystem fileSystem)
Returns a function
package.searchpath that uses fileSystem. |
public static org.classdump.luna.runtime.LuaFunction searchpath(FileSystem fileSystem)
package.searchpath that uses fileSystem.
The following is the corresponding entry from the Lua Reference Manual:
package.searchpath (name, path [, sep [, rep]])Searches for the given name in the given path.
A path is a string containing a sequence of templates separated by semicolons. For each template, the function replaces each interrogation mark (if any) in the template with a copy of name wherein all occurrences of
sep(a dot, by default) were replaced byrep(the system's directory separator, by default), and then tries to open the resulting file name.For instance, if the path is the string
"./?.lua;./?.lc;/usr/local/?/init.lua"the search for the name
foo.awill try to open the files./foo/a.lua,./foo/a.lc, and/usr/local/foo/a/init.lua, in that order.Returns the resulting name of the first file that it can open in read mode (after closing the file), or nil plus an error message if none succeeds. (This error message lists all file names it tried to open.)
fileSystem - the filesystem, must not be nullpackage.searchpathNullPointerException - if fileSystem is nullcoroutine.yieldpublic static void installInto(org.classdump.luna.StateContext context,
org.classdump.luna.Table env,
RuntimeEnvironment runtimeEnvironment,
org.classdump.luna.load.ChunkLoader chunkLoader,
ClassLoader classLoader)
env in the state
context context. The package functions will use the runtime environment
runtimeEnvironment, and load modules using chunkLoader (for Lua
scripts), and classLoader (for Java libraries).
The nullity of runtimeEnvironment, runtimeEnvironment.fileSystem(),
chunkLoader and classLoader determines the configuration in which
the package library will be installed:
runtimeEnvironment == null || runtimeEnvironment.fileSystem() == null,
then no package.config, package.path and package.searchpath
will be provided, and the searchers will not include any searchers or loaders
that require access to a filesystem;chunkLoader == null, then no searchers and loaders that load
Lua chunks will be installed;classLoader == null, then no searchers and loaders that load
Java modules by examining the classpath of the virtual machine will be installed.For instance, if runtimeEnvironment, chunkLoader
and classLoader are all null, then the only way for a module to be
installed using the require function will be by adding a loader to
package.preload.
Installs env and the module library table to env.package.loaded
with the keys "_G" and "package", respectively.
context - the state context, must not be nullenv - the global environment, must not be nullruntimeEnvironment - the runtime environment, may be nullchunkLoader - the chunk loader, may be nullclassLoader - the class loader for Java modules, may be nullNullPointerException - if context or env is nullCopyright © 2016–2017. All rights reserved.