MediaWiki  1.34.0
Scribunto_LuaSandboxInterpreter Class Reference
Inheritance diagram for Scribunto_LuaSandboxInterpreter:
Collaboration diagram for Scribunto_LuaSandboxInterpreter:

Public Member Functions

 __construct ( $engine, array $options)
 
 callFunction ( $func,... $args)
 Call a Lua function. More...
 
 getCPUUsage ()
 
 getPeakMemoryUsage ()
 
 getProfilerFunctionReport ( $units)
 
 isLuaFunction ( $object)
 Test whether an object is a Lua function. More...
 
 loadString ( $text, $chunkName)
 
 pauseUsageTimer ()
 Pause CPU usage and limits. More...
 
 registerLibrary ( $name, array $functions)
 Register a library of functions. More...
 
 unpauseUsageTimer ()
 Unpause CPU usage and limits. More...
 
 wrapPhpFunction ( $callable)
 Wrap a PHP callable as a Lua function, which can be passed back into Lua. More...
 

Static Public Member Functions

static checkLuaSandboxVersion ()
 Check that php-luasandbox is available and of a recent-enough version. More...
 

Public Attributes

Scribunto_LuaEngine $engine
 
bool $profilerEnabled
 
LuaSandbox $sandbox
 
const PERCENT = 2
 
const SAMPLES = 0
 
const SECONDS = 1
 

Protected Member Functions

 convertSandboxError (LuaSandboxError $e)
 

Detailed Description

Definition at line 215 of file Engine.php.

Constructor & Destructor Documentation

◆ __construct()

Scribunto_LuaSandboxInterpreter::__construct (   $engine,
array  $options 
)

Definition at line 254 of file Engine.php.

References $engine, and checkLuaSandboxVersion().

Member Function Documentation

◆ callFunction()

Scribunto_LuaSandboxInterpreter::callFunction (   $func,
  $args 
)

Call a Lua function.

Return an array of results, with indices starting at zero. If an error occurs, a Scribunto_LuaError will be thrown.

Parameters
mixed$funcThe function object
mixed...$args Arguments to the function

Reimplemented from Scribunto_LuaInterpreter.

Definition at line 312 of file Engine.php.

References $args, and convertSandboxError().

◆ checkLuaSandboxVersion()

static Scribunto_LuaSandboxInterpreter::checkLuaSandboxVersion ( )
static

Check that php-luasandbox is available and of a recent-enough version.

Exceptions
Scribunto_LuaInterpreterNotFoundError
Scribunto_LuaInterpreterBadVersionError

Definition at line 240 of file Engine.php.

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

◆ convertSandboxError()

Scribunto_LuaSandboxInterpreter::convertSandboxError ( LuaSandboxError  $e)
protected

Definition at line 270 of file Engine.php.

Referenced by callFunction(), and loadString().

◆ getCPUUsage()

Scribunto_LuaSandboxInterpreter::getCPUUsage ( )

Definition at line 342 of file Engine.php.

◆ getPeakMemoryUsage()

Scribunto_LuaSandboxInterpreter::getPeakMemoryUsage ( )

Definition at line 338 of file Engine.php.

◆ getProfilerFunctionReport()

Scribunto_LuaSandboxInterpreter::getProfilerFunctionReport (   $units)

Definition at line 346 of file Engine.php.

◆ isLuaFunction()

Scribunto_LuaSandboxInterpreter::isLuaFunction (   $object)

Test whether an object is a Lua function.

Parameters
object$object
Returns
bool

Reimplemented from Scribunto_LuaInterpreter.

Definition at line 334 of file Engine.php.

◆ loadString()

Scribunto_LuaSandboxInterpreter::loadString (   $text,
  $chunkName 
)
Parameters
string$text
string$chunkName
Returns
mixed
Exceptions
Scribunto_LuaError

Reimplemented from Scribunto_LuaInterpreter.

Definition at line 290 of file Engine.php.

References convertSandboxError().

◆ pauseUsageTimer()

Scribunto_LuaSandboxInterpreter::pauseUsageTimer ( )

Pause CPU usage and limits.

Returns
void

Reimplemented from Scribunto_LuaInterpreter.

Definition at line 362 of file Engine.php.

◆ registerLibrary()

Scribunto_LuaSandboxInterpreter::registerLibrary (   $name,
array  $functions 
)

Register a library of functions.

Parameters
string$nameThe global variable name to be created or added to.
array$functionsAn associative array mapping the function name to the callback. The callback may throw a Scribunto_LuaError, which will be caught and raised in the Lua code as a Lua error, catchable with pcall().

Reimplemented from Scribunto_LuaInterpreter.

Definition at line 298 of file Engine.php.

◆ unpauseUsageTimer()

Scribunto_LuaSandboxInterpreter::unpauseUsageTimer ( )

Unpause CPU usage and limits.

Returns
void

Reimplemented from Scribunto_LuaInterpreter.

Definition at line 366 of file Engine.php.

◆ wrapPhpFunction()

Scribunto_LuaSandboxInterpreter::wrapPhpFunction (   $callable)

Wrap a PHP callable as a Lua function, which can be passed back into Lua.

If an error occurs, a Scribunto_LuaError will be thrown.

Parameters
callable$callableThe PHP callable
Returns
object a Lua function

Reimplemented from Scribunto_LuaInterpreter.

Definition at line 330 of file Engine.php.

Member Data Documentation

◆ $engine

Scribunto_LuaEngine Scribunto_LuaSandboxInterpreter::$engine

Definition at line 219 of file Engine.php.

Referenced by __construct().

◆ $profilerEnabled

bool Scribunto_LuaSandboxInterpreter::$profilerEnabled

Definition at line 229 of file Engine.php.

◆ $sandbox

LuaSandbox Scribunto_LuaSandboxInterpreter::$sandbox

Definition at line 224 of file Engine.php.

◆ PERCENT

const Scribunto_LuaSandboxInterpreter::PERCENT = 2

Definition at line 233 of file Engine.php.

Referenced by Scribunto_LuaSandboxEngine\getLimitReportData().

◆ SAMPLES

const Scribunto_LuaSandboxInterpreter::SAMPLES = 0

Definition at line 231 of file Engine.php.

◆ SECONDS

const Scribunto_LuaSandboxInterpreter::SECONDS = 1

Definition at line 232 of file Engine.php.

Referenced by Scribunto_LuaSandboxEngine\getLimitReportData().


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