diff --git a/common/src/app/common/buffer.cljc b/common/src/app/common/buffer.cljc index 55ec4f83c8..ee8c708297 100644 --- a/common/src/app/common/buffer.cljc +++ b/common/src/app/common/buffer.cljc @@ -19,42 +19,42 @@ (if (:ns &env) `(.getInt8 ~target ~offset true) (let [target (with-meta target {:tag 'java.nio.ByteBuffer})] - `(long (.get ~target ~offset))))) + `(long (.get ~target (unchecked-int ~offset)))))) (defmacro read-unsigned-byte [target offset] (if (:ns &env) `(.getUint8 ~target ~offset true) (let [target (with-meta target {:tag 'java.nio.ByteBuffer})] - `(bit-and (long (.get ~target ~offset)) 0xff)))) + `(bit-and (long (.get ~target (unchecked-int ~offset))) 0xff)))) (defmacro read-bool [target offset] (if (:ns &env) `(== 1 (.getInt8 ~target ~offset true)) (let [target (with-meta target {:tag 'java.nio.ByteBuffer})] - `(== 1 (.get ~target ~offset))))) + `(== 1 (.get ~target (unchecked-int ~offset)))))) (defmacro read-short [target offset] (if (:ns &env) `(.getInt16 ~target ~offset true) (let [target (with-meta target {:tag 'java.nio.ByteBuffer})] - `(.getShort ~target ~offset)))) + `(.getShort ~target (unchecked-int ~offset))))) (defmacro read-int [target offset] (if (:ns &env) `(.getInt32 ~target ~offset true) (let [target (with-meta target {:tag 'java.nio.ByteBuffer})] - `(long (.getInt ~target ~offset))))) + `(long (.getInt ~target (unchecked-int ~offset)))))) (defmacro read-float [target offset] (if (:ns &env) `(.getFloat32 ~target ~offset true) (let [target (with-meta target {:tag 'java.nio.ByteBuffer})] - `(double (.getFloat ~target ~offset))))) + `(double (.getFloat ~target (unchecked-int ~offset)))))) (defmacro read-uuid [target offset] @@ -68,8 +68,8 @@ (let [target (with-meta target {:tag 'java.nio.ByteBuffer})] `(try (.order ~target ByteOrder/BIG_ENDIAN) - (let [msb# (.getLong ~target (+ ~offset 0)) - lsb# (.getLong ~target (+ ~offset 8))] + (let [msb# (.getLong ~target (unchecked-int (+ ~offset 0))) + lsb# (.getLong ~target (unchecked-int (+ ~offset 8)))] (java.util.UUID. (long msb#) (long lsb#))) (finally (.order ~target ByteOrder/LITTLE_ENDIAN)))))) @@ -79,35 +79,35 @@ (if (:ns &env) `(.setInt8 ~target ~offset ~value true) (let [target (with-meta target {:tag 'java.nio.ByteBuffer})] - `(.put ~target ~offset (unchecked-byte ~value))))) + `(.put ~target (unchecked-int ~offset) (unchecked-byte ~value))))) (defmacro write-bool [target offset value] (if (:ns &env) `(.setInt8 ~target ~offset (if ~value 0x01 0x00) true) (let [target (with-meta target {:tag 'java.nio.ByteBuffer})] - `(.put ~target ~offset (unchecked-byte (if ~value 0x01 0x00)))))) + `(.put ~target (unchecked-int ~offset) (unchecked-byte (if ~value 0x01 0x00)))))) (defmacro write-short [target offset value] (if (:ns &env) `(.setInt16 ~target ~offset ~value true) (let [target (with-meta target {:tag 'java.nio.ByteBuffer})] - `(.putShort ~target ~offset (unchecked-short ~value))))) + `(.putShort ~target (unchecked-int ~offset) (unchecked-short ~value))))) (defmacro write-int [target offset value] (if (:ns &env) `(.setInt32 ~target ~offset ~value true) (let [target (with-meta target {:tag 'java.nio.ByteBuffer})] - `(.putInt ~target ~offset (unchecked-int ~value))))) + `(.putInt ~target (unchecked-int ~offset) (unchecked-int ~value))))) (defmacro write-float [target offset value] (if (:ns &env) `(.setFloat32 ~target ~offset ~value true) (let [target (with-meta target {:tag 'java.nio.ByteBuffer})] - `(.putFloat ~target ~offset (unchecked-float ~value))))) + `(.putFloat ~target (unchecked-int ~offset) (unchecked-float ~value))))) (defmacro write-uuid [target offset value] @@ -122,8 +122,8 @@ value (with-meta value {:tag 'java.util.UUID})] `(try (.order ~target ByteOrder/BIG_ENDIAN) - (.putLong ~target (+ ~offset 0) (.getMostSignificantBits ~value)) - (.putLong ~target (+ ~offset 8) (.getLeastSignificantBits ~value)) + (.putLong ~target (unchecked-int (+ ~offset 0)) (.getMostSignificantBits ~value)) + (.putLong ~target (unchecked-int (+ ~offset 8)) (.getLeastSignificantBits ~value)) (finally (.order ~target ByteOrder/LITTLE_ENDIAN))))))