This page is not complete.
Library object represents a native library loaded by the ctypes
open() method. Its methods let you declare symbols exported by the library, and to manage the library.
Closes the library. You need to call this once you're done using the library.
CData declare( name[, abi, returnType argType1, ...] );
ABIused by the exported function; this will be
ctypes.default_abifor most libraries, except for Windows libraries, which will be
ctypes.stdcall_abi. See ABI constants. You don't need to provide this for exported data; it's only needed for function declarations.
CTypetype returned by the defined API, if it's a function. This parameter should not be provided if the API is an exported data symbol.
- Zero or more parameter
CTypemay be specified for the parameters of the function being declared. These should not be provided if the API is an exported data symbol rather than a function.
- The return type was specified as an array.
Another use for ctypes.declare is to get non-function/non-methods from libraries. The syntax for this is seen in Firefox codebase here:
This shows that we can also supply only two arguments to the declare function. The first being the same as in the above example, name, which is the name of the symbol to export. And in place of the abi argument, we will pass in the type of this export. For example, from the Objective-C library we can export the symbol which holds the address to an external block. This would be done like this:
var objc = ctypes.open(ctypes.libraryName('objc')); objc.declare('_NSConcreteGlobalBlock', ctypes.voidptr_t);