Revision: 4223 http://vexi.svn.sourceforge.net/vexi/?rev=4223&view=rev Author: mkpg2 Date: 2011-09-12 01:31:47 +0000 (Mon, 12 Sep 2011) Log Message: ----------- Feature. Support toString() in trace. If an object implements toString function use that instead of the default formatting. Function. vexi.js.hashOf() returns a hash string which identifies (more or less uniquely) an object based on it's position in memory.
Modified Paths: -------------- trunk/org.vexi-library.js/src/main/java/org/vexi/js/script.js trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSU.jpp trunk/org.vexi-library.js/src/main/jpp/org/vexi/js/VexiJS.jpp Modified: trunk/org.vexi-library.js/src/main/java/org/vexi/js/script.js =================================================================== --- trunk/org.vexi-library.js/src/main/java/org/vexi/js/script.js 2011-09-11 22:45:22 UTC (rev 4222) +++ trunk/org.vexi-library.js/src/main/java/org/vexi/js/script.js 2011-09-12 01:31:47 UTC (rev 4223) @@ -73,6 +73,12 @@ /** take the object input obj and format it as a string */ var formatObject = function(obj, indent, nofollow) { + var toString = obj.toString; + if(toString !=null and (typeof toString == "function")){ + var r = toString(); + if(r!=null) return r; + } + var simple = []; var strlen = 0; var i = 0; Modified: trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSU.jpp =================================================================== --- trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSU.jpp 2011-09-11 22:45:22 UTC (rev 4222) +++ trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSU.jpp 2011-09-12 01:31:47 UTC (rev 4223) @@ -359,4 +359,9 @@ } return a.equals(b); } + + static public JS hashOf(JS js) { + if(js==null) return null; + return JSU.S( Integer.toHexString(js.hashCode())); + } } Modified: trunk/org.vexi-library.js/src/main/jpp/org/vexi/js/VexiJS.jpp =================================================================== --- trunk/org.vexi-library.js/src/main/jpp/org/vexi/js/VexiJS.jpp 2011-09-11 22:45:22 UTC (rev 4222) +++ trunk/org.vexi-library.js/src/main/jpp/org/vexi/js/VexiJS.jpp 2011-09-12 01:31:47 UTC (rev 4223) @@ -567,6 +567,7 @@ /* @jpp(org.ibex.js.JSPrimitive) */ case "String": return org.ibex.js.JSString.Constructor; + case "constructorsOf": return METHOD; /* <p>Creates a deep copy of the input, with all referenced arrays/objects @@ -594,6 +595,17 @@ * */ case "format": return script().get(key); + /* <p>Returns a the hash of an object. Serves to identify an object (using its position in memory). + * A fixed hash cannot be unique, but whilst an object is retained in memory it's hash should be + * unique. </p> + * + * @method + * @param(name=js) + * @return(String) + * */ + case "hashOf": return METHOD; + + /* <p>Takes the given JS and returns a JSON string.</p> * @method * @param(name=js) @@ -612,6 +624,7 @@ case 1: { //#switch(JSU.toString(method)) case "constructorsOf": return JSU.constructorsOf(args[0]); + case "hashOf": return args[0]==null?null:JSU.N(args[0].hashCode()); case "stringify": return JSON.marshal(args[0]); case "deepcopy": return JSU.deepcopy(args[0]); //#end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Doing More with Less: The Next Generation Virtual Desktop What are the key obstacles that have prevented many mid-market businesses from deploying virtual desktops? How do next-generation virtual desktops provide companies an easier-to-deploy, easier-to-manage and more affordable virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/ _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn