Created
September 6, 2016 15:01
-
-
Save moxaj/7757f4ce58e6333397f583d5c5c82e83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro !integer [buffer offset size le? value] | |
`(doto ~buffer | |
~@(map (fn [i] | |
`(aset ~(+ offset (if le? i (- size i 1))) | |
(unchecked-byte | |
(bit-and (unsigned-bit-shift-right ~value ~(* 8 i)) | |
0xFF)))) | |
(range size)))) | |
(defmacro ?integer [buffer offset size le?] | |
(reduce (fn [code i] | |
`(bit-or ~code | |
(bit-shift-left (aget ~buffer ~(+ offset i)) | |
~(* 8 (if le? i (- size i 1)))))) | |
0 | |
(range size))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment