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

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Wed Jun 30 17:31:37 CDT 2010


Author: wozniak
Date: 2010-06-30 17:31:37 -0500 (Wed, 30 Jun 2010)
New Revision: 3419

Modified:
   trunk/src/org/griphyn/vdl/engine/ProcedureSignature.java
   trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
   trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
Log:
New @dirname() 


Modified: trunk/src/org/griphyn/vdl/engine/ProcedureSignature.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/ProcedureSignature.java	2010-06-30 05:37:34 UTC (rev 3418)
+++ trunk/src/org/griphyn/vdl/engine/ProcedureSignature.java	2010-06-30 22:31:37 UTC (rev 3419)
@@ -180,14 +180,21 @@
 		FormalArgumentSignature filenameOut1 = new FormalArgumentSignature("string");
 		filename.addOutputArg(filenameOut1);
 		functionsMap.put(filename.getName(), filename);
-		
+                
 		ProcedureSignature filenames = new ProcedureSignature("filenames");
 		FormalArgumentSignature filenamesIn1 = new FormalArgumentSignature(true); /* file can be specified as any type */
 		filenames.addInputArg(filenamesIn1);
 		FormalArgumentSignature filenamesOut1 = new FormalArgumentSignature("string[]"); /* i think this is what it returns */
 		filenames.addOutputArg(filenamesOut1);
 		functionsMap.put(filenames.getName(), filenames);
-		
+
+                ProcedureSignature dirname = new ProcedureSignature("dirname");
+		FormalArgumentSignature dirnameIn1 = new FormalArgumentSignature(true); /* dir can be specified as any type */
+		dirname.addInputArg(dirnameIn1);
+		FormalArgumentSignature dirnameOut1 = new FormalArgumentSignature("string");
+		dirname.addOutputArg(dirnameOut1);
+		functionsMap.put(dirname.getName(), dirname);
+                
 		ProcedureSignature regexp = new ProcedureSignature("regexp");
 		FormalArgumentSignature regexpIn1 = new FormalArgumentSignature("string");
 		regexp.addInputArg(regexpIn1);

Modified: trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java	2010-06-30 05:37:34 UTC (rev 3418)
+++ trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java	2010-06-30 22:31:37 UTC (rev 3419)
@@ -175,7 +175,7 @@
 
 	public static final String[] EMPTY_STRING_ARRAY = new String[0];
 
-	public String[] filename(VariableStack stack) throws ExecutionException {
+	public static String[] filename(VariableStack stack) throws ExecutionException {
 		DSHandle ovar = (DSHandle)PA_VAR.getValue(stack);
 		synchronized(ovar.getRoot()) {
 			try {
@@ -475,7 +475,7 @@
 		}
 	}
 
-	protected static Future addFutureListener(VariableStack stack, DSHandle handle)
+        public static Future addFutureListener(VariableStack stack, DSHandle handle)
 			throws ExecutionException {
 		assert Thread.holdsLock(handle.getRoot());
 		return getFutureWrapperMap(stack).addNodeListener(handle);

Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java	2010-06-30 05:37:34 UTC (rev 3418)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java	2010-06-30 22:31:37 UTC (rev 3419)
@@ -11,6 +11,7 @@
 import org.globus.cog.karajan.util.TypeUtil;
 import org.globus.cog.karajan.workflow.ExecutionException;
 import org.globus.cog.karajan.workflow.nodes.functions.FunctionsCollection;
+import org.griphyn.vdl.karajan.lib.PathUtils;
 import org.griphyn.vdl.karajan.lib.SwiftArg;
 import org.griphyn.vdl.karajan.lib.VDLFunction;
 import org.griphyn.vdl.mapping.DSHandle;
@@ -24,6 +25,9 @@
 import org.griphyn.vdl.type.Types;
 import org.griphyn.vdl.util.VDL2Config;
 
+import org.griphyn.vdl.mapping.AbsFile;
+import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
+
 public class Misc extends FunctionsCollection {
 
 	private static final Logger logger = Logger.getLogger(Misc.class);
@@ -37,11 +41,12 @@
 		setArguments("swiftscript_tracef", new Arg[] { Arg.VARGS });
 		setArguments("swiftscript_strcat", new Arg[] { Arg.VARGS });
 		setArguments("swiftscript_strcut", new Arg[] { PA_INPUT, PA_PATTERN });
-        setArguments("swiftscript_strstr", new Arg[] { PA_INPUT, PA_PATTERN });
+                setArguments("swiftscript_strstr", new Arg[] { PA_INPUT, PA_PATTERN });
 		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 });
+                setArguments("swiftscript_dirname", new Arg[] { Arg.VARGS });
 	}
 
 	private static final Logger traceLogger = Logger.getLogger("org.globus.swift.trace");
@@ -362,12 +367,42 @@
 		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;
+	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;
 	}
+
+        public DSHandle swiftscript_dirname(VariableStack stack) 
+                throws ExecutionException, NoSuchTypeException, InvalidPathException {
+                DSHandle handle;
+                try
+                {
+                        DSHandle[] args = SwiftArg.VARGS.asDSHandleArray(stack);
+                        DSHandle arg = args[0];
+                        String[] input = VDLFunction.filename(arg);
+                        String name = input[0]; 
+                        String result = new AbsFile(name).getDir();
+                        handle = new RootDataNode(Types.STRING);
+                        handle.setValue(result);
+                        handle.closeShallow();
+                }
+                catch (HandleOpenException e) {
+                        throw new FutureNotYetAvailable
+                                (VDLFunction.addFutureListener(stack, e.getSource()));
+                }
+                return handle;
+        }
 }
+
+/*
+ * Local Variables:
+ *  c-basic-offset: 8
+ * End:
+ *
+ * vim: ft=c ts=8 sts=4 sw=4 expandtab
+ */




More information about the Swift-commit mailing list