summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/arch/operand.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-01-26 09:19:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-01-26 09:19:53 (GMT)
commitdff8fd4c83d9833d4539e2dd0c9d3f998b73608f (patch)
tree5e1088e0572b1e921df6d31d3db3ef753d97555b /plugins/pychrysalide/arch/operand.c
parentae3725eae3c1f2008e6f26b1057d97a6b9050a3c (diff)
Extended the Python API.
Diffstat (limited to 'plugins/pychrysalide/arch/operand.c')
-rw-r--r--plugins/pychrysalide/arch/operand.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/pychrysalide/arch/operand.c b/plugins/pychrysalide/arch/operand.c
index 4630b3a..6780e10 100644
--- a/plugins/pychrysalide/arch/operand.c
+++ b/plugins/pychrysalide/arch/operand.c
@@ -223,3 +223,48 @@ bool ensure_python_arch_operand_is_registered(void)
return true;
}
+
+
+/******************************************************************************
+* *
+* 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 opérande d'architecture. *
+* *
+* Retour : Bilan de l'opération, voire indications supplémentaires. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+int convert_to_arch_operand(PyObject *arg, void *dst)
+{
+ int result; /* Bilan à retourner */
+
+ result = PyObject_IsInstance(arg, (PyObject *)get_python_arch_operand_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 arch operand");
+ break;
+
+ case 1:
+ *((GArchOperand **)dst) = G_ARCH_OPERAND(pygobject_get(arg));
+ break;
+
+ default:
+ assert(false);
+ break;
+
+ }
+
+ return result;
+
+}