summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/format/symbol.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-07-21 20:21:59 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-07-21 20:21:59 (GMT)
commit6a8385724c74b07cf9ed4cb9052f1af1816e3ea5 (patch)
treea7bea8a4bb9c816da77cf5c3dd44fbd8fb89b3a7 /plugins/pychrysalide/format/symbol.c
parentf0682e7b195acbd4d83148f3829479d682f9ee9f (diff)
Created more converters for Python arguments.
Diffstat (limited to 'plugins/pychrysalide/format/symbol.c')
-rw-r--r--plugins/pychrysalide/format/symbol.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/pychrysalide/format/symbol.c b/plugins/pychrysalide/format/symbol.c
index bb58f64..3295e8c 100644
--- a/plugins/pychrysalide/format/symbol.c
+++ b/plugins/pychrysalide/format/symbol.c
@@ -25,6 +25,7 @@
#include "symbol.h"
+#include <assert.h>
#include <malloc.h>
#include <pygobject.h>
@@ -502,3 +503,48 @@ bool ensure_python_binary_symbol_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 symbole binaire. *
+* *
+* Retour : Bilan de l'opération, voire indications supplémentaires. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+int convert_to_binary_symbol(PyObject *arg, void *dst)
+{
+ int result; /* Bilan à retourner */
+
+ result = PyObject_IsInstance(arg, (PyObject *)get_python_binary_symbol_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 binary symbol");
+ break;
+
+ case 1:
+ *((GBinSymbol **)dst) = G_BIN_SYMBOL(pygobject_get(arg));
+ break;
+
+ default:
+ assert(false);
+ break;
+
+ }
+
+ return result;
+
+}