[Swift-devel] Re: simple_mapper auto-padding of "."
Allan Espinosa
aespinosa at cs.uchicago.edu
Sat Mar 20 03:31:58 CDT 2010
I'll be getting my cookies now :)
Patch available in
http://www.ci.uchicago.edu/~aespinosa/swift_mapper-noauto.patch
Test cases/ examples in
tests/language-behaviour/T078-simplemapper-nosuffix.swift and
tests/language-behaviour/T078-simplemapper-nosuffix.swift (Did i get
the exception handling practice correctly?)
diff --git a/src/org/griphyn/vdl/mapping/file/AbstractFileMapper.java
b/src/org/griphyn/vdl/mapping/file/AbstractF
index 362cb01..5b7b455 100644
--- a/src/org/griphyn/vdl/mapping/file/AbstractFileMapper.java
+++ b/src/org/griphyn/vdl/mapping/file/AbstractFileMapper.java
@@ -12,6 +12,7 @@ import org.apache.log4j.Logger;
import org.griphyn.vdl.mapping.AbsFile;
import org.griphyn.vdl.mapping.AbstractMapper;
+import org.griphyn.vdl.mapping.InvalidMappingParameterException;
import org.griphyn.vdl.mapping.MappingParam;
import org.griphyn.vdl.mapping.Path;
import org.griphyn.vdl.mapping.PhysicalFormat;
@@ -36,6 +37,8 @@ import org.griphyn.vdl.mapping.PhysicalFormat;
* this string. If suffix does not begin with a '.'
* character, then a '.' will be added automatically to
* separate the rest of the filename from the suffix</li>
+ * <li>noauto - if specified as "true", then the suffix auto
addition of a'.'
+ * will be disabled. Default value is "false".</li>
* <li>pattern - if specified, then filenames will be selected from
* the location directory when they match the unix glob
* pattern supplied in this parameter.</li>
@@ -47,6 +50,7 @@ public abstract class AbstractFileMapper extends
AbstractMapper {
public static final MappingParam PARAM_SUFFIX = new
MappingParam("suffix", null);
public static final MappingParam PARAM_PATTERN = new
MappingParam("pattern", null);
public static final MappingParam PARAM_LOCATION = new
MappingParam("location", null);
+ public static final MappingParam PARAM_NOAUTO = new
MappingParam("noauto", "false");
public static final Logger logger =
Logger.getLogger(AbstractFileMapper.class);
@@ -79,7 +83,12 @@ public abstract class AbstractFileMapper extends
AbstractMapper {
super.setParams(params);
if (PARAM_SUFFIX.isPresent(this)) {
String suffix = PARAM_SUFFIX.getStringValue(this);
- if (!suffix.startsWith(".")) {
+ String noauto = PARAM_NOAUTO.getStringValue(this);
+ if (!noauto.equals("true") && !noauto.equals("false")) {
+ throw new
InvalidMappingParameterException("noauto parameter was set to 'true'
or
+ ". Value set was '" +
noauto + "'");
+ }
+ if (!suffix.startsWith(".") && noauto.equals("false")) {
PARAM_SUFFIX.setValue(this, "." + suffix);
...skipping...
+(messagefile t) write() {
+ app {
+ echo @filename(t) stdout=@filename(t);
+ }
+}
+
+messagefile outfile <simple_mapper;
+ prefix="T078-simplemapper-nosuffix", noauto="true",
+ suffix="_nodot.out">;
+
+outfile = write();
+
diff --git a/tests/language-behaviour/T078-simplemapper-nosuffix_nodot.out.expected
b/tests/language-behaviour/T07
new file mode 100644
index 0000000..4d96d92
--- /dev/null
+++ b/tests/language-behaviour/T078-simplemapper-nosuffix_nodot.out.expected
@@ -0,0 +1 @@
+T078-simplemapper-nosuffix_nodot.out
diff --git a/tests/language-behaviour/T079-simplemapper-nosuffix_exception.swift
b/tests/language-behaviour/T079-s
new file mode 100644
index 0000000..d7223ef
--- /dev/null
+++ b/tests/language-behaviour/T079-simplemapper-nosuffix_exception.swift
@@ -0,0 +1,16 @@
+// this one is like test T078-simplemapper-nosuffix, but demonstrates the
+// mapping exception on invalid values
+type messagefile;
+
+(messagefile t) write() {
+ app {
+ echo @filename(t) stdout=@filename(t);
+ }
+}
+
+messagefile outfile <simple_mapper;
+ prefix="T078-simplemapper-nosuffix", noauto="exception",
+ suffix="_nodot.out">;
+
+outfile = write();
+
[aespinosa at login2 swift]$ git diff master > ~/public_html/
.__acl index.html swift/
adopters_espinosa.pdf jgi_blastp.tar.gz
swiftplot_svg-r2874.patch
bigdata/ jobdirpath.tar.gz
swift_r2846_bgp.patch
blastp/ log
test-20090124-0019-je79k4q4.log
dag.svg MosaStore-v0.8.09.tar.gz
to_jr_and_syrah.ogg
.DS_Store mpi-collective/ top_vanilla.gz
espinosa_swift.tar.gz mtdm/ visual/
falkon/ provider-coaster-cpu_fix.patch workflow.svg
flow.png run4-trace.tgz
[aespinosa at login2 swift]$ git diff master > ~/public_html/mapper_noauto.patch
[aespinosa at login2 swift]$ cat ~/public_html/mapper_noauto.patch
diff --git a/src/org/griphyn/vdl/mapping/file/AbstractFileMapper.java
b/src/org/griphyn/vdl/mapping/file/AbstractFileMapper.java
index 362cb01..5b7b455 100644
--- a/src/org/griphyn/vdl/mapping/file/AbstractFileMapper.java
+++ b/src/org/griphyn/vdl/mapping/file/AbstractFileMapper.java
@@ -12,6 +12,7 @@ import org.apache.log4j.Logger;
import org.griphyn.vdl.mapping.AbsFile;
import org.griphyn.vdl.mapping.AbstractMapper;
+import org.griphyn.vdl.mapping.InvalidMappingParameterException;
import org.griphyn.vdl.mapping.MappingParam;
import org.griphyn.vdl.mapping.Path;
import org.griphyn.vdl.mapping.PhysicalFormat;
@@ -36,6 +37,8 @@ import org.griphyn.vdl.mapping.PhysicalFormat;
* this string. If suffix does not begin with a '.'
* character, then a '.' will be added automatically to
* separate the rest of the filename from the suffix</li>
+ * <li>noauto - if specified as "true", then the suffix auto
addition of a'.'
+ * will be disabled. Default value is "false".</li>
* <li>pattern - if specified, then filenames will be selected from
* the location directory when they match the unix glob
* pattern supplied in this parameter.</li>
@@ -47,6 +50,7 @@ public abstract class AbstractFileMapper extends
AbstractMapper {
public static final MappingParam PARAM_SUFFIX = new
MappingParam("suffix", null);
public static final MappingParam PARAM_PATTERN = new
MappingParam("pattern", null);
public static final MappingParam PARAM_LOCATION = new
MappingParam("location", null);
+ public static final MappingParam PARAM_NOAUTO = new
MappingParam("noauto", "false");
public static final Logger logger =
Logger.getLogger(AbstractFileMapper.class);
@@ -79,7 +83,12 @@ public abstract class AbstractFileMapper extends
AbstractMapper {
super.setParams(params);
if (PARAM_SUFFIX.isPresent(this)) {
String suffix = PARAM_SUFFIX.getStringValue(this);
- if (!suffix.startsWith(".")) {
+ String noauto = PARAM_NOAUTO.getStringValue(this);
+ if (!noauto.equals("true") && !noauto.equals("false")) {
+ throw new InvalidMappingParameterException("noauto parameter was
set to 'true' or 'false'" +
+ ". Value set was '" + noauto + "'");
+ }
+ if (!suffix.startsWith(".") && noauto.equals("false")) {
PARAM_SUFFIX.setValue(this, "." + suffix);
}
}
diff --git a/tests/language-behaviour/T078-simplemapper-nosuffix.swift
b/tests/language-behaviour/T078-simplemapper-nosuffix.swift
new file mode 100644
index 0000000..55c80de
--- /dev/null
+++ b/tests/language-behaviour/T078-simplemapper-nosuffix.swift
@@ -0,0 +1,17 @@
+// this one is like test 073-simplemapper, but doesn't
+// add the missing dot in front of the suffix
+
+type messagefile;
+
+(messagefile t) write() {
+ app {
+ echo @filename(t) stdout=@filename(t);
+ }
+}
+
+messagefile outfile <simple_mapper;
+ prefix="T078-simplemapper-nosuffix", noauto="true",
+ suffix="_nodot.out">;
+
+outfile = write();
+
diff --git a/tests/language-behaviour/T078-simplemapper-nosuffix_nodot.out.expected
b/tests/language-behaviour/T078-simplemapper-nosuffix_nodot.out.expected
new file mode 100644
index 0000000..4d96d92
--- /dev/null
+++ b/tests/language-behaviour/T078-simplemapper-nosuffix_nodot.out.expected
@@ -0,0 +1 @@
+T078-simplemapper-nosuffix_nodot.out
diff --git a/tests/language-behaviour/T079-simplemapper-nosuffix_exception.swift
b/tests/language-behaviour/T079-simplemapper-nosuffix_exception.swift
new file mode 100644
index 0000000..d7223ef
--- /dev/null
+++ b/tests/language-behaviour/T079-simplemapper-nosuffix_exception.swift
@@ -0,0 +1,16 @@
+// this one is like test T078-simplemapper-nosuffix, but demonstrates the
+// mapping exception on invalid values
+type messagefile;
+
+(messagefile t) write() {
+ app {
+ echo @filename(t) stdout=@filename(t);
+ }
+}
+
+messagefile outfile <simple_mapper;
+ prefix="T078-simplemapper-nosuffix", noauto="exception",
+ suffix="_nodot.out">;
+
+outfile = write();
+
Enjoy!
-Allan
2010/3/19 Mihael Hategan <hategan at mcs.anl.gov>:
> On Fri, 2010-03-19 at 12:51 -0500, Allan Espinosa wrote:
>> Never mind.
>>
>> I found the code that does the padding. I'll just comment it out in
>> my Swift build
>
> Or you could add a parameter to do so in exchange for karma or imaginary
> cookies :)
>
>
>
>
--
Allan M. Espinosa <http://amespinosa.wordpress.com>
PhD student, Computer Science
University of Chicago <http://people.cs.uchicago.edu/~aespinosa>
More information about the Swift-devel
mailing list