jsaddle-dom-0.10.0.0: src/JSDOM/Generated/GPUBufferDescriptor.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from webgpu (webref). Do not edit.
module JSDOM.Generated.GPUBufferDescriptor
(newGPUBufferDescriptor, setSize, getSize, setUsage, getUsage, setMappedAtCreation, getMappedAtCreation, getMappedAtCreationUnsafe, getMappedAtCreationUnchecked, GPUBufferDescriptor(..), gTypeGPUBufferDescriptor)
where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums
-- | <https://gpuweb.github.io/gpuweb/#gpubufferdescriptor GPUBufferDescriptor specification>
newGPUBufferDescriptor :: (MonadDOM m) => Word53 -> Word -> m GPUBufferDescriptor
newGPUBufferDescriptor size usage = liftDOM ((((new (jsg "Object") () >>= \o -> (o ^. jss "size" (toJSVal size)) P.>> (o ^. jss "usage" (toJSVal usage)) P.>> P.return o)) >>= fromJSValUnchecked))
-- | <https://gpuweb.github.io/gpuweb/#dom-gpubufferdescriptor-size GPUBufferDescriptor.size specification>
setSize :: (MonadDOM m) => GPUBufferDescriptor -> Word53 -> m ()
setSize self val = liftDOM (void (self ^. jss "size" (toJSVal val)))
-- | <https://gpuweb.github.io/gpuweb/#dom-gpubufferdescriptor-size GPUBufferDescriptor.size specification>
getSize :: (MonadDOM m) => GPUBufferDescriptor -> m Word53
getSize self = liftDOM (((self ^. js "size") >>= fromJSValUnchecked))
-- | <https://gpuweb.github.io/gpuweb/#dom-gpubufferdescriptor-usage GPUBufferDescriptor.usage specification>
setUsage :: (MonadDOM m) => GPUBufferDescriptor -> Word -> m ()
setUsage self val = liftDOM (void (self ^. jss "usage" (toJSVal val)))
-- | <https://gpuweb.github.io/gpuweb/#dom-gpubufferdescriptor-usage GPUBufferDescriptor.usage specification>
getUsage :: (MonadDOM m) => GPUBufferDescriptor -> m Word
getUsage self = liftDOM ((P.round <$> ((self ^. js "usage") >>= valToNumber)))
-- | <https://gpuweb.github.io/gpuweb/#dom-gpubufferdescriptor-mappedatcreation GPUBufferDescriptor.mappedAtCreation specification>
setMappedAtCreation :: (MonadDOM m) => GPUBufferDescriptor -> Bool -> m ()
setMappedAtCreation self val = liftDOM (void (self ^. jss "mappedAtCreation" (toJSVal val)))
-- | <https://gpuweb.github.io/gpuweb/#dom-gpubufferdescriptor-mappedatcreation GPUBufferDescriptor.mappedAtCreation specification>
getMappedAtCreation :: (MonadDOM m) => GPUBufferDescriptor -> m (Maybe Bool)
getMappedAtCreation self = liftDOM (((self ^. js "mappedAtCreation") >>= fromJSValUnchecked))
-- | <https://gpuweb.github.io/gpuweb/#dom-gpubufferdescriptor-mappedatcreation GPUBufferDescriptor.mappedAtCreation specification>
getMappedAtCreationUnsafe :: (MonadDOM m, HasCallStack) => GPUBufferDescriptor -> m Bool
getMappedAtCreationUnsafe self = liftDOM ((((self ^. js "mappedAtCreation") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://gpuweb.github.io/gpuweb/#dom-gpubufferdescriptor-mappedatcreation GPUBufferDescriptor.mappedAtCreation specification>
getMappedAtCreationUnchecked :: (MonadDOM m) => GPUBufferDescriptor -> m Bool
getMappedAtCreationUnchecked self = liftDOM (((self ^. js "mappedAtCreation") >>= valToBool))