From d21ff9aca314bdab7156b5f990900735d4dfffd6 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Thu, 18 Aug 2022 23:59:22 +0200
Subject: Introduce new features to deal with structured data and Python.

---
 plugins/pychrysalide/helpers.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

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;                                         \
-- 
cgit v0.11.2-87-g4458