{-# LINE 1 "lib/CPython/Types/Dictionary.chs" #-}
{-# LANGUAGE ForeignFunctionInterface #-}
module CPython.Types.Dictionary
( Dictionary
, dictionaryType
, new
, clear
, contains
, copy
, getItem
, setItem
, deleteItem
, items
, keys
, values
, size
, merge
, update
, mergeFromSeq2
) where
import CPython.Internal hiding (new)
instance Concrete Dictionary where
concreteType _ = dictionaryType
dictionaryType :: (Type)
dictionaryType =
unsafePerformIO $
let {res = dictionaryType'_} in
peekStaticObject res >>= \res' ->
return (res')
{-# LINE 45 "lib/CPython/Types/Dictionary.chs" #-}
new :: IO ((Dictionary))
new =
new'_ >>= \res ->
stealObject res >>= \res' ->
return (res')
{-# LINE 48 "lib/CPython/Types/Dictionary.chs" #-}
clear :: (Dictionary) -> IO ((()))
clear a1 =
withObject a1 $ \a1' ->
clear'_ a1' >>= \res ->
let {res' = id res} in
return (res')
{-# LINE 55 "lib/CPython/Types/Dictionary.chs" #-}
contains :: Object key => (Dictionary) -> (key) -> IO ((Bool))
contains a1 a2 =
withObject a1 $ \a1' ->
withObject a2 $ \a2' ->
contains'_ a1' a2' >>= \res ->
checkBoolReturn res >>= \res' ->
return (res')
{-# LINE 64 "lib/CPython/Types/Dictionary.chs" #-}
copy :: (Dictionary) -> IO ((Dictionary))
copy a1 =
withObject a1 $ \a1' ->
copy'_ a1' >>= \res ->
stealObject res >>= \res' ->
return (res')
{-# LINE 70 "lib/CPython/Types/Dictionary.chs" #-}
getItem :: Object key => Dictionary -> key -> IO (Maybe SomeObject)
getItem dict key =
withObject dict $ \dict' ->
withObject key $ \key' -> do
pyErrClear
{-# LINE 78 "lib/CPython/Types/Dictionary.chs" #-}
raw <- pyDictGetItemWithError dict' key'
if raw /= nullPtr
then Just `fmap` peekObject raw
else do
exc <- pyErrOccurred
{-# LINE 83 "lib/CPython/Types/Dictionary.chs" #-}
exceptionIf $ exc /= nullPtr
return Nothing
setItem :: (Object key, Object value) => (Dictionary) -> (key) -> (value) -> IO ((()))
setItem a1 a2 a3 =
withObject a1 $ \a1' ->
withObject a2 $ \a2' ->
withObject a3 $ \a3' ->
setItem'_ a1' a2' a3' >>= \res ->
checkStatusCode res >>= \res' ->
return (res')
{-# LINE 96 "lib/CPython/Types/Dictionary.chs" #-}
deleteItem :: Object key => (Dictionary) -> (key) -> IO ((()))
deleteItem a1 a2 =
withObject a1 $ \a1' ->
withObject a2 $ \a2' ->
deleteItem'_ a1' a2' >>= \res ->
checkStatusCode res >>= \res' ->
return (res')
{-# LINE 106 "lib/CPython/Types/Dictionary.chs" #-}
items :: (Dictionary) -> IO ((List))
items a1 =
withObject a1 $ \a1' ->
items'_ a1' >>= \res ->
stealObject res >>= \res' ->
return (res')
{-# LINE 114 "lib/CPython/Types/Dictionary.chs" #-}
keys :: (Dictionary) -> IO ((List))
keys a1 =
withObject a1 $ \a1' ->
keys'_ a1' >>= \res ->
stealObject res >>= \res' ->
return (res')
{-# LINE 120 "lib/CPython/Types/Dictionary.chs" #-}
values :: (Dictionary) -> IO ((List))
values a1 =
withObject a1 $ \a1' ->
values'_ a1' >>= \res ->
stealObject res >>= \res' ->
return (res')
{-# LINE 126 "lib/CPython/Types/Dictionary.chs" #-}
size :: (Dictionary) -> IO ((Integer))
size a1 =
withObject a1 $ \a1' ->
size'_ a1' >>= \res ->
checkIntReturn res >>= \res' ->
return (res')
{-# LINE 132 "lib/CPython/Types/Dictionary.chs" #-}
merge :: Mapping b => (Dictionary) -> (b) -> (Bool) -> IO ((()))
merge a1 a2 a3 =
withObject a1 $ \a1' ->
withObject a2 $ \a2' ->
let {a3' = fromBool a3} in
merge'_ a1' a2' a3' >>= \res ->
checkStatusCode res >>= \res' ->
return (res')
{-# LINE 146 "lib/CPython/Types/Dictionary.chs" #-}
update :: Mapping b => (Dictionary) -> (b) -> IO ((()))
update a1 a2 =
withObject a1 $ \a1' ->
withObject a2 $ \a2' ->
update'_ a1' a2' >>= \res ->
checkStatusCode res >>= \res' ->
return (res')
{-# LINE 154 "lib/CPython/Types/Dictionary.chs" #-}
mergeFromSeq2 :: Object seq2 => (Dictionary) -> (seq2) -> (Bool) -> IO ((()))
mergeFromSeq2 a1 a2 a3 =
withObject a1 $ \a1' ->
withObject a2 $ \a2' ->
let {a3' = fromBool a3} in
mergeFromSeq2'_ a1' a2' a3' >>= \res ->
checkStatusCode res >>= \res' ->
return (res')
{-# LINE 173 "lib/CPython/Types/Dictionary.chs" #-}
foreign import ccall unsafe "CPython/Types/Dictionary.chs.h hscpython_PyDict_Type"
dictionaryType'_ :: (Ptr ())
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyDict_New"
new'_ :: (IO (Ptr ()))
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyDict_Clear"
clear'_ :: ((Ptr ()) -> (IO ()))
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyDict_Contains"
contains'_ :: ((Ptr ()) -> ((Ptr ()) -> (IO CInt)))
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyDict_Copy"
copy'_ :: ((Ptr ()) -> (IO (Ptr ())))
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyErr_Clear"
pyErrClear :: (IO ())
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyDict_GetItemWithError"
pyDictGetItemWithError :: ((Ptr ()) -> ((Ptr ()) -> (IO (Ptr ()))))
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyErr_Occurred"
pyErrOccurred :: (IO (Ptr ()))
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyDict_SetItem"
setItem'_ :: ((Ptr ()) -> ((Ptr ()) -> ((Ptr ()) -> (IO CInt))))
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyDict_DelItem"
deleteItem'_ :: ((Ptr ()) -> ((Ptr ()) -> (IO CInt)))
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyDict_Items"
items'_ :: ((Ptr ()) -> (IO (Ptr ())))
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyDict_Keys"
keys'_ :: ((Ptr ()) -> (IO (Ptr ())))
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyDict_Values"
values'_ :: ((Ptr ()) -> (IO (Ptr ())))
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyDict_Size"
size'_ :: ((Ptr ()) -> (IO CLong))
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyDict_Merge"
merge'_ :: ((Ptr ()) -> ((Ptr ()) -> (CInt -> (IO CInt))))
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyDict_Update"
update'_ :: ((Ptr ()) -> ((Ptr ()) -> (IO CInt)))
foreign import ccall safe "CPython/Types/Dictionary.chs.h PyDict_MergeFromSeq2"
mergeFromSeq2'_ :: ((Ptr ()) -> ((Ptr ()) -> (CInt -> (IO CInt))))