diff options
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) |