Portability | non-portable (GHC extensions) |
---|---|
Stability | experimental |
Maintainer | Manuel M T Chakravarty <chak@cse.unsw.edu.au> |
Safe Haskell | None |
This module exports the principal API for inline Objective-C.
- module Foreign.C.Types
- type CString = Ptr CChar
- type CStringLen = (Ptr CChar, Int)
- type CWString = Ptr CWchar
- type CWStringLen = (Ptr CWchar, Int)
- data Errno
- objc_import :: [FilePath] -> Q [Dec]
- objc_interface :: [Definition] -> Q [Dec]
- objc_implementation :: [Name] -> [Definition] -> Q [Dec]
- objc :: [Name] -> Name -> Exp -> Q Exp
- objc_emit :: Q [Dec]
Re-export types from C
module Foreign.C.Types
type CStringLen = (Ptr CChar, Int)
A string with explicit length information in bytes instead of a terminating NUL (allowing NUL characters in the middle of the string).
A C wide string is a reference to an array of C wide characters terminated by NUL.
type CWStringLen = (Ptr CWchar, Int)
A wide character string with explicit length information in CWchar
s
instead of a terminating NUL (allowing NUL characters in the middle
of the string).
data Errno
Haskell representation for errno
values.
The implementation is deliberately exposed, to allow users to add
their own definitions of Errno
values.
Combinators for inline Objective-C
objc_import :: [FilePath] -> Q [Dec]Source
Specify imported Objective-C files. Needs to be spliced where an import declaration can appear. (Just put it straight after all the import statements in the module.)
FIXME: need to use TH.addDependentFile on each of the imported ObjC files & read headers
objc_interface :: [Definition] -> Q [Dec]Source
Inline Objective-C top-level definitions for a header file ('.h').
objc_implementation :: [Name] -> [Definition] -> Q [Dec]Source
Inline Objective-C top-level definitions for an implementation file ('.m').
The top-level Haskell variables given in the first argument will be foreign exported to be accessed from the generated Objective-C code. In C, these Haskell variables will always be represented as functions. (In particular, if the Haskell variable refers to a CAF, it will be a nullary function in C — after all, a thunk may still need to be evaluated.)
objc :: [Name] -> Name -> Exp -> Q ExpSource
Inline Objective-C expression.
The inline expression will be wrapped in a C function whose arguments are marshalled versions of the Haskell variables given in the first argument and whose return value will be marshalled to the Haskell type given by the second argument.