remove JS.call(JS[]), JS.getInputStream()
[org.ibex.core.git] / src / org / ibex / core / Ibex.java
index 7b27d14..bd133c7 100644 (file)
@@ -45,8 +45,8 @@ public final class Ibex extends JS.Obj implements JS.Cloneable {
         Sub(JS key) { this.key = key; }
         public void put(JS key, JS val) throws JSExn { Ibex.this.put(JSU.S(JSU.toString(this.key) + "." + JSU.toString(key)), val); }
         public JS get(JS key) throws JSExn { return Ibex.this.get(JSU.S(JSU.toString(this.key) + "." + JSU.toString(key))); }
-        public JS call(JS[] args) throws JSExn { return Ibex.this.call(this.key, args); }
         public JS call(JS method, JS[] args) throws JSExn {
+            if (method == null) return super.call(null, args);
             return Ibex.this.call(JSU.S(JSU.toString(this.key) + "." + JSU.toString(method)), args);
         }
     }
@@ -201,7 +201,7 @@ public final class Ibex extends JS.Obj implements JS.Cloneable {
                     case "stream.parse.xml": if(args[0] == null) return null; new XMLHelper(args[1]).doParse(args[0]); return null;
                         // FIXME backgrounding
                     case "stream.parse.utf8": if(args[0] == null) return null;
-                                              try { return JSU.S(new String(InputStreamToByteArray.convert(args[0].getInputStream()))); }
+                                              try { return JSU.S(new String(InputStreamToByteArray.convert(JSU.getInputStream(args[0])))); }
                                               catch (Exception e) { Log.warn(this, e); }
                     //#end
                     break;
@@ -324,29 +324,29 @@ public final class Ibex extends JS.Obj implements JS.Cloneable {
                 callargs3[0] = JSU.S(c.getLocalName());
                 callargs3[1] = attrs;
                 callargs3[2] = JSU.S(c.getUri());
-                startElement.call(callargs3);
+                startElement.call(null, callargs3);
         } catch (JSExn jse) { throw new Wrapper(jse);
         } finally { callargs3[0] = callargs3[1] = callargs3[2] = null; } }
 
         public void endElement(Tree.Element c) throws XML.Exn { try {
                 callargs2[0] = JSU.S(c.getLocalName());
                 callargs2[1] = JSU.S(c.getUri());
-                endElement.call(callargs2);
+                endElement.call(null, callargs2);
         } catch (JSExn jse) { throw new Wrapper(jse); } finally { callargs2[0] = callargs2[1] = null; } }
 
         public void characters(char[] ch, int start, int length) throws XML.Exn { try {
                 callargs1[0] = JSU.S(new String(ch, start, length));
-                characters.call(callargs1);
+                characters.call(null, callargs1);
         } catch (JSExn jse) { throw new Wrapper(jse); } finally { callargs1[0] = null; } }
 
         public void whitespace(char[] ch, int start, int length) throws XML.Exn { try {
                 callargs1[0] = JSU.S(new String(ch, start, length));
-                whitespace.call(callargs1);
+                whitespace.call(null, callargs1);
         } catch (JSExn jse) { throw new Wrapper(jse); } finally { callargs1[0] = null; } }
 
         public void doParse(JS s) throws JSExn {
             try { 
-                parse(new BufferedReader(new InputStreamReader(s.getInputStream())));
+                parse(new BufferedReader(new InputStreamReader(JSU.getInputStream(s))));
             } catch (Wrapper e) {
                 throw e.wrapee;
             } catch (XML.Exn e) {
@@ -386,16 +386,17 @@ public final class Ibex extends JS.Obj implements JS.Cloneable {
         }
         // FEATURE: This is a gross hack
         public InputStream getImage() throws JSExn {
-            try {
-                InputStream in = getInputStream();
+            //try {
+                InputStream in = JSU.getInputStream(this);
                 if (in != null) return in;
-            } catch (IOException e) { /* DELIBERATE */ }
+                //} catch (IOException e) { /* DELIBERATE */ }
             String[] exts = new String[] { ".png", ".jpeg", ".gif" };
-            for (int i=0; i < exts.length; i++)
-                try {
-                    InputStream in = parent.get(JSU.S(JSU.toString(parentkey) + exts[i])).getInputStream();
+            for (int i=0; i < exts.length; i++) {
+                //try {
+                in = JSU.getInputStream(parent.get(JSU.S(JSU.toString(parentkey) + exts[i])));
                     if (in != null) return in;
-                } catch (IOException f) { /* DELIBERATE */ }
+                    //} catch (IOException f) { /* DELIBERATE */ }
+            }
             return null;
         }
         public JS getStatic() throws JSExn {
@@ -416,7 +417,8 @@ public final class Ibex extends JS.Obj implements JS.Cloneable {
             for(Blessing b = parent; b.parentkey != null; b = b.parent) s = JSU.str(b.parentkey) + "." + s;
             return s;
         }
-        public JS call(JS[] args) throws JSExn {
+        public JS call(JS method, JS[] args) throws JSExn {
+            if (method != null) return super.call(method, args);
             if (args.length != 1) throw new JSExn("can only call a template with one arg");
             getStatic();
             if (t == null) throw new JSExn("No such template " + JSU.str(parentkey));
@@ -431,7 +433,7 @@ public final class Ibex extends JS.Obj implements JS.Cloneable {
             return t;
         }
         // JS:FIXME: Blessing shouldn't need to roll its own JS.Clone implementation
-        public InputStream getInputStream() throws JSExn, IOException { return clonee.getInputStream(); }
+        //public InputStream getInputStream() throws JSExn, IOException { return clonee.getInputStream(); }
     }
 
 }