Revision: 3389 http://vexi.svn.sourceforge.net/vexi/?rev=3389&view=rev Author: mkpg2 Date: 2009-02-16 03:34:13 +0000 (Mon, 16 Feb 2009)
Log Message: ----------- Minor changes to proxylist, add indexOf(), fix delete. Modified Paths: -------------- trunk/core/org.ibex.js/src/org/ibex/js/JS.jpp trunk/core/org.ibex.js/src_junit/test/js/exec/traps/range/readProxylist.js trunk/core/org.ibex.js/src_junit/test/js/exec/traps/range/writeProxylist.js Modified: trunk/core/org.ibex.js/src/org/ibex/js/JS.jpp =================================================================== --- trunk/core/org.ibex.js/src/org/ibex/js/JS.jpp 2009-02-15 21:36:58 UTC (rev 3388) +++ trunk/core/org.ibex.js/src/org/ibex/js/JS.jpp 2009-02-16 03:34:13 UTC (rev 3389) @@ -440,6 +440,7 @@ if (key == null || !JSU.isInt(key)) { String strkey = JSU.toString(key); if("length".equals(strkey)){ return JSU.N(bt.treeSize()); } + if("indexOf".equals(strkey)){ return METHOD; } throw new JSExn("Attempt to get unrecognized string key '"+strkey+"' from a proxylist"); } @@ -487,7 +488,9 @@ int i = JSU.toInt(key); if (i < 0) throw new JSExn("Attempt to put to negative key '"+i+" on a proxylist"); - bt.insertNode(i, value); + if(value!=null) bt.insertNode(i, value); + else bt.deleteNode(i); + } catch (JSExn e) { rangeTrapException = e; throw e; @@ -497,7 +500,19 @@ } } } - + + final private int[] INDEXOF_ARGS = new int[]{JSU.ANY}; + public JS callMethod(JS this_, JS method, JS[] args) throws JSExn { + String methodStr = JSU.toString(method); + if("indexOf".equals(methodStr)){ + JSU.checkArgs(args, INDEXOF_ARGS); + int r = bt.indexNode(args[0]); + if(r==-1) return null; + return JSU.N(r); + } + return super.callMethod(this_, method, args); + } + /** Places the given function as a trap on the given key, first validating the function. */ public void addTrap(JS key, JS f) throws JSExn { if (!SC_Elements.equals(key)) { Modified: trunk/core/org.ibex.js/src_junit/test/js/exec/traps/range/readProxylist.js =================================================================== --- trunk/core/org.ibex.js/src_junit/test/js/exec/traps/range/readProxylist.js 2009-02-15 21:36:58 UTC (rev 3388) +++ trunk/core/org.ibex.js/src_junit/test/js/exec/traps/range/readProxylist.js 2009-02-16 03:34:13 UTC (rev 3389) @@ -14,3 +14,6 @@ assertEquals("b_", proxy[0]); assertEquals("a_", proxy[1]); + +assertEquals(0, proxy.indexOf("a")); +assertEquals(1, proxy.indexOf("b")); Modified: trunk/core/org.ibex.js/src_junit/test/js/exec/traps/range/writeProxylist.js =================================================================== --- trunk/core/org.ibex.js/src_junit/test/js/exec/traps/range/writeProxylist.js 2009-02-15 21:36:58 UTC (rev 3388) +++ trunk/core/org.ibex.js/src_junit/test/js/exec/traps/range/writeProxylist.js 2009-02-16 03:34:13 UTC (rev 3389) @@ -3,14 +3,15 @@ var proxy = sys.proxylist; proxy.Elements ++= function(v){ sys.trace(trapname); - var tn = trapname; - if(tn==1) trapname = 0; - cascade = v+"_"; + if(v) cascade = v+"_"; + else cascade = null; }; proxy[0] = "a"; proxy[1] = "b"; +assertEquals("a_", proxy[0]); +assertEquals("b_", proxy[1]); +proxy[0] = null; +assertEquals("1", proxy.length); assertEquals("b_", proxy[0]); -assertEquals("a_", proxy[1]); - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn