diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2022-10-04 13:30:04 +0200 |
|---|---|---|
| committer | David Lamparter <equinox@opensourcerouting.org> | 2022-10-06 15:34:32 +0200 |
| commit | 9eebf97e3d3fe8bff0d3c5ecdae39f15bd93f40b (patch) | |
| tree | 04b57dbd4183fd0f0b415a022e12cb72e29fdf16 /lib/command_py.c | |
| parent | 53d8bf6d7a233ccc97e0f466374878f2b8e3f657 (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); |
