-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Inline C & Objective-C code in Haskell for language interoperability
--
-- This library provides inline C & Objective-C code using GHC's
-- support for quasi-quotation. In particular, it enables the use of
-- foreign libraries without a dedicated bridge or binding. Here is a
-- tiny example:
--
--
-- nslog :: String -> IO ()
-- nslog msg = $(objc ['msg] ''() [cexp| NSLog(@"Here is a message from Haskell: %@", msg) |])
--
--
-- For more information, see
-- https://github.com/mchakravarty/language-c-inline/wiki.
--
-- Known bugs:
-- https://github.com/mchakravarty/language-c-inline/issues
--
--
-- - New in 0.5.0.0: Marshalling of numeric types
-- - New in 0.4.0.0: Maybe types are marshalled as pointers that may be
-- nil & bug fixes.
-- - New in 0.3.0.0: Boxed Haskell types without a dedicated type
-- mapping are marshalled using stable pointers.
-- - New in 0.2.0.0: Support for multiple free variables in one inline
-- expression as well as for inline code returning void.
-- - New in 0.1.0.0: We are just getting started! This is just a ROUGH
-- AND HIGHLY EXPERIMENTAL PROTOTYPE.
--
@package language-c-inline
@version 0.5.0.0
-- | This module exports the principal API for inline Objective-C.
module Language.C.Inline.ObjC
-- | A C string is a reference to an array of C characters terminated by
-- NUL.
type CString = Ptr CChar
-- | A string with explicit length information in bytes instead of a
-- terminating NUL (allowing NUL characters in the middle of the string).
type CStringLen = (Ptr CChar, Int)
-- | A C wide string is a reference to an array of C wide characters
-- terminated by NUL.
type CWString = Ptr CWchar
-- | A wide character string with explicit length information in
-- CWchars instead of a terminating NUL (allowing NUL characters
-- in the middle of the string).
type CWStringLen = (Ptr CWchar, Int)
-- | Haskell representation for errno values. The implementation
-- is deliberately exposed, to allow users to add their own definitions
-- of Errno values.
data Errno :: *
-- | 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_import :: [FilePath] -> Q [Dec]
-- | Inline Objective-C top-level definitions for a header file ('.h').
objc_interface :: [Definition] -> Q [Dec]
-- | 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_implementation :: [Name] -> [Definition] -> Q [Dec]
-- | 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 :: [Name] -> Name -> Exp -> Q Exp
-- | 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.)
objc_emit :: Q [Dec]