packages feed

xmms2-client 0.0.6.0 → 0.0.7.0

raw patch · 8 files changed

+121/−61 lines, 8 files

Files

C2HS.hs view
@@ -40,7 +40,7 @@   module Foreign,    -- * Re-export the C language component of the FFI-  module CForeign,+  module Foreign.C,    -- * Composite marshalling functions   withCStringLenIntConv, peekCStringLenIntConv, withIntConv, withFloatConv,@@ -58,12 +58,9 @@   import Foreign-       hiding       (Word)-		    -- Should also hide the Foreign.Marshal.Pool exports in-		    -- compilers that export them-import CForeign+import Foreign.C -import Monad        (when, liftM)+import Monad (liftM)   -- Composite marshalling functions@@ -71,28 +68,52 @@  -- Strings with explicit length ---withCStringLenIntConv s f    = withCStringLen s $ \(p, n) -> f (p, cIntConv n)-peekCStringLenIntConv (s, n) = peekCStringLen (s, cIntConv n)+withCStringLenIntConv :: Num n => String -> ((CString, n) -> IO a) -> IO a+withCStringLenIntConv s f    = withCStringLen s $ \(p, n) -> f (p, fromIntegral n) +peekCStringLenIntConv :: Integral n => (CString, n) -> IO String+peekCStringLenIntConv (s, n) = peekCStringLen (s, fromIntegral n)+ -- Marshalling of numerals --  withIntConv   :: (Storable b, Integral a, Integral b) -	      => a -> (Ptr b -> IO c) -> IO c-withIntConv    = with . cIntConv+              => a -> (Ptr b -> IO c) -> IO c+withIntConv    = with . fromIntegral  withFloatConv :: (Storable b, RealFloat a, RealFloat b) -	      => a -> (Ptr b -> IO c) -> IO c-withFloatConv  = with . cFloatConv+              => a -> (Ptr b -> IO c) -> IO c+withFloatConv  = with . realToFrac  peekIntConv   :: (Storable a, Integral a, Integral b) -	      => Ptr a -> IO b-peekIntConv    = liftM cIntConv . peek+              => Ptr a -> IO b+peekIntConv    = liftM fromIntegral . peek  peekFloatConv :: (Storable a, RealFloat a, RealFloat b) -	      => Ptr a -> IO b-peekFloatConv  = liftM cFloatConv . peek+              => Ptr a -> IO b+peekFloatConv  = liftM realToFrac . peek ++-- Everything else below is deprecated.+-- These functions are not used by code generated by c2hs.++{-# DEPRECATED withBool        "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}+{-# DEPRECATED peekBool        "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}+{-# DEPRECATED withEnum        "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}+{-# DEPRECATED peekEnum        "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}+{-# DEPRECATED nothingIf       "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}+{-# DEPRECATED nothingIfNull   "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}+{-# DEPRECATED combineBitMasks "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}+{-# DEPRECATED containsBitMask "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}+{-# DEPRECATED extractBitMasks "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}+{-# DEPRECATED cIntConv        "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}+{-# DEPRECATED cFloatConv      "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}+{-# DEPRECATED cFromBool       "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}+{-# DEPRECATED cToBool         "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}+{-# DEPRECATED cToEnum         "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}+{-# DEPRECATED cFromEnum       "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-}++ -- Passing Booleans by reference -- @@ -116,20 +137,22 @@ -- Storing of 'Maybe' values -- ------------------------- +--TODO: kill off this orphan instance!+ instance Storable a => Storable (Maybe a) where   sizeOf    _ = sizeOf    (undefined :: Ptr ())   alignment _ = alignment (undefined :: Ptr ())    peek p = do-	     ptr <- peek (castPtr p)-	     if ptr == nullPtr-	       then return Nothing-	       else liftM Just $ peek ptr+             ptr <- peek (castPtr p)+             if ptr == nullPtr+               then return Nothing+               else liftM Just $ peek ptr    poke p v = do-	       ptr <- case v of-		        Nothing -> return nullPtr-			Just v' -> new v'+               ptr <- case v of+                        Nothing -> return nullPtr+                        Just v' -> new v'                poke (castPtr p) ptr  @@ -167,8 +190,8 @@ -- containsBitMask :: (Bits a, Enum b) => a -> b -> Bool bits `containsBitMask` bm = let bm' = fromIntegral . fromEnum $ bm-			    in-			    bm' .&. bits == bm'+                            in+                            bm' .&. bits == bm'  -- |Given a bit pattern, yield all bit masks that it contains. --@@ -193,11 +216,6 @@ -- cFloatConv :: (RealFloat a, RealFloat b) => a -> b cFloatConv  = realToFrac--- As this conversion by default goes via `Rational', it can be very slow...-{-# RULES -  "cFloatConv/Float->Float"   forall (x::Float).  cFloatConv x = x;-  "cFloatConv/Double->Double" forall (x::Double). cFloatConv x = x- #-}  -- |Obtain C value from Haskell 'Bool'. --@@ -212,9 +230,9 @@ -- |Convert a C enumeration to Haskell. -- cToEnum :: (Integral i, Enum e) => i -> e-cToEnum  = toEnum . cIntConv+cToEnum  = toEnum . fromIntegral  -- |Convert a Haskell enumeration to C. -- cFromEnum :: (Enum e, Integral i) => e -> i-cFromEnum  = cIntConv . fromEnum+cFromEnum  = fromIntegral . fromEnum
src/XMMS2/Client/Bindings/Coll.chs view
@@ -27,6 +27,7 @@   , collIdlistFromPlaylistFile   , collSync   , collQueryIds+  , collQueryInfos   , broadcastCollectionChanged   ) where @@ -94,6 +95,16 @@  , withValue*      `Value'  , cIntConv        `Int'  , cIntConv        `Int'+ } -> `Result' takeResult* #}++{# fun coll_query_infos as ^+ { withConnection* `Connection'+ , withColl*       `Coll'+ , withValue*      `Value'+ , cIntConv        `Int'+ , cIntConv        `Int'+ , withValue*      `Value'+ , withValue*      `Value'  } -> `Result' takeResult* #}  
src/XMMS2/Client/Bindings/Types/Dict.chs view
@@ -44,10 +44,10 @@   newDict = new_dict >>= takeValue False-{# fun new_dict as new_dict+{# fun unsafe new_dict as new_dict  {} -> `ValuePtr' id #} -{# fun dict_set as ^+{# fun unsafe dict_set as ^  { withValue*   `Value'  , withCString* `String'  , withValue*   `Value'@@ -63,7 +63,7 @@  getDictIter :: Value -> IO DictIter getDictIter = get TypeDict get_dict_iter (takePtr DictIter finalize_dict_iter)-{# fun xmms2hs_get_dict_iter as get_dict_iter+{# fun unsafe xmms2hs_get_dict_iter as get_dict_iter  { withValue* `Value'  , alloca-    `DictIterPtr' peek*  } -> `Bool' #}@@ -77,17 +77,17 @@   (ok, key, val) <- dict_iter_pair iter   unless ok $ throwIO $ InvalidIter   (,) <$> peekCString key <*> takeValue True val-{# fun dict_iter_pair as dict_iter_pair+{# fun unsafe dict_iter_pair as dict_iter_pair  { withDictIter* `DictIter'  , alloca-       `CString'  peek*  , alloca-       `ValuePtr' peek*  } -> `Bool' #} -{# fun dict_iter_valid as ^+{# fun unsafe dict_iter_valid as ^  { withDictIter* `DictIter'  } -> `Bool' #} -{# fun dict_iter_next as ^+{# fun unsafe dict_iter_next as ^  { withDictIter* `DictIter'  } -> `()' #} @@ -116,7 +116,7 @@  propdictToDict :: Value -> [String] -> IO Value propdictToDict v p = propdict_to_dict v p >>= takeValue False-{# fun propdict_to_dict as propdict_to_dict+{# fun unsafe propdict_to_dict as propdict_to_dict  { withValue*         `Value'  , withCStringArray0* `[String]'  } -> `ValuePtr' id #}
src/XMMS2/Client/Bindings/Types/List.chs view
@@ -43,21 +43,21 @@   newList = new_list >>= takeValue False-{# fun new_list as new_list+{# fun unsafe new_list as new_list  {} -> `ValuePtr' id #} -{# fun list_get_size as ^+{# fun unsafe list_get_size as ^  { withValue* `Value'  } -> `Integer' cIntConv #}  listGet l p = get TypeList ((flip list_get) p) (takeValue True) l-{# fun list_get as list_get+{# fun unsafe list_get as list_get  { withValue* `Value'  , cIntConv   `Integer'  , alloca-    `ValuePtr' peek*  } -> `Bool' #} -{#fun list_append as ^+{#fun unsafe list_append as ^  { withValue* `Value'  , withValue* `Value'  } -> `Int' #}@@ -71,7 +71,7 @@  getListIter :: Value -> IO ListIter getListIter = get TypeList get_list_iter (takePtr ListIter finalize_list_iter)-{# fun xmms2hs_get_list_iter as get_list_iter+{# fun unsafe xmms2hs_get_list_iter as get_list_iter  { withValue* `Value'  , alloca-    `ListIterPtr' peek*  } -> `Bool' #}@@ -84,15 +84,15 @@   (ok, v') <- list_iter_entry iter   unless ok $ throwIO InvalidIter   takeValue True v'-{# fun list_iter_entry as list_iter_entry+{# fun unsafe list_iter_entry as list_iter_entry  { withListIter* `ListIter'  , alloca-       `ValuePtr' peek*  } -> `Bool' #} -{# fun list_iter_valid as ^+{# fun unsafe list_iter_valid as ^  { withListIter* `ListIter'  } -> `Bool' #} -{# fun list_iter_next as ^+{# fun unsafe list_iter_next as ^  { withListIter* `ListIter'  } -> `()' #}
src/XMMS2/Client/Bindings/Types/Value.chs view
@@ -67,7 +67,7 @@   p' <- if ref then xmmsv_ref p else return p   takePtr Value xmmsv_unref p' -{# fun xmmsv_ref as xmmsv_ref+{# fun unsafe xmmsv_ref as xmmsv_ref  { id `ValuePtr'  } -> `ValuePtr' id #} @@ -82,7 +82,7 @@  { underscoreToCase }  deriving (Show) #} -{# fun get_type as ^+{# fun unsafe get_type as ^  { withValue* `Value'  } -> `ValueType' cToEnum #} @@ -92,7 +92,7 @@   if ok     then Just <$> peekCString err     else return Nothing-{# fun get_error as get_error+{# fun unsafe get_error as get_error  { withValue* `Value'  , alloca-    `CString' peek*  } -> `Bool' #}@@ -100,28 +100,28 @@ getNone = get TypeNone (const $ return (True, ())) return  newNone = new_none >>= takeValue False-{# fun new_none as new_none+{# fun unsafe new_none as new_none  {} -> `ValuePtr' id #}  getInt = get TypeInt32 get_int return-{# fun get_int as get_int+{# fun unsafe get_int as get_int  { withValue* `Value'  , alloca-    `Int32' peekIntConv*  } -> `Bool' #}  newInt val = new_int val >>= takeValue False-{# fun new_int as new_int+{# fun unsafe new_int as new_int  { cIntConv `Int32'  } -> `ValuePtr' id #}  getString = get TypeString get_string peekCString-{# fun get_string as get_string+{# fun unsafe get_string as get_string  { withValue* `Value'  , alloca-    `CString' peek*  } -> `Bool' #}  newString val = new_string val >>= takeValue False-{# fun new_string as new_string+{# fun unsafe new_string as new_string  { withCString* `String'  } -> `ValuePtr' id #} 
src/XMMS2/Client/Coll.hs view
@@ -28,6 +28,7 @@   , collIdlistFromPlaylistFile   , collSync   , collQueryIds+  , collQueryInfos   , broadcastCollectionChanged   ) where @@ -119,6 +120,21 @@ collQueryIds xmmsc coll order start len = do   order' <- valueNew order   liftResult $ B.collQueryIds xmmsc coll order' start len++collQueryInfos ::+  Connection   ->+  Coll         ->+  [String]     ->+  Int          ->+  Int          ->+  [String]     ->+  [String]     ->+  IO (Result Default [Dict Property])+collQueryInfos xmmsc coll order start len fetch group = do+  order' <- valueNew order+  fetch' <- valueNew fetch+  group' <- valueNew group+  liftResult $ B.collQueryInfos xmmsc coll order' start len fetch' group'   broadcastCollectionChanged :: Connection -> IO (Result Broadcast CollectionChange)
src/XMMS2/Utils.hs view
@@ -19,6 +19,9 @@  module XMMS2.Utils   ( module C2HS+  , cIntConv+  , cFromEnum+  , cToEnum   , withCString   , withMaybeCString   , withCStringArray0@@ -40,9 +43,24 @@  import Codec.Binary.UTF8.String -import C2HS hiding (withCString, peekCString)+import C2HS hiding+  ( withCString+  , peekCString+  , cIntConv+  , cFromEnum+  , cToEnum+  )  +cIntConv :: (Integral a, Integral b) => a -> b+cIntConv = fromIntegral++cFromEnum :: (Enum e, Integral i) => e -> i+cFromEnum  = fromIntegral . fromEnum++cToEnum :: (Integral i, Enum e) => i -> e+cToEnum  = toEnum . fromIntegral+ withMaybeCString (Just s) f = withCString s f withMaybeCString Nothing f  = f nullPtr @@ -58,7 +76,6 @@     doIt (x:xs) p f =       withCString x $ \s -> poke p s >> doIt xs (advancePtr p 1) f - peekCString = liftM decodeString . CS.peekCString  while = while' id@@ -70,9 +87,7 @@      then (:) <$> a <*> while' w c a      else return [] - withZTArray = withArray0 0-  takePtr  con fin = liftM con . newForeignPtr fin takePtr_ con     = liftM con . newForeignPtr_
xmms2-client.cabal view
@@ -1,5 +1,5 @@ name:               xmms2-client-version:            0.0.6.0+version:            0.0.7.0  author:             Oleg Belozeorov maintainer:         Oleg Belozeorov <upwawet@gmail.com>@@ -98,4 +98,4 @@   type:             git   location:         git://github.com/upwawet/xmms2hs.git   subdir:           client-  tag:              v0.0.6.0+  tag:              v0.0.7.0