language-c-inline-0.5.0.0: Inline C & Objective-C code in Haskell for language interoperability

Portabilitynon-portable (GHC extensions)
Stabilityexperimental
MaintainerManuel M T Chakravarty <chak@cse.unsw.edu.au>
Safe HaskellNone

Language.C.Inline.ObjC

Contents

Description

This module exports the principal API for inline Objective-C.

Synopsis

Re-export types from C

type CString = Ptr CChar

A C string is a reference to an array of C characters terminated by NUL.

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).

type CWString = Ptr CWchar

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 CWchars 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.

Instances

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.

objc_emit :: Q [Dec]Source

Emit the Objective-C file and return the foreign declarations. Needs to be the last use of an 'objc...' function. (Just put it at the end of the Haskell module.)