File: Allocation.hs

package info (click to toggle)
haskell-haskell-gi 0.26.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 800 kB
  • sloc: haskell: 8,617; ansic: 74; makefile: 4
file content (30 lines) | stat: -rw-r--r-- 1,115 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- | Information on explicit allocation/deallocation for foreign pointers.
module Data.GI.GIR.Allocation
    ( AllocationInfo(..)
    , AllocationOp(..)
    , unknownAllocationInfo
    ) where

import Data.Text (Text)

-- | Allocation/deallocation information for a given foreign pointer.
data AllocationInfo = AllocationInfo {
      allocCalloc :: AllocationOp
    , allocCopy   :: AllocationOp
    , allocFree   :: AllocationOp
    } deriving (Show)

-- | Information about a given allocation operation. It is either disallowed,
-- allowed via the given function, or it is unknown at the current
-- stage how to perform the operation.
data AllocationOp = AllocationOpUnknown
                  | AllocationOp Text
                    deriving (Show, Eq)

-- | A convenience function, filling in all the allocation info to unknown.
unknownAllocationInfo :: AllocationInfo
unknownAllocationInfo = AllocationInfo {
                          allocCalloc = AllocationOpUnknown
                        , allocCopy = AllocationOpUnknown
                        , allocFree = AllocationOpUnknown
                        }