diff options
author | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:03:14 +0200 |
---|---|---|
committer | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:04:07 +0200 |
commit | d62a17aedeb0eebdba98238874bb13d62c48dbf9 (patch) | |
tree | 3b319b1d61c8b85b4d1f06adf8b844bb8a9b5107 /lib/command_py.c | |
parent | *: add indent control files (diff) | |
download | frr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.tar.xz frr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.zip |
*: reindentreindent-master-after
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/command_py.c')
-rw-r--r-- | lib/command_py.c | 152 |
1 files changed, 77 insertions, 75 deletions
diff --git a/lib/command_py.c b/lib/command_py.c index 6621b0fa7..785d2ffa7 100644 --- a/lib/command_py.c +++ b/lib/command_py.c @@ -31,7 +31,8 @@ #include "clippy.h" struct wrap_graph; -static PyObject *graph_to_pyobj(struct wrap_graph *graph, struct graph_node *gn); +static PyObject *graph_to_pyobj(struct wrap_graph *graph, + struct graph_node *gn); /* * nodes are wrapped as follows: @@ -44,7 +45,7 @@ static PyObject *graph_to_pyobj(struct wrap_graph *graph, struct graph_node *gn) struct wrap_graph_node { PyObject_HEAD - bool allowrepeat; + bool allowrepeat; const char *type; bool deprecated; @@ -69,30 +70,29 @@ struct wrap_graph_node { struct wrap_graph { PyObject_HEAD - char *definition; + char *definition; struct graph *graph; struct wrap_graph_node **nodewrappers; }; static PyObject *refuse_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyErr_SetString(PyExc_ValueError, "cannot create instances of this type"); + PyErr_SetString(PyExc_ValueError, + "cannot create instances of this type"); return NULL; } -#define member(name, type) {(char *)#name, type, offsetof(struct wrap_graph_node, name), READONLY, \ - (char *)#name " (" #type ")"} +#define member(name, type) \ + { \ + (char *)#name, type, offsetof(struct wrap_graph_node, name), \ + READONLY, (char *)#name " (" #type ")" \ + } static PyMemberDef members_graph_node[] = { - member(allowrepeat, T_BOOL), - member(type, T_STRING), - member(deprecated, T_BOOL), - member(hidden, T_BOOL), - member(text, T_STRING), - member(desc, T_STRING), - member(min, T_LONGLONG), - member(max, T_LONGLONG), - member(varname, T_STRING), - {}, + member(allowrepeat, T_BOOL), member(type, T_STRING), + member(deprecated, T_BOOL), member(hidden, T_BOOL), + member(text, T_STRING), member(desc, T_STRING), + member(min, T_LONGLONG), member(max, T_LONGLONG), + member(varname, T_STRING), {}, }; #undef member @@ -106,7 +106,7 @@ static PyObject *graph_node_next(PyObject *self, PyObject *args) PyObject *pylist; if (wrap->node->data - && ((struct cmd_token *)wrap->node->data)->type == END_TKN) + && ((struct cmd_token *)wrap->node->data)->type == END_TKN) return PyList_New(0); pylist = PyList_New(vector_active(wrap->node->to)); for (size_t i = 0; i < vector_active(wrap->node->to); i++) { @@ -124,7 +124,7 @@ static PyObject *graph_node_join(PyObject *self, PyObject *args) struct wrap_graph_node *wrap = (struct wrap_graph_node *)self; if (!wrap->node->data - || ((struct cmd_token *)wrap->node->data)->type == END_TKN) + || ((struct cmd_token *)wrap->node->data)->type == END_TKN) Py_RETURN_NONE; struct cmd_token *tok = wrap->node->data; @@ -137,8 +137,7 @@ static PyObject *graph_node_join(PyObject *self, PyObject *args) static PyMethodDef methods_graph_node[] = { {"next", graph_node_next, METH_NOARGS, "outbound graph edge list"}, {"join", graph_node_join, METH_NOARGS, "outbound join node"}, - {} -}; + {}}; static void graph_node_wrap_free(void *arg) { @@ -148,18 +147,18 @@ static void graph_node_wrap_free(void *arg) } static PyTypeObject typeobj_graph_node = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "_clippy.GraphNode", - .tp_basicsize = sizeof(struct wrap_graph_node), - .tp_flags = Py_TPFLAGS_DEFAULT, - .tp_doc = "struct graph_node *", - .tp_new = refuse_new, - .tp_free = graph_node_wrap_free, - .tp_members = members_graph_node, - .tp_methods = methods_graph_node, + PyVarObject_HEAD_INIT(NULL, 0).tp_name = "_clippy.GraphNode", + .tp_basicsize = sizeof(struct wrap_graph_node), + .tp_flags = Py_TPFLAGS_DEFAULT, + .tp_doc = "struct graph_node *", + .tp_new = refuse_new, + .tp_free = graph_node_wrap_free, + .tp_members = members_graph_node, + .tp_methods = methods_graph_node, }; -static PyObject *graph_to_pyobj(struct wrap_graph *wgraph, struct graph_node *gn) +static PyObject *graph_to_pyobj(struct wrap_graph *wgraph, + struct graph_node *gn) { struct wrap_graph_node *wrap; size_t i; @@ -177,7 +176,8 @@ static PyObject *graph_to_pyobj(struct wrap_graph *wgraph, struct graph_node *gn return obj; } - wrap = (struct wrap_graph_node *)typeobj_graph_node.tp_alloc(&typeobj_graph_node, 0); + wrap = (struct wrap_graph_node *)typeobj_graph_node.tp_alloc( + &typeobj_graph_node, 0); if (!wrap) return NULL; wgraph->nodewrappers[i] = wrap; @@ -192,21 +192,18 @@ static PyObject *graph_to_pyobj(struct wrap_graph *wgraph, struct graph_node *gn struct cmd_token *tok = gn->data; switch (tok->type) { #define item(x) case x: wrap->type = #x; break; - item(WORD_TKN) // words - item(VARIABLE_TKN) // almost anything - item(RANGE_TKN) // integer range - item(IPV4_TKN) // IPV4 addresses - item(IPV4_PREFIX_TKN) // IPV4 network prefixes - item(IPV6_TKN) // IPV6 prefixes - item(IPV6_PREFIX_TKN) // IPV6 network prefixes - - /* plumbing types */ - item(FORK_TKN) - item(JOIN_TKN) - item(START_TKN) - item(END_TKN) - default: - wrap->type = "???"; + item(WORD_TKN) // words + item(VARIABLE_TKN) // almost anything + item(RANGE_TKN) // integer range + item(IPV4_TKN) // IPV4 addresses + item(IPV4_PREFIX_TKN) // IPV4 network prefixes + item(IPV6_TKN) // IPV6 prefixes + item(IPV6_PREFIX_TKN) // IPV6 network prefixes + + /* plumbing types */ + item(FORK_TKN) item(JOIN_TKN) item(START_TKN) + item(END_TKN) default + : wrap->type = "???"; } wrap->deprecated = (tok->attr == CMD_ATTR_DEPRECATED); @@ -222,8 +219,11 @@ static PyObject *graph_to_pyobj(struct wrap_graph *wgraph, struct graph_node *gn return (PyObject *)wrap; } -#define member(name, type) {(char *)#name, type, offsetof(struct wrap_graph, name), READONLY, \ - (char *)#name " (" #type ")"} +#define member(name, type) \ + { \ + (char *)#name, type, offsetof(struct wrap_graph, name), \ + READONLY, (char *)#name " (" #type ")" \ + } static PyMemberDef members_graph[] = { member(definition, T_STRING), {}, @@ -240,10 +240,10 @@ static PyObject *graph_first(PyObject *self, PyObject *args) static PyMethodDef methods_graph[] = { {"first", graph_first, METH_NOARGS, "first graph node"}, - {} -}; + {}}; -static PyObject *graph_parse(PyTypeObject *type, PyObject *args, PyObject *kwds); +static PyObject *graph_parse(PyTypeObject *type, PyObject *args, + PyObject *kwds); static void graph_wrap_free(void *arg) { @@ -253,15 +253,14 @@ static void graph_wrap_free(void *arg) } static PyTypeObject typeobj_graph = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "_clippy.Graph", - .tp_basicsize = sizeof(struct wrap_graph), - .tp_flags = Py_TPFLAGS_DEFAULT, - .tp_doc = "struct graph *", - .tp_new = graph_parse, - .tp_free = graph_wrap_free, - .tp_members = members_graph, - .tp_methods = methods_graph, + PyVarObject_HEAD_INIT(NULL, 0).tp_name = "_clippy.Graph", + .tp_basicsize = sizeof(struct wrap_graph), + .tp_flags = Py_TPFLAGS_DEFAULT, + .tp_doc = "struct graph *", + .tp_new = graph_parse, + .tp_free = graph_wrap_free, + .tp_members = members_graph, + .tp_methods = methods_graph, }; /* top call / entrypoint for python code */ @@ -269,34 +268,34 @@ static PyObject *graph_parse(PyTypeObject *type, PyObject *args, PyObject *kwds) { const char *def, *doc = NULL; struct wrap_graph *gwrap; - static const char *kwnames[] = { "cmddef", "doc", NULL }; + static const char *kwnames[] = {"cmddef", "doc", NULL}; gwrap = (struct wrap_graph *)typeobj_graph.tp_alloc(&typeobj_graph, 0); if (!gwrap) return NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|s", (char **)kwnames, &def, &doc)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|s", (char **)kwnames, + &def, &doc)) return NULL; - struct graph *graph = graph_new (); - struct cmd_token *token = cmd_token_new (START_TKN, 0, NULL, NULL); - graph_new_node (graph, token, (void (*)(void *)) &cmd_token_del); + struct graph *graph = graph_new(); + struct cmd_token *token = cmd_token_new(START_TKN, 0, NULL, NULL); + graph_new_node(graph, token, (void (*)(void *)) & cmd_token_del); - struct cmd_element cmd = { .string = def, .doc = doc }; - cmd_graph_parse (graph, &cmd); - cmd_graph_names (graph); + struct cmd_element cmd = {.string = def, .doc = doc}; + cmd_graph_parse(graph, &cmd); + cmd_graph_names(graph); gwrap->graph = graph; gwrap->definition = strdup(def); gwrap->nodewrappers = calloc(vector_active(graph->nodes), - sizeof (gwrap->nodewrappers[0])); + sizeof(gwrap->nodewrappers[0])); return (PyObject *)gwrap; } static PyMethodDef clippy_methods[] = { {"parse", clippy_parse, METH_VARARGS, "Parse a C file"}, - {NULL, NULL, 0, NULL} -}; + {NULL, NULL, 0, NULL}}; #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef pymoddef_clippy = { @@ -310,14 +309,17 @@ static struct PyModuleDef pymoddef_clippy = { #define initret(val) return val; #else #define modcreate() Py_InitModule("_clippy", clippy_methods) -#define initret(val) do { \ - if (!val) Py_FatalError("initialization failure"); \ - return; } while (0) +#define initret(val) \ + do { \ + if (!val) \ + Py_FatalError("initialization failure"); \ + return; \ + } while (0) #endif PyMODINIT_FUNC command_py_init(void) { - PyObject* pymod; + PyObject *pymod; if (PyType_Ready(&typeobj_graph_node) < 0) initret(NULL); |