packages feed

dbus-core 0.8.5 → 0.8.5.1

raw patch · 23 files changed

+3/−1145 lines, 23 filesdep ~QuickCheckdep ~textPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: QuickCheck, text

API changes (from Hackage documentation)

Files

dbus-core.cabal view
@@ -1,5 +1,5 @@ name: dbus-core-version: 0.8.5+version: 0.8.5.1 synopsis: Low-level D-Bus protocol implementation license: GPL-3 license-file: License.txt@@ -38,7 +38,7 @@     , binary >= 0.4 && < 0.6     , bytestring >= 0.9 && < 0.10     , data-binary-ieee754 >= 0.3 && < 0.5-    , text >= 0.7 && < 0.8+    , text >= 0.8 && < 0.9     , containers >= 0.1 && < 0.4     , unix >= 2.2 && < 2.5     , network >= 2.2 && < 2.3@@ -75,7 +75,7 @@    if flag(test)     build-depends:-        QuickCheck >= 2.1 && < 2.2+        QuickCheck >= 2.2 && < 2.3       , test-framework >= 0.2 && < 0.4       , test-framework-quickcheck2 >= 0.2 && < 0.3   else
hs/DBus/Address.hs view
@@ -1,7 +1,3 @@--#line 19 "src/addresses.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,13 +12,7 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 20 "src/addresses.anansi"--#line 52 "src/introduction.anansi" {-# LANGUAGE OverloadedStrings #-}--#line 21 "src/addresses.anansi" module DBus.Address 	( Address 	, addressMethod@@ -30,25 +20,17 @@ 	, mkAddresses 	, strAddress 	) where--#line 56 "src/introduction.anansi" import Data.Text.Lazy (Text) import qualified Data.Text.Lazy as TL -#line 29 "src/addresses.anansi"- import Data.Char (ord, chr) import qualified Data.Map as M import Text.Printf (printf) import qualified Text.ParserCombinators.Parsec as P import Text.ParserCombinators.Parsec ((<|>)) import DBus.Util (hexToInt, eitherToMaybe)--#line 74 "src/addresses.anansi" optionallyEncoded :: [Char] optionallyEncoded = ['0'..'9'] ++ ['a'..'z'] ++ ['A'..'Z'] ++ "-_/\\*."--#line 82 "src/addresses.anansi" data Address = Address 	{ addressMethod     :: Text 	, addressParameters :: M.Map Text Text@@ -57,8 +39,6 @@ instance Show Address where 	showsPrec d x = showParen (d> 10) $ 		showString "Address " . shows (strAddress x)--#line 97 "src/addresses.anansi" mkAddresses :: Text -> Maybe [Address] mkAddresses s = eitherToMaybe . P.parse parser "" . TL.unpack $ s where 	address = do@@ -83,8 +63,6 @@ 		P.char '%' 		hex <- P.count 2 P.hexDigit 		return . chr . hexToInt $ hex--#line 128 "src/addresses.anansi" strAddress :: Address -> Text strAddress (Address t ps) = TL.concat [t, ":", ps'] where 	ps' = TL.intercalate "," $ do
hs/DBus/Authentication.hs view
@@ -1,7 +1,3 @@--#line 27 "src/authentication.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,13 +12,7 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 28 "src/authentication.anansi"--#line 52 "src/introduction.anansi" {-# LANGUAGE OverloadedStrings #-}--#line 29 "src/authentication.anansi" {-# LANGUAGE DeriveDataTypeable #-} module DBus.Authentication 	( Command@@ -31,54 +21,32 @@ 	, authenticate 	, realUserID 	) where--#line 56 "src/introduction.anansi" import Data.Text.Lazy (Text) import qualified Data.Text.Lazy as TL--#line 38 "src/authentication.anansi"--#line 45 "src/authentication.anansi" import Data.ByteString.Lazy (ByteString) import qualified Data.ByteString.Lazy as ByteString import Data.ByteString.Lazy.Char8 () import qualified DBus.UUID as UUID--#line 61 "src/authentication.anansi" import Data.Typeable (Typeable) import qualified Control.Exception as E--#line 78 "src/authentication.anansi" import Data.Word (Word8)--#line 94 "src/authentication.anansi" import Control.Monad (liftM) import Data.Char (chr) import Data.Text.Lazy.Encoding (encodeUtf8) import DBus.Util (readUntil, dropEnd)--#line 115 "src/authentication.anansi" import System.Posix.User (getRealUserID) import Data.Char (ord) import Text.Printf (printf)--#line 136 "src/authentication.anansi" import Data.Maybe (isJust)--#line 52 "src/authentication.anansi" type Command = Text newtype Mechanism = Mechanism 	{ mechanismRun :: (Command -> IO Command) -> IO UUID.UUID 	}--#line 66 "src/authentication.anansi" data AuthenticationError 	= AuthenticationError Text 	deriving (Show, Typeable)  instance E.Exception AuthenticationError--#line 82 "src/authentication.anansi" authenticate :: Mechanism -> (ByteString -> IO ()) -> IO Word8              -> IO UUID.UUID authenticate mech put getByte = do@@ -86,16 +54,12 @@ 	uuid <- mechanismRun mech (putCommand put getByte) 	put "BEGIN\r\n" 	return uuid--#line 101 "src/authentication.anansi" putCommand :: Monad m => (ByteString -> m ()) -> m Word8 -> Command -> m Command putCommand put get cmd = do 	let getC = liftM (chr . fromIntegral) get 	put $ encodeUtf8 cmd 	put "\r\n" 	liftM (TL.pack . dropEnd 2) $ readUntil "\r\n" getC--#line 121 "src/authentication.anansi" realUserID :: Mechanism realUserID = Mechanism $ \sendCmd -> do 	uid <- getRealUserID@@ -105,8 +69,6 @@ 	case eitherUUID of 		Right uuid -> return uuid 		Left err -> E.throwIO $ AuthenticationError err--#line 140 "src/authentication.anansi" checkOK :: Command -> Either Text UUID.UUID checkOK cmd = if validUUID then Right uuid else Left errorMsg where 	validUUID = TL.isPrefixOf "OK " cmd && isJust maybeUUID
hs/DBus/Bus.hs view
@@ -1,7 +1,3 @@--#line 19 "src/bus.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,13 +12,7 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 20 "src/bus.anansi"--#line 52 "src/introduction.anansi" {-# LANGUAGE OverloadedStrings #-}--#line 21 "src/bus.anansi" module DBus.Bus 	( getBus 	, getFirstBus@@ -30,13 +20,9 @@ 	, getSessionBus 	, getStarterBus 	) where--#line 56 "src/introduction.anansi" import Data.Text.Lazy (Text) import qualified Data.Text.Lazy as TL -#line 29 "src/bus.anansi"- import qualified Control.Exception as E import Control.Monad (when) import Data.Maybe (fromJust, isNothing)@@ -50,64 +36,36 @@ import qualified DBus.Message as M import qualified DBus.Types as T import DBus.Util (fromRight)--#line 50 "src/bus.anansi" busForConnection :: C.Connection -> IO (C.Connection, T.BusName) busForConnection c = fmap ((,) c) $ sendHello c --#line 99 "src/api-docs.anansi" -- | Similar to 'C.connect', but additionally sends @Hello@ messages to the -- central bus.--#line 54 "src/bus.anansi" getBus :: Auth.Mechanism -> A.Address -> IO (C.Connection, T.BusName) getBus = ((busForConnection =<<) .) . C.connect--#line 62 "src/bus.anansi"--#line 104 "src/api-docs.anansi" -- | Similar to 'C.connectFirst', but additionally sends @Hello@ messages to -- the central bus.--#line 63 "src/bus.anansi" getFirstBus :: [(Auth.Mechanism, A.Address)] -> IO (C.Connection, T.BusName) getFirstBus = (busForConnection =<<) . C.connectFirst--#line 74 "src/bus.anansi"--#line 109 "src/api-docs.anansi" -- | Connect to the bus specified in the environment variable -- @DBUS_SYSTEM_BUS_ADDRESS@, or to -- @unix:path=\/var\/run\/dbus\/system_bus_socket@ if @DBUS_SYSTEM_BUS_ADDRESS@ -- is not set.--#line 75 "src/bus.anansi" getSystemBus :: IO (C.Connection, T.BusName) getSystemBus = getBus' $ fromEnv `E.catch` noEnv where 	defaultAddr = "unix:path=/var/run/dbus/system_bus_socket" 	fromEnv = getEnv "DBUS_SYSTEM_BUS_ADDRESS" 	noEnv (E.SomeException _) = return defaultAddr --#line 116 "src/api-docs.anansi" -- | Connect to the bus specified in the environment variable -- @DBUS_SESSION_BUS_ADDRESS@, which must be set.--#line 82 "src/bus.anansi" getSessionBus :: IO (C.Connection, T.BusName) getSessionBus = getBus' $ getEnv "DBUS_SESSION_BUS_ADDRESS" --#line 121 "src/api-docs.anansi" -- | Connect to the bus specified in the environment variable -- @DBUS_STARTER_ADDRESS@, which must be set.--#line 86 "src/bus.anansi" getStarterBus :: IO (C.Connection, T.BusName) getStarterBus = getBus' $ getEnv "DBUS_STARTER_ADDRESS"--#line 91 "src/bus.anansi" getBus' :: IO String -> IO (C.Connection, T.BusName) getBus' io = do 	addr <- fmap TL.pack io@@ -115,8 +73,6 @@ 		Just [x] -> getBus Auth.realUserID x 		Just  xs -> getFirstBus [(Auth.realUserID,x) | x <- xs] 		_        -> E.throwIO $ C.InvalidAddress addr--#line 103 "src/bus.anansi" hello :: M.MethodCall hello = M.MethodCall dbusPath 	"Hello"@@ -124,8 +80,6 @@ 	(Just dbusName) 	Set.empty 	[]--#line 113 "src/bus.anansi" sendHello :: C.Connection -> IO T.BusName sendHello c = do 	serial <- fromRight `fmap` C.send c return hello@@ -138,8 +92,6 @@ 		E.throwIO $ E.AssertionFailed "Invalid response to Hello()" 	 	return . fromJust $ name--#line 128 "src/bus.anansi" waitForReply :: C.Connection -> M.Serial -> IO M.MethodReturn waitForReply c serial = do 	received <- C.receive c
hs/DBus/Connection.hs view
@@ -1,7 +1,3 @@--#line 19 "src/connections.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,83 +12,39 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 20 "src/connections.anansi"--#line 52 "src/introduction.anansi" {-# LANGUAGE OverloadedStrings #-}--#line 21 "src/connections.anansi" {-# LANGUAGE DeriveDataTypeable #-} module DBus.Connection (--#line 53 "src/connections.anansi" 	  Connection 	, connectionAddress 	, connectionUUID--#line 288 "src/connections.anansi" 	, ConnectionError (..)--#line 327 "src/connections.anansi" 	, connect 	, connectFirst--#line 340 "src/connections.anansi" 	, connectionClose--#line 370 "src/connections.anansi" 	, send--#line 394 "src/connections.anansi" 	, receive--#line 24 "src/connections.anansi" 	) where--#line 56 "src/introduction.anansi" import Data.Text.Lazy (Text) import qualified Data.Text.Lazy as TL--#line 26 "src/connections.anansi"--#line 36 "src/connections.anansi" import qualified Control.Concurrent as C import qualified DBus.Address as A import qualified DBus.Message as M import qualified DBus.UUID as UUID--#line 75 "src/connections.anansi" import qualified Data.ByteString.Lazy as L import Data.Word (Word32)--#line 107 "src/connections.anansi" import qualified Network as N import qualified Data.Map as Map--#line 147 "src/connections.anansi" import qualified Network.Socket as NS--#line 193 "src/connections.anansi" import qualified Text.ParserCombinators.Parsec as P import Control.Monad (unless) import Data.Binary.Get (runGet, getWord16host) import Data.Binary.Put (runPut, putWord16be)--#line 255 "src/connections.anansi" import qualified System.IO as I--#line 272 "src/connections.anansi" import qualified Control.Exception as E import Data.Typeable (Typeable)--#line 297 "src/connections.anansi" import qualified DBus.Authentication as Auth--#line 353 "src/connections.anansi" import qualified DBus.Wire as W--#line 43 "src/connections.anansi" data Connection = Connection 	{ connectionAddress    :: A.Address 	, connectionTransport  :: Transport@@ -100,35 +52,23 @@ 	, connectionReadMVar   :: C.MVar () 	, connectionUUID       :: UUID.UUID 	}--#line 62 "src/connections.anansi" instance Show Connection where 	showsPrec d con = showParen (d > 10) strCon where 		addr = A.strAddress $ connectionAddress con 		strCon = s "<Connection " . shows addr . s ">" 		s = showString--#line 80 "src/connections.anansi"--#line 59 "src/api-docs.anansi" -- | A 'Transport' is anything which can send and receive bytestrings, -- typically via a socket.--#line 81 "src/connections.anansi" data Transport = Transport 	{ transportSend :: L.ByteString -> IO () 	, transportRecv :: Word32 -> IO L.ByteString 	, transportClose :: IO () 	}--#line 92 "src/connections.anansi" connectTransport :: A.Address -> IO Transport connectTransport a = transport' (A.addressMethod a) a where 	transport' "unix" = unix 	transport' "tcp"  = tcp 	transport' _      = E.throwIO . UnknownMethod--#line 112 "src/connections.anansi" unix :: A.Address -> IO Transport unix a = port >>= N.connectTo "localhost" >>= handleTransport where 	params = A.addressParameters a@@ -146,8 +86,6 @@ 		(Nothing, Nothing) -> E.throwIO $ BadParameters a tooFew 		(Just x, Nothing) -> return $ TL.unpack x 		(Nothing, Just x) -> return $ '\x00' : TL.unpack x--#line 151 "src/connections.anansi" tcp :: A.Address -> IO Transport tcp a = openHandle >>= handleTransport where 	params = A.addressParameters a@@ -157,19 +95,13 @@ 		addresses <- getAddresses family 		socket <- openSocket port addresses 		NS.socketToHandle socket I.ReadWriteMode--#line 165 "src/connections.anansi" 	hostname = maybe "localhost" TL.unpack $ Map.lookup "host" params--#line 169 "src/connections.anansi" 	unknownFamily x = TL.concat ["Unknown socket family for TCP transport: ", x] 	getFamily = case Map.lookup "family" params of 		Just "ipv4" -> return NS.AF_INET 		Just "ipv6" -> return NS.AF_INET6 		Nothing     -> return NS.AF_UNSPEC 		Just x      -> E.throwIO $ BadParameters a $ unknownFamily x--#line 178 "src/connections.anansi" 	missingPort = "TCP transport requires the ``port'' parameter." 	badPort x = TL.concat ["Invalid socket port for TCP transport: ", x] 	getPort = case Map.lookup "port" params of@@ -177,8 +109,6 @@ 		Just x -> case P.parse parseWord16 "" (TL.unpack x) of 			Right x' -> return $ NS.PortNum x' 			Left  _  -> E.throwIO $ BadParameters a $ badPort x--#line 200 "src/connections.anansi" 	parseWord16 = do 		chars <- P.many1 P.digit 		P.eof@@ -190,8 +120,6 @@ 			fail "bad port" 		let word = fromIntegral value 		return $ runGet getWord16host (runPut (putWord16be word))--#line 214 "src/connections.anansi" 	getAddresses family = do 		let hints = NS.defaultHints 			{ NS.addrFlags = [NS.AI_ADDRCONFIG]@@ -199,13 +127,9 @@ 			, NS.addrSocketType = NS.Stream 			} 		NS.getAddrInfo (Just hints) (Just hostname) Nothing--#line 228 "src/connections.anansi" 	setPort port (NS.SockAddrInet  _ x)     = NS.SockAddrInet port x 	setPort port (NS.SockAddrInet6 _ x y z) = NS.SockAddrInet6 port x y z 	setPort _    addr                       = addr--#line 238 "src/connections.anansi" 	openSocket _ [] = E.throwIO $ NoWorkingAddress [a] 	openSocket port (addr:addrs) = E.catch (openSocket' port addr) $ 		\(E.SomeException _) -> openSocket port addrs@@ -215,15 +139,11 @@ 		                  (NS.addrProtocol addr) 		NS.connect sock . setPort port . NS.addrAddress $ addr 		return sock--#line 259 "src/connections.anansi" handleTransport :: I.Handle -> IO Transport handleTransport h = do 	I.hSetBuffering h I.NoBuffering 	I.hSetBinaryMode h True 	return $ Transport (L.hPut h) (L.hGet h . fromIntegral) (I.hClose h)--#line 277 "src/connections.anansi" data ConnectionError 	= InvalidAddress Text 	| BadParameters A.Address Text@@ -232,14 +152,8 @@ 	deriving (Show, Typeable)  instance E.Exception ConnectionError--#line 301 "src/connections.anansi"--#line 64 "src/api-docs.anansi" -- | Open a connection to some address, using a given authentication -- mechanism. If the connection fails, a 'ConnectionError' will be thrown.--#line 302 "src/connections.anansi" connect :: Auth.Mechanism -> A.Address -> IO Connection connect mechanism a = do 	t <- connectTransport a@@ -248,34 +162,18 @@ 	readLock <- C.newMVar () 	serialMVar <- C.newMVar M.firstSerial 	return $ Connection a t serialMVar readLock uuid--#line 317 "src/connections.anansi"--#line 69 "src/api-docs.anansi" -- | Try to open a connection to various addresses, returning the first -- connection which could be successfully opened.--#line 318 "src/connections.anansi" connectFirst :: [(Auth.Mechanism, A.Address)] -> IO Connection connectFirst orig = connectFirst' orig where 	allAddrs = [a | (_, a) <- orig] 	connectFirst'     [] = E.throwIO $ NoWorkingAddress allAddrs 	connectFirst' ((mech, a):as) = E.catch (connect mech a) $ 		\(E.SomeException _) -> connectFirst' as--#line 334 "src/connections.anansi"--#line 74 "src/api-docs.anansi" -- | Close an open connection. Once closed, the 'Connection' is no longer -- valid and must not be used.--#line 335 "src/connections.anansi" connectionClose :: Connection -> IO () connectionClose = transportClose . connectionTransport--#line 357 "src/connections.anansi"--#line 79 "src/api-docs.anansi" -- | Send a single message, with a generated 'M.Serial'. The second parameter -- exists to prevent race conditions when registering a reply handler; it -- receives the serial the message /will/ be sent with, before it's actually@@ -284,8 +182,6 @@ -- Only one message may be sent at a time; if multiple threads attempt to -- send messages in parallel, one will block until after the other has -- finished.--#line 358 "src/connections.anansi" send :: M.Message a => Connection -> (M.Serial -> IO b) -> a      -> IO (Either W.MarshalError b) send (Connection _ t mvar _ _) io msg = withSerial mvar $ \serial ->@@ -295,8 +191,6 @@ 			transportSend t bytes 			return $ Right x 		Left  err   -> return $ Left err--#line 374 "src/connections.anansi" withSerial :: C.MVar M.Serial -> (M.Serial -> IO a) -> IO a withSerial m io = E.block $ do 	s <- C.takeMVar m@@ -304,18 +198,12 @@ 	x <- E.unblock (io s) `E.onException` C.putMVar m s' 	C.putMVar m s' 	return x--#line 387 "src/connections.anansi"--#line 90 "src/api-docs.anansi" -- | Receive the next message from the connection, blocking until one is -- available. -- -- Only one message may be received at a time; if multiple threads attempt -- to receive messages in parallel, one will block until after the other has -- finished.--#line 388 "src/connections.anansi" receive :: Connection -> IO (Either W.UnmarshalError M.ReceivedMessage) receive (Connection _ t _ lock _) = C.withMVar lock $ \_ -> 	W.unmarshalMessage $ transportRecv t
hs/DBus/Constants.hs view
@@ -1,7 +1,3 @@--#line 19 "src/constants.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,8 +12,6 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 20 "src/constants.anansi" {-# LANGUAGE OverloadedStrings #-} module DBus.Constants where import qualified DBus.Types as T@@ -31,8 +25,6 @@  arrayMaximumLength :: Word32 arrayMaximumLength = 67108864--#line 38 "src/constants.anansi" dbusName :: T.BusName dbusName = "org.freedesktop.DBus" @@ -41,8 +33,6 @@  dbusInterface :: T.InterfaceName dbusInterface = "org.freedesktop.DBus"--#line 51 "src/constants.anansi" interfaceIntrospectable :: T.InterfaceName interfaceIntrospectable = "org.freedesktop.DBus.Introspectable" @@ -51,8 +41,6 @@  interfacePeer :: T.InterfaceName interfacePeer = "org.freedesktop.DBus.Peer"--#line 64 "src/constants.anansi" errorFailed :: T.ErrorName errorFailed = "org.freedesktop.DBus.Error.Failed" 
hs/DBus/Introspection.hs view
@@ -1,7 +1,3 @@--#line 44 "src/introspection.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,13 +12,7 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 45 "src/introspection.anansi"--#line 52 "src/introduction.anansi" {-# LANGUAGE OverloadedStrings #-}--#line 46 "src/introspection.anansi" module DBus.Introspection 	( Object (..) 	, Interface (..)@@ -34,27 +24,15 @@ 	, toXML 	, fromXML 	) where--#line 56 "src/introduction.anansi" import Data.Text.Lazy (Text) import qualified Data.Text.Lazy as TL--#line 58 "src/introspection.anansi"--#line 105 "src/introspection.anansi" import qualified Data.XML.Types as X import qualified Text.XML.LibXML.SAX as SAX import Control.Monad.ST (runST) import qualified Data.STRef as ST--#line 253 "src/introspection.anansi" import Control.Monad ((>=>)) import Data.Maybe (fromMaybe, listToMaybe)--#line 59 "src/introspection.anansi" import qualified DBus.Types as T--#line 65 "src/introspection.anansi" data Object = Object T.ObjectPath [Interface] [Object] 	deriving (Show, Eq) @@ -75,14 +53,10 @@  data PropertyAccess = Read | Write 	deriving (Show, Eq)--#line 94 "src/introspection.anansi" fromXML :: T.ObjectPath -> Text -> Maybe Object fromXML path text = do 	root <- parseElement text 	parseRoot path root--#line 112 "src/introspection.anansi" parseElement :: Text -> Maybe X.Element parseElement text = runST $ do 	stackRef <- ST.newSTRef [([], [])]@@ -108,16 +82,12 @@ 	return $ case stack of 		[] -> Nothing 		(_, children'):_ -> Just $ head children'--#line 147 "src/introspection.anansi" parseRoot :: T.ObjectPath -> X.Element -> Maybe Object parseRoot defaultPath e = do 	path <- case getattrM "name" e of 		Nothing -> Just defaultPath 		Just x  -> T.mkObjectPath x 	parseObject path e--#line 160 "src/introspection.anansi" parseChild :: T.ObjectPath -> X.Element -> Maybe Object parseChild parentPath e = do 	let parentPath' = case T.strObjectPath parentPath of@@ -126,16 +96,12 @@ 	pathSegment <- getattrM "name" e 	path <- T.mkObjectPath $ TL.append parentPath' pathSegment 	parseObject path e--#line 174 "src/introspection.anansi" parseObject :: T.ObjectPath -> X.Element -> Maybe Object parseObject path e | X.elementName e == toName "node" = do 	interfaces <- children parseInterface (named "interface") e 	children' <- children (parseChild path) (named "node") e 	return $ Object path interfaces children' parseObject _ _ = Nothing--#line 185 "src/introspection.anansi" parseInterface :: X.Element -> Maybe Interface parseInterface e = do 	name <- T.mkInterfaceName =<< getattrM "name" e@@ -143,38 +109,28 @@ 	signals <- children parseSignal (named "signal") e 	properties <- children parseProperty (named "property") e 	return $ Interface name methods signals properties--#line 198 "src/introspection.anansi" parseMethod :: X.Element -> Maybe Method parseMethod e = do 	name <- T.mkMemberName =<< getattrM "name" e 	paramsIn <- children parseParameter (isParam ["in", ""]) e 	paramsOut <- children parseParameter (isParam ["out"]) e 	return $ Method name paramsIn paramsOut--#line 209 "src/introspection.anansi" parseSignal :: X.Element -> Maybe Signal parseSignal e = do 	name <- T.mkMemberName =<< getattrM "name" e 	params <- children parseParameter (isParam ["out", ""]) e 	return $ Signal name params--#line 219 "src/introspection.anansi" parseParameter :: X.Element -> Maybe Parameter parseParameter e = do 	let name = getattr "name" e 	sig <- parseType e 	return $ Parameter name sig--#line 227 "src/introspection.anansi" parseType :: X.Element -> Maybe T.Signature parseType e = do 	sig <- T.mkSignature =<< getattrM "type" e 	case T.signatureTypes sig of 		[_] -> Just sig 		_   -> Nothing--#line 239 "src/introspection.anansi" parseProperty :: X.Element -> Maybe Property parseProperty e = do 	let name = getattr "name" e@@ -186,8 +142,6 @@ 		"readwrite" -> Just [Read, Write] 		_           -> Nothing 	return $ Property name sig access--#line 258 "src/introspection.anansi" getattrM :: Text -> X.Element -> Maybe Text getattrM name = fmap attrText . listToMaybe . attrs where 	attrText = textContent . X.attributeContent@@ -209,8 +163,6 @@  toName :: Text -> X.Name toName t = X.Name t Nothing Nothing--#line 292 "src/introspection.anansi" newtype XmlWriter a = XmlWriter { runXmlWriter :: Maybe (a, Text) }  instance Monad XmlWriter where@@ -219,25 +171,17 @@ 		(a, w) <- runXmlWriter m 		(b, w') <- runXmlWriter (f a) 		return (b, TL.append w w')--#line 303 "src/introspection.anansi" tell :: Text -> XmlWriter () tell t = XmlWriter $ Just ((), t)--#line 308 "src/introspection.anansi" toXML :: Object -> Maybe Text toXML obj = do 	(_, text) <- runXmlWriter (writeRoot obj) 	return text--#line 315 "src/introspection.anansi" writeRoot :: Object -> XmlWriter () writeRoot obj@(Object path _ _) = do 	tell "<!DOCTYPE node PUBLIC '-//freedesktop//DTD D-BUS Object Introspection 1.0//EN'" 	tell " 'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'>\n" 	writeObject (T.strObjectPath path) obj--#line 323 "src/introspection.anansi" writeChild :: T.ObjectPath -> Object -> XmlWriter () writeChild parentPath obj@(Object path _ _) = write where 	path' = T.strObjectPath path@@ -251,58 +195,42 @@ 	write = case relpathM of 		Just relpath -> writeObject relpath obj 		Nothing -> XmlWriter Nothing--#line 339 "src/introspection.anansi" writeObject :: Text -> Object -> XmlWriter () writeObject path (Object fullPath interfaces children') = writeElement "node" 	[("name", path)] $ do 		mapM_ writeInterface interfaces 		mapM_ (writeChild fullPath) children'--#line 347 "src/introspection.anansi" writeInterface :: Interface -> XmlWriter () writeInterface (Interface name methods signals properties) = writeElement "interface" 	[("name", T.strInterfaceName name)] $ do 		mapM_ writeMethod methods 		mapM_ writeSignal signals 		mapM_ writeProperty properties--#line 356 "src/introspection.anansi" writeMethod :: Method -> XmlWriter () writeMethod (Method name inParams outParams) = writeElement "method" 	[("name", T.strMemberName name)] $ do 		mapM_ (writeParameter "in") inParams 		mapM_ (writeParameter "out") outParams--#line 364 "src/introspection.anansi" writeSignal :: Signal -> XmlWriter () writeSignal (Signal name params) = writeElement "signal" 	[("name", T.strMemberName name)] $ do 		mapM_ (writeParameter "out") params--#line 371 "src/introspection.anansi" writeParameter :: Text -> Parameter -> XmlWriter () writeParameter direction (Parameter name sig) = writeEmptyElement "arg" 	[ ("name", name) 	, ("type", T.strSignature sig) 	, ("direction", direction) 	]--#line 380 "src/introspection.anansi" writeProperty :: Property -> XmlWriter () writeProperty (Property name sig access) = writeEmptyElement "property" 	[ ("name", name) 	, ("type", T.strSignature sig) 	, ("access", strAccess access) 	]--#line 389 "src/introspection.anansi" strAccess :: [PropertyAccess] -> Text strAccess access = TL.append readS writeS where 	readS = if elem Read access then "read" else "" 	writeS = if elem Write access then "write" else ""--#line 396 "src/introspection.anansi" writeElement :: Text -> [(Text, Text)] -> XmlWriter () -> XmlWriter () writeElement name attrs content = do 	tell "<"@@ -313,16 +241,12 @@ 	tell "</" 	tell name 	tell ">"--#line 409 "src/introspection.anansi" writeEmptyElement :: Text -> [(Text, Text)] -> XmlWriter () writeEmptyElement name attrs = do 	tell "<" 	tell name 	mapM_ writeAttribute attrs 	tell "/>"--#line 418 "src/introspection.anansi" writeAttribute :: (Text, Text) -> XmlWriter () writeAttribute (name, content) = do 	tell " "@@ -330,8 +254,6 @@ 	tell "='" 	tell (escape content) 	tell "'"--#line 428 "src/introspection.anansi" escape :: Text -> Text escape = TL.concatMap escapeChar where 	escapeChar c = case c of
hs/DBus/MatchRule.hs view
@@ -1,7 +1,3 @@--#line 23 "src/match-rules.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,13 +12,7 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 24 "src/match-rules.anansi"--#line 52 "src/introduction.anansi" {-# LANGUAGE OverloadedStrings #-}--#line 25 "src/match-rules.anansi" module DBus.MatchRule ( 	  MatchRule (..) 	, MessageType (..)@@ -32,12 +22,8 @@ 	, matchAll 	, matches 	) where--#line 56 "src/introduction.anansi" import Data.Text.Lazy (Text) import qualified Data.Text.Lazy as TL--#line 35 "src/match-rules.anansi" import Data.Word (Word8) import Data.Maybe (fromMaybe, mapMaybe) import qualified Data.Set as Set@@ -45,8 +31,6 @@ import qualified DBus.Message as M import qualified DBus.Constants as C import DBus.Util (maybeIndex)--#line 45 "src/match-rules.anansi" -- | A match rule is a set of filters; most filters may have one possible -- value assigned, such as a single message type. The exception are parameter -- filters, which are limited in number only by the server implementation.@@ -61,8 +45,6 @@ 	, matchParameters  :: [ParameterValue] 	} 	deriving (Show)--#line 62 "src/match-rules.anansi" -- | Parameters may match against two types, strings and object paths. It's -- probably an error to have two values for the same parameter. -- @@ -74,8 +56,6 @@ 	= StringValue Word8 Text 	| PathValue Word8 T.ObjectPath 	deriving (Show, Eq)--#line 76 "src/match-rules.anansi" -- | The set of allowed message types to filter on is separate from the set -- supported for sending over the wire. This allows the server to support -- additional types not yet implemented in the library, or vice-versa.@@ -86,14 +66,8 @@ 	| Signal 	| Error 	deriving (Show, Eq)--#line 92 "src/match-rules.anansi"--#line 126 "src/api-docs.anansi" -- | Format a 'MatchRule' as the bus expects to receive in a call to -- @AddMatch@.--#line 93 "src/match-rules.anansi" formatRule :: MatchRule -> Text formatRule rule = TL.intercalate "," filters where 	filters = structureFilters ++ parameterFilters@@ -107,16 +81,12 @@ 		, ("destination", fmap T.strBusName . matchDestination) 		] 	unpack (key, mkValue) = formatFilter' key `fmap` mkValue rule--#line 109 "src/match-rules.anansi" formatParameter :: ParameterValue -> Text formatParameter (StringValue index x) = formatFilter' key x where 	key = "arg" `TL.append` TL.pack (show index) formatParameter (PathValue index x) = formatFilter' key value where 	key = "arg" `TL.append` TL.pack (show index) `TL.append` "path" 	value = T.strObjectPath x--#line 121 "src/match-rules.anansi" formatFilter' :: Text -> Text -> Text formatFilter' key value = TL.concat [key, "='", value, "'"] @@ -125,13 +95,7 @@ formatType MethodReturn = "method_return" formatType Signal       = "signal" formatType Error        = "error"--#line 135 "src/match-rules.anansi"--#line 131 "src/api-docs.anansi" -- | Build a 'M.MethodCall' for adding a match rule to the bus.--#line 136 "src/match-rules.anansi" addMatch :: MatchRule -> M.MethodCall addMatch rule = M.MethodCall 	C.dbusPath@@ -140,13 +104,7 @@ 	(Just C.dbusName) 	Set.empty 	[T.toVariant $ formatRule rule]--#line 150 "src/match-rules.anansi"--#line 135 "src/api-docs.anansi" -- | An empty match rule, which matches everything.--#line 151 "src/match-rules.anansi" matchAll :: MatchRule matchAll = MatchRule 	{ matchType        = Nothing@@ -157,14 +115,8 @@ 	, matchDestination = Nothing 	, matchParameters  = [] 	}--#line 167 "src/match-rules.anansi"--#line 139 "src/api-docs.anansi" -- | Whether a 'M.ReceivedMessage' matches a given rule. This is useful -- for implementing signal handlers.--#line 168 "src/match-rules.anansi" matches :: MatchRule -> M.ReceivedMessage -> Bool matches rule msg = and . mapMaybe ($ rule) $ 	[ fmap      (typeMatches msg) . matchType@@ -175,44 +127,32 @@ 	, fmap      (destMatches msg) . matchDestination 	, Just . parametersMatch msg  . matchParameters 	]--#line 181 "src/match-rules.anansi" typeMatches :: M.ReceivedMessage -> MessageType -> Bool typeMatches (M.ReceivedMethodCall   _ _ _) MethodCall   = True typeMatches (M.ReceivedMethodReturn _ _ _) MethodReturn = True typeMatches (M.ReceivedSignal       _ _ _) Signal       = True typeMatches (M.ReceivedError        _ _ _) Error        = True typeMatches _ _ = False--#line 190 "src/match-rules.anansi" senderMatches :: M.ReceivedMessage -> T.BusName -> Bool senderMatches msg name = M.receivedSender msg == Just name--#line 195 "src/match-rules.anansi" ifaceMatches :: M.ReceivedMessage -> T.InterfaceName -> Bool ifaceMatches (M.ReceivedMethodCall _ _ msg) name = 	Just name == M.methodCallInterface msg ifaceMatches (M.ReceivedSignal _ _ msg) name = 	name == M.signalInterface msg ifaceMatches _ _ = False--#line 204 "src/match-rules.anansi" memberMatches :: M.ReceivedMessage -> T.MemberName -> Bool memberMatches (M.ReceivedMethodCall _ _ msg) name = 	name == M.methodCallMember msg memberMatches (M.ReceivedSignal _ _ msg) name = 	name == M.signalMember msg memberMatches _ _ = False--#line 213 "src/match-rules.anansi" pathMatches :: M.ReceivedMessage -> T.ObjectPath -> Bool pathMatches (M.ReceivedMethodCall _ _ msg) path = 	path == M.methodCallPath msg pathMatches (M.ReceivedSignal _ _ msg) path = 	path == M.signalPath msg pathMatches _ _ = False--#line 222 "src/match-rules.anansi" destMatches :: M.ReceivedMessage -> T.BusName -> Bool destMatches (M.ReceivedMethodCall _ _ msg) name = 	Just name == M.methodCallDestination msg@@ -223,8 +163,6 @@ destMatches (M.ReceivedSignal _ _ msg) name = 	Just name == M.signalDestination msg destMatches _ _ = False--#line 235 "src/match-rules.anansi" parametersMatch :: M.ReceivedMessage -> [ParameterValue] -> Bool parametersMatch _ [] = True parametersMatch msg values = all validParam values where
hs/DBus/Message.hs view
@@ -1,7 +1,3 @@--#line 23 "src/messages.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,46 +12,24 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 24 "src/messages.anansi" module DBus.Message (--#line 51 "src/messages.anansi" 	Message ( messageFlags 	        , messageBody 	        )--#line 69 "src/messages.anansi" 	, Flag (..)--#line 124 "src/messages.anansi" 	, Serial 	, serialValue 	, firstSerial 	, nextSerial--#line 169 "src/messages.anansi" 	, MethodCall (..)--#line 206 "src/messages.anansi" 	, MethodReturn (..)--#line 256 "src/messages.anansi" 	, Error (..) 	, errorMessage--#line 296 "src/messages.anansi" 	, Signal (..)--#line 327 "src/messages.anansi" 	, Unknown (..)--#line 377 "src/messages.anansi" 	, ReceivedMessage (..) 	, receivedSerial 	, receivedSender 	, receivedBody--#line 26 "src/messages.anansi" 	) where import DBus.Message.Internal
hs/DBus/Message/Internal.hs view
@@ -1,7 +1,3 @@--#line 31 "src/messages.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,40 +12,24 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 32 "src/messages.anansi"--#line 52 "src/introduction.anansi" {-# LANGUAGE OverloadedStrings #-}--#line 33 "src/messages.anansi" module DBus.Message.Internal where--#line 56 "src/introduction.anansi" import Data.Text.Lazy (Text) import qualified Data.Text.Lazy as TL--#line 35 "src/messages.anansi" import qualified Data.Set as S import Data.Word (Word8, Word32) import Data.Maybe (fromMaybe) import qualified DBus.Types as T import DBus.Util (maybeIndex)--#line 43 "src/messages.anansi" class Message a where 	messageTypeCode     :: a -> Word8 	messageHeaderFields :: a -> [HeaderField] 	messageFlags        :: a -> S.Set Flag 	messageBody         :: a -> [T.Variant]--#line 62 "src/messages.anansi" data Flag 	= NoReplyExpected 	| NoAutoStart 	deriving (Show, Eq, Ord)--#line 80 "src/messages.anansi" data HeaderField 	= Path        T.ObjectPath 	| Interface   T.InterfaceName@@ -60,14 +40,8 @@ 	| Sender      T.BusName 	| Signature   T.Signature 	deriving (Show, Eq)--#line 98 "src/messages.anansi"--#line 152 "src/api-docs.anansi" -- | A value used to uniquely identify a particular message within a session. -- 'Serial's are 32-bit unsigned integers, and eventually wrap.--#line 99 "src/messages.anansi" newtype Serial = Serial { serialValue :: Word32 } 	deriving (Eq, Ord) @@ -77,19 +51,13 @@ instance T.Variable Serial where 	toVariant (Serial x) = T.toVariant x 	fromVariant = fmap Serial . T.fromVariant--#line 113 "src/messages.anansi" firstSerial :: Serial firstSerial = Serial 1  nextSerial :: Serial -> Serial nextSerial (Serial x) = Serial (x + 1)--#line 138 "src/messages.anansi" maybe' :: (a -> b) -> Maybe a -> [b] maybe' f = maybe [] (\x' -> [f x'])--#line 145 "src/messages.anansi" data MethodCall = MethodCall 	{ methodCallPath        :: T.ObjectPath 	, methodCallMember      :: T.MemberName@@ -111,8 +79,6 @@ 		, maybe' Interface . methodCallInterface $ m 		, maybe' Destination . methodCallDestination $ m 		]--#line 187 "src/messages.anansi" data MethodReturn = MethodReturn 	{ methodReturnSerial      :: Serial 	, methodReturnDestination :: Maybe T.BusName@@ -129,8 +95,6 @@ 		  ] 		, maybe' Destination . methodReturnDestination $ m 		]--#line 221 "src/messages.anansi" data Error = Error 	{ errorName        :: T.ErrorName 	, errorSerial      :: Serial@@ -149,8 +113,6 @@ 		  ] 		, maybe' Destination . errorDestination $ m 		]--#line 246 "src/messages.anansi" errorMessage :: Error -> Text errorMessage msg = fromMaybe "(no error message)" $ do 	field <- maybeIndex (errorBody msg) 0@@ -158,8 +120,6 @@ 	if TL.null text 		then Nothing 		else return text--#line 273 "src/messages.anansi" data Signal = Signal 	{ signalPath        :: T.ObjectPath 	, signalMember      :: T.MemberName@@ -180,23 +140,15 @@ 		  ] 		, maybe' Destination . signalDestination $ m 		]--#line 318 "src/messages.anansi" data Unknown = Unknown 	{ unknownType    :: Word8 	, unknownFlags   :: S.Set Flag 	, unknownBody    :: [T.Variant] 	} 	deriving (Show, Eq)--#line 339 "src/messages.anansi"--#line 157 "src/api-docs.anansi" -- | Not an actual message type, but a wrapper around messages received from -- the bus. Each value contains the message's 'Serial' and possibly the -- origin's 'T.BusName'--#line 340 "src/messages.anansi" data ReceivedMessage 	= ReceivedMethodCall   Serial (Maybe T.BusName) MethodCall 	| ReceivedMethodReturn Serial (Maybe T.BusName) MethodReturn@@ -204,24 +156,18 @@ 	| ReceivedSignal       Serial (Maybe T.BusName) Signal 	| ReceivedUnknown      Serial (Maybe T.BusName) Unknown 	deriving (Show, Eq)--#line 350 "src/messages.anansi" receivedSerial :: ReceivedMessage -> Serial receivedSerial (ReceivedMethodCall   s _ _) = s receivedSerial (ReceivedMethodReturn s _ _) = s receivedSerial (ReceivedError        s _ _) = s receivedSerial (ReceivedSignal       s _ _) = s receivedSerial (ReceivedUnknown      s _ _) = s--#line 359 "src/messages.anansi" receivedSender :: ReceivedMessage -> Maybe T.BusName receivedSender (ReceivedMethodCall   _ s _) = s receivedSender (ReceivedMethodReturn _ s _) = s receivedSender (ReceivedError        _ s _) = s receivedSender (ReceivedSignal       _ s _) = s receivedSender (ReceivedUnknown      _ s _) = s--#line 368 "src/messages.anansi" receivedBody :: ReceivedMessage -> [T.Variant] receivedBody (ReceivedMethodCall   _ _ x) = messageBody x receivedBody (ReceivedMethodReturn _ _ x) = messageBody x
hs/DBus/NameReservation.hs view
@@ -1,7 +1,3 @@--#line 22 "src/name-reservation.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,8 +12,6 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 23 "src/name-reservation.anansi" {-# LANGUAGE OverloadedStrings #-} module DBus.NameReservation 	( RequestNameFlag (..)@@ -35,27 +29,17 @@ import qualified DBus.Message as M import qualified DBus.Constants as C import DBus.Util (maybeIndex)--#line 43 "src/name-reservation.anansi" data RequestNameFlag 	= AllowReplacement 	| ReplaceExisting 	| DoNotQueue 	deriving (Show)--#line 51 "src/name-reservation.anansi" encodeFlags :: [RequestNameFlag] -> Word32 encodeFlags = foldr (.|.) 0 . map flagValue where 	flagValue AllowReplacement = 0x1 	flagValue ReplaceExisting  = 0x2 	flagValue DoNotQueue       = 0x4--#line 62 "src/name-reservation.anansi"--#line 144 "src/api-docs.anansi" -- | Build a 'M.MethodCall' for requesting a registered bus name.--#line 63 "src/name-reservation.anansi" requestName :: T.BusName -> [RequestNameFlag] -> M.MethodCall requestName name flags = M.MethodCall 	{ M.methodCallPath = C.dbusPath@@ -67,36 +51,24 @@ 		[ T.toVariant name 		, T.toVariant . encodeFlags $ flags] 	}--#line 77 "src/name-reservation.anansi" data RequestNameReply 	= PrimaryOwner 	| InQueue 	| Exists 	| AlreadyOwner 	deriving (Show)--#line 86 "src/name-reservation.anansi" mkRequestNameReply :: M.MethodReturn -> Maybe RequestNameReply mkRequestNameReply msg = 	maybeIndex (M.messageBody msg) 0 >>= 	T.fromVariant >>= 	decodeRequestReply--#line 94 "src/name-reservation.anansi" decodeRequestReply :: Word32 -> Maybe RequestNameReply decodeRequestReply 1 = Just PrimaryOwner decodeRequestReply 2 = Just InQueue decodeRequestReply 3 = Just Exists decodeRequestReply 4 = Just AlreadyOwner decodeRequestReply _ = Nothing--#line 103 "src/name-reservation.anansi"--#line 148 "src/api-docs.anansi" -- | Build a 'M.MethodCall' for releasing a registered bus name.--#line 104 "src/name-reservation.anansi" releaseName :: T.BusName -> M.MethodCall releaseName name = M.MethodCall 	{ M.methodCallPath = C.dbusPath@@ -106,22 +78,16 @@ 	, M.methodCallMember = "ReleaseName" 	, M.methodCallBody = [T.toVariant name] 	}--#line 116 "src/name-reservation.anansi" data ReleaseNameReply 	= Released 	| NonExistent 	| NotOwner 	deriving (Show)--#line 124 "src/name-reservation.anansi" mkReleaseNameReply :: M.MethodReturn -> Maybe ReleaseNameReply mkReleaseNameReply msg = 	maybeIndex (M.messageBody msg) 0 >>= 	T.fromVariant >>= 	decodeReleaseReply--#line 132 "src/name-reservation.anansi" decodeReleaseReply :: Word32 -> Maybe ReleaseNameReply decodeReleaseReply 1 = Just Released decodeReleaseReply 2 = Just NonExistent
hs/DBus/Types.hs view
@@ -1,7 +1,3 @@--#line 23 "src/types.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,106 +12,66 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 24 "src/types.anansi" module DBus.Types (--#line 100 "src/types.anansi" 	  -- * Available types 	  Type (..) 	, typeCode--#line 176 "src/types.anansi" 	  -- * Variants 	, Variant 	, Variable (..)--#line 248 "src/types.anansi" 	, variantType--#line 442 "src/types.anansi" 	  -- * Signatures 	, Signature 	, signatureTypes 	, strSignature--#line 714 "src/types.anansi" 	, mkSignature 	, mkSignature_--#line 789 "src/types.anansi" 	  -- * Object paths 	, ObjectPath 	, strObjectPath 	, mkObjectPath 	, mkObjectPath_--#line 839 "src/types.anansi" 	  -- * Arrays 	, Array 	, arrayType 	, arrayItems--#line 885 "src/types.anansi" 	, toArray 	, fromArray 	, arrayFromItems--#line 903 "src/types.anansi" 	, arrayToBytes 	, arrayFromBytes--#line 967 "src/types.anansi" 	  -- * Dictionaries 	, Dictionary 	, dictionaryItems 	, dictionaryKeyType 	, dictionaryValueType--#line 1044 "src/types.anansi" 	, toDictionary 	, fromDictionary 	, dictionaryFromItems--#line 1116 "src/types.anansi" 	, dictionaryToArray 	, arrayToDictionary--#line 1133 "src/types.anansi" 	  -- * Structures 	, Structure (..)--#line 1174 "src/types.anansi" 	-- * Names--#line 1204 "src/types.anansi" 	  -- ** Bus names 	, BusName 	, strBusName 	, mkBusName 	, mkBusName_--#line 1257 "src/types.anansi" 	  -- ** Interface names 	, InterfaceName 	, strInterfaceName 	, mkInterfaceName 	, mkInterfaceName_--#line 1298 "src/types.anansi" 	  -- ** Error names 	, ErrorName 	, strErrorName 	, mkErrorName 	, mkErrorName_--#line 1334 "src/types.anansi" 	  -- ** Member names 	, MemberName 	, strMemberName 	, mkMemberName 	, mkMemberName_--#line 26 "src/types.anansi" 	) where import DBus.Types.Internal
hs/DBus/Types/Internal.cpphs view
@@ -1,7 +1,3 @@--#line 31 "src/types.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,76 +12,34 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 32 "src/types.anansi"--#line 52 "src/introduction.anansi" {-# LANGUAGE OverloadedStrings #-}--#line 33 "src/types.anansi"--#line 372 "src/types.anansi" {-# LANGUAGE TypeSynonymInstances #-}--#line 34 "src/types.anansi" module DBus.Types.Internal where--#line 56 "src/introduction.anansi" import Data.Text.Lazy (Text) import qualified Data.Text.Lazy as TL--#line 36 "src/types.anansi"--#line 325 "src/types.anansi" import Data.Word (Word8, Word16, Word32, Word64) import Data.Int (Int16, Int32, Int64)--#line 359 "src/types.anansi" import qualified Data.Text as T--#line 433 "src/types.anansi" import Data.Ord (comparing)--#line 454 "src/types.anansi" import Data.Text.Encoding (decodeUtf8)--#line 513 "src/types.anansi" import qualified Data.ByteString.Unsafe as B import qualified Foreign as F import System.IO.Unsafe (unsafePerformIO)--#line 684 "src/types.anansi" import Data.Text.Lazy.Encoding (encodeUtf8)--#line 697 "src/types.anansi" import DBus.Util (mkUnsafe) import qualified Data.String as String--#line 772 "src/types.anansi" import Text.ParserCombinators.Parsec ((<|>)) import qualified Text.ParserCombinators.Parsec as P import DBus.Util (checkLength, parseMaybe)--#line 978 "src/types.anansi" import Data.List (intercalate)--#line 995 "src/types.anansi" import Control.Monad (unless)--#line 1017 "src/types.anansi" import Control.Arrow ((***)) import qualified Data.Map as Map--#line 1029 "src/types.anansi" import Control.Monad (forM)--#line 37 "src/types.anansi" import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as B8 import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Char8 as BL8--#line 52 "src/types.anansi" data Type 	= DBusBoolean 	| DBusByte@@ -104,14 +58,8 @@ 	| DBusDictionary Type Type 	| DBusStructure [Type] 	deriving (Show, Eq)--#line 73 "src/types.anansi"--#line 27 "src/api-docs.anansi" -- | \"Atomic\" types are any which can't contain any other types. Only -- atomic types may be used as dictionary keys.--#line 74 "src/types.anansi" isAtomicType :: Type -> Bool isAtomicType DBusBoolean    = True isAtomicType DBusByte       = True@@ -126,17 +74,9 @@ isAtomicType DBusSignature  = True isAtomicType DBusObjectPath = True isAtomicType _              = False--#line 94 "src/types.anansi"--#line 32 "src/api-docs.anansi" -- | Every type has an associated type code; a textual representation of -- the type, useful for debugging.--#line 95 "src/types.anansi" typeCode :: Type -> Text--#line 458 "src/types.anansi" typeCode t = TL.fromChunks [decodeUtf8 $ typeCodeB t]  typeCodeB :: Type -> B.ByteString@@ -153,25 +93,13 @@ typeCodeB DBusSignature  = "g" typeCodeB DBusObjectPath = "o" typeCodeB DBusVariant    = "v"--#line 480 "src/types.anansi" typeCodeB (DBusArray t) = B8.cons 'a' $ typeCodeB t--#line 487 "src/types.anansi" typeCodeB (DBusDictionary k v) = B.concat ["a{", typeCodeB k, typeCodeB v, "}"]--#line 495 "src/types.anansi" typeCodeB (DBusStructure ts) = B.concat $ 	["("] ++ map typeCodeB ts ++ [")"]--#line 150 "src/types.anansi"--#line 37 "src/api-docs.anansi" -- | 'Variant's may contain any other built-in D-Bus value. Besides -- representing native @VARIANT@ values, they allow type-safe storage and -- deconstruction of heterogeneous collections.--#line 151 "src/types.anansi" data Variant 	= VarBoxBool Bool 	| VarBoxWord8 Word8@@ -194,8 +122,6 @@ class Variable a where 	toVariant :: a -> Variant 	fromVariant :: Variant -> Maybe a--#line 186 "src/types.anansi" instance Show Variant where 	showsPrec d var = showParen (d > 10) full where 		full = s "Variant " . shows code . s " " . valueStr@@ -221,15 +147,9 @@ 	(VarBoxArray x) -> showsPrec d x 	(VarBoxDictionary x) -> showsPrec d x 	(VarBoxStructure x) -> showsPrec d x--#line 218 "src/types.anansi"--#line 43 "src/api-docs.anansi" -- | Every variant is strongly-typed; that is, the type of its contained -- value is known at all times. This function retrieves that type, so that -- the correct cast can be used to retrieve the value.--#line 219 "src/types.anansi" variantType :: Variant -> Type variantType var = case var of 	(VarBoxBool _) -> DBusBoolean@@ -256,19 +176,13 @@  variantSignature :: Variant -> Maybe Signature variantSignature = mkBytesSignature . typeCodeB . variantType--#line 255 "src/types.anansi" #define INSTANCE_VARIABLE(TYPE) \ 	instance Variable TYPE where \ 		{ toVariant = VarBox/**/TYPE \ 		; fromVariant (VarBox/**/TYPE x) = Just x \ 		; fromVariant _ = Nothing \ 		}--#line 266 "src/types.anansi" INSTANCE_VARIABLE(Variant)--#line 330 "src/types.anansi" INSTANCE_VARIABLE(Bool) INSTANCE_VARIABLE(Word8) INSTANCE_VARIABLE(Int16)@@ -278,24 +192,16 @@ INSTANCE_VARIABLE(Word32) INSTANCE_VARIABLE(Word64) INSTANCE_VARIABLE(Double)--#line 348 "src/types.anansi" instance Variable TL.Text where 	toVariant = VarBoxString 	fromVariant (VarBoxString x) = Just x 	fromVariant _ = Nothing--#line 363 "src/types.anansi" instance Variable T.Text where 	toVariant = toVariant . TL.fromChunks . (:[]) 	fromVariant = fmap (T.concat . TL.toChunks) . fromVariant--#line 376 "src/types.anansi" instance Variable String where 	toVariant = toVariant . TL.pack 	fromVariant = fmap TL.unpack . fromVariant--#line 409 "src/types.anansi" INSTANCE_VARIABLE(Signature) data Signature = Signature { signatureTypes :: [Type] } 	deriving (Eq)@@ -303,23 +209,15 @@ instance Show Signature where 	showsPrec d x = showParen (d > 10) $ 		showString "Signature " . shows (strSignature x)--#line 422 "src/types.anansi" bytesSignature :: Signature -> B.ByteString bytesSignature (Signature ts) = B.concat $ map typeCodeB ts  strSignature :: Signature -> Text strSignature (Signature ts) = TL.concat $ map typeCode ts--#line 437 "src/types.anansi" instance Ord Signature where 	compare = comparing strSignature--#line 529 "src/types.anansi" mkBytesSignature :: B.ByteString -> Maybe Signature mkBytesSignature = unsafePerformIO . flip B.unsafeUseAsCStringLen io where--#line 542 "src/types.anansi" 	parseAtom c yes no = case c of 		0x62 -> yes DBusBoolean 		0x79 -> yes DBusByte@@ -338,10 +236,6 @@ 	fast c = parseAtom c (\t -> Just (Signature [t])) $ case c of 		0x76 -> Just (Signature [DBusVariant]) 		_ -> Nothing--#line 532 "src/types.anansi"--#line 563 "src/types.anansi" 	slow :: F.Ptr Word8 -> Int -> IO (Maybe Signature) 	slow buf len = loop [] 0 where 		loop acc ii | ii >= len = return . Just . Signature $ reverse acc@@ -366,8 +260,6 @@ 						Nothing -> return Nothing 				 				_ -> return Nothing--#line 590 "src/types.anansi" 	structure :: F.Ptr Word8 -> Int -> Int -> IO (Maybe (Int, Type)) 	structure buf len = loop [] where 		loop _ ii | ii >= len = return Nothing@@ -395,8 +287,6 @@ 						Nothing -> return Nothing 				 				_ -> return Nothing--#line 620 "src/types.anansi" 	array :: F.Ptr Word8 -> Int -> Int -> IO (Maybe (Int, Type)) 	array _   len ii | ii >= len = return Nothing 	array buf len ii = do@@ -423,8 +313,6 @@ 					Nothing -> return Nothing 			 			_ -> return Nothing--#line 649 "src/types.anansi" 	dict :: F.Ptr Word8 -> Int -> Int -> IO (Maybe (Int, Type)) 	dict _   len ii | ii + 1 >= len = return Nothing 	dict buf len ii = do@@ -455,33 +343,23 @@ 						if c3 == 0x7D then Just () else Nothing 						t1 <- mt1 						Just (ii' + 1, DBusDictionary t1 t2)--#line 533 "src/types.anansi" 	 	io (cstr, len) = case len of 		0 -> return $ Just $ Signature [] 		1 -> fmap fast $ F.peek cstr 		_ | len <= 255 -> slow (F.castPtr cstr) len 		_ -> return Nothing--#line 688 "src/types.anansi" mkSignature :: Text -> Maybe Signature mkSignature = mkBytesSignature . B.concat . BL.toChunks . encodeUtf8--#line 702 "src/types.anansi" mkSignature_ :: Text -> Signature mkSignature_ = mkUnsafe "signature" mkSignature  instance String.IsString Signature where 	fromString = mkUnsafe "signature" mkBytesSignature . BL8.pack--#line 724 "src/types.anansi" maybeValidType :: Type -> Maybe () maybeValidType t = if B.length (typeCodeB t) > 255 	then Nothing 	else Just ()--#line 745 "src/types.anansi" INSTANCE_VARIABLE(ObjectPath) newtype ObjectPath = ObjectPath 	{ strObjectPath :: Text@@ -494,8 +372,6 @@  instance String.IsString ObjectPath where 	fromString = mkObjectPath_ . TL.pack--#line 778 "src/types.anansi" mkObjectPath :: Text -> Maybe ObjectPath mkObjectPath s = parseMaybe path' (TL.unpack s) where 	c = P.oneOf $ ['a'..'z'] ++ ['A'..'Z'] ++ ['0'..'9'] ++ "_"@@ -504,20 +380,14 @@  mkObjectPath_ :: Text -> ObjectPath mkObjectPath_ = mkUnsafe "object path" mkObjectPath--#line 822 "src/types.anansi" INSTANCE_VARIABLE(Array) data Array 	= VariantArray Type [Variant] 	| ByteArray BL.ByteString 	deriving (Eq) --#line 49 "src/api-docs.anansi" -- | This is the type contained within the array, not the type of the array -- itself.--#line 829 "src/types.anansi" arrayType :: Array -> Type arrayType (VariantArray t _) = t arrayType (ByteArray _) = DBusByte@@ -525,8 +395,6 @@ arrayItems :: Array -> [Variant] arrayItems (VariantArray _ xs) = xs arrayItems (ByteArray xs) = map toVariant $ BL.unpack xs--#line 849 "src/types.anansi" instance Show Array where 	showsPrec d array = showParen (d > 10) $ 		s "Array " . showSig . s " [" . s valueString . s "]" where@@ -534,8 +402,6 @@ 			showSig = shows . typeCode . arrayType $ array 			showVar var = showsPrecVar 0 var "" 			valueString = intercalate ", " $ map showVar $ arrayItems array--#line 863 "src/types.anansi" arrayFromItems :: Type -> [Variant] -> Maybe Array arrayFromItems DBusByte vs = fmap (ByteArray . BL.pack) (mapM fromVariant vs) @@ -544,33 +410,23 @@ 	if all (\x -> variantType x == t) vs 		then Just $ VariantArray t vs 		else Nothing--#line 877 "src/types.anansi" toArray :: Variable a => Type -> [a] -> Maybe Array toArray t = arrayFromItems t . map toVariant  fromArray :: Variable a => Array -> Maybe [a] fromArray = mapM fromVariant . arrayItems--#line 894 "src/types.anansi" arrayToBytes :: Array -> Maybe BL.ByteString arrayToBytes (ByteArray x) = Just x arrayToBytes _             = Nothing  arrayFromBytes :: BL.ByteString -> Array arrayFromBytes = ByteArray--#line 911 "src/types.anansi" instance Variable BL.ByteString where 	toVariant = toVariant . arrayFromBytes 	fromVariant x = fromVariant x >>= arrayToBytes--#line 917 "src/types.anansi" instance Variable B.ByteString where 	toVariant x = toVariant . arrayFromBytes $ BL.fromChunks [x] 	fromVariant = fmap (B.concat . BL.toChunks) . fromVariant--#line 956 "src/types.anansi" INSTANCE_VARIABLE(Dictionary)  data Dictionary = Dictionary@@ -579,8 +435,6 @@ 	, dictionaryItems     :: [(Variant, Variant)] 	} 	deriving (Eq)--#line 982 "src/types.anansi" instance Show Dictionary where 	showsPrec d (Dictionary kt vt pairs) = showParen (d > 10) $ 		s "Dictionary " . showSig . s " {" . s valueString . s "}" where@@ -588,8 +442,6 @@ 			showSig = shows $ TL.append (typeCode kt) (typeCode vt) 			valueString = intercalate ", " $ map showPair pairs 			showPair (k, v) = (showsPrecVar 0 k . showString " -> " . showsPrecVar 0 v) ""--#line 999 "src/types.anansi" dictionaryFromItems :: Type -> Type -> [(Variant, Variant)] -> Maybe Dictionary dictionaryFromItems kt vt pairs = do 	unless (isAtomicType kt) Nothing@@ -601,14 +453,10 @@ 	if all sameType pairs 		then Just $ Dictionary kt vt pairs 		else Nothing--#line 1022 "src/types.anansi" toDictionary :: (Variable a, Variable b) => Type -> Type -> Map.Map a b              -> Maybe Dictionary toDictionary kt vt = dictionaryFromItems kt vt . pairs where 	pairs = map (toVariant *** toVariant) . Map.toList--#line 1033 "src/types.anansi" fromDictionary :: (Variable a, Ord a, Variable b) => Dictionary                -> Maybe (Map.Map a b) fromDictionary (Dictionary _ _ vs) = do@@ -617,15 +465,11 @@ 		v' <- fromVariant v 		return (k', v') 	return $ Map.fromList pairs--#line 1093 "src/types.anansi" dictionaryToArray :: Dictionary -> Array dictionaryToArray (Dictionary kt vt items) = array where 	Just array = toArray itemType structs 	itemType = DBusStructure [kt, vt] 	structs = [Structure [k, v] | (k, v) <- items]--#line 1101 "src/types.anansi" arrayToDictionary :: Array -> Maybe Dictionary arrayToDictionary array = do 	let toPair x = do@@ -638,14 +482,10 @@ 		_                      -> Nothing 	pairs <- mapM toPair $ arrayItems array 	dictionaryFromItems kt vt pairs--#line 1126 "src/types.anansi" INSTANCE_VARIABLE(Structure)  data Structure = Structure [Variant] 	deriving (Show, Eq)--#line 1153 "src/types.anansi" #define NAME_TYPE(TYPE, NAME) \ 	newtype TYPE = TYPE {str/**/TYPE :: Text} \ 		deriving (Eq, Ord); \@@ -664,8 +504,6 @@ 		                                                \ 	mk/**/TYPE/**/_ :: Text -> TYPE; \ 	mk/**/TYPE/**/_ = mkUnsafe NAME mk/**/TYPE--#line 1190 "src/types.anansi" NAME_TYPE(BusName, "bus name")  mkBusName :: Text -> Maybe BusName@@ -677,8 +515,6 @@ 	wellKnown = elems c 	elems start = elem' start >> P.many1 (P.char '.' >> elem' start) 	elem' start = P.oneOf start >> P.many (P.oneOf c')--#line 1245 "src/types.anansi" NAME_TYPE(InterfaceName, "interface name")  mkInterfaceName :: Text -> Maybe InterfaceName@@ -688,14 +524,10 @@ 	element = P.oneOf c >> P.many (P.oneOf c') 	name = element >> P.many1 (P.char '.' >> element) 	parser = name >> P.eof >> return (InterfaceName s)--#line 1291 "src/types.anansi" NAME_TYPE(ErrorName, "error name")  mkErrorName :: Text -> Maybe ErrorName mkErrorName = fmap (ErrorName . strInterfaceName) . mkInterfaceName--#line 1323 "src/types.anansi" NAME_TYPE(MemberName, "member name")  mkMemberName :: Text -> Maybe MemberName
hs/DBus/UUID.hs view
@@ -1,7 +1,3 @@--#line 22 "src/util.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,19 +12,13 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 23 "src/util.anansi" module DBus.UUID 	( UUID 	, toHex 	, fromHex 	) where--#line 56 "src/introduction.anansi" import Data.Text.Lazy (Text) import qualified Data.Text.Lazy as TL--#line 29 "src/util.anansi"  newtype UUID = UUID Text -- TODO: (Word64, Word64)? 	deriving (Eq)
hs/DBus/Util.hs view
@@ -1,7 +1,3 @@--#line 58 "src/util.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,8 +12,6 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 59 "src/util.anansi" module DBus.Util where import Text.ParserCombinators.Parsec (Parser, parse) import Data.Char (digitToInt)
hs/DBus/Util/MonadError.hs view
@@ -1,7 +1,3 @@--#line 117 "src/util.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,8 +12,6 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 118 "src/util.anansi" module DBus.Util.MonadError 	( ErrorM (..) 	, ErrorT (..)
hs/DBus/Wire.hs view
@@ -1,7 +1,3 @@--#line 21 "src/wire.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,26 +12,12 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 22 "src/wire.anansi" module DBus.Wire (--#line 54 "src/wire.anansi" 	  Endianness (..)--#line 238 "src/wire.anansi" 	, MarshalError (..)--#line 442 "src/wire.anansi" 	, UnmarshalError (..)--#line 921 "src/wire.anansi" 	, marshalMessage--#line 991 "src/wire.anansi" 	, unmarshalMessage--#line 24 "src/wire.anansi" 	) where import DBus.Wire.Internal import DBus.Wire.Marshal
hs/DBus/Wire/Internal.hs view
@@ -1,7 +1,3 @@--#line 31 "src/wire.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,13 +12,9 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 32 "src/wire.anansi" module DBus.Wire.Internal where import Data.Word (Word8, Word64) import qualified DBus.Types as T--#line 40 "src/wire.anansi" data Endianness = LittleEndian | BigEndian 	deriving (Show, Eq) @@ -34,11 +26,7 @@ decodeEndianness 108 = Just LittleEndian decodeEndianness 66  = Just BigEndian decodeEndianness _   = Nothing--#line 69 "src/wire.anansi" alignment :: T.Type -> Word8--#line 451 "src/wire.anansi" alignment T.DBusByte    = 1 alignment T.DBusWord16  = 2 alignment T.DBusWord32  = 4@@ -47,30 +35,14 @@ alignment T.DBusInt32   = 4 alignment T.DBusInt64   = 8 alignment T.DBusDouble  = 8--#line 548 "src/wire.anansi" alignment T.DBusBoolean = 4--#line 629 "src/wire.anansi" alignment T.DBusString     = 4 alignment T.DBusObjectPath = 4--#line 671 "src/wire.anansi" alignment T.DBusSignature  = 1--#line 687 "src/wire.anansi" alignment (T.DBusArray _) = 4--#line 769 "src/wire.anansi" alignment (T.DBusDictionary _ _) = 4--#line 786 "src/wire.anansi" alignment (T.DBusStructure _) = 8--#line 804 "src/wire.anansi" alignment T.DBusVariant = 1--#line 71 "src/wire.anansi"  padding :: Word64 -> Word8 -> Word64 padding current count = required where
hs/DBus/Wire/Marshal.hs view
@@ -1,7 +1,3 @@--#line 89 "src/wire.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,40 +12,20 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 90 "src/wire.anansi" {-# LANGUAGE TypeFamilies #-} module DBus.Wire.Marshal where--#line 56 "src/introduction.anansi" import Data.Text.Lazy (Text) import qualified Data.Text.Lazy as TL--#line 93 "src/wire.anansi"--#line 105 "src/wire.anansi" import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as L import qualified Data.Binary.Builder as B--#line 514 "src/wire.anansi" import Data.Binary.Put (runPut) import qualified Data.Binary.IEEE754 as IEEE--#line 599 "src/wire.anansi" import DBus.Wire.Unicode (maybeEncodeUtf8)--#line 703 "src/wire.anansi" import qualified DBus.Constants as C--#line 830 "src/wire.anansi" import qualified DBus.Message.Internal as M--#line 845 "src/wire.anansi" import Data.Bits ((.|.)) import qualified Data.Set as Set--#line 94 "src/wire.anansi" import DBus.Wire.Internal import Control.Monad (when) import Data.Maybe (fromJust)@@ -58,8 +34,6 @@  import qualified DBus.Types as T import qualified DBus.Types.Internal as T--#line 111 "src/wire.anansi" data MarshalState = MarshalState {-# UNPACK #-} !B.Builder {-# UNPACK #-} !Word64  data MarshalR a = MarshalRL MarshalError | MarshalRR a {-# UNPACK #-} !MarshalState@@ -91,18 +65,12 @@ {-# INLINE putState #-} putState :: MarshalState -> MarshalM () putState s = MarshalM $ \_ _ -> MarshalRR () s--#line 148 "src/wire.anansi" runMarshal :: Marshal -> Endianness -> Either MarshalError L.ByteString runMarshal m e = case unMarshalM m e (MarshalState B.empty 0) of 	MarshalRL err -> Left err 	MarshalRR _ (MarshalState builder _) -> Right $ B.toLazyByteString builder--#line 155 "src/wire.anansi" marshal :: T.Variant -> Marshal marshal v = case v of--#line 483 "src/wire.anansi" 	T.VarBoxWord8  x -> marshalWord8 x 	T.VarBoxWord16 x -> marshalBuilder 2 B.putWord16be B.putWord16le x 	T.VarBoxWord32 x -> marshalWord32 x@@ -110,32 +78,16 @@ 	T.VarBoxInt16  x -> marshalBuilder 2 B.putWord16be B.putWord16le $ fromIntegral x 	T.VarBoxInt32  x -> marshalBuilder 4 B.putWord32be B.putWord32le $ fromIntegral x 	T.VarBoxInt64  x -> marshalBuilder 8 B.putWord64be B.putWord64le $ fromIntegral x--#line 523 "src/wire.anansi" 	T.VarBoxDouble x -> marshalDouble x--#line 552 "src/wire.anansi" 	T.VarBoxBool x -> marshalWord32 $ if x then 1 else 0--#line 634 "src/wire.anansi" 	T.VarBoxString x -> marshalText x 	T.VarBoxObjectPath x -> marshalText . T.strObjectPath $ x--#line 675 "src/wire.anansi" 	T.VarBoxSignature x -> marshalSignature x--#line 691 "src/wire.anansi" 	T.VarBoxArray x -> marshalArray x--#line 773 "src/wire.anansi" 	T.VarBoxDictionary x -> marshalArray (T.dictionaryToArray x)--#line 790 "src/wire.anansi" 	T.VarBoxStructure (T.Structure vs) -> do 		pad 8 		mapM_ marshal vs--#line 808 "src/wire.anansi" 	T.VarBoxVariant x -> do 		let textSig = T.typeCode . T.variantType $ x 		sig <- case T.variantSignature x of@@ -143,29 +95,21 @@ 			Nothing -> throwError $ InvalidVariantSignature textSig 		marshalSignature sig 		marshal x--#line 163 "src/wire.anansi" appendS :: BS.ByteString -> Marshal appendS bytes = MarshalM $ \_ (MarshalState builder count) -> let 	builder' = B.append builder $ B.fromByteString bytes 	count' = count + fromIntegral (BS.length bytes) 	in MarshalRR () (MarshalState builder' count')--#line 171 "src/wire.anansi" appendL :: L.ByteString -> Marshal appendL bytes = MarshalM $ \_ (MarshalState builder count) -> let 	builder' = B.append builder $ B.fromLazyByteString bytes 	count' = count + fromIntegral (L.length bytes) 	in MarshalRR () (MarshalState builder' count')--#line 179 "src/wire.anansi" pad :: Word8 -> Marshal pad count = MarshalM $ \e s@(MarshalState _ existing) -> let 	padding' = fromIntegral $ padding existing count 	bytes = BS.replicate padding' 0 	in unMarshalM (appendS bytes) e s--#line 190 "src/wire.anansi" marshalBuilder :: Word8 -> (a -> B.Builder) -> (a -> B.Builder) -> a -> Marshal marshalBuilder size be le x = do 	pad size@@ -175,8 +119,6 @@ 			LittleEndian -> le x 		size' = fromIntegral size 		in MarshalRR () (MarshalState builder' (count + size'))--#line 216 "src/wire.anansi" data MarshalError 	= MessageTooLong Word64 	| ArrayTooLong Word64@@ -196,19 +138,13 @@ 		["Invalid variant signature: ", show x] 	show (InvalidText x) = concat 		["Text cannot be marshaled: ", show x]--#line 465 "src/wire.anansi" marshalWord32 :: Word32 -> Marshal marshalWord32 = marshalBuilder 4 B.putWord32be B.putWord32le--#line 470 "src/wire.anansi" {-# INLINE marshalWord8 #-} marshalWord8 :: Word8 -> Marshal marshalWord8 x = MarshalM $ \_ (MarshalState builder count) -> let 	builder' = B.append builder $ B.singleton x 	in MarshalRR () (MarshalState builder' (count + 1))--#line 527 "src/wire.anansi" marshalDouble :: Double -> Marshal marshalDouble x = do 	pad 8@@ -218,8 +154,6 @@ 			LittleEndian -> IEEE.putFloat64le 		bytes = runPut $ put x 		in unMarshalM (appendL bytes) e s--#line 603 "src/wire.anansi" marshalText :: Text -> Marshal marshalText x = do 	bytes <- case maybeEncodeUtf8 x of@@ -230,8 +164,6 @@ 	marshalWord32 . fromIntegral . L.length $ bytes 	appendL bytes 	marshalWord8 0--#line 651 "src/wire.anansi" marshalSignature :: T.Signature -> Marshal marshalSignature x = do 	let bytes = T.bytesSignature x@@ -239,8 +171,6 @@ 	marshalWord8 size 	appendS bytes 	marshalWord8 0--#line 707 "src/wire.anansi" marshalArray :: T.Array -> Marshal marshalArray x = do 	(arrayPadding, arrayBytes) <- getArrayBytes (T.arrayType x) x@@ -250,13 +180,9 @@ 	marshalWord32 $ fromIntegral arrayLen 	appendL $ L.replicate arrayPadding 0 	appendL arrayBytes--#line 719 "src/wire.anansi" getArrayBytes :: T.Type -> T.Array -> MarshalM (Int64, L.ByteString) getArrayBytes T.DBusByte x = return (0, bytes) where 	Just bytes = T.arrayToBytes x--#line 725 "src/wire.anansi" getArrayBytes itemType x = do 	let vs = T.arrayItems x 	s <- getState@@ -271,14 +197,10 @@ 	 	putState s 	return (paddingSize, itemBytes)--#line 850 "src/wire.anansi" encodeFlags :: Set.Set M.Flag -> Word8 encodeFlags flags = foldr (.|.) 0 $ map flagValue $ Set.toList flags where 	flagValue M.NoReplyExpected = 0x1 	flagValue M.NoAutoStart     = 0x2--#line 868 "src/wire.anansi" encodeField :: M.HeaderField -> T.Structure encodeField (M.Path x)        = encodeField' 1 x encodeField (M.Interface x)   = encodeField' 2 x@@ -294,15 +216,9 @@ 	[ T.toVariant code 	, T.toVariant $ T.toVariant x 	]--#line 925 "src/wire.anansi"--#line 163 "src/api-docs.anansi" -- | Convert a 'M.Message' into a 'L.ByteString'. Although unusual, it is -- possible for marshaling to fail -- if this occurs, an appropriate error -- will be returned instead.--#line 926 "src/wire.anansi" marshalMessage :: M.Message a => Endianness -> M.Serial -> a                -> Either MarshalError L.ByteString marshalMessage e serial msg = runMarshal marshaler e where@@ -320,8 +236,6 @@ 		pad 8 		appendL bodyBytes 		checkMaximumSize--#line 946 "src/wire.anansi" checkBodySig :: [T.Variant] -> MarshalM T.Signature checkBodySig vs = let 	textSig = TL.concat . map (T.typeCode . T.variantType) $ vs@@ -330,8 +244,6 @@ 	in case T.mkBytesSignature bytesSig of 		Just x -> return x 		Nothing -> invalid--#line 957 "src/wire.anansi" marshalHeader :: M.Message a => a -> M.Serial -> T.Signature -> Word32               -> Marshal marshalHeader msg serial bodySig bodyLength = do@@ -344,12 +256,8 @@ 	let fieldType = T.DBusStructure [T.DBusByte, T.DBusVariant] 	marshalArray . fromJust . T.toArray fieldType 	        $ map encodeField fields--#line 972 "src/wire.anansi" marshalEndianness :: Endianness -> Marshal marshalEndianness = marshal . T.toVariant . encodeEndianness--#line 977 "src/wire.anansi" checkMaximumSize :: Marshal checkMaximumSize = do 	(MarshalState _ messageLength) <- getState
hs/DBus/Wire/Unicode.hs view
@@ -1,7 +1,3 @@--#line 574 "src/wire.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,8 +12,6 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 575 "src/wire.anansi" module DBus.Wire.Unicode 	( maybeEncodeUtf8 	, maybeDecodeUtf8) where
hs/DBus/Wire/Unmarshal.hs view
@@ -1,7 +1,3 @@--#line 246 "src/wire.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,48 +12,22 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 247 "src/wire.anansi"--#line 52 "src/introduction.anansi" {-# LANGUAGE OverloadedStrings #-}--#line 248 "src/wire.anansi" {-# LANGUAGE TypeFamilies #-} module DBus.Wire.Unmarshal where--#line 56 "src/introduction.anansi" import Data.Text.Lazy (Text) import qualified Data.Text.Lazy as TL--#line 251 "src/wire.anansi"--#line 262 "src/wire.anansi" import Control.Monad (liftM) import qualified DBus.Util.MonadError as E import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL--#line 364 "src/wire.anansi" import qualified Data.Binary.Get as G--#line 519 "src/wire.anansi" import qualified Data.Binary.IEEE754 as IEEE--#line 616 "src/wire.anansi" import DBus.Wire.Unicode (maybeDecodeUtf8)--#line 834 "src/wire.anansi" import qualified DBus.Message.Internal as M--#line 840 "src/wire.anansi" import Data.Bits ((.&.)) import qualified Data.Set as Set--#line 987 "src/wire.anansi" import qualified DBus.Constants as C--#line 252 "src/wire.anansi" import Control.Monad (when, unless) import Data.Maybe (fromJust, listToMaybe, fromMaybe) import Data.Word (Word8, Word32, Word64)@@ -65,8 +35,6 @@  import DBus.Wire.Internal import qualified DBus.Types.Internal as T--#line 272 "src/wire.anansi" data UnmarshalState = UnmarshalState BL.ByteString {-# UNPACK #-} !Word64  data UnmarshalR a = UnmarshalRL UnmarshalError | UnmarshalRR a {-# UNPACK #-} !UnmarshalState@@ -97,20 +65,14 @@ {-# INLINE putState #-} putState :: UnmarshalState -> Unmarshal () putState s = Unmarshal $ \_ _ -> UnmarshalRR () s--#line 305 "src/wire.anansi" runUnmarshal :: Unmarshal a -> Endianness -> BL.ByteString -> Either UnmarshalError a runUnmarshal m e bytes = case unUnmarshal m e (UnmarshalState bytes 0) of 	UnmarshalRL err -> Left err 	UnmarshalRR a _ -> Right a--#line 312 "src/wire.anansi" unmarshal :: T.Signature -> Unmarshal [T.Variant] unmarshal = mapM unmarshalType . T.signatureTypes  unmarshalType :: T.Type -> Unmarshal T.Variant--#line 493 "src/wire.anansi" unmarshalType T.DBusByte = liftM (T.toVariant . BL.head) $ consume 1 unmarshalType T.DBusWord16 = unmarshalGet' 2 G.getWord16be G.getWord16le unmarshalType T.DBusWord32 = unmarshalGet' 4 G.getWord32be G.getWord32le@@ -127,41 +89,25 @@ unmarshalType T.DBusInt64  = do 	x <- unmarshalGet 8 G.getWord64be G.getWord64le 	return . T.toVariant $ (fromIntegral x :: Int64)--#line 539 "src/wire.anansi" unmarshalType T.DBusDouble = unmarshalGet' 8 IEEE.getFloat64be IEEE.getFloat64le--#line 556 "src/wire.anansi" unmarshalType T.DBusBoolean = unmarshalWord32 >>= 	fromMaybeU' "boolean" (\x -> case x of 		0 -> Just False 		1 -> Just True 		_ -> Nothing)--#line 639 "src/wire.anansi" unmarshalType T.DBusString = liftM T.toVariant unmarshalText  unmarshalType T.DBusObjectPath = unmarshalText >>= 	fromMaybeU' "object path" T.mkObjectPath--#line 679 "src/wire.anansi" unmarshalType T.DBusSignature = liftM T.toVariant unmarshalSignature--#line 695 "src/wire.anansi" unmarshalType (T.DBusArray t) = T.toVariant `liftM` unmarshalArray t--#line 777 "src/wire.anansi" unmarshalType (T.DBusDictionary kt vt) = do 	let pairType = T.DBusStructure [kt, vt] 	array <- unmarshalArray pairType 	fromMaybeU' "dictionary" T.arrayToDictionary array--#line 796 "src/wire.anansi" unmarshalType (T.DBusStructure ts) = do 	skipPadding 8 	liftM (T.toVariant . T.Structure) $ mapM unmarshalType ts--#line 818 "src/wire.anansi" unmarshalType T.DBusVariant = do 	let getType sig = case T.signatureTypes sig of 		[t] -> Just t@@ -169,8 +115,6 @@ 	 	t <- fromMaybeU "variant signature" getType =<< unmarshalSignature 	T.toVariant `liftM` unmarshalType t--#line 322 "src/wire.anansi" {-# INLINE consume #-} consume :: Word64 -> Unmarshal BL.ByteString consume count = Unmarshal $ \_ (UnmarshalState bytes offset) -> let@@ -179,24 +123,18 @@ 	in if BL.length x == count' 		then UnmarshalRR x (UnmarshalState bytes' (offset + count)) 		else UnmarshalRL $ UnexpectedEOF offset--#line 333 "src/wire.anansi" skipPadding :: Word8 -> Unmarshal () skipPadding count = do 	(UnmarshalState _ offset) <- getState 	bytes <- consume $ padding offset count 	unless (BL.all (== 0) bytes) $ 		throwError $ InvalidPadding offset--#line 342 "src/wire.anansi" skipTerminator :: Unmarshal () skipTerminator = do 	(UnmarshalState _ offset) <- getState 	bytes <- consume 1 	unless (BL.all (== 0) bytes) $ 		throwError $ MissingTerminator offset--#line 351 "src/wire.anansi" fromMaybeU :: Show a => Text -> (a -> Maybe b) -> a -> Unmarshal b fromMaybeU label f x = case f x of 	Just x' -> return x'@@ -207,8 +145,6 @@ fromMaybeU' label f x = do 	x' <- fromMaybeU label f x 	return $ T.toVariant x'--#line 368 "src/wire.anansi" unmarshalGet :: Word8 -> G.Get a -> G.Get a -> Unmarshal a unmarshalGet count be le = do 	skipPadding count@@ -223,8 +159,6 @@ unmarshalGet' :: T.Variable a => Word8 -> G.Get a -> G.Get a               -> Unmarshal T.Variant unmarshalGet' count be le = T.toVariant `liftM` unmarshalGet count be le--#line 385 "src/wire.anansi" untilM :: Monad m => m Bool -> m a -> m [a] untilM test comp = do 	done <- test@@ -234,8 +168,6 @@ 			x <- comp 			xs <- untilM test comp 			return $ x:xs--#line 412 "src/wire.anansi" data UnmarshalError 	= UnsupportedProtocolVersion Word8 	| UnexpectedEOF Word64@@ -263,20 +195,14 @@ 	show (MissingTerminator pos) = concat 		["Missing NUL terminator at position ", show pos] 	show ArraySizeMismatch = "Array size mismatch"--#line 478 "src/wire.anansi" unmarshalWord32 :: Unmarshal Word32 unmarshalWord32 = unmarshalGet 4 G.getWord32be G.getWord32le--#line 620 "src/wire.anansi" unmarshalText :: Unmarshal Text unmarshalText = do 	byteCount <- unmarshalWord32 	bytes <- consume . fromIntegral $ byteCount 	skipTerminator 	fromMaybeU "text" maybeDecodeUtf8 bytes--#line 661 "src/wire.anansi" unmarshalSignature :: Unmarshal T.Signature unmarshalSignature = do 	byteCount <- BL.head `liftM` consume 1@@ -284,14 +210,10 @@ 	skipTerminator 	let bytes = B.concat $ BL.toChunks lazy 	fromMaybeU "signature" T.mkBytesSignature bytes--#line 744 "src/wire.anansi" unmarshalArray :: T.Type -> Unmarshal T.Array unmarshalArray T.DBusByte = do 	byteCount <- unmarshalWord32 	T.arrayFromBytes `liftM` consume (fromIntegral byteCount)--#line 751 "src/wire.anansi" unmarshalArray itemType = do 	let getOffset = do 		(UnmarshalState _ o) <- getState@@ -305,16 +227,12 @@ 	when (end' > end) $ 		throwError ArraySizeMismatch 	fromMaybeU "array" (T.arrayFromItems itemType) vs--#line 857 "src/wire.anansi" decodeFlags :: Word8 -> Set.Set M.Flag decodeFlags word = Set.fromList flags where 	flagSet = [ (0x1, M.NoReplyExpected) 	          , (0x2, M.NoAutoStart) 	          ] 	flags = flagSet >>= \(x, y) -> [y | word .&. x > 0]--#line 886 "src/wire.anansi" decodeField :: T.Structure             -> E.ErrorM UnmarshalError [M.HeaderField] decodeField struct = case unpackField struct of@@ -333,42 +251,26 @@ decodeField' x f label = case T.fromVariant x of 	Just x' -> return [f x'] 	Nothing -> E.throwErrorM $ InvalidHeaderField label x--#line 907 "src/wire.anansi" unpackField :: T.Structure -> (Word8, T.Variant) unpackField struct = (c', v') where 	T.Structure [c, v] = struct 	c' = fromJust . T.fromVariant $ c 	v' = fromJust . T.fromVariant $ v--#line 995 "src/wire.anansi"--#line 169 "src/api-docs.anansi" -- | Read bytes from a monad until a complete message has been received.--#line 996 "src/wire.anansi" unmarshalMessage :: Monad m => (Word32 -> m BL.ByteString)                  -> m (Either UnmarshalError M.ReceivedMessage) unmarshalMessage getBytes' = E.runErrorT $ do 	let getBytes = E.ErrorT . liftM Right . getBytes' 	--#line 1011 "src/wire.anansi" 	let fixedSig = "yyyyuuu" 	fixedBytes <- getBytes 16--#line 1020 "src/wire.anansi" 	let messageVersion = BL.index fixedBytes 3 	when (messageVersion /= C.protocolVersion) $ 		E.throwErrorT $ UnsupportedProtocolVersion messageVersion--#line 1028 "src/wire.anansi" 	let eByte = BL.index fixedBytes 0 	endianness <- case decodeEndianness eByte of 		Just x' -> return x' 		Nothing -> E.throwErrorT . Invalid "endianness" . TL.pack . show $ eByte--#line 1038 "src/wire.anansi" 	let unmarshal' x bytes = case runUnmarshal (unmarshal x) endianness bytes of 		Right x' -> return x' 		Left  e  -> E.throwErrorT e@@ -377,57 +279,31 @@ 	let flags = decodeFlags . fromJust . T.fromVariant $ fixed !! 2 	let bodyLength = fromJust . T.fromVariant $ fixed !! 4 	let serial = fromJust . T.fromVariant $ fixed !! 5--#line 1053 "src/wire.anansi" 	let fieldByteCount = fromJust . T.fromVariant $ fixed !! 6--#line 1002 "src/wire.anansi"--#line 1060 "src/wire.anansi" 	let headerSig  = "yyyyuua(yv)" 	fieldBytes <- getBytes fieldByteCount 	let headerBytes = BL.append fixedBytes fieldBytes 	header <- unmarshal' headerSig headerBytes--#line 1069 "src/wire.anansi" 	let fieldArray = fromJust . T.fromVariant $ header !! 6 	let fieldStructures = fromJust . T.fromArray $ fieldArray 	fields <- case E.runErrorM $ concat `liftM` mapM decodeField fieldStructures of 		Left err -> E.throwErrorT err 		Right x -> return x--#line 1003 "src/wire.anansi"--#line 1080 "src/wire.anansi" 	let bodyPadding = padding (fromIntegral fieldByteCount + 16) 8 	getBytes . fromIntegral $ bodyPadding--#line 1091 "src/wire.anansi" 	let bodySig = findBodySignature fields--#line 1097 "src/wire.anansi" 	bodyBytes <- getBytes bodyLength 	body <- unmarshal' bodySig bodyBytes--#line 1004 "src/wire.anansi"--#line 1105 "src/wire.anansi" 	y <- case E.runErrorM $ buildReceivedMessage typeCode fields of 		Right x -> return x 		Left err -> E.throwErrorT $ MissingHeaderField err 	return $ y serial flags body--#line 1085 "src/wire.anansi" findBodySignature :: [M.HeaderField] -> T.Signature findBodySignature fields = fromMaybe "" signature where 	signature = listToMaybe [x | M.Signature x <- fields]--#line 1114 "src/wire.anansi" buildReceivedMessage :: Word8 -> [M.HeaderField] -> E.ErrorM Text                         (M.Serial -> (Set.Set M.Flag) -> [T.Variant]                          -> M.ReceivedMessage)--#line 1122 "src/wire.anansi" buildReceivedMessage 1 fields = do 	path <- require "path" [x | M.Path x <- fields] 	member <- require "member name" [x | M.Member x <- fields]@@ -437,8 +313,6 @@ 		sender = listToMaybe [x | M.Sender x <- fields] 		msg = M.MethodCall path member iface dest flags body 		in M.ReceivedMethodCall serial sender msg--#line 1136 "src/wire.anansi" buildReceivedMessage 2 fields = do 	replySerial <- require "reply serial" [x | M.ReplySerial x <- fields] 	return $ \serial _ body -> let@@ -446,8 +320,6 @@ 		sender = listToMaybe [x | M.Sender x <- fields] 		msg = M.MethodReturn replySerial dest body 		in M.ReceivedMethodReturn serial sender msg--#line 1148 "src/wire.anansi" buildReceivedMessage 3 fields = do 	name <- require "error name" [x | M.ErrorName x <- fields] 	replySerial <- require "reply serial" [x | M.ReplySerial x <- fields]@@ -456,8 +328,6 @@ 		sender = listToMaybe [x | M.Sender x <- fields] 		msg = M.Error name replySerial dest body 		in M.ReceivedError serial sender msg--#line 1161 "src/wire.anansi" buildReceivedMessage 4 fields = do 	path <- require "path" [x | M.Path x <- fields] 	member <- require "member name" [x | M.Member x <- fields]@@ -467,14 +337,10 @@ 		sender = listToMaybe [x | M.Sender x <- fields] 		msg = M.Signal path member iface dest body 		in M.ReceivedSignal serial sender msg--#line 1175 "src/wire.anansi" buildReceivedMessage typeCode fields = return $ \serial flags body -> let 	sender = listToMaybe [x | M.Sender x <- fields] 	msg = M.Unknown typeCode flags body 	in M.ReceivedUnknown serial sender msg--#line 1182 "src/wire.anansi" require :: Text -> [a] -> E.ErrorM Text a require _     (x:_) = return x require label _     = E.throwErrorM label
hs/Tests.hs view
@@ -1,7 +1,3 @@--#line 64 "src/introduction.anansi"--#line 30 "src/introduction.anansi" -- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com> --  -- This program is free software: you can redistribute it and/or modify@@ -16,16 +12,8 @@ --  -- You should have received a copy of the GNU General Public License -- along with this program.  If not, see <http://www.gnu.org/licenses/>.--#line 65 "src/introduction.anansi"--#line 52 "src/introduction.anansi" {-# LANGUAGE OverloadedStrings #-}--#line 66 "src/introduction.anansi" module Main (tests, main) where--#line 159 "src/util.anansi" import Test.QuickCheck import qualified Test.Framework as F import Test.Framework.Providers.QuickCheck2 (testProperty)@@ -52,12 +40,8 @@ import DBus.Wire.Unmarshal import qualified DBus.Introspection as I -#line 68 "src/introduction.anansi"- tests :: [F.Test] tests = [ F.testGroup "dummy" []--#line 384 "src/types.anansi" 	, F.testGroup "String" 		[ testProperty "String -> strict Text" 			$ funEq (fromVariant . toVariant) (Just . T.pack)@@ -72,27 +56,19 @@ 		, testProperty "Strict Text <- lazy Text" 			$ funEq (fromVariant . toVariant) (Just . T.pack . TL.unpack) 		]--#line 736 "src/types.anansi" 	, F.testGroup "Signature" 		[ testProperty "Signature identity" 			$ funEq (mkSignature . strSignature) Just 		]--#line 806 "src/types.anansi" 	, F.testGroup "ObjectPath" 		[ testProperty "ObjectPath identity" 			$ funEq (mkObjectPath . strObjectPath) Just 		]--#line 942 "src/types.anansi" 	, F.testGroup "Array" 		[ testProperty "Array identity" 			$ \x -> Just x == arrayFromItems (arrayType x) (arrayItems x) 		, testProperty "Array homogeneity" prop_ArrayHomogeneous 		]--#line 1071 "src/types.anansi" 	, F.testGroup "Dictionary" 		[ testProperty "Dictionary identity" 			$ \x -> Just x == dictionaryFromItems@@ -106,32 +82,22 @@ 		, testProperty "Dictionary <-> Array conversion" 			$ funEq (arrayToDictionary . dictionaryToArray) Just 		]--#line 1232 "src/types.anansi" 	, F.testGroup "BusName" 		[ testProperty "BusName identity" 			$ funEq (mkBusName . strBusName) Just 		]--#line 1279 "src/types.anansi" 	, F.testGroup "InterfaceName" 		[ testProperty "InterfaceName identity" 			$ funEq (mkInterfaceName . strInterfaceName) Just 		]--#line 1311 "src/types.anansi" 	, F.testGroup "ErrorName" 		[ testProperty "ErrorName identity" 			$ funEq (mkErrorName . strErrorName) Just 		]--#line 1354 "src/types.anansi" 	, F.testGroup "MemberName" 		[ testProperty "MemberName identity" 			$ funEq (mkMemberName . strMemberName) Just 		]--#line 1223 "src/wire.anansi" 	, F.testGroup "Wire format" 		[ testProperty "Marshal -> Ummarshal" prop_Unmarshal 		, F.testGroup "Messages"@@ -141,8 +107,6 @@ 			, testProperty "Signals" prop_WireSignal 			] 		]--#line 177 "src/addresses.anansi" 	, F.testGroup "Addresses" 		[ testProperty "Address identity" 			$ \x -> mkAddresses (strAddress x) == Just [x]@@ -173,8 +137,6 @@ 			, test "no param" $ isNothing . mkAddresses $ "a:," 			] 		]--#line 507 "src/introspection.anansi" 	, F.testGroup "Introspection" 		[ testProperty "Generate -> Parse" 			$ \x@(I.Object path _ _) -> let@@ -183,14 +145,10 @@ 			parsed = I.fromXML path xml' 			in isJust xml ==> I.fromXML path xml' == Just x 		]--#line 72 "src/introduction.anansi" 	]  main :: IO () main = F.defaultMain tests--#line 106 "src/types.anansi" instance Arbitrary Type where 	arbitrary = oneof [atomicType, containerType] @@ -221,8 +179,6 @@ 			return $ DBusDictionary kt vt 		2 -> fmap DBusStructure $ halfSized arbitrary 		3 -> return DBusVariant--#line 272 "src/types.anansi" instance Arbitrary Variant where 	arbitrary = arbitrary >>= genVariant @@ -244,20 +200,14 @@ 	(DBusDictionary _ _) -> fmap toVariant (arbitrary :: Gen Dictionary) 	(DBusStructure _)    -> fmap toVariant (arbitrary :: Gen Structure) 	DBusVariant          -> fmap toVariant (arbitrary :: Gen Variant)--#line 731 "src/types.anansi" instance Arbitrary Signature where 	arbitrary = sizedText 255 $ fmap (TL.concat . map typeCode) arbitrary--#line 797 "src/types.anansi" instance Arbitrary ObjectPath where 	arbitrary = fmap (mkObjectPath_ . TL.pack) path' where 		c = ['a'..'z'] ++ ['A'..'Z'] ++ ['0'..'9'] ++ "_" 		path = fmap (intercalate "/" . ([] :)) genElements 		path' = frequency [(1, return "/"), (9, path)] 		genElements = atLeast 1 (atLeast 1 (elements c))--#line 926 "src/types.anansi" instance Arbitrary Array where 	arbitrary = do 		t <- atomicType@@ -271,8 +221,6 @@ 	firstType = if null types 		then DBusByte 		else head types--#line 1053 "src/types.anansi" instance Arbitrary Dictionary where 	arbitrary = do 		kt <- atomicType@@ -288,12 +236,8 @@ 	vType = dictionaryValueType x 	correctType (k, v) = variantType k == kType && 	                     variantType v == vType--#line 1138 "src/types.anansi" instance Arbitrary Structure where 	arbitrary = fmap Structure $ halfSized arbitrary--#line 1212 "src/types.anansi" instance Arbitrary BusName where 	arbitrary = sizedText 255 (oneof [unique, wellKnown]) where 		c = ['a'..'z'] ++ ['A'..'Z'] ++ "_-"@@ -311,8 +255,6 @@ 			x <- elements start 			xs <- atLeast 0 (elements c') 			return (x:xs)--#line 1265 "src/types.anansi" instance Arbitrary InterfaceName where 	arbitrary = sizedText 255 genName where 		c = ['a'..'z'] ++ ['A'..'Z'] ++ "_"@@ -324,12 +266,8 @@ 			x <- elements c 			xs <- atLeast 0 (elements c') 			return (x:xs)--#line 1306 "src/types.anansi" instance Arbitrary ErrorName where 	arbitrary = fmap (mkErrorName_ . strInterfaceName) arbitrary--#line 1342 "src/types.anansi" instance Arbitrary MemberName where 	arbitrary = sizedText 255 genName where 		c = ['a'..'z'] ++ ['A'..'Z'] ++ "_"@@ -339,16 +277,10 @@ 			x <- elements c 			xs <- atLeast 0 (elements c') 			return . TL.pack $ (x:xs)--#line 73 "src/messages.anansi" instance Arbitrary Flag where 	arbitrary = elements [NoReplyExpected, NoAutoStart]--#line 131 "src/messages.anansi" instance Arbitrary Serial where 	arbitrary = fmap Serial arbitrary--#line 173 "src/messages.anansi" instance Arbitrary MethodCall where 	arbitrary = do 		path   <- arbitrary@@ -358,16 +290,12 @@ 		flags  <- fmap Set.fromList arbitrary 		Structure body <- arbitrary 		return $ MethodCall path member iface dest flags body--#line 210 "src/messages.anansi" instance Arbitrary MethodReturn where 	arbitrary = do 		serial <- arbitrary 		dest   <- arbitrary 		Structure body <- arbitrary 		return $ MethodReturn serial dest body--#line 261 "src/messages.anansi" instance Arbitrary Error where 	arbitrary = do 		name   <- arbitrary@@ -375,8 +303,6 @@ 		dest   <- arbitrary 		Structure body <- arbitrary 		return $ Error name serial dest body--#line 300 "src/messages.anansi" instance Arbitrary Signal where 	arbitrary = do 		path   <- arbitrary@@ -385,12 +311,8 @@ 		dest   <- arbitrary 		Structure body <- arbitrary 		return $ Signal path member iface dest body--#line 58 "src/wire.anansi" instance Arbitrary Endianness where 	arbitrary = elements [LittleEndian, BigEndian]--#line 1188 "src/wire.anansi" prop_Unmarshal :: Endianness -> Variant -> Property prop_Unmarshal e x = valid ==> unmarshaled == Right [x] where 	sig = mkSignature . typeCode . variantType $ x@@ -423,8 +345,6 @@  prop_WireSignal e serial msg = prop_MarshalMessage e serial msg 	$ ReceivedSignal serial Nothing msg--#line 138 "src/addresses.anansi" instance Arbitrary Address where 	arbitrary = genAddress where 		optional = ['0'..'9'] ++ ['a'..'z'] ++ ['A'..'Z'] ++ "-_/\\*."@@ -461,8 +381,6 @@ 			let addrStr = concat [m, ":", params, extraSemicolon] 			let Just [addr] = mkAddresses $ TL.pack addrStr 			return addr--#line 442 "src/introspection.anansi" subObject :: ObjectPath -> Gen I.Object subObject parentPath = sized $ \n -> resize (min n 4) $ do 	let nonRoot = do@@ -525,8 +443,6 @@ 			[[], [I.Read], [I.Write], 			 [I.Read, I.Write]] 		return $ I.Property (TL.pack name) sig access--#line 187 "src/util.anansi" halfSized :: Gen a -> Gen a halfSized gen = sized $ \n -> if n > 0 then 	resize (n `div` 2) gen@@ -550,41 +466,9 @@  isRight :: Either a b -> Bool isRight = either (const False) (const True)--#line 216 "src/util.anansi" test :: Testable a => F.TestName -> a -> F.Test test name prop = F.plusTestOptions options (testProperty name prop) where 	options = F.TestOptions Nothing (Just 1) Nothing Nothing--#line 225 "src/util.anansi"-instance Arbitrary Word8 where-	arbitrary = arbitraryBoundedIntegral-	shrink    = shrinkIntegral--instance Arbitrary Word16 where-	arbitrary = arbitraryBoundedIntegral-	shrink    = shrinkIntegral--instance Arbitrary Word32 where-	arbitrary = arbitraryBoundedIntegral-	shrink    = shrinkIntegral--instance Arbitrary Word64 where-	arbitrary = arbitraryBoundedIntegral-	shrink    = shrinkIntegral--instance Arbitrary Int16 where-	arbitrary = arbitraryBoundedIntegral-	shrink    = shrinkIntegral--instance Arbitrary Int32 where-	arbitrary = arbitraryBoundedIntegral-	shrink    = shrinkIntegral--instance Arbitrary Int64 where-	arbitrary = arbitraryBoundedIntegral-	shrink    = shrinkIntegral- instance Arbitrary T.Text where 	arbitrary = fmap T.pack arbitrary 
src/util.anansi view
@@ -222,34 +222,6 @@ variants of {\tt Text}, so define them here.  :f Tests.hs-instance Arbitrary Word8 where-	arbitrary = arbitraryBoundedIntegral-	shrink    = shrinkIntegral--instance Arbitrary Word16 where-	arbitrary = arbitraryBoundedIntegral-	shrink    = shrinkIntegral--instance Arbitrary Word32 where-	arbitrary = arbitraryBoundedIntegral-	shrink    = shrinkIntegral--instance Arbitrary Word64 where-	arbitrary = arbitraryBoundedIntegral-	shrink    = shrinkIntegral--instance Arbitrary Int16 where-	arbitrary = arbitraryBoundedIntegral-	shrink    = shrinkIntegral--instance Arbitrary Int32 where-	arbitrary = arbitraryBoundedIntegral-	shrink    = shrinkIntegral--instance Arbitrary Int64 where-	arbitrary = arbitraryBoundedIntegral-	shrink    = shrinkIntegral- instance Arbitrary T.Text where 	arbitrary = fmap T.pack arbitrary