[Swift-commit] r3264 - in trunk: libexec src/org/griphyn/vdl/engine src/org/griphyn/vdl/karajan/lib/swiftscript

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Thu Mar 18 14:05:32 CDT 2010


Author: wozniak
Date: 2010-03-18 14:05:32 -0500 (Thu, 18 Mar 2010)
New Revision: 3264

Modified:
   trunk/libexec/vdl-lib.xml
   trunk/src/org/griphyn/vdl/engine/ProcedureSignature.java
   trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
Log:
New @tostring(). 


Modified: trunk/libexec/vdl-lib.xml
===================================================================
--- trunk/libexec/vdl-lib.xml	2010-03-18 18:21:11 UTC (rev 3263)
+++ trunk/libexec/vdl-lib.xml	2010-03-18 19:05:32 UTC (rev 3264)
@@ -12,6 +12,7 @@
 	<export name="strsplit"><elementDef classname="org.griphyn.vdl.karajan.lib.swiftscript.Misc"/></export>
 	<export name="regexp"><elementDef classname="org.griphyn.vdl.karajan.lib.swiftscript.Misc"/></export>
 	<export name="toint"><elementDef classname="org.griphyn.vdl.karajan.lib.swiftscript.Misc"/></export>
+	<export name="tostring"><elementDef classname="org.griphyn.vdl.karajan.lib.swiftscript.Misc"/></export>
 	<export name="trace"><elementDef classname="org.griphyn.vdl.karajan.lib.swiftscript.Misc"/></export>
 	<export name="tracef"><elementDef classname="org.griphyn.vdl.karajan.lib.swiftscript.Misc"/></export>
 	<export name="java"><elementDef classname="org.griphyn.vdl.karajan.lib.swiftscript.Java"/></export>

Modified: trunk/src/org/griphyn/vdl/engine/ProcedureSignature.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/ProcedureSignature.java	2010-03-18 18:21:11 UTC (rev 3263)
+++ trunk/src/org/griphyn/vdl/engine/ProcedureSignature.java	2010-03-18 19:05:32 UTC (rev 3264)
@@ -214,7 +214,7 @@
 		strcut.addOutputArg(strcutOut1);
 		functionsMap.put(strcut.getName(), strcut);
 
-                ProcedureSignature strstr = new ProcedureSignature("strstr");
+		ProcedureSignature strstr = new ProcedureSignature("strstr");
 		FormalArgumentSignature strstrIn1 = new FormalArgumentSignature("string");
 		strstr.addInputArg(strstrIn1);
 		FormalArgumentSignature strstrIn2 = new FormalArgumentSignature("string");
@@ -224,13 +224,13 @@
 		functionsMap.put(strstr.getName(), strstr);
                 
 		ProcedureSignature strsplit = new ProcedureSignature("strsplit");
-                FormalArgumentSignature strsplitIn1 = new FormalArgumentSignature("string");
-                strsplit.addInputArg(strsplitIn1);
-                FormalArgumentSignature strsplitIn2 = new FormalArgumentSignature("string");
-                strsplit.addInputArg(strsplitIn2);
-                FormalArgumentSignature strsplitOut1 = new FormalArgumentSignature("string[]");
-                strsplit.addOutputArg(strsplitOut1);
-                functionsMap.put(strsplit.getName(), strsplit);
+		FormalArgumentSignature strsplitIn1 = new FormalArgumentSignature("string");
+		strsplit.addInputArg(strsplitIn1);
+		FormalArgumentSignature strsplitIn2 = new FormalArgumentSignature("string");
+		strsplit.addInputArg(strsplitIn2);
+		FormalArgumentSignature strsplitOut1 = new FormalArgumentSignature("string[]");
+		strsplit.addOutputArg(strsplitOut1);
+		functionsMap.put(strsplit.getName(), strsplit);
 		
 		ProcedureSignature toint = new ProcedureSignature("toint");
 		FormalArgumentSignature tointIn1 = new FormalArgumentSignature("string");
@@ -239,6 +239,13 @@
 		toint.addOutputArg(toOut1);
 		functionsMap.put(toint.getName(), toint);
 		
+		ProcedureSignature tostring = new ProcedureSignature("tostring");
+		FormalArgumentSignature tostringIn1 = new FormalArgumentSignature(true);
+		tostring.addInputArg(tostringIn1);
+		FormalArgumentSignature tostringOut1 = new FormalArgumentSignature("string");
+		tostring.addOutputArg(tostringOut1);
+		functionsMap.put(tostring.getName(), tostring);
+		
 		ProcedureSignature java = new ProcedureSignature("java");
 		java.setAnyNumOfInputArgs();
 		FormalArgumentSignature output = new FormalArgumentSignature("java");

Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java	2010-03-18 18:21:11 UTC (rev 3263)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java	2010-03-18 19:05:32 UTC (rev 3264)
@@ -2,9 +2,6 @@
 
 import java.io.IOException;
 
-import java.util.Collection;
-import java.util.List;
-import java.util.Stack;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -44,6 +41,7 @@
 		setArguments("swiftscript_strsplit", new Arg[] { PA_INPUT, PA_PATTERN });
 		setArguments("swiftscript_regexp", new Arg[] { PA_INPUT, PA_PATTERN, PA_TRANSFORM });
 		setArguments("swiftscript_toint", new Arg[] { PA_INPUT });
+		setArguments("swiftscript_tostring", new Arg[] { PA_INPUT });
 	}
 
 	private static final Logger traceLogger = Logger.getLogger("org.globus.swift.trace");
@@ -174,20 +172,19 @@
 	            ArrayDataNode node = (ArrayDataNode) args[arg];
 	            output.append("[");
 	            try {
-	                Stack stack = new Stack();
-                    Collection children = args[arg].getFields(Path.CHILDREN);
-                    for (Object o : children) 
-                        stack.push(o);
-                    while (!stack.empty()) {
-                        DSHandle child = (DSHandle) stack.pop();
-                        output.append(child);
-                        if (!stack.empty())
-                            output.append(",");
-                    }
+	                int size = node.size();
+	                for (int i = 0; i < size; i++) {
+	                    String entry = ""+i; 
+	                    DSHandle handle = node.getField(Path.parse(entry));
+	                    output.append(handle);
+	                    if (i < size-1)
+	                        output.append(",");
+	                }
+	            }
+	            catch (Exception e) {
+	                e.printStackTrace();
+	                throw new ExecutionException("trace(%q): Could not get children of: " + args[arg]);
                 }
-                catch (Exception e) {
-                    throw new ExecutionException("trace(%q): Could not get children of: " + args[arg]);
-                }
                 output.append("]");
 	        }
 	        else {
@@ -364,4 +361,13 @@
 		VDLFunction.logProvenanceParameter(provid, PA_INPUT.getRawValue(stack), "string");
 		return handle;
 	}
+	
+	public DSHandle swiftscript_tostring(VariableStack stack) throws ExecutionException, NoSuchTypeException,
+	InvalidPathException {
+	    Object input = PA_INPUT.getValue(stack);
+	    DSHandle handle = new RootDataNode(Types.STRING);
+	    handle.setValue(""+input);
+	    handle.closeShallow();
+	    return handle;
+	}
 }




More information about the Swift-commit mailing list