diff --git a/exe/GarnetRs/Wrapped.hs b/exe/GarnetRs/Wrapped.hs index d045576..ee80ce0 100644 --- a/exe/GarnetRs/Wrapped.hs +++ b/exe/GarnetRs/Wrapped.hs @@ -41,5 +41,5 @@ helloStruct = Raw.hello_struct . convertT helloShape :: Shape -> IO () helloShape = Raw.hello_shape . convertShape -add :: Int64 -> Int64 -> IO Int64 +add :: Int64 -> Int64 -> Int64 add = Raw.add diff --git a/exe/Main.hs b/exe/Main.hs index 80f3f47..9084e3b 100644 --- a/exe/Main.hs +++ b/exe/Main.hs @@ -9,4 +9,4 @@ main = do helloStruct T{a = False, b = maxBound} helloShape $ Circle 3.14 helloShape $ Rectangle 10.0 5.0 - putStrLn . ("3 + 4 = " <>) . show =<< add 3 4 + putStrLn $ "3 + 4 = " <> show (add 3 4) diff --git a/generated/GarnetRs/FunPtr.hs b/generated/GarnetRs/FunPtr.hs index 77c1f94..253311f 100644 --- a/generated/GarnetRs/FunPtr.hs +++ b/generated/GarnetRs/FunPtr.hs @@ -125,7 +125,7 @@ hs_bindgen_bbabdbe61cd1eeb2 = {-# NOINLINE add #-} {-| __C declaration:__ @add@ - __defined at:__ @garnet_rs.h 38:9@ + __defined at:__ @garnet_rs.h 38:32@ __exported by:__ @garnet_rs.h@ -} diff --git a/generated/GarnetRs/Safe.hs b/generated/GarnetRs/Safe.hs index 7b0bec2..40b04fa 100644 --- a/generated/GarnetRs/Safe.hs +++ b/generated/GarnetRs/Safe.hs @@ -126,26 +126,30 @@ hello_shape = foreign import ccall safe "hs_bindgen_1c0c71fa74c428a9" hs_bindgen_1c0c71fa74c428a9_base :: GHC.Int.Int64 -> GHC.Int.Int64 - -> IO GHC.Int.Int64 + -> GHC.Int.Int64 -- __unique:__ @com_garnet_GarnetRs_Safe_add@ hs_bindgen_1c0c71fa74c428a9 :: HsBindgen.Runtime.LibC.Int64 -> HsBindgen.Runtime.LibC.Int64 - -> IO HsBindgen.Runtime.LibC.Int64 + -> HsBindgen.Runtime.LibC.Int64 hs_bindgen_1c0c71fa74c428a9 = HsBindgen.Runtime.Internal.HasFFIType.fromFFIType hs_bindgen_1c0c71fa74c428a9_base -{-| __C declaration:__ @add@ +{-| - __defined at:__ @garnet_rs.h 38:9@ + Marked @__attribute((const))__@ - __exported by:__ @garnet_rs.h@ +__C declaration:__ @add@ + +__defined at:__ @garnet_rs.h 38:32@ + +__exported by:__ @garnet_rs.h@ -} add :: HsBindgen.Runtime.LibC.Int64 -- ^ __C declaration:__ @a@ -> HsBindgen.Runtime.LibC.Int64 -- ^ __C declaration:__ @b@ - -> IO HsBindgen.Runtime.LibC.Int64 + -> HsBindgen.Runtime.LibC.Int64 add = hs_bindgen_1c0c71fa74c428a9 diff --git a/generated/GarnetRs/Unsafe.hs b/generated/GarnetRs/Unsafe.hs index 87f47f8..0fa12e0 100644 --- a/generated/GarnetRs/Unsafe.hs +++ b/generated/GarnetRs/Unsafe.hs @@ -126,26 +126,30 @@ hello_shape = foreign import ccall unsafe "hs_bindgen_20eb651f0a8faf48" hs_bindgen_20eb651f0a8faf48_base :: GHC.Int.Int64 -> GHC.Int.Int64 - -> IO GHC.Int.Int64 + -> GHC.Int.Int64 -- __unique:__ @com_garnet_GarnetRs_Unsafe_add@ hs_bindgen_20eb651f0a8faf48 :: HsBindgen.Runtime.LibC.Int64 -> HsBindgen.Runtime.LibC.Int64 - -> IO HsBindgen.Runtime.LibC.Int64 + -> HsBindgen.Runtime.LibC.Int64 hs_bindgen_20eb651f0a8faf48 = HsBindgen.Runtime.Internal.HasFFIType.fromFFIType hs_bindgen_20eb651f0a8faf48_base -{-| __C declaration:__ @add@ +{-| - __defined at:__ @garnet_rs.h 38:9@ + Marked @__attribute((const))__@ - __exported by:__ @garnet_rs.h@ +__C declaration:__ @add@ + +__defined at:__ @garnet_rs.h 38:32@ + +__exported by:__ @garnet_rs.h@ -} add :: HsBindgen.Runtime.LibC.Int64 -- ^ __C declaration:__ @a@ -> HsBindgen.Runtime.LibC.Int64 -- ^ __C declaration:__ @b@ - -> IO HsBindgen.Runtime.LibC.Int64 + -> HsBindgen.Runtime.LibC.Int64 add = hs_bindgen_20eb651f0a8faf48 diff --git a/rust/garnet_rs.h b/rust/garnet_rs.h index 15aaba1..3bef3e6 100644 --- a/rust/garnet_rs.h +++ b/rust/garnet_rs.h @@ -35,4 +35,4 @@ void hello_struct(struct T t); void hello_shape(struct Shape s); -int64_t add(int64_t a, int64_t b); +__attribute__((const)) int64_t add(int64_t a, int64_t b); diff --git a/rust/lib.rs b/rust/lib.rs index 5be6262..3e2f64f 100644 --- a/rust/lib.rs +++ b/rust/lib.rs @@ -34,6 +34,7 @@ extern "C" fn hello_shape(s: Shape) -> () { say_hello(&format!("{:?}", s)) } +/// cbindgen:prefix=__attribute__((const)) #[unsafe(no_mangle)] extern "C" fn add(a: i64, b: i64) -> i64 { a + b