mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2024-11-22 16:57:00 +00:00
Generator: use mkName instead of newName (#37)
This commit is contained in:
parent
d4aec47f4e
commit
06921defb1
@ -92,7 +92,7 @@ headers = $( do
|
|||||||
( unlines ( map Megaparsec.parseErrorPretty . toList $ Megaparsec.bundleErrors err ) ) <> "\n" <>
|
( unlines ( map Megaparsec.parseErrorPretty . toList $ Megaparsec.bundleErrors err ) ) <> "\n" <>
|
||||||
( unlines ( map show prev ) <> "\n\n" <> unlines ( map show rest ) )
|
( unlines ( map show prev ) <> "\n\n" <> unlines ( map show rest ) )
|
||||||
Right res -> pure res
|
Right res -> pure res
|
||||||
TH.lift =<< generateNames basicHeaders
|
TH.lift $ generateNames basicHeaders
|
||||||
)
|
)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
module DearImGui.Generator.Types where
|
module DearImGui.Generator.Types where
|
||||||
|
|
||||||
-- base
|
-- base
|
||||||
import Data.Traversable
|
import Data.Functor
|
||||||
( for )
|
( (<&>) )
|
||||||
|
|
||||||
-- template-haskell
|
-- template-haskell
|
||||||
import qualified Language.Haskell.TH as TH
|
import qualified Language.Haskell.TH as TH
|
||||||
@ -50,13 +50,16 @@ data Headers typeName
|
|||||||
{ enums :: [ Enumeration typeName ] }
|
{ enums :: [ Enumeration typeName ] }
|
||||||
deriving stock ( Show, TH.Lift )
|
deriving stock ( Show, TH.Lift )
|
||||||
|
|
||||||
generateNames :: Headers () -> TH.Q ( Headers ( TH.Name, TH.Name ) )
|
generateNames :: Headers () -> Headers ( TH.Name, TH.Name )
|
||||||
generateNames ( Headers { enums = basicEnums } ) = do
|
generateNames ( Headers { enums = basicEnums } ) = Headers { enums = namedEnums }
|
||||||
enums <- for basicEnums \ enum@( Enumeration { enumName } ) -> do
|
where
|
||||||
let
|
namedEnums :: [ Enumeration ( TH.Name, TH.Name ) ]
|
||||||
enumNameStr :: String
|
namedEnums = basicEnums <&> \ enum@( Enumeration { enumName } ) ->
|
||||||
enumNameStr = Text.unpack enumName
|
let
|
||||||
tyName <- TH.newName enumNameStr
|
enumNameStr :: String
|
||||||
conName <- TH.newName enumNameStr
|
enumNameStr = Text.unpack enumName
|
||||||
pure $ enum { enumTypeName = ( tyName, conName ) }
|
tyName, conName :: TH.Name
|
||||||
pure $ Headers { enums }
|
tyName = TH.mkName enumNameStr
|
||||||
|
conName = TH.mkName enumNameStr
|
||||||
|
in
|
||||||
|
enum { enumTypeName = ( tyName, conName ) }
|
||||||
|
Loading…
Reference in New Issue
Block a user