George Thomas 9ca4f615d8 Use simpler tagged union translation
Avoids the worst part of the header hack, and makes Haskell wrapper simpler.
2026-02-19 17:22:15 +00:00

156 lines
3.9 KiB
Haskell

{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_HADDOCK prune #-}
module GarnetRs.Unsafe where
import qualified Foreign as F
import qualified Foreign.C as FC
import qualified GHC.Int
import qualified GHC.Ptr as Ptr
import qualified HsBindgen.Runtime.Internal.CAPI
import qualified HsBindgen.Runtime.Internal.HasFFIType
import qualified HsBindgen.Runtime.LibC
import qualified HsBindgen.Runtime.PtrConst
import Data.Void (Void)
import GarnetRs
import Prelude (IO)
$(HsBindgen.Runtime.Internal.CAPI.addCSource (HsBindgen.Runtime.Internal.CAPI.unlines
[ "#include <garnet_rs.h>"
, "void hs_bindgen_2dfe97662a4d6377 ("
, " char const *arg1"
, ")"
, "{"
, " hello(arg1);"
, "}"
, "void hs_bindgen_29d823ada2bc7302 ("
, " struct T *arg1"
, ")"
, "{"
, " hello_struct(*arg1);"
, "}"
, "void hs_bindgen_b3f40a03f07eaa85 ("
, " struct Shape *arg1"
, ")"
, "{"
, " hello_shape(*arg1);"
, "}"
, "int64_t hs_bindgen_20eb651f0a8faf48 ("
, " int64_t arg1,"
, " int64_t arg2"
, ")"
, "{"
, " return add(arg1, arg2);"
, "}"
]))
-- __unique:__ @com_garnet_GarnetRs_Unsafe_hello@
foreign import ccall unsafe "hs_bindgen_2dfe97662a4d6377" hs_bindgen_2dfe97662a4d6377_base ::
Ptr.Ptr Void
-> IO ()
-- __unique:__ @com_garnet_GarnetRs_Unsafe_hello@
hs_bindgen_2dfe97662a4d6377 ::
HsBindgen.Runtime.PtrConst.PtrConst FC.CChar
-> IO ()
hs_bindgen_2dfe97662a4d6377 =
HsBindgen.Runtime.Internal.HasFFIType.fromFFIType hs_bindgen_2dfe97662a4d6377_base
{-| __C declaration:__ @hello@
__defined at:__ @garnet_rs.h 33:6@
__exported by:__ @garnet_rs.h@
-}
hello ::
HsBindgen.Runtime.PtrConst.PtrConst FC.CChar
-- ^ __C declaration:__ @c@
-> IO ()
hello = hs_bindgen_2dfe97662a4d6377
-- __unique:__ @com_garnet_GarnetRs_Unsafe_hello_struct@
foreign import ccall unsafe "hs_bindgen_29d823ada2bc7302" hs_bindgen_29d823ada2bc7302_base ::
Ptr.Ptr Void
-> IO ()
-- __unique:__ @com_garnet_GarnetRs_Unsafe_hello_struct@
hs_bindgen_29d823ada2bc7302 ::
Ptr.Ptr T
-> IO ()
hs_bindgen_29d823ada2bc7302 =
HsBindgen.Runtime.Internal.HasFFIType.fromFFIType hs_bindgen_29d823ada2bc7302_base
{-| __C declaration:__ @hello_struct@
__defined at:__ @garnet_rs.h 35:6@
__exported by:__ @garnet_rs.h@
-}
hello_struct ::
T
-- ^ __C declaration:__ @t@
-> IO ()
hello_struct =
\t0 ->
F.with t0 (\t1 -> hs_bindgen_29d823ada2bc7302 t1)
-- __unique:__ @com_garnet_GarnetRs_Unsafe_hello_shape@
foreign import ccall unsafe "hs_bindgen_b3f40a03f07eaa85" hs_bindgen_b3f40a03f07eaa85_base ::
Ptr.Ptr Void
-> IO ()
-- __unique:__ @com_garnet_GarnetRs_Unsafe_hello_shape@
hs_bindgen_b3f40a03f07eaa85 ::
Ptr.Ptr Shape
-> IO ()
hs_bindgen_b3f40a03f07eaa85 =
HsBindgen.Runtime.Internal.HasFFIType.fromFFIType hs_bindgen_b3f40a03f07eaa85_base
{-| __C declaration:__ @hello_shape@
__defined at:__ @garnet_rs.h 37:6@
__exported by:__ @garnet_rs.h@
-}
hello_shape ::
Shape
-- ^ __C declaration:__ @s@
-> IO ()
hello_shape =
\s0 ->
F.with s0 (\s1 -> hs_bindgen_b3f40a03f07eaa85 s1)
-- __unique:__ @com_garnet_GarnetRs_Unsafe_add@
foreign import ccall unsafe "hs_bindgen_20eb651f0a8faf48" hs_bindgen_20eb651f0a8faf48_base ::
GHC.Int.Int64
-> GHC.Int.Int64
-> GHC.Int.Int64
-- __unique:__ @com_garnet_GarnetRs_Unsafe_add@
hs_bindgen_20eb651f0a8faf48 ::
HsBindgen.Runtime.LibC.Int64
-> HsBindgen.Runtime.LibC.Int64
-> HsBindgen.Runtime.LibC.Int64
hs_bindgen_20eb651f0a8faf48 =
HsBindgen.Runtime.Internal.HasFFIType.fromFFIType hs_bindgen_20eb651f0a8faf48_base
{-|
Marked @__attribute((const))__@
__C declaration:__ @add@
__defined at:__ @garnet_rs.h 39:32@
__exported by:__ @garnet_rs.h@
-}
add ::
HsBindgen.Runtime.LibC.Int64
-- ^ __C declaration:__ @a@
-> HsBindgen.Runtime.LibC.Int64
-- ^ __C declaration:__ @b@
-> HsBindgen.Runtime.LibC.Int64
add = hs_bindgen_20eb651f0a8faf48