{-# LINE 1 "Graphics/UI/SDL/Version.hsc" #-}
{-# LINE 5 "Graphics/UI/SDL/Version.hsc" #-}
module Graphics.UI.SDL.Version
( compiledFor
, linkedWith
) where
import Data.Version (Version(Version))
import Foreign (Word8, Ptr, Storable(sizeOf, alignment, peekByteOff, peek))
data SDLVersion
= SDLVersion Word8 Word8 Word8
instance Storable SDLVersion where
sizeOf :: SDLVersion -> Int
sizeOf SDLVersion
_ = (Int
3)
{-# LINE 19 "Graphics/UI/SDL/Version.hsc" #-}
alignment _ = 1
peek :: Ptr SDLVersion -> IO SDLVersion
peek Ptr SDLVersion
ptr = do Word8
major <- (\Ptr SDLVersion
hsc_ptr -> Ptr SDLVersion -> Int -> IO Word8
forall b. Ptr b -> Int -> IO Word8
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr SDLVersion
hsc_ptr Int
0) Ptr SDLVersion
ptr
{-# LINE 21 "Graphics/UI/SDL/Version.hsc" #-}
Word8
minor <- (\Ptr SDLVersion
hsc_ptr -> Ptr SDLVersion -> Int -> IO Word8
forall b. Ptr b -> Int -> IO Word8
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr SDLVersion
hsc_ptr Int
1) Ptr SDLVersion
ptr
{-# LINE 22 "Graphics/UI/SDL/Version.hsc" #-}
Word8
patch <- (\Ptr SDLVersion
hsc_ptr -> Ptr SDLVersion -> Int -> IO Word8
forall b. Ptr b -> Int -> IO Word8
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr SDLVersion
hsc_ptr Int
2) Ptr SDLVersion
ptr
{-# LINE 23 "Graphics/UI/SDL/Version.hsc" #-}
SDLVersion -> IO SDLVersion
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Word8 -> Word8 -> Word8 -> SDLVersion
SDLVersion Word8
major Word8
minor Word8
patch)
compiledFor :: Version
compiledFor :: Version
compiledFor = [Int] -> [String] -> Version
Version [ Int
1
{-# LINE 27 "Graphics/UI/SDL/Version.hsc" #-}
, Int
2
{-# LINE 28 "Graphics/UI/SDL/Version.hsc" #-}
, Int
68
{-# LINE 29 "Graphics/UI/SDL/Version.hsc" #-}
] []
foreign import ccall unsafe "SDL_Linked_Version" sdlLinkedVersion :: IO (Ptr SDLVersion)
linkedWith :: IO Version
linkedWith :: IO Version
linkedWith = do Ptr SDLVersion
versionPtr <- IO (Ptr SDLVersion)
sdlLinkedVersion
SDLVersion Word8
major Word8
minor Word8
patch <- Ptr SDLVersion -> IO SDLVersion
forall a. Storable a => Ptr a -> IO a
peek Ptr SDLVersion
versionPtr
Version -> IO Version
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Int] -> [String] -> Version
Version ((Word8 -> Int) -> [Word8] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map Word8 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral [Word8
major,Word8
minor,Word8
patch]) [])