packages feed

dear-imgui-raw-internal-1.0.0: src/DearImGui/Raw/Internal/ImGuiInputEvent.hsc

{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE PatternSynonyms #-}

-- This file was generated by dear-bindings-ffi. Do not edit by hand.

module DearImGui.Raw.Internal.ImGuiInputEvent
  ( ImGuiInputEvent
  , destroy
  , init
  , withDefault
  ) where

import Control.Exception (bracket_)
import DearImGui.Raw (ImU32)
import DearImGui.Raw.Internal.Enums.ImGuiInputEventType (ImGuiInputEventType)
import DearImGui.Raw.Internal.Enums.ImGuiInputSource (ImGuiInputSource)
import Foreign.C.Types
import Foreign.Marshal.Alloc (alloca)
import Foreign.Ptr (Ptr, plusPtr)
import Foreign.Storable (Storable (..))
import GHC.Records (HasField (..))
import Prelude hiding (init)

#include "dcimgui_nodefaultargfunctions_internal.h"

-- structs (opaque)

data ImGuiInputEvent
instance Storable ImGuiInputEvent where
  sizeOf _    = #{size ImGuiInputEvent}
  alignment _ = #{alignment ImGuiInputEvent}
  peek _ = error "ImGuiInputEvent: opaque struct, peek not supported in v0"
  poke _ _ = error "ImGuiInputEvent: opaque struct, poke not supported in v0"

instance HasField "type_" (Ptr ImGuiInputEvent) (Ptr ImGuiInputEventType) where
  getField = #{ptr ImGuiInputEvent, Type}

instance HasField "source" (Ptr ImGuiInputEvent) (Ptr ImGuiInputSource) where
  getField = #{ptr ImGuiInputEvent, Source}

instance HasField "eventId" (Ptr ImGuiInputEvent) (Ptr ImU32) where
  getField = #{ptr ImGuiInputEvent, EventId}

instance HasField "addedByTestEngine" (Ptr ImGuiInputEvent) (Ptr CBool) where
  getField = #{ptr ImGuiInputEvent, AddedByTestEngine}

foreign import capi unsafe "DearImGuiWrappers.h ImGuiInputEvent_Init_wrap"
  init
    :: Ptr ImGuiInputEvent
    -> IO ()

foreign import capi unsafe "DearImGuiWrappers.h ImGuiInputEvent_Destroy_wrap"
  destroy
    :: Ptr ImGuiInputEvent
    -> IO ()

withDefault :: (Ptr ImGuiInputEvent -> IO a) -> IO a
withDefault k = alloca $ \p -> bracket_ (init p) (destroy p) (k p)