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

Public Member Functions

 __construct ( $engine, array $options)
 
 __destruct ()
 
 callFunction ( $func,... $args)
 Call a Lua function. More...
 
 cleanupLuaChunks ()
 
 getStatus ()
 
 isLuaFunction ( $object)
 Test whether an object is a Lua function. More...
 
 loadString ( $text, $chunkName)
 
 pauseUsageTimer ()
 Pause CPU usage and limits. More...
 
 quit ()
 
 registerLibrary ( $name, array $functions)
 Register a library of functions. More...
 
 terminate ()
 
 testquit ()
 
 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 getLuaVersion (array $options)
 

Public Attributes

bool $enableDebug
 
Scribunto_LuaStandaloneEngine $engine
 
ScribuntoException $exitError
 
int $id
 
resource bool $proc
 
resource $readPipe
 
resource $writePipe
 

Protected Member Functions

 callback ( $id, array $args)
 
 checkValid ()
 
 debug ( $msg)
 
 decodeHeader ( $header)
 
 dispatch ( $msgToLua)
 
 encodeLuaVar ( $var, $level=0)
 
 encodeMessage ( $message)
 
 handleCall ( $message)
 
 handleError ( $message)
 
 handleIOError ()
 
 receiveMessage ()
 
 sendMessage ( $msg)
 

Protected Attributes

callable[] $callbacks
 
LoggerInterface $logger
 

Static Protected Attributes

static $nextInterpreterId = 0
 

Static Private Member Functions

static fixNulls (array $array, $count)
 Fill in missing nulls in a list received from Lua. More...
 

Detailed Description

Definition at line 120 of file LuaStandaloneEngine.php.

Constructor & Destructor Documentation

◆ __construct()

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

◆ __destruct()

Scribunto_LuaStandaloneInterpreter::__destruct ( )

Definition at line 283 of file LuaStandaloneEngine.php.

References terminate().

Member Function Documentation

◆ callback()

Scribunto_LuaStandaloneInterpreter::callback (   $id,
array  $args 
)
protected

Definition at line 478 of file LuaStandaloneEngine.php.

References $id.

Referenced by handleCall().

◆ callFunction()

Scribunto_LuaStandaloneInterpreter::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 358 of file LuaStandaloneEngine.php.

References $args, cleanupLuaChunks(), and dispatch().

◆ checkValid()

Scribunto_LuaStandaloneInterpreter::checkValid ( )
protected
Exceptions
ScribuntoException

Definition at line 665 of file LuaStandaloneEngine.php.

References $exitError.

Referenced by handleIOError(), receiveMessage(), and sendMessage().

◆ cleanupLuaChunks()

Scribunto_LuaStandaloneInterpreter::cleanupLuaChunks ( )

◆ debug()

Scribunto_LuaStandaloneInterpreter::debug (   $msg)
protected

Definition at line 723 of file LuaStandaloneEngine.php.

Referenced by receiveMessage(), and sendMessage().

◆ decodeHeader()

Scribunto_LuaStandaloneInterpreter::decodeHeader (   $header)
protected

Definition at line 648 of file LuaStandaloneEngine.php.

References $header.

Referenced by receiveMessage().

◆ dispatch()

Scribunto_LuaStandaloneInterpreter::dispatch (   $msgToLua)
protected

◆ encodeLuaVar()

Scribunto_LuaStandaloneInterpreter::encodeLuaVar (   $var,
  $level = 0 
)
protected
Parameters
mixed$var
int$level
Returns
string
Exceptions
MWException

Definition at line 577 of file LuaStandaloneEngine.php.

References $s, and $type.

Referenced by encodeMessage().

◆ encodeMessage()

Scribunto_LuaStandaloneInterpreter::encodeMessage (   $message)
protected

Definition at line 562 of file LuaStandaloneEngine.php.

References $serialized, and encodeLuaVar().

Referenced by sendMessage().

◆ fixNulls()

static Scribunto_LuaStandaloneInterpreter::fixNulls ( array  $array,
  $count 
)
staticprivate

Fill in missing nulls in a list received from Lua.

Parameters
array$arrayList received from Lua
int$countNumber of values that should be in the list
Returns
array Non-sparse array

Definition at line 445 of file LuaStandaloneEngine.php.

Referenced by dispatch(), and handleCall().

◆ getLuaVersion()

static Scribunto_LuaStandaloneInterpreter::getLuaVersion ( array  $options)
static

◆ getStatus()

Scribunto_LuaStandaloneInterpreter::getStatus ( )

Definition at line 425 of file LuaStandaloneEngine.php.

References dispatch().

◆ handleCall()

Scribunto_LuaStandaloneInterpreter::handleCall (   $message)
protected

Definition at line 453 of file LuaStandaloneEngine.php.

References callback(), fixNulls(), and Scribunto_LuaError\getLuaMessage().

Referenced by dispatch().

◆ handleError()

Scribunto_LuaStandaloneInterpreter::handleError (   $message)
protected

Definition at line 482 of file LuaStandaloneEngine.php.

Referenced by dispatch().

◆ handleIOError()

Scribunto_LuaStandaloneInterpreter::handleIOError ( )
protected
Exceptions
ScribuntoException

Definition at line 679 of file LuaStandaloneEngine.php.

References $exitError, $status, and checkValid().

Referenced by receiveMessage(), and sendMessage().

◆ isLuaFunction()

Scribunto_LuaStandaloneInterpreter::isLuaFunction (   $object)

Test whether an object is a Lua function.

Parameters
object$object
Returns
bool

Reimplemented from Scribunto_LuaInterpreter.

Definition at line 402 of file LuaStandaloneEngine.php.

◆ loadString()

Scribunto_LuaStandaloneInterpreter::loadString (   $text,
  $chunkName 
)
Parameters
string$text
string$chunkName
Returns
Scribunto_LuaStandaloneInterpreterFunction

Reimplemented from Scribunto_LuaInterpreter.

Definition at line 347 of file LuaStandaloneEngine.php.

References cleanupLuaChunks(), and dispatch().

◆ pauseUsageTimer()

Scribunto_LuaStandaloneInterpreter::pauseUsageTimer ( )

Pause CPU usage and limits.

Returns
void

Reimplemented from Scribunto_LuaInterpreter.

Definition at line 432 of file LuaStandaloneEngine.php.

◆ quit()

Scribunto_LuaStandaloneInterpreter::quit ( )

Definition at line 326 of file LuaStandaloneEngine.php.

References dispatch().

◆ receiveMessage()

Scribunto_LuaStandaloneInterpreter::receiveMessage ( )
protected

Definition at line 530 of file LuaStandaloneEngine.php.

References $header, checkValid(), debug(), decodeHeader(), handleIOError(), and unserialize().

Referenced by dispatch().

◆ registerLibrary()

Scribunto_LuaStandaloneInterpreter::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 406 of file LuaStandaloneEngine.php.

References $id, and dispatch().

◆ sendMessage()

Scribunto_LuaStandaloneInterpreter::sendMessage (   $msg)
protected

Definition at line 517 of file LuaStandaloneEngine.php.

References checkValid(), debug(), encodeMessage(), and handleIOError().

Referenced by dispatch().

◆ terminate()

Scribunto_LuaStandaloneInterpreter::terminate ( )

Definition at line 317 of file LuaStandaloneEngine.php.

Referenced by __destruct().

◆ testquit()

Scribunto_LuaStandaloneInterpreter::testquit ( )

Definition at line 334 of file LuaStandaloneEngine.php.

References dispatch().

◆ unpauseUsageTimer()

Scribunto_LuaStandaloneInterpreter::unpauseUsageTimer ( )

Unpause CPU usage and limits.

Returns
void

Reimplemented from Scribunto_LuaInterpreter.

Definition at line 435 of file LuaStandaloneEngine.php.

◆ wrapPhpFunction()

Scribunto_LuaStandaloneInterpreter::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 381 of file LuaStandaloneEngine.php.

References $id, and dispatch().

Member Data Documentation

◆ $callbacks

callable [] Scribunto_LuaStandaloneInterpreter::$callbacks
protected

Definition at line 166 of file LuaStandaloneEngine.php.

◆ $enableDebug

bool Scribunto_LuaStandaloneInterpreter::$enableDebug

Definition at line 131 of file LuaStandaloneEngine.php.

◆ $engine

Scribunto_LuaStandaloneEngine Scribunto_LuaStandaloneInterpreter::$engine

Definition at line 126 of file LuaStandaloneEngine.php.

Referenced by __construct().

◆ $exitError

ScribuntoException Scribunto_LuaStandaloneInterpreter::$exitError

Definition at line 151 of file LuaStandaloneEngine.php.

Referenced by checkValid(), and handleIOError().

◆ $id

int Scribunto_LuaStandaloneInterpreter::$id

Definition at line 156 of file LuaStandaloneEngine.php.

Referenced by callback(), registerLibrary(), and wrapPhpFunction().

◆ $logger

LoggerInterface Scribunto_LuaStandaloneInterpreter::$logger
protected

Definition at line 161 of file LuaStandaloneEngine.php.

◆ $nextInterpreterId

Scribunto_LuaStandaloneInterpreter::$nextInterpreterId = 0
staticprotected

Definition at line 121 of file LuaStandaloneEngine.php.

◆ $proc

resource bool Scribunto_LuaStandaloneInterpreter::$proc

Definition at line 136 of file LuaStandaloneEngine.php.

◆ $readPipe

resource Scribunto_LuaStandaloneInterpreter::$readPipe

Definition at line 146 of file LuaStandaloneEngine.php.

◆ $writePipe

resource Scribunto_LuaStandaloneInterpreter::$writePipe

Definition at line 141 of file LuaStandaloneEngine.php.


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