2012-04-13 10:38:12 +00:00
|
|
|
<?php
|
|
|
|
|
2016-05-17 14:52:05 +00:00
|
|
|
// @codingStandardsIgnoreLine Squiz.Classes.ValidClassName.NotCamelCaps
|
2012-04-13 10:38:12 +00:00
|
|
|
abstract class Scribunto_LuaInterpreter {
|
|
|
|
/**
|
|
|
|
* Load a string. Return an object which can later be passed to callFunction.
|
|
|
|
* If there is a pass error, a Scribunto_LuaError will be thrown.
|
|
|
|
*
|
2014-10-09 19:49:40 +00:00
|
|
|
* @param string $text The Lua source code
|
|
|
|
* @param string $chunkName The chunk name
|
2017-09-24 17:38:14 +00:00
|
|
|
* @return mixed
|
2012-04-13 10:38:12 +00:00
|
|
|
*/
|
|
|
|
abstract public function loadString( $text, $chunkName );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Call a Lua function. Return an array of results, with indices starting
|
|
|
|
* at zero. If an error occurs, a Scribunto_LuaError will be thrown.
|
|
|
|
*
|
2014-10-09 19:49:40 +00:00
|
|
|
* @param mixed $func The function object
|
2012-04-13 10:38:12 +00:00
|
|
|
*/
|
|
|
|
abstract public function callFunction( $func /*...*/ );
|
|
|
|
|
2012-12-13 20:50:44 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
2014-10-09 19:49:40 +00:00
|
|
|
* @param callable $callable The PHP callable
|
2012-12-13 20:50:44 +00:00
|
|
|
* @return a Lua function
|
|
|
|
*/
|
|
|
|
abstract public function wrapPhpFunction( $callable );
|
|
|
|
|
2012-12-24 14:45:16 +00:00
|
|
|
/**
|
|
|
|
* Test whether an object is a Lua function.
|
|
|
|
*
|
2017-09-24 17:38:14 +00:00
|
|
|
* @param object $object
|
2012-12-24 14:45:16 +00:00
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
abstract public function isLuaFunction( $object );
|
|
|
|
|
2012-04-13 10:38:12 +00:00
|
|
|
/**
|
|
|
|
* Register a library of functions.
|
|
|
|
*
|
2017-09-24 17:38:14 +00:00
|
|
|
* @param string $name The global variable name to be created or added to.
|
|
|
|
* @param array $functions An associative array mapping the function name to the
|
2012-04-13 10:38:12 +00:00
|
|
|
* callback. The callback may throw a Scribunto_LuaError, which will be
|
2014-07-07 18:46:59 +00:00
|
|
|
* caught and raised in the Lua code as a Lua error, catchable with
|
|
|
|
* pcall().
|
2012-04-13 10:38:12 +00:00
|
|
|
*/
|
2014-10-10 09:02:03 +00:00
|
|
|
abstract public function registerLibrary( $name, array $functions );
|
2013-03-06 23:28:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Pause CPU usage and limits
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
abstract public function pauseUsageTimer();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unpause CPU usage and limits
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
abstract public function unpauseUsageTimer();
|
2012-04-13 10:38:12 +00:00
|
|
|
}
|
|
|
|
|
2016-05-17 14:52:05 +00:00
|
|
|
// @codingStandardsIgnoreLine Squiz.Classes.ValidClassName.NotCamelCaps
|
2012-04-19 07:40:56 +00:00
|
|
|
class Scribunto_LuaInterpreterNotFoundError extends MWException {}
|
2016-10-13 15:07:44 +00:00
|
|
|
|
|
|
|
// @codingStandardsIgnoreLine Squiz.Classes.ValidClassName.NotCamelCaps
|
|
|
|
class Scribunto_LuaInterpreterBadVersionError extends MWException {}
|