{-# 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 = return . SomeArrayBuffer
#endif
{-# INLINE mutableArrayBufferFromJSVal #-}
mutableArrayBufferToJSVal :: MutableArrayBuffer -> JSM JSVal
#ifdef ghcjs_HOST_OS
mutableArrayBufferToJSVal = return . pToJSVal
#else
mutableArrayBufferToJSVal (SomeArrayBuffer v) = return v
#endif
{-# INLINE mutableArrayBufferToJSVal #-}