diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/pychrysalide/helpers.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/pychrysalide/helpers.h b/plugins/pychrysalide/helpers.h index 2285259..52a9370 100644 --- a/plugins/pychrysalide/helpers.h +++ b/plugins/pychrysalide/helpers.h @@ -286,6 +286,32 @@ int convert_to_gdk_rgba(PyObject *, void *); }) +#define RETRIEVE_NUMERIC_FIELD(dict, base, field) \ + ({ \ + bool __status; \ + PyObject *__attrib; \ + __status = false; \ + __attrib = PyDict_GetItemString(dict, #field); \ + if (__attrib != NULL && PyLong_Check(__attrib)) \ + { \ + base->field = PyLong_AsUnsignedLongLong(__attrib); \ + __status = (PyErr_Occurred() == NULL); \ + } \ + __status; \ + }) + + +#define TRANSLATE_BYTES_FIELD(dict, base, field, len) \ + ({ \ + void *__data; \ + PyObject *__attrib; \ + __data = (void *)&base->field; \ + __attrib = PyBytes_FromStringAndSize(__data, len); \ + Py_INCREF(__attrib); \ + ADD_FIELD_TRANSLATION(dict, #field, __attrib); \ + }) + + #define TRANSLATE_STRING_FIELD(dict, base, field) \ ({ \ PyObject *__attrib; \ |