packages feed

xcffib 1.1.2 → 1.2.0

raw patch · 12 files changed

+48/−22 lines, 12 filesdep ~xcb-typesPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: xcb-types

API changes (from Hackage documentation)

- Data.XCB.Python.PyHelpers: mkXClass :: String -> String -> Suite () -> Suite () -> Statement ()
+ Data.XCB.Python.PyHelpers: mkXClass :: String -> String -> Bool -> Suite () -> Suite () -> Statement ()

Files

generator/Data/XCB/Python/Parse.hs view
@@ -212,7 +212,7 @@ xExpressionToPyExpr acc (FieldRef n) = mkName $ acc n xExpressionToPyExpr _ (EnumRef (UnQualType enum) n) = mkName $ enum ++ "." ++ n -- Currently xcb only uses unqualified types, not sure how qualtype should behave-xExpressionToPyExpr _ (EnumRef (QualType _ _) _) = error "Qualified type, unknown behavior"+xExpressionToPyExpr _ (EnumRef (QualType ext n) _) = mkName $ ext ++ "." ++ n xExpressionToPyExpr acc (PopCount e) =   mkCall "xcffib.popcount" [xExpressionToPyExpr acc e] -- http://cgit.freedesktop.org/xcb/proto/tree/doc/xml-xcb.txt#n290@@ -226,7 +226,10 @@   let o' = xUnopToPyOp o       e' = xExpressionToNestedPyExpr acc e   in Paren (UnaryOp o' e' ()) ()-xExpressionToPyExpr _ (ParamRef n) = mkName n+xExpressionToPyExpr acc (ParamRef n) =+    if n == "num_axes"+    then mkName $ acc n+    else error ("unsupported paramref " ++ n)  getConst :: XExpression -> Maybe Int getConst (Value i) = Just i@@ -321,6 +324,9 @@       cons = case m M.! typ of                BaseType c -> mkStr c                CompositeType tExt c | ext /= tExt -> mkName $ tExt ++ "." ++ c+               CompositeType _ "DeviceTimeCoord" ->+                 let wrapper = mkName "xcffib.__DeviceTimeCoord_wrapper"+                 in mkCall wrapper [mkName "DeviceTimeCoord", mkName (attr "num_axes")]                CompositeType _ c -> mkName c       list = mkCall "xcffib.List" [ unpacker                                   , cons@@ -358,7 +364,7 @@ structElemToPyPack _ _ _ (Length _ _) = Left (Nothing, "") structElemToPyPack _ _ accessor (Switch n expr _ bitcases) =   let name = accessor n-      cmp = xExpressionToPyExpr id expr+      cmp = xExpressionToPyExpr accessor expr       elems = map (mkSwitch cmp) bitcases   in Right $ [(name, Right elems)]     where@@ -366,17 +372,18 @@                -> BitCase                -> (Expr (), [GenStructElem Type])       mkSwitch cmp (BitCase _ bcCmp _ elems') =-        let cmpVal = xExpressionToPyExpr id bcCmp+        let cmpVal = xExpressionToPyExpr accessor bcCmp             equality = BinaryOp (P.BinaryAnd ()) cmp cmpVal ()         in (equality, elems')-structElemToPyPack _ m accessor (SField n typ _ _) =+structElemToPyPack ext m accessor (SField n typ _ _) =   let name = accessor n   in case m M.! typ of        BaseType c -> Left (Just name, c)-       CompositeType _ typNam ->+       CompositeType tExt typNam ->          let cond = mkCall "hasattr" [mkArg name, ArgExpr (mkStr "pack") ()]              trueB = mkCall (name ++ ".pack") noArgs-             synthetic = mkCall (typNam ++ ".synthetic") [mkArg ("*" ++ name)]+             typNam' = if ext == tExt then typNam else tExt ++ "." ++ typNam+             synthetic = mkCall (typNam' ++ ".synthetic") [mkArg ("*" ++ name)]              falseB = mkCall (mkDot synthetic "pack") noArgs          in Right $ [(name                     , Left (Just (CondExpr trueB cond falseB ()))@@ -684,8 +691,8 @@         let rhs = mkInt theLen         return $ mkAssign "fixed_size" rhs   modify $ mkModify ext n (CompositeType ext n)-  return $ Declaration [mkXClass n "xcffib.Struct" statements (pack : fixedLength ++ synthetic)]-processXDecl ext (XEvent name opcode _ membs noSequence) = do+  return $ Declaration [mkXClass n "xcffib.Struct" False statements (pack : fixedLength ++ synthetic)]+processXDecl ext (XEvent name opcode _ xge membs noSequence) = do   m <- get   let cname = name ++ "Event"       prefix = if fromMaybe False noSequence then "x" else "x%c2x"@@ -693,7 +700,9 @@       synthetic = mkSyntheticMethod membs       (statements, _) = mkStructStyleUnpack prefix ext m membs       eventsUpd = mkDictUpdate "_events" opcode cname-  return $ Declaration [ mkXClass cname "xcffib.Event" statements (pack : synthetic)+      isxge = fromMaybe False xge+      -- xgeexp = mkAssign "xge" (if fromMaybe False xge then (mkName "True") else (mkName "False"))+  return $ Declaration [ mkXClass cname "xcffib.Event" isxge statements (pack : synthetic)                        , eventsUpd                        ] processXDecl ext (XError name opcode _ membs) = do@@ -704,7 +713,7 @@       (statements, _) = mkStructStyleUnpack prefix ext m membs       errorsUpd = mkDictUpdate "_errors" opcode cname       alias = mkAssign ("Bad" ++ name) (mkName cname)-  return $ Declaration [ mkXClass cname "xcffib.Error" statements [pack]+  return $ Declaration [ mkXClass cname "xcffib.Error" False statements [pack]                        , alias                        , errorsUpd                        ]@@ -720,7 +729,7 @@         GenXReply _ reply' <- reply         let (replyStmts, _) = mkStructStyleUnpack "x%c2x4x" ext m reply'             replyName = name ++ "Reply"-            theReply = mkXClass replyName "xcffib.Reply" replyStmts []+            theReply = mkXClass replyName "xcffib.Reply" False replyStmts []             replyType = mkAssign "reply_type" $ mkName replyName             cookie = mkClass cookieName "xcffib.Cookie" [replyType]         return [theReply, cookie]@@ -754,7 +763,7 @@       -- Here, we only want to pack the first member of the union, since every       -- member is the same data and we don't want to repeatedly pack it.       pack = mkPackMethod ext name m Nothing [head membs] Nothing-      decl = [mkXClass name "xcffib.Union" initMethod [pack]]+      decl = [mkXClass name "xcffib.Union" False initMethod [pack]]   modify $ mkModify ext name (CompositeType ext name)   return $ Declaration decl   where@@ -784,7 +793,7 @@ -- again. processXDecl ext (XEventStruct name _) = do   modify $ mkModify ext name (CompositeType ext name)-  return $ Declaration $ [mkXClass name "xcffib.Buffer" [] []]+  return $ Declaration $ [mkXClass name "xcffib.Buffer" False [] []]  mkVersion :: XHeader -> Suite () mkVersion header =
generator/Data/XCB/Python/PyHelpers.hs view
@@ -134,15 +134,16 @@ mkArg :: String -> Argument () mkArg n = ArgExpr (mkName n) () -mkXClass :: String -> String -> Suite () -> Suite () -> Statement ()-mkXClass clazz superclazz [] [] = mkEmptyClass clazz superclazz-mkXClass clazz superclazz constructor methods =+mkXClass :: String -> String -> Bool -> Suite () -> Suite () -> Statement ()+mkXClass clazz superclazz False [] [] = mkEmptyClass clazz superclazz+mkXClass clazz superclazz xge constructor methods =   let args = [ "self", "unpacker" ]       super = mkCall (superclazz ++ ".__init__") $ map mkName args       body = eventToUnpacker : (StmtExpr super ()) : constructor       initParams = mkParams args+      xgeexp = mkAssign "xge" (if xge then (mkName "True") else (mkName "False"))       initMethod = Fun (ident "__init__") initParams Nothing body ()-  in mkClass clazz superclazz $ initMethod : methods+  in mkClass clazz superclazz $ xgeexp : initMethod : methods      where 
test/generator/error.py view
@@ -7,6 +7,7 @@ _events = {} _errors = {} class RequestError(xcffib.Error):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())
test/generator/event.py view
@@ -7,6 +7,7 @@ _events = {} _errors = {} class ScreenChangeNotifyEvent(xcffib.Event):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())
test/generator/no_sequence.py view
@@ -4,6 +4,7 @@ _events = {} _errors = {} class KeymapNotifyEvent(xcffib.Event):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())
test/generator/render.py view
@@ -7,6 +7,7 @@ _events = {} _errors = {} class COLOR(xcffib.Struct):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())@@ -28,6 +29,7 @@         self.alpha = alpha         return self class RECTANGLE(xcffib.Struct):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())
test/generator/request_reply.py view
@@ -4,6 +4,7 @@ _events = {} _errors = {} class STR(xcffib.Struct):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())@@ -24,6 +25,7 @@         self.name = name         return self class ListExtensionsReply(xcffib.Reply):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())
test/generator/struct.py view
@@ -4,6 +4,7 @@ _events = {} _errors = {} class AxisInfo(xcffib.Struct):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())@@ -24,6 +25,7 @@         self.maximum = maximum         return self class ValuatorInfo(xcffib.Struct):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())
test/generator/switch.py view
@@ -4,6 +4,7 @@ _events = {} _errors = {} class INT64(xcffib.Struct):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())@@ -23,6 +24,7 @@         self.lo = lo         return self class GetPropertyReply(xcffib.Reply):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())@@ -39,6 +41,7 @@ class GetPropertyCookie(xcffib.Cookie):     reply_type = GetPropertyReply class GetPropertyWithPadReply(xcffib.Reply):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())
test/generator/type_pad.py view
@@ -4,6 +4,7 @@ _events = {} _errors = {} class CHARINFO(xcffib.Struct):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())@@ -27,6 +28,7 @@         self.attributes = attributes         return self class FONTPROP(xcffib.Struct):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())@@ -46,6 +48,7 @@         self.value = value         return self class ListFontsWithInfoReply(xcffib.Reply):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())
test/generator/union.py view
@@ -4,6 +4,7 @@ _events = {} _errors = {} class ClientMessageData(xcffib.Union):+    xge = False     def __init__(self, unpacker):         if isinstance(unpacker, xcffib.Protobj):             unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.cabal view
@@ -1,5 +1,5 @@ name:                xcffib-version:             1.1.2+version:             1.2.0 synopsis:            A cffi-based python binding for X homepage:            http://github.com/tych0/xcffib license:             OtherLicense@@ -25,7 +25,7 @@  library   build-depends: base ==4.*,-                 xcb-types >= 0.11.0,+                 xcb-types >= 0.12.0,                  language-python >= 0.5.6,                  filepath,                  filemanip,@@ -48,7 +48,7 @@                  xcffib,                  language-python >= 0.5.6,                  split,-                 xcb-types >= 0.11.0,+                 xcb-types >= 0.12.0,                  optparse-applicative >= 0.13,                  filepath,                  filemanip,@@ -83,7 +83,7 @@   type: exitcode-stdio-1.0   build-depends: base ==4.*,                  xcffib,-                 xcb-types >= 0.11.0,+                 xcb-types >= 0.12.0,                  language-python >= 0.5.6,                  HUnit,                  test-framework,