Revision: 3109
          http://vexi.svn.sourceforge.net/vexi/?rev=3109&view=rev
Author:   mkpg2
Date:     2008-09-24 16:04:04 +0000 (Wed, 24 Sep 2008)

Log Message:
-----------
Fixes.

Modified Paths:
--------------
    trunk/core/org.ibex.js/src/org/ibex/js/Fountain.java
    trunk/core/org.ibex.js/src/org/ibex/js/JSRegexp.jpp
    trunk/core/org.ibex.js/src/org/ibex/js/JSU.jpp
    trunk/core/org.ibex.js/src/org/vexi/js/VexiJS.jpp
    trunk/core/org.ibex.js/src_dev/org/ibex/js/RunJS.java
    trunk/core/org.ibex.js/src_junit/org/ibex/js/TestFountain.java
    trunk/core/org.ibex.js/src_junit/test/js/exec/string/TestString.java
    trunk/core/org.ibex.js/src_junit/test/js/exec/string/parseInt.js

Added Paths:
-----------
    trunk/core/org.ibex.js/src_junit/test/js/exec/string/replace.js

Modified: trunk/core/org.ibex.js/src/org/ibex/js/Fountain.java
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/Fountain.java        2008-09-24 
16:03:00 UTC (rev 3108)
+++ trunk/core/org.ibex.js/src/org/ibex/js/Fountain.java        2008-09-24 
16:04:04 UTC (rev 3109)
@@ -46,7 +46,7 @@
        static public class NotCacheableException extends Exception { }
 
     // streams are "sealed" by default to prevent accidental object leakage
-    private Cache getCache = new Cache(100, true);
+    private Cache getCache = new Cache(100);
 
     public final JS get(JS key) throws JSExn {
         JS ret = (JS)getCache.get(key);
@@ -235,7 +235,9 @@
         private byte[] bytes;
         private int suggested;
         public ByteArray(byte[] bytes) { this.bytes = bytes; suggested = 
bytes.length; }
-        public ByteArray(int suggested) { this.suggested = suggested; }
+        public ByteArray(JS suggested) throws JSExn { 
+               this.suggested = suggested==null?8192:JSU.toInt(suggested);
+        }
         public InputStream _getInputStream() throws IOException { return new 
ByteArrayInputStream(bytes); }
         public OutputStream getOutputStream() throws IOException {
                return new ByteArrayOutputStream(suggested){

Modified: trunk/core/org.ibex.js/src/org/ibex/js/JSRegexp.jpp
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/JSRegexp.jpp 2008-09-24 16:03:00 UTC 
(rev 3108)
+++ trunk/core/org.ibex.js/src/org/ibex/js/JSRegexp.jpp 2008-09-24 16:04:04 UTC 
(rev 3109)
@@ -171,7 +171,8 @@
     }
     
     static JS stringReplace(JS o, JS arg0, JS arg1) throws JSExn {
-        String s = JSU.toString(o);
+
+       String s = JSU.toString(o);
         GnuRegexp.RE re;
         JSFunction replaceFunc = null;
         String replaceString = null;

Modified: trunk/core/org.ibex.js/src/org/ibex/js/JSU.jpp
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/JSU.jpp      2008-09-24 16:03:00 UTC 
(rev 3108)
+++ trunk/core/org.ibex.js/src/org/ibex/js/JSU.jpp      2008-09-24 16:04:04 UTC 
(rev 3109)
@@ -216,9 +216,10 @@
     // 6, 8 
     
     final static public void checkArgs(JS[] args, int[] types) throws JSExn{
-        if(args.length>types.length) throw new JSExn("too many args, expected 
"+args.length+", got " + types.length);
-       for(int i=0; i<args.length; i++){
-            JS arg = args[i]; int type = types[i];
+        if(args.length>types.length) throw new JSExn("too many args, expected 
"+types.length+", got " + args.length);
+       for(int i=0; i<types.length; i++){
+            JS arg = i>=args.length?null:args[i]; 
+            int type = types[i];
             
             if(arg==null){ 
                 if((type & NULL)==0) throw new JSExn("Arg " + i + " cannot be 
null");

Modified: trunk/core/org.ibex.js/src/org/vexi/js/VexiJS.jpp
===================================================================
--- trunk/core/org.ibex.js/src/org/vexi/js/VexiJS.jpp   2008-09-24 16:03:00 UTC 
(rev 3108)
+++ trunk/core/org.ibex.js/src/org/vexi/js/VexiJS.jpp   2008-09-24 16:04:04 UTC 
(rev 3109)
@@ -157,7 +157,7 @@
         }
         public JS call(JS method, JS[] args) throws JSExn {
                //#switch(JSU.toString(method))
-               case "buffer": return new 
Fountain.ByteArray(args.length>0?JSU.toInt(args[0]):8192);
+               case "buffer": return new 
Fountain.ByteArray(args.length>0?args[0]:null);
                case "multiple": return Fountain.multiple(args);
                //#end
                
@@ -204,7 +204,7 @@
                        JSU.checkArgs(args, ARGTYPES_post);
                        String url = JSU.toString(args[0]);
                        Fountain in = JSU.getFountain(args[1]);
-                       return new 
Fountain.ByteArray(args.length>0?JSU.toInt(args[0]):8192);
+                       return new 
Fountain.ByteArray(args.length>0?args[0]:null);
                //#end
                
                switch(args.length) {
@@ -299,8 +299,10 @@
        Fountain f = (Fountain)args[0];
        final BufferedReader r;
        try {
+               InputStream is = f.getInputStream();
+               if(is==null) is = new ByteArrayInputStream(new byte[0]);
                        r = new BufferedReader(
-                                       new 
InputStreamReader(f.getInputStream(), "UTF8"));
+                                       new InputStreamReader(is, "UTF8"));
                } catch (UnsupportedEncodingException e) {
                        throw new Error("UF8 not available!");
                } catch (IOException e) {

Modified: trunk/core/org.ibex.js/src_dev/org/ibex/js/RunJS.java
===================================================================
--- trunk/core/org.ibex.js/src_dev/org/ibex/js/RunJS.java       2008-09-24 
16:03:00 UTC (rev 3108)
+++ trunk/core/org.ibex.js/src_dev/org/ibex/js/RunJS.java       2008-09-24 
16:04:04 UTC (rev 3109)
@@ -254,7 +254,7 @@
                                }
                            }
                            
-                           private Cache subCache = new Cache(20, true);
+                           private Cache subCache = new Cache(20);
                            private Sub getSub(JS key) {
                                Sub ret = (Sub)subCache.get(key);
                                if (ret == null) subCache.put(key, ret = new 
Sub(key));

Modified: trunk/core/org.ibex.js/src_junit/org/ibex/js/TestFountain.java
===================================================================
--- trunk/core/org.ibex.js/src_junit/org/ibex/js/TestFountain.java      
2008-09-24 16:03:00 UTC (rev 3108)
+++ trunk/core/org.ibex.js/src_junit/org/ibex/js/TestFountain.java      
2008-09-24 16:04:04 UTC (rev 3109)
@@ -11,8 +11,8 @@
        
        public void testPipe() throws JSExn, IOException{
                
-               Fountain a = new Fountain.ByteArray(null);
-               Fountain b = new Fountain.ByteArray(null);
+               Fountain a = new Fountain.ByteArray((JS)null);
+               Fountain b = new Fountain.ByteArray((JS)null);
                Fountain.writeUTF8(new JS[]{a,JSU.S("sausage")});
                IOUtil.pipe(a.getInputStream(), b.getOutputStream());
                String s = JSU.toString(Fountain.parseUTF8(new JS[]{b}));

Modified: trunk/core/org.ibex.js/src_junit/test/js/exec/string/TestString.java
===================================================================
--- trunk/core/org.ibex.js/src_junit/test/js/exec/string/TestString.java        
2008-09-24 16:03:00 UTC (rev 3108)
+++ trunk/core/org.ibex.js/src_junit/test/js/exec/string/TestString.java        
2008-09-24 16:04:04 UTC (rev 3109)
@@ -10,7 +10,7 @@
 
     public static void main(String[] args) throws Throwable {
        JSTestSuite jts = new JSTestSuite(TestString.class);
-       String SCRIPT = "parseInt.js";
+       String SCRIPT = "replace.js";
        //String SCRIPT = "testNumber2String.js";
        TestCase t = jts.createTestCase(jts.getResourceDirs(), SCRIPT);
        t.runBare();

Modified: trunk/core/org.ibex.js/src_junit/test/js/exec/string/parseInt.js
===================================================================
--- trunk/core/org.ibex.js/src_junit/test/js/exec/string/parseInt.js    
2008-09-24 16:03:00 UTC (rev 3108)
+++ trunk/core/org.ibex.js/src_junit/test/js/exec/string/parseInt.js    
2008-09-24 16:04:04 UTC (rev 3109)
@@ -1,5 +1,4 @@
 sys.import("lib");
-sys.import("shared");
 
 var foo = "00";
 var bar = sys.string.parseInt(foo);

Added: trunk/core/org.ibex.js/src_junit/test/js/exec/string/replace.js
===================================================================
--- trunk/core/org.ibex.js/src_junit/test/js/exec/string/replace.js             
                (rev 0)
+++ trunk/core/org.ibex.js/src_junit/test/js/exec/string/replace.js     
2008-09-24 16:04:04 UTC (rev 3109)
@@ -0,0 +1,6 @@
+sys.import("lib");
+
+var foo = "a  sentance with  spaces";
+var bar = foo.replace("  "," ");
+sys.log.info(bar);
+assertEquals("a sentance with  spaces", bar);
\ No newline at end of file


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to