37 $this->engine = $engine;
49 abstract public function register();
66 return $this->engine->getInterpreter();
75 return $this->engine->getParser();
93 return $this->engine->getParser()->getOptions();
109 'double' =>
'number',
110 'integer' =>
'number',
111 'string' =>
'string',
112 'boolean' =>
'boolean',
115 $type = gettype( $var );
116 if ( isset( $luaTypes[
$type] ) ) {
117 return $luaTypes[
$type];
122 if ( is_object( $var ) ) {
123 $type .=
" of class " . get_class( $var );
141 protected function checkType( $name, $argIdx, $arg, $expectType ) {
143 if (
$type !== $expectType ) {
145 "bad argument #$argIdx to '$name' ($expectType expected, got $type)"
165 if ( $arg ===
null ) {
168 $this->
checkType( $name, $argIdx, $arg, $expectType );
178 return $this->
getEngine()->incrementExpensiveFunctionCount();
This class provides some basic services that Lua libraries will probably need.
getLuaType( $var)
Get the Lua type corresponding to the type of the variable.
getInterpreter()
Get the interpreter.
__construct(Scribunto_LuaEngine $engine)
checkType( $name, $argIdx, $arg, $expectType)
Check the type of a variable.
Scribunto_LuaEngine $engine
getEngine()
Get the engine.
checkTypeOptional( $name, $argIdx, &$arg, $expectType, $default)
Check the type of a variable, with default if null.
getParser()
Get the parser.
incrementExpensiveFunctionCount()
Increment the expensive function count, and throw if limit exceeded.
getParserOptions()
Get the parser options.