diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2022-08-18 21:59:22 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2022-08-18 21:59:22 (GMT) |
commit | d21ff9aca314bdab7156b5f990900735d4dfffd6 (patch) | |
tree | 62c0d699188f9d439a0807874cccaeb42825271f /plugins/pychrysalide | |
parent | 51e4bf015e0bd0320f2a44bd1f97f1cd7e95a41d (diff) |
Introduce new features to deal with structured data and Python.
Diffstat (limited to 'plugins/pychrysalide')
-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; \ |