mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-12 01:11:55 +00:00
Add Scribunto_LuaInterpreter::isLuaFunction method
Add a method to LuaInterpreter to determine whether an object is a wrapped Lua function. Change-Id: I20bf16948db025372d68cc89bf5ddcbf617db864
This commit is contained in:
parent
374972c924
commit
114f5c13ec
|
@ -27,6 +27,14 @@ abstract class Scribunto_LuaInterpreter {
|
|||
*/
|
||||
abstract public function wrapPhpFunction( $callable );
|
||||
|
||||
/**
|
||||
* Test whether an object is a Lua function.
|
||||
*
|
||||
* @param $object
|
||||
* @return boolean
|
||||
*/
|
||||
abstract public function isLuaFunction( $object );
|
||||
|
||||
/**
|
||||
* Register a library of functions.
|
||||
*
|
||||
|
|
|
@ -159,6 +159,10 @@ class Scribunto_LuaSandboxInterpreter extends Scribunto_LuaInterpreter {
|
|||
return $func;
|
||||
}
|
||||
|
||||
public function isLuaFunction( $object ) {
|
||||
return $object instanceof LuaSandboxFunction;
|
||||
}
|
||||
|
||||
public function getPeakMemoryUsage() {
|
||||
return $this->sandbox->getPeakMemoryUsage();
|
||||
}
|
||||
|
|
|
@ -189,6 +189,10 @@ class Scribunto_LuaStandaloneInterpreter extends Scribunto_LuaInterpreter {
|
|||
return $ret[1];
|
||||
}
|
||||
|
||||
public function isLuaFunction( $object ) {
|
||||
return $object instanceof Scribunto_LuaStandaloneInterpreterFunction;
|
||||
}
|
||||
|
||||
public function registerLibrary( $name, $functions ) {
|
||||
$functionIds = array();
|
||||
foreach ( $functions as $funcName => $callback ) {
|
||||
|
|
Loading…
Reference in a new issue