mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2025-07-05 12:38:47 +02:00
Parse enums from headers & generate code (#19)
This commit is contained in:
34
src/DearImGui/Enums.hs
Normal file
34
src/DearImGui/Enums.hs
Normal file
@ -0,0 +1,34 @@
|
||||
{-# LANGUAGE AllowAmbiguousTypes #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DerivingStrategies #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
{-# LANGUAGE MagicHash #-}
|
||||
{-# LANGUAGE PatternSynonyms #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE TypeApplications #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
|
||||
module DearImGui.Enums where
|
||||
|
||||
-- base
|
||||
import GHC.Exts
|
||||
( proxy# )
|
||||
import GHC.TypeNats
|
||||
( Nat, KnownNat, natVal' )
|
||||
import Numeric.Natural
|
||||
( Natural )
|
||||
|
||||
-- dear-imgui-generator
|
||||
import DearImGui.Generator
|
||||
( declareEnumerations )
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
class KnownNat ( Count a ) => FiniteEnum a where
|
||||
type Count a :: Nat
|
||||
count :: Natural
|
||||
count = natVal' @( Count a ) proxy#
|
||||
|
||||
declareEnumerations ''FiniteEnum ''Count
|
Reference in New Issue
Block a user