diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2020-04-24 14:09:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-24 14:09:16 +0200 |
commit | 967ebd2431d7033d53bf1e6ba7a74e77b2571293 (patch) | |
tree | 704bd154dd4090b8ecd826e7e3791b45df9abf43 /tools | |
parent | Merge pull request #6282 from opensourcerouting/fix-isisd-sh-run (diff) | |
parent | *: change the signature of the northbound callbacks to be more flexible (diff) | |
download | frr-967ebd2431d7033d53bf1e6ba7a74e77b2571293.tar.xz frr-967ebd2431d7033d53bf1e6ba7a74e77b2571293.zip |
Merge pull request #6279 from opensourcerouting/nb-cb-args
*: change the signature of the northbound callbacks to be more flexible
Diffstat (limited to 'tools')
-rw-r--r-- | tools/coccinelle/nb-cbs.cocci | 298 | ||||
-rw-r--r-- | tools/gen_northbound_callbacks.c | 28 |
2 files changed, 308 insertions, 18 deletions
diff --git a/tools/coccinelle/nb-cbs.cocci b/tools/coccinelle/nb-cbs.cocci new file mode 100644 index 000000000..6e4d32ead --- /dev/null +++ b/tools/coccinelle/nb-cbs.cocci @@ -0,0 +1,298 @@ +@@ +identifier func =~ ".*_create$"; +identifier event, dnode, resource; +@@ + +int +- func(enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource) ++ func(struct nb_cb_create_args *args) + { +<... +( +- event ++ args->event +| +- dnode ++ args->dnode +| +- resource ++ args->resource +) +...> + } + +@@ +identifier func =~ ".*_modify$"; +identifier event, dnode, resource; +@@ + +int +- func(enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource) ++ func(struct nb_cb_modify_args *args) + { +<... +( +- event ++ args->event +| +- dnode ++ args->dnode +| +- resource ++ args->resource +) +...> + } + +@@ +identifier func =~ ".*_destroy$"; +identifier event, dnode; +@@ + +int +- func(enum nb_event event, const struct lyd_node *dnode) ++ func(struct nb_cb_destroy_args *args) + { +<... +( +- dnode ++ args->dnode +| +- event ++ args->event +) +...> + } + +@@ +identifier func =~ ".*_pre_validate$"; +identifier dnode; +@@ + +int +- func(const struct lyd_node dnode) ++ func(struct nb_cb_pre_validate_args *args) + { +<... +- dnode ++ args->dnode +...> + } + +@@ +identifier func =~ ".*_apply_finish$"; +identifier dnode; +@@ + +void +- func(const struct lyd_node *dnode) ++ func(struct nb_cb_apply_finish_args *args) + { +<... +- dnode ++ args->dnode +...> + } + +@@ +identifier func =~ ".*_get_elem$"; +identifier xpath, list_entry; +@@ + +struct yang_data * +- func(const char *xpath, const void *list_entry) ++ func(struct nb_cb_get_elem_args *args) + { +<... +( +- xpath ++ args->xpath +| +- list_entry ++ args->list_entry +) +...> + } + +@@ +identifier func =~ ".*_get_next$"; +identifier parent_list_entry, list_entry; +@@ + +const void * +- func(const void *parent_list_entry, const void *list_entry) ++ func(struct nb_cb_get_next_args *args) + { +<... +( +- parent_list_entry ++ args->parent_list_entry +| +- list_entry ++ args->list_entry +) +...> + } + +@@ +identifier func =~ ".*_get_keys$"; +identifier list_entry, keys; +@@ + +int +- func(const void *list_entry, struct yang_list_keys *keys) ++ func(struct nb_cb_get_keys_args *args) + { +<... +( +- list_entry ++ args->list_entry +| +- keys ++ args->keys +) +...> + } + +@@ +identifier func =~ ".*_lookup_entry$"; +identifier parent_list_entry, keys; +@@ + +const void * +- func(const void *parent_list_entry, const struct yang_list_keys *keys) ++ func(struct nb_cb_lookup_entry_args *args) + { +<... +( +- parent_list_entry ++ args->parent_list_entry +| +- keys ++ args->keys +) +...> + } + +@@ +identifier func =~ ".*_rpc$"; +identifier xpath, input, output; +@@ + +int +- func(const char *xpath, const struct list *input, struct list *output) ++ func(struct nb_cb_rpc_args *args) + { +<... +( +- xpath ++ args->xpath +| +- input ++ args->input +| +- output ++ args->output +) +...> + } + +@@ +identifier func =~ ".*_create$"; +identifier event, dnode, resource; +@@ + +int +- func(enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource) ++ func(struct nb_cb_create_args *args) +; + +@@ +identifier func =~ ".*_modify$"; +identifier event, dnode, resource; +@@ + +int +- func(enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource) ++ func(struct nb_cb_modify_args *args) +; + +@@ +identifier func =~ ".*_destroy$"; +identifier event, dnode; +@@ + +int +- func(enum nb_event event, const struct lyd_node *dnode) ++ func(struct nb_cb_destroy_args *args) +; + +@@ +identifier func =~ ".*_pre_validate$"; +identifier dnode; +@@ + +int +- func(const struct lyd_node dnode) ++ func(struct nb_cb_pre_validate_args *args) +; + +@@ +identifier func =~ ".*_apply_finish$"; +identifier dnode; +@@ + +void +- func(const struct lyd_node *dnode) ++ func(struct nb_cb_apply_finish_args *args) +; + +@@ +identifier func =~ ".*_get_elem$"; +identifier xpath, list_entry; +@@ + +struct yang_data * +- func(const char *xpath, const void *list_entry) ++ func(struct nb_cb_get_elem_args *args) +; + +@@ +identifier func =~ ".*_get_next$"; +identifier parent_list_entry, list_entry; +@@ + +const void * +- func(const void *parent_list_entry, const void *list_entry) ++ func(struct nb_cb_get_next_args *args) +; + +@@ +identifier func =~ ".*_get_keys$"; +identifier list_entry, keys; +@@ + +int +- func(const void *list_entry, struct yang_list_keys *keys) ++ func(struct nb_cb_get_keys_args *args) +; + +@@ +identifier func =~ ".*_lookup_entry$"; +identifier parent_list_entry, keys; +@@ + +const void * +- func(const void *parent_list_entry, const struct yang_list_keys *keys) ++ func(struct nb_cb_lookup_entry_args *args) +; + +@@ +identifier func =~ ".*_rpc$"; +identifier xpath, input, output; +@@ + +int +- func(const char *xpath, const struct list *input, struct list *output) ++ func(struct nb_cb_rpc_args *args) +; diff --git a/tools/gen_northbound_callbacks.c b/tools/gen_northbound_callbacks.c index 711898685..8dccbac3a 100644 --- a/tools/gen_northbound_callbacks.c +++ b/tools/gen_northbound_callbacks.c @@ -46,70 +46,62 @@ static struct nb_callback_info { .operation = NB_OP_CREATE, .return_type = "int ", .return_value = "NB_OK", - .arguments = - "enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource", + .arguments = "struct nb_cb_create_args *args", }, { .operation = NB_OP_MODIFY, .return_type = "int ", .return_value = "NB_OK", - .arguments = - "enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource", + .arguments = "struct nb_cb_modify_args *args", }, { .operation = NB_OP_DESTROY, .return_type = "int ", .return_value = "NB_OK", - .arguments = - "enum nb_event event, const struct lyd_node *dnode", + .arguments = "struct nb_cb_destroy_args *args", }, { .operation = NB_OP_MOVE, .return_type = "int ", .return_value = "NB_OK", - .arguments = - "enum nb_event event, const struct lyd_node *dnode", + .arguments = "struct nb_cb_move_args *args", }, { .operation = NB_OP_APPLY_FINISH, .optional = true, .return_type = "void ", .return_value = "", - .arguments = "const struct lyd_node *dnode", + .arguments = "struct nb_cb_apply_finish_args *args", }, { .operation = NB_OP_GET_ELEM, .return_type = "struct yang_data *", .return_value = "NULL", - .arguments = "const char *xpath, const void *list_entry", + .arguments = "struct nb_cb_get_elem_args *args", }, { .operation = NB_OP_GET_NEXT, .return_type = "const void *", .return_value = "NULL", - .arguments = - "const void *parent_list_entry, const void *list_entry", + .arguments = "struct nb_cb_get_next_args *args", }, { .operation = NB_OP_GET_KEYS, .return_type = "int ", .return_value = "NB_OK", - .arguments = - "const void *list_entry, struct yang_list_keys *keys", + .arguments = "struct nb_cb_get_keys_args *args", }, { .operation = NB_OP_LOOKUP_ENTRY, .return_type = "const void *", .return_value = "NULL", - .arguments = - "const void *parent_list_entry, const struct yang_list_keys *keys", + .arguments = "struct nb_cb_lookup_entry_args *args", }, { .operation = NB_OP_RPC, .return_type = "int ", .return_value = "NB_OK", - .arguments = - "const char *xpath, const struct list *input, struct list *output", + .arguments = "struct nb_cb_rpc_args *args", }, { /* sentinel */ |