Revision: 4195 http://vexi.svn.sourceforge.net/vexi/?rev=4195&view=rev Author: clrg Date: 2011-07-22 10:15:08 +0000 (Fri, 22 Jul 2011)
Log Message: ----------- Feature: Box.contains(b) Modified Paths: -------------- trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp trunk/org.vexi-core.main/src/test/java/test/core/box/methods.t Modified: trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp =================================================================== --- trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp 2011-07-22 02:31:03 UTC (rev 4194) +++ trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp 2011-07-22 10:15:08 UTC (rev 4195) @@ -1,4 +1,4 @@ -// Copyright 2000-2008 the Contributors, as shown in the revision logs. +// Copyright 2000-2011 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. @@ -1695,6 +1695,15 @@ assertMethodRedirect(method); clear(args[0]); return null; + case "contains": + try { + for (Box b = (Box)args[0]; b.parent!=null; b = b.parent) + if (b.parent == this) + return JSU.T; + } catch (ClassCastException cce) { + throw new JSExn("Cannot call Box."+method+"() with non-box argument"); + } + return JSU.F; case "distanceto": try { return new DistanceTo(this, (Box)args[0]); @@ -1979,12 +1988,17 @@ } return redirect == this ? METHOD : redirect.getAndTriggerTraps(SC_add); - /* <p>Clear a box of its children. It is the equivalent of the following vexiscript:</p> + /* <p>Clear a box of its children. When called with no arguments, all children are cleared, + * and it is the equivalent of the following vexiscript:</p> * * <pre> while (box.numchildren) box[0] = null;</pre> * + * <p>When one index is supplied, it clears all children from that index, inclusive of the + * index. If a 2nd index is supplied, it clears up to but not including the 2nd index.</p> + * * @method - * @param() + * @param(name=from,optional=true) + * @param(name=to,optional=true) * @return(null) * */ case "clear": @@ -1993,6 +2007,15 @@ } return redirect == this ? METHOD : redirect.getAndTriggerTraps(SC_clear); + /* <p>Determines whether the argument box is a descendent of the subject box.</p> + * + * @method + * @param(box) + * @return(Boolean) + */ + case "contains": + return METHOD; + /* <p>Returns the index of box <em>b</em> within the subject box. If box <em>b</em> is not * an immediate child of the box, or an immediate child of the box's redirect, then the * function returns -1.</p> Modified: trunk/org.vexi-core.main/src/test/java/test/core/box/methods.t =================================================================== --- trunk/org.vexi-core.main/src/test/java/test/core/box/methods.t 2011-07-22 02:31:03 UTC (rev 4194) +++ trunk/org.vexi-core.main/src/test/java/test/core/box/methods.t 2011-07-22 10:15:08 UTC (rev 4195) @@ -50,5 +50,22 @@ assertEq(a.indexof(b3), 1); a.clear(); + var c1 = box; + var c2 = box; + var c3 = box; + a.add(c1); + a.add(box); + c1.add(box); + c1.add(c2); + c1.add(c3); + assertEq(a.contains(c1), true); + assertEq(a.contains(c2), true); + assertEq(c1.contains(c2), true); + assertEq(c1.contains(c3), true); + assertEq(c1.contains(c1), false); + assertEq(c1.contains(a), false); + assertEq(c2.contains(a), false); + a.clear(); + <ui:box /> </vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ 10 Tips for Better Web Security Learn 10 ways to better secure your business today. Topics covered include: Web security, SSL, hacker attacks & Denial of Service (DoS), private keys, security Microsoft Exchange, secure Instant Messaging, and much more. http://www.accelacomm.com/jaw/sfnl/114/51426210/ _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn