From: Duncan C. <dun...@us...> - 2005-04-08 13:40:20
|
Update of /cvsroot/gtk2hs/gtk2hs/glib/System/Glib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15809/glib/System/Glib Modified Files: GList.chs Log Message: Add readGList function needed for some new modules. Remove unused ptrToInt function. Index: GList.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/glib/System/Glib/GList.chs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- GList.chs 8 Jan 2005 17:45:06 -0000 1.1 +++ GList.chs 8 Apr 2005 13:40:10 -0000 1.2 @@ -25,8 +25,8 @@ -- * The same for GSList. -- module System.Glib.GList ( - ptrToInt, GList, + readGList, fromGList, toGList, GSList, @@ -46,12 +46,18 @@ -- methods --- Convert a pointer to an Int. +-- Turn a GList into a list of pointers but don't destroy the list. -- -ptrToInt :: Ptr a -> Int -ptrToInt ptr = minusPtr ptr nullPtr +readGList :: GList -> IO [Ptr a] +readGList glist + | glist==nullPtr = return [] + | otherwise = do + x <- {#get GList->data#} glist + glist' <- {#get GList->next#} glist + xs <- readGList glist' + return (castPtr x:xs) --- Turn a GList into a list of pointers. +-- Turn a GList into a list of pointers (freeing the GList in the process). -- fromGList :: GList -> IO [Ptr a] fromGList glist = do @@ -76,7 +82,7 @@ xs <- readGSList gslist' return (castPtr x:xs) --- Turn a GSList into a list of pointers. +-- Turn a GSList into a list of pointers (freeing the GSList in the process). -- fromGSList :: GSList -> IO [Ptr a] fromGSList gslist |