plugin types REFACTOR remove STORE and CANONIZE flags
The behavior was changed as if both of these
flags are always set. Also, types now always
include their canonical/JSON string value.
Finally, default value resolution was also
refactored to avoid some code duplication.
This change was most evident in deviations,
which were then significantly refactored.
diff --git a/src/printer_yang.c b/src/printer_yang.c
index 20b01b5..fb806de 100755
--- a/src/printer_yang.c
+++ b/src/printer_yang.c
@@ -928,12 +928,12 @@
}
static void
-yprc_dflt_value(struct ypr_ctx *ctx, const struct lyd_value *value, const struct lys_module *value_mod, struct lysc_ext_instance *exts)
+yprc_dflt_value(struct ypr_ctx *ctx, const struct lyd_value *value, struct lysc_ext_instance *exts)
{
int dynamic;
const char *str;
- str = value->realtype->plugin->print(value, LY_PREF_SCHEMA, (void *)value_mod, &dynamic);
+ str = value->realtype->plugin->print(value, LY_PREF_JSON, NULL, &dynamic);
ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, str, exts);
if (dynamic) {
free((void*)str);
@@ -950,10 +950,6 @@
LEVEL++;
yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, type->exts, &flag, 0);
- if (type->dflt) {
- ypr_open(ctx->out, &flag);
- yprc_dflt_value(ctx, type->dflt, type->dflt_mod, type->exts);
- }
switch (type->basetype) {
case LY_TYPE_BINARY: {
@@ -1577,7 +1573,7 @@
}
if (leaf->dflt) {
- yprc_dflt_value(ctx, leaf->dflt, leaf->dflt_mod, leaf->exts);
+ yprc_dflt_value(ctx, leaf->dflt, leaf->exts);
}
yprc_node_common2(ctx, node, NULL);
@@ -1642,7 +1638,7 @@
yprc_must(ctx, &llist->musts[u], NULL);
}
LY_ARRAY_FOR(llist->dflts, u) {
- yprc_dflt_value(ctx, llist->dflts[u], llist->dflts_mods[u], llist->exts);
+ yprc_dflt_value(ctx, llist->dflts[u], llist->exts);
}
ypr_config(ctx, node->flags, node->exts, NULL);