MediaWiki
1.34.4
|
This class provides some basic services that Lua libraries will probably need. More...
Public Member Functions | |
__construct (Scribunto_LuaEngine $engine) | |
incrementExpensiveFunctionCount () | |
Increment the expensive function count, and throw if limit exceeded. More... | |
register () | |
Called to register the library. More... | |
Protected Member Functions | |
checkType ( $name, $argIdx, $arg, $expectType) | |
Check the type of a variable. More... | |
checkTypeOptional ( $name, $argIdx, &$arg, $expectType, $default) | |
Check the type of a variable, with default if null. More... | |
getEngine () | |
Get the engine. More... | |
getInterpreter () | |
Get the interpreter. More... | |
getLuaType ( $var) | |
Get the Lua type corresponding to the type of the variable. More... | |
getParser () | |
Get the parser. More... | |
getParserOptions () | |
Get the parser options. More... | |
getTitle () | |
Get the title. More... | |
Private Attributes | |
Scribunto_LuaEngine | $engine |
This class provides some basic services that Lua libraries will probably need.
Definition at line 27 of file LibraryBase.php.
Scribunto_LuaLibraryBase::__construct | ( | Scribunto_LuaEngine | $engine | ) |
Scribunto_LuaEngine | $engine |
Definition at line 36 of file LibraryBase.php.
References $engine.
|
protected |
Check the type of a variable.
If the type of the variable does not match the expected type, a Scribunto_LuaError will be thrown.
string | $name | Name of the calling function (as seen from Lua) |
int | $argIdx | Index of the argument being tested (1-based) |
mixed | $arg | Variable to test |
string | $expectType | Lua type expected |
Definition at line 141 of file LibraryBase.php.
References $type, and getLuaType().
Referenced by Scribunto_LuaTitleLibrary\cascadingProtection(), Scribunto_LuaTitleLibrary\checkNamespace(), Scribunto_LuaUstringLibrary\checkPattern(), Scribunto_LuaUstringLibrary\checkString(), checkTypeOptional(), Scribunto_LuaLanguageLibrary\convertGrammar(), Scribunto_LuaLanguageLibrary\convertPlural(), MediaWiki\Extensions\ParserFunctions\LuaLibrary\expr(), Scribunto_LuaLanguageLibrary\fetchLanguageName(), Scribunto_LuaLanguageLibrary\formatDate(), Scribunto_LuaLanguageLibrary\formatDuration(), Scribunto_LuaLanguageLibrary\formatNum(), Scribunto_LuaLanguageLibrary\gender(), Scribunto_LuaTitleLibrary\getContent(), Scribunto_LuaLanguageLibrary\getDurationIntervals(), Scribunto_LuaTitleLibrary\getExpensiveData(), Scribunto_LuaLanguageLibrary\getFallbacksFor(), Scribunto_LuaTitleLibrary\getFileInfo(), Scribunto_LuaSiteLibrary\getNsIndex(), Scribunto_LuaTitleLibrary\getUrl(), Scribunto_LuaLanguageLibrary\isKnownLanguageTag(), Scribunto_LuaLanguageLibrary\isSupportedLanguage(), Scribunto_LuaLanguageLibrary\isValidBuiltInCode(), Scribunto_LuaLanguageLibrary\isValidCode(), Scribunto_LuaTextLibrary\jsonDecode(), Scribunto_LuaTextLibrary\killMarkers(), Scribunto_LuaLanguageLibrary\languageMethod(), Scribunto_LuaTitleLibrary\makeTitle(), Scribunto_LuaTitleLibrary\newTitle(), Scribunto_LuaSiteLibrary\pagesInCategory(), Scribunto_LuaSiteLibrary\pagesInNamespace(), Scribunto_LuaTitleLibrary\protectionLevels(), Scribunto_LuaTitleLibrary\redirectTarget(), Scribunto_LuaTitleBlacklistLibrary\test(), Scribunto_LuaTextLibrary\textUnstrip(), Scribunto_LuaTextLibrary\textUnstripNoWiki(), Scribunto_LuaSiteLibrary\usersInGroup(), Scribunto_LuaUstringLibrary\ustringChar(), and Scribunto_LuaUstringLibrary\ustringGsub().
|
protected |
Check the type of a variable, with default if null.
If the variable is null, $default will be assigned. Otherwise, if the type of the variable does not match the expected type, a Scribunto_LuaError will be thrown.
string | $name | Name of the calling function (as seen from Lua) |
int | $argIdx | Index of the argument being tested (1-based) |
mixed | &$arg | Variable to test/set |
string | $expectType | Lua type expected |
mixed | $default | Default value |
Definition at line 164 of file LibraryBase.php.
References checkType().
Referenced by Scribunto_LuaLanguageLibrary\fetchLanguageName(), Scribunto_LuaLanguageLibrary\fetchLanguageNames(), Scribunto_LuaLanguageLibrary\formatDate(), Scribunto_LuaLanguageLibrary\formatDuration(), Scribunto_LuaLanguageLibrary\getDurationIntervals(), Scribunto_LuaTitleLibrary\getUrl(), Scribunto_LuaSiteLibrary\interwikiMap(), Scribunto_LuaTextLibrary\jsonDecode(), Scribunto_LuaTextLibrary\jsonEncode(), Scribunto_LuaTitleLibrary\makeTitle(), Scribunto_LuaSiteLibrary\pagesInCategory(), Scribunto_LuaTitleBlacklistLibrary\test(), Scribunto_LuaUstringLibrary\ustringByteoffset(), Scribunto_LuaUstringLibrary\ustringCodepoint(), Scribunto_LuaUstringLibrary\ustringFind(), Scribunto_LuaUstringLibrary\ustringGsub(), Scribunto_LuaUstringLibrary\ustringMatch(), and Scribunto_LuaUstringLibrary\ustringSub().
|
protected |
Get the engine.
Definition at line 56 of file LibraryBase.php.
References $engine.
Referenced by Scribunto_LuaLanguageLibrary\formatDate(), getTitle(), incrementExpensiveFunctionCount(), Scribunto_LuaHtmlLibrary\register(), Scribunto_LuaMessageLibrary\register(), Scribunto_LuaUriLibrary\register(), Scribunto_LuaTitleBlacklistLibrary\register(), Scribunto_LuaHashLibrary\register(), MediaWiki\Extensions\ParserFunctions\LuaLibrary\register(), Scribunto_LuaTextLibrary\register(), Scribunto_LuaLanguageLibrary\register(), Scribunto_LuaTitleLibrary\register(), Scribunto_LuaSiteLibrary\register(), Scribunto_LuaUstringLibrary\register(), and Scribunto_LuaCommonTestsLibrary\register().
|
protected |
Get the interpreter.
Definition at line 65 of file LibraryBase.php.
Referenced by getLuaType(), and Scribunto_LuaUstringLibrary\ustringGsub().
|
protected |
Get the Lua type corresponding to the type of the variable.
If the variable does not correspond to any type, the PHP type will be returned (prefixed with "PHP"). For example, "PHP resource" or "PHP object of class Foo".
mixed | $var | Variable to test |
Definition at line 106 of file LibraryBase.php.
References $type, and getInterpreter().
Referenced by Scribunto_LuaUstringLibrary\checkPattern(), Scribunto_LuaUstringLibrary\checkString(), checkType(), Scribunto_LuaLanguageLibrary\languageMethod(), Scribunto_LuaTitleLibrary\newTitle(), and Scribunto_LuaUstringLibrary\ustringGsub().
|
protected |
Get the parser.
Definition at line 74 of file LibraryBase.php.
Referenced by Scribunto_LuaUriLibrary\anchorEncode(), Scribunto_LuaTitleLibrary\getContentInternal(), Scribunto_LuaTitleLibrary\getExpensiveData(), Scribunto_LuaTitleLibrary\getFileInfo(), Scribunto_LuaTitleLibrary\getInexpensiveTitleData(), Scribunto_LuaTextLibrary\killMarkers(), Scribunto_LuaTitleLibrary\newTitle(), Scribunto_LuaMessageLibrary\register(), Scribunto_LuaSiteLibrary\register(), Scribunto_LuaTitleBlacklistLibrary\test(), Scribunto_LuaTextLibrary\textUnstrip(), and Scribunto_LuaTextLibrary\textUnstripNoWiki().
|
protected |
Get the parser options.
Definition at line 92 of file LibraryBase.php.
Referenced by Scribunto_LuaLanguageLibrary\formatDate(), and Scribunto_LuaLanguageLibrary\gender().
|
protected |
Get the title.
Definition at line 83 of file LibraryBase.php.
References getEngine().
Referenced by Scribunto_LuaTitleLibrary\getInexpensiveTitleData(), Scribunto_LuaUriLibrary\register(), and Scribunto_LuaTitleLibrary\register().
Scribunto_LuaLibraryBase::incrementExpensiveFunctionCount | ( | ) |
Increment the expensive function count, and throw if limit exceeded.
Definition at line 177 of file LibraryBase.php.
References getEngine().
Referenced by Scribunto_LuaTitleLibrary\cascadingProtection(), Scribunto_LuaTitleLibrary\getExpensiveData(), Scribunto_LuaTitleLibrary\getFileInfo(), Scribunto_LuaTitleLibrary\newTitle(), Scribunto_LuaSiteLibrary\pagesInCategory(), Scribunto_LuaTitleLibrary\protectionLevels(), and Scribunto_LuaTitleBlacklistLibrary\test().
|
abstract |
Called to register the library.
This should do any necessary setup and then call $this->getEngine()->registerInterface(). The value returned by that call should be returned from this function, and must be for 'deferLoad' libraries to work right.
Reimplemented in Scribunto_LuaCommonTestsFailLibrary, Scribunto_LuaCommonTestsLibrary, Scribunto_LuaUstringLibrary, Scribunto_LuaSiteLibrary, Scribunto_LuaTitleLibrary, Scribunto_LuaLanguageLibrary, MediaWiki\Extensions\ParserFunctions\LuaLibrary, Scribunto_LuaTextLibrary, Scribunto_LuaHashLibrary, Scribunto_LuaHtmlLibrary, Scribunto_LuaMessageLibrary, Scribunto_LuaUriLibrary, and Scribunto_LuaTitleBlacklistLibrary.
|
private |
Definition at line 31 of file LibraryBase.php.
Referenced by Scribunto_LuaUstringLibrary\__construct(), __construct(), and getEngine().