File: Function.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 (33 lines) | stat: -rw-r--r-- 900 bytes parent folder | download | duplicates (3)
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
31
32
33
module Data.GI.GIR.Function
    ( Function(..)
    , parseFunction
    ) where

import Data.Text (Text)

import Data.GI.GIR.Callable (Callable(..), parseCallable)
import Data.GI.GIR.Parser

data Function = Function {
  -- | The symbol in the dynlib that this function refers to.
      fnSymbol   :: Text
    , fnMovedTo  :: Maybe Text
    , fnCallable :: Callable
    } deriving Show

parseFunction :: Parser (Name, Function)
parseFunction = do
  name <- parseName
  shadows <- queryAttr "shadows"
  let exposedName = case shadows of
                      Just n -> name {name = n}
                      Nothing -> name
  callable <- parseCallable
  symbol <- getAttrWithNamespace CGIRNS "identifier"
  movedTo <- queryAttr "moved-to"
  return $ (exposedName,
            Function {
              fnSymbol = symbol
            , fnCallable = callable
            , fnMovedTo = movedTo
            })