{-# LINE 1 "src/Data/Number/Flint/Calcium/Ca/Ext/FFI.hsc" #-}
module Data.Number.Flint.Calcium.Ca.Ext.FFI (
CaExt (..)
, CCaExt (..)
, newCaExtQQbar
, newCaExtConst
, newCaExtFx
, newCaExtFxy
, newCaExtFxn
, withCaExt
, ca_ext_init_qqbar
, ca_ext_init_const
, ca_ext_init_fx
, ca_ext_init_fxy
, ca_ext_init_fxn
, ca_ext_init_set
, ca_ext_clear
, ca_ext_nargs
, ca_ext_get_arg
, ca_ext_hash
, ca_ext_equal_repr
, ca_ext_cmp_repr
, ca_ext_print
, ca_ext_get_acb_raw
, ca_ext_cache_init
, ca_ext_cache_clear
, ca_ext_cache_insert
) where
import Foreign.Ptr
import Foreign.ForeignPtr
import Foreign.C.Types
import Foreign.C.String
import Foreign.Storable
import Foreign.Marshal.Array
import Data.Number.Flint.Flint
import Data.Number.Flint.Fmpz
import Data.Number.Flint.Acb.Types
import Data.Number.Flint.NF.QQbar
import Data.Number.Flint.Calcium
import Data.Number.Flint.Calcium.Ca
import Data.Number.Flint.Calcium.Ca.Types
instance Storable CCaExt where
{-# INLINE sizeOf #-}
sizeOf :: CCaExt -> Int
sizeOf CCaExt
_ = (Int
152)
{-# LINE 60 "src/Data/Number/Flint/Calcium/Ca/Ext/FFI.hsc" #-}
{-# INLINE alignment #-}
alignment :: CCaExt -> Int
alignment CCaExt
_ = Int
8
{-# LINE 62 "src/Data/Number/Flint/Calcium/Ca/Ext/FFI.hsc" #-}
peek = error "CCaExt.peek: Not defined"
poke :: Ptr CCaExt -> CCaExt -> IO ()
poke = [Char] -> Ptr CCaExt -> CCaExt -> IO ()
forall a. HasCallStack => [Char] -> a
error [Char]
"CCaExt.poke: Not defined"
newCaExtQQbar :: QQbar -> CaCtx -> IO CaExt
newCaExtQQbar QQbar
x ctx :: CaCtx
ctx@(CaCtx ForeignPtr CCaCtx
ctxf) = do
ForeignPtr CCaExt
res <- IO (ForeignPtr CCaExt)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CCaExt -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CCaExt
res ((Ptr CCaExt -> IO ()) -> IO ()) -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CCaExt
resp -> do
CaCtx -> (Ptr CCaCtx -> IO (QQbar, ())) -> IO (CaCtx, (QQbar, ()))
forall {a}. CaCtx -> (Ptr CCaCtx -> IO a) -> IO (CaCtx, a)
withCaCtx CaCtx
ctx ((Ptr CCaCtx -> IO (QQbar, ())) -> IO (CaCtx, (QQbar, ())))
-> (Ptr CCaCtx -> IO (QQbar, ())) -> IO (CaCtx, (QQbar, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CCaCtx
ctxp -> do
QQbar -> (Ptr CQQbar -> IO ()) -> IO (QQbar, ())
forall {a}. QQbar -> (Ptr CQQbar -> IO a) -> IO (QQbar, a)
withQQbar QQbar
x ((Ptr CQQbar -> IO ()) -> IO (QQbar, ()))
-> (Ptr CQQbar -> IO ()) -> IO (QQbar, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CQQbar
xp -> do
Ptr CCaExt -> Ptr CQQbar -> Ptr CCaCtx -> IO ()
ca_ext_init_qqbar Ptr CCaExt
resp Ptr CQQbar
xp Ptr CCaCtx
ctxp
FinalizerEnvPtr CCaExt CCaCtx
-> Ptr CCaExt -> ForeignPtr CCaCtx -> IO ()
forall env a.
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
addForeignPtrFinalizerEnv FinalizerEnvPtr CCaExt CCaCtx
p_ca_ext_clear Ptr CCaExt
resp ForeignPtr CCaCtx
ctxf
CaExt -> IO CaExt
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CaExt -> IO CaExt) -> CaExt -> IO CaExt
forall a b. (a -> b) -> a -> b
$ ForeignPtr CCaExt -> CaExt
CaExt ForeignPtr CCaExt
res
newCaExtConst :: CCalciumFunctionCode -> CaCtx -> IO CaExt
newCaExtConst CCalciumFunctionCode
fc ctx :: CaCtx
ctx@(CaCtx ForeignPtr CCaCtx
ctxf) = do
ForeignPtr CCaExt
res <- IO (ForeignPtr CCaExt)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CCaExt -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CCaExt
res ((Ptr CCaExt -> IO ()) -> IO ()) -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CCaExt
resp -> do
CaCtx -> (Ptr CCaCtx -> IO ()) -> IO (CaCtx, ())
forall {a}. CaCtx -> (Ptr CCaCtx -> IO a) -> IO (CaCtx, a)
withCaCtx CaCtx
ctx ((Ptr CCaCtx -> IO ()) -> IO (CaCtx, ()))
-> (Ptr CCaCtx -> IO ()) -> IO (CaCtx, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CCaCtx
ctxp -> do
Ptr CCaExt -> CCalciumFunctionCode -> Ptr CCaCtx -> IO ()
ca_ext_init_const Ptr CCaExt
resp CCalciumFunctionCode
fc Ptr CCaCtx
ctxp
FinalizerEnvPtr CCaExt CCaCtx
-> Ptr CCaExt -> ForeignPtr CCaCtx -> IO ()
forall env a.
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
addForeignPtrFinalizerEnv FinalizerEnvPtr CCaExt CCaCtx
p_ca_ext_clear Ptr CCaExt
resp ForeignPtr CCaCtx
ctxf
CaExt -> IO CaExt
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CaExt -> IO CaExt) -> CaExt -> IO CaExt
forall a b. (a -> b) -> a -> b
$ ForeignPtr CCaExt -> CaExt
CaExt ForeignPtr CCaExt
res
newCaExtFx :: CCalciumFunctionCode -> Ca -> CaCtx -> IO CaExt
newCaExtFx CCalciumFunctionCode
fx Ca
x ctx :: CaCtx
ctx@(CaCtx ForeignPtr CCaCtx
ctxf) = do
ForeignPtr CCaExt
res <- IO (ForeignPtr CCaExt)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CCaExt -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CCaExt
res ((Ptr CCaExt -> IO ()) -> IO ()) -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CCaExt
resp -> do
CaCtx -> (Ptr CCaCtx -> IO (Ca, ())) -> IO (CaCtx, (Ca, ()))
forall {a}. CaCtx -> (Ptr CCaCtx -> IO a) -> IO (CaCtx, a)
withCaCtx CaCtx
ctx ((Ptr CCaCtx -> IO (Ca, ())) -> IO (CaCtx, (Ca, ())))
-> (Ptr CCaCtx -> IO (Ca, ())) -> IO (CaCtx, (Ca, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CCaCtx
ctxp -> do
Ca -> (Ptr CCa -> IO ()) -> IO (Ca, ())
forall {a}. Ca -> (Ptr CCa -> IO a) -> IO (Ca, a)
withCa Ca
x ((Ptr CCa -> IO ()) -> IO (Ca, ()))
-> (Ptr CCa -> IO ()) -> IO (Ca, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CCa
x -> do
Ptr CCaExt
-> CCalciumFunctionCode -> Ptr CCa -> Ptr CCaCtx -> IO ()
ca_ext_init_fx Ptr CCaExt
resp CCalciumFunctionCode
fx Ptr CCa
x Ptr CCaCtx
ctxp
FinalizerEnvPtr CCaExt CCaCtx
-> Ptr CCaExt -> ForeignPtr CCaCtx -> IO ()
forall env a.
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
addForeignPtrFinalizerEnv FinalizerEnvPtr CCaExt CCaCtx
p_ca_ext_clear Ptr CCaExt
resp ForeignPtr CCaCtx
ctxf
CaExt -> IO CaExt
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CaExt -> IO CaExt) -> CaExt -> IO CaExt
forall a b. (a -> b) -> a -> b
$ ForeignPtr CCaExt -> CaExt
CaExt ForeignPtr CCaExt
res
newCaExtFxy :: CCalciumFunctionCode -> Ca -> Ca -> CaCtx -> IO CaExt
newCaExtFxy CCalciumFunctionCode
fxy Ca
x Ca
y ctx :: CaCtx
ctx@(CaCtx ForeignPtr CCaCtx
ctxf) = do
ForeignPtr CCaExt
res <- IO (ForeignPtr CCaExt)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CCaExt -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CCaExt
res ((Ptr CCaExt -> IO ()) -> IO ()) -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CCaExt
resp -> do
CaCtx
-> (Ptr CCaCtx -> IO (Ca, (Ca, ()))) -> IO (CaCtx, (Ca, (Ca, ())))
forall {a}. CaCtx -> (Ptr CCaCtx -> IO a) -> IO (CaCtx, a)
withCaCtx CaCtx
ctx ((Ptr CCaCtx -> IO (Ca, (Ca, ()))) -> IO (CaCtx, (Ca, (Ca, ()))))
-> (Ptr CCaCtx -> IO (Ca, (Ca, ()))) -> IO (CaCtx, (Ca, (Ca, ())))
forall a b. (a -> b) -> a -> b
$ \Ptr CCaCtx
ctxp -> do
Ca -> (Ptr CCa -> IO (Ca, ())) -> IO (Ca, (Ca, ()))
forall {a}. Ca -> (Ptr CCa -> IO a) -> IO (Ca, a)
withCa Ca
x ((Ptr CCa -> IO (Ca, ())) -> IO (Ca, (Ca, ())))
-> (Ptr CCa -> IO (Ca, ())) -> IO (Ca, (Ca, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CCa
x -> do
Ca -> (Ptr CCa -> IO ()) -> IO (Ca, ())
forall {a}. Ca -> (Ptr CCa -> IO a) -> IO (Ca, a)
withCa Ca
y ((Ptr CCa -> IO ()) -> IO (Ca, ()))
-> (Ptr CCa -> IO ()) -> IO (Ca, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CCa
y -> do
Ptr CCaExt
-> CCalciumFunctionCode
-> Ptr CCa
-> Ptr CCa
-> Ptr CCaCtx
-> IO ()
ca_ext_init_fxy Ptr CCaExt
resp CCalciumFunctionCode
fxy Ptr CCa
x Ptr CCa
y Ptr CCaCtx
ctxp
FinalizerEnvPtr CCaExt CCaCtx
-> Ptr CCaExt -> ForeignPtr CCaCtx -> IO ()
forall env a.
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
addForeignPtrFinalizerEnv FinalizerEnvPtr CCaExt CCaCtx
p_ca_ext_clear Ptr CCaExt
resp ForeignPtr CCaCtx
ctxf
CaExt -> IO CaExt
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CaExt -> IO CaExt) -> CaExt -> IO CaExt
forall a b. (a -> b) -> a -> b
$ ForeignPtr CCaExt -> CaExt
CaExt ForeignPtr CCaExt
res
newCaExtFxn :: CCalciumFunctionCode -> Ca -> CLong -> CaCtx -> IO CaExt
newCaExtFxn CCalciumFunctionCode
fxn Ca
x CLong
nargs ctx :: CaCtx
ctx@(CaCtx ForeignPtr CCaCtx
ctxf) = do
ForeignPtr CCaExt
res <- IO (ForeignPtr CCaExt)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CCaExt -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CCaExt
res ((Ptr CCaExt -> IO ()) -> IO ()) -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CCaExt
resp -> do
CaCtx -> (Ptr CCaCtx -> IO (Ca, ())) -> IO (CaCtx, (Ca, ()))
forall {a}. CaCtx -> (Ptr CCaCtx -> IO a) -> IO (CaCtx, a)
withCaCtx CaCtx
ctx ((Ptr CCaCtx -> IO (Ca, ())) -> IO (CaCtx, (Ca, ())))
-> (Ptr CCaCtx -> IO (Ca, ())) -> IO (CaCtx, (Ca, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CCaCtx
ctxp -> do
Ca -> (Ptr CCa -> IO ()) -> IO (Ca, ())
forall {a}. Ca -> (Ptr CCa -> IO a) -> IO (Ca, a)
withCa Ca
x ((Ptr CCa -> IO ()) -> IO (Ca, ()))
-> (Ptr CCa -> IO ()) -> IO (Ca, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CCa
x -> do
Ptr CCaExt
-> CCalciumFunctionCode -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO ()
ca_ext_init_fxn Ptr CCaExt
resp CCalciumFunctionCode
fxn Ptr CCa
x CLong
nargs Ptr CCaCtx
ctxp
FinalizerEnvPtr CCaExt CCaCtx
-> Ptr CCaExt -> ForeignPtr CCaCtx -> IO ()
forall env a.
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
addForeignPtrFinalizerEnv FinalizerEnvPtr CCaExt CCaCtx
p_ca_ext_clear Ptr CCaExt
resp ForeignPtr CCaCtx
ctxf
CaExt -> IO CaExt
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CaExt -> IO CaExt) -> CaExt -> IO CaExt
forall a b. (a -> b) -> a -> b
$ ForeignPtr CCaExt -> CaExt
CaExt ForeignPtr CCaExt
res
withCaExt :: CaExt -> (Ptr CCaExt -> IO a) -> IO (CaExt, a)
withCaExt (CaExt ForeignPtr CCaExt
x) Ptr CCaExt -> IO a
f = do
ForeignPtr CCaExt -> (Ptr CCaExt -> IO (CaExt, a)) -> IO (CaExt, a)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CCaExt
x ((Ptr CCaExt -> IO (CaExt, a)) -> IO (CaExt, a))
-> (Ptr CCaExt -> IO (CaExt, a)) -> IO (CaExt, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CCaExt
px -> Ptr CCaExt -> IO a
f Ptr CCaExt
px IO a -> (a -> IO (CaExt, a)) -> IO (CaExt, a)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (CaExt, a) -> IO (CaExt, a)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ((CaExt, a) -> IO (CaExt, a))
-> (a -> (CaExt, a)) -> a -> IO (CaExt, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ForeignPtr CCaExt -> CaExt
CaExt ForeignPtr CCaExt
x,)
foreign import ccall "ca_ext.h ca_ext_init_qqbar"
ca_ext_init_qqbar :: Ptr CCaExt -> Ptr CQQbar -> Ptr CCaCtx -> IO ()
foreign import ccall "ca_ext.h ca_ext_init_const"
ca_ext_init_const :: Ptr CCaExt -> CCalciumFunctionCode -> Ptr CCaCtx -> IO ()
foreign import ccall "ca_ext.h ca_ext_init_fx"
ca_ext_init_fx :: Ptr CCaExt -> CCalciumFunctionCode -> Ptr CCa -> Ptr CCaCtx -> IO ()
foreign import ccall "ca_ext.h ca_ext_init_fxy"
ca_ext_init_fxy :: Ptr CCaExt -> CCalciumFunctionCode -> Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO ()
foreign import ccall "ca_ext.h ca_ext_init_fxn"
ca_ext_init_fxn :: Ptr CCaExt -> CCalciumFunctionCode -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO ()
foreign import ccall "ca_ext.h ca_ext_init_set"
ca_ext_init_set :: Ptr CCaExt -> Ptr CCaExt -> Ptr CCaCtx -> IO ()
foreign import ccall "ca_ext.h ca_ext_clear"
ca_ext_clear :: Ptr CCaExt -> Ptr CCaCtx -> IO ()
foreign import ccall "ca_ext.h &ca_ext_clear"
p_ca_ext_clear :: FunPtr (Ptr CCaExt -> Ptr CCaCtx -> IO ())
foreign import ccall "ca_ext.h ca_ext_nargs"
ca_ext_nargs :: Ptr CCaExt -> Ptr CCaCtx -> IO CLong
foreign import ccall "ca_ext.h ca_ext_get_arg"
ca_ext_get_arg :: Ptr CCa -> Ptr CCaExt -> CLong -> Ptr CCaCtx -> IO ()
foreign import ccall "ca_ext.h ca_ext_hash"
ca_ext_hash :: Ptr CCaExt -> Ptr CCaCtx -> IO CULong
foreign import ccall "ca_ext.h ca_ext_equal_repr"
ca_ext_equal_repr :: Ptr CCaExt -> Ptr CCaExt -> Ptr CCaCtx -> IO CInt
foreign import ccall "ca_ext.h ca_ext_cmp_repr"
ca_ext_cmp_repr :: Ptr CCaExt -> Ptr CCaExt -> Ptr CCaCtx -> IO CInt
foreign import ccall "ca_ext.h ca_ext_get_str"
ca_ext_get_str :: Ptr CCaExt -> Ptr CCaCtx -> IO CString
foreign import ccall "ca_ext.h ca_ext_fprint"
ca_ext_fprint :: Ptr CFile -> Ptr CCaExt -> Ptr CCaCtx -> IO ()
ca_ext_print :: Ptr CCaExt -> Ptr CCaCtx -> IO ()
ca_ext_print :: Ptr CCaExt -> Ptr CCaCtx -> IO ()
ca_ext_print Ptr CCaExt
x Ptr CCaCtx
ctx = do
(Ptr CCaExt -> IO CString) -> Ptr CCaExt -> IO CInt
forall a. (Ptr a -> IO CString) -> Ptr a -> IO CInt
printCStr ((Ptr CCaExt -> Ptr CCaCtx -> IO CString)
-> Ptr CCaCtx -> Ptr CCaExt -> IO CString
forall a b c. (a -> b -> c) -> b -> a -> c
flip Ptr CCaExt -> Ptr CCaCtx -> IO CString
ca_ext_get_str Ptr CCaCtx
ctx) Ptr CCaExt
x
() -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
foreign import ccall "ca_ext.h ca_ext_get_acb_raw"
ca_ext_get_acb_raw :: Ptr CAcb -> Ptr CCaExt -> CLong -> Ptr CCaCtx -> IO ()
foreign import ccall "ca_ext.h ca_ext_cache_init"
ca_ext_cache_init :: Ptr CCaExtCache -> Ptr CCaCtx -> IO ()
foreign import ccall "ca_ext.h ca_ext_cache_clear"
ca_ext_cache_clear :: Ptr CCaExtCache -> Ptr CCaCtx -> IO ()
foreign import ccall "ca_ext.h ca_ext_cache_insert"
ca_ext_cache_insert :: Ptr CCaExtCache -> Ptr CCaExt -> Ptr CCaCtx -> IO (Ptr CCaExt)