module GI.GIR.Function ( Function(..) , parseFunction ) where import Data.Text (Text) import qualified Data.Text as T import GI.GIR.Callable (Callable(..), parseCallable) import GI.GIR.Parser data Function = Function { fnSymbol :: Text, fnThrows :: Bool, fnCallable :: Callable } deriving Show parseFunction :: Parser (Name, Function) parseFunction = do name <- parseName shadows <- queryAttr "shadows" let exposedName = case shadows of Just n -> name {name = T.unpack n} Nothing -> name callable <- parseCallable symbol <- getAttrWithNamespace CGIRNS "identifier" throws <- optionalAttr "throws" False parseBool return $ (exposedName, Function { fnSymbol = symbol , fnCallable = callable , fnThrows = throws })