-- 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.20 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 :: Text -> a -- | 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 -- | 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.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)) -- | 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 -- | 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 namespace where it lives and the type init -- function. girLoadGType :: Text -> Text -> IO GType instance Data.GI.Base.BasicTypes.BoxedObject Data.GI.CodeGen.LibGIRepository.BaseInfo module Data.GI.CodeGen.GType data GType :: * gtypeIsA :: GType -> GType -> Bool gtypeIsBoxed :: GType -> Bool -- | 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 -- | 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 module Data.GI.GIR.Repository -- | Try to load the `.gir` file corresponding to the given repository readGiRepository :: Bool -> Text -> Maybe Text -> [FilePath] -> IO Document -- | Parsing of documentation nodes. module Data.GI.GIR.Documentation -- | Documentation for a given element. data Documentation Documentation :: Text -> Documentation [docText] :: Documentation -> Text -- | Parse the documentation node for the given element of the GIR file. queryDocumentation :: Element -> Maybe 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 -- | Encode the given DeprecationInfo for the given symbol as a -- deprecation pragma. deprecatedPragma :: Text -> Maybe DeprecationInfo -> 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 -- | 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 -- | 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 -- | 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.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 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.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.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.Name instance GHC.Classes.Ord Data.GI.GIR.BasicTypes.Name instance GHC.Classes.Eq Data.GI.GIR.BasicTypes.Name -- | 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 -- | 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 text, if present. parseDocumentation :: Parser (Maybe 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 -- | Deprecation information on a symbol. data DeprecationInfo -- | Documentation for a given element. data Documentation instance GHC.Show.Show Data.GI.GIR.Parser.ParseContext -- | Parsing of Enums. module Data.GI.GIR.Enum data Enumeration Enumeration :: [(Text, Int64)] -> Maybe Text -> Maybe Text -> Int -> Maybe DeprecationInfo -> Enumeration [enumValues] :: Enumeration -> [(Text, Int64)] [errorDomain] :: Enumeration -> Maybe Text [enumTypeInit] :: Enumeration -> Maybe Text -- | Bytes used for storage of this struct. [enumStorageBytes] :: Enumeration -> Int [enumDeprecated] :: Enumeration -> Maybe DeprecationInfo -- | Parse an "enumeration" element from the GIR file. parseEnum :: Parser (Name, Enumeration) 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 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 -- | Parse the C-type associated to the element. If there is no "c:type" -- attribute we return the type name. parseCType :: Parser Text -- | Like parseType, but allow for none, returned as -- Nothing. parseOptionalType :: Parser (Maybe Type) -- | Parsing of constants in GIR files. module Data.GI.GIR.Constant -- | Info about a constant. data Constant Constant :: Type -> Text -> Maybe DeprecationInfo -> Constant [constantType] :: Constant -> Type [constantValue] :: Constant -> Text [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 -- | Type constructors. 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 -- | 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 -- | 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 -- | Embed in the IO monad. io :: TypeRep -> TypeRep -- | A Ptr to the type. ptr :: TypeRep -> TypeRep -- | A FunPtr to the type. funptr :: TypeRep -> TypeRep -- | Type constructor applied to the given types. con :: Text -> [TypeRep] -> TypeRep -- | Embed in the Maybe monad. maybeT :: TypeRep -> TypeRep module Data.GI.GIR.Arg data Arg Arg :: Text -> Type -> Direction -> Bool -> 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 [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.Arg instance GHC.Classes.Eq Data.GI.GIR.Arg.Arg instance GHC.Show.Show Data.GI.GIR.Arg.Arg 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.Direction instance GHC.Classes.Eq Data.GI.GIR.Arg.Direction instance GHC.Show.Show Data.GI.GIR.Arg.Direction module Data.GI.GIR.Callable data Callable Callable :: Maybe Type -> Bool -> Transfer -> [Arg] -> Bool -> Maybe DeprecationInfo -> Callable [returnType] :: Callable -> Maybe Type [returnMayBeNull] :: Callable -> Bool [returnTransfer] :: Callable -> Transfer [args] :: Callable -> [Arg] [skipReturn] :: Callable -> Bool [callableDeprecated] :: Callable -> Maybe DeprecationInfo parseCallable :: Parser Callable instance GHC.Classes.Eq Data.GI.GIR.Callable.Callable instance GHC.Show.Show Data.GI.GIR.Callable.Callable -- | Parsing of callbacks. module Data.GI.GIR.Callback data Callback Callback :: Callable -> Callback 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 -> Bool -> Maybe Callback -> Int -> [FieldInfoFlag] -> Maybe DeprecationInfo -> Field [fieldName] :: Field -> Text [fieldVisible] :: Field -> Bool [fieldType] :: Field -> Type [fieldIsPointer] :: Field -> Bool [fieldCallback] :: Field -> Maybe Callback [fieldOffset] :: Field -> Int [fieldFlags] :: Field -> [FieldInfoFlag] [fieldDeprecated] :: Field -> Maybe DeprecationInfo data FieldInfoFlag parseFields :: Parser [Field] instance GHC.Show.Show Data.GI.GIR.Field.Field instance GHC.Show.Show Data.GI.GIR.Field.FieldInfoFlag module Data.GI.GIR.Function data Function Function :: Text -> Bool -> Maybe Text -> Callable -> Function [fnSymbol] :: Function -> Text [fnThrows] :: Function -> Bool [fnMovedTo] :: Function -> Maybe Text [fnCallable] :: Function -> Callable parseFunction :: Parser (Name, Function) instance GHC.Show.Show Data.GI.GIR.Function.Function module Data.GI.GIR.Signal data Signal Signal :: Text -> Callable -> Maybe DeprecationInfo -> Signal [sigName] :: Signal -> Text [sigCallable] :: Signal -> Callable [sigDeprecated] :: Signal -> Maybe DeprecationInfo 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 -> Bool -> MethodType -> Maybe Text -> Callable -> Method [methodName] :: Method -> Name [methodSymbol] :: Method -> Text [methodThrows] :: Method -> Bool [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.Method instance GHC.Classes.Eq Data.GI.GIR.Method.Method instance GHC.Show.Show Data.GI.GIR.Method.MethodType instance GHC.Classes.Eq Data.GI.GIR.Method.MethodType module Data.GI.GIR.Property data Property Property :: Text -> Type -> [PropertyFlag] -> Maybe Bool -> Maybe Bool -> Transfer -> Maybe DeprecationInfo -> Property [propName] :: Property -> Text [propType] :: Property -> Type [propFlags] :: Property -> [PropertyFlag] [propReadNullable] :: Property -> Maybe Bool [propWriteNullable] :: Property -> Maybe Bool [propTransfer] :: Property -> Transfer [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.Property instance GHC.Show.Show Data.GI.GIR.Property.Property instance GHC.Classes.Eq Data.GI.GIR.Property.PropertyFlag instance GHC.Show.Show Data.GI.GIR.Property.PropertyFlag module Data.GI.GIR.Interface data Interface Interface :: Maybe Text -> [Name] -> [Property] -> [Signal] -> [Method] -> Maybe DeprecationInfo -> Interface [ifTypeInit] :: Interface -> Maybe Text [ifPrerequisites] :: Interface -> [Name] [ifProperties] :: Interface -> [Property] [ifSignals] :: Interface -> [Signal] [ifMethods] :: Interface -> [Method] [ifDeprecated] :: Interface -> Maybe DeprecationInfo parseInterface :: Parser (Name, Interface) instance GHC.Show.Show Data.GI.GIR.Interface.Interface -- | Parsing of objects. module Data.GI.GIR.Object data Object Object :: Maybe Name -> Text -> Text -> [Name] -> Maybe DeprecationInfo -> Maybe Documentation -> [Method] -> [Property] -> [Signal] -> Object [objParent] :: Object -> Maybe Name [objTypeInit] :: Object -> Text [objTypeName] :: Object -> Text [objInterfaces] :: Object -> [Name] [objDeprecated] :: Object -> Maybe DeprecationInfo [objDocumentation] :: Object -> Maybe Documentation [objMethods] :: Object -> [Method] [objProperties] :: Object -> [Property] [objSignals] :: Object -> [Signal] parseObject :: Parser (Name, Object) instance GHC.Show.Show Data.GI.GIR.Object.Object -- | 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.Show.Show Data.GI.GIR.Allocation.AllocationInfo instance GHC.Classes.Eq Data.GI.GIR.Allocation.AllocationOp instance GHC.Show.Show Data.GI.GIR.Allocation.AllocationOp -- | Parsing of structs. module Data.GI.GIR.Struct data Struct Struct :: Bool -> AllocationInfo -> Maybe Text -> Int -> Maybe Name -> Bool -> [Field] -> [Method] -> Maybe DeprecationInfo -> Maybe Documentation -> Struct [structIsBoxed] :: Struct -> Bool [structAllocationInfo] :: Struct -> AllocationInfo [structTypeInit] :: Struct -> Maybe Text [structSize] :: Struct -> Int [gtypeStructFor] :: Struct -> Maybe Name [structIsDisguised] :: Struct -> Bool [structFields] :: Struct -> [Field] [structMethods] :: Struct -> [Method] [structDeprecated] :: Struct -> Maybe DeprecationInfo [structDocumentation] :: Struct -> Maybe Documentation parseStruct :: Parser (Name, Struct) instance GHC.Show.Show Data.GI.GIR.Struct.Struct -- | Parsing of unions. module Data.GI.GIR.Union data Union Union :: Bool -> AllocationInfo -> Int -> Maybe Text -> [Field] -> [Method] -> Maybe DeprecationInfo -> Union [unionIsBoxed] :: Union -> Bool [unionAllocationInfo] :: Union -> AllocationInfo [unionSize] :: Union -> Int [unionTypeInit] :: Union -> Maybe Text [unionFields] :: Union -> [Field] [unionMethods] :: Union -> [Method] [unionDeprecated] :: Union -> Maybe DeprecationInfo parseUnion :: Parser (Name, Union) instance GHC.Show.Show Data.GI.GIR.Union.Union module Data.GI.GIR.Alias -- | Find all aliases in a given document. documentListAliases :: Document -> Map Alias Type module Data.GI.CodeGen.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 -- | 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 -- | Encode the given DeprecationInfo for the given symbol as a -- deprecation pragma. deprecatedPragma :: Text -> Maybe DeprecationInfo -> Text -- | Deprecation information on a symbol. data DeprecationInfo 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 -> Maybe DeprecationInfo -> Constant [constantType] :: Constant -> Type [constantValue] :: Constant -> Text [constantDeprecated] :: Constant -> Maybe DeprecationInfo data Arg Arg :: Text -> Type -> Direction -> Bool -> 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 [argScope] :: Arg -> Scope [argClosure] :: Arg -> Int [argDestroy] :: Arg -> Int [argCallerAllocates] :: Arg -> Bool [transfer] :: Arg -> Transfer data Callable Callable :: Maybe Type -> Bool -> Transfer -> [Arg] -> Bool -> Maybe DeprecationInfo -> Callable [returnType] :: Callable -> Maybe Type [returnMayBeNull] :: Callable -> Bool [returnTransfer] :: Callable -> Transfer [args] :: Callable -> [Arg] [skipReturn] :: Callable -> Bool [callableDeprecated] :: Callable -> Maybe DeprecationInfo data Function Function :: Text -> Bool -> Maybe Text -> Callable -> Function [fnSymbol] :: Function -> Text [fnThrows] :: Function -> Bool [fnMovedTo] :: Function -> Maybe Text [fnCallable] :: Function -> Callable data Signal Signal :: Text -> Callable -> Maybe DeprecationInfo -> Signal [sigName] :: Signal -> Text [sigCallable] :: Signal -> Callable [sigDeprecated] :: Signal -> Maybe DeprecationInfo data Property Property :: Text -> Type -> [PropertyFlag] -> Maybe Bool -> Maybe Bool -> Transfer -> Maybe DeprecationInfo -> Property [propName] :: Property -> Text [propType] :: Property -> Type [propFlags] :: Property -> [PropertyFlag] [propReadNullable] :: Property -> Maybe Bool [propWriteNullable] :: Property -> Maybe Bool [propTransfer] :: Property -> Transfer [propDeprecated] :: Property -> Maybe DeprecationInfo data Field Field :: Text -> Bool -> Type -> Bool -> Maybe Callback -> Int -> [FieldInfoFlag] -> Maybe DeprecationInfo -> Field [fieldName] :: Field -> Text [fieldVisible] :: Field -> Bool [fieldType] :: Field -> Type [fieldIsPointer] :: Field -> Bool [fieldCallback] :: Field -> Maybe Callback [fieldOffset] :: Field -> Int [fieldFlags] :: Field -> [FieldInfoFlag] [fieldDeprecated] :: Field -> Maybe DeprecationInfo data Struct Struct :: Bool -> AllocationInfo -> Maybe Text -> Int -> Maybe Name -> Bool -> [Field] -> [Method] -> Maybe DeprecationInfo -> Maybe Documentation -> Struct [structIsBoxed] :: Struct -> Bool [structAllocationInfo] :: Struct -> AllocationInfo [structTypeInit] :: Struct -> Maybe Text [structSize] :: Struct -> Int [gtypeStructFor] :: Struct -> Maybe Name [structIsDisguised] :: Struct -> Bool [structFields] :: Struct -> [Field] [structMethods] :: Struct -> [Method] [structDeprecated] :: Struct -> Maybe DeprecationInfo [structDocumentation] :: Struct -> Maybe Documentation data Callback Callback :: Callable -> Callback data Interface Interface :: Maybe Text -> [Name] -> [Property] -> [Signal] -> [Method] -> Maybe DeprecationInfo -> Interface [ifTypeInit] :: Interface -> Maybe Text [ifPrerequisites] :: Interface -> [Name] [ifProperties] :: Interface -> [Property] [ifSignals] :: Interface -> [Signal] [ifMethods] :: Interface -> [Method] [ifDeprecated] :: Interface -> Maybe DeprecationInfo data Method Method :: Name -> Text -> Bool -> MethodType -> Maybe Text -> Callable -> Method [methodName] :: Method -> Name [methodSymbol] :: Method -> Text [methodThrows] :: Method -> Bool [methodType] :: Method -> MethodType [methodMovedTo] :: Method -> Maybe Text [methodCallable] :: Method -> Callable data Object Object :: Maybe Name -> Text -> Text -> [Name] -> Maybe DeprecationInfo -> Maybe Documentation -> [Method] -> [Property] -> [Signal] -> Object [objParent] :: Object -> Maybe Name [objTypeInit] :: Object -> Text [objTypeName] :: Object -> Text [objInterfaces] :: Object -> [Name] [objDeprecated] :: Object -> Maybe DeprecationInfo [objDocumentation] :: Object -> Maybe Documentation [objMethods] :: Object -> [Method] [objProperties] :: Object -> [Property] [objSignals] :: Object -> [Signal] data Enumeration Enumeration :: [(Text, Int64)] -> Maybe Text -> Maybe Text -> Int -> Maybe DeprecationInfo -> Enumeration [enumValues] :: Enumeration -> [(Text, Int64)] [errorDomain] :: Enumeration -> Maybe Text [enumTypeInit] :: Enumeration -> Maybe 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 -> Int -> Maybe Text -> [Field] -> [Method] -> Maybe DeprecationInfo -> Union [unionIsBoxed] :: Union -> Bool [unionAllocationInfo] :: Union -> AllocationInfo [unionSize] :: Union -> Int [unionTypeInit] :: Union -> Maybe Text [unionFields] :: Union -> [Field] [unionMethods] :: Union -> [Method] [unionDeprecated] :: Union -> Maybe DeprecationInfo instance GHC.Show.Show Data.GI.CodeGen.API.GIRInfo instance GHC.Show.Show Data.GI.CodeGen.API.GIRInfoParse instance GHC.Show.Show Data.GI.CodeGen.API.GIRNamespace instance GHC.Show.Show Data.GI.CodeGen.API.API instance GHC.Show.Show Data.GI.CodeGen.API.GIRRule instance GHC.Show.Show Data.GI.CodeGen.API.GIRNodeSpec instance GHC.Show.Show Data.GI.CodeGen.API.GIRNameTag -- | 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) module Data.GI.CodeGen.Overrides data Overrides -- | Parse the given config file (as a set of lines) for a given -- introspection namespace, filling in the configuration as needed. In -- case the parsing fails we return a description of the error instead. parseOverridesFile :: [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.OSType instance GHC.Show.Show Data.GI.CodeGen.Overrides.ParserState instance GHC.Show.Show Data.GI.CodeGen.Overrides.Overrides instance GHC.Base.Monoid Data.GI.CodeGen.Overrides.Overrides -- | Configuration for the code generator. module Data.GI.CodeGen.Config data Config Config :: Maybe Text -> Bool -> Overrides -> CodeGenFlags -> Config -- | Name of the module being generated. [modName] :: Config -> Maybe Text -- | Whether to print extra info. [verbose] :: Config -> Bool -- | List of loaded overrides for the code generator. [overrides] :: Config -> Overrides -- | List of flags for the code generator. [cgFlags] :: Config -> CodeGenFlags -- | Flags controlling different aspects of the code generator. data CodeGenFlags CodeGenFlags :: Bool -> Bool -> Bool -> CodeGenFlags -- | Whether to generate overloaded properties. [cgOverloadedProperties] :: CodeGenFlags -> Bool -- | Whether to generate support for overloaded signals. [cgOverloadedSignals] :: CodeGenFlags -> Bool -- | Whether to generate support for overloaded methods. [cgOverloadedMethods] :: CodeGenFlags -> Bool instance GHC.Show.Show Data.GI.CodeGen.Config.Config instance GHC.Show.Show Data.GI.CodeGen.Config.CodeGenFlags module Data.GI.CodeGen.Code data Code -- | No code NoCode :: Code -- | A single line, indented to current indentation Line :: Text -> Code -- | Indented region Indent :: Code -> Code -- | The basic sequence of code Sequence :: (Seq Code) -> Code -- | A grouped set of lines Group :: Code -> Code -- | Information on a generated module. data ModuleInfo ModuleInfo :: ModuleName -> Code -> Code -> Map Text ModuleInfo -> Deps -> Seq Export -> Set ModuleName -> Set Text -> Set Text -> Set ModuleFlag -> Maybe Text -> BaseVersion -> ModuleInfo -- | Full module name: [GI, Gtk, Label]. [moduleName] :: ModuleInfo -> ModuleName -- | Generated code for the module. [moduleCode] :: ModuleInfo -> Code -- | Interface going into the .hs-boot file. [bootCode] :: ModuleInfo -> Code -- | Indexed by the relative module name. [submodules] :: ModuleInfo -> Map Text ModuleInfo -- | Set of dependencies for this module. [moduleDeps] :: ModuleInfo -> Deps -- | Exports for the module. [moduleExports] :: ModuleInfo -> Seq Export -- | Qualified (source) imports [qualifiedImports] :: ModuleInfo -> Set ModuleName -- | Set of language pragmas for the module. [modulePragmas] :: ModuleInfo -> Set Text -- | GHC options for compiling the module. [moduleGHCOpts] :: ModuleInfo -> Set Text -- | Flags for the module. [moduleFlags] :: ModuleInfo -> Set ModuleFlag -- | Documentation for the module. [moduleDoc] :: ModuleInfo -> Maybe Text -- | Minimal version of base the module will work on. [moduleMinBase] :: ModuleInfo -> BaseVersion -- | Flags for module code generation. data ModuleFlag -- | Use the standard prelude, instead of the haskell-gi-base short one. ImplicitPrelude :: ModuleFlag type BaseCodeGen excType a = ReaderT CodeGenConfig (StateT ModuleInfo (ExceptT excType IO)) a -- | The code generator monad, for generators that cannot throw errors. The -- fact that they cannot throw errors is encoded in the forall, which -- disallows any operation on the error, except discarding it or passing -- it along without inspecting. This last operation is useful in order to -- allow embedding CodeGen computations inside ExcCodeGen -- computations, while disallowing the opposite embedding without -- explicit error handling. type CodeGen a = forall e. BaseCodeGen e a -- | Code generators that can throw errors. type ExcCodeGen a = BaseCodeGen CGError a data CGError CGErrorNotImplemented :: Text -> CGError CGErrorBadIntrospectionInfo :: Text -> CGError CGErrorMissingInfo :: Text -> CGError -- | Like evalCodeGen, but discard the resulting output value. genCode :: Config -> Map Name API -> ModuleName -> CodeGen () -> IO 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 -> ModuleName -> CodeGen a -> IO (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 type ModuleName = [Text] -- | Mark the given dependency as used by the module. registerNSDependency :: Text -> CodeGen () -- | Given a module name and a symbol in the module (including a proper -- namespace), return a qualified name for the symbol. qualified :: ModuleName -> Name -> CodeGen Text -- | Return the currently loaded set of dependencies. getDeps :: CodeGen Deps -- | Like recurse, giving explicitly the set of loaded APIs for -- the subgenerator. recurseWithAPIs :: Map Name API -> CodeGen () -> CodeGen () -- | Try running the given action, and if it fails run -- fallback instead. handleCGExc :: (CGError -> CodeGen a) -> ExcCodeGen a -> CodeGen a -- | Give a friendly textual description of the error for presenting to the -- user. describeCGError :: CGError -> Text notImplementedError :: Text -> ExcCodeGen a badIntroError :: Text -> ExcCodeGen a missingInfoError :: Text -> ExcCodeGen a -- | Increase the indent level for code generation. indent :: BaseCodeGen e a -> BaseCodeGen e a -- | Print out the given line both to the normal module, and to the HsBoot -- file. bline :: Text -> CodeGen () -- | Print out a (newline-terminated) line. line :: Text -> CodeGen () -- | A blank line blank :: CodeGen () -- | Group a set of related code. group :: BaseCodeGen e a -> BaseCodeGen e a -- | Write the given code into the .hs-boot file for the current module. hsBoot :: BaseCodeGen e a -> BaseCodeGen e a -- | Run the given CodeGen in order to generate a submodule (specified an -- an ordered list) of the current module. submodule :: [Text] -> BaseCodeGen e () -> BaseCodeGen e () -- | Set the language pragmas for the current module. setLanguagePragmas :: [Text] -> CodeGen () -- | Set the GHC options for compiling this module (in a OPTIONS_GHC -- pragma). setGHCOptions :: [Text] -> CodeGen () -- | Set the given flags for the module. setModuleFlags :: [ModuleFlag] -> CodeGen () -- | Set the minimum base version supported by the current module. setModuleMinBase :: BaseVersion -> CodeGen () -- | Add the given text to the module-level documentation for the module -- being generated. addModuleDocumentation :: Maybe Documentation -> CodeGen () -- | Export a toplevel (i.e. belonging to no section) symbol. exportToplevel :: SymbolName -> CodeGen () -- | Reexport a whole module. exportModule :: SymbolName -> CodeGen () -- | Add a type declaration-related export. exportDecl :: SymbolName -> CodeGen () -- | Add a method export under the given section. exportMethod :: HaddockSection -> SymbolName -> CodeGen () -- | Add a property-related export under the given section. exportProperty :: HaddockSection -> SymbolName -> CodeGen () -- | Add a signal-related export under the given section. exportSignal :: HaddockSection -> SymbolName -> CodeGen () findAPI :: Type -> CodeGen (Maybe API) -- | Find the API associated with a given type. If the API cannot be found -- this raises an error. getAPI :: Type -> CodeGen API findAPIByName :: Name -> CodeGen API -- | Return the list of APIs available to the generator. getAPIs :: CodeGen (Map Name API) -- | Return the ambient configuration for the code generator. config :: CodeGen Config -- | Return the name of the current module. currentModule :: CodeGen Text instance GHC.Show.Show Data.GI.CodeGen.Code.CGError 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.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.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.ExportType instance GHC.Classes.Eq Data.GI.CodeGen.Code.ExportType instance GHC.Show.Show Data.GI.CodeGen.Code.ExportType 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 module Data.GI.CodeGen.Cabal -- | Try to generate the cabal project. In case of error return the -- corresponding error string. genCabalProject :: GIRInfo -> [GIRInfo] -> [Text] -> BaseVersion -> CodeGen (Maybe Text) cabalConfig :: Text setupHs :: Text module Data.GI.CodeGen.GObject isGObject :: Type -> CodeGen Bool apiIsGObject :: Name -> API -> CodeGen Bool -- | Check whether the given name descends from GObject. nameIsGObject :: Name -> CodeGen Bool isInitiallyUnowned :: Type -> CodeGen Bool apiIsInitiallyUnowned :: Name -> API -> CodeGen Bool module Data.GI.CodeGen.Inheritance -- | List all properties defined for an object, including those defined by -- its ancestors. fullObjectPropertyList :: Name -> Object -> CodeGen [(Name, Property)] -- | List all properties defined for an interface, including those defined -- by its prerequisites. fullInterfacePropertyList :: Name -> Interface -> CodeGen [(Name, Property)] -- | List all signals defined for an object, including those defined by its -- ancestors. fullObjectSignalList :: Name -> Object -> CodeGen [(Name, Signal)] -- | List all signals defined for an interface, including those defined by -- its prerequisites. fullInterfaceSignalList :: Name -> Interface -> CodeGen [(Name, Signal)] -- | List all methods defined for an object, including those defined by its -- ancestors. fullObjectMethodList :: Name -> Object -> CodeGen [(Name, Method)] -- | List all methods defined for an interface, including those defined by -- its prerequisites. fullInterfaceMethodList :: Name -> Interface -> CodeGen [(Name, Method)] -- | Compute the (ordered) list of parents of the current object. instanceTree :: Name -> CodeGen [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 module Data.GI.CodeGen.SymbolNaming lowerName :: Name -> Text upperName :: Name -> Text -- | Save a bit of typing for optional arguments in the case that we want -- to pass Nothing. noName :: Text -> CodeGen () -- | 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 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 Text -- | For a string of the form "one-sample-string" return -- OneSampleString hyphensToCamelCase :: Text -> Text -- | Similarly, 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. 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 -- | Construct the submodule name (as a list, to be joined by intercalating -- ".") 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 -> ModuleName -- | Return an identifier for the given interface type valid in the current -- module. qualifiedAPI :: Name -> CodeGen Text -- | Construct an identifier for the given symbol in the given API. qualifiedSymbol :: Text -> Name -> CodeGen Text module Data.GI.CodeGen.Conversions convert :: Text -> BaseCodeGen e Converter -> BaseCodeGen e Text genConversion :: Text -> Converter -> CodeGen Text unpackCArray :: Text -> Type -> Transfer -> ExcCodeGen Converter 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 haskellType :: Type -> CodeGen 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. isoHaskellType :: Type -> CodeGen TypeRep foreignType :: Type -> CodeGen TypeRep argumentType :: [Char] -> Type -> CodeGen ([Char], Text, [Text]) elementType :: Type -> Maybe Type elementMap :: Type -> Text -> Maybe Text 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 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 Bool -- | Returns whether the given type is represented by a pointer on the C -- side. typeIsPtr :: Type -> CodeGen 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 (Maybe Text) -- | An appropriate NULL value for the given type, for types which are -- represented by pointers on the C side. nullPtrForType :: Type -> CodeGen (Maybe Text) getIsScalar :: Type -> CodeGen Bool -- | Information on how to allocate the given type, if known. typeAllocInfo :: Type -> CodeGen (Maybe TypeAllocInfo) -- | Information on how to allocate a type. data TypeAllocInfo TypeAllocInfo :: Bool -> Int -> TypeAllocInfo [typeAllocInfoIsBoxed] :: TypeAllocInfo -> Bool -- | In bytes. [typeAllocInfoSize] :: TypeAllocInfo -> Int apply :: Constructor -> Converter mapC :: Constructor -> Converter literal :: Constructor -> Converter data Constructor P :: Text -> Constructor M :: Text -> Constructor Id :: Constructor 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.Show.Show Data.GI.CodeGen.Conversions.Map instance GHC.Show.Show Data.GI.CodeGen.Conversions.Constructor instance GHC.Classes.Eq 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) instance Data.String.IsString Data.GI.CodeGen.Conversions.Constructor module Data.GI.CodeGen.Constant genConstant :: Name -> Constant -> CodeGen () -- | Support for enums and flags. module Data.GI.CodeGen.EnumFlags genEnum :: Name -> Enumeration -> CodeGen () -- | Very similar to enums, but we also declare ourselves as members of the -- IsGFlag typeclass. genFlags :: Name -> Flags -> CodeGen () module Data.GI.CodeGen.OverloadedLabels genOverloadedLabels :: [(Name, API)] -> CodeGen () module Data.GI.CodeGen.Properties genInterfaceProperties :: Name -> Interface -> CodeGen () genObjectProperties :: Name -> Object -> CodeGen () -- | 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 () -- | Marshalling of structs and unions. module Data.GI.CodeGen.Struct genStructOrUnionFields :: Name -> [Field] -> CodeGen () -- | Specialization for structs of genZeroSU. genZeroStruct :: Name -> Struct -> CodeGen () -- | Specialization for unions of genZeroSU. genZeroUnion :: Name -> Union -> CodeGen () -- | 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 -- | Generate the typeclass with information for how to allocate/deallocate -- unboxed structs and unions. genWrappedPtr :: Name -> AllocationInfo -> Int -> CodeGen () 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 () module Data.GI.CodeGen.Callable -- | Generate a wrapper for a known C symbol. genCCallableWrapper :: Name -> Text -> Callable -> Bool -> 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 -> Bool -> 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 -- | Whether to expose closures and the associated destroy notify handlers -- in the Haskell wrapper. data ExposeClosures WithClosures :: ExposeClosures WithoutClosures :: ExposeClosures hOutType :: Callable -> [Arg] -> Bool -> ExcCodeGen TypeRep arrayLengths :: Callable -> [Arg] arrayLengthsMap :: Callable -> [(Arg, Arg)] -- | The Haskell signature for the given callable. It returns a tuple -- ([constraints], [(type, argname)]). callableSignature :: Callable -> ForeignSymbol -> Bool -> ExcCodeGen ([Text], [(Text, 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 Bool inArgInterfaces :: [Arg] -> ExcCodeGen ([Text], [Text]) module Data.GI.CodeGen.OverloadedMethods -- | Generate the MethodList instance given the list of methods -- for the given named type. genMethodList :: Name -> [(Name, Method)] -> CodeGen () -- | 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 () module Data.GI.CodeGen.Signal genSignal :: Signal -> Name -> ExcCodeGen () genCallback :: Name -> Callback -> CodeGen () -- | Return the name for the signal in Haskell CamelCase conventions. signalHaskellName :: Text -> Text module Data.GI.CodeGen.OverloadedSignals -- | Signal instances for (GObject-derived) objects. genObjectSignals :: Name -> Object -> CodeGen () -- | Signal instances for interfaces. genInterfaceSignals :: Name -> Interface -> CodeGen () -- | Generate the overloaded signal connectors: Clicked, -- ActivateLink, ... genOverloadedSignalConnectors :: [(Name, API)] -> CodeGen () module Data.GI.CodeGen.CodeGen genConstant :: Name -> Constant -> CodeGen () genFunction :: Name -> Function -> CodeGen () genModule :: Map Name API -> CodeGen () -- | Convenience hooks for writing custom Setup.hs files for -- bindings. module Data.GI.CodeGen.CabalHooks -- | The entry point for Setup.hs files in bindings. setupHaskellGIBinding :: Text -> Text -> Bool -> Maybe FilePath -> Maybe FilePath -> IO ()