{-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE JavaScriptFFI #-} -- For HasCallStack compatibility {-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-} module GHCJS.DOM.JSFFI.Generated.IDBDatabase (js_createObjectStore, createObjectStore, createObjectStore_, createObjectStoreUnsafe, createObjectStoreUnchecked, js_deleteObjectStore, deleteObjectStore, js_transaction, transaction, transaction_, transactionUnsafe, transactionUnchecked, js_transaction', transaction', transaction'_, transaction'Unsafe, transaction'Unchecked, js_close, close, js_getName, getName, js_getVersion, getVersion, js_getObjectStoreNames, getObjectStoreNames, getObjectStoreNamesUnsafe, getObjectStoreNamesUnchecked, abort, error, versionChange, IDBDatabase(..), gTypeIDBDatabase) where import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, fmap, Show, Read, Eq, Ord) import qualified Prelude (error) import Data.Typeable (Typeable) import GHCJS.Types (JSVal(..), JSString) import GHCJS.Foreign (jsNull) import GHCJS.Foreign.Callback (syncCallback, asyncCallback, syncCallback1, asyncCallback1, syncCallback2, asyncCallback2, OnBlocked(..)) import GHCJS.Marshal (ToJSVal(..), FromJSVal(..)) import GHCJS.Marshal.Pure (PToJSVal(..), PFromJSVal(..)) import Control.Monad (void) import Control.Monad.IO.Class (MonadIO(..)) import Data.Int (Int64) import Data.Word (Word, Word64) import Data.Maybe (fromJust) import GHCJS.DOM.Types import Control.Applicative ((<$>)) import GHCJS.DOM.EventTargetClosures (EventName, unsafeEventName) import GHCJS.DOM.JSFFI.Generated.Enums foreign import javascript unsafe "$1[\"createObjectStore\"]($2, $3)" js_createObjectStore :: IDBDatabase -> JSString -> Nullable Dictionary -> IO (Nullable IDBObjectStore) -- | createObjectStore :: (MonadIO m, ToJSString name, IsDictionary options) => IDBDatabase -> name -> Maybe options -> m (Maybe IDBObjectStore) createObjectStore self name options = liftIO (nullableToMaybe <$> (js_createObjectStore (self) (toJSString name) (maybeToNullable (fmap toDictionary options)))) -- | createObjectStore_ :: (MonadIO m, ToJSString name, IsDictionary options) => IDBDatabase -> name -> Maybe options -> m () createObjectStore_ self name options = liftIO (void (js_createObjectStore (self) (toJSString name) (maybeToNullable (fmap toDictionary options)))) -- | createObjectStoreUnsafe :: (MonadIO m, ToJSString name, IsDictionary options, HasCallStack) => IDBDatabase -> name -> Maybe options -> m IDBObjectStore createObjectStoreUnsafe self name options = liftIO ((nullableToMaybe <$> (js_createObjectStore (self) (toJSString name) (maybeToNullable (fmap toDictionary options)))) >>= maybe (Prelude.error "Nothing to return") return) -- | createObjectStoreUnchecked :: (MonadIO m, ToJSString name, IsDictionary options) => IDBDatabase -> name -> Maybe options -> m IDBObjectStore createObjectStoreUnchecked self name options = liftIO (fromJust . nullableToMaybe <$> (js_createObjectStore (self) (toJSString name) (maybeToNullable (fmap toDictionary options)))) foreign import javascript unsafe "$1[\"deleteObjectStore\"]($2)" js_deleteObjectStore :: IDBDatabase -> JSString -> IO () -- | deleteObjectStore :: (MonadIO m, ToJSString name) => IDBDatabase -> name -> m () deleteObjectStore self name = liftIO (js_deleteObjectStore (self) (toJSString name)) foreign import javascript unsafe "$1[\"transaction\"]($2, $3)" js_transaction :: IDBDatabase -> JSString -> JSString -> IO (Nullable IDBTransaction) -- | transaction :: (MonadIO m, ToJSString storeName, ToJSString mode) => IDBDatabase -> storeName -> mode -> m (Maybe IDBTransaction) transaction self storeName mode = liftIO (nullableToMaybe <$> (js_transaction (self) (toJSString storeName) (toJSString mode))) -- | transaction_ :: (MonadIO m, ToJSString storeName, ToJSString mode) => IDBDatabase -> storeName -> mode -> m () transaction_ self storeName mode = liftIO (void (js_transaction (self) (toJSString storeName) (toJSString mode))) -- | transactionUnsafe :: (MonadIO m, ToJSString storeName, ToJSString mode, HasCallStack) => IDBDatabase -> storeName -> mode -> m IDBTransaction transactionUnsafe self storeName mode = liftIO ((nullableToMaybe <$> (js_transaction (self) (toJSString storeName) (toJSString mode))) >>= maybe (Prelude.error "Nothing to return") return) -- | transactionUnchecked :: (MonadIO m, ToJSString storeName, ToJSString mode) => IDBDatabase -> storeName -> mode -> m IDBTransaction transactionUnchecked self storeName mode = liftIO (fromJust . nullableToMaybe <$> (js_transaction (self) (toJSString storeName) (toJSString mode))) foreign import javascript unsafe "$1[\"transaction\"]($2, $3)" js_transaction' :: IDBDatabase -> JSVal -> JSString -> IO (Nullable IDBTransaction) -- | transaction' :: (MonadIO m, ToJSString storeNames, ToJSString mode) => IDBDatabase -> [storeNames] -> mode -> m (Maybe IDBTransaction) transaction' self storeNames mode = liftIO (nullableToMaybe <$> (toJSVal storeNames >>= \ storeNames' -> js_transaction' (self) storeNames' (toJSString mode))) -- | transaction'_ :: (MonadIO m, ToJSString storeNames, ToJSString mode) => IDBDatabase -> [storeNames] -> mode -> m () transaction'_ self storeNames mode = liftIO (void (toJSVal storeNames >>= \ storeNames' -> js_transaction' (self) storeNames' (toJSString mode))) -- | transaction'Unsafe :: (MonadIO m, ToJSString storeNames, ToJSString mode, HasCallStack) => IDBDatabase -> [storeNames] -> mode -> m IDBTransaction transaction'Unsafe self storeNames mode = liftIO ((nullableToMaybe <$> (toJSVal storeNames >>= \ storeNames' -> js_transaction' (self) storeNames' (toJSString mode))) >>= maybe (Prelude.error "Nothing to return") return) -- | transaction'Unchecked :: (MonadIO m, ToJSString storeNames, ToJSString mode) => IDBDatabase -> [storeNames] -> mode -> m IDBTransaction transaction'Unchecked self storeNames mode = liftIO (fromJust . nullableToMaybe <$> (toJSVal storeNames >>= \ storeNames' -> js_transaction' (self) storeNames' (toJSString mode))) foreign import javascript unsafe "$1[\"close\"]()" js_close :: IDBDatabase -> IO () -- | close :: (MonadIO m) => IDBDatabase -> m () close self = liftIO (js_close (self)) foreign import javascript unsafe "$1[\"name\"]" js_getName :: IDBDatabase -> IO JSString -- | getName :: (MonadIO m, FromJSString result) => IDBDatabase -> m result getName self = liftIO (fromJSString <$> (js_getName (self))) foreign import javascript unsafe "$1[\"version\"]" js_getVersion :: IDBDatabase -> IO Double -- | getVersion :: (MonadIO m) => IDBDatabase -> m Word64 getVersion self = liftIO (round <$> (js_getVersion (self))) foreign import javascript unsafe "$1[\"objectStoreNames\"]" js_getObjectStoreNames :: IDBDatabase -> IO (Nullable DOMStringList) -- | getObjectStoreNames :: (MonadIO m) => IDBDatabase -> m (Maybe DOMStringList) getObjectStoreNames self = liftIO (nullableToMaybe <$> (js_getObjectStoreNames (self))) -- | getObjectStoreNamesUnsafe :: (MonadIO m, HasCallStack) => IDBDatabase -> m DOMStringList getObjectStoreNamesUnsafe self = liftIO ((nullableToMaybe <$> (js_getObjectStoreNames (self))) >>= maybe (Prelude.error "Nothing to return") return) -- | getObjectStoreNamesUnchecked :: (MonadIO m) => IDBDatabase -> m DOMStringList getObjectStoreNamesUnchecked self = liftIO (fromJust . nullableToMaybe <$> (js_getObjectStoreNames (self))) -- | abort :: EventName IDBDatabase Event abort = unsafeEventName (toJSString "abort") -- | error :: EventName IDBDatabase Event error = unsafeEventName (toJSString "error") -- | versionChange :: EventName IDBDatabase IDBVersionChangeEvent versionChange = unsafeEventName (toJSString "versionchange")