libyang CHANGE unify the statement enumerations
Instead of keeping a separate enumeration for YANG extension pattern
statements, just use the standard ly_stmt enumeration.
diff --git a/src/parser_stmt.c b/src/parser_stmt.c
index 0536f70..3f6cf96 100644
--- a/src/parser_stmt.c
+++ b/src/parser_stmt.c
@@ -79,14 +79,14 @@
*
* @param[in] ctx parser context.
* @param[in] stmt Source statement data from the parsed extension instance.
- * @param[in] insubstmt Type of the keyword this extension instance is a substatement of.
+ * @param[in] insubstmt The statement this extension instance is a substatement of.
* @param[in] insubstmt_index Index of the keyword instance this extension instance is a substatement of.
* @param[in,out] exts Extension instances to add to.
*
* @return LY_ERR values.
*/
static LY_ERR
-lysp_stmt_ext(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, LYEXT_SUBSTMT insubstmt,
+lysp_stmt_ext(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, enum ly_stmt insubstmt,
LY_ARRAY_COUNT_TYPE insubstmt_index, struct lysp_ext_instance **exts)
{
struct lysp_ext_instance *e;
@@ -254,7 +254,7 @@
for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {
switch (child->kw) {
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_STATUS, 0, exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_STATUS, 0, exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "status");
@@ -301,7 +301,7 @@
LY_CHECK_RET(lysp_stmt_text_field(ctx, child, 0, &when->ref, Y_STR_ARG, &when->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &when->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &when->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "when");
@@ -345,7 +345,7 @@
for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {
switch (child->kw) {
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_CONFIG, 0, exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_CONFIG, 0, exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "config");
@@ -390,7 +390,7 @@
for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {
switch (child->kw) {
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_MANDATORY, 0, exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_MANDATORY, 0, exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "mandatory");
@@ -432,7 +432,7 @@
LY_CHECK_RET(lysp_stmt_text_field(ctx, child, 0, &restr->emsg, Y_STR_ARG, &restr->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &restr->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &restr->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), ly_stmt2str(stmt->kw));
@@ -512,7 +512,7 @@
LY_CHECK_RET(lysp_stmt_when(ctx, child, &any->when));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &any->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &any->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw),
@@ -591,7 +591,7 @@
for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {
switch (child->kw) {
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, stmt->kw == LY_STMT_VALUE ? LYEXT_SUBSTMT_VALUE : LYEXT_SUBSTMT_POSITION, 0, exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, stmt->kw == LY_STMT_VALUE ? LY_STMT_VALUE : LY_STMT_POSITION, 0, exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), ly_stmt2str(stmt->kw));
@@ -655,7 +655,7 @@
LY_CHECK_RET(lysp_stmt_type_enum_value_pos(ctx, child, &enm->value, &enm->flags, &enm->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &enm->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &enm->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), ly_stmt2str(stmt->kw));
@@ -710,7 +710,7 @@
for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {
switch (child->kw) {
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_FRACTION_DIGITS, 0, exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_FRACTION_DIGITS, 0, exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "fraction-digits");
@@ -755,7 +755,7 @@
for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {
switch (child->kw) {
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_REQUIRE_INSTANCE, 0, exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_REQUIRE_INSTANCE, 0, exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "require-instance");
@@ -806,7 +806,7 @@
for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {
switch (child->kw) {
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_MODIFIER, 0, exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_MODIFIER, 0, exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "modifier");
@@ -864,7 +864,7 @@
LY_CHECK_RET(lysp_stmt_type_pattern_modifier(ctx, child, &restr->arg.str, &restr->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &restr->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &restr->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "pattern");
@@ -961,7 +961,7 @@
type->flags |= LYS_SET_TYPE;
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &type->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &type->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "type");
@@ -1034,7 +1034,7 @@
LY_CHECK_RET(lysp_stmt_when(ctx, child, &leaf->when));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &leaf->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &leaf->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "leaf");
@@ -1107,7 +1107,7 @@
for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {
switch (child->kw) {
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_MAX_ELEMENTS, 0, exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "max-elements");
@@ -1168,7 +1168,7 @@
for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {
switch (child->kw) {
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_MIN_ELEMENTS, 0, exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "min-elements");
@@ -1214,7 +1214,7 @@
for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {
switch (child->kw) {
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_ORDERED_BY, 0, exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_ORDERED_BY, 0, exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "ordered-by");
@@ -1294,7 +1294,7 @@
LY_CHECK_RET(lysp_stmt_when(ctx, child, &llist->when));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &llist->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &llist->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "llist");
@@ -1365,7 +1365,7 @@
LY_CHECK_RET(lysp_stmt_text_field(ctx, child, 0, &rf->presence, Y_STR_ARG, &rf->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &rf->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &rf->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "refine");
@@ -1420,7 +1420,7 @@
LY_CHECK_RET(lysp_stmt_text_field(ctx, child, 0, &tpdf->units, Y_STR_ARG, &tpdf->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &tpdf->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &tpdf->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "typedef");
@@ -1504,7 +1504,7 @@
LY_CHECK_RET(lysp_stmt_grouping(ctx, child, &inout_p->node, &inout_p->groupings));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &inout_p->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &inout_p->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), ly_stmt2str(stmt->kw));
@@ -1572,7 +1572,7 @@
LY_CHECK_RET(lysp_stmt_grouping(ctx, child, &act->node, &act->groupings));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &act->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &act->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), parent ? "action" : "rpc");
@@ -1669,7 +1669,7 @@
LY_CHECK_RET(lysp_stmt_grouping(ctx, child, ¬if->node, ¬if->groupings));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, ¬if->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, ¬if->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "notification");
@@ -1755,7 +1755,7 @@
LY_CHECK_RET(lysp_stmt_notif(ctx, child, &grp->node, &grp->notifs));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &grp->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &grp->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "grouping");
@@ -1844,7 +1844,7 @@
LY_CHECK_RET(lysp_stmt_notif(ctx, child, &aug->node, &aug->notifs));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &aug->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &aug->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "augment");
@@ -1905,7 +1905,7 @@
LY_CHECK_RET(lysp_stmt_augment(ctx, child, &uses->node, &uses->augments));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &uses->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &uses->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "uses");
@@ -1984,7 +1984,7 @@
LY_CHECK_RET(lysp_stmt_uses(ctx, child, &cas->node, &cas->child));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &cas->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &cas->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "case");
@@ -2072,7 +2072,7 @@
LY_CHECK_RET(lysp_stmt_list(ctx, child, &choice->node, &choice->child));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &choice->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &choice->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "choice");
@@ -2173,7 +2173,7 @@
LY_CHECK_RET(lysp_stmt_notif(ctx, child, &cont->node, &cont->notifs));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &cont->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &cont->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "container");
@@ -2288,7 +2288,7 @@
LY_CHECK_RET(lysp_stmt_notif(ctx, child, &list->node, &list->notifs));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &list->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &list->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "list");
@@ -2360,7 +2360,7 @@
ret = lysp_stmt_qnames(&pctx, stmt, (struct lysp_qname **)result, Y_STR_ARG, exts);
break;
case LY_STMT_EXTENSION_INSTANCE:
- ret = lysp_stmt_ext(&pctx, stmt, LYEXT_SUBSTMT_SELF, 0, exts);
+ ret = lysp_stmt_ext(&pctx, stmt, LY_STMT_NONE, 0, exts);
break;
case LY_STMT_FRACTION_DIGITS:
ret = lysp_stmt_type_fracdigits(&pctx, stmt, *(uint8_t **)result, exts);