1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +00:00

XomwTemplateParser: Port other XomwPPTemplateFrame classes [#632]

This commit is contained in:
gnosygnu 2020-04-03 06:39:35 -04:00
parent 9809dfd6c7
commit 17d7a7ebed
16 changed files with 291 additions and 260 deletions

View File

@ -20,6 +20,7 @@ import gplx.core.brys.*;
public class XophpArray implements Bry_bfr_able { public class XophpArray implements Bry_bfr_able {
private final Ordered_hash hash = Ordered_hash_.New(); private final Ordered_hash hash = Ordered_hash_.New();
private int nxt_idx; private int nxt_idx;
public int Len() {return hash.Len();}
public int count() {return hash.Len();} public int count() {return hash.Len();}
public boolean count_bool() {return hash.Len() > 0;} public boolean count_bool() {return hash.Len() > 0;}
public boolean isset(String key) {return hash.Has(key);} public boolean isset(String key) {return hash.Has(key);}

View File

@ -16,12 +16,14 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*; package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
import gplx.core.brys.*; import gplx.core.brys.*;
public class XophpArrayItm implements Bry_bfr_able { public class XophpArrayItm implements Bry_bfr_able {
XophpArrayItm(boolean key_is_int, String key, Object val) { XophpArrayItm(boolean key_is_int, int key_as_int, String key, Object val) {
this.key_is_int = key_is_int; this.key_is_int = key_is_int;
this.key_as_int = key_as_int;
this.key = key; this.key = key;
this.val = val; this.val = val;
} }
public boolean Key_is_int() {return key_is_int;} private final boolean key_is_int; public boolean Key_is_int() {return key_is_int;} private final boolean key_is_int;
public int Key_as_int() {return key_as_int;} private final int key_as_int;
public String Key() {return key;} private final String key; public String Key() {return key;} private final String key;
public Object Val() {return val;} public void Val_(Object v) {this.val = v;} private Object val; public Object Val() {return val;} public void Val_(Object v) {this.val = v;} private Object val;
@ -38,6 +40,6 @@ public class XophpArrayItm implements Bry_bfr_able {
} }
} }
public static XophpArrayItm New_int(int key, Object val) {return new XophpArrayItm(Bool_.Y, Int_.To_str(key), val);} public static XophpArrayItm New_int(int key, Object val) {return new XophpArrayItm(Bool_.Y, key, Int_.To_str(key), val);}
public static XophpArrayItm New_str(String key, Object val) {return new XophpArrayItm(Bool_.N, key , val);} public static XophpArrayItm New_str(String key, Object val) {return new XophpArrayItm(Bool_.N, -1, key , val);}
} }

View File

@ -203,4 +203,8 @@ public class XophpArray_ {
} }
return sb.To_str_and_clear(); return sb.To_str_and_clear();
} }
public static int count(XophpArray array) {
return array.count();
}
} }

View File

@ -15,6 +15,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*; package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
public class XophpInt_ { public class XophpInt_ {
public static final int False = 0; // REF.PHP:https://www.php.net/manual/en/language.types.boolean.php
public static boolean is_true(int val) {return val != -1;} // handles code like "if ($var === false)" where var is an Object; public static boolean is_true(int val) {return val != -1;} // handles code like "if ($var === false)" where var is an Object;
public static String strval(int number) { public static String strval(int number) {
return Int_.To_str(number); return Int_.To_str(number);

View File

@ -45,4 +45,10 @@ public class XophpType_ {
public static boolean is_string(Object o) { public static boolean is_string(Object o) {
return To_type_id(o) == Type_ids_.Id__str; return To_type_id(o) == Type_ids_.Id__str;
} }
public static boolean is_array(Object o) {
return Type_.Eq_by_obj(o, XophpArray.class);
}
public static boolean instance_of(Object o, Class<?> t) {
return Type_.Eq_by_obj(o, t);
}
} }

View File

@ -4129,13 +4129,13 @@ public class XomwDefaultSettings {
// * Maximum indent level of toc. // * Maximum indent level of toc.
// */ // */
// $wgMaxTocLevel = 999; // $wgMaxTocLevel = 999;
//
// /** /**
// * A complexity limit on template expansion: the maximum number of nodes visited * A complexity limit on template expansion: the maximum number of nodes visited
// * by PPFrame::expand() * by PPFrame::expand()
// */ */
// $wgMaxPPNodeCount = 1000000; public static int wgMaxPPNodeCount = 1000000;
//
// /** // /**
// * A complexity limit on template expansion: the maximum number of elements // * A complexity limit on template expansion: the maximum number of elements
// * generated by Preprocessor::preprocessToObj(). This allows you to limit the // * generated by Preprocessor::preprocessToObj(). This allows you to limit the
@ -4154,12 +4154,12 @@ public class XomwDefaultSettings {
// * stop the parser before it hits the xdebug limit. // * stop the parser before it hits the xdebug limit.
// */ // */
// $wgMaxTemplateDepth = 40; // $wgMaxTemplateDepth = 40;
//
// /** /**
// * @see $wgMaxTemplateDepth * @see $wgMaxTemplateDepth
// */ */
// $wgMaxPPExpandDepth = 40; public static int wgMaxPPExpandDepth = 40;
//
// /** // /**
// * URL schemes that should be recognized as valid by wfParseUrl(). // * URL schemes that should be recognized as valid by wfParseUrl().
// * // *

View File

@ -21,4 +21,7 @@ public class XomwMWException extends Err {
public static Err New_by_method(Class<?> type, String method, String msg) { public static Err New_by_method(Class<?> type, String method, String msg) {
return Err_.new_wo_type(Type_.Name(type) + "." + method + ":" + msg); return Err_.new_wo_type(Type_.Name(type) + "." + method + ":" + msg);
} }
public static Err New_by_method_obj(Object obj, String method, String msg) {
return Err_.new_wo_type(Type_.Name_by_obj(obj) + "." + method + msg);
}
} }

View File

@ -192,7 +192,7 @@ public class XomwParser implements XomwParserIface {
private int mLinkID; private int mLinkID;
public int mIncludeSizes, mPPNodeCount, mGeneratedPPNodeCount, mHighestExpansionDepth; public int mIncludeSizes, mPPNodeCount, mGeneratedPPNodeCount, mHighestExpansionDepth;
// public mDefaultSort; // public mDefaultSort;
// public mTplRedirCache, mTplDomCache, mHeadings, mDoubleUnderscores; public XophpArray mTplRedirCache = null, mTplDomCache = null, mHeadings = null, mDoubleUnderscores = null;
// public mExpensiveFunctionCount; // number of expensive parser function calls // public mExpensiveFunctionCount; // number of expensive parser function calls
// public mShowToc, mForceTocPosition; // public mShowToc, mForceTocPosition;
// //
@ -441,7 +441,7 @@ public class XomwParser implements XomwParserIface {
// this.mGeneratedPPNodeCount = 0; // this.mGeneratedPPNodeCount = 0;
// this.mHighestExpansionDepth = 0; // this.mHighestExpansionDepth = 0;
// this.mDefaultSort = false; // this.mDefaultSort = false;
// this.mHeadings = []; this.mHeadings = XophpArray.New();
// this.mDoubleUnderscores = []; // this.mDoubleUnderscores = [];
// this.mExpensiveFunctionCount = 0; // this.mExpensiveFunctionCount = 0;
// //

View File

@ -74,21 +74,21 @@ public class XomwParserOptions {
*/ */
private int mMaxIncludeSize; private int mMaxIncludeSize;
// /** /**
// * Maximum number of nodes touched by PPFrame::expand() * Maximum number of nodes touched by PPFrame::expand()
// */ */
// private $mMaxPPNodeCount; private int mMaxPPNodeCount;
//
// /** // /**
// * Maximum number of nodes generated by Preprocessor::preprocessToObj() // * Maximum number of nodes generated by Preprocessor::preprocessToObj()
// */ // */
// private $mMaxGeneratedPPNodeCount; // private $mMaxGeneratedPPNodeCount;
//
// /** /**
// * Maximum recursion depth in PPFrame::expand() * Maximum recursion depth in PPFrame::expand()
// */ */
// private $mMaxPPExpandDepth; private int mMaxPPExpandDepth;
//
// /** // /**
// * Maximum recursion depth for templates within templates // * Maximum recursion depth for templates within templates
// */ // */
@ -276,18 +276,18 @@ public class XomwParserOptions {
return this.mMaxIncludeSize; return this.mMaxIncludeSize;
} }
// public function getMaxPPNodeCount() { public int getMaxPPNodeCount() {
// return this.mMaxPPNodeCount; return this.mMaxPPNodeCount;
// } }
//
// public function getMaxGeneratedPPNodeCount() { // public function getMaxGeneratedPPNodeCount() {
// return this.mMaxGeneratedPPNodeCount; // return this.mMaxGeneratedPPNodeCount;
// } // }
//
// public function getMaxPPExpandDepth() { public int getMaxPPExpandDepth() {
// return this.mMaxPPExpandDepth; return this.mMaxPPExpandDepth;
// } }
//
// public function getMaxTemplateDepth() { // public function getMaxTemplateDepth() {
// return this.mMaxTemplateDepth; // return this.mMaxTemplateDepth;
// } // }
@ -703,9 +703,9 @@ public class XomwParserOptions {
// this.mEnableImageWhitelist = $wgEnableImageWhitelist; // this.mEnableImageWhitelist = $wgEnableImageWhitelist;
// this.mAllowSpecialInclusion = $wgAllowSpecialInclusion; // this.mAllowSpecialInclusion = $wgAllowSpecialInclusion;
this.mMaxIncludeSize = XomwDefaultSettings.wgMaxArticleSize * 1024; this.mMaxIncludeSize = XomwDefaultSettings.wgMaxArticleSize * 1024;
// this.mMaxPPNodeCount = $wgMaxPPNodeCount; this.mMaxPPNodeCount = XomwDefaultSettings.wgMaxPPNodeCount;
// this.mMaxGeneratedPPNodeCount = $wgMaxGeneratedPPNodeCount; // this.mMaxGeneratedPPNodeCount = $wgMaxGeneratedPPNodeCount;
// this.mMaxPPExpandDepth = $wgMaxPPExpandDepth; this.mMaxPPExpandDepth = XomwDefaultSettings.wgMaxPPExpandDepth;
// this.mMaxTemplateDepth = $wgMaxTemplateDepth; // this.mMaxTemplateDepth = $wgMaxTemplateDepth;
// this.mExpensiveParserFunctionLimit = $wgExpensiveParserFunctionLimit; // this.mExpensiveParserFunctionLimit = $wgExpensiveParserFunctionLimit;
// this.mCleanSignatures = $wgCleanSignatures; // this.mCleanSignatures = $wgCleanSignatures;

View File

@ -65,6 +65,7 @@ public class XomwStripState {
this.addItem(TYPE_NOWIKI, marker, val); this.addItem(TYPE_NOWIKI, marker, val);
} }
public void addGeneral(String marker, String val) {this.addGeneral(Bry_.new_u8(marker), Bry_.new_u8(val));}
/** /**
* @param String $marker * @param String $marker
* @param String $value * @param String $value

View File

@ -112,7 +112,7 @@ class XomwPPFrame_Hash extends XomwPPFrame { /**
// this.parser.addTrackingCategory('duplicate-args-category'); // this.parser.addTrackingCategory('duplicate-args-category');
} }
numberedArgs.Set(index, bits.Get_by("value")); numberedArgs.Set(index, bits.Get_by("value"));
// XophpArray_.unset_by_idx(namedArgs, index); namedArgs.unset(index);
} else { } else {
// Named parameter // Named parameter
String name = String_.Trim(this.expand(bits.Get_by("name"), XomwPPFrame.STRIP_COMMENTS)); String name = String_.Trim(this.expand(bits.Get_by("name"), XomwPPFrame.STRIP_COMMENTS));
@ -123,13 +123,12 @@ class XomwPPFrame_Hash extends XomwPPFrame { /**
// wfEscapeWikiText(name)).text()); // wfEscapeWikiText(name)).text());
// this.parser.addTrackingCategory('duplicate-args-category'); // this.parser.addTrackingCategory('duplicate-args-category');
} }
// namedArgs.Set(name, bits.Get_by("value")); namedArgs.Set(name, bits.Get_by("value"));
// XophpArray_.unset(numberedArgs, name); numberedArgs.unset(name);
} }
} }
} }
// return new PPTemplateFrame_Hash(this.preprocessor, this, numberedArgs, namedArgs, title); return new XomwPPTemplateFrame_Hash(this.preprocessor, this, numberedArgs, namedArgs, title);
return null;
} }
/** /**
@ -157,20 +156,20 @@ class XomwPPFrame_Hash extends XomwPPFrame { /**
return (String)root; return (String)root;
} }
// if (++this.parser.mPPNodeCount > this.parser.mOptions.getMaxPPNodeCount()) { if (++this.parser.mPPNodeCount > this.parser.mOptions.getMaxPPNodeCount()) {
// this.parser.limitationWarn('node-count-exceeded', // this.parser.limitationWarn('node-count-exceeded',
// this.parser.mPPNodeCount, // this.parser.mPPNodeCount,
// this.parser.mOptions.getMaxPPNodeCount() // this.parser.mOptions.getMaxPPNodeCount()
// ); // );
// return '<span class="error">Node-count limit exceeded</span>'; return "<span class=\"error\">Node-count limit exceeded</span>";
// } }
// if (expansionDepth > this.parser.mOptions.getMaxPPExpandDepth()) { if (expansionDepth > this.parser.mOptions.getMaxPPExpandDepth()) {
// this.parser.limitationWarn('expansion-depth-exceeded', // this.parser.limitationWarn('expansion-depth-exceeded',
// expansionDepth, // expansionDepth,
// this.parser.mOptions.getMaxPPExpandDepth() // this.parser.mOptions.getMaxPPExpandDepth()
// ); // );
// return '<span class="error">Expansion depth limit exceeded</span>'; return "<span class=\"error\">Expansion depth limit exceeded</span>";
// } }
++expansionDepth; ++expansionDepth;
if (expansionDepth > this.parser.mHighestExpansionDepth) { if (expansionDepth > this.parser.mHighestExpansionDepth) {
this.parser.mHighestExpansionDepth = expansionDepth; this.parser.mHighestExpansionDepth = expansionDepth;
@ -342,12 +341,12 @@ class XomwPPFrame_Hash extends XomwPPFrame { /**
// Expand immediately and insert heading index marker // Expand immediately and insert heading index marker
String s = this.expand(contextChildren, flags); String s = this.expand(contextChildren, flags);
XophpArray bits = XomwPPNode_Hash_Tree.splitRawHeading(contextChildren); XophpArray bits = XomwPPNode_Hash_Tree.splitRawHeading(contextChildren);
// String titleText = this.title.getPrefixedDBkey(); String titleText = this.title.getPrefixedDBkeyStr();
// this.parser.mHeadings[] = [titleText, bits['i']]; this.parser.mHeadings.Add(titleText, bits.Get_by("i"));
// serial = count(this.parser.mHeadings) - 1; int serial = XophpArray_.count(this.parser.mHeadings) - 1;
String marker = XomwParser.MARKER_PREFIX + "-h-serial-" + XomwParser.MARKER_SUFFIX; String marker = XomwParser.MARKER_PREFIX + "-h-" + Int_.To_str(serial) + "-" + XomwParser.MARKER_SUFFIX;
s = XophpString_.substr(s, 0, bits.Get_by_int("level")) + marker + XophpString_.substr(s, bits.Get_by_int("level")); s = XophpString_.substr(s, 0, bits.Get_by_int("level")) + marker + XophpString_.substr(s, bits.Get_by_int("level"));
// this.parser.mStripState.addGeneral(marker, ''); this.parser.mStripState.addGeneral(marker, "");
outItm += s; outItm += s;
} else { } else {
// Expand in virtual stack // Expand in virtual stack
@ -384,29 +383,34 @@ class XomwPPFrame_Hash extends XomwPPFrame { /**
* @param String|PPNode $args,... * @param String|PPNode $args,...
* @return String * @return String
*/ */
// public function implodeWithFlags($sep, $flags /*, ... */) { public String implodeWithFlags(String sep, int flags, XophpArray args) {
// $args = array_slice(func_get_args(), 2); // args = XophpArray_.array_slice(func_get_args(), 2);
//
// $first = true; boolean first = true;
// $s = ''; String s = "";
// foreach ($args as $root) { int len = args.Len();
// if ($root instanceof PPNode_Hash_Array) { for (int i = 0; i < len; i++) {
// $root = $root.value; Object root_obj = args.Get_at(i);
// } XophpArray root = null;
// if (!is_array($root)) { if (XophpType_.instance_of(root_obj, XomwPPNode_Hash_Array.class)) {
// $root = [$root]; root = (XophpArray)((XomwPPNode_Hash_Array)root_obj).value;
// } }
// foreach ($root as $node) { if (!XophpType_.is_array(root_obj)) {
// if ($first) { root = XophpArray.New().Add(root_obj);
// $first = false; }
// } else { int root_len = root.Len();
// $s .= $sep; for (int j = 0; j < root_len; j++) {
// } XomwPPNode node = (XomwPPNode)root.Get_at(j);
// $s .= this.expand($node, $flags); if (first) {
// } first = false;
// } } else {
// return $s; s += sep;
// } }
s += this.expand(node, flags);
}
}
return s;
}
/** /**
* Implode with no flags specified * Implode with no flags specified
@ -510,10 +514,10 @@ class XomwPPFrame_Hash extends XomwPPFrame { /**
return new XomwPPNode_Hash_Array(outItm); return new XomwPPNode_Hash_Array(outItm);
} }
// public function __toString() { @Override public String toString() {
// return 'frame{}'; return "frame{}";
// } }
//
/** /**
* @param boolean $level * @param boolean $level
* @return array|boolean|String * @return array|boolean|String

View File

@ -34,7 +34,7 @@ public abstract class XomwPPNode {
* Returns false if this is not a tree node. * Returns false if this is not a tree node.
* @return PPNode * @return PPNode
*/ */
// public abstract XomwPPNode[] getChildren(); public abstract XomwPPNode_Hash_Array getChildren();
/** /**
* Get the first child of a tree node. False if there isn't one. * Get the first child of a tree node. False if there isn't one.
@ -55,19 +55,19 @@ public abstract class XomwPPNode {
* @param String $type * @param String $type
* @return boolean|PPNode * @return boolean|PPNode
*/ */
// public abstract XomwPPNode getChildrenOfType(String type); public abstract XomwPPNode_Hash_Array getChildrenOfType(String type);
/** /**
* Returns the length of the array, or false if this is not an array-type node * Returns the length of the array, or false if this is not an array-type node
*/ */
// public abstract int getLength(); public abstract int getLength();
/** /**
* Returns an item of an array-type node * Returns an item of an array-type node
* @param int $i * @param int $i
* @return boolean|PPNode * @return boolean|PPNode
*/ */
// public abstract XomwPPNode item(int i); public abstract XomwPPNode item(int i);
/** /**
* Get the name of this node. The following names are defined here: * Get the name of this node. The following names are defined here:
@ -91,20 +91,20 @@ public abstract class XomwPPNode {
* value PPNode value * value PPNode value
* @return array * @return array
*/ */
@gplx.Virtual public XophpArray splitArg() {return null;} public abstract XophpArray splitArg();
/** /**
* Split an "<ext>" node into an associative array containing name, attr, inner and close * Split an "<ext>" node into an associative array containing name, attr, inner and close
* All values in the resulting array are PPNodes. Inner and close are optional. * All values in the resulting array are PPNodes. Inner and close are optional.
* @return array * @return array
*/ */
// public abstract Hash_adp splitExt(); public abstract XophpArray splitExt();
/** /**
* Split an "<h>" node * Split an "<h>" node
* @return array * @return array
*/ */
// public abstract Hash_adp splitHeading(); public abstract XophpArray splitHeading();
public abstract String toString(); public abstract String toString();
} }

View File

@ -14,6 +14,7 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*; package gplx.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.xowa.mediawiki.includes.exception.*;
// MW.FILE:Preprocessor_Hash // MW.FILE:Preprocessor_Hash
/** /**
* @ingroup Parser * @ingroup Parser
@ -25,18 +26,16 @@ public class XomwPPNode_Hash_Array extends XomwPPNode { public XophpArray value
} }
@Override public String toString() { @Override public String toString() {
// return var_export( $this, true ); // return var_export($this, true);
return null; return value.To_str();
} }
public int getLength() { @Override public int getLength() {
return -1; return XophpArray_.count(this.value);
// return count( this.value );
} }
public Object item(int i) { @Override public XomwPPNode item(int i) {
return null; return (XomwPPNode)this.value.Get_at(i);
// return this.value[$i];
} }
@Override public String getName() { @Override public String getName() {
@ -47,27 +46,27 @@ public class XomwPPNode_Hash_Array extends XomwPPNode { public XophpArray value
return null; return null;
} }
// public function getChildren() { @Override public XomwPPNode_Hash_Array getChildren() {
// return false; return null;
// } }
@Override public XomwPPNode getFirstChild() { @Override public XomwPPNode getFirstChild() {
return null; return null;
} }
// public function getChildrenOfType( $name ) { @Override public XomwPPNode_Hash_Array getChildrenOfType(String name) {
// return false; return null;
// } }
//
// public function splitArg() { @Override public XophpArray splitArg() {
// throw new MWException( __METHOD__ . ': not supported' ); throw XomwMWException.New_by_method_obj(this, "splitArg", ": not supported");
// } }
//
// public function splitExt() { @Override public XophpArray splitExt() {
// throw new MWException( __METHOD__ . ': not supported' ); throw XomwMWException.New_by_method_obj(this, "splitExt", ": not supported");
// } }
//
// public function splitHeading() { @Override public XophpArray splitHeading() {
// throw new MWException( __METHOD__ . ': not supported' ); throw XomwMWException.New_by_method_obj(this, "splitHeading", ": not supported");
// } }
} }

View File

@ -14,6 +14,7 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*; package gplx.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.xowa.mediawiki.includes.exception.*;
// MW.FILE:Preprocessor_Hash // MW.FILE:Preprocessor_Hash
/** /**
* @ingroup Parser * @ingroup Parser
@ -55,35 +56,35 @@ public class XomwPPNode_Hash_Attr extends XomwPPNode { public String name, valu
return XomwPPNode_Hash_Tree.factory(this.store, this.index + 1); return XomwPPNode_Hash_Tree.factory(this.store, this.index + 1);
} }
// public function getChildren() { @Override public XomwPPNode_Hash_Array getChildren() {
// return false; return null;
// } }
//
@Override public XomwPPNode getFirstChild() { @Override public XomwPPNode getFirstChild() {
return null; return null;
} }
// public function getChildrenOfType($name) { @Override public XomwPPNode_Hash_Array getChildrenOfType(String name) {
// return false; return null;
// } }
//
// public function getLength() { @Override public int getLength() {
// return false; return XophpInt_.False;
// } }
//
// public function item($i) { @Override public XomwPPNode item(int i) {
// return false; return null;
// } }
//
// public function splitArg() { @Override public XophpArray splitArg() {
// throw new MWException(__METHOD__ . ': not supported'); throw XomwMWException.New_by_method_obj(this, "splitArg", ": not supported");
// } }
//
// public function splitExt() { @Override public XophpArray splitExt() {
// throw new MWException(__METHOD__ . ': not supported'); throw XomwMWException.New_by_method_obj(this, "splitExt", ": not supported");
// } }
//
// public function splitHeading() { @Override public XophpArray splitHeading() {
// throw new MWException(__METHOD__ . ': not supported'); throw XomwMWException.New_by_method_obj(this, "splitHeading", ": not supported");
// } }
} }

View File

@ -48,39 +48,39 @@ public class XomwPPNode_Hash_Text extends XomwPPNode { public String value;
return XomwPPNode_Hash_Tree.factory(this.store, this.index + 1); return XomwPPNode_Hash_Tree.factory(this.store, this.index + 1);
} }
// public function getChildren() { @Override public XomwPPNode_Hash_Array getChildren() {
// return false; return null;
// } }
@Override public XomwPPNode getFirstChild() { @Override public XomwPPNode getFirstChild() {
return null; return null;
} }
// public function getChildrenOfType($name) { @Override public XomwPPNode_Hash_Array getChildrenOfType(String name) {
// return false; return null;
// } }
//
// public function getLength() { @Override public int getLength() {
// return false; return XophpInt_.False;
// } }
//
// public function item($i) { @Override public XomwPPNode item(int i) {
// return false; return null;
// } }
@Override public String getName() { @Override public String getName() {
return "#text"; return "#text";
} }
// public function splitArg() { @Override public XophpArray splitArg() {
// throw new MWException(__METHOD__ . ': not supported'); throw XomwMWException.New_by_method_obj(this, "splitArg", ": not supported");
// } }
//
// public function splitExt() { @Override public XophpArray splitExt() {
// throw new MWException(__METHOD__ . ': not supported'); throw XomwMWException.New_by_method_obj(this, "splitExt", ": not supported");
// } }
//
// public function splitHeading() { @Override public XophpArray splitHeading() {
// throw new MWException(__METHOD__ . ': not supported'); throw XomwMWException.New_by_method_obj(this, "splitHeading", ": not supported");
// } }
} }

View File

@ -133,13 +133,14 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
/** /**
* @return PPNode_Hash_Array * @return PPNode_Hash_Array
*/ */
public XomwPPNode_Hash_Array getChildren() { @Override public XomwPPNode_Hash_Array getChildren() {
// children = []; XophpArray children = XophpArray.New();
// foreach (this.rawChildren as i => child) { int rawChildrenLen = rawChildren.Len();
// children[] = self::factory(this.rawChildren, i); for (int i = 0; i < rawChildrenLen; i++) {
// } XophpArrayItm itm = rawChildren.Get_at_itm(i);
// return new PPNode_Hash_Array(children); children.Add(XomwPPNode_Hash_Tree.factory(this.rawChildren, itm.Key_as_int()));
return null; }
return new XomwPPNode_Hash_Array(children);
} }
/** /**
@ -169,45 +170,47 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
return factory(this.store, this.index + 1); return factory(this.store, this.index + 1);
} }
// /** /**
// * Get an array of the children with a given node name * Get an array of the children with a given node name
// * *
// * @param String name * @param String name
// * @return PPNode_Hash_Array * @return PPNode_Hash_Array
// */ */
// public function getChildrenOfType(name) { @Override public XomwPPNode_Hash_Array getChildrenOfType(String name) {
// children = []; XophpArray children = XophpArray.New();
// foreach (this.rawChildren as i => child) { int rawChildren_len = this.rawChildren.Len();
// if (is_array(child) && child[self::NAME] === name) { for (int idx = 0; idx < rawChildren_len; idx++) {
// children[] = self::factory(this.rawChildren, i); XophpArrayItm itm = this.rawChildren.Get_at_itm(idx);
// } Object child = itm.Val();
// } if (XophpType_.is_array(child) && String_.Eq(((XophpArray)child).Get_at_str(XomwPPNode_Hash_Tree.NAME), name)) {
// return new PPNode_Hash_Array(children); children.Add(XomwPPNode_Hash_Tree.factory(this.rawChildren, itm.Key_as_int()));
// } }
}
return new XomwPPNode_Hash_Array(children);
}
/** /**
* Get the raw child array. For @gplx.Internal protected use. * Get the raw child array. For @gplx.Internal protected use.
* @return array * @return array
*/ */
public XophpArray getRawChildren() { public XophpArray getRawChildren() {
// return this.rawChildren; return this.rawChildren;
return null;
} }
// /** /**
// * @return boolean * @return boolean
// */ */
// public function getLength() { @Override public int getLength() {
// return false; return XophpInt_.False;
// } }
//
// /** /**
// * @param int i * @param int i
// * @return boolean * @return boolean
// */ */
// public function item(i) { @Override public XomwPPNode item(int i) {
// return false; return null;
// } }
/** /**
* @return String * @return String
@ -216,59 +219,65 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
return this.name; return this.name;
} }
// /** /**
// * Split a "<part>" node into an associative array containing: * Split a "<part>" node into an associative array containing:
// * - name PPNode name * - name PPNode name
// * - index String index * - index String index
// * - value PPNode value * - value PPNode value
// * *
// * @throws MWException * @throws MWException
// * @return array * @return array
// */ */
// public function splitArg() { @Override public XophpArray splitArg() {
// return self::splitRawArg(this.rawChildren); return XomwPPNode_Hash_Tree.splitRawArg(this.rawChildren);
// } }
//
// /** /**
// * Like splitArg() but for a raw child array. For @gplx.Internal protected use only. * Like splitArg() but for a raw child array. For @gplx.Internal protected use only.
// */ */
// public static function splitRawArg(array children) { public static XophpArray splitRawArg(XophpArray children) {
// bits = []; XophpArray bits = XophpArray.New();
// foreach (children as i => child) { int childrenLen = children.Len();
// if (!is_array(child)) { for (int j = 0; j < childrenLen; j++) {
// continue; XophpArrayItm itm = children.Get_at_itm(j);
// } Object childObj = itm.Val();
// if (child[self::NAME] === 'name') { if (!XophpType_.is_array(childObj)) {
// bits['name'] = new self(children, i); continue;
// if (isset(child[self::CHILDREN][0][self::NAME]) }
// && child[self::CHILDREN][0][self::NAME] === '@index' XophpArray child = (XophpArray)childObj;
// ) { int i = itm.Key_as_int();
// bits['index'] = child[self::CHILDREN][0][self::CHILDREN][0]; if (String_.Eq(child.Get_at_str(XomwPPNode_Hash_Tree.NAME), "name")) {
// } bits.Set("name", new XomwPPNode_Hash_Tree(children, i));
// } elseif (child[self::NAME] === 'value') { if (XophpObject_.isset_obj(child.Get_at_ary(XomwPPNode_Hash_Tree.CHILDREN).Get_at_ary(0).Get_at(XomwPPNode_Hash_Tree.NAME))
// bits['value'] = new self(children, i); && String_.Eq(child.Get_at_ary(XomwPPNode_Hash_Tree.CHILDREN).Get_at_ary(0).Get_at_str(XomwPPNode_Hash_Tree.NAME), "@index")
// } ) {
// } bits.Set("index", child.Get_at_ary(XomwPPNode_Hash_Tree.CHILDREN).Get_at_ary(0).Get_at_ary(XomwPPNode_Hash_Tree.CHILDREN).Get_at(0));
// }
// if (!isset(bits['name'])) { }
// throw new MWException('Invalid brace node passed to ' . __METHOD__); else if (String_.Eq(child.Get_at_str(XomwPPNode_Hash_Tree.NAME), "value")) {
// } bits.Set("value", new XomwPPNode_Hash_Tree(children, i));
// if (!isset(bits['index'])) { }
// bits['index'] = ""; }
// }
// return bits; if (!XophpObject_.isset_obj(bits.Get_by("name"))) {
// } throw XomwMWException.New_by_method(XomwPPNode_Hash_Tree.class, "splitRawArg", "Invalid brace node passed to " + "splitRawArg");
// }
// /** if (!XophpObject_.isset_obj(bits.Get_by("index"))) {
// * Split an "<ext>" node into an associative array containing name, attr, inner and close bits.Set("index", "");
// * All values in the resulting array are PPNodes. Inner and close are optional. }
// * return bits;
// * @throws MWException }
// * @return array
// */ /**
// public function splitExt() { * Split an "<ext>" node into an associative array containing name, attr, inner and close
// return self::splitRawExt(this.rawChildren); * All values in the resulting array are PPNodes. Inner and close are optional.
// } *
* @throws MWException
* @return array
*/
@Override public XophpArray splitExt() {
return XomwPPNode_Hash_Tree.splitRawExt(this.rawChildren);
}
/** /**
* Like splitExt() but for a raw child array. For @gplx.Internal protected use only. * Like splitExt() but for a raw child array. For @gplx.Internal protected use only.
@ -308,7 +317,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
* @throws MWException * @throws MWException
* @return array * @return array
*/ */
public XophpArray splitHeading() { @Override public XophpArray splitHeading() {
if (!String_.Eq(this.name, "h")) { if (!String_.Eq(this.name, "h")) {
throw new XomwMWException("Invalid h node passed to " + "splitHeading"); throw new XomwMWException("Invalid h node passed to " + "splitHeading");
} }