From: Duncan C. <dun...@wo...> - 2007-12-10 03:40:15
|
Sun Dec 9 19:36:36 PST 2007 Duncan Coutts <du...@ha...> * Fix PixbufData's MArray instance for ghc-6.8 The MArray class gained a getNumElements method in ghc 6.8 Also take the opportunity to tidy things up a bit. hunk ./gtk/Graphics/UI/Gtk/Gdk/Pixbuf.chs.pp 124 -import Graphics.UI.Gtk.Gdk.PixbufData ( PixbufData(PixbufData), - insertBounds ) +import Graphics.UI.Gtk.Gdk.PixbufData ( PixbufData, mkPixbufData ) hunk ./gtk/Graphics/UI/Gtk/Gdk/Pixbuf.chs.pp 126 -{# context lib="gdk-pixbuf" prefix="gdk" #} +{# context prefix="gdk" #} hunk ./gtk/Graphics/UI/Gtk/Gdk/Pixbuf.chs.pp 201 -pixbufGetPixels :: (Ix i, Num i, Storable e) => Pixbuf -> IO (PixbufData i e) +pixbufGetPixels :: Storable e => Pixbuf -> IO (PixbufData Int e) hunk ./gtk/Graphics/UI/Gtk/Gdk/Pixbuf.chs.pp 211 - return (insertBounds bytes (PixbufData pb pixPtr undefined)) + return (mkPixbufData pb pixPtr bytes) hunk ./gtk/Graphics/UI/Gtk/Gdk/PixbufData.hs.pp 30 - PixbufData(PixbufData), - insertBounds + PixbufData, + mkPixbufData hunk ./gtk/Graphics/UI/Gtk/Gdk/PixbufData.hs.pp 44 +#if __GLASGOW_HASKELL__ >= 608 + ,getNumElements +#endif hunk ./gtk/Graphics/UI/Gtk/Gdk/PixbufData.hs.pp 53 -data Ix i => PixbufData i e = PixbufData Pixbuf (Ptr e) (i,i) +data Ix i => PixbufData i e = PixbufData !Pixbuf + {-# UNPACK #-} !(Ptr e) + !(i,i) + {-# UNPACK #-} !Int + +mkPixbufData :: Storable e => Pixbuf -> Ptr e -> Int -> PixbufData Int e +mkPixbufData pb (ptr :: Ptr e) size = + PixbufData pb ptr (0, count) count + where count = fromIntegral (size `div` sizeOf (undefined :: e)) hunk ./gtk/Graphics/UI/Gtk/Gdk/PixbufData.hs.pp 73 - unsafeRead (PixbufData (Pixbuf pb) pixPtr _) idx = do + unsafeRead (PixbufData (Pixbuf pb) pixPtr _ _) idx = do hunk ./gtk/Graphics/UI/Gtk/Gdk/PixbufData.hs.pp 78 - unsafeWrite (PixbufData (Pixbuf pb) pixPtr _) idx elem = do + unsafeWrite (PixbufData (Pixbuf pb) pixPtr _ _) idx elem = do hunk ./gtk/Graphics/UI/Gtk/Gdk/PixbufData.hs.pp 83 - getBounds (PixbufData pb ptr bd) = return bd + getBounds (PixbufData _ _ bd _) = return bd +#endif +#if __GLASGOW_HASKELL__ >= 608 + {-# INLINE getNumElements #-} + getNumElements (PixbufData _ _ _ count) = return count hunk ./gtk/Graphics/UI/Gtk/Gdk/PixbufData.hs.pp 89 - --- Insert bounds into a PixbufData. -insertBounds :: (Num i, Ix i, Storable e) => Int -> [_$_] - PixbufData i e -> PixbufData i e -insertBounds size ((PixbufData pb ptr _) :: PixbufData i e) = - PixbufData pb ptr (0, fromIntegral (size `div` sizeOf (undefined :: e))) |