Revision: 4004 http://vexi.svn.sourceforge.net/vexi/?rev=4004&view=rev Author: clrg Date: 2011-01-26 01:41:13 +0000 (Wed, 26 Jan 2011)
Log Message: ----------- Documentation Modified Paths: -------------- trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSNumber.java trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JS.jpp trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSExn.jpp Modified: trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java =================================================================== --- trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java 2011-01-25 18:06:58 UTC (rev 4003) +++ trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java 2011-01-26 01:41:13 UTC (rev 4004) @@ -24,29 +24,37 @@ /*@PAGE(concept=Surfaces) * * <p>Each top-level window in a Vexi UI is called a <i>surface</i>. There are two kinds of - * surfaces: <i>frames</i>, which usually have a platform-specific titlebar and border, and - * <i>windows</i>, which never have any additional platform-specific decorations.</p> - * <ul> - * <li><b>Frames</b> : usually have a platform-specific titlebar and border</li> - * <li><b>Windows</b> : never have any additional platform-specific decorations</li> - * </ul> + * surfaces, <i>frames</i> and <i>windows</i>. * - * <p>To create a new Surface, put the intended root box to either:</p> - * <ul> - * <li><code>vexi.ui.frame</code></li> - * <li><code>vexi.ui.window</code></li> - * </ul> + * <h3>Surface Frames</h3> * + * <p>Frames usually have a platform-specific titlebar and border.</p> + * + * <p>To create a new frame, put the intended root box to <code>vexi.ui.frame</code>.</p> + * * <p>For example, from within the intended root template:</p> - * <pre> vexi.ui.frame = thisbox;</pre> * + * <pre>vexi.ui.frame = thisbox;</pre> + * + * <h2>Surface Windows</h2> + * + * <p>Windows never have any additional platform-specific decorations.</p> + * + * <p>To create a new frame, put the intended root box to <code>vexi.ui.window</code>.</p> + * + * <p>For example:</p> + * + * <pre>vexi.ui.window = thisbox;</pre> + * + * <h2>Surface Behaviour</h2> + * * <p>Whenever we refer to the size or position of a surface, we are referring to the size or * position of the UI-accessible portion of the surface; this does not include any * platform-specific decorations. This means that if you set the position of a frame to (0,0), the * platform-specific titlebar will actually be off the screen on most platforms (it will be above * and to the left of the top-left corner of the screen).</p> * - * <p>Surfaces are not actual vexiscript objects; you cannot obtain a reference to a surface. + * <p>Surfaces are not actual vexiscript objects; you can not obtain a reference to a surface. * However, each surface is uniquely identified by its <i>root box</i>.</p> * */ 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-01-25 18:06:58 UTC (rev 4003) +++ trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp 2011-01-26 01:41:13 UTC (rev 4004) @@ -32,7 +32,7 @@ * the subject box. In this way, a parentless box and it's descendents combine to form a tree * structure, a box tree where the topmost parentless box is referred to as the root box.</p> * - * <p>A root box may be attached to a <a href="Surface.html">Surface</a>.</p> + * <p>A root box may be attached to a <a href="Surfaces.html">Surface</a>.</p> * * <h2>Box Layout</h2> * @@ -1980,10 +1980,11 @@ if (redirect==null) { throw new JSExn("Can not call Box."+JSU.toString(name)+"() on a box with a null redirect"); } - return redirect == this ? METHOD : redirect.getAndTriggerTraps(SC_clear); + return redirect == this ? METHOD : redirect.getAndTriggerTraps(SC_contains); - /* <p>Returns the index of childbox within a box. If childbox is not an immediate child of - * the box, or an immediate child of the box's redirect, then the function returns -1.</p> + /* <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> * * @method * @param(b) 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 18:06:58 UTC (rev 4003) +++ trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSNumber.java 2011-01-26 01:41:13 UTC (rev 4004) @@ -35,7 +35,12 @@ //#noswitch - leave, needed for jsdoc /*@PAGE(varname=Number,humanname=Numbers) * - * <p>TODO</p> + * <p>A standard javscript number.</p> + * + * <p>A number is a primitive, so all <a href="vexi.js.String.html">string</a> functions are valid.</p> + * + * <p>There is no distinction in javascript between different types of numbers. Integers and non-integers + * are both of type <code>"number"</code>.</p> * * */ //#end Modified: trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JS.jpp =================================================================== --- trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JS.jpp 2011-01-25 18:06:58 UTC (rev 4003) +++ trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JS.jpp 2011-01-26 01:41:13 UTC (rev 4004) @@ -566,15 +566,29 @@ public JS get(JS key) throws JSExn { /*@PAGE(varname=Object,humanname=JS Object) * - * <p>The standard js object.</p> + * <p>The vexiscript implementation of a standard js object.</p> * + * <h3>Creating Objects</h3> + * * <p>Objects can be created as literals in vexiscript using <code>{}</code>.</p> * * <p>Objects can be initialized with content using <code>{ key1:val1, key2:val2,... - * keyn:valn }.</code></p> + * keyn:valn }</code>.</p> * - * <p>Unlike in browser javascript, in vexiscript Objects do not have any standard + * <p>You can create objects in xml by including the <code>vexi://js</code> namespace:</p> + * + * <pre><vexi xmlns:js="vexi://js"> + * <js:Object key="value"> + * thisobj.key2 = "other value"; + * </js:Object> + *</vexi></pre> + * + * <h3>Object Behaviour</h3> + * + * <p>Unlike in browser javascript, in vexiscript objects do not have any standard * properties, and so have a completely free keyspace.</p> + * + * <p>Objects may be <a href="Cloning.html">cloned</a> and you can place <a href="Traps.html">traps</a> on object properties.</p> * * */ return getSafe(key); @@ -587,11 +601,11 @@ } /** Store a value against a key on the object. */ - public void put(JS key, JS value) throws JSExn { putSafe(key,value); } + public void put(JS key, JS value) throws JSExn { putSafe(key, myvalue); } public void putSafe(JS key, JS value) { // workaround, avoid JSExn in signature // FEATURE: MEMORY OPTIMIZE? // if (props==null) props = new SmallMap(); - // else if(props.size()>4) props = new HashMap(props); + // else if (props.size()>4) props = new HashMap(props); if (props==null) { props = new HashMap(4); } Modified: trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSExn.jpp =================================================================== --- trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSExn.jpp 2011-01-25 18:06:58 UTC (rev 4003) +++ trunk/org.vexi-library.js/src/main/jpp/org/ibex/js/JSExn.jpp 2011-01-26 01:41:13 UTC (rev 4004) @@ -9,80 +9,80 @@ import org.ibex.util.*; /** An exception which can be thrown and caught by JavaScript code */ -public class JSExn extends Exception implements Constants{ - static public JS Constructor = new JS.Constructor("Exception"){ - public JS new_(JS[] args) throws JSExn { - JS msg = args.length>=1?args[0]:null; - JS type = args.length>=2?args[1]:null; - return new JSExn(msg,type).getObject(); - } - }; - - /** Maximum number of entries to report in a backtrace. */ +public class JSExn extends Exception implements Constants { + static public JS Constructor = new JS.Constructor("Exception") { + public JS new_(JS[] args) throws JSExn { + JS msg = args.length>=1?args[0]:null; + JS type = args.length>=2?args[1]:null; + return new JSExn(msg, type).getObject(); + } + }; + + /** Maximum number of entries to report in a backtrace. */ public static final int MAX_BACKTRACE_SIZE = 50; final Basket.List backtrace = new Basket.Array(); final private ExnJSObj js ; public JSExn(InterruptedException e) { - this("JS thread interrupted", SC_interrupted, e); + this("JS thread interrupted", SC_interrupted, e); } public JSExn(Throwable e) { - this("Unexpected Java exception thrown by the core\n" + e.getClass().getName() + ":" + e.getMessage(),e); + this("Unexpected Java exception thrown by the core\n" + e.getClass().getName() + ":" + e.getMessage(),e); } public JSExn(String msg, Throwable e) { - this(msg, SC_error, e); + this(msg, SC_error, e); } public JSExn(String msg, JS type, Throwable e) { - super(e); - this.js = new ExnJSObj(JSU.S(msg), type); - fill(null); + super(e); + this.js = new ExnJSObj(JSU.S(msg), type); + fill(null); } public JSExn(String msg, JS type){ this(JSU.S(msg), type); } public JSExn(String s) { this(JSU.S(s)); } public JSExn(JS msg) { this(msg,null); } public JSExn(JS msg, JS type) { this(msg,type,null); } public JSExn(JS msg, JS type, Interpreter cx) { - this.js = new ExnJSObj(msg,type); - fill(cx); + this.js = new ExnJSObj(msg,type); + fill(cx); } - void fillIfEmpty(Interpreter cx){ - if(backtrace.size()==0) - fill(cx); + void fillIfEmpty(Interpreter cx) { + if (backtrace.size()==0) + fill(cx); } private void fill(Interpreter cx) { - if(cx == null) cx = Scheduler.getAvailableInterpreter(); - if(cx == null) return; - while(cx!=null){ - cx.stack.backtrace(this); - cx = cx.old; + if (cx == null) cx = Scheduler.getAvailableInterpreter(); + if (cx == null) return; + while (cx!=null) { + cx.stack.backtrace(this); + cx = cx.old; } } - public Throwable getCause(){ + public Throwable getCause() { Throwable r = super.getCause(); - if(r!=null) return r; + if (r!=null) return r; JS c = getObject().getSafe(SC_cause); - if(c!=null) return ((ExnJSObj)c).getJSExn(); + if (c!=null) return ((ExnJSObj)c).getJSExn(); return null; } public void printStackTrace() { printStackTrace(System.err); } public void printStackTrace(PrintStream ps) { printStackTrace(new PrintWriter(ps)); } public void printStackTrace(PrintWriter pw) { - printStackTrace(pw, Logger.INFO); + printStackTrace(pw, Logger.INFO); } - public void printStackTrace(int level, Logger logger, Object o){ - if(level>=logger.getLevel()){ - StringWriter sw = new StringWriter(1024); - PrintWriter pw = new PrintWriter(sw); - printStackTrace(pw,logger.getLevel()); - logger.log(o, sw.toString(), logger.getLevel()); - } + public void printStackTrace(int level, Logger logger, Object o) { + if (level>=logger.getLevel()) { + StringWriter sw = new StringWriter(1024); + PrintWriter pw = new PrintWriter(sw); + printStackTrace(pw,logger.getLevel()); + logger.log(o, sw.toString(), logger.getLevel()); + } } public void printStackTrace(PrintWriter pw, int level) { int size = Math.min(backtrace.size(), MAX_BACKTRACE_SIZE); @@ -95,16 +95,16 @@ // If there is a cause it is because it generally/should mean we didn't know // how to handle the exception. So we want to print its stack trace. The actual // java stack trace of the jsexn only gets printed when debug log level is set. - if(level<=Logger.DEBUG) + if (level<=Logger.DEBUG) super.printStackTrace(pw); else { Throwable ourCause = getCause(); if (ourCause != null){ - if(ourCause instanceof JSExn || - (level<=Logger.ERROR && SC_error.equals(js.getSafe(SC_type)) )){ + if (ourCause instanceof JSExn || + (level<=Logger.ERROR && SC_error.equals(js.getSafe(SC_type)) )) { ourCause.printStackTrace(pw); } - } + } } pw.flush(); } @@ -112,8 +112,8 @@ public String getMessage() { return toString(); } void addBacktrace(String line) { - if(line==null) return; - backtrace.add(line); + if (line==null) return; + backtrace.add(line); } public static class Wrapper extends RuntimeException { @@ -130,65 +130,73 @@ // JSExn JS interface (as !JSExn instanceof JS) // Provides access to the stack trace from JSExn. - public class ExnJSObj extends JS.Obj{ - public ExnJSObj(JS msg, JS type) { - putSafe(SC_message,msg); - putSafe(SC_type,type); - } + public class ExnJSObj extends JS.Obj { + public ExnJSObj(JS msg, JS type) { + putSafe(SC_message, msg); + putSafe(SC_type, type); + } - public JS get(JS key) throws JSExn { - //#switch(JSU.toString(key)) - /*@PAGE(varname=Exception,humanname=Exception Object) */ - /* - * Returns the backtrace as an Array of Strings. One array - * for each line in the backtrace. - * - * @type(Array) - * */ - case "backtrace": { - // FEATURE store backTrace as a JSArray of JS Strings. - JSArray r = new JSArray(); - for(int i=0; i<backtrace.size(); i++){ - r.add(JSU.S((String) backtrace.get(i))); - } - return r; - } - /* - * Property used for exception chaining. If the reason to + public JS get(JS key) throws JSExn { + //#switch(JSU.toString(key)) + /*@PAGE(varname=Exception,humanname=Exception Object) + * + * <p>The Exception constructor takes two optional arguments, the first argument sets the + * Exception message and the second sets the Exception type.</p> + * + * <pre>var exn = new vexi.js.Exception("arbitray message", "arbitrary type");</pre> + * + * <p>Alternatively you can simply <code>throw</code> a String — i.e. <code>throw "message"</code> + * — but this approach will interrupt your application if the thrown Exception is not caught by a + * <code>catch</code> clause higher up in the call stack.</p> + * */ + + /* <p>Returns the backtrace as an Array of Strings. One array + * for each line in the backtrace.</p> + * + * @type(Array) + * */ + case "backtrace": + // FEATURE store backTrace as a JSArray of JS Strings. + JSArray r = new JSArray(); + for (int i=0; i<backtrace.size(); i++) { + r.add(JSU.S((String)backtrace.get(i))); + } + return r; + + /* <p>Property used for exception chaining. If the reason to * throw the exception is not being able to recover when * handling another exception then this can be set so that * complete information about the error can be communicated - * up out of the call stack. + * up out of the call stack.</p> * * @type(Exception) * */ - case "cause": { - Throwable e = getCause(); - if(e instanceof JSExn){ - return ((JSExn)e).getObject(); - } - return null; - } - /* - * The message describing the reason the exception was thrown. - * - * @type(String) - * */ - case "message": return super.get(key); - /* - * The type of the exception. - * - * @type(String) - * */ - case "type": return super.get(key); - //#end - return super.get(key); - } - - public void put(JS key, JS val) throws JSExn{ + case "cause": + Throwable e = getCause(); + if (e instanceof JSExn) { + return ((JSExn)e).getObject(); + } + return null; + + /* <p>The message describing the reason the exception was thrown</p> + * + * @type(String) + * */ + case "message": return super.get(key); + + /* <p>The type of the exception</p> + * + * @type(String) + * */ + case "type": return super.get(key); + //#end + return super.get(key); + } + + public void put(JS key, JS val) throws JSExn { //#switch(JSU.toString(key)) case "cause": { - if(!(val instanceof ExnJSObj)){ + if (!(val instanceof ExnJSObj)) { throw new JSExn("Not a valid cause: "+ key); } super.put(key,val); @@ -196,21 +204,22 @@ //#end super.put(key,val); } - - public String getMessage(){ - try{ - return JSU.toString(js.get(SC_message)); - }catch(JSExn e){// Shouldn't happen - } - return null; - //JSExn.this = x; - } - - // Get back the JSExn. Used by the interpreter when throwing an ExnJSObj - JSExn getJSExn(){ - return JSExn.this; - } - public JS type() { return SC_exception;} + + public String getMessage() { + try { + return JSU.toString(js.get(SC_message)); + } catch (JSExn e) { + // Shouldn't happen + } + return null; + //JSExn.this = x; + } + + // Get back the JSExn. Used by the interpreter when throwing an ExnJSObj + JSExn getJSExn() { + return JSExn.this; + } + public JS type() { return SC_exception;} } } 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