MediaWiki
1.34.0
|
Public Member Functions | |
addWarning ( $text) | |
Adds a warning to be displayed upon preview. More... | |
callParserFunction ( $frameId, $function, $args) | |
Handler for callParserFunction() More... | |
checkNumber ( $funcName, $args, $index0) | |
Workalike for luaL_checknumber() More... | |
checkString ( $funcName, $args, $index0) | |
Workalike for luaL_checkstring() More... | |
checkType ( $funcName, $args, $index0, $type, $msgType) | |
Workalike for luaL_checktype() More... | |
destroy () | |
executeFunctionChunk ( $chunk, $frame) | |
Execute a module function chunk. More... | |
executeModule ( $chunk, $functionName, $frame) | |
Execute a module chunk in a new isolated environment, and return the specified function. More... | |
expandTemplate ( $frameId, $titleText, $args) | |
Handler for expandTemplate() More... | |
frameExists ( $frameId) | |
Handler for frameExists() More... | |
getAllExpandedArguments ( $frameId) | |
Handler for getAllExpandedArguments() More... | |
getCodeEditorLanguage () | |
Get the language for Ace code editor. More... | |
getExpandedArgument ( $frameId, $name) | |
Handler for getExpandedArgument() More... | |
getFrameTitle ( $frameId) | |
Handler for getTitle() More... | |
getGeSHiLanguage () | |
Get the language for GeSHi syntax highlighter. More... | |
getInterpreter () | |
Get the current interpreter object. More... | |
getLuaLibDir () | |
Return the base path for Lua modules. More... | |
getPerformanceCharacteristics () | |
Get performance characteristics of the Lua engine/interpreter. More... | |
incrementExpensiveFunctionCount () | |
Increment the expensive function count, and throw if limit exceeded. More... | |
isSubsting () | |
Return whether the parser is currently substing. More... | |
load () | |
Initialise the interpreter and the base environment. More... | |
loadPackage ( $name) | |
Handler for the loadPackage() callback. More... | |
loadPHPLibrary ( $name) | |
Handler for the loadPHPLibrary() callback. More... | |
newChildFrame ( $frameId, $title, array $args) | |
Handler for newChildFrame() More... | |
newLuaError ( $message, $params=[]) | |
preprocess ( $frameId, $text) | |
Handler for preprocess() More... | |
registerInterface ( $moduleFileName, $interfaceFuncs, $setupOptions=[]) | |
Register a Lua Library. More... | |
runConsole (array $params) | |
Run an interactive console request. More... | |
setTTL ( $ttl) | |
Handler for setTTL() More... | |
Public Member Functions inherited from ScribuntoEngineBase | |
__construct (array $options) | |
__destruct () | |
fetchModuleFromParser (Title $title) | |
Load a module from some parser-defined template loading mechanism and register a parser output dependency. More... | |
formatLimitData ( $key, &$value, &$report, $isHTML, $localize) | |
Format limit report data. More... | |
getDefaultExceptionParams () | |
getOption ( $optionName) | |
Get an element from the configuration array. More... | |
getParser () | |
getResourceUsage ( $resource) | |
Get CPU and memory usage information, if the script engine provides it. More... | |
getSoftwareInfo (array &$software) | |
Get software information for Special:Version. More... | |
getTitle () | |
newException ( $message, array $params=[]) | |
reportLimitData (ParserOutput $output) | |
Add limit report data to a ParserOutput object. More... | |
setTitle ( $title) | |
validate ( $text, $chunkName=false) | |
Validates the script and returns a Status object containing the syntax errors for the given code. More... | |
Static Public Member Functions | |
static | newAutodetectEngine (array $options) |
If luasandbox is installed and usable then use it, otherwise. More... | |
Public Attributes | |
const | MAX_EXPAND_CACHE_SIZE = 100 |
Public Attributes inherited from ScribuntoEngineBase | |
const | CPU_SECONDS = 1 |
const | MEM_PEAK_BYTES = 2 |
Protected Member Functions | |
formatHtmlLogs ( $logs, $localize) | |
Format the logged data for HTML output. More... | |
getFrameById ( $frameId) | |
Helper function for the implementation of frame methods. More... | |
getLogBuffer () | |
Get data logged by modules. More... | |
loadLibraryFromFile ( $fileName) | |
Load a library from the given file and execute it in the base environment. More... | |
newInterpreter () | |
Create a new interpreter object. More... | |
newModule ( $text, $chunkName) | |
normalizeModuleFileName ( $fileName) | |
Normalize a lua module to its full path. More... | |
Protected Member Functions inherited from ScribuntoEngineBase | |
getLibraries ( $engine, array $coreLibraries=[]) | |
Load a list of all libraries supported by this engine. More... | |
getLibraryPaths ( $engine, array $coreLibraryPaths=[]) | |
Load a list of all paths libraries can be in for this engine. More... | |
Protected Attributes | |
$availableLibraries = [] | |
array | $currentFrames = [] |
$expandCache = [] | |
Scribunto_LuaInterpreter | $interpreter |
$loaded = false | |
array | $mw |
Protected Attributes inherited from ScribuntoEngineBase | |
ScribuntoModuleBase[] | $modules = [] |
array | $options |
Parser | $parser |
Title | $title |
Static Protected Attributes | |
static array | $libraryClasses |
Libraries to load. More... | |
static array | $libraryPaths |
Paths for modules that may be loaded from Lua. More... | |
Private Member Functions | |
doCachedExpansion ( $frame, $input, $cacheKey) | |
instantiatePHPLibrary ( $name, $def, $loadDeferred) | |
Instantiate and register a library. More... | |
setupCurrentFrames (PPFrame $frame=null) | |
Replaces the list of current frames, and return a ScopedCallback that will reset them when it goes out of scope. More... | |
Definition at line 6 of file LuaCommon.php.
Scribunto_LuaEngine::addWarning | ( | $text | ) |
Adds a warning to be displayed upon preview.
Definition at line 877 of file LuaCommon.php.
References ScribuntoEngineBase\getParser().
Scribunto_LuaEngine::callParserFunction | ( | $frameId, | |
$function, | |||
$args | |||
) |
Handler for callParserFunction()
Definition at line 748 of file LuaCommon.php.
References $args, getFrameById(), ScribuntoEngineBase\getParser(), PPFrame\RECOVER_ORIG, and wfEscapeWikiText().
Scribunto_LuaEngine::checkNumber | ( | $funcName, | |
$args, | |||
$index0 | |||
) |
Workalike for luaL_checknumber()
string | $funcName | The Lua function name, for use in error messages |
array | $args | The argument array |
int | $index0 | The zero-based argument index |
Definition at line 487 of file LuaCommon.php.
References $args, and checkType().
Referenced by setTTL().
Scribunto_LuaEngine::checkString | ( | $funcName, | |
$args, | |||
$index0 | |||
) |
Workalike for luaL_checkstring()
string | $funcName | The Lua function name, for use in error messages |
array | $args | The argument array |
int | $index0 | The zero-based argument index |
Definition at line 476 of file LuaCommon.php.
References $args, and checkType().
Referenced by getExpandedArgument(), loadPackage(), loadPHPLibrary(), and preprocess().
Scribunto_LuaEngine::checkType | ( | $funcName, | |
$args, | |||
$index0, | |||
$type, | |||
$msgType | |||
) |
Workalike for luaL_checktype()
string | $funcName | The Lua function name, for use in error messages |
array | $args | The argument array |
int | $index0 | The zero-based argument index |
string | array | $type | The allowed type names as given by gettype() |
string | $msgType | The type name used in the error message |
Scribunto_LuaError |
Definition at line 459 of file LuaCommon.php.
Referenced by checkNumber(), and checkString().
Scribunto_LuaEngine::destroy | ( | ) |
Reimplemented from ScribuntoEngineBase.
Definition at line 103 of file LuaCommon.php.
|
private |
Definition at line 892 of file LuaCommon.php.
References MAX_EXPAND_CACHE_SIZE, and serialize().
Referenced by expandTemplate(), and preprocess().
Scribunto_LuaEngine::executeFunctionChunk | ( | $chunk, | |
$frame | |||
) |
Execute a module function chunk.
mixed | $chunk | As accepted by Scribunto_LuaInterpreter::callFunction() |
PPFrame | null | $frame |
Definition at line 290 of file LuaCommon.php.
References getInterpreter(), and setupCurrentFrames().
Scribunto_LuaEngine::executeModule | ( | $chunk, | |
$functionName, | |||
$frame | |||
) |
Execute a module chunk in a new isolated environment, and return the specified function.
mixed | $chunk | As accepted by Scribunto_LuaInterpreter::callFunction() |
string | $functionName | |
PPFrame | null | $frame |
ScribuntoException |
Definition at line 262 of file LuaCommon.php.
References getInterpreter(), ScribuntoEngineBase\newException(), and setupCurrentFrames().
Scribunto_LuaEngine::expandTemplate | ( | $frameId, | |
$titleText, | |||
$args | |||
) |
Handler for expandTemplate()
Definition at line 705 of file LuaCommon.php.
References $args, ScribuntoEngineBase\$title, doCachedExpansion(), getFrameById(), Title\getNamespace(), ScribuntoEngineBase\getParser(), MWNamespace\isNonincludable(), Title\newFromText(), and NS_TEMPLATE.
|
protected |
Format the logged data for HTML output.
string | $logs | Logged data |
bool | $localize | Whether to localize the message key |
Definition at line 322 of file LuaCommon.php.
References wfMessage().
Referenced by Scribunto_LuaStandaloneEngine\formatLimitData(), and Scribunto_LuaSandboxEngine\formatLimitData().
Scribunto_LuaEngine::frameExists | ( | $frameId | ) |
Handler for frameExists()
Definition at line 602 of file LuaCommon.php.
Scribunto_LuaEngine::getAllExpandedArguments | ( | $frameId | ) |
Handler for getAllExpandedArguments()
Definition at line 690 of file LuaCommon.php.
References getFrameById(), and getInterpreter().
Scribunto_LuaEngine::getCodeEditorLanguage | ( | ) |
Get the language for Ace code editor.
Reimplemented from ScribuntoEngineBase.
Definition at line 384 of file LuaCommon.php.
Scribunto_LuaEngine::getExpandedArgument | ( | $frameId, | |
$name | |||
) |
Handler for getExpandedArgument()
Definition at line 670 of file LuaCommon.php.
References $args, checkString(), getFrameById(), and getInterpreter().
|
protected |
Helper function for the implementation of frame methods.
string | $frameId |
Scribunto_LuaError |
Definition at line 585 of file LuaCommon.php.
References ScribuntoEngineBase\getParser().
Referenced by callParserFunction(), expandTemplate(), getAllExpandedArguments(), getExpandedArgument(), getFrameTitle(), newChildFrame(), preprocess(), and setTTL().
Scribunto_LuaEngine::getFrameTitle | ( | $frameId | ) |
Scribunto_LuaEngine::getGeSHiLanguage | ( | ) |
Get the language for GeSHi syntax highlighter.
Reimplemented from ScribuntoEngineBase.
Definition at line 380 of file LuaCommon.php.
Scribunto_LuaEngine::getInterpreter | ( | ) |
Get the current interpreter object.
Definition at line 223 of file LuaCommon.php.
References $interpreter, and load().
Referenced by executeFunctionChunk(), executeModule(), getAllExpandedArguments(), getExpandedArgument(), getLogBuffer(), loadLibraryFromFile(), preprocess(), and runConsole().
|
protected |
Get data logged by modules.
Definition at line 303 of file LuaCommon.php.
References getInterpreter().
Referenced by Scribunto_LuaSandboxEngine\getLimitReportData(), and Scribunto_LuaStandaloneEngine\reportLimitData().
Scribunto_LuaEngine::getLuaLibDir | ( | ) |
Return the base path for Lua modules.
Definition at line 189 of file LuaCommon.php.
Referenced by Scribunto_LuaSandboxEngine\getMwLuaLine().
|
abstract |
Get performance characteristics of the Lua engine/interpreter.
phpCallsRequireSerialization: boolean whether calls between PHP and Lua functions require (slow) serialization of parameters and return values
Reimplemented in Scribunto_LuaStandaloneEngine, and Scribunto_LuaSandboxEngine.
Scribunto_LuaEngine::incrementExpensiveFunctionCount | ( | ) |
Increment the expensive function count, and throw if limit exceeded.
Definition at line 864 of file LuaCommon.php.
References ScribuntoEngineBase\getParser().
|
private |
Instantiate and register a library.
string | $name | |
array | string | $def | |
bool | $loadDeferred |
MWException |
Definition at line 499 of file LuaCommon.php.
Referenced by load(), and loadPHPLibrary().
Scribunto_LuaEngine::isSubsting | ( | ) |
Return whether the parser is currently substing.
Definition at line 887 of file LuaCommon.php.
References ScribuntoEngineBase\getParser(), and OT_WIKI.
Scribunto_LuaEngine::load | ( | ) |
Initialise the interpreter and the base environment.
Reimplemented in Scribunto_LuaStandaloneEngine.
Definition at line 114 of file LuaCommon.php.
References ScribuntoEngineBase\getLibraries(), instantiatePHPLibrary(), newInterpreter(), and registerInterface().
Referenced by getInterpreter(), Scribunto_LuaSandboxEngine\getLimitReportData(), and Scribunto_LuaSandboxEngine\getResourceUsage().
|
protected |
Load a library from the given file and execute it in the base environment.
string | $fileName | File name/path to load |
Definition at line 344 of file LuaCommon.php.
References $cache, getInterpreter(), and ObjectCache\getLocalServerInstance().
Referenced by registerInterface().
Scribunto_LuaEngine::loadPackage | ( | $name | ) |
Handler for the loadPackage() callback.
Load the specified module and return its chunk. It's not necessary to cache the resulting chunk in the object instance, since there is caching in a wrapper on the Lua side.
Definition at line 546 of file LuaCommon.php.
References $args, $path, ScribuntoEngineBase\$title, checkString(), ScribuntoEngineBase\fetchModuleFromParser(), ScribuntoEngineBase\getLibraryPaths(), Title\hasContentModel(), Title\newFromText(), and normalizeModuleFileName().
Scribunto_LuaEngine::loadPHPLibrary | ( | $name | ) |
Handler for the loadPHPLibrary() callback.
Register the specified library and return its function table. It's not necessary to cache the function table in the object instance, since there is caching in a wrapper on the Lua side.
Definition at line 525 of file LuaCommon.php.
References $args, checkString(), and instantiatePHPLibrary().
|
static |
If luasandbox is installed and usable then use it, otherwise.
array | $options |
Definition at line 62 of file LuaCommon.php.
References ScribuntoEngineBase\$options, Scribunto_LuaSandboxInterpreter\checkLuaSandboxVersion(), and Scribunto\newEngine().
Scribunto_LuaEngine::newChildFrame | ( | $frameId, | |
$title, | |||
array | $args | ||
) |
Handler for newChildFrame()
Definition at line 616 of file LuaCommon.php.
References $args, ScribuntoEngineBase\$title, getFrameById(), ScribuntoEngineBase\getParser(), and Title\newFromText().
|
abstractprotected |
Create a new interpreter object.
Reimplemented in Scribunto_LuaSandboxEngine, and Scribunto_LuaStandaloneEngine.
Referenced by load().
Scribunto_LuaEngine::newLuaError | ( | $message, | |
$params = [] |
|||
) |
string | $message | |
array | $params |
Definition at line 99 of file LuaCommon.php.
References ScribuntoEngineBase\getDefaultExceptionParams().
|
protected |
string | $text | |
string | bool | $chunkName |
Reimplemented from ScribuntoEngineBase.
Definition at line 90 of file LuaCommon.php.
Referenced by runConsole().
|
protected |
Normalize a lua module to its full path.
If path does not look like an absolute path (i.e. begins with DIRECTORY_SEPARATOR or "X:"), prepend getLuaLibDir()
string | $fileName | name of the lua module file |
Definition at line 201 of file LuaCommon.php.
Referenced by loadPackage(), and registerInterface().
Scribunto_LuaEngine::preprocess | ( | $frameId, | |
$text | |||
) |
Handler for preprocess()
Definition at line 833 of file LuaCommon.php.
References $args, checkString(), doCachedExpansion(), getFrameById(), and getInterpreter().
Scribunto_LuaEngine::registerInterface | ( | $moduleFileName, | |
$interfaceFuncs, | |||
$setupOptions = [] |
|||
) |
Register a Lua Library.
This should be called from the library's PHP module's register() method.
The value for $interfaceFuncs is used to populate the mw_interface global that is defined when the library's Lua module is loaded. Values must be PHP callables, which will be seen in Lua as functions.
string | $moduleFileName | The path to the Lua portion of the library (absolute, or relative to $this->getLuaLibDir()) |
array | $interfaceFuncs | Populates mw_interface |
array | $setupOptions | Passed to the modules setupInterface() method. |
Definition at line 175 of file LuaCommon.php.
References loadLibraryFromFile(), and normalizeModuleFileName().
Referenced by load().
Scribunto_LuaEngine::runConsole | ( | array | $params | ) |
Run an interactive console request.
array | $params | Associative array. Options are:
|
Reimplemented from ScribuntoEngineBase.
Definition at line 388 of file LuaCommon.php.
References getInterpreter(), newModule(), setupCurrentFrames(), and wfMessage().
Scribunto_LuaEngine::setTTL | ( | $ttl | ) |
Handler for setTTL()
Definition at line 655 of file LuaCommon.php.
References $args, checkNumber(), and getFrameById().
|
private |
Replaces the list of current frames, and return a ScopedCallback that will reset them when it goes out of scope.
PPFrame | null | $frame | If null, an empty frame with no parent will be used |
Definition at line 235 of file LuaCommon.php.
References $currentFrames, $expandCache, and ScribuntoEngineBase\getParser().
Referenced by executeFunctionChunk(), executeModule(), and runConsole().
|
protected |
Definition at line 51 of file LuaCommon.php.
|
protected |
Definition at line 49 of file LuaCommon.php.
Referenced by setupCurrentFrames().
|
protected |
Definition at line 50 of file LuaCommon.php.
Referenced by setupCurrentFrames().
|
protected |
Definition at line 39 of file LuaCommon.php.
Referenced by getInterpreter().
|
staticprotected |
Libraries to load.
See also the 'ScribuntoExternalLibraries' hook. Maps module names to PHP classes or definition arrays
Definition at line 11 of file LuaCommon.php.
|
staticprotected |
Paths for modules that may be loaded from Lua.
See also the 'ScribuntoExternalLibraryPaths' hook. Paths
Definition at line 28 of file LuaCommon.php.
|
protected |
Definition at line 34 of file LuaCommon.php.
|
protected |
Definition at line 44 of file LuaCommon.php.
const Scribunto_LuaEngine::MAX_EXPAND_CACHE_SIZE = 100 |
Definition at line 53 of file LuaCommon.php.
Referenced by doCachedExpansion().