* Reduced stack depth by using an internal stack in expand(), and by having some common code paths (e.g. non-subst double-brace during PST) return objects which can be expanded in that internal stack instead of the PHP stack. This is friendly to xdebug but slightly slower than the original version. Also it probably helps robustness when you don't add 7 stack levels per pair of double braces. * Profiling indicates that expand and PPD are now good targets for porting to C. Abstracted and refactored the relevant code to allow for a drop-in replacement. A factor of 2 reduction in average-case replaceVariables() time may be possible. * Verified with preprocessorFuzzTest.php against r29950, updated to allow better PST tests. * Made parserTests.php respect $wgParserConf * LST and ParserFunctions need a simultaneous update with the core due to changed interfaces. DOM objects are now wrapped rather than directly exposed.
74 lines
1.4 KiB
PHP
74 lines
1.4 KiB
PHP
<?php
|
|
|
|
interface Preprocessor {
|
|
function __construct( $parser );
|
|
function newFrame();
|
|
function preprocessToObj( $text, $flags = 0 );
|
|
}
|
|
|
|
interface PPFrame {
|
|
const NO_ARGS = 1;
|
|
const NO_TEMPLATES = 2;
|
|
const STRIP_COMMENTS = 4;
|
|
const NO_IGNORE = 8;
|
|
|
|
const RECOVER_ORIG = 11;
|
|
|
|
/**
|
|
* Create a child frame
|
|
*/
|
|
function newChild( $args = false, $title = false );
|
|
|
|
/**
|
|
* Expand a document tree node
|
|
*/
|
|
function expand( $root, $flags = 0 );
|
|
|
|
/**
|
|
* Implode with flags for expand()
|
|
*/
|
|
function implodeWithFlags( $sep, $flags /*, ... */ );
|
|
|
|
/**
|
|
* Implode with no flags specified
|
|
*/
|
|
function implode( $sep /*, ... */ );
|
|
|
|
/**
|
|
* Makes an object that, when expand()ed, will be the same as one obtained
|
|
* with implode()
|
|
*/
|
|
function virtualImplode( $sep /*, ... */ );
|
|
|
|
/**
|
|
* Virtual implode with brackets
|
|
*/
|
|
function virtualBracketedImplode( $start, $sep, $end /*, ... */ );
|
|
|
|
/**
|
|
* Returns true if there are no arguments in this frame
|
|
*/
|
|
function isEmpty();
|
|
|
|
function getArgument( $name );
|
|
|
|
/**
|
|
* Returns true if the infinite loop check is OK, false if a loop is detected
|
|
*/
|
|
function loopCheck( $title );
|
|
}
|
|
|
|
interface PPNode {
|
|
function getChildren();
|
|
function getFirstChild();
|
|
function getNextSibling();
|
|
function getChildrenOfType( $type );
|
|
function getLength();
|
|
function item( $i );
|
|
function getName();
|
|
|
|
function splitArg();
|
|
function splitExt();
|
|
function splitHeading();
|
|
}
|
|
|