summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/helpers.h
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-05-17 08:48:02 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-05-17 08:48:02 (GMT)
commitf3e136eab9fd6adcb51988c9f70ca7f35552abc4 (patch)
tree69c074fec2b72637bd01142add44b130dd13a909 /plugins/pychrysalide/helpers.h
parent85bd3c6c415d42c0722298cf8e4542c94a87d7f1 (diff)
Introduced a new object of string constant sets.
Diffstat (limited to 'plugins/pychrysalide/helpers.h')
-rw-r--r--plugins/pychrysalide/helpers.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/pychrysalide/helpers.h b/plugins/pychrysalide/helpers.h
index dbc9272..5f28c57 100644
--- a/plugins/pychrysalide/helpers.h
+++ b/plugins/pychrysalide/helpers.h
@@ -225,6 +225,33 @@ PyObject *_cast_with_constants_group(const char *, const char *, unsigned long);
#define cast_with_constants_group_from_module(owner, name, value) \
_cast_with_constants_group(owner, name, value)
+/* Officialise un groupe de constantes de chaînes de caractères. */
+bool _create_string_constants_group(PyObject *, const char *, const char *, PyObject **);
+
+#define create_string_constants_group_to_type(type, name, doc, out) \
+ _create_string_constants_group(type->tp_dict, name, doc, out)
+
+#define create_string_constants_group_to_module(mod, name, doc, out) \
+ ({ \
+ bool __result; \
+ PyObject *__dict; \
+ __dict = PyModule_GetDict(mod); \
+ __result = _create_string_constants_group(__dict, name, doc, out); \
+ __result; \
+ })
+
+#define extend_string_constants_group(dict, key, str) \
+ ({ \
+ bool __result; \
+ PyObject *__str_obj; \
+ int __ret; \
+ __str_obj = PyUnicode_FromString(str); \
+ __ret = PyDict_SetItemString(dict, key, __str_obj); \
+ Py_DECREF(__str_obj); \
+ __result = (__ret == 0); \
+ __result; \
+ })
+
#endif /* _PLUGINS_PYCHRYSALIDE_HELPERS_H */