Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'clj-1.3' into 0.2.2

  • Loading branch information...
commit 5df6d50fcb96228bf8ce600c52e36fb9d6f3f2d2 2 parents d292f6a + b908b63
Zach Tellman authored
Showing with 8 additions and 5 deletions.
  1. +7 −4 src/gloss/core/codecs.clj
  2. +1 −1  test/gloss/test/core.clj
11 src/gloss/core/codecs.clj
View
@@ -177,13 +177,16 @@
(enum :int32 {:a 100, :b 200, :c 300})"
[primitive-type & map-or-seq]
(assert (primitive-codecs primitive-type))
- (let [n->v (if (and (= 1 (count map-or-seq)) (map? (first map-or-seq)))
+ (let [coerce #(if (char? %)
+ (int %)
+ (long %))
+ n->v (if (and (= 1 (count map-or-seq)) (map? (first map-or-seq)))
(let [m (first map-or-seq)]
(zipmap
- (map long (vals m))
+ (map coerce (vals m))
(keys m)))
(zipmap
- (map long (range (count map-or-seq)))
+ (map coerce (range (count map-or-seq)))
map-or-seq))
v->n (zipmap (vals n->v) (keys n->v))
codec (primitive-codecs primitive-type)]
@@ -192,7 +195,7 @@
(read-bytes [this b]
(let [[success x b] (read-bytes codec b)]
(if success
- [true (n->v (long x)) b]
+ [true (n->v (coerce x)) b]
[false this b])))
Writer
(sizeof [_]
2  test/gloss/test/core.clj
View
@@ -213,7 +213,7 @@
(enum :byte :a :b :c)
:a)
(test-roundtrip
- (enum :int16 {:a 100 :b 1000})
+ (enum :int16 {:a 100 :b 1000 :c \c})
:b))
(deftest test-bit-seq
Please sign in to comment.
Something went wrong with that request. Please try again.