{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- Provides information about a location in an SVG document.
-- 
-- The information should be considered approximate; it is
-- meant to provide feedback for errors in an editor.
-- 
-- /Since: 4.22/

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Gtk.Structs.SvgLocation
    ( 

-- * Exported types
    SvgLocation(..)                         ,
    newZeroSvgLocation                      ,


 -- * Methods

#if defined(ENABLE_OVERLOADING)
    ResolveSvgLocationMethod                ,
#endif



 -- * Properties


-- ** bytes #attr:bytes#
-- | the byte index in document. If unknown, this will
--   be zero (which is also a valid value, but only if all
--   three values are zero)

    getSvgLocationBytes                     ,
    setSvgLocationBytes                     ,
#if defined(ENABLE_OVERLOADING)
    svgLocation_bytes                       ,
#endif


-- ** lineChars #attr:lineChars#
-- | the char index in the line, 0-based

    getSvgLocationLineChars                 ,
    setSvgLocationLineChars                 ,
#if defined(ENABLE_OVERLOADING)
    svgLocation_lineChars                   ,
#endif


-- ** lines #attr:lines#
-- | the line index in the document, 0-based

    getSvgLocationLines                     ,
    setSvgLocationLines                     ,
#if defined(ENABLE_OVERLOADING)
    svgLocation_lines                       ,
#endif




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)

#else

#endif

-- | Memory-managed wrapper type.
newtype SvgLocation = SvgLocation (SP.ManagedPtr SvgLocation)
    deriving (Eq)

instance SP.ManagedPtrNewtype SvgLocation where
    toManagedPtr (SvgLocation p) = p

instance BoxedPtr SvgLocation where
    boxedPtrCopy = \p -> B.ManagedPtr.withManagedPtr p (copyBytes 24 >=> B.ManagedPtr.wrapPtr SvgLocation)
    boxedPtrFree = \x -> SP.withManagedPtr x SP.freeMem
instance CallocPtr SvgLocation where
    boxedPtrCalloc = callocBytes 24


-- | Construct a t'SvgLocation' struct initialized to zero.
newZeroSvgLocation :: MonadIO m => m SvgLocation
newZeroSvgLocation = liftIO $ boxedPtrCalloc >>= wrapPtr SvgLocation

instance tag ~ 'AttrSet => Constructible SvgLocation tag where
    new _ attrs = do
        o <- newZeroSvgLocation
        GI.Attributes.set o attrs
        return o


-- | Get the value of the “@bytes@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' svgLocation #bytes
-- @
getSvgLocationBytes :: MonadIO m => SvgLocation -> m FCT.CSize
getSvgLocationBytes s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO FCT.CSize
    return val

-- | Set the value of the “@bytes@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' svgLocation [ #bytes 'Data.GI.Base.Attributes.:=' value ]
-- @
setSvgLocationBytes :: MonadIO m => SvgLocation -> FCT.CSize -> m ()
setSvgLocationBytes s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 0) (val :: FCT.CSize)

#if defined(ENABLE_OVERLOADING)
data SvgLocationBytesFieldInfo
instance AttrInfo SvgLocationBytesFieldInfo where
    type AttrBaseTypeConstraint SvgLocationBytesFieldInfo = (~) SvgLocation
    type AttrAllowedOps SvgLocationBytesFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint SvgLocationBytesFieldInfo = (~) FCT.CSize
    type AttrTransferTypeConstraint SvgLocationBytesFieldInfo = (~)FCT.CSize
    type AttrTransferType SvgLocationBytesFieldInfo = FCT.CSize
    type AttrGetType SvgLocationBytesFieldInfo = FCT.CSize
    type AttrLabel SvgLocationBytesFieldInfo = "bytes"
    type AttrOrigin SvgLocationBytesFieldInfo = SvgLocation
    attrGet = getSvgLocationBytes
    attrSet = setSvgLocationBytes
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gtk.Structs.SvgLocation.bytes"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gtk-4.0.11/docs/GI-Gtk-Structs-SvgLocation.html#g:attr:bytes"
        })

svgLocation_bytes :: AttrLabelProxy "bytes"
svgLocation_bytes = AttrLabelProxy

#endif


-- | Get the value of the “@lines@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' svgLocation #lines
-- @
getSvgLocationLines :: MonadIO m => SvgLocation -> m FCT.CSize
getSvgLocationLines s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO FCT.CSize
    return val

-- | Set the value of the “@lines@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' svgLocation [ #lines 'Data.GI.Base.Attributes.:=' value ]
-- @
setSvgLocationLines :: MonadIO m => SvgLocation -> FCT.CSize -> m ()
setSvgLocationLines s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (val :: FCT.CSize)

#if defined(ENABLE_OVERLOADING)
data SvgLocationLinesFieldInfo
instance AttrInfo SvgLocationLinesFieldInfo where
    type AttrBaseTypeConstraint SvgLocationLinesFieldInfo = (~) SvgLocation
    type AttrAllowedOps SvgLocationLinesFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint SvgLocationLinesFieldInfo = (~) FCT.CSize
    type AttrTransferTypeConstraint SvgLocationLinesFieldInfo = (~)FCT.CSize
    type AttrTransferType SvgLocationLinesFieldInfo = FCT.CSize
    type AttrGetType SvgLocationLinesFieldInfo = FCT.CSize
    type AttrLabel SvgLocationLinesFieldInfo = "lines"
    type AttrOrigin SvgLocationLinesFieldInfo = SvgLocation
    attrGet = getSvgLocationLines
    attrSet = setSvgLocationLines
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gtk.Structs.SvgLocation.lines"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gtk-4.0.11/docs/GI-Gtk-Structs-SvgLocation.html#g:attr:lines"
        })

svgLocation_lines :: AttrLabelProxy "lines"
svgLocation_lines = AttrLabelProxy

#endif


-- | Get the value of the “@line_chars@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' svgLocation #lineChars
-- @
getSvgLocationLineChars :: MonadIO m => SvgLocation -> m FCT.CSize
getSvgLocationLineChars s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO FCT.CSize
    return val

-- | Set the value of the “@line_chars@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' svgLocation [ #lineChars 'Data.GI.Base.Attributes.:=' value ]
-- @
setSvgLocationLineChars :: MonadIO m => SvgLocation -> FCT.CSize -> m ()
setSvgLocationLineChars s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 16) (val :: FCT.CSize)

#if defined(ENABLE_OVERLOADING)
data SvgLocationLineCharsFieldInfo
instance AttrInfo SvgLocationLineCharsFieldInfo where
    type AttrBaseTypeConstraint SvgLocationLineCharsFieldInfo = (~) SvgLocation
    type AttrAllowedOps SvgLocationLineCharsFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint SvgLocationLineCharsFieldInfo = (~) FCT.CSize
    type AttrTransferTypeConstraint SvgLocationLineCharsFieldInfo = (~)FCT.CSize
    type AttrTransferType SvgLocationLineCharsFieldInfo = FCT.CSize
    type AttrGetType SvgLocationLineCharsFieldInfo = FCT.CSize
    type AttrLabel SvgLocationLineCharsFieldInfo = "line_chars"
    type AttrOrigin SvgLocationLineCharsFieldInfo = SvgLocation
    attrGet = getSvgLocationLineChars
    attrSet = setSvgLocationLineChars
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gtk.Structs.SvgLocation.lineChars"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gtk-4.0.11/docs/GI-Gtk-Structs-SvgLocation.html#g:attr:lineChars"
        })

svgLocation_lineChars :: AttrLabelProxy "lineChars"
svgLocation_lineChars = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList SvgLocation
type instance O.AttributeList SvgLocation = SvgLocationAttributeList
type SvgLocationAttributeList = ('[ '("bytes", SvgLocationBytesFieldInfo), '("lines", SvgLocationLinesFieldInfo), '("lineChars", SvgLocationLineCharsFieldInfo)] :: [(Symbol, DK.Type)])
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveSvgLocationMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveSvgLocationMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveSvgLocationMethod t SvgLocation, O.OverloadedMethod info SvgLocation p) => OL.IsLabel t (SvgLocation -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveSvgLocationMethod t SvgLocation, O.OverloadedMethod info SvgLocation p, R.HasField t SvgLocation p) => R.HasField t SvgLocation p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveSvgLocationMethod t SvgLocation, O.OverloadedMethodInfo info SvgLocation) => OL.IsLabel t (O.MethodProxy info SvgLocation) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif


