summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/arch
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-05-21 20:43:30 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-05-21 20:43:30 (GMT)
commitd8eb070be32504949ad55fd644d9f1a69df1e05d (patch)
tree321a2591b67b3131baa514fdfe47ae492f665263 /plugins/pychrysalide/arch
parent7e5b1add6fdeb74b2356acf8ccf7009f45cfa85e (diff)
Written a proper documentation for the binary format Python bindings.
Diffstat (limited to 'plugins/pychrysalide/arch')
-rw-r--r--plugins/pychrysalide/arch/constants.c56
-rw-r--r--plugins/pychrysalide/arch/constants.h3
2 files changed, 59 insertions, 0 deletions
diff --git a/plugins/pychrysalide/arch/constants.c b/plugins/pychrysalide/arch/constants.c
index f738ec3..04d0917 100644
--- a/plugins/pychrysalide/arch/constants.c
+++ b/plugins/pychrysalide/arch/constants.c
@@ -192,3 +192,59 @@ bool define_proc_context_constants(PyTypeObject *type)
return result;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : arg = argument quelconque à tenter de convertir. *
+* dst = destination des valeurs récupérées en cas de succès. *
+* *
+* Description : Tente de convertir en constante DisassPriorityLevel. *
+* *
+* Retour : Bilan de l'opération, voire indications supplémentaires. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+int convert_to_disass_priority_level(PyObject *arg, void *dst)
+{
+ int result; /* Bilan à retourner */
+ unsigned long value; /* Valeur transcrite */
+
+ result = PyObject_IsInstance(arg, (PyObject *)&PyLong_Type);
+
+ switch (result)
+ {
+ case -1:
+ /* L'exception est déjà fixée par Python */
+ result = 0;
+ break;
+
+ case 0:
+ PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to DisassPriorityLevel");
+ break;
+
+ case 1:
+ value = PyLong_AsUnsignedLong(arg);
+
+ if (value > DPL_COUNT)
+ {
+ PyErr_SetString(PyExc_TypeError, "invalid value for DisassPriorityLevel");
+ result = 0;
+ }
+
+ else
+ *((DisassPriorityLevel *)dst) = value;
+
+ break;
+
+ default:
+ assert(false);
+ break;
+
+ }
+
+ return result;
+
+}
diff --git a/plugins/pychrysalide/arch/constants.h b/plugins/pychrysalide/arch/constants.h
index f047c56..24b3908 100644
--- a/plugins/pychrysalide/arch/constants.h
+++ b/plugins/pychrysalide/arch/constants.h
@@ -40,6 +40,9 @@ bool define_arch_vmpa_constants(PyTypeObject *);
/* Définit les constantes relatives aux contextes. */
bool define_proc_context_constants(PyTypeObject *);
+/* Tente de convertir en constante DisassPriorityLevel. */
+int convert_to_disass_priority_level(PyObject *, void *);
+
#endif /* _PLUGINS_PYCHRYSALIDE_ARCH_CONSTANTS_H */