diff options
author | Picca Frédéric-Emmanuel <picca@debian.org> | 2019-02-02 12:55:46 +0100 |
---|---|---|
committer | Picca Frédéric-Emmanuel <picca@debian.org> | 2019-02-02 12:55:46 +0100 |
commit | 30098174e89f801160dc7656642eaaf34822a1f5 (patch) | |
tree | da8d68c1328bc641139c5724a08ca1f76e57bac5 /contrib/haskell/src/Hkl/C/EngineList.hsc | |
parent | b97bde539e3e5568f29ee50211f8decdea0a8aaf (diff) | |
parent | b3cce9a78f1862dcaeeebc6784b70b3f116e583d (diff) |
Update upstream source from tag 'upstream/5.0.0.2456'
Update to upstream version '5.0.0.2456'
with Debian dir fdd1364b79a1292c1ac74d5d36b9b54742d56b0b
Diffstat (limited to 'contrib/haskell/src/Hkl/C/EngineList.hsc')
-rw-r--r-- | contrib/haskell/src/Hkl/C/EngineList.hsc | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/contrib/haskell/src/Hkl/C/EngineList.hsc b/contrib/haskell/src/Hkl/C/EngineList.hsc new file mode 100644 index 0000000..08232f6 --- /dev/null +++ b/contrib/haskell/src/Hkl/C/EngineList.hsc @@ -0,0 +1,60 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE GADTs #-} + +module Hkl.C.EngineList + ( HklEngineList + , engineListEnginesGet + , newEngineList + , withEngineList + ) where + +import Prelude hiding (min, max) + +import Foreign ( ForeignPtr + , FunPtr + , Ptr + , newForeignPtr + , withForeignPtr + , peekArray) +import Foreign.C ( CSize(..) ) +import Foreign.Storable + +import Hkl.C.Engine +import Hkl.C.Geometry +import Hkl.Types + +#include "hkl.h" + +-- private types + +data HklEngineList + +-- EngineList + +withEngineList :: Factory -> (Ptr HklEngineList -> IO b) -> IO b +withEngineList f func = do + fptr <- newEngineList f + withForeignPtr fptr func + +newEngineList :: Factory -> IO (ForeignPtr HklEngineList) +newEngineList f = newFactory f + >>= c_hkl_factory_create_new_engine_list + >>= newForeignPtr c_hkl_engine_list_free + +foreign import ccall unsafe "hkl.h hkl_factory_create_new_engine_list" + c_hkl_factory_create_new_engine_list:: Ptr HklFactory -> IO (Ptr HklEngineList) + +foreign import ccall unsafe "hkl.h &hkl_engine_list_free" + c_hkl_engine_list_free :: FunPtr (Ptr HklEngineList -> IO ()) + +engineListEnginesGet :: Ptr HklEngineList -> IO [Engine] +engineListEnginesGet e = do + pdarray <- c_hkl_engine_list_engines_get e + n <- (#{peek darray_engine, size} pdarray) :: IO CSize + engines <- #{peek darray_engine ,item} pdarray :: IO (Ptr (Ptr HklEngine)) + enginess <- peekArray (fromEnum n) engines + mapM peekEngine enginess + +foreign import ccall unsafe "hkl.h hkl_engine_list_engines_get" + c_hkl_engine_list_engines_get:: Ptr HklEngineList -> IO (Ptr ()) |