module Graphics.Text.Font.Choose.ObjectSet where
import Foreign.Ptr (Ptr)
import Foreign.C.String (CString, withCString)
import Control.Monad (forM)
import Control.Exception (bracket)
type ObjectSet = [String]
------
--- LowLevel
------
data ObjectSet'
type ObjectSet_ = Ptr ObjectSet'
withObjectSet :: ObjectSet -> (ObjectSet_ -> IO a) -> IO a
withObjectSet objs cb = withNewObjectSet $ \objs' -> do
forM objs $ \obj -> withCString obj $ fcObjectSetAdd objs'
cb objs'
foreign import ccall "FcObjectSetAdd" fcObjectSetAdd ::
ObjectSet_ -> CString -> IO Bool
withNewObjectSet :: (ObjectSet_ -> IO a) -> IO a
withNewObjectSet cb = bracket fcObjectSetCreate fcObjectSetDestroy cb
foreign import ccall "FcObjectSetCreate" fcObjectSetCreate :: IO ObjectSet_
foreign import ccall "FcObjectSetDestroy" fcObjectSetDestroy :: ObjectSet_ -> IO ()