💾 Archived View for tris.fyi › pydoc › _cffi_backend captured on 2022-04-28 at 17:28:54. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-01-08)
-=-=-=-=-=-=-
This module has no docstring.
bitshift = <member 'bitshift' of '_cffi_backend.CField' objects>
bitsize = <member 'bitsize' of '_cffi_backend.CField' objects>
flags = <member 'flags' of '_cffi_backend.CField' objects>
offset = <member 'offset' of '_cffi_backend.CField' objects>
type = <member 'type' of '_cffi_backend.CField' objects>
close_lib(...)
load_function(...)
read_variable(...)
write_variable(...)
abi = <attribute 'abi' of '_cffi_backend.CType' objects> function ABI
args = <attribute 'args' of '_cffi_backend.CType' objects> function argument types
cname = <attribute 'cname' of '_cffi_backend.CType' objects> C name
elements = <attribute 'elements' of '_cffi_backend.CType' objects> enum elements
ellipsis = <attribute 'ellipsis' of '_cffi_backend.CType' objects> function has '...'
fields = <attribute 'fields' of '_cffi_backend.CType' objects> struct or union fields
item = <attribute 'item' of '_cffi_backend.CType' objects> pointer to, or array of
kind = <attribute 'kind' of '_cffi_backend.CType' objects> kind
length = <attribute 'length' of '_cffi_backend.CType' objects> array length or None
relements = <attribute 'relements' of '_cffi_backend.CType' objects> enum elements, reverse
result = <attribute 'result' of '_cffi_backend.CType' objects> function result type
The internal base type for CData objects. Use FFI.CData to access it. Always check with isinstance(): subtypes are sometimes returned on CPython, for performance reasons.
abi = <attribute 'abi' of '_cffi_backend.CType' objects> function ABI
args = <attribute 'args' of '_cffi_backend.CType' objects> function argument types
cname = <attribute 'cname' of '_cffi_backend.CType' objects> C name
elements = <attribute 'elements' of '_cffi_backend.CType' objects> enum elements
ellipsis = <attribute 'ellipsis' of '_cffi_backend.CType' objects> function has '...'
fields = <attribute 'fields' of '_cffi_backend.CType' objects> struct or union fields
item = <attribute 'item' of '_cffi_backend.CType' objects> pointer to, or array of
kind = <attribute 'kind' of '_cffi_backend.CType' objects> kind
length = <attribute 'length' of '_cffi_backend.CType' objects> array length or None
relements = <attribute 'relements' of '_cffi_backend.CType' objects> enum elements, reverse
result = <attribute 'result' of '_cffi_backend.CType' objects> function result type
ffi.buffer(cdata[, byte_size]): Return a read-write buffer object that references the raw C data pointed to by the given 'cdata'. The 'cdata' must be a pointer or an array. Can be passed to functions expecting a buffer, or directly manipulated with: buf[:] get a copy of it in a regular string, or buf[idx] as a single character buf[:] = ... buf[idx] = ... change the content
with_traceback(...) Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>
addressof(...) Limited equivalent to the '&' operator in C: 1. ffi.addressof(<cdata 'struct-or-union'>) returns a cdata that is a pointer to this struct or union. 2. ffi.addressof(<cdata>, field-or-index...) returns the address of a field or array item inside the given structure or array, recursively in case of nested structures or arrays. 3. ffi.addressof(<library>, "name") returns the address of the named function or global variable.
alignof(...) Return the natural alignment size in bytes of the argument. It can be a string naming a C type, or a 'cdata' instance.
callback(...) Return a callback object or a decorator making such a callback object. 'cdecl' must name a C function pointer type. The callback invokes the specified 'python_callable' (which may be provided either directly or via a decorator). Important: the callback object must be manually kept alive for as long as the callback may be invoked from the C code.
cast(...) Similar to a C cast: returns an instance of the named C type initialized with the given 'source'. The source is casted between integers or pointers of any type.
def_extern(...) A decorator. Attaches the decorated Python function to the C code generated for the 'extern "Python"' function of the same name. Calling the C function will then invoke the Python function. Optional arguments: 'name' is the name of the C function, if different from the Python function; and 'error' and 'onerror' handle what occurs if the Python function raises an exception (see the docs for details).
dlclose(...) Close a library obtained with ffi.dlopen(). After this call, access to functions or variables from the library will fail (possibly with a segmentation fault).
dlopen(...) Load and return a dynamic library identified by 'name'. The standard C library can be loaded by passing None. Note that functions and types declared with 'ffi.cdef()' are not linked to a particular library, just like C headers. In the library we only look for the actual (untyped) symbols at the time of their first access.
from_buffer(...) Return a <cdata 'char[]'> that points to the data of the given Python object, which must support the buffer interface. Note that this is not meant to be used on the built-in types str or unicode (you can build 'char[]' arrays explicitly) but only on objects containing large quantities of raw data in some other format, like 'array.array' or numpy arrays.
from_handle(...) Cast a 'void *' back to a Python object. Must be used *only* on the pointers returned by new_handle(), and *only* as long as the exact cdata object returned by new_handle() is still alive (somewhere else in the program). Failure to follow these rules will crash.
gc(...) Return a new cdata object that points to the same data. Later, when this new cdata object is garbage-collected, 'destructor(old_cdata_object)' will be called. The optional 'size' gives an estimate of the size, used to trigger the garbage collection more eagerly. So far only used on PyPy. It tells the GC that the returned object keeps alive roughly 'size' bytes of external memory.
getctype(...) Return a string giving the C type 'cdecl', which may be itself a string or a <ctype> object. If 'replace_with' is given, it gives extra text to append (or insert for more complicated C types), like a variable name, or '*' to get actually the C type 'pointer-to-cdecl'.
init_once(...) init_once(function, tag): run function() once. More precisely, 'function()' is called the first time we see a given 'tag'. The return value of function() is remembered and returned by the current and all future init_once() with the same tag. If init_once() is called from multiple threads in parallel, all calls block until the execution of function() is done. If function() raises an exception, it is propagated and nothing is cached.
integer_const(...) Get the value of an integer constant. 'ffi.integer_const("xxx")' is equivalent to 'lib.xxx' if xxx names an integer constant. The point of this function is limited to use cases where you have an 'ffi' object but not any associated 'lib' object.
list_types(...) Returns the user type names known to this FFI instance. This returns a tuple containing three lists of names: (typedef_names, names_of_structs, names_of_unions)
memmove(...) ffi.memmove(dest, src, n) copies n bytes of memory from src to dest. Like the C function memmove(), the memory areas may overlap; apart from that it behaves like the C function memcpy(). 'src' can be any cdata ptr or array, or any Python buffer object. 'dest' can be any cdata ptr or array, or a writable Python buffer object. The size to copy, 'n', is always measured in bytes. Unlike other methods, this one supports all Python buffer including byte strings and bytearrays---but it still does not support non-contiguous buffers.
new(...) Allocate an instance according to the specified C type and return a pointer to it. The specified C type must be either a pointer or an array: ``new('X *')`` allocates an X and returns a pointer to it, whereas ``new('X[n]')`` allocates an array of n X'es and returns an array referencing it (which works mostly like a pointer, like in C). You can also use ``new('X[]', n)`` to allocate an array of a non-constant length n. The memory is initialized following the rules of declaring a global variable in C: by default it is zero-initialized, but an explicit initializer can be given which can be used to fill all or part of the memory. When the returned <cdata> object goes out of scope, the memory is freed. In other words the returned <cdata> object has ownership of the value of type 'cdecl' that it points to. This means that the raw data can be used as long as this object is kept alive, but must not be used for a longer time. Be careful about that when copying the pointer to the memory somewhere else, e.g. into another structure.
new_allocator(...) Return a new allocator, i.e. a function that behaves like ffi.new() but uses the provided low-level 'alloc' and 'free' functions. 'alloc' is called with the size as argument. If it returns NULL, a MemoryError is raised. 'free' is called with the result of 'alloc' as argument. Both can be either Python functions or directly C functions. If 'free' is None, then no free function is called. If both 'alloc' and 'free' are None, the default is used. If 'should_clear_after_alloc' is set to False, then the memory returned by 'alloc' is assumed to be already cleared (or you are fine with garbage); otherwise CFFI will clear it.
new_handle(...) Return a non-NULL cdata of type 'void *' that contains an opaque reference to the argument, which can be any Python object. To cast it back to the original object, use from_handle(). You must keep alive the cdata object returned by new_handle()!
offsetof(...) Return the offset of the named field inside the given structure or array, which must be given as a C type name. You can give several field names in case of nested structures. You can also give numeric values which correspond to array items, in case of an array type.
release(...) Release now the resources held by a 'cdata' object from ffi.new(), ffi.gc() or ffi.from_buffer(). The cdata object must not be used afterwards. 'ffi.release(cdata)' is equivalent to 'cdata.__exit__()'. Note that on CPython this method has no effect (so far) on objects returned by ffi.new(), because the memory is allocated inline with the cdata object and cannot be freed independently. It might be fixed in future releases of cffi.
sizeof(...) Return the size in bytes of the argument. It can be a string naming a C type, or a 'cdata' instance.
string(...) Return a Python string (or unicode string) from the 'cdata'. If 'cdata' is a pointer or array of characters or bytes, returns the null-terminated string. The returned string extends until the first null character, or at most 'maxlen' characters. If 'cdata' is an array then 'maxlen' defaults to its length. If 'cdata' is a pointer or array of wchar_t, returns a unicode string following the same rules. If 'cdata' is a single character or byte or a wchar_t, returns it as a string or unicode string. If 'cdata' is an enum, returns the value of the enumerator as a string, or 'NUMBER' if the value is out of range.
typeof(...) Parse the C type given as a string and return the corresponding <ctype> object. It can also be used on 'cdata' instance to get its C type.
unpack(...) Unpack an array of C data of the given length, returning a Python string/unicode/list. If 'cdata' is a pointer to 'char', returns a byte string. It does not stop at the first null. This is equivalent to: ffi.buffer(cdata, length)[:] If 'cdata' is a pointer to 'wchar_t', returns a unicode string. 'length' is measured in wchar_t's; it is not the size in bytes. If 'cdata' is a pointer to anything else, returns a list of 'length' items. This is a faster equivalent to: [cdata[i] for i in range(length)]
NULL = <cdata 'void *' NULL>
RTLD_DEEPBIND = 8
RTLD_GLOBAL = 256
RTLD_LAZY = 1
RTLD_LOCAL = 0
RTLD_NODELETE = 4096
RTLD_NOLOAD = 4
RTLD_NOW = 2
errno = <attribute 'errno' of '_cffi_backend.FFI' objects> the value of 'errno' from/to the C calls
ffi.buffer(cdata[, byte_size]): Return a read-write buffer object that references the raw C data pointed to by the given 'cdata'. The 'cdata' must be a pointer or an array. Can be passed to functions expecting a buffer, or directly manipulated with: buf[:] get a copy of it in a regular string, or buf[idx] as a single character buf[:] = ... buf[idx] = ... change the content
alignof(...)
callback(...)
cast(...)
complete_struct_or_union(...)
from_buffer(...)
from_handle(...)
gcp(...)
get_errno(...)
getcname(...)
load_library(...)
memmove(...)
new_array_type(...)
new_enum_type(...)
new_function_type(...)
new_pointer_type(...)
new_primitive_type(...)
new_struct_type(...)
new_union_type(...)
new_void_type(...)
newp(...)
newp_handle(...)
rawaddressof(...)
release(...)
set_errno(...)
sizeof(...)
string(...)
typeof(...)
typeoffsetof(...)
unpack(...)
FFI_CDECL = 2
FFI_DEFAULT_ABI = 2
RTLD_DEEPBIND = 8
RTLD_GLOBAL = 256
RTLD_LAZY = 1
RTLD_LOCAL = 0
RTLD_NODELETE = 4096
RTLD_NOLOAD = 4
RTLD_NOW = 2