   ^mikron.runtime.buffer.IMikronByteBuffer [^Buffer buffer]
   (.-byte-buffer buffer))
 
-(defn get-bit-pos
+(defn get-bit-position
   "Gets the bit position of `buffer`."
-  #?(:clj {:inline (fn [buffer] `(get-bit-pos* (get-bit-buffer ~buffer)))})
-  ^long [^Buffer buffer]
-  (get-bit-pos* (get-bit-buffer buffer)))
-
-(defn set-bit-pos
+  #?(:clj {:inline (fn [buffer] `(get-bit-position* (get-bit-buffer ~buffer)))})
+  ^long [^Buffer buffer]
+  (get-bit-position* (get-bit-buffer buffer)))
+
+(defn set-bit-position
   "Sets the bit position of `buffer` to `value`."
-  #?(:clj {:inline (fn [buffer value] `(set-bit-pos* (get-bit-buffer ~buffer) ~value))})
-  [^Buffer buffer ^long value]
-  (set-bit-pos* (get-bit-buffer buffer) value))
+  #?(:clj {:inline (fn [buffer value] `(set-bit-position* (get-bit-buffer ~buffer) ~value))})
+  [^Buffer buffer ^long value]
+  (set-bit-position* (get-bit-buffer buffer) value))
 
 (defn get-bit-index
   "Gets the bit index of `buffer`."

  ^bytes [^Buffer buffer]
  (take-bytes-all* (get-byte-buffer buffer)))

(defn get-pos
  "Gets the position of `buffer`."
  #?(:clj {:inline (fn [buffer] `(get-pos* (get-byte-buffer ~buffer)))})
  ^long [^Buffer buffer]
  (get-pos* (get-byte-buffer buffer)))

(defn set-pos
  "Sets the position of `buffer`."
  #?(:clj {:inline (fn [buffer value] `(set-pos* (get-byte-buffer ~buffer) ~value))})
  [^Buffer buffer ^long value]
  (set-pos* (get-byte-buffer buffer) value))

(defn get-le
  "Gets the endianness of `buffer`."

  "Resets `buffer`."
  ^Buffer [^Buffer buffer]
  (doto buffer
    (set-position 0)
    (set-bit-position -1)
    (set-bit-value 0)
    (set-bit-index 0)))

(defn finalize
  "Finalizes `buffer`."
  ^Buffer [^Buffer buffer]
  (let [bit-position (get-bit-position buffer)]
    (when-not (== -1 bit-position)
      (put-byte-at buffer bit-position (get-bit-value buffer)))
    buffer))

(definterface+ IMikronByteBufferFactory
