mediawiki-extensions-Scribunto/engines/LuaCommon/LuaInterpreter.php
tstarling b68cae904a More tests and some related bug fixes
* Added tests for the engine classes.
* Added some tests that run under Lua.
* In the chunk names, fixed truncation of module names at 60 bytes
  by using an "=" prefix instead of @.
* Fixed a bug in mw.clone() which was causing the metatable to be set on
  the source table instead of the destination.
* Put restricted setfenv/getfenv in the cloned environment rather than
  the base environment, they work better that way.
* In setfenv(), check for getfenv() == nil, since that's what our own
  restricted getfenv returns.
* Fixed getfenv() handling of numeric arguments: add one where
  appropriate.

Change-Id: I2b356fd65a3fcb348c4e99a3a4267408fb995739
2012-04-19 17:48:20 +10:00

34 lines
1.1 KiB
PHP

<?php
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.
*
* @param $text The Lua source code
* @param $chunkName The chunk name
*/
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.
*
* @param $func The function object
*/
abstract public function callFunction( $func /*...*/ );
/**
* Register a library of functions.
*
* @param $name The global variable name to be created or added to.
* @param $functions An 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().
*/
abstract public function registerLibrary( $name, $functions );
}
class Scribunto_LuaInterpreterNotFoundError extends MWException {}