From: Wolfgang T. <wth...@us...> - 2006-03-17 04:57:39
|
Update of /cvsroot/hoc/hoc/HOC/HOC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12412/HOC/HOC Modified Files: Arguments.hs Log Message: Add utility function withExportedArray :: (HOC.Arguments.ObjCArgument a b) => [a] -> (GHC.Ptr.Ptr b -> IO c) -> IO c Index: Arguments.hs =================================================================== RCS file: /cvsroot/hoc/hoc/HOC/HOC/Arguments.hs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Arguments.hs 27 Sep 2005 11:55:22 -0000 1.5 +++ Arguments.hs 17 Mar 2006 04:57:37 -0000 1.6 @@ -1,3 +1,4 @@ +{-# OPTIONS -fallow-undecidable-instances #-} module HOC.Arguments where import HOC.Base @@ -6,6 +7,7 @@ import Foreign.Storable import Foreign.ForeignPtr import Foreign.Ptr +import Foreign.Marshal.Array import System.IO.Unsafe(unsafePerformIO) import HOC.TH @@ -27,6 +29,15 @@ importArgument = return -} +withExportedArray :: ObjCArgument a b => [a] -> (Ptr b -> IO c) -> IO c +withExportedArray l a = withExportedList l $ \l' -> withArray l' a + where + withExportedList [] a = a [] + withExportedList (x:xs) a + = withExportedArgument x $ + \x' -> withExportedList xs $ + \xs' -> a (x':xs') + declareStorableObjCArgument :: TypeQ -> String -> Q [Dec] {- This is what we'd like to do. |