{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)

'GI.GstBase.Structs.BitReader.BitReader' provides a bit reader that can read any number of bits
from a memory buffer. It provides functions for reading any number of bits
into 8, 16, 32 and 64 bit variables.
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.GstBase.Structs.BitReader
    (

-- * Exported types
    BitReader(..)                           ,
    newZeroBitReader                        ,
    noBitReader                             ,


 -- * Methods
-- ** free #method:free#

#if ENABLE_OVERLOADING
    BitReaderFreeMethodInfo                 ,
#endif
    bitReaderFree                           ,


-- ** getBitsUint16 #method:getBitsUint16#

#if ENABLE_OVERLOADING
    BitReaderGetBitsUint16MethodInfo        ,
#endif
    bitReaderGetBitsUint16                  ,


-- ** getBitsUint32 #method:getBitsUint32#

#if ENABLE_OVERLOADING
    BitReaderGetBitsUint32MethodInfo        ,
#endif
    bitReaderGetBitsUint32                  ,


-- ** getBitsUint64 #method:getBitsUint64#

#if ENABLE_OVERLOADING
    BitReaderGetBitsUint64MethodInfo        ,
#endif
    bitReaderGetBitsUint64                  ,


-- ** getBitsUint8 #method:getBitsUint8#

#if ENABLE_OVERLOADING
    BitReaderGetBitsUint8MethodInfo         ,
#endif
    bitReaderGetBitsUint8                   ,


-- ** getPos #method:getPos#

#if ENABLE_OVERLOADING
    BitReaderGetPosMethodInfo               ,
#endif
    bitReaderGetPos                         ,


-- ** getRemaining #method:getRemaining#

#if ENABLE_OVERLOADING
    BitReaderGetRemainingMethodInfo         ,
#endif
    bitReaderGetRemaining                   ,


-- ** getSize #method:getSize#

#if ENABLE_OVERLOADING
    BitReaderGetSizeMethodInfo              ,
#endif
    bitReaderGetSize                        ,


-- ** init #method:init#

#if ENABLE_OVERLOADING
    BitReaderInitMethodInfo                 ,
#endif
    bitReaderInit                           ,


-- ** peekBitsUint16 #method:peekBitsUint16#

#if ENABLE_OVERLOADING
    BitReaderPeekBitsUint16MethodInfo       ,
#endif
    bitReaderPeekBitsUint16                 ,


-- ** peekBitsUint32 #method:peekBitsUint32#

#if ENABLE_OVERLOADING
    BitReaderPeekBitsUint32MethodInfo       ,
#endif
    bitReaderPeekBitsUint32                 ,


-- ** peekBitsUint64 #method:peekBitsUint64#

#if ENABLE_OVERLOADING
    BitReaderPeekBitsUint64MethodInfo       ,
#endif
    bitReaderPeekBitsUint64                 ,


-- ** peekBitsUint8 #method:peekBitsUint8#

#if ENABLE_OVERLOADING
    BitReaderPeekBitsUint8MethodInfo        ,
#endif
    bitReaderPeekBitsUint8                  ,


-- ** setPos #method:setPos#

#if ENABLE_OVERLOADING
    BitReaderSetPosMethodInfo               ,
#endif
    bitReaderSetPos                         ,


-- ** skip #method:skip#

#if ENABLE_OVERLOADING
    BitReaderSkipMethodInfo                 ,
#endif
    bitReaderSkip                           ,


-- ** skipToByte #method:skipToByte#

#if ENABLE_OVERLOADING
    BitReaderSkipToByteMethodInfo           ,
#endif
    bitReaderSkipToByte                     ,




 -- * Properties
-- ** bit #attr:bit#
{- | Bit position in the current byte
-}
#if ENABLE_OVERLOADING
    bitReader_bit                           ,
#endif
    getBitReaderBit                         ,
    setBitReaderBit                         ,


-- ** byte #attr:byte#
{- | Current byte position
-}
#if ENABLE_OVERLOADING
    bitReader_byte                          ,
#endif
    getBitReaderByte                        ,
    setBitReaderByte                        ,


-- ** size #attr:size#
{- | Size of /@data@/ in bytes
-}
#if ENABLE_OVERLOADING
    bitReader_size                          ,
#endif
    getBitReaderSize                        ,
    setBitReaderSize                        ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL


-- | Memory-managed wrapper type.
newtype BitReader = BitReader (ManagedPtr BitReader)
instance WrappedPtr BitReader where
    wrappedPtrCalloc = callocBytes 56
    wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 56 >=> wrapPtr BitReader)
    wrappedPtrFree = Just ptr_to_g_free

-- | Construct a `BitReader` struct initialized to zero.
newZeroBitReader :: MonadIO m => m BitReader
newZeroBitReader = liftIO $ wrappedPtrCalloc >>= wrapPtr BitReader

instance tag ~ 'AttrSet => Constructible BitReader tag where
    new _ attrs = do
        o <- newZeroBitReader
        GI.Attributes.set o attrs
        return o


-- | A convenience alias for `Nothing` :: `Maybe` `BitReader`.
noBitReader :: Maybe BitReader
noBitReader = Nothing

-- XXX Skipped attribute for "BitReader:data" :: Not implemented: "Don't know how to unpack C array of type TCArray False (-1) 1 (TBasicType TUInt8)"
{- |
Get the value of the “@size@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' bitReader #size
@
-}
getBitReaderSize :: MonadIO m => BitReader -> m Word32
getBitReaderSize s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO Word32
    return val

{- |
Set the value of the “@size@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' bitReader [ #size 'Data.GI.Base.Attributes.:=' value ]
@
-}
setBitReaderSize :: MonadIO m => BitReader -> Word32 -> m ()
setBitReaderSize s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (val :: Word32)

#if ENABLE_OVERLOADING
data BitReaderSizeFieldInfo
instance AttrInfo BitReaderSizeFieldInfo where
    type AttrAllowedOps BitReaderSizeFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint BitReaderSizeFieldInfo = (~) Word32
    type AttrBaseTypeConstraint BitReaderSizeFieldInfo = (~) BitReader
    type AttrGetType BitReaderSizeFieldInfo = Word32
    type AttrLabel BitReaderSizeFieldInfo = "size"
    type AttrOrigin BitReaderSizeFieldInfo = BitReader
    attrGet _ = getBitReaderSize
    attrSet _ = setBitReaderSize
    attrConstruct = undefined
    attrClear _ = undefined

bitReader_size :: AttrLabelProxy "size"
bitReader_size = AttrLabelProxy

#endif


{- |
Get the value of the “@byte@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' bitReader #byte
@
-}
getBitReaderByte :: MonadIO m => BitReader -> m Word32
getBitReaderByte s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 12) :: IO Word32
    return val

{- |
Set the value of the “@byte@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' bitReader [ #byte 'Data.GI.Base.Attributes.:=' value ]
@
-}
setBitReaderByte :: MonadIO m => BitReader -> Word32 -> m ()
setBitReaderByte s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 12) (val :: Word32)

#if ENABLE_OVERLOADING
data BitReaderByteFieldInfo
instance AttrInfo BitReaderByteFieldInfo where
    type AttrAllowedOps BitReaderByteFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint BitReaderByteFieldInfo = (~) Word32
    type AttrBaseTypeConstraint BitReaderByteFieldInfo = (~) BitReader
    type AttrGetType BitReaderByteFieldInfo = Word32
    type AttrLabel BitReaderByteFieldInfo = "byte"
    type AttrOrigin BitReaderByteFieldInfo = BitReader
    attrGet _ = getBitReaderByte
    attrSet _ = setBitReaderByte
    attrConstruct = undefined
    attrClear _ = undefined

bitReader_byte :: AttrLabelProxy "byte"
bitReader_byte = AttrLabelProxy

#endif


{- |
Get the value of the “@bit@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' bitReader #bit
@
-}
getBitReaderBit :: MonadIO m => BitReader -> m Word32
getBitReaderBit s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO Word32
    return val

{- |
Set the value of the “@bit@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' bitReader [ #bit 'Data.GI.Base.Attributes.:=' value ]
@
-}
setBitReaderBit :: MonadIO m => BitReader -> Word32 -> m ()
setBitReaderBit s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 16) (val :: Word32)

#if ENABLE_OVERLOADING
data BitReaderBitFieldInfo
instance AttrInfo BitReaderBitFieldInfo where
    type AttrAllowedOps BitReaderBitFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint BitReaderBitFieldInfo = (~) Word32
    type AttrBaseTypeConstraint BitReaderBitFieldInfo = (~) BitReader
    type AttrGetType BitReaderBitFieldInfo = Word32
    type AttrLabel BitReaderBitFieldInfo = "bit"
    type AttrOrigin BitReaderBitFieldInfo = BitReader
    attrGet _ = getBitReaderBit
    attrSet _ = setBitReaderBit
    attrConstruct = undefined
    attrClear _ = undefined

bitReader_bit :: AttrLabelProxy "bit"
bitReader_bit = AttrLabelProxy

#endif



#if ENABLE_OVERLOADING
instance O.HasAttributeList BitReader
type instance O.AttributeList BitReader = BitReaderAttributeList
type BitReaderAttributeList = ('[ '("size", BitReaderSizeFieldInfo), '("byte", BitReaderByteFieldInfo), '("bit", BitReaderBitFieldInfo)] :: [(Symbol, *)])
#endif

-- method BitReader::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_free" gst_bit_reader_free ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    IO ()

{- |
Frees a 'GI.GstBase.Structs.BitReader.BitReader' instance, which was previously allocated by
@/gst_bit_reader_new()/@.
-}
bitReaderFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> m ()
bitReaderFree reader = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    gst_bit_reader_free reader'
    touchManagedPtr reader
    return ()

#if ENABLE_OVERLOADING
data BitReaderFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo BitReaderFreeMethodInfo BitReader signature where
    overloadedMethod _ = bitReaderFree

#endif

-- method BitReader::get_bits_uint16
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUInt16, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to a #guint16 to store the result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "nbits", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bits to read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_get_bits_uint16" gst_bit_reader_get_bits_uint16 ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    Ptr Word16 ->                           -- val : TBasicType TUInt16
    Word32 ->                               -- nbits : TBasicType TUInt
    IO CInt

{- |
Read /@nbits@/ bits into /@val@/ and update the current position.
-}
bitReaderGetBitsUint16 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> Word32
    {- ^ /@nbits@/: number of bits to read -}
    -> m ((Bool, Word16))
    {- ^ __Returns:__ 'True' if successful, 'False' otherwise. -}
bitReaderGetBitsUint16 reader nbits = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    val <- allocMem :: IO (Ptr Word16)
    result <- gst_bit_reader_get_bits_uint16 reader' val nbits
    let result' = (/= 0) result
    val' <- peek val
    touchManagedPtr reader
    freeMem val
    return (result', val')

#if ENABLE_OVERLOADING
data BitReaderGetBitsUint16MethodInfo
instance (signature ~ (Word32 -> m ((Bool, Word16))), MonadIO m) => O.MethodInfo BitReaderGetBitsUint16MethodInfo BitReader signature where
    overloadedMethod _ = bitReaderGetBitsUint16

#endif

-- method BitReader::get_bits_uint32
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUInt32, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to a #guint32 to store the result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "nbits", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bits to read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_get_bits_uint32" gst_bit_reader_get_bits_uint32 ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    Ptr Word32 ->                           -- val : TBasicType TUInt32
    Word32 ->                               -- nbits : TBasicType TUInt
    IO CInt

{- |
Read /@nbits@/ bits into /@val@/ and update the current position.
-}
bitReaderGetBitsUint32 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> Word32
    {- ^ /@nbits@/: number of bits to read -}
    -> m ((Bool, Word32))
    {- ^ __Returns:__ 'True' if successful, 'False' otherwise. -}
bitReaderGetBitsUint32 reader nbits = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    val <- allocMem :: IO (Ptr Word32)
    result <- gst_bit_reader_get_bits_uint32 reader' val nbits
    let result' = (/= 0) result
    val' <- peek val
    touchManagedPtr reader
    freeMem val
    return (result', val')

#if ENABLE_OVERLOADING
data BitReaderGetBitsUint32MethodInfo
instance (signature ~ (Word32 -> m ((Bool, Word32))), MonadIO m) => O.MethodInfo BitReaderGetBitsUint32MethodInfo BitReader signature where
    overloadedMethod _ = bitReaderGetBitsUint32

#endif

-- method BitReader::get_bits_uint64
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to a #guint64 to store the result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "nbits", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bits to read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_get_bits_uint64" gst_bit_reader_get_bits_uint64 ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    Ptr Word64 ->                           -- val : TBasicType TUInt64
    Word32 ->                               -- nbits : TBasicType TUInt
    IO CInt

{- |
Read /@nbits@/ bits into /@val@/ and update the current position.
-}
bitReaderGetBitsUint64 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> Word32
    {- ^ /@nbits@/: number of bits to read -}
    -> m ((Bool, Word64))
    {- ^ __Returns:__ 'True' if successful, 'False' otherwise. -}
bitReaderGetBitsUint64 reader nbits = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    val <- allocMem :: IO (Ptr Word64)
    result <- gst_bit_reader_get_bits_uint64 reader' val nbits
    let result' = (/= 0) result
    val' <- peek val
    touchManagedPtr reader
    freeMem val
    return (result', val')

#if ENABLE_OVERLOADING
data BitReaderGetBitsUint64MethodInfo
instance (signature ~ (Word32 -> m ((Bool, Word64))), MonadIO m) => O.MethodInfo BitReaderGetBitsUint64MethodInfo BitReader signature where
    overloadedMethod _ = bitReaderGetBitsUint64

#endif

-- method BitReader::get_bits_uint8
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUInt8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to a #guint8 to store the result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "nbits", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bits to read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_get_bits_uint8" gst_bit_reader_get_bits_uint8 ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    Ptr Word8 ->                            -- val : TBasicType TUInt8
    Word32 ->                               -- nbits : TBasicType TUInt
    IO CInt

{- |
Read /@nbits@/ bits into /@val@/ and update the current position.
-}
bitReaderGetBitsUint8 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> Word32
    {- ^ /@nbits@/: number of bits to read -}
    -> m ((Bool, Word8))
    {- ^ __Returns:__ 'True' if successful, 'False' otherwise. -}
bitReaderGetBitsUint8 reader nbits = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    val <- allocMem :: IO (Ptr Word8)
    result <- gst_bit_reader_get_bits_uint8 reader' val nbits
    let result' = (/= 0) result
    val' <- peek val
    touchManagedPtr reader
    freeMem val
    return (result', val')

#if ENABLE_OVERLOADING
data BitReaderGetBitsUint8MethodInfo
instance (signature ~ (Word32 -> m ((Bool, Word8))), MonadIO m) => O.MethodInfo BitReaderGetBitsUint8MethodInfo BitReader signature where
    overloadedMethod _ = bitReaderGetBitsUint8

#endif

-- method BitReader::get_pos
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_get_pos" gst_bit_reader_get_pos ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    IO Word32

{- |
Returns the current position of a 'GI.GstBase.Structs.BitReader.BitReader' instance in bits.
-}
bitReaderGetPos ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> m Word32
    {- ^ __Returns:__ The current position of /@reader@/ in bits. -}
bitReaderGetPos reader = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    result <- gst_bit_reader_get_pos reader'
    touchManagedPtr reader
    return result

#if ENABLE_OVERLOADING
data BitReaderGetPosMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo BitReaderGetPosMethodInfo BitReader signature where
    overloadedMethod _ = bitReaderGetPos

#endif

-- method BitReader::get_remaining
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_get_remaining" gst_bit_reader_get_remaining ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    IO Word32

{- |
Returns the remaining number of bits of a 'GI.GstBase.Structs.BitReader.BitReader' instance.
-}
bitReaderGetRemaining ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> m Word32
    {- ^ __Returns:__ The remaining number of bits of /@reader@/ instance. -}
bitReaderGetRemaining reader = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    result <- gst_bit_reader_get_remaining reader'
    touchManagedPtr reader
    return result

#if ENABLE_OVERLOADING
data BitReaderGetRemainingMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo BitReaderGetRemainingMethodInfo BitReader signature where
    overloadedMethod _ = bitReaderGetRemaining

#endif

-- method BitReader::get_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_get_size" gst_bit_reader_get_size ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    IO Word32

{- |
Returns the total number of bits of a 'GI.GstBase.Structs.BitReader.BitReader' instance.
-}
bitReaderGetSize ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> m Word32
    {- ^ __Returns:__ The total number of bits of /@reader@/ instance. -}
bitReaderGetSize reader = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    result <- gst_bit_reader_get_size reader'
    touchManagedPtr reader
    return result

#if ENABLE_OVERLOADING
data BitReaderGetSizeMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo BitReaderGetSizeMethodInfo BitReader signature where
    overloadedMethod _ = bitReaderGetSize

#endif

-- method BitReader::init
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "data from which the bit reader should read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "size", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Size of @data in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "size", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Size of @data in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_init" gst_bit_reader_init ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    Ptr Word8 ->                            -- data : TCArray False (-1) 2 (TBasicType TUInt8)
    Word32 ->                               -- size : TBasicType TUInt
    IO ()

{- |
Initializes a 'GI.GstBase.Structs.BitReader.BitReader' instance to read from /@data@/. This function
can be called on already initialized instances.
-}
bitReaderInit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> ByteString
    {- ^ /@data@/: data from which the bit reader should read -}
    -> m ()
bitReaderInit reader data_ = liftIO $ do
    let size = fromIntegral $ B.length data_
    reader' <- unsafeManagedPtrGetPtr reader
    data_' <- packByteString data_
    gst_bit_reader_init reader' data_' size
    touchManagedPtr reader
    freeMem data_'
    return ()

#if ENABLE_OVERLOADING
data BitReaderInitMethodInfo
instance (signature ~ (ByteString -> m ()), MonadIO m) => O.MethodInfo BitReaderInitMethodInfo BitReader signature where
    overloadedMethod _ = bitReaderInit

#endif

-- method BitReader::peek_bits_uint16
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUInt16, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to a #guint16 to store the result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "nbits", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bits to read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_peek_bits_uint16" gst_bit_reader_peek_bits_uint16 ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    Ptr Word16 ->                           -- val : TBasicType TUInt16
    Word32 ->                               -- nbits : TBasicType TUInt
    IO CInt

{- |
Read /@nbits@/ bits into /@val@/ but keep the current position.
-}
bitReaderPeekBitsUint16 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> Word32
    {- ^ /@nbits@/: number of bits to read -}
    -> m ((Bool, Word16))
    {- ^ __Returns:__ 'True' if successful, 'False' otherwise. -}
bitReaderPeekBitsUint16 reader nbits = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    val <- allocMem :: IO (Ptr Word16)
    result <- gst_bit_reader_peek_bits_uint16 reader' val nbits
    let result' = (/= 0) result
    val' <- peek val
    touchManagedPtr reader
    freeMem val
    return (result', val')

#if ENABLE_OVERLOADING
data BitReaderPeekBitsUint16MethodInfo
instance (signature ~ (Word32 -> m ((Bool, Word16))), MonadIO m) => O.MethodInfo BitReaderPeekBitsUint16MethodInfo BitReader signature where
    overloadedMethod _ = bitReaderPeekBitsUint16

#endif

-- method BitReader::peek_bits_uint32
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUInt32, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to a #guint32 to store the result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "nbits", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bits to read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_peek_bits_uint32" gst_bit_reader_peek_bits_uint32 ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    Ptr Word32 ->                           -- val : TBasicType TUInt32
    Word32 ->                               -- nbits : TBasicType TUInt
    IO CInt

{- |
Read /@nbits@/ bits into /@val@/ but keep the current position.
-}
bitReaderPeekBitsUint32 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> Word32
    {- ^ /@nbits@/: number of bits to read -}
    -> m ((Bool, Word32))
    {- ^ __Returns:__ 'True' if successful, 'False' otherwise. -}
bitReaderPeekBitsUint32 reader nbits = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    val <- allocMem :: IO (Ptr Word32)
    result <- gst_bit_reader_peek_bits_uint32 reader' val nbits
    let result' = (/= 0) result
    val' <- peek val
    touchManagedPtr reader
    freeMem val
    return (result', val')

#if ENABLE_OVERLOADING
data BitReaderPeekBitsUint32MethodInfo
instance (signature ~ (Word32 -> m ((Bool, Word32))), MonadIO m) => O.MethodInfo BitReaderPeekBitsUint32MethodInfo BitReader signature where
    overloadedMethod _ = bitReaderPeekBitsUint32

#endif

-- method BitReader::peek_bits_uint64
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to a #guint64 to store the result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "nbits", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bits to read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_peek_bits_uint64" gst_bit_reader_peek_bits_uint64 ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    Ptr Word64 ->                           -- val : TBasicType TUInt64
    Word32 ->                               -- nbits : TBasicType TUInt
    IO CInt

{- |
Read /@nbits@/ bits into /@val@/ but keep the current position.
-}
bitReaderPeekBitsUint64 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> Word32
    {- ^ /@nbits@/: number of bits to read -}
    -> m ((Bool, Word64))
    {- ^ __Returns:__ 'True' if successful, 'False' otherwise. -}
bitReaderPeekBitsUint64 reader nbits = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    val <- allocMem :: IO (Ptr Word64)
    result <- gst_bit_reader_peek_bits_uint64 reader' val nbits
    let result' = (/= 0) result
    val' <- peek val
    touchManagedPtr reader
    freeMem val
    return (result', val')

#if ENABLE_OVERLOADING
data BitReaderPeekBitsUint64MethodInfo
instance (signature ~ (Word32 -> m ((Bool, Word64))), MonadIO m) => O.MethodInfo BitReaderPeekBitsUint64MethodInfo BitReader signature where
    overloadedMethod _ = bitReaderPeekBitsUint64

#endif

-- method BitReader::peek_bits_uint8
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUInt8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to a #guint8 to store the result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "nbits", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bits to read", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_peek_bits_uint8" gst_bit_reader_peek_bits_uint8 ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    Ptr Word8 ->                            -- val : TBasicType TUInt8
    Word32 ->                               -- nbits : TBasicType TUInt
    IO CInt

{- |
Read /@nbits@/ bits into /@val@/ but keep the current position.
-}
bitReaderPeekBitsUint8 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> Word32
    {- ^ /@nbits@/: number of bits to read -}
    -> m ((Bool, Word8))
    {- ^ __Returns:__ 'True' if successful, 'False' otherwise. -}
bitReaderPeekBitsUint8 reader nbits = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    val <- allocMem :: IO (Ptr Word8)
    result <- gst_bit_reader_peek_bits_uint8 reader' val nbits
    let result' = (/= 0) result
    val' <- peek val
    touchManagedPtr reader
    freeMem val
    return (result', val')

#if ENABLE_OVERLOADING
data BitReaderPeekBitsUint8MethodInfo
instance (signature ~ (Word32 -> m ((Bool, Word8))), MonadIO m) => O.MethodInfo BitReaderPeekBitsUint8MethodInfo BitReader signature where
    overloadedMethod _ = bitReaderPeekBitsUint8

#endif

-- method BitReader::set_pos
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pos", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The new position in bits", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_set_pos" gst_bit_reader_set_pos ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    Word32 ->                               -- pos : TBasicType TUInt
    IO CInt

{- |
Sets the new position of a 'GI.GstBase.Structs.BitReader.BitReader' instance to /@pos@/ in bits.
-}
bitReaderSetPos ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> Word32
    {- ^ /@pos@/: The new position in bits -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the position could be set successfully, 'False'
otherwise. -}
bitReaderSetPos reader pos = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    result <- gst_bit_reader_set_pos reader' pos
    let result' = (/= 0) result
    touchManagedPtr reader
    return result'

#if ENABLE_OVERLOADING
data BitReaderSetPosMethodInfo
instance (signature ~ (Word32 -> m Bool), MonadIO m) => O.MethodInfo BitReaderSetPosMethodInfo BitReader signature where
    overloadedMethod _ = bitReaderSetPos

#endif

-- method BitReader::skip
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "nbits", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bits to skip", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_skip" gst_bit_reader_skip ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    Word32 ->                               -- nbits : TBasicType TUInt
    IO CInt

{- |
Skips /@nbits@/ bits of the 'GI.GstBase.Structs.BitReader.BitReader' instance.
-}
bitReaderSkip ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> Word32
    {- ^ /@nbits@/: the number of bits to skip -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@nbits@/ bits could be skipped, 'False' otherwise. -}
bitReaderSkip reader nbits = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    result <- gst_bit_reader_skip reader' nbits
    let result' = (/= 0) result
    touchManagedPtr reader
    return result'

#if ENABLE_OVERLOADING
data BitReaderSkipMethodInfo
instance (signature ~ (Word32 -> m Bool), MonadIO m) => O.MethodInfo BitReaderSkipMethodInfo BitReader signature where
    overloadedMethod _ = bitReaderSkip

#endif

-- method BitReader::skip_to_byte
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "reader", argType = TInterface (Name {namespace = "GstBase", name = "BitReader"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBitReader instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bit_reader_skip_to_byte" gst_bit_reader_skip_to_byte ::
    Ptr BitReader ->                        -- reader : TInterface (Name {namespace = "GstBase", name = "BitReader"})
    IO CInt

{- |
Skips until the next byte.
-}
bitReaderSkipToByte ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    BitReader
    {- ^ /@reader@/: a 'GI.GstBase.Structs.BitReader.BitReader' instance -}
    -> m Bool
    {- ^ __Returns:__ 'True' if successful, 'False' otherwise. -}
bitReaderSkipToByte reader = liftIO $ do
    reader' <- unsafeManagedPtrGetPtr reader
    result <- gst_bit_reader_skip_to_byte reader'
    let result' = (/= 0) result
    touchManagedPtr reader
    return result'

#if ENABLE_OVERLOADING
data BitReaderSkipToByteMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo BitReaderSkipToByteMethodInfo BitReader signature where
    overloadedMethod _ = bitReaderSkipToByte

#endif

#if ENABLE_OVERLOADING
type family ResolveBitReaderMethod (t :: Symbol) (o :: *) :: * where
    ResolveBitReaderMethod "free" o = BitReaderFreeMethodInfo
    ResolveBitReaderMethod "init" o = BitReaderInitMethodInfo
    ResolveBitReaderMethod "peekBitsUint16" o = BitReaderPeekBitsUint16MethodInfo
    ResolveBitReaderMethod "peekBitsUint32" o = BitReaderPeekBitsUint32MethodInfo
    ResolveBitReaderMethod "peekBitsUint64" o = BitReaderPeekBitsUint64MethodInfo
    ResolveBitReaderMethod "peekBitsUint8" o = BitReaderPeekBitsUint8MethodInfo
    ResolveBitReaderMethod "skip" o = BitReaderSkipMethodInfo
    ResolveBitReaderMethod "skipToByte" o = BitReaderSkipToByteMethodInfo
    ResolveBitReaderMethod "getBitsUint16" o = BitReaderGetBitsUint16MethodInfo
    ResolveBitReaderMethod "getBitsUint32" o = BitReaderGetBitsUint32MethodInfo
    ResolveBitReaderMethod "getBitsUint64" o = BitReaderGetBitsUint64MethodInfo
    ResolveBitReaderMethod "getBitsUint8" o = BitReaderGetBitsUint8MethodInfo
    ResolveBitReaderMethod "getPos" o = BitReaderGetPosMethodInfo
    ResolveBitReaderMethod "getRemaining" o = BitReaderGetRemainingMethodInfo
    ResolveBitReaderMethod "getSize" o = BitReaderGetSizeMethodInfo
    ResolveBitReaderMethod "setPos" o = BitReaderSetPosMethodInfo
    ResolveBitReaderMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveBitReaderMethod t BitReader, O.MethodInfo info BitReader p) => OL.IsLabel t (BitReader -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif