Scraps of notes on pyxed development.
huku <[email protected]>
Most functions exported to Python are simple wrappers around the low level C API
offered by XED2. To be properly returned to the user, the return values of those
C functions must be converted to one of the datatypes recognized by the Python
runtime (i.e. PyObject
pointers). For the sake of developing pyxed, I
settled down to the following set of simple guidelines:
-
When a XED2 function returns
xed_uint_t
to indicate a true/false result, orxed_bool_t
(alsotypedef
'ed tounsigned int
), usePyBool_FromLong()
to retrieve the corresponding Python object. -
When functions return arbitrary values of type
xed_uint_t
, usePyLong_FromUnsignedLong()
. -
For return values of type
xed_*_enum_t
, usePyInt_FromLong()
(according to the C standard, enumerations are treated asint
values).