From 593eed5f8ec2c09e89fb2bde2421fc8bdda13ac0 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Tue, 22 Feb 2022 19:45:16 +0100 Subject: Improve Python bindings. --- plugins/pychrysalide/analysis/contents/encapsulated.c | 3 +++ plugins/pychrysalide/analysis/contents/memory.c | 6 +++++- plugins/pychrysalide/analysis/contents/restricted.c | 3 +++ plugins/pychrysalide/helpers.h | 9 +++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/plugins/pychrysalide/analysis/contents/encapsulated.c b/plugins/pychrysalide/analysis/contents/encapsulated.c index 03fce54..0e09f81 100644 --- a/plugins/pychrysalide/analysis/contents/encapsulated.c +++ b/plugins/pychrysalide/analysis/contents/encapsulated.c @@ -314,6 +314,9 @@ bool ensure_python_encaps_content_is_registered(void) if (!ensure_python_serializable_object_is_registered()) return false; + if (!ensure_python_binary_content_is_registered()) + return false; + if (!register_class_for_pygobject(dict, G_TYPE_ENCAPS_CONTENT, type, &PyGObject_Type)) return false; diff --git a/plugins/pychrysalide/analysis/contents/memory.c b/plugins/pychrysalide/analysis/contents/memory.c index 37b098d..4782445 100644 --- a/plugins/pychrysalide/analysis/contents/memory.c +++ b/plugins/pychrysalide/analysis/contents/memory.c @@ -31,6 +31,7 @@ #include +#include "../content.h" #include "../storage/serialize.h" #include "../../access.h" #include "../../helpers.h" @@ -153,7 +154,7 @@ PyTypeObject *get_python_memory_content_type(void) bool ensure_python_memory_content_is_registered(void) { - PyTypeObject *type; /* Type Python 'MemoryContent' */ + PyTypeObject *type; /* Type Python 'MemoryContent' */ PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ @@ -168,6 +169,9 @@ bool ensure_python_memory_content_is_registered(void) if (!ensure_python_serializable_object_is_registered()) return false; + if (!ensure_python_binary_content_is_registered()) + return false; + if (!register_class_for_pygobject(dict, G_TYPE_MEMORY_CONTENT, type, &PyGObject_Type)) return false; diff --git a/plugins/pychrysalide/analysis/contents/restricted.c b/plugins/pychrysalide/analysis/contents/restricted.c index 703f79b..47df8c5 100644 --- a/plugins/pychrysalide/analysis/contents/restricted.c +++ b/plugins/pychrysalide/analysis/contents/restricted.c @@ -204,6 +204,9 @@ bool ensure_python_restricted_content_is_registered(void) if (!ensure_python_serializable_object_is_registered()) return false; + if (!ensure_python_binary_content_is_registered()) + return false; + if (!register_class_for_pygobject(dict, G_TYPE_RESTRICTED_CONTENT, type, &PyGObject_Type)) return false; diff --git a/plugins/pychrysalide/helpers.h b/plugins/pychrysalide/helpers.h index 32851c0..2285259 100644 --- a/plugins/pychrysalide/helpers.h +++ b/plugins/pychrysalide/helpers.h @@ -277,6 +277,15 @@ int convert_to_gdk_rgba(PyObject *, void *); }) +#define TRANSLATE_NUMERIC_FIELD(dict, base, field) \ + ({ \ + PyObject *__attrib; \ + __attrib = PyLong_FromUnsignedLongLong(base->field); \ + Py_INCREF(__attrib); \ + ADD_FIELD_TRANSLATION(dict, #field, __attrib); \ + }) + + #define TRANSLATE_STRING_FIELD(dict, base, field) \ ({ \ PyObject *__attrib; \ -- cgit v0.11.2-87-g4458