{-# LANGUAGE CPP #-}
module Language.Javascript.JSaddle.Helper where
import GHCJS.Types (JSVal)
import Language.Javascript.JSaddle.Types (JSM)
#ifdef ghcjs_HOST_OS
import GHCJS.Marshal.Pure (pFromJSVal, pToJSVal)
import JavaScript.TypedArray.ArrayBuffer (MutableArrayBuffer)
#else
import JavaScript.TypedArray.ArrayBuffer.Internal (MutableArrayBuffer, SomeArrayBuffer(..))
#endif
mutableArrayBufferFromJSVal :: JSVal -> JSM MutableArrayBuffer
#ifdef ghcjs_HOST_OS
mutableArrayBufferFromJSVal = return . pFromJSVal
#else
mutableArrayBufferFromJSVal :: JSVal -> JSM MutableArrayBuffer
mutableArrayBufferFromJSVal = MutableArrayBuffer -> JSM MutableArrayBuffer
forall a. a -> JSM a
forall (m :: * -> *) a. Monad m => a -> m a
return (MutableArrayBuffer -> JSM MutableArrayBuffer)
-> (JSVal -> MutableArrayBuffer) -> JSVal -> JSM MutableArrayBuffer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSVal -> MutableArrayBuffer
forall s (a :: MutabilityType s). JSVal -> SomeArrayBuffer a
SomeArrayBuffer
#endif
{-# INLINE mutableArrayBufferFromJSVal #-}
mutableArrayBufferToJSVal :: MutableArrayBuffer -> JSM JSVal
#ifdef ghcjs_HOST_OS
mutableArrayBufferToJSVal = return . pToJSVal
#else
mutableArrayBufferToJSVal :: MutableArrayBuffer -> JSM JSVal
mutableArrayBufferToJSVal (SomeArrayBuffer JSVal
v) = JSVal -> JSM JSVal
forall a. a -> JSM a
forall (m :: * -> *) a. Monad m => a -> m a
return JSVal
v
#endif
{-# INLINE mutableArrayBufferToJSVal #-}