{-# LINE 1 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
module Data.Number.Flint.Calcium.Fexpr.FFI (
Fexpr (..)
, CFexpr ()
, newFexpr
, withFexpr
, withNewFexpr
, fexpr_init
, fexpr_clear
, _fexpr_vec_init
, _fexpr_vec_clear
, fexpr_fit_size
, fexpr_set
, fexpr_swap
, fexpr_type_small_int
, fexpr_type_small_symbol
, fexpr_type_small_string
, fexpr_type_big_int_pos
, fexpr_type_big_int_neg
, fexpr_type_big_symbol
, fexpr_type_big_string
, fexpr_type_call0
, fexpr_type_call1
, fexpr_type_call2
, fexpr_type_call3
, fexpr_type_call4
, fexpr_type_calln
, fexpr_depth
, fexpr_num_leaves
, fexpr_size
, fexpr_size_bytes
, fexpr_allocated_bytes
, fexpr_equal
, fexpr_equal_si
, fexpr_equal_ui
, fexpr_hash
, fexpr_cmp_fast
, fexpr_is_integer
, fexpr_is_symbol
, fexpr_is_string
, fexpr_is_atom
, fexpr_zero
, fexpr_is_zero
, fexpr_is_neg_integer
, fexpr_set_si
, fexpr_set_ui
, fexpr_set_fmpz
, fexpr_get_fmpz
, fexpr_set_symbol_builtin
, fexpr_is_builtin_symbol
, fexpr_is_any_builtin_symbol
, fexpr_set_symbol_str
, fexpr_get_symbol_str
, fexpr_set_string
, fexpr_get_string
, fexpr_write
, fexpr_print
, fexpr_get_str
, fexpr_write_latex
, fexpr_print_latex
, fexpr_get_str_latex
, fexpr_latex_small
, fexpr_latex_logic
, fexpr_nargs
, fexpr_func
, fexpr_view_func
, fexpr_arg
, fexpr_view_arg
, fexpr_view_next
, fexpr_is_builtin_call
, fexpr_is_any_builtin_call
, fexpr_call0
, fexpr_call1
, fexpr_call2
, fexpr_call3
, fexpr_call4
, fexpr_call_vec
, fexpr_call_builtin1
, fexpr_call_builtin2
, fexpr_contains
, fexpr_replace
, fexpr_replace2
, fexpr_replace_vec
, fexpr_set_fmpq
, fexpr_set_arf
, fexpr_set_d
, fexpr_set_re_im_d
, fexpr_neg
, fexpr_add
, fexpr_sub
, fexpr_mul
, fexpr_div
, fexpr_pow
, fexpr_is_arithmetic_operation
, fexpr_arithmetic_nodes
, fexpr_get_fmpz_mpoly_q
, fexpr_set_fmpz_mpoly
, fexpr_set_fmpz_mpoly_q
, fexpr_expanded_normal_form
, newFexprVec
, withFexprVec
, withNewFexprVec
, fexpr_vec_init
, fexpr_vec_clear
, fexpr_vec_print
, fexpr_vec_swap
, fexpr_vec_fit_length
, fexpr_vec_set
, fexpr_vec_append
, fexpr_vec_insert_unique
, fexpr_vec_set_length
, _fexpr_vec_sort_fast
) where
import Foreign.Ptr
import Foreign.ForeignPtr
import Foreign.C.Types
import Foreign.C.String
import Foreign.Storable
import Data.Word
import Data.Number.Flint.Flint
import Data.Number.Flint.Fmpz
import Data.Number.Flint.Fmpz.MPoly
import Data.Number.Flint.Fmpz.MPoly.Q
import Data.Number.Flint.Fmpq
import Data.Number.Flint.Arb.Types
import Data.Number.Flint.Calcium
data Fexpr = Fexpr {-# UNPACK #-} !(ForeignPtr CFexpr)
data CFexpr = CFexpr (Ptr CULong) CLong
instance Storable CFexpr where
{-# INLINE sizeOf #-}
sizeOf :: CFexpr -> Int
sizeOf CFexpr
_ = (Int
16)
{-# LINE 165 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
{-# INLINE alignment #-}
alignment :: CFexpr -> Int
alignment CFexpr
_ = Int
8
{-# LINE 167 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
peek ptr = CFexpr
<$> (\hsc_ptr -> peekByteOff hsc_ptr 0) ptr
{-# LINE 169 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
<*> (\hsc_ptr -> peekByteOff hsc_ptr 8) ptr
{-# LINE 170 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
poke ptr (CFexpr d a) = do
(\hsc_ptr -> pokeByteOff hsc_ptr 0) ptr d
{-# LINE 172 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 8) ptr a
{-# LINE 173 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
newFexpr :: IO Fexpr
newFexpr = do
ForeignPtr CFexpr
p <- IO (ForeignPtr CFexpr)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CFexpr -> (Ptr CFexpr -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFexpr
p Ptr CFexpr -> IO ()
fexpr_init
FinalizerPtr CFexpr -> ForeignPtr CFexpr -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr CFexpr
p_fexpr_clear ForeignPtr CFexpr
p
Fexpr -> IO Fexpr
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Fexpr -> IO Fexpr) -> Fexpr -> IO Fexpr
forall a b. (a -> b) -> a -> b
$ ForeignPtr CFexpr -> Fexpr
Fexpr ForeignPtr CFexpr
p
withFexpr :: Fexpr -> (Ptr CFexpr -> IO a) -> IO (Fexpr, a)
withFexpr (Fexpr ForeignPtr CFexpr
p) Ptr CFexpr -> IO a
f = do
ForeignPtr CFexpr -> (Ptr CFexpr -> IO (Fexpr, a)) -> IO (Fexpr, a)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFexpr
p ((Ptr CFexpr -> IO (Fexpr, a)) -> IO (Fexpr, a))
-> (Ptr CFexpr -> IO (Fexpr, a)) -> IO (Fexpr, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CFexpr
fp -> (ForeignPtr CFexpr -> Fexpr
Fexpr ForeignPtr CFexpr
p,) (a -> (Fexpr, a)) -> IO a -> IO (Fexpr, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr CFexpr -> IO a
f Ptr CFexpr
fp
withNewFexpr :: (Ptr CFexpr -> IO a) -> IO (Fexpr, a)
withNewFexpr Ptr CFexpr -> IO a
f = do
Fexpr
x <- IO Fexpr
newFexpr
Fexpr -> (Ptr CFexpr -> IO a) -> IO (Fexpr, a)
forall {a}. Fexpr -> (Ptr CFexpr -> IO a) -> IO (Fexpr, a)
withFexpr Fexpr
x Ptr CFexpr -> IO a
f
type FexprType = CULong
fexpr_type_small_int :: FexprLatexFlag
fexpr_type_small_int = (FexprLatexFlag
0) :: FexprType
{-# LINE 190 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
fexpr_type_small_symbol = (1) :: FexprType
{-# LINE 191 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
fexpr_type_small_string = (2) :: FexprType
{-# LINE 192 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
fexpr_type_big_int_pos = (3) :: FexprType
{-# LINE 193 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
fexpr_type_big_int_neg = (4) :: FexprType
{-# LINE 194 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
fexpr_type_big_symbol = (5) :: FexprType
{-# LINE 195 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
fexpr_type_big_string = (6) :: FexprType
{-# LINE 196 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
fexpr_type_call0 = (7) :: FexprType
{-# LINE 197 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
fexpr_type_call1 = (8) :: FexprType
{-# LINE 198 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
fexpr_type_call2 = (9) :: FexprType
{-# LINE 199 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
fexpr_type_call3 = (10) :: FexprType
{-# LINE 200 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
fexpr_type_call4 = (11) :: FexprType
{-# LINE 201 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
fexpr_type_calln = (12) :: FexprType
{-# LINE 202 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
foreign import ccall "fexpr.h fexpr_init"
fexpr_init :: Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_clear"
fexpr_clear :: Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h &fexpr_clear"
p_fexpr_clear :: FunPtr (Ptr CFexpr -> IO ())
foreign import ccall "fexpr.h _fexpr_vec_init"
_fexpr_vec_init :: CLong -> IO (Ptr Fexpr)
foreign import ccall "fexpr.h _fexpr_vec_clear"
_fexpr_vec_clear :: Ptr Fexpr -> CLong -> IO ()
foreign import ccall "fexpr.h fexpr_fit_size"
fexpr_fit_size :: Ptr CFexpr -> CLong -> IO ()
foreign import ccall "fexpr.h fexpr_set"
fexpr_set :: Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_swap"
fexpr_swap :: Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_depth"
fexpr_depth :: Ptr CFexpr -> IO CLong
foreign import ccall "fexpr.h fexpr_num_leaves"
fexpr_num_leaves :: Ptr CFexpr -> IO CLong
foreign import ccall "fexpr.h fexpr_size"
fexpr_size :: Ptr CFexpr -> IO CLong
foreign import ccall "fexpr.h fexpr_size_bytes"
fexpr_size_bytes :: Ptr CFexpr -> IO CLong
foreign import ccall "fexpr.h fexpr_allocated_bytes"
fexpr_allocated_bytes :: Ptr CFexpr -> IO CLong
foreign import ccall "fexpr.h fexpr_equal"
fexpr_equal :: Ptr CFexpr -> Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_equal_si"
fexpr_equal_si :: Ptr CFexpr -> CLong -> IO CInt
foreign import ccall "fexpr.h fexpr_equal_ui"
fexpr_equal_ui :: Ptr CFexpr -> CULong -> IO CInt
foreign import ccall "fexpr.h fexpr_hash"
fexpr_hash :: Ptr CFexpr -> IO CULong
foreign import ccall "fexpr.h fexpr_cmp_fast"
fexpr_cmp_fast :: Ptr CFexpr -> Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_is_integer"
fexpr_is_integer :: Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_is_symbol"
fexpr_is_symbol :: Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_is_string"
fexpr_is_string :: Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_is_atom"
fexpr_is_atom :: Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_zero"
fexpr_zero :: Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_is_zero"
fexpr_is_zero :: Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_is_neg_integer"
fexpr_is_neg_integer :: Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_set_si"
fexpr_set_si :: Ptr CFexpr -> CLong -> IO ()
foreign import ccall "fexpr.h fexpr_set_ui"
fexpr_set_ui :: Ptr CFexpr -> CULong -> IO ()
foreign import ccall "fexpr.h fexpr_set_fmpz"
fexpr_set_fmpz :: Ptr CFexpr -> Ptr CFmpz -> IO ()
foreign import ccall "fexpr.h fexpr_get_fmpz"
fexpr_get_fmpz :: Ptr CFmpz -> Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_set_symbol_builtin"
fexpr_set_symbol_builtin :: Ptr CFexpr -> CLong -> IO ()
foreign import ccall "fexpr.h fexpr_is_builtin_symbol"
fexpr_is_builtin_symbol :: Ptr CFexpr -> CLong -> IO CInt
foreign import ccall "fexpr.h fexpr_is_any_builtin_symbol"
fexpr_is_any_builtin_symbol :: Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_set_symbol_str"
fexpr_set_symbol_str :: Ptr CFexpr -> CString -> IO ()
foreign import ccall "fexpr.h fexpr_get_symbol_str"
fexpr_get_symbol_str :: Ptr CFexpr -> IO CString
foreign import ccall "fexpr.h fexpr_set_string"
fexpr_set_string :: Ptr CFexpr -> CString -> IO ()
foreign import ccall "fexpr.h fexpr_get_string"
fexpr_get_string :: Ptr CFexpr -> IO CString
foreign import ccall "fexpr.h fexpr_write"
fexpr_write :: Ptr CCalciumStream -> Ptr CFexpr -> IO ()
fexpr_print :: Ptr CFexpr -> IO ()
fexpr_print :: Ptr CFexpr -> IO ()
fexpr_print Ptr CFexpr
expr = do
(Ptr CFexpr -> IO CString) -> Ptr CFexpr -> IO CInt
forall a. (Ptr a -> IO CString) -> Ptr a -> IO CInt
printCStr Ptr CFexpr -> IO CString
fexpr_get_str Ptr CFexpr
expr
() -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
foreign import ccall "fexpr.h fexpr_get_str"
fexpr_get_str :: Ptr CFexpr -> IO CString
foreign import ccall "fexpr.h fexpr_write_latex"
fexpr_write_latex :: Ptr CCalciumStream -> Ptr CFexpr -> CULong -> IO ()
fexpr_print_latex :: Ptr CFexpr -> CULong -> IO ()
fexpr_print_latex :: Ptr CFexpr -> FexprLatexFlag -> IO ()
fexpr_print_latex Ptr CFexpr
expr FexprLatexFlag
flags = do
(Ptr CFexpr -> IO CString) -> Ptr CFexpr -> IO CInt
forall a. (Ptr a -> IO CString) -> Ptr a -> IO CInt
printCStr ((Ptr CFexpr -> FexprLatexFlag -> IO CString)
-> FexprLatexFlag -> Ptr CFexpr -> IO CString
forall a b c. (a -> b -> c) -> b -> a -> c
flip Ptr CFexpr -> FexprLatexFlag -> IO CString
fexpr_get_str_latex FexprLatexFlag
flags) Ptr CFexpr
expr
() -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
foreign import ccall "fexpr.h fexpr_get_str_latex"
fexpr_get_str_latex :: Ptr CFexpr -> CULong -> IO CString
type FexprLatexFlag = CULong
fexpr_latex_small, fexpr_latex_logic :: FexprLatexFlag
fexpr_latex_small :: FexprLatexFlag
fexpr_latex_small = FexprLatexFlag
1
{-# LINE 493 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
fexpr_latex_logic :: FexprLatexFlag
fexpr_latex_logic = FexprLatexFlag
2
{-# LINE 499 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
foreign import ccall "fexpr.h fexpr_nargs"
fexpr_nargs :: Ptr CFexpr -> IO CLong
foreign import ccall "fexpr.h fexpr_func"
fexpr_func :: Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_view_func"
fexpr_view_func :: Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_arg"
fexpr_arg :: Ptr CFexpr -> Ptr CFexpr -> CLong -> IO ()
foreign import ccall "fexpr.h fexpr_view_arg"
fexpr_view_arg :: Ptr CFexpr -> Ptr CFexpr -> CLong -> IO ()
foreign import ccall "fexpr.h fexpr_view_next"
fexpr_view_next :: Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_is_builtin_call"
fexpr_is_builtin_call :: Ptr CFexpr -> CLong -> IO CInt
foreign import ccall "fexpr.h fexpr_is_any_builtin_call"
fexpr_is_any_builtin_call :: Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_call0"
fexpr_call0 :: Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_call1"
fexpr_call1 :: Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_call2"
fexpr_call2 :: Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_call3"
fexpr_call3 :: Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_call4"
fexpr_call4 :: Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_call_vec"
fexpr_call_vec :: Ptr CFexpr -> Ptr CFexpr -> Ptr Fexpr -> CLong -> IO ()
foreign import ccall "fexpr.h fexpr_call_builtin1"
fexpr_call_builtin1 :: Ptr CFexpr -> CLong -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_call_builtin2"
fexpr_call_builtin2 :: Ptr CFexpr -> CLong -> Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_contains"
fexpr_contains :: Ptr CFexpr -> Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_replace"
fexpr_replace :: Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_replace2"
fexpr_replace2 :: Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_replace_vec"
fexpr_replace_vec :: Ptr CFexpr -> Ptr CFexpr -> Ptr CFexprVec -> Ptr CFexprVec -> IO CInt
foreign import ccall "fexpr.h fexpr_set_fmpq"
fexpr_set_fmpq :: Ptr CFexpr -> Ptr CFmpq -> IO ()
foreign import ccall "fexpr.h fexpr_set_arf"
fexpr_set_arf :: Ptr CFexpr -> Ptr CArf -> IO ()
foreign import ccall "fexpr.h fexpr_set_d"
fexpr_set_d :: Ptr CFexpr -> CDouble -> IO ()
foreign import ccall "fexpr.h fexpr_set_re_im_d"
fexpr_set_re_im_d :: Ptr CFexpr -> CDouble -> CDouble -> IO ()
foreign import ccall "fexpr.h fexpr_neg"
fexpr_neg :: Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_add"
fexpr_add :: Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_sub"
fexpr_sub :: Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_mul"
fexpr_mul :: Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_div"
fexpr_div :: Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_pow"
fexpr_pow :: Ptr CFexpr -> Ptr CFexpr -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_is_arithmetic_operation"
fexpr_is_arithmetic_operation :: Ptr CFexpr -> IO CInt
foreign import ccall "fexpr.h fexpr_arithmetic_nodes"
fexpr_arithmetic_nodes :: Ptr CFexprVec -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_get_fmpz_mpoly_q"
fexpr_get_fmpz_mpoly_q :: Ptr CFmpzMPolyQ -> Ptr CFexpr -> Ptr CFexprVec -> Ptr CFmpzMPolyCtx -> IO CInt
foreign import ccall "fexpr.h fexpr_set_fmpz_mpoly"
fexpr_set_fmpz_mpoly :: Ptr CFexpr -> Ptr CFmpzMPoly -> Ptr CFexprVec -> Ptr CFmpzMPolyCtx -> IO ()
foreign import ccall "fexpr.h fexpr_set_fmpz_mpoly_q"
fexpr_set_fmpz_mpoly_q :: Ptr CFexpr -> Ptr CFmpzMPolyQ -> Ptr CFexprVec -> Ptr CFmpzMPolyCtx -> IO ()
foreign import ccall "fexpr.h fexpr_expanded_normal_form"
fexpr_expanded_normal_form :: Ptr CFexpr -> Ptr CFexpr -> CULong -> IO CInt
data FexprVec = FexprVec {-# UNPACK #-} !(ForeignPtr CFexprVec)
data CFexprVec = CFexprVec (Ptr Fexpr) CLong CLong
instance Storable CFexprVec where
{-# INLINE sizeOf #-}
sizeOf :: CFexprVec -> Int
sizeOf CFexprVec
_ = (Int
24)
{-# LINE 768 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
{-# INLINE alignment #-}
alignment :: CFexprVec -> Int
alignment CFexprVec
_ = Int
8
{-# LINE 770 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
peek ptr = CFexprVec
<$> (\hsc_ptr -> peekByteOff hsc_ptr 0) ptr
{-# LINE 772 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
<*> (\hsc_ptr -> peekByteOff hsc_ptr 8) ptr
{-# LINE 773 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
<*> (\hsc_ptr -> peekByteOff hsc_ptr 16) ptr
{-# LINE 774 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
poke ptr (CFexprVec entries alloc length) = do
(\hsc_ptr -> pokeByteOff hsc_ptr 0) ptr entries
{-# LINE 776 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 8) ptr alloc
{-# LINE 777 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 16) ptr length
{-# LINE 778 "src/Data/Number/Flint/Calcium/Fexpr/FFI.hsc" #-}
newFexprVec :: CLong -> IO FexprVec
newFexprVec CLong
n = do
ForeignPtr CFexprVec
p <- IO (ForeignPtr CFexprVec)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CFexprVec -> (Ptr CFexprVec -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFexprVec
p ((Ptr CFexprVec -> IO ()) -> IO ())
-> (Ptr CFexprVec -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CFexprVec
p -> do
Ptr CFexprVec -> CLong -> IO ()
fexpr_vec_init Ptr CFexprVec
p CLong
n
FinalizerPtr CFexprVec -> ForeignPtr CFexprVec -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr CFexprVec
p_fexpr_vec_clear ForeignPtr CFexprVec
p
FexprVec -> IO FexprVec
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FexprVec -> IO FexprVec) -> FexprVec -> IO FexprVec
forall a b. (a -> b) -> a -> b
$ ForeignPtr CFexprVec -> FexprVec
FexprVec ForeignPtr CFexprVec
p
withFexprVec :: FexprVec -> (Ptr CFexprVec -> IO a) -> IO (FexprVec, a)
withFexprVec (FexprVec ForeignPtr CFexprVec
p) Ptr CFexprVec -> IO a
f = do
ForeignPtr CFexprVec
-> (Ptr CFexprVec -> IO (FexprVec, a)) -> IO (FexprVec, a)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFexprVec
p ((Ptr CFexprVec -> IO (FexprVec, a)) -> IO (FexprVec, a))
-> (Ptr CFexprVec -> IO (FexprVec, a)) -> IO (FexprVec, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CFexprVec
fp -> (ForeignPtr CFexprVec -> FexprVec
FexprVec ForeignPtr CFexprVec
p,) (a -> (FexprVec, a)) -> IO a -> IO (FexprVec, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr CFexprVec -> IO a
f Ptr CFexprVec
fp
withNewFexprVec :: CLong -> (Ptr CFexprVec -> IO a) -> IO (FexprVec, a)
withNewFexprVec CLong
n Ptr CFexprVec -> IO a
f = do
FexprVec
x <- CLong -> IO FexprVec
newFexprVec CLong
n
FexprVec -> (Ptr CFexprVec -> IO a) -> IO (FexprVec, a)
forall {a}. FexprVec -> (Ptr CFexprVec -> IO a) -> IO (FexprVec, a)
withFexprVec FexprVec
x Ptr CFexprVec -> IO a
f
foreign import ccall "fexpr.h fexpr_vec_init"
fexpr_vec_init :: Ptr CFexprVec -> CLong -> IO ()
foreign import ccall "fexpr.h fexpr_vec_clear"
fexpr_vec_clear :: Ptr CFexprVec -> IO ()
foreign import ccall "fexpr.h &fexpr_vec_clear"
p_fexpr_vec_clear :: FunPtr (Ptr CFexprVec -> IO ())
foreign import ccall "fexpr.h fexpr_vec_print"
fexpr_vec_print :: Ptr CFexprVec -> IO ()
foreign import ccall "fexpr.h fexpr_vec_swap"
fexpr_vec_swap :: Ptr CFexprVec -> Ptr CFexprVec -> IO ()
foreign import ccall "fexpr.h fexpr_vec_fit_length"
fexpr_vec_fit_length :: Ptr CFexprVec -> CLong -> IO ()
foreign import ccall "fexpr.h fexpr_vec_set"
fexpr_vec_set :: Ptr CFexprVec -> Ptr CFexprVec -> IO ()
foreign import ccall "fexpr.h fexpr_vec_append"
fexpr_vec_append :: Ptr CFexprVec -> Ptr CFexpr -> IO ()
foreign import ccall "fexpr.h fexpr_vec_insert_unique"
fexpr_vec_insert_unique :: Ptr CFexprVec -> Ptr CFexpr -> IO CLong
foreign import ccall "fexpr.h fexpr_vec_set_length"
fexpr_vec_set_length :: Ptr CFexprVec -> CLong -> IO ()
foreign import ccall "fexpr.h _fexpr_vec_sort_fast"
_fexpr_vec_sort_fast :: Ptr Fexpr -> CLong -> IO ()