-- GENERATED by C->Haskell Compiler, version 0.28.3 Switcheroo, 25 November 2017 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# 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 Antialias = 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 from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from Debug

  fromEnum Antialias = 1
  fromEnum StencilStrokes = 2
  fromEnum Debug = 4

  toEnum 1 = Antialias
  toEnum 2 = StencilStrokes
  toEnum 4 = Debug
  toEnum unmatched = error ("CreateFlags.toEnum: Cannot match " ++ show unmatched)

{-# LINE 13 "src/NanoVG/Internal/CreateContext.chs" #-}


type GLuint = Word32

toCInt :: CreateFlags -> CInt
toCInt = fromIntegral . fromEnum

fromCInt :: CInt -> CreateFlags
fromCInt = toEnum . fromIntegral