clojurewerkz/buffy — pull request #10 by Jell (2014-01-13 02:53:10+00:00)
Title: Adding a bit-map-type (WIP: tests missing)

Although I'm not yet done with it, I present here a first attempt at a `bit-map-type` implementation that works as follow:

```lisp
(def buf (spec :payload (bit-map-type :a 4 :b 4)))

(set-field buf :payload {:a 3, :b 7})
(get-field buf :payload)
#=> {:a 3, :b7}

(read (bit-type 1) (.buf buf) 0)
#=> (false false true true false true true true)
```

The `bit-map-type` function checks the validity of the fields i.e. the total number of bits should be a multiple of 8, and up to 64 (I'm using a long for bitwise operations, thought it would be easier. My guess is that it's going to be good enough).

Please let me know your thoughts on the implementations and the design of the proposed `bit-map-type`.

Cheerios!