schema compile BUGFIX if-feature in identity
Disabled identities by if-feature(s) are now also present in the lysc
tree. Checking whether the identity is not disabled by if-feature is
performed dynamically using ::lys_identity_iffeature_value(). Also the
compiled YANG printer now prints all identities, but disabled ones are
marked by comment.
diff --git a/src/schema_features.c b/src/schema_features.c
index e54fc7b..29e6478 100644
--- a/src/schema_features.c
+++ b/src/schema_features.c
@@ -97,6 +97,31 @@
return LY_ENOT;
}
+API LY_ERR
+lys_identity_iffeature_value(const struct lysc_ident *ident)
+{
+ LY_ARRAY_COUNT_TYPE u;
+ ly_bool enabled;
+ const struct lysp_ident *idents_p;
+
+ assert(ident);
+
+ idents_p = ident->module->parsed->identities;
+ LY_ARRAY_FOR(idents_p, u) {
+ if (idents_p[u].name == ident->name) {
+ break;
+ }
+ }
+ assert(u != LY_ARRAY_COUNT(idents_p));
+
+ LY_CHECK_RET(lys_eval_iffeatures(ident->module->ctx, idents_p[u].iffeatures, &enabled));
+ if (!enabled) {
+ return LY_ENOT;
+ }
+
+ return LY_SUCCESS;
+}
+
API struct lysp_feature *
lysp_feature_next(const struct lysp_feature *last, const struct lysp_module *pmod, uint32_t *idx)
{