Safe Haskell | None |
---|---|
Language | Haskell98 |
GHCJS implements the ByteArray# primitive with a JavaScript object containing an ArrayBuffer and various TypedArray views. This module contains utilities for manipulating and converting the buffer as a JavaScript object.
None of the properties of a Buffer object should be written to in foreign code. Changing the contents of a MutableBuffer in foreign code is allowed.
Synopsis
- type Buffer = SomeBuffer Immutable
- type MutableBuffer = SomeBuffer Mutable
- create :: Int -> IO MutableBuffer
- createFromArrayBuffer :: SomeArrayBuffer any -> SomeBuffer any
- thaw :: Buffer -> IO MutableBuffer
- freeze :: MutableBuffer -> IO Buffer
- clone :: MutableBuffer -> IO (SomeBuffer any2)
- byteLength :: SomeBuffer any -> Int
- getArrayBuffer :: SomeBuffer any -> SomeArrayBuffer any
- getUint8Array :: SomeBuffer any -> SomeUint8Array any
- getUint16Array :: SomeBuffer any -> SomeUint16Array any
- getInt32Array :: SomeBuffer any -> SomeInt32Array any
- getDataView :: SomeBuffer any -> SomeDataView any
- getFloat32Array :: SomeBuffer any -> SomeFloat32Array any
- getFloat64Array :: SomeBuffer any -> SomeFloat64Array any
- toByteArray :: Buffer -> ByteArray
- fromByteArray :: ByteArray -> Buffer
- toByteArrayPrim :: Buffer -> ByteArray#
- fromByteArrayPrim :: ByteArray# -> Buffer
- toMutableByteArray :: Buffer -> MutableByteArray s
- fromMutableByteArray :: MutableByteArray s -> Buffer
- toMutableByteArrayPrim :: Buffer -> MutableByteArray# s
- fromMutableByteArrayPrim :: MutableByteArray# s -> Buffer
- toByteString :: Int -> Maybe Int -> Buffer -> ByteString
- fromByteString :: ByteString -> (Buffer, Int, Int)
- toPtr :: MutableBuffer -> Ptr a
- unsafeToPtr :: Buffer -> Ptr a
Documentation
type Buffer = SomeBuffer Immutable Source #
type MutableBuffer = SomeBuffer Mutable Source #
createFromArrayBuffer :: SomeArrayBuffer any -> SomeBuffer any Source #
clone :: MutableBuffer -> IO (SomeBuffer any2) Source #
JavaScript properties
byteLength :: SomeBuffer any -> Int Source #
getArrayBuffer :: SomeBuffer any -> SomeArrayBuffer any Source #
getUint8Array :: SomeBuffer any -> SomeUint8Array any Source #
getUint16Array :: SomeBuffer any -> SomeUint16Array any Source #
getInt32Array :: SomeBuffer any -> SomeInt32Array any Source #
getDataView :: SomeBuffer any -> SomeDataView any Source #
getFloat32Array :: SomeBuffer any -> SomeFloat32Array any Source #
getFloat64Array :: SomeBuffer any -> SomeFloat64Array any Source #
primitive
toByteArray :: Buffer -> ByteArray Source #
fromByteArray :: ByteArray -> Buffer Source #
toByteArrayPrim :: Buffer -> ByteArray# Source #
fromByteArrayPrim :: ByteArray# -> Buffer Source #
toMutableByteArray :: Buffer -> MutableByteArray s Source #
bytestring
toByteString :: Int -> Maybe Int -> Buffer -> ByteString Source #
Wrap a Buffer
into a ByteString
using the given offset
and length.
fromByteString :: ByteString -> (Buffer, Int, Int) Source #
Convert a ByteString
into a triple of (buffer, offset, length)
Warning: if the ByteString'
s internal ForeignPtr
has a
finalizer associated with it, the returned Buffer
will not count
as a reference for the purpose of determining when that finalizer
should run.
pointers
toPtr :: MutableBuffer -> Ptr a Source #
unsafeToPtr :: Buffer -> Ptr a Source #