cpython-3.3.0: Bindings for libpython

Safe HaskellNone




getPointer :: Capsule -> Maybe Text -> IO (Ptr ())Source

Retrieve the pointer stored in the capsule. On failure, throws an exception.

The name parameter must compare exactly to the name stored in the capsule. If the name stored in the capsule is Nothing, the name passed in must also be Nothing. Python uses the C function strcmp() to compare capsule names.

getContext :: Capsule -> IO (Ptr ())Source

Return the current context stored in the capsule, which might be NULL.

getName :: Capsule -> IO (Maybe Text)Source

Return the current name stored in the capsule, which might be Nothing.

importNamed :: Text -> Bool -> IO (Maybe (Ptr ()))Source

Import a pointer to a C object from a capsule attribute in a module. The name parameter should specify the full name to the attribute, as in "module.attribute". The name stored in the capsule must match this string exactly. If the second parameter is False, import the module without blocking (using PyImport_ImportModuleNoBlock()). Otherwise, imports the module conventionally (using PyImport_ImportModule()).

Return the capsule’s internal pointer on success. On failure, throw an exception. If the module could not be imported, and if importing in non-blocking mode, returns Nothing.

isValid :: Capsule -> Maybe Text -> IO BoolSource

Determines whether or not a capsule is valid. A valid capsule's type is capsuleType, has a non-NULL pointer stored in it, and its internal name matches the name parameter. (See getPointer for information on how capsule names are compared.)

In other words, if isValid returns True, calls to any of the accessors (any function starting with get) are guaranteed to succeed.

setPointer :: Capsule -> Ptr () -> IO ()Source

Set the void pointer inside the capsule. The pointer may not be NULL.

setContext :: Capsule -> Ptr () -> IO ()Source

Set the context pointer inside the capsule.