{-# LINE 1 "src/NanoVG/Internal/CreateContext.chs" #-}
module NanoVG.Internal.CreateContext where
import qualified Foreign.Ptr as C2HSImp
import Foreign.C.Types
import Data.Word (Word32(..))
{-# LINE 9 "src/NanoVG/Internal/CreateContext.chs" #-}
data CreateFlags = Antialias
| StencilStrokes
| Debug
deriving (Show,Read,Eq,Ord)
instance Enum CreateFlags where
succ :: CreateFlags -> CreateFlags
succ CreateFlags
Antialias = CreateFlags
StencilStrokes
succ StencilStrokes = Debug
succ Debug = error "CreateFlags.succ: Debug has no successor"
pred StencilStrokes = Antialias
pred Debug = StencilStrokes
pred Antialias = error "CreateFlags.pred: Antialias has no predecessor"
enumFromTo :: CreateFlags -> CreateFlags -> [CreateFlags]
enumFromTo CreateFlags
from CreateFlags
to = CreateFlags -> [CreateFlags]
forall t. Enum t => t -> [t]
go CreateFlags
from
where
end :: Int
end = CreateFlags -> Int
forall a. Enum a => a -> Int
fromEnum CreateFlags
to
go :: t -> [t]
go t
v = case Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (t -> Int
forall a. Enum a => a -> Int
fromEnum t
v) Int
end of
Ordering
LT -> t
v t -> [t] -> [t]
forall a. a -> [a] -> [a]
: t -> [t]
go (t -> t
forall a. Enum a => a -> a
succ t
v)
Ordering
EQ -> [t
v]
Ordering
GT -> []
enumFrom :: CreateFlags -> [CreateFlags]
enumFrom CreateFlags
from = CreateFlags -> CreateFlags -> [CreateFlags]
forall a. Enum a => a -> a -> [a]
enumFromTo CreateFlags
from CreateFlags
Debug
fromEnum :: CreateFlags -> Int
fromEnum CreateFlags
Antialias = Int
1
fromEnum CreateFlags
StencilStrokes = Int
2
fromEnum CreateFlags
Debug = Int
4
toEnum :: Int -> CreateFlags
toEnum Int
1 = CreateFlags
Antialias
toEnum Int
2 = CreateFlags
StencilStrokes
toEnum Int
4 = CreateFlags
Debug
toEnum Int
unmatched = String -> CreateFlags
forall a. HasCallStack => String -> a
error (String
"CreateFlags.toEnum: Cannot match " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
unmatched)
{-# LINE 13 "src/NanoVG/Internal/CreateContext.chs" #-}
type GLuint = Word32
toCInt :: CreateFlags -> CInt
toCInt = fromIntegral . fromEnum
fromCInt :: CInt -> CreateFlags
fromCInt = toEnum . fromIntegral