diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-01-03 22:51:31 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-01-03 22:51:31 (GMT) |
commit | 8255d60ac64a851c2e7ca37d63aa1ba37d35b704 (patch) | |
tree | 06f1855dd7ead9da2acc0c595e3710faf503628f /plugins/pychrysalide/helpers.h | |
parent | 90b8f66eb8ae62d951dfbd333fb338e38874c9fe (diff) |
Used a Python enumeration for verbosity levels.
Diffstat (limited to 'plugins/pychrysalide/helpers.h')
-rw-r--r-- | plugins/pychrysalide/helpers.h | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/plugins/pychrysalide/helpers.h b/plugins/pychrysalide/helpers.h index 3bb457d..8ee47e3 100644 --- a/plugins/pychrysalide/helpers.h +++ b/plugins/pychrysalide/helpers.h @@ -165,9 +165,6 @@ int forward_pygobjet_init(PyObject *); /* ----------------------- TRANSFERT DES VALEURS CONSTANTES ------------------------- */ -/* Officialise un groupe de constantes avec sémentique. */ -bool attach_constants_group(PyTypeObject *, bool, const char *, PyObject *, const char *); - /* Simplification d'un ajout de constante pour l'appelant */ #define add_const_to_group(d, n, v) \ ({ \ @@ -186,8 +183,31 @@ bool attach_constants_group(PyTypeObject *, bool, const char *, PyObject *, cons __result; \ }) +/* Officialise un groupe de constantes avec sémentique. */ +bool _attach_constants_group(const char *, PyObject *, bool, const char *, PyObject *, const char *); + +#define attach_constants_group_to_type(type, flags, name, values, doc) \ + _attach_constants_group(type->tp_name, type->tp_dict, flags, name, values, doc) + +#define attach_constants_group_to_module(mod, flags, name, values, doc) \ + ({ \ + bool __result; \ + const char *__owner; \ + PyObject *__dict; \ + __owner = PyModule_GetName(mod); \ + __dict = PyModule_GetDict(mod); \ + __result = _attach_constants_group(__owner, __dict, flags, name, values, doc); \ + __result; \ + }) + /* Traduit une valeur constante C en équivalent Python. */ -PyObject *cast_with_constants_group(const PyTypeObject *, const char *, unsigned long); +PyObject *_cast_with_constants_group(const char *, const char *, unsigned long); + +#define cast_with_constants_group_from_type(type, name, value) \ + _cast_with_constants_group(type->tp_name, name, value) + +#define cast_with_constants_group_from_module(owner, name, value) \ + _cast_with_constants_group(owner, name, value) |