[Swift-commit] r5256 - branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript

wozniak at ci.uchicago.edu wozniak at ci.uchicago.edu
Sat Oct 22 21:06:35 CDT 2011


Author: wozniak
Date: 2011-10-22 21:06:35 -0500 (Sat, 22 Oct 2011)
New Revision: 5256

Modified:
   branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java
   branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java
   branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java
Log:
Multiple toString/getValue fixes


Modified: branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java
===================================================================
--- branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java	2011-10-23 02:06:03 UTC (rev 5255)
+++ branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java	2011-10-23 02:06:35 UTC (rev 5256)
@@ -1,6 +1,6 @@
 package org.griphyn.vdl.karajan.lib.swiftscript;
 
-import org.apache.log4j.Logger;
+// import org.apache.log4j.Logger;
 import org.globus.cog.karajan.arguments.Arg;
 import org.globus.cog.karajan.stack.VariableStack;
 import org.globus.cog.karajan.workflow.ExecutionException;
@@ -16,8 +16,8 @@
  */
 public class Assert extends VDLFunction {
 
-    private static final Logger logger = 
-        Logger.getLogger(Assert.class);
+    //    private static final Logger logger = 
+    //    Logger.getLogger(Assert.class);
     
     static {
         setArguments(Assert.class, new Arg[] { Arg.VARGS });
@@ -31,7 +31,7 @@
         
         if (args.length == 2)
             if (args[1].getType() == Types.STRING)
-                message = args[1].toString();
+                message = (String) args[1].getValue();
             else
                 throw new ExecutionException
                 ("Second argument to assert() must be a String!");

Modified: branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java
===================================================================
--- branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java	2011-10-23 02:06:03 UTC (rev 5255)
+++ branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java	2011-10-23 02:06:35 UTC (rev 5256)
@@ -39,8 +39,8 @@
         
         check(args);
         
-        String filename = args[0].toString();
-        String spec = args[1].toString(); 
+        String filename = (String) args[0].getValue();
+        String spec = (String) args[1].getValue(); 
         DSHandle[] vars = Sprintf.copyArray(args, 2, args.length-2);
         
         StringBuilder output = new StringBuilder();
@@ -59,10 +59,10 @@
             ("fprintf(): requires at least 2 arguments!");
         if (! args[0].getType().equals(Types.STRING))
             throw new ExecutionException
-            ("fprintf(): first argument is a string filename!");
+            ("fprintf(): first argument must be a string filename!");
         if (! args[0].getType().equals(Types.STRING))
             throw new ExecutionException
-            ("fprintf(): second argument is a string specifier!");
+            ("fprintf(): second argument must be a string specifier!");
     }
     
     private static void write(String filename, String msg) 

Modified: branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java
===================================================================
--- branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java	2011-10-23 02:06:03 UTC (rev 5255)
+++ branches/release-0.93/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java	2011-10-23 02:06:35 UTC (rev 5256)
@@ -23,6 +23,7 @@
       %%: % sign. <br>
       %M: Filename output: waits for close
       %p: Not typechecked, output as in trace(). <br>
+      %b: Typechecked boolean output. <br>
       %f: Typechecked float output. <br>
       %i: Typechecked int output. <br>
       %s: Typechecked string output. <br>
@@ -119,6 +120,9 @@
         if (c == 'M') {
             append_M(vars[arg], output);
         }
+        else if (c == 'b') { 
+            append_b(vars[arg], output);
+        }
         else if (c == 'f') {
             append_f(vars[arg], output);
         }
@@ -161,6 +165,17 @@
         }
     }
     
+    private static void append_b(DSHandle arg, StringBuilder output) 
+    throws ExecutionException {
+        if (arg.getType() == Types.BOOLEAN) {
+            output.append(arg.getValue());
+        }
+        else {
+            throw new ExecutionException
+            ("tracef(): %b requires a boolean!");
+        }
+    }
+    
     private static void append_f(DSHandle arg, StringBuilder output) 
     throws ExecutionException {
         if (arg.getType() == Types.FLOAT) {




More information about the Swift-commit mailing list