MediaWiki REL1_34
ScribuntoEngineBase Class Reference

Wikitext scripting infrastructure for MediaWiki: base classes. More...

Inheritance diagram for ScribuntoEngineBase:
Collaboration diagram for ScribuntoEngineBase:

Public Member Functions

 __construct (array $options)
 
 __destruct ()
 
 destroy ()
 
 fetchModuleFromParser (Title $title)
 Load a module from some parser-defined template loading mechanism and register a parser output dependency.
 
 formatLimitData ( $key, &$value, &$report, $isHTML, $localize)
 Format limit report data.
 
 getCodeEditorLanguage ()
 Get the language for Ace code editor.
 
 getDefaultExceptionParams ()
 
 getGeSHiLanguage ()
 Get the language for GeSHi syntax highlighter.
 
 getOption ( $optionName)
 Get an element from the configuration array.
 
 getParser ()
 
 getResourceUsage ( $resource)
 Get CPU and memory usage information, if the script engine provides it.
 
 getSoftwareInfo (array &$software)
 Get software information for Special:Version.
 
 getTitle ()
 
 newException ( $message, array $params=[])
 
 reportLimitData (ParserOutput $output)
 Add limit report data to a ParserOutput object.
 
 runConsole (array $params)
 Run an interactive console request.
 
 setTitle ( $title)
 
 validate ( $text, $chunkName=false)
 Validates the script and returns a Status object containing the syntax errors for the given code.
 

Public Attributes

const CPU_SECONDS = 1
 
const MEM_PEAK_BYTES = 2
 

Protected Member Functions

 getLibraries ( $engine, array $coreLibraries=[])
 Load a list of all libraries supported by this engine.
 
 getLibraryPaths ( $engine, array $coreLibraryPaths=[])
 Load a list of all paths libraries can be in for this engine.
 
 newModule ( $text, $chunkName)
 Creates a new module object within this engine.
 

Protected Attributes

ScribuntoModuleBase[] $modules = []
 
array $options
 
Parser $parser
 
Title $title
 

Detailed Description

Wikitext scripting infrastructure for MediaWiki: base classes.

Copyright (C) 2012 Victor Vasiliev vasil.nosp@m.vv@g.nosp@m.mail..nosp@m.com et al https://www.mediawiki.org/

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html Base class for all script engines. Includes all code not related to particular modules, like tracking links between modules or loading module texts.

Definition at line 29 of file Base.php.

Constructor & Destructor Documentation

◆ __construct()

ScribuntoEngineBase::__construct ( array $options)
Parameters
array$optionsAssociative array of options:

Definition at line 89 of file Base.php.

References $options.

◆ __destruct()

ScribuntoEngineBase::__destruct ( )

Definition at line 99 of file Base.php.

References destroy().

Member Function Documentation

◆ destroy()

ScribuntoEngineBase::destroy ( )

Reimplemented in Scribunto_LuaEngine.

Definition at line 103 of file Base.php.

Referenced by __destruct().

◆ fetchModuleFromParser()

ScribuntoEngineBase::fetchModuleFromParser ( Title $title)

Load a module from some parser-defined template loading mechanism and register a parser output dependency.

Does not initialize the module, i.e. do not expect it to complain if the module text is garbage or has syntax error. Returns a module or null if it doesn't exist.

Parameters
Title$titleThe title of the module
Returns
ScribuntoModuleBase|null

Definition at line 164 of file Base.php.

References $title, Title\getPrefixedDBkey(), and newModule().

Referenced by Scribunto_LuaEngine\loadPackage().

◆ formatLimitData()

ScribuntoEngineBase::formatLimitData ( $key,
& $value,
& $report,
$isHTML,
$localize )

Format limit report data.

Parameters
string$key
mixed&$value
string&$report
bool$isHTML
bool$localize
Returns
bool

Reimplemented in Scribunto_LuaSandboxEngine, and Scribunto_LuaStandaloneEngine.

Definition at line 287 of file Base.php.

◆ getCodeEditorLanguage()

ScribuntoEngineBase::getCodeEditorLanguage ( )

Get the language for Ace code editor.

Returns
string|false

Reimplemented in Scribunto_LuaEngine.

Definition at line 224 of file Base.php.

◆ getDefaultExceptionParams()

ScribuntoEngineBase::getDefaultExceptionParams ( )
Returns
array

Definition at line 146 of file Base.php.

References $title.

Referenced by newException(), and Scribunto_LuaEngine\newLuaError().

◆ getGeSHiLanguage()

ScribuntoEngineBase::getGeSHiLanguage ( )

Get the language for GeSHi syntax highlighter.

Returns
string|false

Reimplemented in Scribunto_LuaEngine.

Definition at line 216 of file Base.php.

Referenced by ScribuntoContent\highlight().

◆ getLibraries()

ScribuntoEngineBase::getLibraries ( $engine,
array $coreLibraries = [] )
protected

Load a list of all libraries supported by this engine.

The return value is an array with keys being the library name seen by the module and values being either a PHP class name or an array with the following elements:

  • class: (string) Class to load (required)
  • deferLoad: (bool) Library should not be loaded at startup; modules needing the library must request it (e.g. via 'require' in Lua)
Parameters
string$enginescript engine we're using (eg: lua)
array$coreLibrariesArray of core libraries we support
Returns
array

Definition at line 249 of file Base.php.

Referenced by Scribunto_LuaEngine\load().

◆ getLibraryPaths()

ScribuntoEngineBase::getLibraryPaths ( $engine,
array $coreLibraryPaths = [] )
protected

Load a list of all paths libraries can be in for this engine.

Parameters
string$enginescript engine we're using (eg: lua)
array$coreLibraryPathsArray of library paths to use by default
Returns
array

Definition at line 262 of file Base.php.

Referenced by Scribunto_LuaEngine\loadPackage().

◆ getOption()

ScribuntoEngineBase::getOption ( $optionName)

Get an element from the configuration array.

Parameters
string$optionName
Returns
mixed

Definition at line 130 of file Base.php.

◆ getParser()

◆ getResourceUsage()

ScribuntoEngineBase::getResourceUsage ( $resource)

Get CPU and memory usage information, if the script engine provides it.

If the script engine is capable of reporting CPU and memory usage data, it should override this implementation.

Parameters
int$resourceOne of ScribuntoEngineBase::CPU_SECONDS or ScribuntoEngineBase::MEM_PEAK_BYTES.
Returns
float|int|false Resource usage for the specified resource or false if not available.

Reimplemented in Scribunto_LuaSandboxEngine.

Definition at line 208 of file Base.php.

◆ getSoftwareInfo()

ScribuntoEngineBase::getSoftwareInfo ( array & $software)
abstract

Get software information for Special:Version.

Parameters
array&$software

Reimplemented in Scribunto_LuaSandboxEngine, and Scribunto_LuaStandaloneEngine.

◆ getTitle()

ScribuntoEngineBase::getTitle ( )
Returns
Title

Definition at line 120 of file Base.php.

References $title.

◆ newException()

ScribuntoEngineBase::newException ( $message,
array $params = [] )
Parameters
string$message
array$params
Returns
ScribuntoException

Definition at line 139 of file Base.php.

References getDefaultExceptionParams().

Referenced by Scribunto_LuaEngine\executeModule().

◆ newModule()

ScribuntoEngineBase::newModule ( $text,
$chunkName )
abstractprotected

Creates a new module object within this engine.

Parameters
string$text
string | bool$chunkName
Returns
ScribuntoModuleBase

Reimplemented in Scribunto_LuaEngine.

Referenced by fetchModuleFromParser(), and validate().

◆ reportLimitData()

ScribuntoEngineBase::reportLimitData ( ParserOutput $output)

Add limit report data to a ParserOutput object.

Parameters
ParserOutput$outputParserOutput object in which to add limit data
Returns
null

Reimplemented in Scribunto_LuaSandboxEngine, and Scribunto_LuaStandaloneEngine.

Definition at line 274 of file Base.php.

◆ runConsole()

ScribuntoEngineBase::runConsole ( array $params)
abstract

Run an interactive console request.

Parameters
array$paramsAssociative array. Options are:
  • title: The title object for the module being debugged
  • content: The text content of the module
  • prevQuestions: An array of previous "questions" used to establish the state
  • question: The current "question", a string script
Returns
array containing:
  • print: The resulting print buffer
  • return: The resulting return value

Reimplemented in Scribunto_LuaEngine.

◆ setTitle()

ScribuntoEngineBase::setTitle ( $title)
Parameters
Title$title

Definition at line 113 of file Base.php.

References $title.

◆ validate()

ScribuntoEngineBase::validate ( $text,
$chunkName = false )

Validates the script and returns a Status object containing the syntax errors for the given code.

Parameters
string$text
string | bool$chunkName
Returns
Status

Definition at line 191 of file Base.php.

References newModule().

Member Data Documentation

◆ $modules

ScribuntoModuleBase [] ScribuntoEngineBase::$modules = []
protected

Definition at line 48 of file Base.php.

◆ $options

array ScribuntoEngineBase::$options
protected

Definition at line 43 of file Base.php.

Referenced by __construct(), and Scribunto_LuaEngine\newAutodetectEngine().

◆ $parser

Parser ScribuntoEngineBase::$parser
protected

Definition at line 53 of file Base.php.

Referenced by getParser().

◆ $title

◆ CPU_SECONDS

const ScribuntoEngineBase::CPU_SECONDS = 1

Definition at line 32 of file Base.php.

Referenced by Scribunto_LuaSandboxEngine\getResourceUsage().

◆ MEM_PEAK_BYTES

const ScribuntoEngineBase::MEM_PEAK_BYTES = 2

Definition at line 33 of file Base.php.

Referenced by Scribunto_LuaSandboxEngine\getResourceUsage().


The documentation for this class was generated from the following file: