Revision: 3999 http://vexi.svn.sourceforge.net/vexi/?rev=3999&view=rev Author: clrg Date: 2011-01-25 00:46:21 +0000 (Tue, 25 Jan 2011)
Log Message: ----------- More jsdoc work Modified Paths: -------------- trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSNumber.java trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSArray.jpp trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSPrimitive.jpp Modified: trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSNumber.java =================================================================== --- trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSNumber.java 2011-01-25 00:21:11 UTC (rev 3998) +++ trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSNumber.java 2011-01-25 00:46:21 UTC (rev 3999) @@ -5,7 +5,7 @@ package org.ibex.js; public abstract class JSNumber extends JSPrimitive { - static public JS Constructor = new JS.Constructor("Number"); + static public JS Constructor = new JS.Constructor("Number"); public boolean equals(Object o) { if (o == this) { return true; @@ -78,7 +78,7 @@ } final static public class B extends JSNumber { - static public JS Constructor = new JS.Constructor("Boolean"); + static public JS Constructor = new JS.Constructor("Boolean"); private final boolean b; B(boolean b) { this.b = b; } int toInt() { return b ? 1 : 0; } @@ -91,8 +91,30 @@ * * <p>A simple <code>true</code> or <code>false</code> value.</p> * - * <p>A boolean is a <a href="Primitive.html">Primitive</a>.</p> - * + * <p>A boolean is a primitive, so all <a href="vexi.js.String.html">string</a> functions are valid.</p> + * + * <p>The following values equate to <b><code>false</code></b> when used in boolean operations:<p> + * + * <ul><li><code>null</code></li> + * <li><code>0</code></li> + * <li><code>""</code></li></ul> + * + * <p>The following values equate to <b><code>true</code></b> when used in boolean operations:<p> + * + * <ul><li>Any non-<code>null</code> object</li> + * <li>Any non-<code>0</code> number</li> + * <li>Any non-empty string</li></ul> + * + * <p>Consider:</p> + * + * <pre> 0 == false; + * "0" == true; + * 1 == true; + * -1 == true; + * null == false; + * "null" == true; + * {} == true;</pre> + * * */ //#end return super.get(key); Modified: trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSArray.jpp =================================================================== --- trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSArray.jpp 2011-01-25 00:21:11 UTC (rev 3998) +++ trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSArray.jpp 2011-01-25 00:46:21 UTC (rev 3999) @@ -10,13 +10,13 @@ /** A JavaScript array implementation */ public class JSArray extends Basket.Array implements Basket.CompareFunc, Constants, JSArrayLike, JS.Copyable { - static public JS Constructor = new JS.Constructor("Array"){ - public JS new_(JS[] args) throws JSExn { - if(args.length==1) new JSArray((int)JSU.toLong(args[0])); - return new JSArray(args); - } - }; - + static public JS Constructor = new JS.Constructor("Array") { + public JS new_(JS[] args) throws JSExn { + if (args.length==1) new JSArray((int)JSU.toLong(args[0])); + return new JSArray(args); + } + }; + public JSArray() { } public JSArray(int size) { super(size); } public JSArray(JS[] args) { super(args.length); addAll(args); } @@ -37,58 +37,58 @@ * <p>Arrays can be created as literals in vexiscript using <code>[]</code> which * creates a new empty array.</p> * - * <p>Arrays can be initialized with contents in vexiscript using <code>[i1, i2,... in]</code>. + * <p>Arrays can be initialized with contents in vexiscript using <code>[i1, i2,... in]</code>.</p> * */ - /* Returns a new array containing the elements from the array object followed by the - * elements from each of the arguments. - * - * @param(name=a,varargs=true) - * @return(Array) - * */ - case "concat": return METHOD; - - /* Returns a shallow copy of the array. - * - * @return(Array) - * */ - case "copy": return METHOD; - - /* <p>Returns the array's values concatenated into a single string, with each value - * separated by the separator string.</p> - * - * <p>If separator is omitted, then it defaults to "," as the separator string.</p> - * - * @param(name=separator,optional=true) - * @return(String) - * */ - case "join": return METHOD; - - /* The length of an array. - * - * @type(Number) - * */ - case "length": return JSU.N(size()); - - /* Removes the last element of the array and returns it. - * If the array is currently empty, then it returns null. + /* Returns a new array containing the elements from the array object followed by the + * elements from each of the arguments. * + * @param(name=a,varargs=true) + * @return(Array) + * */ + case "concat": return METHOD; + + /* Returns a shallow copy of the array. + * + * @return(Array) + * */ + case "copy": return METHOD; + + /* <p>Returns the array's values concatenated into a single string, with each value + * separated by the separator string.</p> + * + * <p>If ‘separator’ is omitted, then it defaults to "," as the separator string.</p> + * + * @param(name=separator,optional=true) + * @return(String) + * */ + case "join": return METHOD; + + /* The length of an array. + * + * @type(Number) + * */ + case "length": return JSU.N(size()); + + /* <p>Removes the last element of the array and returns it. + * If the array is currently empty, then it returns null.</p> + * * @return(<i>varies</i>) * */ - case "pop": return METHOD; - - /* Adds the specified values to the end of the current array - * and returns the new size of the array. - * - * @param(name=v,varargs=true) - * @return(Number) - * */ - case "push": return METHOD; - - /* Reverses the order of the elements in the current array and returns the array. - * - * @return(Array) - * */ + case "pop": return METHOD; + + /* Adds the specified values to the end of the current array + * and returns the new size of the array. + * + * @param(name=v,varargs=true) + * @return(Number) + * */ + case "push": return METHOD; + + /* Reverses the order of the elements in the current array and returns the array. + * + * @return(Array) + * */ case "reverse": return METHOD; /* Removes the first element of the array and returns it. If the array is currently @@ -99,12 +99,12 @@ case "shift": return METHOD; /* <p>Returns a new array which contains a copy of the section of the current array - * between start and end - 1, inclusive.</p> + * between ‘start’ and ‘end - 1’, inclusive.</p> * * <p>If either argument is less than 0, then the argument is treated as the number of - * slots counted backwards from the end of the array. If start is omitted, it defaults - * to the start of the array; if end is omitted, it defaults to the array's length. If - * start is greater than end, the function returns an empty array.</p> + * slots counted backwards from the end of the array. If ‘start’ is omitted, it defaults + * to the start of the array; if ‘end’ is omitted, it defaults to the array's length. If + * ‘start’ is greater than ‘end’, the function returns an empty array.</p> * * @param(name=start,optional=true) * @param(name=end,optional=true) @@ -114,8 +114,8 @@ /* <p>Sorts the contents of the current array and returns it.</p> * - * <p>If compareFunction is specified, then the given comparison function (which must - * take 2 arguments) will be used to do the sorting. If compareFunction is omitted, + * <p>If ‘compareFunction’ is specified, then the given comparison function (which must + * take 2 arguments) will be used to do the sorting. If ‘compareFunction’ is omitted, * then the values will be sorted alphabetically by their string values.</p> * * @param(name=compareFunction,optional=true) @@ -123,19 +123,19 @@ * */ case "sort": return METHOD; - /* <p>Removes the array elements from start to start + deleteCount from the array, + /* <p>Removes the array elements from ‘start’ to ‘start + deleteCount’ from the array, * and replaces them with the specified values. Returns a new array containing the * deleted values.<p> * - * <p>If start is less than 0, then the argument is treated as the number of slots - * counted backwards from the end of the array. If start is omitted, it defaults to - * the start of the array; if deleteCount is omitted, it defaults to 0. If no values + * <p>If ‘start’ is less than 0, then the argument is treated as the number of slots + * counted backwards from the end of the array. If ‘start’ is omitted, it defaults to + * the start of the array; if ‘deleteCount’ is omitted, it defaults to 0. If no values * are specified, then no new items are inserted into the array.<p> * * @param(name=start,optional=true) * @param(name=deleteCount,optional=true) * @param(name=v,varargs=true) - * @return(Number) + * @return(Number) */ case "splice": return METHOD; @@ -148,9 +148,9 @@ /* Inserts the specified values at the beginning of the array. Returns the new size * of the array. * - * @param(name=v,varargs=true) + * @param(name=v,varargs=true) * @return(Number) - * */ + * */ case "unshift": return METHOD; //#end @@ -196,11 +196,11 @@ public JS new_(JS[] args) throws JSExn { throw new JSExn(type() +" is not a constructor"); } public JS apply(JS target, JS[] args) throws JSExn { throw new JSExn("Cannot call a " + type()); } public JS callMethod(JS this_, JS method, JS[] args) throws JSExn { - JSArrayLike thisArr = (JSArrayLike)this_; + JSArrayLike thisArr = (JSArrayLike)this_; //#switch(JSU.toString(method)) - case "concat": return concat(args); - case "copy": return copy(); - case "join": return join(args.length == 0 ? "," : JSU.toString(args[0])); + case "concat": return concat(args); + case "copy": return copy(); + case "join": return join(args.length == 0 ? "," : JSU.toString(args[0])); case "pop": return size() == 0 ? null : (JS)remove(size() - 1); case "push": addAll(args); return JSU.N(size()); case "reverse": reverse(); return this; @@ -236,10 +236,10 @@ System.arraycopy(entries, 0, o, start, entries.length); } - private void concat_fill(JSArrayLike arr) throws JSExn { - for (int i=0; i<arr.size(); i++) { - add(arr.getElement(i)); - } + private void concat_fill(JSArrayLike arr) throws JSExn { + for (int i=0; i<arr.size(); i++) { + add(arr.getElement(i)); + } } // ECMA Implementation //////////////////////////////////////////////////// @@ -260,21 +260,21 @@ /** joins tegether array contents into a string */ private JS concat(JS[] args) throws JSExn { - int l = size(); - // size & check - for (int i=0; i<args.length; i++) { - if (!(args[i] instanceof JSArrayLike)) { - throw new JSExn("Arg "+i+" not an []"); - } - JSArrayLike a = ((JSArrayLike)args[i]); - l += a.size(); - } - JSArray r = new JSArray(l); - r.concat_fill(this); - for (int i=0; i<args.length; i++) { - r.concat_fill((JSArrayLike)args[i]); - } - return r; + int l = size(); + // size & check + for (int i=0; i<args.length; i++) { + if (!(args[i] instanceof JSArrayLike)) { + throw new JSExn("Arg "+i+" not an []"); + } + JSArrayLike a = ((JSArrayLike)args[i]); + l += a.size(); + } + JSArray r = new JSArray(l); + r.concat_fill(this); + for (int i=0; i<args.length; i++) { + r.concat_fill((JSArrayLike)args[i]); + } + return r; } /** create a copy of an array between indice start and end */ @@ -348,28 +348,28 @@ } private JSArray copy() { - JSArray r = new JSArray(0); - r.size = size; + JSArray r = new JSArray(0); + r.size = size; r.o = new Object[size]; System.arraycopy(o, 0, r.o, 0, size); return r; } public JS deepcopy() throws JSExn { - JSArray r = new JSArray(0); - r.size = size; + JSArray r = new JSArray(0); + r.size = size; r.o = new Object[size]; - for (int i=0; i<size(); i++) { - r.o[i] = JSU.deepcopy((JS)o[i]); - } + for (int i=0; i<size(); i++) { + r.o[i] = JSU.deepcopy((JS)o[i]); + } return r; } public JS getElement(int i) throws JSExn { return (JS) get(i); } public JS[] toArray() { - JS[] r = new JS[size()]; - for (int i=0; i<size(); i++) { - r[i] = (JS)o[i]; - } - return r; + JS[] r = new JS[size()]; + for (int i=0; i<size(); i++) { + r[i] = (JS)o[i]; + } + return r; } } \ No newline at end of file Modified: trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSPrimitive.jpp =================================================================== --- trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSPrimitive.jpp 2011-01-25 00:21:11 UTC (rev 3998) +++ trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSPrimitive.jpp 2011-01-25 00:46:21 UTC (rev 3999) @@ -6,10 +6,10 @@ public class JSPrimitive extends JS.Immutable implements Constants, JS.Copyable { - // REMARK primitives are immutable - public JS deepcopy() { return this; } - - public JS callMethod(JS this_, JS method, JS[] args) throws JSExn { + // REMARK primitives are immutable + public JS deepcopy() { return this; } + + public JS callMethod(JS this_, JS method, JS[] args) throws JSExn { String s = coerceToString(); int slength = s.length(); //#switch(JSU.toString(method)) @@ -24,8 +24,8 @@ return JSU.N(s.charAt(p)); } case "compareTo": { - String a = JSU.toString(args[0]); - return JSU.N(s.compareTo(a)); + String a = JSU.toString(args[0]); + return JSU.N(s.compareTo(a)); } case "concat": { StringBuffer sb = new StringBuffer(slength*2).append(s); @@ -60,8 +60,8 @@ return JSU.S(s.substring(a,b)); } case "split": - if (args.length==0) return new JSArray(this); - return JSRegexp.stringSplit(this,args[0],args.length>1?args[1]:null); + if (args.length==0) return new JSArray(this); + return JSRegexp.stringSplit(this,args[0],args.length>1?args[1]:null); case "substr": { int start = args.length >= 1 ? JSU.toInt(args[0]) : 0; int len = args.length >= 2 ? JSU.toInt(args[1]) : Integer.MAX_VALUE; @@ -87,10 +87,10 @@ case "toLowerCase": return JSU.S(s.toLowerCase()); case "toPrecision": throw new JSExn("toPrecision() not implemented"); case "toString": { - if (this instanceof JSString) return this; - if (JSU.isInt(this) && args.length == 1) - return JSU.S(Integer.toString(JSU.toInt(this), JSU.toInt(args[0]))); - return JSU.S(JSU.toString(this)); + if (this instanceof JSString) return this; + if (JSU.isInt(this) && args.length == 1) + return JSU.S(Integer.toString(JSU.toInt(this), JSU.toInt(args[0]))); + return JSU.S(JSU.toString(this)); } case "toUpperCase": return JSU.S(s.toUpperCase()); case "trim": return JSU.S(s.trim()); @@ -104,27 +104,28 @@ * * <p>Strings can be created as literals in javascript using <code>""</code> or <code>''</code></p> * */ - - /* The number of characters in a string. @type(Number) */ - case "length": return JSU.N(JSU.toString(this).length()); + + /* The number of characters in a string. + * @type(Number) */ + case "length": return JSU.N(JSU.toString(this).length()); - /* <p>Returns the character at position pos in the string.</p> - * - * <p>If pos is omitted, it defaults to 0. If pos is outside - * the range of valid characters, the function returns "".</p> - * - * @param(name=pos) - * @return(String) - * */ + /* <p>Returns the character at position pos in the string.</p> + * + * <p>If pos is omitted, it defaults to 0. If pos is outside + * the range of valid characters, the function returns "".</p> + * + * @param(name=pos) + * @return(String) + * */ case "charAt": return METHOD; - /* <p>Returns the numeric value of the character at position pos in the string.</p> - * - * <p>If pos is omitted, it defaults to 0. If pos is outside the range - * of valid characters, the function returns NaN.</p> - * - * @param(name=pos) - * @return(Number) - * */ + /* <p>Returns the numeric value of the character at position pos in the string.</p> + * + * <p>If pos is omitted, it defaults to 0. If pos is outside the range + * of valid characters, the function returns NaN.</p> + * + * @param(name=pos) + * @return(Number) + * */ case "charCodeAt": return METHOD; /* <p> Compares two strings lexicographically. Returns -1,0,1 depending on whether * the string precedes, is equal to, or follows <i>str</i></p> @@ -133,100 +134,100 @@ * @return(Number) * */ case "compareTo": return METHOD; - /* <p>Constructs a new string which is a concatenation of the current string - * and all values passed to the function.</p> - * - * @param(name=str,varargs=true) - * @return(String) - * */ + /* <p>Constructs a new string which is a concatenation of the current string + * and all values passed to the function.</p> + * + * @param(name=str,varargs=true) + * @return(String) + * */ case "concat": return METHOD; - /* <p>Returns the first position of sub-string search in the current string, - * with search starting at position start. If the sub-string is not found, - * the function returns -1.</p> - * - * <p>If start is omitted, it defaults to the start of the string; if search - * is omitted, then it defaults to null.</p> - * - * @param(name=search) - * @param(name=start, optional=true) - * @return(Number) - * */ + /* <p>Returns the first position of sub-string search in the current string, + * with search starting at position start. If the sub-string is not found, + * the function returns -1.</p> + * + * <p>If start is omitted, it defaults to the start of the string; if search + * is omitted, then it defaults to null.</p> + * + * @param(name=search) + * @param(name=start, optional=true) + * @return(Number) + * */ case "indexOf": return METHOD; - /* <p>Returns the last position of sub-string search in the current string, - * but will only search up to position end. If the sub-string is not found, - * the function returns -1.</p> - * - * <p>If end is omitted, it defaults to the length of the string; if search - * is omitted, then it defaults to null.</p> - * - * @param(name=search) - * @param(name=end, optional=true) - * @return(Number) - * */ + /* <p>Returns the last position of sub-string search in the current string, + * but will only search up to position end. If the sub-string is not found, + * the function returns -1.</p> + * + * <p>If end is omitted, it defaults to the length of the string; if search + * is omitted, then it defaults to null.</p> + * + * @param(name=search) + * @param(name=end, optional=true) + * @return(Number) + * */ case "lastIndexOf": return METHOD; - /* <p>Returns expression.stringMatch(string) - see regexp.stringMatch(string).</p> - * - * @param(name=regexp) - * @return(String) - * */ + /* <p>Returns expression.stringMatch(string) — see regexp.stringMatch(string).</p> + * + * @param(name=regexp) + * @return(String) + * */ case "match": return METHOD; - /* <p>Returns expression.stringReplace(string, replaceString) \x96 - * see regexp.stringReplace(searchString, replaceString).</p> - * - * @param(name=regexp) - * @param(name=str) - * @return(String) - * */ + /* <p>Returns expression.stringReplace(string, replaceString) — + * see regexp.stringReplace(searchString, replaceString).</p> + * + * @param(name=regexp) + * @param(name=str) + * @return(String) + * */ case "replace": return METHOD; - /* Returns expression.stringSearch(string) - see regexp.stringSearch(string). + /* Returns expression.stringSearch(string) — see regexp.stringSearch(string). * * @param(name=regexp) - * @return(String) - * */ + * @return(String) + * */ case "search": return METHOD; - /* <p>Returns the section of the string between start and end - 1, inclusive.</p> - * - * <p>If either argument is less than 0, then the argument is treated as the - * number of characters counted backwards from the end of the string. If start - * is omitted, it defaults to the start of the string; if end is omitted, it - * defaults to the string\x92s length. If start is greater than end, the function - * returns "".</p> - * - * @param(name=start) - * @param(name=end,optional=true) - * @return(String) - * */ + /* <p>Returns the section of the string between start and end — 1, inclusive.</p> + * + * <p>If either argument is less than 0, then the argument is treated as the + * number of characters counted backwards from the end of the string. If start + * is omitted, it defaults to the start of the string; if end is omitted, it + * defaults to the string\x92s length. If start is greater than end, the function + * returns "".</p> + * + * @param(name=start) + * @param(name=end,optional=true) + * @return(String) + * */ case "slice": return METHOD; - /* <p>Splits the current string into separate strings, using the sub-string - * defined by expression as a separator. Returns an array of limit elements - * that contains the list of strings.</p> - * - * @param(name=regexp) - * @param(name=limit,optional=true) - * @return(Array) - * */ + /* <p>Splits the current string into separate strings, using the sub-string + * defined by expression as a separator. Returns an array of limit elements + * that contains the list of strings.</p> + * + * @param(name=regexp) + * @param(name=limit,optional=true) + * @return(Array) + * */ case "split": return METHOD; - /* <p>Returns the section of the string beginning at start and continuing - * for length characters.</p> - * - * <p>If length is omitted, then the remaining length of the string is used. - * If both start and length are omitted, then the entire string is returned.</p> - * - * @param(name=start) - * @param(name=length,optional=true) - * @return(String) - * */ + /* <p>Returns the section of the string beginning at start and continuing + * for length characters.</p> + * + * <p>If length is omitted, then the remaining length of the string is used. + * If both start and length are omitted, then the entire string is returned.</p> + * + * @param(name=start) + * @param(name=length,optional=true) + * @return(String) + * */ case "substr": return METHOD; - /* <p>Returns the section of the string between start and end - 1, inclusive.</p> - * - * <p>If end is omitted, it defaults to the string\x92s length. If both start and end - * are omitted, then the entire string is returned. If start is greater than end, - * the two values are swapped.</p> - * - * @param(name=start) - * @param(name=end,optional=true) - * @return(String) - * */ + /* <p>Returns the section of the string between start and end — 1, inclusive.</p> + * + * <p>If end is omitted, it defaults to the string\x92s length. If both start and end + * are omitted, then the entire string is returned. If start is greater than end, + * the two values are swapped.</p> + * + * @param(name=start) + * @param(name=end,optional=true) + * @return(String) + * */ case "substring": return METHOD; /* <p>TODO</p> * @@ -246,13 +247,17 @@ * @return(String) * */ case "toFixed": if (this instanceof JSNumber) return METHOD; - /* Returns the lower-case equivalent of the current string. @return(String) */ + /* Returns the lower-case equivalent of the current string + * @return(String) */ case "toLowerCase": return METHOD; - /* Returns the current string. @return(String) */ + /* Returns the current string. + * @return(String) */ case "toString": return METHOD; - /* Returns the upper-case equivalent of the current string. @return(String) */ + /* Returns the upper-case equivalent of the current string + * @return(String) */ case "toUpperCase": return METHOD; - /* Returns the string with leading and trailing whitespace removed. @return(String) */ + /* Returns the string with leading and trailing whitespace removed + * @return(String) */ case "trim": return METHOD; //#end return super.get(key); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn