File tree 7 files changed +78
-12
lines changed
7 files changed +78
-12
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
- clojure -A:test -m kaocha.runner " $@ "
2
+ clojure -A:test:sci -m kaocha.runner " $@ "
Original file line number Diff line number Diff line change 27
27
com.clojure-goes-fast/clj-async-profiler {:mvn/version " 0.4.1" }}
28
28
:jvm-opts [" -server"
29
29
" -Xmx4096m"
30
- " -Dclojure.compiler.direct-linking=true" ]}}
30
+ " -Dclojure.compiler.direct-linking=true" ]}
31
+ :sci {:extra-deps {borkdude/sci {:git/url " https://github.com/borkdude/sci"
32
+ :sha " eb97e01a5913fb81859da814ba55a25b807dd6cc" }}}}
31
33
:deps {org.clojure/clojure {:mvn/version " 1.10.1" }
32
- borkdude/sci {:git/url " https://github.com/borkdude/sci"
33
- :sha " eb97e01a5913fb81859da814ba55a25b807dd6cc" }
34
34
borkdude/edamame {:mvn/version " 0.0.11-alpha.12" }
35
35
org.clojure/test.check {:mvn/version " 1.0.0" }
36
36
com.gfredericks/test.chuck {:mvn/version " 0.2.10" }}}
Original file line number Diff line number Diff line change 1
1
(ns malli.core
2
2
(:refer-clojure :exclude [eval type])
3
- (:require [sci.core :as sci]
4
- [malli.registry :as mr])
3
+ (:require [malli.registry :as mr]
4
+ #?(:clj [malli.impl.clj.dynaload :as dynaload]
5
+ :cljs [malli.impl.cljs.dynaload :as dynaload]))
5
6
#? (:clj (:import (java.util.regex Pattern))))
6
7
7
8
; ;
909
910
(-map-entries schema)))))
910
911
911
912
(defn ^:no-doc eval [?code]
912
- (if (fn? ?code) ?code (sci/eval-string (str ?code) {:preset :termination-safe
913
- :bindings {'m/properties properties
914
- 'm/type type
915
- 'm/children children
916
- 'm/map-entries map-entries}})))
913
+ (if (fn? ?code) ?code (@dynaload/eval-string
914
+ (str ?code) {:preset :termination-safe
915
+ :bindings {'m/properties properties
916
+ 'm/type type
917
+ 'm/children children
918
+ 'm/map-entries map-entries}})))
917
919
; ;
918
920
; ; Visitors
919
921
; ;
Original file line number Diff line number Diff line change
1
+ (ns malli.impl.clj.dynaload
2
+ {:no-doc true })
3
+
4
+ (defonce ^:private dynalock (Object. ))
5
+
6
+ (defmacro ^:private locking2
7
+ " Executes exprs in an implicit do, while holding the monitor of x.
8
+ Will release the monitor of x in all circumstances."
9
+ {:added " 1.0" }
10
+ [x & body]
11
+ `(let [lockee# ~x]
12
+ (try
13
+ (let [locklocal# lockee#]
14
+ (monitor-enter locklocal#)
15
+ (try
16
+ ~@body
17
+ (finally
18
+ (monitor-exit locklocal#)))))))
19
+
20
+ (defn dynaload
21
+ [s]
22
+ (delay
23
+ (let [ns (namespace s)]
24
+ (assert ns )
25
+ (locking2 dynalock
26
+ (require (symbol ns )))
27
+ (let [v (resolve s)]
28
+ (if v
29
+ @v
30
+ (throw (RuntimeException. (str " Var " s " is not on the classpath" ))))))))
31
+
32
+ (def eval-string
33
+ (dynaload 'sci.core/eval-string))
Original file line number Diff line number Diff line change
1
+ (ns malli.impl.cljs.dynaload )
2
+
3
+ (defmacro dynaload [[_quote s]]
4
+ `(LazyVar.
5
+ (fn []
6
+ (if (cljs.core/exists? ~s)
7
+ ~(vary-meta s assoc :cljs.analyzer/no-resolve true )
8
+ (throw
9
+ (js/Error.
10
+ (str " Var " '~s " does not exist, "
11
+ (namespace '~s) " never required" )))))
12
+ nil ))
Original file line number Diff line number Diff line change
1
+ (ns malli.impl.cljs.dynaload
2
+ {:no-doc true }
3
+ (:require-macros
4
+ [malli.impl.cljs.dynaload :refer [dynaload]]))
5
+
6
+ (deftype LazyVar [f ^:mutable cached]
7
+ IDeref
8
+ (-deref [this]
9
+ (if-not (nil? cached)
10
+ cached
11
+ (let [x (f )]
12
+ (when-not (nil? x)
13
+ (set! cached x))
14
+ x))))
15
+
16
+ (def eval-string
17
+ (dynaload 'sci.core/eval-string))
Original file line number Diff line number Diff line change 3
3
[malli.core :as m]
4
4
[malli.edn :as me]
5
5
[malli.transform :as mt]
6
- [malli.util :as mu]))
6
+ [malli.util :as mu]
7
+ ; ; TODO: separate tests for sci
8
+ [sci.core]))
7
9
8
10
(defn with-schema-forms [result]
9
11
(some-> result
You can’t perform that action at this time.
0 commit comments