Skip to content

Commit fe45e2f

Browse files
committed
add std::ffi context
1 parent 06c3d11 commit fe45e2f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Language/Rust/Inline.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module Language.Rust.Inline (
5151
getHTypeInContext,
5252
-- ** Built-in contexts
5353
basic,
54+
ffi,
5455
libc,
5556
ghcUnboxed,
5657
functions,

src/Language/Rust/Inline/Context.hs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,24 @@ singleton rts qht = mkContext [(rts, qht, True)]
145145

146146
-- * Some handy contexts
147147

148+
-- | Types defined in 'Foreign.C.Types' and the 'std::ffi' module.
149+
ffi :: Q Context
150+
ffi = mkContext
151+
[ ([ty| std::ffi::c_char |], [t| CChar |], False)
152+
, ([ty| std::ffi::c_double |], [t| CDouble |], False)
153+
, ([ty| std::ffi::c_float |], [t| CFloat |], False)
154+
, ([ty| std::ffi::c_int |], [t| CInt |], False)
155+
, ([ty| std::ffi::c_long |], [t| CLong |], False)
156+
, ([ty| std::ffi::c_longlong |], [t| CLLong |], False)
157+
, ([ty| std::ffi::c_schar |], [t| CSChar |], False)
158+
, ([ty| std::ffi::c_short |], [t| CShort |], False)
159+
, ([ty| std::ffi::c_uchar |], [t| CUChar |], False)
160+
, ([ty| std::ffi::c_uint |], [t| CUInt |], False)
161+
, ([ty| std::ffi::c_ulong |], [t| CULong |], False)
162+
, ([ty| std::ffi::c_ulonglong |], [t| CULLong |], False)
163+
, ([ty| std::ffi::c_ushort |], [t| CUShort |], False)
164+
]
165+
148166
-- | Types defined in 'Foreign.C.Types' and the 'libc' crate.
149167
--
150168
-- There should be no conversion required here - these have /identical/ memory

0 commit comments

Comments
 (0)