diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2022-10-04 13:30:04 +0200 |
|---|---|---|
| committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2023-07-08 10:58:42 +0300 |
| commit | 5371bbf321841acf7a0b5531e738a28e51cba845 (patch) | |
| tree | 3580d28fc3785082670f9065e00fa6b604c9977e /lib/command_py.c | |
| parent | 7c95fd50c6b2bb600d6a4a8a6ab6216111d18ca9 (diff) | |
lib: make cmd_element->attr a bitmask & clarify
It already "looks" like a bitmask, but we currently can't flag a command
both YANG and HIDDEN at the same time. It really should be a bitmask.
Also clarify DEPRECATED behaviour (or the absence thereof.)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/command_py.c')
| -rw-r--r-- | lib/command_py.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/command_py.c b/lib/command_py.c index 6301eec5e8..ff7b2d18a5 100644 --- a/lib/command_py.c +++ b/lib/command_py.c @@ -226,8 +226,8 @@ static PyObject *graph_to_pyobj(struct wrap_graph *wgraph, wrap->type = "???"; } - wrap->deprecated = (tok->attr == CMD_ATTR_DEPRECATED); - wrap->hidden = (tok->attr == CMD_ATTR_HIDDEN); + wrap->deprecated = !!(tok->attr & CMD_ATTR_DEPRECATED); + wrap->hidden = !!(tok->attr & CMD_ATTR_HIDDEN); wrap->text = tok->text; wrap->desc = tok->desc; wrap->varname = tok->varname; @@ -353,6 +353,11 @@ PyMODINIT_FUNC command_py_init(void) if (!pymod) initret(NULL); + if (PyModule_AddIntMacro(pymod, CMD_ATTR_YANG) + || PyModule_AddIntMacro(pymod, CMD_ATTR_HIDDEN) + || PyModule_AddIntMacro(pymod, CMD_ATTR_DEPRECATED)) + initret(NULL); + Py_INCREF(&typeobj_graph_node); PyModule_AddObject(pymod, "GraphNode", (PyObject *)&typeobj_graph_node); Py_INCREF(&typeobj_graph); |
