Skip to content

Commit

Permalink
Merge pull request #44 from johnchapin/fix_reflection
Browse files Browse the repository at this point in the history
Fix reflection warnings
  • Loading branch information
Paudi Moriarty committed Aug 16, 2016
2 parents d25b008 + 4de68e0 commit d8b0935
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
20 changes: 14 additions & 6 deletions src/io/aviso/binary.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@

(extend-type (Class/forName "[B")
BinaryData
(data-length [ary] (alength ary))
(byte-at [ary index] (aget ary index)))
(data-length [ary] (alength (bytes ary)))
(byte-at [ary index] (aget (bytes ary) index)))

;;; Extends String as a convenience; assumes that the
;;; String is in utf-8.

(extend-type String
BinaryData
(data-length [s] (.length s))
(byte-at [s index] (-> s (.charAt index) byte)))
(byte-at [s index] (-> s (.charAt index) int byte)))

(extend-type StringBuilder
BinaryData
(data-length [sb] (.length sb))
(byte-at [sb index]
(-> sb (.charAt index) int byte)))

(extend-type nil
BinaryData
Expand Down Expand Up @@ -104,6 +110,8 @@
character."
([data]
(write-binary *out* data nil))
([writer data]
(write-binary writer data nil))
([writer data options]
(let [{show-ascii? :ascii
per-line-option :line-bytes} options
Expand All @@ -118,7 +126,7 @@
(let [remaining (- (data-length data) offset)]
(when (pos? remaining)
(write-line writer formatter show-ascii? offset data (min per-line remaining))
(recur (+ per-line offset))))))))
(recur (long (+ per-line offset)))))))))

(defn format-binary
"Formats the data using [[write-binary]] and returns the result as a string."
Expand Down Expand Up @@ -180,9 +188,9 @@
(loop [offset 0]
(when (pos? (- target-length offset))
(write-delta-line writer offset expected-length expected actual-length actual)
(recur (+ bytes-per-diff-line offset)))))))
(recur (long (+ bytes-per-diff-line offset))))))))

(defn format-binary-delta
"Formats the delta using [[write-binary-delta]] and returns the result as a string."
[expected actual]
(w/into-string write-binary-delta expected actual))
(w/into-string write-binary-delta expected actual))
2 changes: 1 addition & 1 deletion src/io/aviso/columns.clj
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
(w/writeln writer)
(let [cf (first column-fns)
[new-indent remaining-values] (cf writer current-indent values)]
(recur new-indent (rest column-fns) remaining-values)))))))
(recur (long new-indent) (rest column-fns) remaining-values)))))))

(defn max-length
"Find the maximum length of the strings in the collection, based on their visual length (that is,
Expand Down
2 changes: 1 addition & 1 deletion src/io/aviso/exception.clj
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
(>= i in-length) (.toString result)
(= \_ (.charAt s i)) (let [[match replacement] (match-mangled s i)]
(.append result replacement)
(recur (+ i (length match))))
(recur (long (+ i (length match)))))
:else (do
(.append result (.charAt s i))
(recur (inc i)))))))
Expand Down

0 comments on commit d8b0935

Please sign in to comment.