[#600] Support for reifying java.nio.file.FileVisitor

This commit is contained in:
Michiel Borkent 2020-09-30 15:37:29 +02:00
parent e54329d2a3
commit 4a45cd3fd7
3 changed files with 26 additions and 12 deletions

2
sci

@ -1 +1 @@
Subproject commit a7f8d05f08ab150621c2403dacdd57c47ea09ff4 Subproject commit 17f03e8f73b08fbf30d870ceb23be0d7945f1d58

View file

@ -149,7 +149,9 @@
java.nio.file.FileAlreadyExistsException java.nio.file.FileAlreadyExistsException
java.nio.file.FileSystem java.nio.file.FileSystem
java.nio.file.FileSystems java.nio.file.FileSystems
java.nio.file.FileVisitor
java.nio.file.FileVisitOption java.nio.file.FileVisitOption
java.nio.file.FileVisitResult
java.nio.file.Files java.nio.file.Files
java.nio.file.LinkOption java.nio.file.LinkOption
java.nio.file.NoSuchFileException java.nio.file.NoSuchFileException

View file

@ -434,6 +434,17 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that
Thread java.lang.Thread Thread java.lang.Thread
Throwable java.lang.Throwable}) Throwable java.lang.Throwable})
(def reify-opts
{'java.nio.file.FileVisitor
(fn [{:keys [:methods]}]
{:object (reify java.nio.file.FileVisitor
(preVisitDirectory [this p attrs]
((get methods 'preVisitDirectory) this p attrs))
(postVisitDirectory [this p attrs]
((get methods 'postVisitDirectory) this p attrs))
(visitFile [this p attrs]
((get methods 'visitFile) this p attrs)))})})
(def input-var (sci/new-dynamic-var '*input* nil)) (def input-var (sci/new-dynamic-var '*input* nil))
(def edn-readers (cond-> {} (def edn-readers (cond-> {}
features/yaml? features/yaml?
@ -546,7 +557,8 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that
:imports imports :imports imports
:load-fn load-fn :load-fn load-fn
:uberscript uberscript :uberscript uberscript
:readers core/data-readers} :readers core/data-readers
:reify reify-opts}
opts (addons/future opts) opts (addons/future opts)
sci-ctx (sci/init opts) sci-ctx (sci/init opts)
_ (vreset! common/ctx sci-ctx) _ (vreset! common/ctx sci-ctx)