xcb-types-0.7.1: Parses XML files used by the XCB project

Copyright | (c) Antoine Latter 2008
License | BSD3
Maintainer | Antoine Latter <aslatter@gmail.com>
Stability | provisional
Portability | portable
Safe Haskell | Safe
Language | Haskell98

Data.XCB.Types

Description

Defines types inteneded to be equivalent to the schema used by the XCB project in their XML protocol description.

Synopsis

- type XHeader = GenXHeader Type
- type XDecl = GenXDecl Type
- type StructElem = GenStructElem Type
- type XEnumElem = EnumElem Type
- type BitCase = GenBitCase Type
- type XidUnionElem = GenXidUnionElem Type
- type XReply = GenXReply Type
- type XExpression = Expression Type
- data GenXHeader typ = XHeader {
  - xheader_header :: Name
  - xheader_xname :: Maybe Name
  - xheader_name :: Maybe Name
  - xheader_multiword :: Maybe Bool
  - xheader_major_version :: Maybe Int
  - xheader_minor_version :: Maybe Int
  - xheader_decls :: [GenXDecl typ]
  }
- data GenXDecl typ
  - = XStruct Name [GenStructElem typ]
  - | XTypeDef Name typ
  - | XEvent Name Int [GenStructElem typ] (Maybe Bool)
  - | XRequest Name Int [GenStructElem typ] (Maybe (GenXReply typ))
  - | XidType Name
  - | XidUnion Name [GenXidUnionElem typ]
  - | XEnum Name [EnumElem typ]
  - | XUnion Name [GenStructElem typ]
  - | XImport Name
  - | XError Name Int [GenStructElem typ]
- data GenStructElem typ
  - = Pad Int
  - | List Name typ (Maybe (Expression typ)) (Maybe (EnumVals typ))
  - | SField Name typ (Maybe (EnumVals typ)) (Maybe (MaskVals typ))
  - | ExprField Name typ (Expression typ)
  - | ValueParam typ Name (Maybe MaskPadding) ListName
  - | Switch Name (Expression typ) [GenBitCase typ]
  - | Doc (Maybe String) (Map Name String) [(String, String)]
  - | Fd String
- data GenBitCase typ = BitCase (Maybe Name) (Expression typ) [GenStructElem typ]
- type GenXReply typ = [GenStructElem typ]
- data GenXidUnionElem typ = XidUnionElem typ
- data EnumElem typ = EnumElem Name (Maybe (Expression typ))
- data Expression typ
  - = Value Int
  - | Bit Int
  - | FieldRef Name
  - | EnumRef typ Name
  - | PopCount (Expression typ)
  - | SumOf Name
  - | Op Binop (Expression typ) (Expression typ)
  - | Unop Unop (Expression typ)
- data Binop
  - = Add
  - | Sub
  - | Mult
  - | Div
  - | And
  - | RShift
- data Unop = Complement
- data Type
  - = UnQualType Name
  - | QualType Name Name
- type EnumVals typ = typ
- type MaskVals typ = typ
- type Name = String
- type Ref = String
- type MaskName = Name
- type ListName = Name
- type MaskPadding = Int

# Documentation

type XHeader = GenXHeader Type #

type XDecl = GenXDecl Type #

type StructElem = GenStructElem Type #

type XEnumElem = EnumElem Type #

type BitCase = GenBitCase Type #

type XidUnionElem = GenXidUnionElem Type #

type XReply = GenXReply Type #

type XExpression = Expression Type #

data GenXHeader typ #

This is what a single XML file maps to. It contains some meta-data then declarations.

Constructors

XHeader |
Fields xheader_header :: Name Name of module. Used in the other modules as a reference. xheader_xname :: Maybe Name Name used to indentify extensions between the X client and server. xheader_name :: Maybe Name InterCaps name. xheader_multiword :: Maybe Bool xheader_major_version :: Maybe Int xheader_minor_version :: Maybe Int xheader_decls :: [GenXDecl typ] Declarations contained in this module.

Instances

Functor GenXHeader # |
Methods fmap :: (a -> b) -> GenXHeader a -> GenXHeader b # (<$) :: a -> GenXHeader b -> GenXHeader a #
Show typ => Show (GenXHeader typ) # |
Methods showsPrec :: Int -> GenXHeader typ -> ShowS # show :: GenXHeader typ -> String # showList :: [GenXHeader typ] -> ShowS #
Pretty a => Pretty (GenXHeader a) # |
Methods toDoc :: GenXHeader a -> Doc # pretty :: GenXHeader a -> String #

data GenXDecl typ #

The different types of declarations which can be made in one of the XML files.

Constructors

XStruct Name [GenStructElem typ] |
XTypeDef Name typ |
XEvent Name Int [GenStructElem typ] (Maybe Bool) | The boolean indicates if the event includes a sequence number.
XRequest Name Int [GenStructElem typ] (Maybe (GenXReply typ)) |
XidType Name |
XidUnion Name [GenXidUnionElem typ] |
XEnum Name [EnumElem typ] |
XUnion Name [GenStructElem typ] |
XImport Name |
XError Name Int [GenStructElem typ] |

Instances

Functor GenXDecl # |
Methods fmap :: (a -> b) -> GenXDecl a -> GenXDecl b # (<$) :: a -> GenXDecl b -> GenXDecl a #
Show typ => Show (GenXDecl typ) # |
Methods showsPrec :: Int -> GenXDecl typ -> ShowS # show :: GenXDecl typ -> String # showList :: [GenXDecl typ] -> ShowS #
Pretty a => Pretty (GenXDecl a) # |
Methods toDoc :: GenXDecl a -> Doc # pretty :: GenXDecl a -> String #

data GenStructElem typ #

Constructors

Pad Int |
List Name typ (Maybe (Expression typ)) (Maybe (EnumVals typ)) |
SField Name typ (Maybe (EnumVals typ)) (Maybe (MaskVals typ)) |
ExprField Name typ (Expression typ) |
ValueParam typ Name (Maybe MaskPadding) ListName |
Switch Name (Expression typ) [GenBitCase typ] |
Doc (Maybe String) (Map Name String) [(String, String)] |
Fd String |

Instances

Functor GenStructElem # |
Methods fmap :: (a -> b) -> GenStructElem a -> GenStructElem b # (<$) :: a -> GenStructElem b -> GenStructElem a #
Show typ => Show (GenStructElem typ) # |
Methods showsPrec :: Int -> GenStructElem typ -> ShowS # show :: GenStructElem typ -> String # showList :: [GenStructElem typ] -> ShowS #
Pretty a => Pretty (GenStructElem a) # |
Methods toDoc :: GenStructElem a -> Doc # pretty :: GenStructElem a -> String #

data GenBitCase typ #

Constructors

BitCase (Maybe Name) (Expression typ) [GenStructElem typ] |

Instances

Functor GenBitCase # |
Methods fmap :: (a -> b) -> GenBitCase a -> GenBitCase b # (<$) :: a -> GenBitCase b -> GenBitCase a #
Show typ => Show (GenBitCase typ) # |
Methods showsPrec :: Int -> GenBitCase typ -> ShowS # show :: GenBitCase typ -> String # showList :: [GenBitCase typ] -> ShowS #
Pretty a => Pretty (GenBitCase a) # |
Methods toDoc :: GenBitCase a -> Doc # pretty :: GenBitCase a -> String #

type GenXReply typ = [GenStructElem typ] #

data GenXidUnionElem typ #

Constructors

XidUnionElem typ |

Instances

Functor GenXidUnionElem # |
Methods fmap :: (a -> b) -> GenXidUnionElem a -> GenXidUnionElem b # (<$) :: a -> GenXidUnionElem b -> GenXidUnionElem a #
Show typ => Show (GenXidUnionElem typ) # |
Methods showsPrec :: Int -> GenXidUnionElem typ -> ShowS # show :: GenXidUnionElem typ -> String # showList :: [GenXidUnionElem typ] -> ShowS #
Pretty a => Pretty (GenXidUnionElem a) # |
Methods toDoc :: GenXidUnionElem a -> Doc # pretty :: GenXidUnionElem a -> String #

data EnumElem typ #

Constructors

EnumElem Name (Maybe (Expression typ)) |

Instances

Functor EnumElem # |
Methods fmap :: (a -> b) -> EnumElem a -> EnumElem b # (<$) :: a -> EnumElem b -> EnumElem a #
Show typ => Show (EnumElem typ) # |
Methods showsPrec :: Int -> EnumElem typ -> ShowS # show :: EnumElem typ -> String # showList :: [EnumElem typ] -> ShowS #
Pretty a => Pretty (EnumElem a) # |
Methods toDoc :: EnumElem a -> Doc # pretty :: EnumElem a -> String #

data Expression typ #

Declarations may contain expressions from this small language

Constructors

Value Int | A literal value
Bit Int | A log-base-2 literal value
FieldRef Name | A reference to a field in the same declaration
EnumRef typ Name | A reference to a member of an enum.
PopCount (Expression typ) | Calculate the number of set bits in the argument
SumOf Name | Note sure. The argument should be a reference to a list
Op Binop (Expression typ) (Expression typ) | A binary opeation
Unop Unop (Expression typ) | A unary operation

Instances

Functor Expression # |
Methods fmap :: (a -> b) -> Expression a -> Expression b # (<$) :: a -> Expression b -> Expression a #
Show typ => Show (Expression typ) # |
Methods showsPrec :: Int -> Expression typ -> ShowS # show :: Expression typ -> String # showList :: [Expression typ] -> ShowS #
Pretty a => Pretty (Expression a) # |
Methods toDoc :: Expression a -> Doc # pretty :: Expression a -> String #

data Binop #

Supported Binary operations.

Constructors

Add |
Sub |
Mult |
Div |
And |
RShift |

Instances

Show Binop # |
Methods showsPrec :: Int -> Binop -> ShowS # show :: Binop -> String # showList :: [Binop] -> ShowS #
Pretty Binop # |
Methods toDoc :: Binop -> Doc # pretty :: Binop -> String #

data Unop #

Constructors

Complement |

Instances

Show Unop # |
Methods showsPrec :: Int -> Unop -> ShowS # show :: Unop -> String # showList :: [Unop] -> ShowS #
Pretty Unop # |
Methods toDoc :: Unop -> Doc # pretty :: Unop -> String #

data Type #

Types may include a reference to the containing module.

Constructors

UnQualType Name |
QualType Name Name |

Instances

Eq Type # |
Methods (==) :: Type -> Type -> Bool # (/=) :: Type -> Type -> Bool #
Ord Type # |
Methods compare :: Type -> Type -> Ordering # (<) :: Type -> Type -> Bool # (<=) :: Type -> Type -> Bool # (>) :: Type -> Type -> Bool # (>=) :: Type -> Type -> Bool # max :: Type -> Type -> Type # min :: Type -> Type -> Type #
Show Type # |
Methods showsPrec :: Int -> Type -> ShowS # show :: Type -> String # showList :: [Type] -> ShowS #
Pretty Type # |
Methods toDoc :: Type -> Doc # pretty :: Type -> String #

type EnumVals typ = typ #

type MaskVals typ = typ #

type Name = String #

type Ref = String #

type MaskName = Name #

type ListName = Name #

type MaskPadding = Int #