data tree CHANGE move macros to functions to cleanup API
Remove lyd_node_children() since it is just an old duplication of
LYD_CHILD and LYD_CHILD_NO_KEYS macros. As a consequence, these macros
are converted to the functions together with LYD_PARENT (same names, but
lowercase) since they have similar functionality in the API.
diff --git a/src/diff.c b/src/diff.c
index 3e3dfbc..0c28bf4 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -98,7 +98,7 @@
diff_parent = match;
/* move down in the diff */
- siblings = LYD_CHILD_NO_KEYS(match);
+ siblings = lyd_child_no_keys(match);
}
/* duplicate the subtree (and connect to the diff if possible) */
@@ -591,7 +591,7 @@
/* check descendants, if any, recursively */
if (match_second) {
- LY_CHECK_GOTO(lyd_diff_siblings_r(LYD_CHILD_NO_KEYS(iter_first), LYD_CHILD_NO_KEYS(match_second), options,
+ LY_CHECK_GOTO(lyd_diff_siblings_r(lyd_child_no_keys(iter_first), lyd_child_no_keys(match_second), options,
0, diff), cleanup);
}
@@ -909,7 +909,7 @@
}
} else {
/* none operation on nodes without children is redundant and hence forbidden */
- if (!LYD_CHILD_NO_KEYS(diff_node)) {
+ if (!lyd_child_no_keys(diff_node)) {
LOGINT_RET(ctx);
}
}
@@ -971,7 +971,7 @@
}
/* apply diff recursively */
- LY_LIST_FOR(LYD_CHILD_NO_KEYS(diff_node), diff_child) {
+ LY_LIST_FOR(lyd_child_no_keys(diff_node), diff_child) {
LY_CHECK_RET(lyd_diff_apply_r(lyd_node_children_p(match), match, diff_child, diff_cb, cb_data));
}
@@ -1238,7 +1238,7 @@
diff_match->flags |= src_diff->flags & LYD_DEFAULT;
} else {
/* but the operation of its children should remain DELETE */
- LY_LIST_FOR(LYD_CHILD_NO_KEYS(diff_match), child) {
+ LY_LIST_FOR(lyd_child_no_keys(diff_match), child) {
LY_CHECK_RET(lyd_diff_change_op(child, LYD_DIFF_OP_DELETE));
}
}
@@ -1278,7 +1278,7 @@
diff_match->flags & LYD_DEFAULT ? "true" : "false", NULL));
} else {
/* keep operation for all descendants (for now) */
- LY_LIST_FOR(LYD_CHILD_NO_KEYS(diff_match), child) {
+ LY_LIST_FOR(lyd_child_no_keys(diff_match), child) {
LY_CHECK_RET(lyd_diff_change_op(child, cur_op));
}
}
@@ -1292,8 +1292,8 @@
LY_CHECK_RET(lyd_diff_change_op(diff_match, LYD_DIFF_OP_DELETE));
/* all descendants not in the diff will be deleted and redundant in the diff, so remove them */
- LY_LIST_FOR_SAFE(LYD_CHILD_NO_KEYS(diff_match), next, child) {
- if (lyd_find_sibling_first(LYD_CHILD(src_diff), child, NULL) == LY_ENOTFOUND) {
+ LY_LIST_FOR_SAFE(lyd_child_no_keys(diff_match), next, child) {
+ if (lyd_find_sibling_first(lyd_child(src_diff), child, NULL) == LY_ENOTFOUND) {
lyd_free_tree(child);
}
}
@@ -1323,7 +1323,7 @@
assert(diff);
- child = LYD_CHILD_NO_KEYS(diff);
+ child = lyd_child_no_keys(diff);
mod = ly_ctx_get_module_latest(LYD_CTX(diff), "yang");
assert(mod);
@@ -1397,7 +1397,7 @@
LY_CHECK_RET(lyd_diff_get_op(src_diff, &src_op));
/* find an equal node in the current diff */
- lyd_diff_find_node(diff_parent ? LYD_CHILD_NO_KEYS(diff_parent) : *diff, src_diff, &diff_node);
+ lyd_diff_find_node(diff_parent ? lyd_child_no_keys(diff_parent) : *diff, src_diff, &diff_node);
if (diff_node) {
/* get target (current) operation */
@@ -1434,7 +1434,7 @@
diff_parent = diff_node;
/* merge src_diff recursively */
- LY_LIST_FOR(LYD_CHILD_NO_KEYS(src_diff), child) {
+ LY_LIST_FOR(lyd_child_no_keys(src_diff), child) {
LY_CHECK_RET(lyd_diff_merge_r(child, diff_parent, diff_cb, cb_data, diff));
}
} else {