[#600] Support for reifying java.nio.file.FileVisitor
This commit is contained in:
parent
e54329d2a3
commit
4a45cd3fd7
3 changed files with 26 additions and 12 deletions
2
sci
2
sci
|
|
@ -1 +1 @@
|
||||||
Subproject commit a7f8d05f08ab150621c2403dacdd57c47ea09ff4
|
Subproject commit 17f03e8f73b08fbf30d870ceb23be0d7945f1d58
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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?
|
||||||
|
|
@ -500,7 +511,7 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that
|
||||||
(add-classpath* jar))
|
(add-classpath* jar))
|
||||||
load-fn (fn [{:keys [:namespace :reload]}]
|
load-fn (fn [{:keys [:namespace :reload]}]
|
||||||
(when-let [{:keys [:loader]}
|
(when-let [{:keys [:loader]}
|
||||||
@cp-state]
|
@cp-state]
|
||||||
(if ;; ignore built-in namespaces when uberscripting, unless with :reload
|
(if ;; ignore built-in namespaces when uberscripting, unless with :reload
|
||||||
(and uberscript
|
(and uberscript
|
||||||
(not reload)
|
(not reload)
|
||||||
|
|
@ -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)
|
||||||
|
|
@ -558,9 +570,9 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that
|
||||||
file (try [[(read-file file)] nil]
|
file (try [[(read-file file)] nil]
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
(error-handler e {:expression expressions
|
(error-handler e {:expression expressions
|
||||||
:verbose? verbose?
|
:verbose? verbose?
|
||||||
:preloads preloads
|
:preloads preloads
|
||||||
:loader (:loader @cp-state)}))))
|
:loader (:loader @cp-state)}))))
|
||||||
expression (str/join " " expressions) ;; this might mess with the locations...
|
expression (str/join " " expressions) ;; this might mess with the locations...
|
||||||
exit-code
|
exit-code
|
||||||
;; handle preloads
|
;; handle preloads
|
||||||
|
|
@ -571,9 +583,9 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that
|
||||||
(sci/eval-string* sci-ctx preloads)
|
(sci/eval-string* sci-ctx preloads)
|
||||||
(catch Throwable e
|
(catch Throwable e
|
||||||
(error-handler e {:expression expression
|
(error-handler e {:expression expression
|
||||||
:verbose? verbose?
|
:verbose? verbose?
|
||||||
:preloads preloads
|
:preloads preloads
|
||||||
:loader (:loader @cp-state)})))))
|
:loader (:loader @cp-state)})))))
|
||||||
nil))
|
nil))
|
||||||
exit-code
|
exit-code
|
||||||
(or exit-code
|
(or exit-code
|
||||||
|
|
@ -613,9 +625,9 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that
|
||||||
res)))))
|
res)))))
|
||||||
(catch Throwable e
|
(catch Throwable e
|
||||||
(error-handler e {:expression expression
|
(error-handler e {:expression expression
|
||||||
:verbose? verbose?
|
:verbose? verbose?
|
||||||
:preloads preloads
|
:preloads preloads
|
||||||
:loader (:loader @cp-state)}))))
|
:loader (:loader @cp-state)}))))
|
||||||
uberscript [nil 0]
|
uberscript [nil 0]
|
||||||
:else [(repl/start-repl! sci-ctx) 0]))
|
:else [(repl/start-repl! sci-ctx) 0]))
|
||||||
1)]
|
1)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue