{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.Gio.Objects.BufferedInputStream
    ( 

-- * Exported types
    BufferedInputStream(..)                 ,
    BufferedInputStreamK                    ,
    toBufferedInputStream                   ,
    noBufferedInputStream                   ,


 -- * Methods
-- ** bufferedInputStreamFill
    bufferedInputStreamFill                 ,


-- ** bufferedInputStreamFillAsync
    bufferedInputStreamFillAsync            ,


-- ** bufferedInputStreamFillFinish
    bufferedInputStreamFillFinish           ,


-- ** bufferedInputStreamGetAvailable
    bufferedInputStreamGetAvailable         ,


-- ** bufferedInputStreamGetBufferSize
    bufferedInputStreamGetBufferSize        ,


-- ** bufferedInputStreamNew
    bufferedInputStreamNew                  ,


-- ** bufferedInputStreamNewSized
    bufferedInputStreamNewSized             ,


-- ** bufferedInputStreamPeek
    bufferedInputStreamPeek                 ,


-- ** bufferedInputStreamPeekBuffer
    bufferedInputStreamPeekBuffer           ,


-- ** bufferedInputStreamReadByte
    bufferedInputStreamReadByte             ,


-- ** bufferedInputStreamSetBufferSize
    bufferedInputStreamSetBufferSize        ,




 -- * Properties
-- ** BufferSize
    BufferedInputStreamBufferSizePropertyInfo,
    constructBufferedInputStreamBufferSize  ,
    getBufferedInputStreamBufferSize        ,
    setBufferedInputStreamBufferSize        ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Gio.Types
import GI.Gio.Callbacks
import qualified GI.GObject as GObject

newtype BufferedInputStream = BufferedInputStream (ForeignPtr BufferedInputStream)
foreign import ccall "g_buffered_input_stream_get_type"
    c_g_buffered_input_stream_get_type :: IO GType

type instance ParentTypes BufferedInputStream = BufferedInputStreamParentTypes
type BufferedInputStreamParentTypes = '[FilterInputStream, InputStream, GObject.Object, Seekable]

instance GObject BufferedInputStream where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_buffered_input_stream_get_type
    

class GObject o => BufferedInputStreamK o
instance (GObject o, IsDescendantOf BufferedInputStream o) => BufferedInputStreamK o

toBufferedInputStream :: BufferedInputStreamK o => o -> IO BufferedInputStream
toBufferedInputStream = unsafeCastTo BufferedInputStream

noBufferedInputStream :: Maybe BufferedInputStream
noBufferedInputStream = Nothing

-- VVV Prop "buffer-size"
   -- Type: TBasicType TUInt32
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]

getBufferedInputStreamBufferSize :: (MonadIO m, BufferedInputStreamK o) => o -> m Word32
getBufferedInputStreamBufferSize obj = liftIO $ getObjectPropertyCUInt obj "buffer-size"

setBufferedInputStreamBufferSize :: (MonadIO m, BufferedInputStreamK o) => o -> Word32 -> m ()
setBufferedInputStreamBufferSize obj val = liftIO $ setObjectPropertyCUInt obj "buffer-size" val

constructBufferedInputStreamBufferSize :: Word32 -> IO ([Char], GValue)
constructBufferedInputStreamBufferSize val = constructObjectPropertyCUInt "buffer-size" val

data BufferedInputStreamBufferSizePropertyInfo
instance AttrInfo BufferedInputStreamBufferSizePropertyInfo where
    type AttrAllowedOps BufferedInputStreamBufferSizePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint BufferedInputStreamBufferSizePropertyInfo = (~) Word32
    type AttrBaseTypeConstraint BufferedInputStreamBufferSizePropertyInfo = BufferedInputStreamK
    type AttrGetType BufferedInputStreamBufferSizePropertyInfo = Word32
    type AttrLabel BufferedInputStreamBufferSizePropertyInfo = "BufferedInputStream::buffer-size"
    attrGet _ = getBufferedInputStreamBufferSize
    attrSet _ = setBufferedInputStreamBufferSize
    attrConstruct _ = constructBufferedInputStreamBufferSize

type instance AttributeList BufferedInputStream = BufferedInputStreamAttributeList
type BufferedInputStreamAttributeList = ('[ '("base-stream", FilterInputStreamBaseStreamPropertyInfo), '("buffer-size", BufferedInputStreamBufferSizePropertyInfo), '("close-base-stream", FilterInputStreamCloseBaseStreamPropertyInfo)] :: [(Symbol, *)])

type instance SignalList BufferedInputStream = BufferedInputStreamSignalList
type BufferedInputStreamSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method BufferedInputStream::new
-- method type : Constructor
-- Args : [Arg {argName = "base_stream", argType = TInterface "Gio" "InputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "base_stream", argType = TInterface "Gio" "InputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "BufferedInputStream"
-- throws : False
-- Skip return : False

foreign import ccall "g_buffered_input_stream_new" g_buffered_input_stream_new :: 
    Ptr InputStream ->                      -- base_stream : TInterface "Gio" "InputStream"
    IO (Ptr BufferedInputStream)


bufferedInputStreamNew ::
    (MonadIO m, InputStreamK a) =>
    a ->                                    -- base_stream
    m BufferedInputStream
bufferedInputStreamNew base_stream = liftIO $ do
    let base_stream' = unsafeManagedPtrCastPtr base_stream
    result <- g_buffered_input_stream_new base_stream'
    checkUnexpectedReturnNULL "g_buffered_input_stream_new" result
    result' <- (wrapObject BufferedInputStream) result
    touchManagedPtr base_stream
    return result'

-- method BufferedInputStream::new_sized
-- method type : Constructor
-- Args : [Arg {argName = "base_stream", argType = TInterface "Gio" "InputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "base_stream", argType = TInterface "Gio" "InputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "BufferedInputStream"
-- throws : False
-- Skip return : False

foreign import ccall "g_buffered_input_stream_new_sized" g_buffered_input_stream_new_sized :: 
    Ptr InputStream ->                      -- base_stream : TInterface "Gio" "InputStream"
    Word64 ->                               -- size : TBasicType TUInt64
    IO (Ptr BufferedInputStream)


bufferedInputStreamNewSized ::
    (MonadIO m, InputStreamK a) =>
    a ->                                    -- base_stream
    Word64 ->                               -- size
    m BufferedInputStream
bufferedInputStreamNewSized base_stream size = liftIO $ do
    let base_stream' = unsafeManagedPtrCastPtr base_stream
    result <- g_buffered_input_stream_new_sized base_stream' size
    checkUnexpectedReturnNULL "g_buffered_input_stream_new_sized" result
    result' <- (wrapObject BufferedInputStream) result
    touchManagedPtr base_stream
    return result'

-- method BufferedInputStream::fill
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "count", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "count", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt64
-- throws : True
-- Skip return : False

foreign import ccall "g_buffered_input_stream_fill" g_buffered_input_stream_fill :: 
    Ptr BufferedInputStream ->              -- _obj : TInterface "Gio" "BufferedInputStream"
    Int64 ->                                -- count : TBasicType TInt64
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO Int64


bufferedInputStreamFill ::
    (MonadIO m, BufferedInputStreamK a, CancellableK b) =>
    a ->                                    -- _obj
    Int64 ->                                -- count
    Maybe (b) ->                            -- cancellable
    m Int64
bufferedInputStreamFill _obj count cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_buffered_input_stream_fill _obj' count maybeCancellable
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        return result
     ) (do
        return ()
     )

-- method BufferedInputStream::fill_async
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "count", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "io_priority", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "count", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "io_priority", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_buffered_input_stream_fill_async" g_buffered_input_stream_fill_async :: 
    Ptr BufferedInputStream ->              -- _obj : TInterface "Gio" "BufferedInputStream"
    Int64 ->                                -- count : TBasicType TInt64
    Int32 ->                                -- io_priority : TBasicType TInt32
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


bufferedInputStreamFillAsync ::
    (MonadIO m, BufferedInputStreamK a, CancellableK b) =>
    a ->                                    -- _obj
    Int64 ->                                -- count
    Int32 ->                                -- io_priority
    Maybe (b) ->                            -- cancellable
    Maybe (AsyncReadyCallback) ->           -- callback
    m ()
bufferedInputStreamFillAsync _obj count io_priority cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr AsyncReadyCallbackC))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- mkAsyncReadyCallback (asyncReadyCallbackWrapper (Just ptrcallback) jCallback)
            poke ptrcallback jCallback'
            return jCallback'
    let user_data = nullPtr
    g_buffered_input_stream_fill_async _obj' count io_priority maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    whenJust cancellable touchManagedPtr
    return ()

-- method BufferedInputStream::fill_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt64
-- throws : True
-- Skip return : False

foreign import ccall "g_buffered_input_stream_fill_finish" g_buffered_input_stream_fill_finish :: 
    Ptr BufferedInputStream ->              -- _obj : TInterface "Gio" "BufferedInputStream"
    Ptr AsyncResult ->                      -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO Int64


bufferedInputStreamFillFinish ::
    (MonadIO m, BufferedInputStreamK a, AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m Int64
bufferedInputStreamFillFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ g_buffered_input_stream_fill_finish _obj' result_'
        touchManagedPtr _obj
        touchManagedPtr result_
        return result
     ) (do
        return ()
     )

-- method BufferedInputStream::get_available
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt64
-- throws : False
-- Skip return : False

foreign import ccall "g_buffered_input_stream_get_available" g_buffered_input_stream_get_available :: 
    Ptr BufferedInputStream ->              -- _obj : TInterface "Gio" "BufferedInputStream"
    IO Word64


bufferedInputStreamGetAvailable ::
    (MonadIO m, BufferedInputStreamK a) =>
    a ->                                    -- _obj
    m Word64
bufferedInputStreamGetAvailable _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_buffered_input_stream_get_available _obj'
    touchManagedPtr _obj
    return result

-- method BufferedInputStream::get_buffer_size
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt64
-- throws : False
-- Skip return : False

foreign import ccall "g_buffered_input_stream_get_buffer_size" g_buffered_input_stream_get_buffer_size :: 
    Ptr BufferedInputStream ->              -- _obj : TInterface "Gio" "BufferedInputStream"
    IO Word64


bufferedInputStreamGetBufferSize ::
    (MonadIO m, BufferedInputStreamK a) =>
    a ->                                    -- _obj
    m Word64
bufferedInputStreamGetBufferSize _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_buffered_input_stream_get_buffer_size _obj'
    touchManagedPtr _obj
    return result

-- method BufferedInputStream::peek
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TCArray False (-1) 3 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "offset", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "count", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "count", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TCArray False (-1) 3 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "offset", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt64
-- throws : False
-- Skip return : False

foreign import ccall "g_buffered_input_stream_peek" g_buffered_input_stream_peek :: 
    Ptr BufferedInputStream ->              -- _obj : TInterface "Gio" "BufferedInputStream"
    Ptr Word8 ->                            -- buffer : TCArray False (-1) 3 (TBasicType TUInt8)
    Word64 ->                               -- offset : TBasicType TUInt64
    Word64 ->                               -- count : TBasicType TUInt64
    IO Word64


bufferedInputStreamPeek ::
    (MonadIO m, BufferedInputStreamK a) =>
    a ->                                    -- _obj
    ByteString ->                           -- buffer
    Word64 ->                               -- offset
    m Word64
bufferedInputStreamPeek _obj buffer offset = liftIO $ do
    let count = fromIntegral $ B.length buffer
    let _obj' = unsafeManagedPtrCastPtr _obj
    buffer' <- packByteString buffer
    result <- g_buffered_input_stream_peek _obj' buffer' offset count
    touchManagedPtr _obj
    freeMem buffer'
    return result

-- method BufferedInputStream::peek_buffer
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "count", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : [Arg {argName = "count", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TCArray False (-1) 1 (TBasicType TUInt8)
-- throws : False
-- Skip return : False

foreign import ccall "g_buffered_input_stream_peek_buffer" g_buffered_input_stream_peek_buffer :: 
    Ptr BufferedInputStream ->              -- _obj : TInterface "Gio" "BufferedInputStream"
    Ptr Word64 ->                           -- count : TBasicType TUInt64
    IO (Ptr Word8)


bufferedInputStreamPeekBuffer ::
    (MonadIO m, BufferedInputStreamK a) =>
    a ->                                    -- _obj
    m ByteString
bufferedInputStreamPeekBuffer _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    count <- allocMem :: IO (Ptr Word64)
    result <- g_buffered_input_stream_peek_buffer _obj' count
    count' <- peek count
    checkUnexpectedReturnNULL "g_buffered_input_stream_peek_buffer" result
    result' <- (unpackByteStringWithLength count') result
    touchManagedPtr _obj
    freeMem count
    return result'

-- method BufferedInputStream::read_byte
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : True
-- Skip return : False

foreign import ccall "g_buffered_input_stream_read_byte" g_buffered_input_stream_read_byte :: 
    Ptr BufferedInputStream ->              -- _obj : TInterface "Gio" "BufferedInputStream"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO Int32


bufferedInputStreamReadByte ::
    (MonadIO m, BufferedInputStreamK a, CancellableK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- cancellable
    m Int32
bufferedInputStreamReadByte _obj cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_buffered_input_stream_read_byte _obj' maybeCancellable
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        return result
     ) (do
        return ()
     )

-- method BufferedInputStream::set_buffer_size
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "BufferedInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_buffered_input_stream_set_buffer_size" g_buffered_input_stream_set_buffer_size :: 
    Ptr BufferedInputStream ->              -- _obj : TInterface "Gio" "BufferedInputStream"
    Word64 ->                               -- size : TBasicType TUInt64
    IO ()


bufferedInputStreamSetBufferSize ::
    (MonadIO m, BufferedInputStreamK a) =>
    a ->                                    -- _obj
    Word64 ->                               -- size
    m ()
bufferedInputStreamSetBufferSize _obj size = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_buffered_input_stream_set_buffer_size _obj' size
    touchManagedPtr _obj
    return ()