File tree Expand file tree Collapse file tree 6 files changed +38
-13
lines changed Expand file tree Collapse file tree 6 files changed +38
-13
lines changed Original file line number Diff line number Diff line change 4
4
:url " http://opensource.org/licenses/MIT" }
5
5
:dependencies [[primitive-math " 0.1.5" ]
6
6
[clj-tuple " 0.2.2" ]
7
- [manifold " 0.1.4 " ]]
7
+ [manifold " 0.1.6 " ]]
8
8
:profiles {:dev {:dependencies [[org.clojure/clojure " 1.8.0" ]
9
9
[org.clojure/test.check " 0.9.0" ]
10
10
[codox-md " 0.2.0" :exclusions [org.clojure/clojure]]]}}
Original file line number Diff line number Diff line change 4
4
[clj-tuple :refer [vector]]
5
5
[manifold.stream :as s]
6
6
[byte-streams
7
- [utils :as u]
7
+ [utils :as u :refer [defprotocol+ defrecord+ deftype+] ]
8
8
[protocols :as p]])
9
9
(:import
10
10
[java.util.concurrent
17
17
18
18
(declare pprint-type )
19
19
20
- (deftype Conversion [f ^double cost]
20
+ (deftype+ Conversion [f ^double cost]
21
21
Object
22
22
(equals [_ x]
23
23
(and
27
27
(hashCode [_]
28
28
(bit-xor (System/identityHashCode f) (unchecked-int cost))))
29
29
30
- (deftype Type [wrapper type]
30
+ (deftype+ Type [wrapper type]
31
31
Object
32
32
(equals [_ x]
33
33
(and
88
88
:else
89
89
(= a b)))))
90
90
91
- (defprotocol IConversionGraph
91
+ (defprotocol+ IConversionGraph
92
92
(assoc-conversion [_ src dst f cost])
93
93
(equivalent-targets [_ dst])
94
94
(possible-sources [_])
114
114
:else
115
115
nil ))
116
116
117
- (deftype ConversionGraph [m]
117
+ (deftype+ ConversionGraph [m]
118
118
IConversionGraph
119
119
(assoc-conversion [_ src dst f cost]
120
120
(let [m' (assoc-in m [src dst] (Conversion. f cost))
156
156
157
157
; ;;
158
158
159
- (defrecord ConversionPath [path fns visited? cost]
159
+ (defrecord+ ConversionPath [path fns visited? cost]
160
160
Comparable
161
161
(compareTo [_ x]
162
162
(let [cmp (compare cost (.cost ^ConversionPath x))]
Original file line number Diff line number Diff line change 1
1
(ns byte-streams.protocols
2
+ (:require
3
+ [byte-streams.utils :refer [defprotocol+]])
2
4
(:import
3
5
[java.util.concurrent
4
6
ConcurrentHashMap]))
5
7
6
- (defprotocol Closeable
8
+ (defprotocol+ Closeable
7
9
(close [_] " A protocol that is a superset of `java.io.Closeable`." ))
8
10
9
- (defprotocol ByteSource
11
+ (defprotocol+ ByteSource
10
12
(take-bytes! [_ n options] " Takes `n` bytes from the byte source." ))
11
13
12
- (defprotocol ByteSink
14
+ (defprotocol+ ByteSink
13
15
(send-bytes! [_ bytes options] " Puts `bytes` in the byte sink." ))
14
16
15
17
(extend-protocol Closeable
Original file line number Diff line number Diff line change 2
2
(:refer-clojure :exclude [take])
3
3
(:require
4
4
[primitive-math :as p]
5
- [byte-streams.utils :refer [doit]]
5
+ [byte-streams.utils :refer [doit definterface+ deftype+ ]]
6
6
[manifold
7
7
[utils :as u]
8
8
[stream :as s]
20
20
21
21
(set! *unchecked-math* true )
22
22
23
- (definterface PushbackStream
23
+ (definterface+ PushbackStream
24
24
(put [^bytes x ^int offset ^int length])
25
25
(put [^java.nio.ByteBuffer buf])
26
26
(pushback [^bytes ary ^int offset ^int length])
87
87
body)))
88
88
89
89
(both
90
- (deftype (either [PushbackByteStream] [SynchronizedPushbackByteStream])
90
+ (deftype+ (either [PushbackByteStream] [SynchronizedPushbackByteStream])
91
91
[lock
92
92
^LinkedList consumers
93
93
^long buffer-capacity
Original file line number Diff line number Diff line change 5
5
[java.util.concurrent
6
6
ConcurrentHashMap]))
7
7
8
+ (defmacro defprotocol+ [name & body]
9
+ (when-not (resolve name)
10
+ `(defprotocol ~name ~@body)))
11
+
12
+ (defmacro deftype+ [name & body]
13
+ (when-not (resolve name)
14
+ `(deftype ~name ~@body)))
15
+
16
+ (defmacro defrecord+ [name & body]
17
+ (when-not (resolve name)
18
+ `(defrecord ~name ~@body)))
19
+
20
+ (defmacro definterface+ [name & body]
21
+ (when-not (resolve name)
22
+ `(definterface ~name ~@body)))
23
+
8
24
(defmacro doit
9
25
" A version of doseq that doesn't emit all that inline-destroying chunked-seq code."
10
26
[[x it] & body]
Original file line number Diff line number Diff line change
1
+ (ns byte-streams-reload-test
2
+ (:require
3
+ [clojure.test :refer :all ]))
4
+
5
+ (deftest test-reload-all
6
+ (dotimes [_ 5 ]
7
+ (require 'byte-streams :reload-all )))
You can’t perform that action at this time.
0 commit comments