-;; Copyright (c) 2015 Andrey Antukh <niwi@niwi.nz>
+;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
 ;; All rights reserved.
 ;;
 ;; Redistribution and use in source and binary forms, with or without

  (get-capacity [buff]
    (reduce #(+ %1 (get-capacity %2)) 0 buff)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ES6 Typed Arrays
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

#?(:cljs
   (extend-type js/DataView
     IBufferShort
     (read-short [buff pos]
       (.getInt16 buff pos))
     (write-short [buff pos value]
       (.setInt16 buff pos value))
     (read-ushort [buff pos]
       (.getUint16 buff pos))
     (write-ushort [buff pos value]
       (.setUint16 buff pos value))

     IBufferInt
     (read-int [buff pos]
       (.getInt32 buff pos))
     (write-int [buff pos value]
       (.setInt32 buff pos value))
     (read-uint [buff pos]
       (.getUint32 buff pos))
     (write-uint [buff pos value]
       (.setUint32 buff pos value))

     IBufferFloat
     (read-float [buff pos]
       (.getFloat32 buff pos))
     (write-float [buff pos value]
       (.setFloat32 buff pos value))

     IBufferDouble
     (read-double [buff pos]
       (.getFloat64 buff pos))
     (write-double [buff pos value]
       (.setFloat64 buff pos value))

     IBufferByte
     (read-byte [buff pos]

     (get-capacity [buff]
       (.-byteLength buff))))

;; --- Public Api

#?(:clj
   (def ^:private allocator (ByteBufAllocator/DEFAULT)))

(defmulti allocate
  "Polymorphic function for allocate new bytebuffers.
