From 6195b32afd6a244691dec869710e2d02027a6f6c Mon Sep 17 00:00:00 2001 From: Stefan Dresselhaus Date: Mon, 17 Jul 2023 17:50:17 +0200 Subject: [PATCH] upgraded imgui to v1.89.7; Downstream-breakage **possible** --- dear-imgui.cabal | 2 +- generator/DearImGui/Generator/Parser.hs | 31 +++++++++++++++++++------ imgui | 2 +- src/DearImGui/SDL.hs | 2 +- src/DearImGui/SDL/OpenGL.hs | 2 +- src/DearImGui/SDL/Vulkan.hs | 2 +- 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/dear-imgui.cabal b/dear-imgui.cabal index 85573b2..ee40285 100644 --- a/dear-imgui.cabal +++ b/dear-imgui.cabal @@ -243,7 +243,7 @@ library build-depends: sdl2 cxx-sources: - imgui/backends/imgui_impl_sdl.cpp + imgui/backends/imgui_impl_sdl2.cpp if os(windows) || os(darwin) extra-libraries: diff --git a/generator/DearImGui/Generator/Parser.hs b/generator/DearImGui/Generator/Parser.hs index 75bb1de..db7399c 100644 --- a/generator/DearImGui/Generator/Parser.hs +++ b/generator/DearImGui/Generator/Parser.hs @@ -60,7 +60,7 @@ import Data.Text ( Text ) import qualified Data.Text as Text ( all, any, breakOn, drop, dropWhile, dropWhileEnd - , length, stripPrefix, unlines, unpack + , length, stripPrefix, unlines, unpack, pack ) -- transformers @@ -81,6 +81,8 @@ import DearImGui.Generator.Tokeniser import DearImGui.Generator.Types ( Comment(..), Enumeration(..), Headers(..) ) +import qualified Text.Show as Text + -------------------------------------------------------------------------------- -- Parse error type. @@ -90,7 +92,9 @@ data CustomParseError , problems :: ![Text] } | MissingForwardDeclaration - { enumName :: !Text } + { enumName :: !Text + , library :: HashMap Text ( TH.Name, Comment ) + } | UnexpectedSection { sectionName :: !Text , problem :: ![Text] @@ -101,8 +105,9 @@ instance ShowErrorComponent CustomParseError where showErrorComponent ( Couldn'tLookupEnumValues { enumName, problems } ) = Text.unpack $ "Couldn't lookup the following values in enum " <> enumName <> ":\n" <> Text.unlines ( map ( " - " <> ) problems ) - showErrorComponent ( MissingForwardDeclaration { enumName } ) = Text.unpack $ - "Missing forward declaration for enum named " <> enumName + showErrorComponent ( MissingForwardDeclaration { enumName, library } ) = Text.unpack $ + "Missing forward declaration for enum named " <> enumName <> "\n" + <> "In Library: " <> Text.pack ( Text.show library) showErrorComponent ( UnexpectedSection { sectionName, problem } ) = Text.unpack $ "Unexpected section name.\n\ \Expected: " <> sectionName <> "\n\ @@ -124,6 +129,7 @@ headers = do ( _defines, basicEnums ) <- partitionEithers <$> manyTill ( ( Left <$> try ignoreDefine ) + <|> ( Left <$> try cppConditional ) <|> ( Right <$> enumeration enumNamesAndTypes ) ) ( namedSection "Helpers: Memory allocations macros, ImVector<>" ) @@ -134,7 +140,7 @@ headers = do _ <- skipManyTill anySingle ( namedSection "Misc data structures" ) - _ <- skipManyTill anySingle ( namedSection "Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, ImColor)" ) + _ <- skipManyTill anySingle ( namedSection "Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, Math Operators, ImColor)" ) _ <- skipManyTill anySingle ( namedSection "Drawing API (ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawListFlags, ImDrawList, ImDrawData)" ) skipManyTill anySingle ( try . lookAhead $ many comment *> keyword "enum" ) @@ -171,14 +177,24 @@ forwardDeclarations = do pure ( structName, doc ) _ <- many comment enums <- many do + keyword "enum" + enumName <- identifier + symbol ":" + ty <- cTypeName + reservedSymbol ';' + doc <- commentText <$> comment + pure ( enumName, ( ty, CommentText <$> Text.drop 2 . snd $ Text.breakOn "//" doc ) ) + _ <- many comment + typedefs <- many do keyword "typedef" ty <- cTypeName enumName <- identifier reservedSymbol ';' doc <- commentText <$> comment + _ <- many comment pure ( enumName, ( ty, CommentText <$> Text.drop 2 . snd $ Text.breakOn "//" doc ) ) -- Stopping after simple structs and enums for now. - pure ( HashMap.fromList structs, HashMap.fromList enums ) + pure ( HashMap.fromList structs, HashMap.fromList (enums <> typedefs) ) cTypeName :: MonadParsec e [Tok] m => m TH.Name cTypeName = keyword "int" $> ''CInt @@ -200,6 +216,7 @@ enumeration enumNamesAndTypes = do keyword "enum" pure inlineDocs fullEnumName <- identifier + _ <- try $ (symbol ":" >> cTypeName >> pure ()) <|> pure () let enumName :: Text enumName = Text.dropWhileEnd ( == '_' ) fullEnumName @@ -207,7 +224,7 @@ enumeration enumNamesAndTypes = do enumTypeName = () ( underlyingType, forwardDoc ) <- case HashMap.lookup enumName enumNamesAndTypes of Just res -> pure res - Nothing -> customFailure ( MissingForwardDeclaration { enumName } ) + Nothing -> customFailure ( MissingForwardDeclaration { enumName, library=enumNamesAndTypes } ) let docs :: [Comment] docs = forwardDoc : CommentText "" : inlineDocs diff --git a/imgui b/imgui index 9aae45e..d4ddc46 160000 --- a/imgui +++ b/imgui @@ -1 +1 @@ -Subproject commit 9aae45eb4a05a5a1f96be1ef37eb503a12ceb889 +Subproject commit d4ddc46e7773e9a9b68f965d007968f35ca4e09a diff --git a/src/DearImGui/SDL.hs b/src/DearImGui/SDL.hs index b67e39c..9e91041 100644 --- a/src/DearImGui/SDL.hs +++ b/src/DearImGui/SDL.hs @@ -50,7 +50,7 @@ import Control.Monad.IO.Class C.context (Cpp.cppCtx <> C.bsCtx) C.include "imgui.h" -C.include "backends/imgui_impl_sdl.h" +C.include "backends/imgui_impl_sdl2.h" C.include "SDL.h" Cpp.using "namespace ImGui" diff --git a/src/DearImGui/SDL/OpenGL.hs b/src/DearImGui/SDL/OpenGL.hs index 7ae7bfa..bc92420 100644 --- a/src/DearImGui/SDL/OpenGL.hs +++ b/src/DearImGui/SDL/OpenGL.hs @@ -42,7 +42,7 @@ import Control.Monad.IO.Class C.context (Cpp.cppCtx <> C.bsCtx) C.include "imgui.h" C.include "backends/imgui_impl_opengl2.h" -C.include "backends/imgui_impl_sdl.h" +C.include "backends/imgui_impl_sdl2.h" C.include "SDL.h" C.include "SDL_opengl.h" Cpp.using "namespace ImGui" diff --git a/src/DearImGui/SDL/Vulkan.hs b/src/DearImGui/SDL/Vulkan.hs index 1aa7448..85161c8 100644 --- a/src/DearImGui/SDL/Vulkan.hs +++ b/src/DearImGui/SDL/Vulkan.hs @@ -33,7 +33,7 @@ import Control.Monad.IO.Class ( MonadIO, liftIO ) C.context Cpp.cppCtx C.include "imgui.h" C.include "backends/imgui_impl_vulkan.h" -C.include "backends/imgui_impl_sdl.h" +C.include "backends/imgui_impl_sdl2.h" C.include "SDL.h" C.include "SDL_vulkan.h" Cpp.using "namespace ImGui"