3.5.1. Atom Protocol#
Caterpillar provides a special protocol for working with atoms. It is designed to incorporate packing and unpacking of data streams as well as calculating its size and measuring its type.
Changed in version 2.6.0: Reworked the CAPI and its components.
-
type CpAtomObject#
All classes that implement capabilities of an atom should inherit from this class. It defines, but does not implement all four protocol methods. There are no specific members - consider this class to be an abstract base class.
-
PyTypeObject CpAtom_Type#
The type object of the
CpAtomclass.
TODO: describe missing functions
-
int CpAtom_HasPack(PyObject *o)#
-
int CpAtom_FastCanPack(PyObject *o, _coremodulestate *state)#
Return
1if the object provides an interface of packing other objects and0otherwise. Note that it returns1for classes with a__pack__()method, since the type of objects to be packed can not be determined by introspection.
-
int CpAtom_HasUnpack(PyObject *o)#
Return
1if the object provides an interface of unpacking other objects and0otherwise. Note that it returns1for classes with a__unpack__()method, since the type of objects to be unpacked can not be determined by introspection.
-
int CpAtom_HasType(PyObject *o)#
Returns
1if the object provides a method of determining the type this object (usually an atom) represents and0otherwise. As all other functions, this one will simply check for the presence of the__type__()method.
-
int CpAtom_HasSize(PyObject *o)#
Searches for
__size__(), returns1if it is present and0otherwise.