2003/09/27 09:08:26
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:38:25 +0000 (07:38 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:38:25 +0000 (07:38 +0000)
darcs-hash:20040130073825-2ba56-4f43333feee4efa9343bca2f0fdd8b99d5e7eb28.gz

src/org/xwt/Box.java.pp
src/org/xwt/HTTP.java
src/org/xwt/Res.java
src/org/xwt/Template.java
src/org/xwt/Trap.java
src/org/xwt/XWT.java

index aac3bd1..85b143e 100644 (file)
@@ -871,8 +871,8 @@ public final class Box extends JS.Scope {
         void put(String name, Box b, Object value) { put(b, value); }
 
         static {
-            //#repeat fillcolor/strokecolor
-            specialBoxProperties.put("fillcolor", new SpecialBoxProperty() {
+            //#repeat fill/stroke fillcolor/strokecolor
+            specialBoxProperties.put("fill", new SpecialBoxProperty() {
                     public Object get(Box b) {
                         if ((b.fillcolor & 0xFF000000) == 0) return null;
                         String red = Integer.toHexString((b.fillcolor & 0x00FF0000) >> 16);
@@ -907,13 +907,13 @@ public final class Box extends JS.Scope {
             //#end
         
             specialBoxProperties.put("color", new SpecialBoxProperty() {
-                    public Object get(Box b) { return b.get("fillcolor"); }
-                    public void put(Box b, Object value) { b.put("fillcolor", value); }
+                    public Object get(Box b) { return b.get("fill"); }
+                    public void put(Box b, Object value) { b.put("fill", value); }
                 });
 
             specialBoxProperties.put("textcolor", new SpecialBoxProperty() {
-                    public Object get(Box b) { return b.get("strokecolor"); }
-                    public void put(Box b, Object value) { b.put("strokecolor", value); }
+                    public Object get(Box b) { return b.get("stroke"); }
+                    public void put(Box b, Object value) { b.put("stroke", value); }
                 });
 
             specialBoxProperties.put("text", new SpecialBoxProperty() {
index fed6e6e..8f26528 100644 (file)
@@ -323,6 +323,10 @@ public class HTTP {
     // Everything Else ////////////////////////////////////////////////////////////////////////////
 
     private synchronized void connect() throws IOException {
+        if (originalUrl.equals("stdio:")) {
+            in = new BufferedInputStream(System.in);
+            return;
+        }
         if (sock != null) {
             if (in == null) in = new BufferedInputStream(sock.getInputStream());
             return;
@@ -366,7 +370,7 @@ public class HTTP {
 
     public void sendRequest(String contentType, String content) throws IOException {
 
-        PrintWriter pw = new PrintWriter(new OutputStreamWriter(sock.getOutputStream()));
+        PrintWriter pw = new PrintWriter(new OutputStreamWriter(originalUrl.equals("stdio:") ? System.out : sock.getOutputStream()));
         if (content != null) {
             pw.print("POST " + path + " HTTP/1.1\r\n");
             int contentLength = content.substring(0, 2).equals("\r\n") ?
index 1f1a927..107c766 100644 (file)
@@ -54,6 +54,7 @@ public abstract class Res extends JS {
         if (url.startsWith("file:") && permitLocalFilesystem) return new File(url.substring(5));
         if (url.startsWith("cab:")) return new CAB(stringToRes(url.substring(4)));
         if (url.startsWith("data:")) return new ByteArray(Base64.decode(url.substring(5)));
+        if (url.startsWith("utf8:")) return new ByteArray(url.substring(5).getBytes());
         throw new JS.Exn("invalid resource specifier " + url);
     }
 
index 209ae25..338771d 100644 (file)
@@ -117,7 +117,7 @@ public class Template {
             t.apply(b, callback, xwt);
         }
 
-        PerInstantiationScope pis = new PerInstantiationScope(b, xwt, parentPis);
+        PerInstantiationScope pis = new PerInstantiationScope(b, xwt, parentPis, staticScope);
         for (int i=0; children != null && i<children.size(); i++) {
             Box kid = new Box();
             ((Template)children.elementAt(i)).apply(kid, callback, xwt, pis);
@@ -337,21 +337,24 @@ public class Template {
     private static class PerInstantiationScope extends JS.Scope {
         XWT xwt = null;
         PerInstantiationScope parentBoxPis = null;
+        JS.Scope myStatic = null;
         void putDollar(String key, Box target) {
             if (parentBoxPis != null) parentBoxPis.putDollar(key, target);
             declare("$" + key);
             put("$" + key, target);
         }
-        public PerInstantiationScope(Scope parentScope, XWT xwt, PerInstantiationScope parentBoxPis) {
+        public PerInstantiationScope(Scope parentScope, XWT xwt, PerInstantiationScope parentBoxPis, JS.Scope myStatic) {
             super(parentScope);
             this.parentBoxPis = parentBoxPis;
             this.xwt = xwt;
+            this.myStatic = myStatic;
         }
         public boolean isTransparent() { return true; }
         public boolean has(Object key) { return false; }
         public void declare(String s) { super.declare(s); }
         public Object get(Object key) {
             if (key.equals("xwt")) return xwt;
+            if (key.equals("static")) return myStatic;
             if (Box.SpecialBoxProperty.specialBoxProperties.get(key.toString()) != null) return getParentScope().get(key);
             if (super.has(key)) return super.get(key);
             Object ret = xwt.rr.get(key);
index f33f75a..9f2bdf3 100644 (file)
@@ -97,15 +97,24 @@ public class Trap {
     private Trap() { }
 
     public Object perform() throws JS.Exn {
-        if (f.getNumFormalArgs() > 0) return cascade();
-        return f.call(new TrapArgs(this));
+        try {
+            if (f.getNumFormalArgs() > 0) return cascade();
+            return f.call(new TrapArgs(this));
+        } catch (Exception e) {
+            Log.log(this, "Exception thrown from within trap: " + e);
+            return null;
+        }
     }
     
     public void perform(Object val) throws JS.Exn {
-        if (f.getNumFormalArgs() == 0) cascade(val);
-        TrapArgs ta = new TrapArgs(this, val);
-        Object ret = f.call(ta);
-        if (ret != Boolean.FALSE && !ta.cascadeHappened) cascade(val);
+        try {
+            if (f.getNumFormalArgs() == 0) cascade(val);
+            TrapArgs ta = new TrapArgs(this, val);
+            Object ret = f.call(ta);
+            if (ret != Boolean.FALSE && !ta.cascadeHappened) cascade(val);
+        } catch (Exception e) {
+            Log.log(this, "Exception thrown from within trap: " + e);
+        }
     }
     
     public Object cascade() {
index d276f05..ce2bfba 100644 (file)
@@ -25,6 +25,7 @@ public final class XWT extends JS.Obj {
     public Object get(Object name) {
         if (name.equals("alt")) return Surface.alt ? Boolean.TRUE : Boolean.FALSE;
         else if (name.equals("rr")) return rr;
+        else if (name.equals("box")) return new Box();
         else if (name.equals("control")) return Surface.control ? Boolean.TRUE : Boolean.FALSE;
         else if (name.equals("shift")) return Surface.shift ? Boolean.TRUE : Boolean.FALSE;
         else if (name.equals("clipboard")) return Platform.getClipBoard();
@@ -107,10 +108,6 @@ public final class XWT extends JS.Obj {
                 return new SOAP(args.elementAt(0).toString(), "", args.elementAt(1).toString(), args.elementAt(2).toString());
             else return null;
 
-        } else if (method.equals("newBox")) {
-            if (checkOnly) return Boolean.TRUE;
-            return new Box();
-
         } else if (method.equals("sleep")) {
             if (checkOnly) return Boolean.TRUE;
             if (args != null && (args.length() != 1 || args.elementAt(0) == null)) return null;