schema CHANGE unify actions, inouts and notification with lys*_node
diff --git a/src/printer_yang.c b/src/printer_yang.c
index 7dc0109..2cd9604 100644
--- a/src/printer_yang.c
+++ b/src/printer_yang.c
@@ -991,14 +991,18 @@
static void yprp_node(struct ypr_ctx *ctx, const struct lysp_node *node);
static void yprc_node(struct ypr_ctx *ctx, const struct lysc_node *node);
-static void yprp_action(struct ypr_ctx *ctx, const struct lysp_action *action);
+static void yprp_action(struct ypr_ctx *ctx, const struct lysp_node_action *action);
+static void yprp_notification(struct ypr_ctx *ctx, const struct lysp_node_notif *notif);
static void
-yprp_grouping(struct ypr_ctx *ctx, const struct lysp_grp *grp)
+yprp_grouping(struct ypr_ctx *ctx, const struct lysp_node_grp *grp)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
struct lysp_node *data;
+ struct lysp_node_action *action;
+ struct lysp_node_notif *notif;
+ struct lysp_node_grp *subgrp;
ly_print_(ctx->out, "\n%*sgrouping %s", INDENT, grp->name);
LEVEL++;
@@ -1013,9 +1017,9 @@
yprp_typedef(ctx, &grp->typedefs[u]);
}
- LY_ARRAY_FOR(grp->groupings, u) {
+ LY_LIST_FOR(grp->groupings, subgrp) {
ypr_open(ctx->out, &flag);
- yprp_grouping(ctx, &grp->groupings[u]);
+ yprp_grouping(ctx, subgrp);
}
LY_LIST_FOR(grp->data, data) {
@@ -1023,8 +1027,14 @@
yprp_node(ctx, data);
}
- LY_ARRAY_FOR(grp->actions, u) {
- yprp_action(ctx, &grp->actions[u]);
+ LY_LIST_FOR(grp->actions, action) {
+ ypr_open(ctx->out, &flag);
+ yprp_action(ctx, action);
+ }
+
+ LY_LIST_FOR(grp->notifs, notif) {
+ ypr_open(ctx->out, &flag);
+ yprp_notification(ctx, notif);
}
LEVEL--;
@@ -1032,10 +1042,11 @@
}
static void
-yprp_inout(struct ypr_ctx *ctx, const struct lysp_action_inout *inout, ly_bool *flag)
+yprp_inout(struct ypr_ctx *ctx, const struct lysp_node_action_inout *inout, ly_bool *flag)
{
LY_ARRAY_COUNT_TYPE u;
struct lysp_node *data;
+ struct lysp_node_grp *grp;
if (!inout->data) {
/* no children */
@@ -1053,8 +1064,8 @@
LY_ARRAY_FOR(inout->typedefs, u) {
yprp_typedef(ctx, &inout->typedefs[u]);
}
- LY_ARRAY_FOR(inout->groupings, u) {
- yprp_grouping(ctx, &inout->groupings[u]);
+ LY_LIST_FOR(inout->groupings, grp) {
+ yprp_grouping(ctx, grp);
}
LY_LIST_FOR(inout->data, data) {
@@ -1066,7 +1077,7 @@
}
static void
-yprc_inout(struct ypr_ctx *ctx, const struct lysc_action *action, const struct lysc_action_inout *inout, ly_bool *flag)
+yprc_inout(struct ypr_ctx *ctx, const struct lysc_node_action *action, const struct lysc_node_action_inout *inout, ly_bool *flag)
{
LY_ARRAY_COUNT_TYPE u;
struct lysc_node *data;
@@ -1080,7 +1091,7 @@
ly_print_(ctx->out, "\n%*s%s {\n", INDENT, (&action->input == inout) ? "input" : "output");
LEVEL++;
- yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, (&action->input == inout) ? action->input_exts : action->output_exts, NULL, 0);
+ yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, (&action->input == inout) ? action->input.exts : action->output.exts, NULL, 0);
LY_ARRAY_FOR(inout->musts, u) {
yprc_must(ctx, &inout->musts[u], NULL);
}
@@ -1096,11 +1107,12 @@
}
static void
-yprp_notification(struct ypr_ctx *ctx, const struct lysp_notif *notif)
+yprp_notification(struct ypr_ctx *ctx, const struct lysp_node_notif *notif)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
struct lysp_node *data;
+ struct lysp_node_grp *grp;
ly_print_(ctx->out, "%*snotification %s", INDENT, notif->name);
@@ -1120,9 +1132,9 @@
yprp_typedef(ctx, ¬if->typedefs[u]);
}
- LY_ARRAY_FOR(notif->groupings, u) {
+ LY_LIST_FOR(notif->groupings, grp) {
ypr_open(ctx->out, &flag);
- yprp_grouping(ctx, ¬if->groupings[u]);
+ yprp_grouping(ctx, grp);
}
LY_LIST_FOR(notif->data, data) {
@@ -1135,7 +1147,7 @@
}
static void
-yprc_notification(struct ypr_ctx *ctx, const struct lysc_notif *notif)
+yprc_notification(struct ypr_ctx *ctx, const struct lysc_node_notif *notif)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
@@ -1165,10 +1177,11 @@
}
static void
-yprp_action(struct ypr_ctx *ctx, const struct lysp_action *action)
+yprp_action(struct ypr_ctx *ctx, const struct lysp_node_action *action)
{
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
+ struct lysp_node_grp *grp;
ly_print_(ctx->out, "%*s%s %s", INDENT, action->parent ? "action" : "rpc", action->name);
@@ -1184,9 +1197,9 @@
yprp_typedef(ctx, &action->typedefs[u]);
}
- LY_ARRAY_FOR(action->groupings, u) {
+ LY_LIST_FOR(action->groupings, grp) {
ypr_open(ctx->out, &flag);
- yprp_grouping(ctx, &action->groupings[u]);
+ yprp_grouping(ctx, grp);
}
yprp_inout(ctx, &action->input, &flag);
@@ -1197,7 +1210,7 @@
}
static void
-yprc_action(struct ypr_ctx *ctx, const struct lysc_action *action)
+yprc_action(struct ypr_ctx *ctx, const struct lysc_node_action *action)
{
ly_bool flag = 0;
@@ -1271,6 +1284,9 @@
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
struct lysp_node *child;
+ struct lysp_node_action *action;
+ struct lysp_node_notif *notif;
+ struct lysp_node_grp *grp;
struct lysp_node_container *cont = (struct lysp_node_container *)node;
yprp_node_common1(ctx, node, &flag);
@@ -1290,9 +1306,9 @@
yprp_typedef(ctx, &cont->typedefs[u]);
}
- LY_ARRAY_FOR(cont->groupings, u) {
+ LY_LIST_FOR(cont->groupings, grp) {
ypr_open(ctx->out, &flag);
- yprp_grouping(ctx, &cont->groupings[u]);
+ yprp_grouping(ctx, grp);
}
LY_LIST_FOR(cont->child, child) {
@@ -1300,14 +1316,14 @@
yprp_node(ctx, child);
}
- LY_ARRAY_FOR(cont->actions, u) {
+ LY_LIST_FOR(cont->actions, action) {
ypr_open(ctx->out, &flag);
- yprp_action(ctx, &cont->actions[u]);
+ yprp_action(ctx, action);
}
- LY_ARRAY_FOR(cont->notifs, u) {
+ LY_LIST_FOR(cont->notifs, notif) {
ypr_open(ctx->out, &flag);
- yprp_notification(ctx, &cont->notifs[u]);
+ yprp_notification(ctx, notif);
}
LEVEL--;
@@ -1320,6 +1336,8 @@
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
struct lysc_node *child;
+ struct lysc_node_action *action;
+ struct lysc_node_notif *notif;
struct lysc_node_container *cont = (struct lysc_node_container *)node;
yprc_node_common1(ctx, node, &flag);
@@ -1340,14 +1358,14 @@
yprc_node(ctx, child);
}
- LY_ARRAY_FOR(cont->actions, u) {
+ LY_LIST_FOR(cont->actions, action) {
ypr_open(ctx->out, &flag);
- yprc_action(ctx, &cont->actions[u]);
+ yprc_action(ctx, action);
}
- LY_ARRAY_FOR(cont->notifs, u) {
+ LY_LIST_FOR(cont->notifs, notif) {
ypr_open(ctx->out, &flag);
- yprc_notification(ctx, &cont->notifs[u]);
+ yprc_notification(ctx, notif);
}
}
@@ -1573,6 +1591,9 @@
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
struct lysp_node *child;
+ struct lysp_node_action *action;
+ struct lysp_node_notif *notif;
+ struct lysp_node_grp *grp;
struct lysp_node_list *list = (struct lysp_node_list *)node;
yprp_node_common1(ctx, node, &flag);
@@ -1617,9 +1638,9 @@
yprp_typedef(ctx, &list->typedefs[u]);
}
- LY_ARRAY_FOR(list->groupings, u) {
+ LY_LIST_FOR(list->groupings, grp) {
ypr_open(ctx->out, &flag);
- yprp_grouping(ctx, &list->groupings[u]);
+ yprp_grouping(ctx, grp);
}
LY_LIST_FOR(list->child, child) {
@@ -1627,14 +1648,14 @@
yprp_node(ctx, child);
}
- LY_ARRAY_FOR(list->actions, u) {
+ LY_LIST_FOR(list->actions, action) {
ypr_open(ctx->out, &flag);
- yprp_action(ctx, &list->actions[u]);
+ yprp_action(ctx, action);
}
- LY_ARRAY_FOR(list->notifs, u) {
+ LY_LIST_FOR(list->notifs, notif) {
ypr_open(ctx->out, &flag);
- yprp_notification(ctx, &list->notifs[u]);
+ yprp_notification(ctx, notif);
}
LEVEL--;
@@ -1645,7 +1666,6 @@
yprc_list(struct ypr_ctx *ctx, const struct lysc_node *node)
{
LY_ARRAY_COUNT_TYPE u, v;
- struct lysc_node *child;
struct lysc_node_list *list = (struct lysc_node_list *)node;
yprc_node_common1(ctx, node, NULL);
@@ -1684,16 +1704,20 @@
ypr_reference(ctx, node->ref, node->exts, NULL);
if (!(ctx->options & LYS_PRINT_NO_SUBSTMT)) {
+ struct lysc_node *child;
+ struct lysc_node_action *action;
+ struct lysc_node_notif *notif;
+
LY_LIST_FOR(list->child, child) {
yprc_node(ctx, child);
}
- LY_ARRAY_FOR(list->actions, u) {
- yprc_action(ctx, &list->actions[u]);
+ LY_LIST_FOR(list->actions, action) {
+ yprc_action(ctx, action);
}
- LY_ARRAY_FOR(list->notifs, u) {
- yprc_notification(ctx, &list->notifs[u]);
+ LY_LIST_FOR(list->notifs, notif) {
+ yprc_notification(ctx, notif);
}
}
@@ -1752,10 +1776,11 @@
}
static void
-yprp_augment(struct ypr_ctx *ctx, const struct lysp_augment *aug)
+yprp_augment(struct ypr_ctx *ctx, const struct lysp_node_augment *aug)
{
- LY_ARRAY_COUNT_TYPE u;
struct lysp_node *child;
+ struct lysp_node_action *action;
+ struct lysp_node_notif *notif;
ly_print_(ctx->out, "%*saugment \"%s\" {\n", INDENT, aug->nodeid);
LEVEL++;
@@ -1771,12 +1796,12 @@
yprp_node(ctx, child);
}
- LY_ARRAY_FOR(aug->actions, u) {
- yprp_action(ctx, &aug->actions[u]);
+ LY_LIST_FOR(aug->actions, action) {
+ yprp_action(ctx, action);
}
- LY_ARRAY_FOR(aug->notifs, u) {
- yprp_notification(ctx, &aug->notifs[u]);
+ LY_LIST_FOR(aug->notifs, notif) {
+ yprp_notification(ctx, notif);
}
LEVEL--;
@@ -1789,6 +1814,7 @@
LY_ARRAY_COUNT_TYPE u;
ly_bool flag = 0;
struct lysp_node_uses *uses = (struct lysp_node_uses *)node;
+ struct lysp_node_augment *aug;
yprp_node_common1(ctx, node, &flag);
yprp_node_common2(ctx, node, &flag);
@@ -1798,9 +1824,9 @@
yprp_refine(ctx, &uses->refines[u]);
}
- LY_ARRAY_FOR(uses->augments, u) {
+ LY_LIST_FOR(uses->augments, aug) {
ypr_open(ctx->out, &flag);
- yprp_augment(ctx, &uses->augments[u]);
+ yprp_augment(ctx, aug);
}
LEVEL--;
@@ -2063,6 +2089,10 @@
{
LY_ARRAY_COUNT_TYPE u;
struct lysp_node *data;
+ struct lysp_node_action *action;
+ struct lysp_node_notif *notif;
+ struct lysp_node_grp *grp;
+ struct lysp_node_augment *aug;
LY_ARRAY_FOR(modp->extensions, u) {
ly_print_(ctx->out, "\n");
@@ -2085,24 +2115,24 @@
yprp_typedef(ctx, &modp->typedefs[u]);
}
- LY_ARRAY_FOR(modp->groupings, u) {
- yprp_grouping(ctx, &modp->groupings[u]);
+ LY_LIST_FOR(modp->groupings, grp) {
+ yprp_grouping(ctx, grp);
}
LY_LIST_FOR(modp->data, data) {
yprp_node(ctx, data);
}
- LY_ARRAY_FOR(modp->augments, u) {
- yprp_augment(ctx, &modp->augments[u]);
+ LY_LIST_FOR(modp->augments, aug) {
+ yprp_augment(ctx, aug);
}
- LY_ARRAY_FOR(modp->rpcs, u) {
- yprp_action(ctx, &modp->rpcs[u]);
+ LY_LIST_FOR(modp->rpcs, action) {
+ yprp_action(ctx, action);
}
- LY_ARRAY_FOR(modp->notifs, u) {
- yprp_notification(ctx, &modp->notifs[u]);
+ LY_LIST_FOR(modp->notifs, notif) {
+ yprp_notification(ctx, notif);
}
LY_ARRAY_FOR(modp->deviations, u) {
@@ -2227,7 +2257,6 @@
yang_print_compiled(struct ly_out *out, const struct lys_module *module, uint32_t options)
{
LY_ARRAY_COUNT_TYPE u;
- struct lysc_node *data;
struct lysc_module *modc = module->compiled;
struct ypr_ctx ctx_ = {.out = out, .level = 0, .module = module, .options = options}, *ctx = &ctx_;
@@ -2265,16 +2294,20 @@
}
if (!(ctx->options & LYS_PRINT_NO_SUBSTMT)) {
+ struct lysc_node *data;
+ struct lysc_node_action *rpc;
+ struct lysc_node_notif *notif;
+
LY_LIST_FOR(modc->data, data) {
yprc_node(ctx, data);
}
- LY_ARRAY_FOR(modc->rpcs, u) {
- yprc_action(ctx, &modc->rpcs[u]);
+ LY_LIST_FOR(modc->rpcs, rpc) {
+ yprc_action(ctx, rpc);
}
- LY_ARRAY_FOR(modc->notifs, u) {
- yprc_notification(ctx, &modc->notifs[u]);
+ LY_LIST_FOR(modc->notifs, notif) {
+ yprc_notification(ctx, notif);
}
}