-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Generate Haskell bindings for GObject Introspection capable libraries -- -- Generate Haskell bindings for GObject Introspection capable libraries. -- This includes most notably Gtk+, but many other libraries in the -- GObject ecosystem provide introspection data too. @package haskell-gi @version 0.26.4 module Data.GI.CodeGen.GType data () => GType gtypeIsA :: GType -> GType -> Bool gtypeIsBoxed :: GType -> Bool module Data.GI.CodeGen.PkgConfig -- | Get the pkg-config name and associated installed version of a given -- gobject-introspection namespace. Since the mapping is not one-to-one -- some guessing is involved, although in most cases the required -- information is listed in the GIR file. pkgConfigGetVersion :: Text -> Text -> [Text] -> Bool -> Map Text Text -> IO (Maybe (Text, Text)) -- | Try asking pkg-config for the version of a given module, and return -- the package name together with its version. tryPkgConfig :: Text -> IO (Maybe (Text, Text)) -- | Project information to include in generated bindings, should be kept -- in sync with haskell-gi.cabal module Data.GI.CodeGen.ProjectInfo homepage :: Text authors :: Text license :: Text licenseText :: Text -> Text -- | Under which category in hackage should the generated bindings be -- listed. category :: Text maintainers :: Text -- | Default list of extensions to turn on when compiling the generated -- code. defaultExtensions :: [Text] -- | Extensions that will be used in some modules, but we do not wish to -- turn on by default. otherExtensions :: [Text] -- | Default options for GHC when compiling generated code. ghcOptions :: [Text] -- | Default version of the report to use. defaultLanguage :: Text -- | List of dependencies for all bindings. Notice that base is not -- included here, since not all bindings use the same base version. -- haskell-gi and haskell-gi-base are not included either, since the -- versions to use may change depending on whether we are using old style -- or new style bindings. standardDeps :: [Text] module Data.GI.CodeGen.Util prime :: Text -> Text parenthesize :: Text -> Text padTo :: Int -> Text -> Text withComment :: Text -> Text -> Text -- | Capitalize the first character of the given string. ucFirst :: Text -> Text -- | Make the first character of the given string lowercase. lcFirst :: Text -> Text -- | Apply the given modification function to the given symbol. If the -- symbol is qualified the modification will only apply to the last -- component. modifyQualified :: (Text -> Text) -> Text -> Text -- | Construct the Text representation of a showable. tshow :: Show a => a -> Text -- | Throw an error with the given Text. terror :: HasCallStack => Text -> a -- | Read a file assuming it is UTF-8 encoded. If decoding fails this calls -- error. utf8ReadFile :: FilePath -> IO Text -- | Write the given Text into an UTF-8 encoded file. utf8WriteFile :: FilePath -> Text -> IO () -- | Split a list into sublists delimited by the given element. splitOn :: Eq a => a -> [a] -> [[a]] -- | Print a (colored) warning message to stderr printWarning :: Text -> IO () -- | Abstract representation for paths into modules. module Data.GI.CodeGen.ModulePath -- | A path to a module. newtype ModulePath ModulePath :: [Text] -> ModulePath [modulePathToList] :: ModulePath -> [Text] -- | Construct a path into the given GIR namespace. The given Text -- will be split along ".". -- --

Examples

-- --
--   >>> dotModulePath (toModulePath "Foo")
--   "Foo"
--   
-- --
--   >>> dotModulePath ("Foo" <> toModulePath "Bar.Baz")
--   "Foo.Bar.Baz"
--   
-- --
--   >>> dotModulePath ("Foo" <> toModulePath "bar.baz")
--   "Foo.Bar.Baz"
--   
toModulePath :: Text -> ModulePath -- | Append the given component to the given module path. -- --

Examples

-- --
--   >>> dotModulePath ("Foo" /. "Bar")
--   "Foo.Bar"
--   
(/.) :: ModulePath -> Text -> ModulePath -- | Turn a module path into the corresponding dotted string. Note that the -- implementation ensures that the module names start with a capital -- letter. -- --

Examples

-- --
--   >>> dotModulePath ("Foo" /. "Bar" /. "Baz")
--   "Foo.Bar.Baz"
--   
-- --
--   >>> dotModulePath ("foo" /. "bar" /. "baz")
--   "Foo.Bar.Baz"
--   
dotModulePath :: ModulePath -> Text instance GHC.Classes.Ord Data.GI.CodeGen.ModulePath.ModulePath instance GHC.Show.Show Data.GI.CodeGen.ModulePath.ModulePath instance GHC.Classes.Eq Data.GI.CodeGen.ModulePath.ModulePath instance GHC.Base.Monoid Data.GI.CodeGen.ModulePath.ModulePath instance GHC.Base.Semigroup Data.GI.CodeGen.ModulePath.ModulePath instance Data.String.IsString Data.GI.CodeGen.ModulePath.ModulePath -- | A minimal wrapper for libgirepository. module Data.GI.CodeGen.LibGIRepository -- | Ensure that the given version of the namespace is loaded. If that is -- not possible we error out. girRequire :: Text -> Text -> IO Typelib -- | Wrapper for GITypelib, remembering the originating namespace -- and version. data Typelib -- | A convenience function for setting up the typelib search path from the -- environment. Note that for efficiency reasons this should only be -- called once per program run. If the list of paths passed in is empty, -- the environment variable HASKELL_GI_TYPELIB_SEARCH_PATH will -- be checked. In either case the system directories will be searched -- after the passed in directories. setupTypelibSearchPath :: [FilePath] -> IO () -- | Extra info about a field in a struct or union which is not easily -- determined from the GIR file. (And which we determine by using -- libgirepository.) data FieldInfo FieldInfo :: Int -> FieldInfo [fieldInfoOffset] :: FieldInfo -> Int -- | Find out the size of a struct, and the map from field names to offsets -- inside the struct. girStructFieldInfo :: Text -> Text -> IO (Int, Map Text FieldInfo) -- | Find out the size of a union, and the map from field names to offsets -- inside the union. girUnionFieldInfo :: Text -> Text -> IO (Int, Map Text FieldInfo) -- | Load a GType given the Typelib where it lives and the type init -- function. girLoadGType :: Typelib -> Text -> IO GType -- | Check whether a symbol is present in the dynamical liberary. girIsSymbolResolvable :: Typelib -> Text -> IO Bool instance GHC.Show.Show Data.GI.CodeGen.LibGIRepository.Typelib instance Data.GI.Base.Overloading.HasParentTypes Data.GI.CodeGen.LibGIRepository.BaseInfo instance Data.GI.Base.BasicTypes.TypedObject Data.GI.CodeGen.LibGIRepository.BaseInfo instance Data.GI.Base.BasicTypes.GBoxed Data.GI.CodeGen.LibGIRepository.BaseInfo -- | Information on explicit allocation/deallocation for foreign pointers. module Data.GI.GIR.Allocation -- | Allocation/deallocation information for a given foreign pointer. data AllocationInfo AllocationInfo :: AllocationOp -> AllocationOp -> AllocationOp -> AllocationInfo [allocCalloc] :: AllocationInfo -> AllocationOp [allocCopy] :: AllocationInfo -> AllocationOp [allocFree] :: AllocationInfo -> AllocationOp -- | 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 AllocationOp :: Text -> AllocationOp -- | A convenience function, filling in all the allocation info to unknown. unknownAllocationInfo :: AllocationInfo instance GHC.Classes.Eq Data.GI.GIR.Allocation.AllocationOp instance GHC.Show.Show Data.GI.GIR.Allocation.AllocationOp instance GHC.Show.Show Data.GI.GIR.Allocation.AllocationInfo -- | Basic types used in GIR parsing. module Data.GI.GIR.BasicTypes -- | Name for a symbol in the GIR file. data Name Name :: Text -> Text -> Name [namespace] :: Name -> Text [name] :: Name -> Text -- | Transfer mode for an argument or property. data Transfer TransferNothing :: Transfer TransferContainer :: Transfer TransferEverything :: Transfer -- | An alias, which is simply (Namespace, name). newtype Alias Alias :: Name -> Alias -- | This type represents the types found in GObject Introspection -- interfaces: the types of constants, arguments, etc. data Type TBasicType :: BasicType -> Type -- | GError TError :: Type -- | GVariant TVariant :: Type -- | GValue TGValue :: Type -- | GParamSpec TParamSpec :: Type -- | Zero terminated, Array Fixed Size, Array Length, Element Type TCArray :: Bool -> Int -> Int -> Type -> Type -- | GArray TGArray :: Type -> Type -- | GPtrArray TPtrArray :: Type -> Type -- | GByteArray TByteArray :: Type -- | GList TGList :: Type -> Type -- | GSList TGSList :: Type -> Type -- | GHashTable TGHash :: Type -> Type -> Type -- | GClosure containing the given API (if known) TGClosure :: Maybe Type -> Type -- | A reference to some API in the GIR TInterface :: Name -> Type -- | Basic types. These are generally trivial to marshal, and the GIR -- assumes that they are defined. data BasicType -- | gboolean TBoolean :: BasicType -- | gint TInt :: BasicType -- | guint TUInt :: BasicType -- | glong TLong :: BasicType -- | gulong TULong :: BasicType -- | gint8 TInt8 :: BasicType -- | guint8 TUInt8 :: BasicType -- | gint16 TInt16 :: BasicType -- | guint16 TUInt16 :: BasicType -- | gint32 TInt32 :: BasicType -- | guint32 TUInt32 :: BasicType -- | gint64 TInt64 :: BasicType -- | guint64 TUInt64 :: BasicType -- | gfloat TFloat :: BasicType -- | gdouble TDouble :: BasicType -- | gunichar TUniChar :: BasicType -- | GType TGType :: BasicType -- | gchar*, encoded as UTF-8 TUTF8 :: BasicType -- | gchar*, encoding a filename TFileName :: BasicType -- | gpointer TPtr :: BasicType -- | gintptr TIntPtr :: BasicType -- | guintptr TUIntPtr :: BasicType instance GHC.Show.Show Data.GI.GIR.BasicTypes.Name instance GHC.Classes.Ord Data.GI.GIR.BasicTypes.Name instance GHC.Classes.Eq Data.GI.GIR.BasicTypes.Name instance GHC.Classes.Ord Data.GI.GIR.BasicTypes.Transfer instance GHC.Classes.Eq Data.GI.GIR.BasicTypes.Transfer instance GHC.Show.Show Data.GI.GIR.BasicTypes.Transfer instance GHC.Show.Show Data.GI.GIR.BasicTypes.Alias instance GHC.Classes.Eq Data.GI.GIR.BasicTypes.Alias instance GHC.Classes.Ord Data.GI.GIR.BasicTypes.Alias instance GHC.Classes.Ord Data.GI.GIR.BasicTypes.BasicType instance GHC.Show.Show Data.GI.GIR.BasicTypes.BasicType instance GHC.Classes.Eq Data.GI.GIR.BasicTypes.BasicType instance GHC.Classes.Ord Data.GI.GIR.BasicTypes.Type instance GHC.Show.Show Data.GI.GIR.BasicTypes.Type instance GHC.Classes.Eq Data.GI.GIR.BasicTypes.Type -- | An abstraction for representing type constructors. This is a very -- simplified version of Typeable, which we don't use directly to -- avoid compatibility headaches. module Data.GI.CodeGen.Type -- | This type represents the types found in GObject Introspection -- interfaces: the types of constants, arguments, etc. data Type TBasicType :: BasicType -> Type -- | GError TError :: Type -- | GVariant TVariant :: Type -- | GValue TGValue :: Type -- | GParamSpec TParamSpec :: Type -- | Zero terminated, Array Fixed Size, Array Length, Element Type TCArray :: Bool -> Int -> Int -> Type -> Type -- | GArray TGArray :: Type -> Type -- | GPtrArray TPtrArray :: Type -> Type -- | GByteArray TByteArray :: Type -- | GList TGList :: Type -> Type -- | GSList TGSList :: Type -> Type -- | GHashTable TGHash :: Type -> Type -> Type -- | GClosure containing the given API (if known) TGClosure :: Maybe Type -> Type -- | A reference to some API in the GIR TInterface :: Name -> Type -- | Basic types. These are generally trivial to marshal, and the GIR -- assumes that they are defined. data BasicType -- | gboolean TBoolean :: BasicType -- | gint TInt :: BasicType -- | guint TUInt :: BasicType -- | glong TLong :: BasicType -- | gulong TULong :: BasicType -- | gint8 TInt8 :: BasicType -- | guint8 TUInt8 :: BasicType -- | gint16 TInt16 :: BasicType -- | guint16 TUInt16 :: BasicType -- | gint32 TInt32 :: BasicType -- | guint32 TUInt32 :: BasicType -- | gint64 TInt64 :: BasicType -- | guint64 TUInt64 :: BasicType -- | gfloat TFloat :: BasicType -- | gdouble TDouble :: BasicType -- | gunichar TUniChar :: BasicType -- | GType TGType :: BasicType -- | gchar*, encoded as UTF-8 TUTF8 :: BasicType -- | gchar*, encoding a filename TFileName :: BasicType -- | gpointer TPtr :: BasicType -- | gintptr TIntPtr :: BasicType -- | guintptr TUIntPtr :: BasicType -- | A fully applied type. data TypeRep -- | Type constructor applied to the given types. con :: Text -> [TypeRep] -> TypeRep -- | A shorthand for a type constructor taking no arguments. con0 :: Text -> TypeRep -- | Give a valid Haskell source representation of the given -- TypeRep. typeShow :: TypeRep -> Text -- | Return a textual representation of the type constructor for the given -- TypeRep. typeConName :: TypeRep -> Text -- | Embed in the IO monad. io :: TypeRep -> TypeRep -- | A Ptr to the type. ptr :: TypeRep -> TypeRep -- | A FunPtr to the type. funptr :: TypeRep -> TypeRep -- | Embed in the Maybe monad. maybeT :: TypeRep -> TypeRep instance GHC.Classes.Eq Data.GI.CodeGen.Type.TypeCon instance GHC.Classes.Eq Data.GI.CodeGen.Type.TypeRep -- | A parser for gtk-doc formatted documentation, see -- https://developer.gnome.org/gtk-doc-manual/ for the spec. module Data.GI.CodeGen.GtkDoc -- | Parse the given gtk-doc formatted documentation. -- --

Examples

-- --
--   >>> parseGtkDoc ""
--   GtkDoc []
--   
-- --
--   >>> parseGtkDoc "func()"
--   GtkDoc [SymbolRef (OldFunctionRef "func")]
--   
-- --
--   >>> parseGtkDoc "literal"
--   GtkDoc [Literal "literal"]
--   
-- --
--   >>> parseGtkDoc "This is a long literal"
--   GtkDoc [Literal "This is a long literal"]
--   
-- --
--   >>> parseGtkDoc "Call foo() for free cookies"
--   GtkDoc [Literal "Call ",SymbolRef (OldFunctionRef "foo"),Literal " for free cookies"]
--   
-- --
--   >>> parseGtkDoc "The signal ::activate is related to gtk_button_activate()."
--   GtkDoc [Literal "The signal ",SymbolRef (LocalSignalRef "activate"),Literal " is related to ",SymbolRef (OldFunctionRef "gtk_button_activate"),Literal "."]
--   
-- --
--   >>> parseGtkDoc "The signal ##%#GtkButton::activate is related to gtk_button_activate()."
--   GtkDoc [Literal "The signal ##%",SymbolRef (OldSignalRef "GtkButton" "activate"),Literal " is related to ",SymbolRef (OldFunctionRef "gtk_button_activate"),Literal "."]
--   
-- --
--   >>> parseGtkDoc "# A section\n\n## and a subsection ##\n"
--   GtkDoc [SectionHeader 1 (GtkDoc [Literal "A section"]),Literal "\n",SectionHeader 2 (GtkDoc [Literal "and a subsection "])]
--   
-- --
--   >>> parseGtkDoc "Compact list:\n- First item\n- Second item"
--   GtkDoc [Literal "Compact list:\n",List [ListItem (GtkDoc [Literal "First item"]) [],ListItem (GtkDoc [Literal "Second item"]) []]]
--   
-- --
--   >>> parseGtkDoc "Spaced list:\n\n- First item\n\n- Second item"
--   GtkDoc [Literal "Spaced list:\n",List [ListItem (GtkDoc [Literal "First item"]) [],ListItem (GtkDoc [Literal "Second item"]) []]]
--   
-- --
--   >>> parseGtkDoc "List with urls:\n- [test](http://test)\n- ![](image.png)"
--   GtkDoc [Literal "List with urls:\n",List [ListItem (GtkDoc [ExternalLink (Link {linkName = "test", linkAddress = "http://test"})]) [],ListItem (GtkDoc [Image (Link {linkName = "", linkAddress = "image.png"})]) []]]
--   
parseGtkDoc :: Text -> GtkDoc -- | A parsed representation of gtk-doc formatted documentation. newtype GtkDoc GtkDoc :: [Token] -> GtkDoc -- | A parsed gtk-doc token. data Token Literal :: Text -> Token Comment :: Text -> Token Verbatim :: Text -> Token CodeBlock :: Maybe Language -> Text -> Token ExternalLink :: Link -> Token Image :: Link -> Token List :: [ListItem] -> Token -- | A section header of the given depth. SectionHeader :: Int -> GtkDoc -> Token SymbolRef :: CRef -> Token -- | The language for an embedded code block. newtype Language Language :: Text -> Language -- | A link to a resource, either offline or a section of the -- documentation. data Link Link :: Text -> Text -> Link [linkName] :: Link -> Text [linkAddress] :: Link -> Text -- | An item in a list, given by a list of lines (not including ending -- newlines). The list is always non-empty, so we represent it by the -- first line and then a possibly empty list with the rest of the lines. data ListItem ListItem :: GtkDoc -> [GtkDoc] -> ListItem -- | A reference to some symbol in the API. data CRef FunctionRef :: Name -> CRef OldFunctionRef :: Text -> CRef MethodRef :: Name -> Text -> CRef ParamRef :: Text -> CRef ConstantRef :: Text -> CRef SignalRef :: Name -> Text -> CRef OldSignalRef :: Text -> Text -> CRef LocalSignalRef :: Text -> CRef PropertyRef :: Name -> Text -> CRef OldPropertyRef :: Text -> Text -> CRef VMethodRef :: Text -> Text -> CRef VFuncRef :: Name -> Text -> CRef StructFieldRef :: Text -> Text -> CRef CTypeRef :: Text -> CRef TypeRef :: Name -> CRef instance GHC.Classes.Eq Data.GI.CodeGen.GtkDoc.Link instance GHC.Show.Show Data.GI.CodeGen.GtkDoc.Link instance GHC.Classes.Eq Data.GI.CodeGen.GtkDoc.Language instance GHC.Show.Show Data.GI.CodeGen.GtkDoc.Language instance GHC.Classes.Ord Data.GI.CodeGen.GtkDoc.CRef instance GHC.Classes.Eq Data.GI.CodeGen.GtkDoc.CRef instance GHC.Show.Show Data.GI.CodeGen.GtkDoc.CRef instance GHC.Classes.Eq Data.GI.CodeGen.GtkDoc.ListItem instance GHC.Show.Show Data.GI.CodeGen.GtkDoc.ListItem instance GHC.Classes.Eq Data.GI.CodeGen.GtkDoc.Token instance GHC.Show.Show Data.GI.CodeGen.GtkDoc.Token instance GHC.Classes.Eq Data.GI.CodeGen.GtkDoc.GtkDoc instance GHC.Show.Show Data.GI.CodeGen.GtkDoc.GtkDoc module Data.GI.GIR.Repository -- | Try to load the `.gir` file corresponding to the given repository readGiRepository :: Bool -> Text -> Maybe Text -> [FilePath] -> IO Document -- | Some helpers for making traversals of GIR documents easier. module Data.GI.GIR.XMLUtils -- | Turn a node into an element (if it is indeed an element node). nodeToElement :: Node -> Maybe Element -- | Find all children of the given element which are XML Elements -- themselves. subelements :: Element -> [Element] -- | The local name of an element. localName :: Element -> Text -- | Lookup an attribute for an element (with no prefix). lookupAttr :: Name -> Element -> Maybe Text -- | GIR namespaces we know about. data GIRXMLNamespace GLibGIRNS :: GIRXMLNamespace CGIRNS :: GIRXMLNamespace CoreGIRNS :: GIRXMLNamespace -- | Lookup an attribute for an element, given the namespace where it -- lives. lookupAttrWithNamespace :: GIRXMLNamespace -> Name -> Element -> Maybe Text -- | Restrict to those with the given local name. childElemsWithLocalName :: Text -> Element -> [Element] -- | Restrict to those with given name. childElemsWithNSName :: GIRXMLNamespace -> Text -> Element -> [Element] -- | Find the first child element with the given name. firstChildWithLocalName :: Text -> Element -> Maybe Element -- | Get the content of a given element, if it exists. getElementContent :: Element -> Maybe Text -- | Construct a Name by only giving the local name. xmlLocalName :: Text -> Name -- | Construct a Name specifying a namespace too. xmlNSName :: GIRXMLNamespace -> Text -> Name instance GHC.Show.Show Data.GI.GIR.XMLUtils.GIRXMLNamespace -- | Parsing of documentation nodes. module Data.GI.GIR.Documentation -- | Documentation for a given element. The documentation text is typically -- encoded in the gtk-doc format, see -- https://developer.gnome.org/gtk-doc-manual/ . This can be -- parsed with parseGtkDoc. data Documentation Documentation :: Maybe Text -> Maybe Text -> Documentation [rawDocText] :: Documentation -> Maybe Text [sinceVersion] :: Documentation -> Maybe Text -- | Parse the documentation node for the given element of the GIR file. queryDocumentation :: Element -> Documentation instance GHC.Classes.Ord Data.GI.GIR.Documentation.Documentation instance GHC.Classes.Eq Data.GI.GIR.Documentation.Documentation instance GHC.Show.Show Data.GI.GIR.Documentation.Documentation module Data.GI.GIR.Deprecation -- | Deprecation information on a symbol. data DeprecationInfo DeprecationInfo :: Maybe Text -> Maybe Text -> DeprecationInfo [deprecatedSinceVersion] :: DeprecationInfo -> Maybe Text [deprecationMessage] :: DeprecationInfo -> Maybe Text -- | Parse the deprecation information for the given element of the GIR -- file. queryDeprecated :: Element -> Maybe DeprecationInfo instance GHC.Classes.Eq Data.GI.GIR.Deprecation.DeprecationInfo instance GHC.Show.Show Data.GI.GIR.Deprecation.DeprecationInfo -- | The Parser monad. module Data.GI.GIR.Parser -- | Monad where parsers live: we carry a context around, and can throw -- errors that abort the parsing. type Parser a = ReaderT ParseContext (Except ParseError) a -- | Info to carry around when parsing. data ParseContext ParseContext :: Text -> [Text] -> Element -> Map Alias Type -> ParseContext [ctxNamespace] :: ParseContext -> Text [treePosition] :: ParseContext -> [Text] [currentElement] :: ParseContext -> Element [knownAliases] :: ParseContext -> Map Alias Type -- | A message describing a parsing error in human readable form. type ParseError = Text -- | Throw a parse error. parseError :: ParseError -> Parser a -- | Run the given parser, returning either success or an error. runParser :: Text -> Map Alias Type -> Element -> Parser a -> Either ParseError a -- | Get the qualified name for the current element. parseName :: Parser Name -- | Parse the deprecation text, if present. parseDeprecation :: Parser (Maybe DeprecationInfo) -- | Parse the documentation info for the current node. parseDocumentation :: Parser Documentation -- | Parse a signed integral number. parseIntegral :: Integral a => Text -> Parser a -- | A boolean value given by a numerical constant. parseBool :: Text -> Parser Bool -- | Parse all the introspectable subelements with the given local name. parseChildrenWithLocalName :: Text -> Parser a -> Parser [a] -- | Parse all subelements with the given local name. parseAllChildrenWithLocalName :: Text -> Parser a -> Parser [a] -- | Parse all introspectable children with the given namespace and local -- name. parseChildrenWithNSName :: GIRXMLNamespace -> Text -> Parser a -> Parser [a] -- | Return the value of an attribute for the given element. If the -- attribute is not present this throws an error. getAttr :: Name -> Parser Text -- | Like getAttr, but allow for specifying the namespace. getAttrWithNamespace :: GIRXMLNamespace -> Name -> Parser Text -- | Return the value of an attribute if it is present, and Nothing -- otherwise. queryAttr :: Name -> Parser (Maybe Text) -- | Like queryAttr, but allow for specifying the namespace. queryAttrWithNamespace :: GIRXMLNamespace -> Name -> Parser (Maybe Text) -- | Ask for an optional attribute, applying the given parser to it. If the -- argument does not exist return the default value provided. optionalAttr :: Name -> a -> (Text -> Parser a) -> Parser a -- | Return the current namespace. currentNamespace :: Parser Text -- | Build a Name out of the (possibly qualified) supplied name. If -- the supplied name is unqualified we qualify with the current -- namespace, and otherwise we simply parse it. qualifyName :: Text -> Parser Name -- | Check whether there is an alias for the given name, and return the -- corresponding type in case it exists, and otherwise a TInterface. resolveQualifiedTypeName :: Name -> Parser Type -- | Name for a symbol in the GIR file. data Name Name :: Text -> Text -> Name [namespace] :: Name -> Text [name] :: Name -> Text data () => Element -- | GIR namespaces we know about. data GIRXMLNamespace GLibGIRNS :: GIRXMLNamespace CGIRNS :: GIRXMLNamespace CoreGIRNS :: GIRXMLNamespace -- | Deprecation information on a symbol. data DeprecationInfo -- | Documentation for a given element. The documentation text is typically -- encoded in the gtk-doc format, see -- https://developer.gnome.org/gtk-doc-manual/ . This can be -- parsed with parseGtkDoc. data Documentation instance GHC.Show.Show Data.GI.GIR.Parser.ParseContext -- | Parsing type information from GIR files. module Data.GI.GIR.Type -- | Parse the type of a node (which will be described by a child node -- named "type" or "array"). parseType :: Parser Type -- | Find the C name for the current element. queryCType :: Parser (Maybe Text) -- | Parse the C type for the current node. parseCType :: Parser Text -- | Parse the C-type associated to the element, if found. queryElementCType :: Parser (Maybe Text) -- | Like parseType, but allow for none, returned as -- Nothing. parseOptionalType :: Parser (Maybe Type) -- | Parsing of Enums. module Data.GI.GIR.Enum data Enumeration Enumeration :: [EnumerationMember] -> Maybe Text -> Maybe Text -> Documentation -> Text -> Int -> Maybe DeprecationInfo -> Enumeration [enumMembers] :: Enumeration -> [EnumerationMember] [enumErrorDomain] :: Enumeration -> Maybe Text [enumTypeInit] :: Enumeration -> Maybe Text [enumDocumentation] :: Enumeration -> Documentation [enumCType] :: Enumeration -> Text -- | Bytes used for storage of this struct. [enumStorageBytes] :: Enumeration -> Int [enumDeprecated] :: Enumeration -> Maybe DeprecationInfo -- | Member of an enumeration. data EnumerationMember EnumerationMember :: Text -> Int64 -> Text -> Documentation -> EnumerationMember [enumMemberName] :: EnumerationMember -> Text [enumMemberValue] :: EnumerationMember -> Int64 [enumMemberCId] :: EnumerationMember -> Text [enumMemberDoc] :: EnumerationMember -> Documentation -- | Parse an "enumeration" element from the GIR file. parseEnum :: Parser (Name, Enumeration) instance GHC.Show.Show Data.GI.GIR.Enum.EnumerationMember instance GHC.Show.Show Data.GI.GIR.Enum.Enumeration -- | Parsing of bitfields, a.k.a. flags. They are represented in the same -- way as enums, so this is a thin wrapper over that code. module Data.GI.GIR.Flags data Flags Flags :: Enumeration -> Flags parseFlags :: Parser (Name, Flags) instance GHC.Show.Show Data.GI.GIR.Flags.Flags -- | Parsing of constants in GIR files. module Data.GI.GIR.Constant -- | Info about a constant. data Constant Constant :: Type -> Text -> Text -> Documentation -> Maybe DeprecationInfo -> Constant [constantType] :: Constant -> Type [constantValue] :: Constant -> Text [constantCType] :: Constant -> Text [constantDocumentation] :: Constant -> Documentation [constantDeprecated] :: Constant -> Maybe DeprecationInfo -- | Parse a "constant" element from the GIR file. parseConstant :: Parser (Name, Constant) instance GHC.Show.Show Data.GI.GIR.Constant.Constant module Data.GI.GIR.Arg data Arg Arg :: Text -> Type -> Direction -> Bool -> Documentation -> Scope -> Int -> Int -> Bool -> Transfer -> Arg -- | C name for the argument. For a escaped name valid in Haskell -- code, use escapedArgName. [argCName] :: Arg -> Text [argType] :: Arg -> Type [direction] :: Arg -> Direction [mayBeNull] :: Arg -> Bool [argDoc] :: Arg -> Documentation [argScope] :: Arg -> Scope [argClosure] :: Arg -> Int [argDestroy] :: Arg -> Int [argCallerAllocates] :: Arg -> Bool [transfer] :: Arg -> Transfer data Direction DirectionIn :: Direction DirectionOut :: Direction DirectionInout :: Direction data Scope ScopeTypeInvalid :: Scope ScopeTypeCall :: Scope ScopeTypeAsync :: Scope ScopeTypeNotified :: Scope parseArg :: Parser Arg parseTransfer :: Parser Transfer instance GHC.Classes.Ord Data.GI.GIR.Arg.Direction instance GHC.Classes.Eq Data.GI.GIR.Arg.Direction instance GHC.Show.Show Data.GI.GIR.Arg.Direction instance GHC.Classes.Ord Data.GI.GIR.Arg.Scope instance GHC.Classes.Eq Data.GI.GIR.Arg.Scope instance GHC.Show.Show Data.GI.GIR.Arg.Scope instance GHC.Classes.Ord Data.GI.GIR.Arg.Arg instance GHC.Classes.Eq Data.GI.GIR.Arg.Arg instance GHC.Show.Show Data.GI.GIR.Arg.Arg module Data.GI.GIR.Property data Property Property :: Text -> Type -> [PropertyFlag] -> Maybe Bool -> Maybe Bool -> Transfer -> Documentation -> Maybe DeprecationInfo -> Property [propName] :: Property -> Text [propType] :: Property -> Type [propFlags] :: Property -> [PropertyFlag] [propReadNullable] :: Property -> Maybe Bool [propWriteNullable] :: Property -> Maybe Bool [propTransfer] :: Property -> Transfer [propDoc] :: Property -> Documentation [propDeprecated] :: Property -> Maybe DeprecationInfo data PropertyFlag PropertyReadable :: PropertyFlag PropertyWritable :: PropertyFlag PropertyConstruct :: PropertyFlag PropertyConstructOnly :: PropertyFlag parseProperty :: Parser Property instance GHC.Classes.Eq Data.GI.GIR.Property.PropertyFlag instance GHC.Show.Show Data.GI.GIR.Property.PropertyFlag instance GHC.Classes.Eq Data.GI.GIR.Property.Property instance GHC.Show.Show Data.GI.GIR.Property.Property module Data.GI.GIR.Callable data Callable Callable :: Maybe Type -> Bool -> Transfer -> Documentation -> [Arg] -> Bool -> Bool -> Maybe DeprecationInfo -> Documentation -> Maybe Bool -> Callable [returnType] :: Callable -> Maybe Type [returnMayBeNull] :: Callable -> Bool [returnTransfer] :: Callable -> Transfer [returnDocumentation] :: Callable -> Documentation [args] :: Callable -> [Arg] [skipReturn] :: Callable -> Bool [callableThrows] :: Callable -> Bool [callableDeprecated] :: Callable -> Maybe DeprecationInfo [callableDocumentation] :: Callable -> Documentation -- | Whether the symbol for this callable can be resolved in the dynamical -- library associated with the current introspection data. Nothing -- means that we have not checked yet. [callableResolvable] :: Callable -> Maybe Bool parseCallable :: Parser Callable instance GHC.Classes.Eq Data.GI.GIR.Callable.Callable instance GHC.Show.Show Data.GI.GIR.Callable.Callable module Data.GI.GIR.Signal data Signal Signal :: Text -> Callable -> Maybe DeprecationInfo -> Bool -> Documentation -> Signal [sigName] :: Signal -> Text [sigCallable] :: Signal -> Callable [sigDeprecated] :: Signal -> Maybe DeprecationInfo [sigDetailed] :: Signal -> Bool [sigDoc] :: Signal -> Documentation parseSignal :: Parser Signal instance GHC.Classes.Eq Data.GI.GIR.Signal.Signal instance GHC.Show.Show Data.GI.GIR.Signal.Signal module Data.GI.GIR.Method data Method Method :: Name -> Text -> MethodType -> Maybe Text -> Callable -> Method [methodName] :: Method -> Name -- | The symbol in the dynlib that this method refers to. [methodSymbol] :: Method -> Text [methodType] :: Method -> MethodType [methodMovedTo] :: Method -> Maybe Text [methodCallable] :: Method -> Callable data MethodType -- | Constructs an instance of the parent type Constructor :: MethodType -- | A function in the namespace MemberFunction :: MethodType -- | A function taking the parent instance as first argument. OrdinaryMethod :: MethodType parseMethod :: MethodType -> Parser Method instance GHC.Show.Show Data.GI.GIR.Method.MethodType instance GHC.Classes.Eq Data.GI.GIR.Method.MethodType instance GHC.Show.Show Data.GI.GIR.Method.Method instance GHC.Classes.Eq Data.GI.GIR.Method.Method -- | Parsing of objects. module Data.GI.GIR.Object data Object Object :: Maybe Name -> Text -> Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> [Name] -> Maybe DeprecationInfo -> Documentation -> [Method] -> [Property] -> [Signal] -> Object [objParent] :: Object -> Maybe Name [objTypeInit] :: Object -> Text [objTypeName] :: Object -> Text [objCType] :: Object -> Maybe Text [objRefFunc] :: Object -> Maybe Text [objUnrefFunc] :: Object -> Maybe Text [objSetValueFunc] :: Object -> Maybe Text [objGetValueFunc] :: Object -> Maybe Text [objInterfaces] :: Object -> [Name] [objDeprecated] :: Object -> Maybe DeprecationInfo [objDocumentation] :: Object -> Documentation [objMethods] :: Object -> [Method] [objProperties] :: Object -> [Property] [objSignals] :: Object -> [Signal] parseObject :: Parser (Name, Object) instance GHC.Show.Show Data.GI.GIR.Object.Object module Data.GI.GIR.Interface data Interface Interface :: Maybe Text -> Maybe Text -> Documentation -> [Name] -> [Property] -> [Signal] -> [Method] -> AllocationInfo -> Maybe DeprecationInfo -> Interface [ifTypeInit] :: Interface -> Maybe Text [ifCType] :: Interface -> Maybe Text [ifDocumentation] :: Interface -> Documentation [ifPrerequisites] :: Interface -> [Name] [ifProperties] :: Interface -> [Property] [ifSignals] :: Interface -> [Signal] [ifMethods] :: Interface -> [Method] [ifAllocationInfo] :: Interface -> AllocationInfo [ifDeprecated] :: Interface -> Maybe DeprecationInfo parseInterface :: Parser (Name, Interface) instance GHC.Show.Show Data.GI.GIR.Interface.Interface module Data.GI.GIR.Function data Function Function :: Text -> Maybe Text -> Callable -> Function -- | The symbol in the dynlib that this function refers to. [fnSymbol] :: Function -> Text [fnMovedTo] :: Function -> Maybe Text [fnCallable] :: Function -> Callable parseFunction :: Parser (Name, Function) instance GHC.Show.Show Data.GI.GIR.Function.Function -- | Parsing of callbacks. module Data.GI.GIR.Callback data Callback Callback :: Callable -> Maybe Text -> Documentation -> Callback [cbCallable] :: Callback -> Callable [cbCType] :: Callback -> Maybe Text [cbDocumentation] :: Callback -> Documentation parseCallback :: Parser (Name, Callback) instance GHC.Show.Show Data.GI.GIR.Callback.Callback -- | Parsing of objectstructunion fields. module Data.GI.GIR.Field data Field Field :: Text -> Bool -> Type -> Maybe Bool -> Maybe Callback -> Int -> [FieldInfoFlag] -> Documentation -> Maybe DeprecationInfo -> Field [fieldName] :: Field -> Text [fieldVisible] :: Field -> Bool [fieldType] :: Field -> Type -- | Nothing if not known. [fieldIsPointer] :: Field -> Maybe Bool [fieldCallback] :: Field -> Maybe Callback [fieldOffset] :: Field -> Int [fieldFlags] :: Field -> [FieldInfoFlag] [fieldDocumentation] :: Field -> Documentation [fieldDeprecated] :: Field -> Maybe DeprecationInfo data FieldInfoFlag parseFields :: Parser [Field] instance GHC.Show.Show Data.GI.GIR.Field.FieldInfoFlag instance GHC.Show.Show Data.GI.GIR.Field.Field -- | Parsing of unions. module Data.GI.GIR.Union data Union Union :: Bool -> AllocationInfo -> Documentation -> Int -> Maybe Text -> [Field] -> [Method] -> Maybe Text -> Maybe DeprecationInfo -> Union [unionIsBoxed] :: Union -> Bool [unionAllocationInfo] :: Union -> AllocationInfo [unionDocumentation] :: Union -> Documentation [unionSize] :: Union -> Int [unionTypeInit] :: Union -> Maybe Text [unionFields] :: Union -> [Field] [unionMethods] :: Union -> [Method] [unionCType] :: Union -> Maybe Text [unionDeprecated] :: Union -> Maybe DeprecationInfo parseUnion :: Parser (Name, Union) instance GHC.Show.Show Data.GI.GIR.Union.Union -- | Parsing of structs. module Data.GI.GIR.Struct data Struct Struct :: Bool -> AllocationInfo -> Maybe Text -> Maybe Text -> Int -> Maybe Name -> Bool -> Bool -> [Field] -> [Method] -> Maybe DeprecationInfo -> Documentation -> Struct [structIsBoxed] :: Struct -> Bool [structAllocationInfo] :: Struct -> AllocationInfo [structTypeInit] :: Struct -> Maybe Text [structCType] :: Struct -> Maybe Text [structSize] :: Struct -> Int [gtypeStructFor] :: Struct -> Maybe Name [structIsDisguised] :: Struct -> Bool [structForceVisible] :: Struct -> Bool [structFields] :: Struct -> [Field] [structMethods] :: Struct -> [Method] [structDeprecated] :: Struct -> Maybe DeprecationInfo [structDocumentation] :: Struct -> Documentation parseStruct :: Parser (Name, Struct) instance GHC.Show.Show Data.GI.GIR.Struct.Struct module Data.GI.GIR.Alias -- | Find all aliases in a given document. documentListAliases :: Document -> Map Alias Type module Data.GI.CodeGen.API -- | An element in the exposed API data API APIConst :: Constant -> API APIFunction :: Function -> API APICallback :: Callback -> API APIEnum :: Enumeration -> API APIFlags :: Flags -> API APIInterface :: Interface -> API APIObject :: Object -> API APIStruct :: Struct -> API APIUnion :: Union -> API data GIRInfo GIRInfo :: [Text] -> Text -> Text -> [(Name, API)] -> Map Text Name -> GIRInfo [girPCPackages] :: GIRInfo -> [Text] [girNSName] :: GIRInfo -> Text [girNSVersion] :: GIRInfo -> Text [girAPIs] :: GIRInfo -> [(Name, API)] [girCTypes] :: GIRInfo -> Map Text Name -- | Load and parse a GIR file, including its dependencies. loadGIRInfo :: Bool -> Text -> Maybe Text -> [FilePath] -> [GIRRule] -> IO (GIRInfo, [GIRInfo]) -- | Bare minimum loading and parsing of a single repository, without -- loading or parsing its dependencies, resolving aliases, or fixing up -- structs or interfaces. loadRawGIRInfo :: Bool -> Text -> Maybe Text -> [FilePath] -> IO GIRInfo -- | A rule for modifying the GIR file. data GIRRule -- | (Path to element, attrName), newValue. GIRSetAttr :: (GIRPath, Name) -> Text -> GIRRule -- | Delete the given attribute GIRDeleteAttr :: GIRPath -> Name -> GIRRule -- | Add a child node at the given selector. GIRAddNode :: GIRPath -> Name -> GIRRule -- | Delete any nodes matching the given selector. GIRDeleteNode :: GIRPath -> GIRRule -- | Path to a node in the GIR file, starting from the document root of the -- GIR file. This is a very simplified version of something like XPath. type GIRPath = [GIRNodeSpec] -- | Node selector for a path in the GIR file. data GIRNodeSpec -- | Node with the given "name" attr. GIRNamed :: GIRNameTag -> GIRNodeSpec -- | Node of the given type. GIRType :: Text -> GIRNodeSpec -- | Combination of the above. GIRTypedName :: Text -> GIRNameTag -> GIRNodeSpec -- | A name tag, which is either a name or a regular expression. data GIRNameTag GIRPlainName :: Text -> GIRNameTag GIRRegex :: Text -> GIRNameTag -- | Name for a symbol in the GIR file. data Name Name :: Text -> Text -> Name [namespace] :: Name -> Text [name] :: Name -> Text -- | Transfer mode for an argument or property. data Transfer TransferNothing :: Transfer TransferContainer :: Transfer TransferEverything :: Transfer -- | Allocation/deallocation information for a given foreign pointer. data AllocationInfo AllocationInfo :: AllocationOp -> AllocationOp -> AllocationOp -> AllocationInfo [allocCalloc] :: AllocationInfo -> AllocationOp [allocCopy] :: AllocationInfo -> AllocationOp [allocFree] :: AllocationInfo -> AllocationOp -- | 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 AllocationOp :: Text -> AllocationOp -- | A convenience function, filling in all the allocation info to unknown. unknownAllocationInfo :: AllocationInfo data Direction DirectionIn :: Direction DirectionOut :: Direction DirectionInout :: Direction data Scope ScopeTypeInvalid :: Scope ScopeTypeCall :: Scope ScopeTypeAsync :: Scope ScopeTypeNotified :: Scope -- | Deprecation information on a symbol. data DeprecationInfo -- | Member of an enumeration. data EnumerationMember EnumerationMember :: Text -> Int64 -> Text -> Documentation -> EnumerationMember [enumMemberName] :: EnumerationMember -> Text [enumMemberValue] :: EnumerationMember -> Int64 [enumMemberCId] :: EnumerationMember -> Text [enumMemberDoc] :: EnumerationMember -> Documentation data PropertyFlag PropertyReadable :: PropertyFlag PropertyWritable :: PropertyFlag PropertyConstruct :: PropertyFlag PropertyConstructOnly :: PropertyFlag data MethodType -- | Constructs an instance of the parent type Constructor :: MethodType -- | A function in the namespace MemberFunction :: MethodType -- | A function taking the parent instance as first argument. OrdinaryMethod :: MethodType -- | Info about a constant. data Constant Constant :: Type -> Text -> Text -> Documentation -> Maybe DeprecationInfo -> Constant [constantType] :: Constant -> Type [constantValue] :: Constant -> Text [constantCType] :: Constant -> Text [constantDocumentation] :: Constant -> Documentation [constantDeprecated] :: Constant -> Maybe DeprecationInfo data Arg Arg :: Text -> Type -> Direction -> Bool -> Documentation -> Scope -> Int -> Int -> Bool -> Transfer -> Arg -- | C name for the argument. For a escaped name valid in Haskell -- code, use escapedArgName. [argCName] :: Arg -> Text [argType] :: Arg -> Type [direction] :: Arg -> Direction [mayBeNull] :: Arg -> Bool [argDoc] :: Arg -> Documentation [argScope] :: Arg -> Scope [argClosure] :: Arg -> Int [argDestroy] :: Arg -> Int [argCallerAllocates] :: Arg -> Bool [transfer] :: Arg -> Transfer data Callable Callable :: Maybe Type -> Bool -> Transfer -> Documentation -> [Arg] -> Bool -> Bool -> Maybe DeprecationInfo -> Documentation -> Maybe Bool -> Callable [returnType] :: Callable -> Maybe Type [returnMayBeNull] :: Callable -> Bool [returnTransfer] :: Callable -> Transfer [returnDocumentation] :: Callable -> Documentation [args] :: Callable -> [Arg] [skipReturn] :: Callable -> Bool [callableThrows] :: Callable -> Bool [callableDeprecated] :: Callable -> Maybe DeprecationInfo [callableDocumentation] :: Callable -> Documentation -- | Whether the symbol for this callable can be resolved in the dynamical -- library associated with the current introspection data. Nothing -- means that we have not checked yet. [callableResolvable] :: Callable -> Maybe Bool data Function Function :: Text -> Maybe Text -> Callable -> Function -- | The symbol in the dynlib that this function refers to. [fnSymbol] :: Function -> Text [fnMovedTo] :: Function -> Maybe Text [fnCallable] :: Function -> Callable data Signal Signal :: Text -> Callable -> Maybe DeprecationInfo -> Bool -> Documentation -> Signal [sigName] :: Signal -> Text [sigCallable] :: Signal -> Callable [sigDeprecated] :: Signal -> Maybe DeprecationInfo [sigDetailed] :: Signal -> Bool [sigDoc] :: Signal -> Documentation data Property Property :: Text -> Type -> [PropertyFlag] -> Maybe Bool -> Maybe Bool -> Transfer -> Documentation -> Maybe DeprecationInfo -> Property [propName] :: Property -> Text [propType] :: Property -> Type [propFlags] :: Property -> [PropertyFlag] [propReadNullable] :: Property -> Maybe Bool [propWriteNullable] :: Property -> Maybe Bool [propTransfer] :: Property -> Transfer [propDoc] :: Property -> Documentation [propDeprecated] :: Property -> Maybe DeprecationInfo data Field Field :: Text -> Bool -> Type -> Maybe Bool -> Maybe Callback -> Int -> [FieldInfoFlag] -> Documentation -> Maybe DeprecationInfo -> Field [fieldName] :: Field -> Text [fieldVisible] :: Field -> Bool [fieldType] :: Field -> Type -- | Nothing if not known. [fieldIsPointer] :: Field -> Maybe Bool [fieldCallback] :: Field -> Maybe Callback [fieldOffset] :: Field -> Int [fieldFlags] :: Field -> [FieldInfoFlag] [fieldDocumentation] :: Field -> Documentation [fieldDeprecated] :: Field -> Maybe DeprecationInfo data Struct Struct :: Bool -> AllocationInfo -> Maybe Text -> Maybe Text -> Int -> Maybe Name -> Bool -> Bool -> [Field] -> [Method] -> Maybe DeprecationInfo -> Documentation -> Struct [structIsBoxed] :: Struct -> Bool [structAllocationInfo] :: Struct -> AllocationInfo [structTypeInit] :: Struct -> Maybe Text [structCType] :: Struct -> Maybe Text [structSize] :: Struct -> Int [gtypeStructFor] :: Struct -> Maybe Name [structIsDisguised] :: Struct -> Bool [structForceVisible] :: Struct -> Bool [structFields] :: Struct -> [Field] [structMethods] :: Struct -> [Method] [structDeprecated] :: Struct -> Maybe DeprecationInfo [structDocumentation] :: Struct -> Documentation data Callback Callback :: Callable -> Maybe Text -> Documentation -> Callback [cbCallable] :: Callback -> Callable [cbCType] :: Callback -> Maybe Text [cbDocumentation] :: Callback -> Documentation data Interface Interface :: Maybe Text -> Maybe Text -> Documentation -> [Name] -> [Property] -> [Signal] -> [Method] -> AllocationInfo -> Maybe DeprecationInfo -> Interface [ifTypeInit] :: Interface -> Maybe Text [ifCType] :: Interface -> Maybe Text [ifDocumentation] :: Interface -> Documentation [ifPrerequisites] :: Interface -> [Name] [ifProperties] :: Interface -> [Property] [ifSignals] :: Interface -> [Signal] [ifMethods] :: Interface -> [Method] [ifAllocationInfo] :: Interface -> AllocationInfo [ifDeprecated] :: Interface -> Maybe DeprecationInfo data Method Method :: Name -> Text -> MethodType -> Maybe Text -> Callable -> Method [methodName] :: Method -> Name -- | The symbol in the dynlib that this method refers to. [methodSymbol] :: Method -> Text [methodType] :: Method -> MethodType [methodMovedTo] :: Method -> Maybe Text [methodCallable] :: Method -> Callable data Object Object :: Maybe Name -> Text -> Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> [Name] -> Maybe DeprecationInfo -> Documentation -> [Method] -> [Property] -> [Signal] -> Object [objParent] :: Object -> Maybe Name [objTypeInit] :: Object -> Text [objTypeName] :: Object -> Text [objCType] :: Object -> Maybe Text [objRefFunc] :: Object -> Maybe Text [objUnrefFunc] :: Object -> Maybe Text [objSetValueFunc] :: Object -> Maybe Text [objGetValueFunc] :: Object -> Maybe Text [objInterfaces] :: Object -> [Name] [objDeprecated] :: Object -> Maybe DeprecationInfo [objDocumentation] :: Object -> Documentation [objMethods] :: Object -> [Method] [objProperties] :: Object -> [Property] [objSignals] :: Object -> [Signal] data Enumeration Enumeration :: [EnumerationMember] -> Maybe Text -> Maybe Text -> Documentation -> Text -> Int -> Maybe DeprecationInfo -> Enumeration [enumMembers] :: Enumeration -> [EnumerationMember] [enumErrorDomain] :: Enumeration -> Maybe Text [enumTypeInit] :: Enumeration -> Maybe Text [enumDocumentation] :: Enumeration -> Documentation [enumCType] :: Enumeration -> Text -- | Bytes used for storage of this struct. [enumStorageBytes] :: Enumeration -> Int [enumDeprecated] :: Enumeration -> Maybe DeprecationInfo data Flags Flags :: Enumeration -> Flags data Union Union :: Bool -> AllocationInfo -> Documentation -> Int -> Maybe Text -> [Field] -> [Method] -> Maybe Text -> Maybe DeprecationInfo -> Union [unionIsBoxed] :: Union -> Bool [unionAllocationInfo] :: Union -> AllocationInfo [unionDocumentation] :: Union -> Documentation [unionSize] :: Union -> Int [unionTypeInit] :: Union -> Maybe Text [unionFields] :: Union -> [Field] [unionMethods] :: Union -> [Method] [unionCType] :: Union -> Maybe Text [unionDeprecated] :: Union -> Maybe DeprecationInfo instance GHC.Show.Show Data.GI.CodeGen.API.GIRNameTag instance GHC.Show.Show Data.GI.CodeGen.API.GIRNodeSpec instance GHC.Show.Show Data.GI.CodeGen.API.GIRRule instance GHC.Show.Show Data.GI.CodeGen.API.API instance GHC.Show.Show Data.GI.CodeGen.API.GIRNamespace instance GHC.Show.Show Data.GI.CodeGen.API.GIRInfoParse instance GHC.Show.Show Data.GI.CodeGen.API.GIRInfo module Data.GI.CodeGen.Overrides data Overrides -- | Parse the given overrides, filling in the configuration as needed. In -- case the parsing fails we return a description of the error instead. parseOverrides :: Text -> IO (Either Text Overrides) -- | Load a given API, applying filtering. Load also any necessary -- dependencies. filterAPIsAndDeps :: Overrides -> GIRInfo -> [GIRInfo] -> (Map Name API, Map Name API) instance GHC.Show.Show Data.GI.CodeGen.Overrides.Overrides instance GHC.Show.Show Data.GI.CodeGen.Overrides.ParserState instance GHC.Show.Show Data.GI.CodeGen.Overrides.OSType instance GHC.Base.Monoid Data.GI.CodeGen.Overrides.Overrides instance GHC.Base.Semigroup Data.GI.CodeGen.Overrides.Overrides -- | Configuration for the code generator. module Data.GI.CodeGen.Config data Config Config :: Text -> Text -> Text -> Text -> Bool -> Overrides -> Config -- | GIR name of the module being generated (Gtk, GObject, ...). [modName] :: Config -> Text -- | Version of the GIR API for the package being generated ("3.0", "2.0", -- ...). [modVersion] :: Config -> Text -- | Haskell package being generated (gi-gtk, gi-gobject, ...). [ghcPkgName] :: Config -> Text -- | Version of the haskell package ("3.0.35", "2.0.21", ...). [ghcPkgVersion] :: Config -> Text -- | Whether to print extra info. [verbose] :: Config -> Bool -- | List of loaded overrides for the code generator. [overrides] :: Config -> Overrides instance GHC.Show.Show Data.GI.CodeGen.Config.Config -- | Various fixups in the introspection data. module Data.GI.CodeGen.Fixups -- | Remove functions and methods annotated with "moved-to". dropMovedItems :: API -> Maybe API -- | GObject-introspection does not currently support nullability -- annotations, so we try to guess the nullability from the nullability -- annotations of the curresponding get/set methods, which in principle -- should be reliable. guessPropertyNullability :: (Name, API) -> (Name, API) -- | Not every interface that provides signals/properties is marked as -- requiring GObject, but this is necessarily the case, so fix the -- introspection data accordingly. detectGObject :: (Name, API) -> (Name, API) -- | Some libraries include duplicated flags by mistake, drop those. dropDuplicatedFields :: (Name, API) -> (Name, API) -- | Sometimes arguments are marked as being a user_data destructor, but -- there is no associated user_data argument. In this case we drop the -- annotation. checkClosureDestructors :: (Name, API) -> (Name, API) -- | Some symbols have names that are not valid Haskell identifiers, fix -- that here. fixSymbolNaming :: (Name, API) -> (Name, API) module Data.GI.CodeGen.Code -- | The generated Code is a sequence of CodeTokens. data Code -- | Information on a generated module. data ModuleInfo -- | Flags for module code generation. data ModuleFlag -- | Use the standard prelude, instead of the haskell-gi-base short one. ImplicitPrelude :: ModuleFlag -- | The base type for the code generator monad. Generators that cannot -- throw errors are parametric in the exception type excType. type CodeGen excType a = ReaderT CodeGenConfig (StateT (CGState, ModuleInfo) (Except excType)) a -- | Code generators that can throw errors. type ExcCodeGen a = CodeGen CGError a -- | Set of errors for the code generator. data CGError -- | Like evalCodeGen, but discard the resulting output value. genCode :: Config -> Map Name API -> ModulePath -> CodeGen e () -> ModuleInfo -- | Run a code generator, and return the information for the generated -- module together with the return value of the generator. evalCodeGen :: Config -> Map Name API -> ModulePath -> CodeGen e a -> (a, ModuleInfo) -- | Write down the code for a module and its submodules to disk under the -- given base directory. It returns the list of written modules. writeModuleTree :: Bool -> Maybe FilePath -> ModuleInfo -> IO [Text] -- | Return the list of modules writeModuleTree would write, without -- actually writing anything to disk. listModuleTree :: ModuleInfo -> [Text] -- | Return a text representation of the Code. codeToText :: Code -> Text -- | Return the transitive set of dependencies, i.e. the union of those of -- the module and (transitively) its submodules. transitiveModuleDeps :: ModuleInfo -> Deps -- | Return the minimal base version supported by the module and all its -- submodules. minBaseVersion :: ModuleInfo -> BaseVersion -- | Minimal version of base supported by a given module. data BaseVersion -- |
    --
  1. 7.0
  2. --
Base47 :: BaseVersion -- |
    --
  1. 8.0
  2. --
Base48 :: BaseVersion -- | A Text representation of the given base version bound. showBaseVersion :: BaseVersion -> Text -- | Mark the given dependency as used by the module. registerNSDependency :: Text -> CodeGen e () -- | Given a module name and a symbol in the module (including a proper -- namespace), return a qualified name for the symbol. qualified :: ModulePath -> Name -> CodeGen e Text -- | Return the currently loaded set of dependencies. getDeps :: CodeGen e Deps -- | Like recurseCG, giving explicitly the set of loaded APIs and C -- to Haskell map for the subgenerator. recurseWithAPIs :: Map Name API -> CodeGen e () -> CodeGen e () -- | Try running the given action, and if it fails run -- fallback instead. handleCGExc :: (CGError -> CodeGen e a) -> ExcCodeGen a -> CodeGen e a -- | Print, as a comment, a friendly textual description of the error. printCGError :: CGError -> CodeGen e () notImplementedError :: Text -> ExcCodeGen a badIntroError :: Text -> ExcCodeGen a missingInfoError :: Text -> ExcCodeGen a -- | Increase the indent level for code generation. indent :: CodeGen e a -> CodeGen e a -- | Increase the indentation level for the rest of the lines in the -- current group. increaseIndent :: CodeGen e () -- | Print out the given line both to the normal module, and to the HsBoot -- file. bline :: Text -> CodeGen e () -- | Print out a (newline-terminated) line. line :: Text -> CodeGen e () -- | A blank line blank :: CodeGen e () -- | Group a set of related code. group :: CodeGen e a -> CodeGen e a -- | A (possibly multi line) comment, separated by newlines comment :: Text -> CodeGen e () -- | Guard a code block with CPP code, such that it is included only if the -- specified feature is enabled. cppIf :: CPPGuard -> CodeGen e a -> CodeGen e a -- | Possible features to test via CPP. data CPPGuard -- | Enable overloading CPPOverloading :: CPPGuard -- | Require a specific version of the given package. CPPMinVersion :: Text -> (Integer, Integer, Integer) -> CPPGuard -- | Write the given code into the .hs-boot file for the current module. hsBoot :: CodeGen e a -> CodeGen e a -- | Run the given CodeGen in order to generate a submodule (specified an -- an ordered list) of the current module. submodule :: ModulePath -> CodeGen e () -> CodeGen e () -- | Set the language pragmas for the current module. setLanguagePragmas :: [Text] -> CodeGen e () -- | Add a language pragma for the current module. addLanguagePragma :: Text -> CodeGen e () -- | Set the GHC options for compiling this module (in a OPTIONS_GHC -- pragma). setGHCOptions :: [Text] -> CodeGen e () -- | Set the given flags for the module. setModuleFlags :: [ModuleFlag] -> CodeGen e () -- | Set the minimum base version supported by the current module. setModuleMinBase :: BaseVersion -> CodeGen e () -- | Get a type variable unused in the current scope. getFreshTypeVariable :: CodeGen e Text -- | Introduce a new scope for type variable naming: the next fresh -- variable will be called a. resetTypeVariableScope :: CodeGen e () -- | Reexport a whole module. exportModule :: SymbolName -> CodeGen e () -- | Add a type declaration-related export. exportDecl :: SymbolName -> CodeGen e () -- | Export a symbol in the given haddock subsection. export :: HaddockSection -> SymbolName -> CodeGen e () -- | Subsection of the haddock documentation where the export should be -- located, or alternatively the toplevel section. data HaddockSection ToplevelSection :: HaddockSection Section :: NamedSection -> HaddockSection NamedSubsection :: NamedSection -> Text -> HaddockSection -- | Known subsections. The ordering here is the ordering in which they -- will appear in the haddocks. data NamedSection MethodSection :: NamedSection PropertySection :: NamedSection SignalSection :: NamedSection EnumSection :: NamedSection FlagSection :: NamedSection -- | Add documentation for a given section. addSectionFormattedDocs :: HaddockSection -> Text -> CodeGen e () -- | Prepend documentation at the beginning of a given section. prependSectionFormattedDocs :: HaddockSection -> Text -> CodeGen e () -- | Try to find the API associated with a given type, if known. findAPI :: HasCallStack => Type -> CodeGen e (Maybe API) -- | Find the API associated with a given type. If the API cannot be found -- this raises an error. getAPI :: HasCallStack => Type -> CodeGen e API findAPIByName :: HasCallStack => Name -> CodeGen e API -- | Return the list of APIs available to the generator. getAPIs :: CodeGen e (Map Name API) -- | Return the C -> Haskell available to the generator. getC2HMap :: CodeGen e (Map CRef Hyperlink) -- | Return the ambient configuration for the code generator. config :: CodeGen e Config -- | Return the name of the current module. currentModule :: CodeGen e Text instance GHC.Classes.Ord Data.GI.CodeGen.Code.CPPConditional instance GHC.Show.Show Data.GI.CodeGen.Code.CPPConditional instance GHC.Classes.Eq Data.GI.CodeGen.Code.CPPConditional instance GHC.Classes.Ord Data.GI.CodeGen.Code.Code instance GHC.Show.Show Data.GI.CodeGen.Code.Code instance GHC.Classes.Eq Data.GI.CodeGen.Code.Code instance GHC.Base.Monoid Data.GI.CodeGen.Code.Code instance GHC.Base.Semigroup Data.GI.CodeGen.Code.Code instance GHC.Show.Show Data.GI.CodeGen.Code.CodeToken instance GHC.Classes.Ord Data.GI.CodeGen.Code.CodeToken instance GHC.Classes.Eq Data.GI.CodeGen.Code.CodeToken instance GHC.Classes.Ord Data.GI.CodeGen.Code.NamedSection instance GHC.Classes.Eq Data.GI.CodeGen.Code.NamedSection instance GHC.Show.Show Data.GI.CodeGen.Code.NamedSection instance GHC.Classes.Ord Data.GI.CodeGen.Code.HaddockSection instance GHC.Classes.Eq Data.GI.CodeGen.Code.HaddockSection instance GHC.Show.Show Data.GI.CodeGen.Code.HaddockSection instance GHC.Classes.Ord Data.GI.CodeGen.Code.ExportType instance GHC.Classes.Eq Data.GI.CodeGen.Code.ExportType instance GHC.Show.Show Data.GI.CodeGen.Code.ExportType instance GHC.Classes.Ord Data.GI.CodeGen.Code.Export instance GHC.Classes.Eq Data.GI.CodeGen.Code.Export instance GHC.Show.Show Data.GI.CodeGen.Code.Export instance GHC.Classes.Ord Data.GI.CodeGen.Code.ModuleFlag instance GHC.Classes.Eq Data.GI.CodeGen.Code.ModuleFlag instance GHC.Show.Show Data.GI.CodeGen.Code.ModuleFlag instance GHC.Classes.Ord Data.GI.CodeGen.Code.BaseVersion instance GHC.Classes.Eq Data.GI.CodeGen.Code.BaseVersion instance GHC.Show.Show Data.GI.CodeGen.Code.BaseVersion instance GHC.Show.Show Data.GI.CodeGen.Code.CGError instance GHC.Classes.Ord Data.GI.CodeGen.Code.Subsection instance GHC.Show.Show Data.GI.CodeGen.Code.Subsection instance GHC.Classes.Eq Data.GI.CodeGen.Code.Subsection module Data.GI.CodeGen.SymbolNaming -- | Same as lowerSymbol, but accepts a Name. The namespace -- part of the name will be discarded. -- --

Examples

-- --
--   >>> lowerName (Name "Gtk" "main_quit")
--   "mainQuit"
--   
lowerName :: Name -> Text -- | Turn the given identifier into camelCase, starting with a lowercase -- letter. -- --

Examples

-- --
--   >>> lowerSymbol "main_quit"
--   "mainQuit"
--   
lowerSymbol :: Text -> Text -- | Turn the given Name into CamelCase, starting with a capital -- letter. -- --

Examples

-- --
--   >>> upperName (Name "Foo" "bar_baz")
--   "BarBaz"
--   
upperName :: Name -> Text -- | Name for the given argument, making sure it is a valid Haskell -- argument name (and escaping it if not). escapedArgName :: Arg -> Text -- | Return a qualified form of the constraint for the given name (which -- should correspond to a valid TInterface). classConstraint :: Name -> CodeGen e Text -- | Same as classConstraint, but applicable directly to a type. The -- type should be a TInterface, otherwise an error will be raised. typeConstraint :: Type -> CodeGen e Text -- | Return a qualified form of the function mapping instances of -- IsX to haskell values of type X. safeCast :: Name -> CodeGen e Text -- | Turn a hyphen-separated identifier into camel case. -- --

Examples

-- --
--   >>> hyphensToCamelCase "one-sample-string"
--   "OneSampleString"
--   
hyphensToCamelCase :: Text -> Text -- | Similarly to hyphensToCamelCase, turn a name -- separated_by_underscores into CamelCase. We preserve final and initial -- underscores, and n>1 consecutive underscores are transformed into -- n-1 underscores. -- --

Examples

-- --
--   >>> underscoresToCamelCase "sample_id"
--   "SampleId"
--   
-- --
--   >>> underscoresToCamelCase "_internal_id_"
--   "_InternalId_"
--   
-- --
--   >>> underscoresToCamelCase "multiple___underscores"
--   "Multiple__Underscores"
--   
underscoresToCamelCase :: Text -> Text -- | Foreign type associated with a callback type. It can be passed in -- qualified. callbackCType :: Text -> Text -- | Haskell type exposing the closure arguments, which are generally -- elided. callbackHTypeWithClosures :: Text -> Text -- | The name of a function which takes a callback without closure -- arguments, and generates a function which does accep the closures, but -- simply ignores them. callbackDropClosures :: Text -> Text -- | The name of the dynamic wrapper for the given callback type. It can be -- passed in qualified. callbackDynamicWrapper :: Text -> Text -- | The name for the foreign wrapper allocator (foreign import -- "wrapper" ...) for the given callback type. It can be passed in -- qualified. callbackWrapperAllocator :: Text -> Text -- | The name of the Haskell to foreign wrapper for the given callback -- type. It can be passed in qualified. callbackHaskellToForeign :: Text -> Text -- | The name of the Haskell to foreign wrapper for the given callback -- type, keeping the closure arguments (we usually elide them). The -- callback type can be passed in qualified. callbackHaskellToForeignWithClosures :: Text -> Text -- | The name for the closure generator for the given callback type. It can -- be passed in qualified. callbackClosureGenerator :: Text -> Text -- | Return the name for the signal in Haskell CamelCase conventions. signalHaskellName :: Text -> Text -- | Qualified name for the "(sigName, info)" tag for a given signal. signalInfoName :: Name -> Signal -> CodeGen e Text -- | Construct the submodule path where the given API element will live. -- This is the path relative to the root for the corresponding namespace. -- I.e. the GI.Gtk part is not prepended. submoduleLocation :: Name -> API -> ModulePath -- | Obtain the absolute location of the module where the given API -- lives. moduleLocation :: Name -> API -> ModulePath -- | Return an identifier for the given interface type valid in the current -- module. qualifiedAPI :: API -> Name -> CodeGen e Text -- | Construct an identifier for the given symbol in the given API. qualifiedSymbol :: Text -> Name -> CodeGen e Text -- | Construct the Haskell version of the name associated to the given API. normalizedAPIName :: API -> Name -> Name -- | Return a link to the hackage package for the given name. Note that the -- generated link will only be valid if the name belongs to the binding -- which is currently being generated. hackageModuleLink :: Name -> CodeGen e Text -- | Prefix in Haddock for the signal anchor. haddockSignalAnchor :: Text -- | Prefix in Haddock for the attribute anchor. haddockAttrAnchor :: Text -- | Construct a map from C identifiers to the corresponding Haskell -- elements in the bindings. module Data.GI.CodeGen.CtoHaskellMap -- | Given a set of APIs, build a Map that given a Text -- corresponding to a certain C identifier returns the corresponding -- Haskell element in the bindings. For instance, -- gtk_widget_show will get mapped to show. cToHaskellMap :: [(Name, API)] -> Map CRef Hyperlink -- | Link to an identifier, module, etc. data Hyperlink -- | An identifier at the value level: functions, data constructors, ... ValueIdentifier :: Text -> Hyperlink -- | An identifier at the type level. TypeIdentifier :: Text -> Hyperlink -- | Link to a module. ModuleLink :: Text -> Hyperlink -- | Link to an anchor inside a given module, with an optional label. ModuleLinkWithAnchor :: Maybe Text -> Text -> Text -> Hyperlink instance GHC.Classes.Eq Data.GI.CodeGen.CtoHaskellMap.Hyperlink instance GHC.Show.Show Data.GI.CodeGen.CtoHaskellMap.Hyperlink module Data.GI.CodeGen.Inheritance -- | List all properties defined for an object, including those defined by -- its ancestors. fullObjectPropertyList :: Name -> Object -> CodeGen e [(Name, Property)] -- | List all properties defined for an interface, including those defined -- by its prerequisites. fullInterfacePropertyList :: Name -> Interface -> CodeGen e [(Name, Property)] -- | List all signals defined for an object, including those defined by its -- ancestors. fullObjectSignalList :: Name -> Object -> CodeGen e [(Name, Signal)] -- | List all signals defined for an interface, including those defined by -- its prerequisites. fullInterfaceSignalList :: Name -> Interface -> CodeGen e [(Name, Signal)] -- | List all methods defined for an object, including those defined by its -- ancestors. fullObjectMethodList :: Name -> Object -> CodeGen e [(Name, Method)] -- | List all methods defined for an interface, including those defined by -- its prerequisites. fullInterfaceMethodList :: Name -> Interface -> CodeGen e [(Name, Method)] -- | Compute the (ordered) list of parents of the current object. instanceTree :: Name -> CodeGen e [Name] instance Data.GI.CodeGen.Inheritance.Inheritable Data.GI.GIR.Property.Property instance Data.GI.CodeGen.Inheritance.Inheritable Data.GI.GIR.Signal.Signal instance Data.GI.CodeGen.Inheritance.Inheritable Data.GI.GIR.Method.Method -- | Render an abstract representation of documentation (as produced by -- parseGtkDoc) as Haddock formatted documentation. module Data.GI.CodeGen.Haddock -- | Write the deprecation pragma for the given DeprecationInfo, if -- not Nothing. deprecatedPragma :: Text -> Maybe DeprecationInfo -> CodeGen e () -- | Write the given documentation into generated code. writeDocumentation :: RelativeDocPosition -> Documentation -> CodeGen e () -- | Where is the documentation located with respect to the relevant -- symbol, useful for determining whether we want to start with -- | or ^. data RelativeDocPosition DocBeforeSymbol :: RelativeDocPosition DocAfterSymbol :: RelativeDocPosition -- | Like writeDocumentation, but allows us to pass explicitly the -- Haddock comment to write. writeHaddock :: RelativeDocPosition -> Text -> CodeGen e () -- | Write the documentation for the given argument. writeArgDocumentation :: Arg -> CodeGen e () -- | Write the documentation for the given return value. writeReturnDocumentation :: Callable -> Bool -> CodeGen e () -- | Add the given text to the documentation for the section being -- generated. addSectionDocumentation :: HaddockSection -> Documentation -> CodeGen e () module Data.GI.CodeGen.GObject -- | Check whether the given type descends from GObject. isGObject :: Type -> CodeGen e Bool -- | Check whether the given API descends from GObject. apiIsGObject :: Name -> API -> CodeGen e Bool -- | Check whether the given name descends from GObject. nameIsGObject :: Name -> CodeGen e Bool module Data.GI.CodeGen.OverloadedSignals -- | Signal instances for (GObject-derived) objects. genObjectSignals :: Name -> Object -> CodeGen e () -- | Signal instances for interfaces. genInterfaceSignals :: Name -> Interface -> CodeGen e () -- | Support for enums and flags. module Data.GI.CodeGen.EnumFlags genEnum :: Name -> Enumeration -> CodeGen e () -- | Very similar to enums, but we also declare ourselves as members of the -- IsGFlag typeclass. genFlags :: Name -> Flags -> CodeGen e () module Data.GI.CodeGen.Conversions convert :: Text -> CodeGen e Converter -> CodeGen e Text genConversion :: Text -> Converter -> CodeGen e Text unpackCArray :: Text -> Type -> Transfer -> ExcCodeGen Converter -- | Given an array, together with its type, return the code for reading -- its length. computeArrayLength :: Text -> Type -> ExcCodeGen Text -- | Whether the callable has closure arguments (i.e. "user_data" style -- arguments). callableHasClosures :: Callable -> Bool hToF :: Type -> Transfer -> ExcCodeGen Converter fToH :: Type -> Transfer -> ExcCodeGen Converter -- | Somewhat like fToH, but with slightly different borrowing -- semantics: in the case of TransferNothing we wrap incoming -- pointers to boxed structs into transient ManagedPtrs (every -- other case behaves as fToH). These are ManagedPtrs for -- which we do not make a copy, and which will be disowned when the -- function exists, instead of making a copy that the GC will collect -- eventually. -- -- This is necessary in order to get the semantics of callbacks and -- signals right: in some cases making a copy of the object does not -- simply increase the refcount, but rather makes a full copy. In this -- cases modification of the original object is not possible, but this is -- sometimes useful, see for example -- -- https://github.com/haskell-gi/haskell-gi/issues/97 -- -- Another situation where making a copy of incoming arguments is -- problematic is when the underlying library is not thread-safe. When -- running under the threaded GHC runtime it can happen that the GC runs -- on a different OS thread than the thread where the object was created, -- and this leads to rather mysterious bugs, see for example -- -- https://github.com/haskell-gi/haskell-gi/issues/96 -- -- This case is particularly nasty, since it affects -- onWidgetDraw, which is very common. transientToH :: Type -> Transfer -> ExcCodeGen Converter -- | This translates GI types to the types used for generated Haskell code. haskellType :: Type -> CodeGen e TypeRep -- | Basically like haskellType, but for types which admit a -- "isomorphic" version of the Haskell type distinct from the usual -- Haskell type. Generally the Haskell type we expose is isomorphic to -- the foreign type, but in some cases, such as callbacks with closure -- arguments, this does not hold, as we omit the closure arguments. This -- function returns a type which is actually isomorphic. There is another -- case this function deals with: for convenience untyped -- TGClosure types have a type variable on the Haskell side when -- they are arguments to functions, but we do not want this when they -- appear as arguments to callbacks/signals, or return types of -- properties, as it would force the type synonym/type family to depend -- on the type variable. isoHaskellType :: Type -> CodeGen e TypeRep foreignType :: Type -> CodeGen e TypeRep -- | Given a type find the typeclasses the type belongs to, and return the -- representation of the type in the function signature and the list of -- typeclass constraints for the type. argumentType :: Type -> ExposeClosures -> CodeGen e (Text, [Text]) -- | Whether to expose closures and the associated destroy notify handlers -- in the Haskell wrapper. data ExposeClosures WithClosures :: ExposeClosures WithoutClosures :: ExposeClosures elementType :: Type -> Maybe Type elementMap :: Type -> Text -> Maybe Text -- | If the given type maps to a list in Haskell, return the type of the -- elements, and the function that maps over them. elementTypeAndMap :: Type -> Text -> Maybe (Type, Text) -- | Returns whether the given type corresponds to a ManagedPtr -- instance (a thin wrapper over a ForeignPtr). isManaged :: Type -> CodeGen e Bool -- | Returns whether the given type should be represented by a Maybe -- type on the Haskell side. This applies to all properties which have a -- C representation in terms of pointers, except for G(S)Lists, for which -- NULL is a valid G(S)List, and raw pointers, which we just pass through -- to the Haskell side. Notice that introspection annotations can -- override this. typeIsNullable :: Type -> CodeGen e Bool -- | Returns whether the given type is represented by a pointer on the C -- side. typeIsPtr :: Type -> CodeGen e Bool -- | Check whether the given type corresponds to a callback. typeIsCallback :: Type -> CodeGen e Bool -- | If the passed in type is nullable, return the conversion function -- between the FFI pointer type (may be a Ptr or a -- FunPtr) and the corresponding Maybe type. maybeNullConvert :: Type -> CodeGen e (Maybe Text) -- | An appropriate NULL value for the given type, for types which are -- represented by pointers on the C side. nullPtrForType :: Type -> CodeGen e (Maybe Text) -- | Information on how to allocate the given type, if known. typeAllocInfo :: Type -> CodeGen e (Maybe TypeAllocInfo) -- | Information on how to allocate a type: allocator function and size of -- the struct. data TypeAllocInfo TypeAlloc :: Text -> Int -> TypeAllocInfo apply :: Constructor -> Converter mapC :: Constructor -> Converter literal :: Constructor -> Converter data Constructor P :: Text -> Constructor M :: Text -> Constructor Id :: Constructor instance GHC.Show.Show Data.GI.CodeGen.Conversions.Constructor instance GHC.Classes.Eq Data.GI.CodeGen.Conversions.Constructor instance GHC.Show.Show Data.GI.CodeGen.Conversions.Map instance GHC.Base.Functor Data.GI.CodeGen.Conversions.FExpr instance GHC.Show.Show next => GHC.Show.Show (Data.GI.CodeGen.Conversions.FExpr next) instance GHC.Classes.Eq Data.GI.CodeGen.Conversions.ExposeClosures instance Data.String.IsString Data.GI.CodeGen.Conversions.Constructor instance GHC.Base.Functor f => GHC.Base.Functor (Data.GI.CodeGen.Conversions.Free f) instance GHC.Base.Functor f => GHC.Base.Applicative (Data.GI.CodeGen.Conversions.Free f) instance GHC.Base.Functor f => GHC.Base.Monad (Data.GI.CodeGen.Conversions.Free f) module Data.GI.CodeGen.Transfer -- | Given an input argument to a C callable, and its label in the code, -- return the list of actions relevant to freeing the memory allocated -- for the argument (if appropriate, depending on the ownership transfer -- semantics of the callable). freeInArg :: Arg -> Text -> Text -> ExcCodeGen [Text] -- | Same thing as freeInArg, but called in case the call to C didn't -- succeed. We thus free everything we allocated in preparation for the -- call, including args that would have been transferred to C. freeInArgOnError :: Arg -> Text -> Text -> ExcCodeGen [Text] -- | Free a container and/or the contained elements, depending on the -- transfer mode. freeContainerType :: Transfer -> Type -> Text -> Text -> ExcCodeGen () -- | Marshalling of structs and unions. module Data.GI.CodeGen.Struct -- | Generate code for the given list of fields. genStructOrUnionFields :: Name -> [Field] -> CodeGen e () -- | Specialization for structs of genZeroSU. genZeroStruct :: Name -> Struct -> CodeGen e () -- | Specialization for unions of genZeroSU. genZeroUnion :: Name -> Union -> CodeGen e () -- | Extract the callback types embedded in the fields of structs, and at -- the same time fix the type of the corresponding fields. Returns the -- list of APIs associated to this struct, not including the struct -- itself. extractCallbacksInStruct :: (Name, API) -> [(Name, API)] -- | Fix the interface names of callback fields in an APIStruct to -- correspond to the ones that we are going to generate. If something -- other than an APIStruct is passed in we don't touch it. fixAPIStructs :: (Name, API) -> (Name, API) -- | Whether (not) to generate bindings for the given struct. ignoreStruct :: Name -> Struct -> Bool -- | Allocation and deallocation for types registered as GBoxed in -- the GLib type system. genBoxed :: Name -> Text -> CodeGen e () -- | Generate the typeclass with information for how to allocate/deallocate -- a given type which is not a GBoxed. genWrappedPtr :: Name -> AllocationInfo -> Int -> CodeGen e () module Data.GI.CodeGen.Properties genInterfaceProperties :: Name -> Interface -> CodeGen e () genObjectProperties :: Name -> Object -> CodeGen e () -- | Generate gtk2hs compatible attribute labels (to ease porting). These -- are namespaced labels, for examples widgetSensitive. We take -- the list of methods, since there may be name clashes (an example is -- Auth::is_for_proxy method in libsoup, and the corresponding -- Auth::is-for-proxy property). When there is a clash we give priority -- to the method. genNamespacedPropLabels :: Name -> [Property] -> [Method] -> CodeGen e () module Data.GI.CodeGen.Constant genConstant :: Name -> Constant -> CodeGen e () module Data.GI.CodeGen.Callable -- | Generate a wrapper for a known C symbol. genCCallableWrapper :: Name -> Text -> Callable -> ExcCodeGen () -- | Generate a wrapper for a dynamic C symbol (i.e. a Haskell function -- that will invoke its first argument, which should be a FunPtr -- of the appropriate type). The caller should have created a type -- synonym with the right type for the foreign symbol. genDynamicCallableWrapper :: Name -> Text -> Callable -> ExcCodeGen Text -- | The foreign symbol to wrap. It is either a foreign symbol wrapped in a -- foreign import, in which case we are given the name of the Haskell -- wrapper, or alternatively the information about a "dynamic" wrapper in -- scope. data ForeignSymbol -- | Haskell symbol in scope. KnownForeignSymbol :: Text -> ForeignSymbol -- | Info about the dynamic wrapper. DynamicForeignSymbol :: DynamicWrapper -> ForeignSymbol hOutType :: Callable -> [Arg] -> ExcCodeGen TypeRep -- | Whether to skip the return value in the generated bindings. The C -- convention is that functions throwing an error and returning a -- gboolean set the boolean to TRUE iff there is no error, so the -- information is always implicit in whether we emit an exception or not, -- so the return value can be omitted from the generated bindings without -- loss of information (and omitting it gives rise to a nicer API). See -- https://bugzilla.gnome.org/show_bug.cgi?id=649657 skipRetVal :: Callable -> Bool arrayLengths :: Callable -> [Arg] arrayLengthsMap :: Callable -> [(Arg, Arg)] -- | The Haskell signature for the given callable. It returns a tuple -- ([constraints], [(type, argname)]). callableSignature :: Callable -> ForeignSymbol -> ExposeClosures -> ExcCodeGen Signature -- | Signature for a callable. data Signature Signature :: Callable -> [Text] -> [(Maybe Arg, Text)] -> Text -> Signature [signatureCallable] :: Signature -> Callable [signatureConstraints] :: Signature -> [Text] [signatureArgTypes] :: Signature -> [(Maybe Arg, Text)] [signatureReturnType] :: Signature -> Text -- | caller-allocates arguments are arguments that the caller allocates, -- and the called function modifies. They are marked as out -- argumens in the introspection data, we sometimes treat them as -- inout arguments instead. The semantics are somewhat tricky: -- for memory management purposes they should be treated as "in" -- arguments, but from the point of view of the exposed API they should -- be treated as "out" or "inout". Unfortunately we cannot always just -- assume that they are purely "out", so in many cases the generated API -- is somewhat suboptimal (since the initial values are not important): -- for example for g_io_channel_read_chars the size of the buffer to read -- is determined by the caller-allocates argument. As a compromise, we -- assume that we can allocate anything that is not a TCArray of length -- determined by an argument. fixupCallerAllocates :: Callable -> Callable -- | In arguments for the given callable on the Haskell side, -- together with the omitted arguments. callableHInArgs :: Callable -> ExposeClosures -> ([Arg], [Arg]) -- | Out arguments for the given callable on the Haskell side. callableHOutArgs :: Callable -> [Arg] -- | Given an argument to a function, return whether it should be wrapped -- in a maybe type (useful for nullable types). We do some sanity -- checking to make sure that the argument is actually nullable (a -- relatively common annotation mistake is to mix up (optional) with -- (nullable)). wrapMaybe :: Arg -> CodeGen e Bool -- | Given the list of arguments returns the list of constraints and the -- list of types in the signature. inArgInterfaces :: [Arg] -> ExposeClosures -> ExcCodeGen ([Text], [Text]) module Data.GI.CodeGen.Signal -- | Generate a wrapper for a signal. genSignal :: Signal -> Name -> CodeGen e () genCallback :: Name -> Callback -> CodeGen e () -- | Return the name for the signal in Haskell CamelCase conventions. signalHaskellName :: Text -> Text module Data.GI.CodeGen.OverloadedMethods -- | Generate the MethodList instance given the list of methods -- for the given named type. Returns a Haddock comment summarizing the -- list of methods available. genMethodList :: Name -> [(Name, Method)] -> CodeGen e () -- | Generate the MethodInfo type and instance for the given -- method. genMethodInfo :: Name -> Method -> ExcCodeGen () -- | Generate a method info that is not actually callable, but rather gives -- a type error when trying to use it. genUnsupportedMethodInfo :: Name -> Method -> CodeGen e () module Data.GI.CodeGen.CodeGen genConstant :: Name -> Constant -> CodeGen e () genFunction :: Name -> Function -> CodeGen e () genModule :: Map Name API -> CodeGen e () -- | Convenience hooks for writing custom Setup.hs files for -- bindings. module Data.GI.CodeGen.CabalHooks -- | The entry point for Setup.hs files in bindings. setupBinding :: Text -> Text -> Text -> Text -> Bool -> Maybe FilePath -> [TaggedOverride] -> Maybe FilePath -> IO () -- | Return the list of modules that setupHaskellGIBinding would -- create, together with the set of dependencies loaded while generating -- the code. configureDryRun :: Text -> Text -> Text -> Text -> Maybe FilePath -> [TaggedOverride] -> IO ([Text], Set Text) -- | Included overrides file. data TaggedOverride TaggedOverride :: Text -> Text -> TaggedOverride -- | Tag for the override, for error reporting purposes. [overrideTag] :: TaggedOverride -> Text [overrideText] :: TaggedOverride -> Text module Data.GI.CodeGen.Cabal -- | Generate the cabal project. genCabalProject :: (GIRInfo, PkgInfo) -> [(GIRInfo, PkgInfo)] -> [Text] -> BaseVersion -> CodeGen e () cabalConfig :: Text setupHs :: Text -- | Determine the pkg-config name and installed version (major.minor only) -- for a given module, or throw an exception if that fails. tryPkgConfig :: GIRInfo -> Bool -> Map Text Text -> IO (Either Text PkgInfo) instance GHC.Show.Show Data.GI.CodeGen.Cabal.PkgInfo