gi-glib-0.2.46.13: GI/GLib/Structs/Node.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
The #GNode struct represents one node in a [n-ary tree][glib-N-ary-Trees].
-}
module GI.GLib.Structs.Node
(
-- * Exported types
Node(..) ,
newZeroNode ,
noNode ,
-- * Methods
-- ** nodeChildIndex
NodeChildIndexMethodInfo ,
nodeChildIndex ,
-- ** nodeChildPosition
NodeChildPositionMethodInfo ,
nodeChildPosition ,
-- ** nodeDepth
NodeDepthMethodInfo ,
nodeDepth ,
-- ** nodeDestroy
NodeDestroyMethodInfo ,
nodeDestroy ,
-- ** nodeIsAncestor
NodeIsAncestorMethodInfo ,
nodeIsAncestor ,
-- ** nodeMaxHeight
NodeMaxHeightMethodInfo ,
nodeMaxHeight ,
-- ** nodeNChildren
NodeNChildrenMethodInfo ,
nodeNChildren ,
-- ** nodeNNodes
NodeNNodesMethodInfo ,
nodeNNodes ,
-- ** nodeReverseChildren
NodeReverseChildrenMethodInfo ,
nodeReverseChildren ,
-- ** nodeUnlink
NodeUnlinkMethodInfo ,
nodeUnlink ,
-- * Properties
-- ** Children
nodeReadChildren ,
-- ** Data
nodeReadData ,
-- ** Next
nodeReadNext ,
-- ** Parent
nodeReadParent ,
-- ** Prev
nodeReadPrev ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.GLib.Types
import GI.GLib.Callbacks
newtype Node = Node (ForeignPtr Node)
-- | Construct a `Node` struct initialized to zero.
newZeroNode :: MonadIO m => m Node
newZeroNode = liftIO $ callocBytes 40 >>= wrapPtr Node
noNode :: Maybe Node
noNode = Nothing
nodeReadData :: Node -> IO (Ptr ())
nodeReadData s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO (Ptr ())
return val
nodeReadNext :: Node -> IO Node
nodeReadNext s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO (Ptr Node)
val' <- (newPtr 40 Node) val
return val'
nodeReadPrev :: Node -> IO Node
nodeReadPrev s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 16) :: IO (Ptr Node)
val' <- (newPtr 40 Node) val
return val'
nodeReadParent :: Node -> IO Node
nodeReadParent s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 24) :: IO (Ptr Node)
val' <- (newPtr 40 Node) val
return val'
nodeReadChildren :: Node -> IO Node
nodeReadChildren s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 32) :: IO (Ptr Node)
val' <- (newPtr 40 Node) val
return val'
-- method Node::child_index
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Node", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False
foreign import ccall "g_node_child_index" g_node_child_index ::
Ptr Node -> -- _obj : TInterface "GLib" "Node"
Ptr () -> -- data : TBasicType TVoid
IO Int32
nodeChildIndex ::
(MonadIO m) =>
Node -- _obj
-> Ptr () -- data_
-> m Int32 -- result
nodeChildIndex _obj data_ = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- g_node_child_index _obj' data_
touchManagedPtr _obj
return result
data NodeChildIndexMethodInfo
instance (signature ~ (Ptr () -> m Int32), MonadIO m) => MethodInfo NodeChildIndexMethodInfo Node signature where
overloadedMethod _ = nodeChildIndex
-- method Node::child_position
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Node", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "child", argType = TInterface "GLib" "Node", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False
foreign import ccall "g_node_child_position" g_node_child_position ::
Ptr Node -> -- _obj : TInterface "GLib" "Node"
Ptr Node -> -- child : TInterface "GLib" "Node"
IO Int32
nodeChildPosition ::
(MonadIO m) =>
Node -- _obj
-> Node -- child
-> m Int32 -- result
nodeChildPosition _obj child = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
let child' = unsafeManagedPtrGetPtr child
result <- g_node_child_position _obj' child'
touchManagedPtr _obj
touchManagedPtr child
return result
data NodeChildPositionMethodInfo
instance (signature ~ (Node -> m Int32), MonadIO m) => MethodInfo NodeChildPositionMethodInfo Node signature where
overloadedMethod _ = nodeChildPosition
-- method Node::depth
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Node", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False
foreign import ccall "g_node_depth" g_node_depth ::
Ptr Node -> -- _obj : TInterface "GLib" "Node"
IO Word32
nodeDepth ::
(MonadIO m) =>
Node -- _obj
-> m Word32 -- result
nodeDepth _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- g_node_depth _obj'
touchManagedPtr _obj
return result
data NodeDepthMethodInfo
instance (signature ~ (m Word32), MonadIO m) => MethodInfo NodeDepthMethodInfo Node signature where
overloadedMethod _ = nodeDepth
-- method Node::destroy
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Node", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_node_destroy" g_node_destroy ::
Ptr Node -> -- _obj : TInterface "GLib" "Node"
IO ()
nodeDestroy ::
(MonadIO m) =>
Node -- _obj
-> m () -- result
nodeDestroy _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_node_destroy _obj'
touchManagedPtr _obj
return ()
data NodeDestroyMethodInfo
instance (signature ~ (m ()), MonadIO m) => MethodInfo NodeDestroyMethodInfo Node signature where
overloadedMethod _ = nodeDestroy
-- method Node::is_ancestor
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Node", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "descendant", argType = TInterface "GLib" "Node", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False
foreign import ccall "g_node_is_ancestor" g_node_is_ancestor ::
Ptr Node -> -- _obj : TInterface "GLib" "Node"
Ptr Node -> -- descendant : TInterface "GLib" "Node"
IO CInt
nodeIsAncestor ::
(MonadIO m) =>
Node -- _obj
-> Node -- descendant
-> m Bool -- result
nodeIsAncestor _obj descendant = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
let descendant' = unsafeManagedPtrGetPtr descendant
result <- g_node_is_ancestor _obj' descendant'
let result' = (/= 0) result
touchManagedPtr _obj
touchManagedPtr descendant
return result'
data NodeIsAncestorMethodInfo
instance (signature ~ (Node -> m Bool), MonadIO m) => MethodInfo NodeIsAncestorMethodInfo Node signature where
overloadedMethod _ = nodeIsAncestor
-- method Node::max_height
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Node", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False
foreign import ccall "g_node_max_height" g_node_max_height ::
Ptr Node -> -- _obj : TInterface "GLib" "Node"
IO Word32
nodeMaxHeight ::
(MonadIO m) =>
Node -- _obj
-> m Word32 -- result
nodeMaxHeight _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- g_node_max_height _obj'
touchManagedPtr _obj
return result
data NodeMaxHeightMethodInfo
instance (signature ~ (m Word32), MonadIO m) => MethodInfo NodeMaxHeightMethodInfo Node signature where
overloadedMethod _ = nodeMaxHeight
-- method Node::n_children
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Node", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False
foreign import ccall "g_node_n_children" g_node_n_children ::
Ptr Node -> -- _obj : TInterface "GLib" "Node"
IO Word32
nodeNChildren ::
(MonadIO m) =>
Node -- _obj
-> m Word32 -- result
nodeNChildren _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- g_node_n_children _obj'
touchManagedPtr _obj
return result
data NodeNChildrenMethodInfo
instance (signature ~ (m Word32), MonadIO m) => MethodInfo NodeNChildrenMethodInfo Node signature where
overloadedMethod _ = nodeNChildren
-- method Node::n_nodes
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Node", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface "GLib" "TraverseFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False
foreign import ccall "g_node_n_nodes" g_node_n_nodes ::
Ptr Node -> -- _obj : TInterface "GLib" "Node"
CUInt -> -- flags : TInterface "GLib" "TraverseFlags"
IO Word32
nodeNNodes ::
(MonadIO m) =>
Node -- _obj
-> [TraverseFlags] -- flags
-> m Word32 -- result
nodeNNodes _obj flags = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
let flags' = gflagsToWord flags
result <- g_node_n_nodes _obj' flags'
touchManagedPtr _obj
return result
data NodeNNodesMethodInfo
instance (signature ~ ([TraverseFlags] -> m Word32), MonadIO m) => MethodInfo NodeNNodesMethodInfo Node signature where
overloadedMethod _ = nodeNNodes
-- method Node::reverse_children
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Node", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_node_reverse_children" g_node_reverse_children ::
Ptr Node -> -- _obj : TInterface "GLib" "Node"
IO ()
nodeReverseChildren ::
(MonadIO m) =>
Node -- _obj
-> m () -- result
nodeReverseChildren _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_node_reverse_children _obj'
touchManagedPtr _obj
return ()
data NodeReverseChildrenMethodInfo
instance (signature ~ (m ()), MonadIO m) => MethodInfo NodeReverseChildrenMethodInfo Node signature where
overloadedMethod _ = nodeReverseChildren
-- method Node::unlink
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Node", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_node_unlink" g_node_unlink ::
Ptr Node -> -- _obj : TInterface "GLib" "Node"
IO ()
nodeUnlink ::
(MonadIO m) =>
Node -- _obj
-> m () -- result
nodeUnlink _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_node_unlink _obj'
touchManagedPtr _obj
return ()
data NodeUnlinkMethodInfo
instance (signature ~ (m ()), MonadIO m) => MethodInfo NodeUnlinkMethodInfo Node signature where
overloadedMethod _ = nodeUnlink
type family ResolveNodeMethod (t :: Symbol) (o :: *) :: * where
ResolveNodeMethod "childIndex" o = NodeChildIndexMethodInfo
ResolveNodeMethod "childPosition" o = NodeChildPositionMethodInfo
ResolveNodeMethod "depth" o = NodeDepthMethodInfo
ResolveNodeMethod "destroy" o = NodeDestroyMethodInfo
ResolveNodeMethod "isAncestor" o = NodeIsAncestorMethodInfo
ResolveNodeMethod "maxHeight" o = NodeMaxHeightMethodInfo
ResolveNodeMethod "nChildren" o = NodeNChildrenMethodInfo
ResolveNodeMethod "nNodes" o = NodeNNodesMethodInfo
ResolveNodeMethod "reverseChildren" o = NodeReverseChildrenMethodInfo
ResolveNodeMethod "unlink" o = NodeUnlinkMethodInfo
ResolveNodeMethod l o = MethodResolutionFailed l o
instance (info ~ ResolveNodeMethod t Node, MethodInfo info Node p) => IsLabelProxy t (Node -> p) where
fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveNodeMethod t Node, MethodInfo info Node p) => IsLabel t (Node -> p) where
fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif