This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] coerce Blobs to Paths


I discovered that (path (->string &sh{cd /tmp;pwd})) fails:

> #|kawa:1|# (path (->string &sh{cd;pwd}))
> Value '/tmp
> ' has wrong type (gnu.lists.Blob) (expected: path)
> 	at gnu.text.Path.valueOf(Path.java:84)
> 	at atInteractiveLevel$1.run(stdin:1)
> 	at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:314)
> 	at gnu.expr.ModuleExp.evalModule(ModuleExp.java:215)
> 	at kawa.Shell.run(Shell.java:281)
> 	at kawa.Shell.run(Shell.java:196)
> 	at kawa.Shell.run(Shell.java:177)
> 	at kawa.repl.main(repl.java:877)

but (path (->String &sh{cd /tmp;pwd})) works:

> #|kawa:2|# (path (->String &sh{cd;pwd}))
> /tmp

The Path coercion methods do not recognize the new gnu.lists.Blob.

The attached patch updates Path#coerceToPathOrNull,
FilePath#coerceToFilePathOrNull, and URIPath#coerceToURIPathOrNull
to accept CharSequence (which includes Blob).

This supersedes the special handling of FString.  I also rearranged
the tests there to handle String first to make sure those just get a
cast and not a call to String#toString which would be silly.

I didn't implement the "FIXME: || UntypedAtomic" part, sorry.

--
Jamison Hope
The PTR Group
www.theptrgroup.com


Attachment: path-coerce-blob.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]