schema CHANGE add description and reference into compiled structures
diff --git a/src/tree_schema.h b/src/tree_schema.h
index e8c861b..04a65f4 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -957,6 +957,8 @@
*/
struct lysc_when {
struct lyxp_expr *cond; /**< XPath when condition */
+ const char *dsc; /**< description */
+ const char *ref; /**< reference */
struct lysc_node *context; /**< context node of the expression */
struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
};
@@ -966,6 +968,8 @@
*/
struct lysc_ident {
const char *name; /**< identity name (mandatory), including possible prefix */
+ const char *dsc; /**< description */
+ const char *ref; /**< reference */
struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
struct lysc_ident **derived; /**< list of (pointers to the) derived identities ([sized array](@ref sizedarrays)) */
struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
@@ -977,6 +981,8 @@
*/
struct lysc_feature {
const char *name; /**< feature name (mandatory) */
+ const char *dsc; /**< description */
+ const char *ref; /**< reference */
struct lysc_feature **depfeatures;/**< list of pointers to other features depending on this one ([sized array](@ref sizedarrays)) */
struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
@@ -1006,11 +1012,6 @@
struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
};
-struct lysc_default {
- struct lys_module *module; /**< module where the default was defined */
- const char *value; /**< default value (with possible prefixes from the module where defined) */
-};
-
struct lysc_range {
struct lysc_range_part {
union { /**< min boundary TODO decimal */
@@ -1022,6 +1023,8 @@
uint64_t max_u64; /**< for uint8, uint16, uint32 and uint64 */
};
} *parts; /**< compiled range expression ([sized array](@ref sizedarrays)) */
+ const char *dsc; /**< description */
+ const char *ref; /**< reference */
const char *emsg; /**< error-message */
const char *eapptag; /**< error-app-tag value */
struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
@@ -1030,6 +1033,8 @@
struct lysc_pattern {
pcre *expr; /**< compiled regular expression */
pcre_extra *expr_extra; /**< additional information to speed up matching */
+ const char *dsc; /**< description */
+ const char *ref; /**< reference */
const char *emsg; /**< error-message */
const char *eapptag; /**< error-app-tag value */
struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
@@ -1040,6 +1045,8 @@
struct lysc_must {
struct lys_module *module; /**< module where the must was defined */
struct lyxp_expr *cond; /**< XPath when condition */
+ const char *dsc; /**< description */
+ const char *ref; /**< reference */
const char *emsg; /**< error-message */
const char *eapptag; /**< error-app-tag value */
struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
@@ -1085,6 +1092,8 @@
uint32_t refcount; /**< reference counter for type sharing */
struct lysc_type_enum_item {
const char *name; /**< enumeration identifier */
+ const char *dsc; /**< description */
+ const char *ref; /**< reference */
struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
int32_t value; /**< integer value associated with the enumeration */
@@ -1126,6 +1135,8 @@
uint32_t refcount; /**< reference counter for type sharing */
struct lysc_type_bits_item {
const char *name; /**< bit identifier */
+ const char *dsc; /**< description */
+ const char *ref; /**< reference */
struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
uint32_t position; /**< non-negative integer value associated with the bit */
@@ -1372,6 +1383,10 @@
const char *ns; /**< namespace of the module (mandatory) */
const char *prefix; /**< module prefix (mandatory) */
const char *revision; /**< the revision of the module */
+ const char *org; /**< party/company responsible for the module */
+ const char *contact; /**< contact information for the module */
+ const char *dsc; /**< description of the module */
+ const char *ref; /**< cross-reference for the module */
struct lysc_import *imports; /**< list of imported modules ([sized array](@ref sizedarrays)) */
struct lysc_feature *features; /**< list of feature definitions ([sized array](@ref sizedarrays)) */
diff --git a/src/tree_schema_compile.c b/src/tree_schema_compile.c
index 24cd11a..a2e95fe 100644
--- a/src/tree_schema_compile.c
+++ b/src/tree_schema_compile.c
@@ -427,6 +427,8 @@
LY_ERR ret = LY_SUCCESS;
when->cond = lyxp_expr_parse(ctx->ctx, when_p->cond);
+ DUP_STRING(ctx->ctx, when_p->dsc, when->dsc);
+ DUP_STRING(ctx->ctx, when_p->ref, when->ref);
LY_CHECK_ERR_GOTO(!when->cond, ret = ly_errcode(ctx->ctx), done);
COMPILE_ARRAY_GOTO(ctx, when_p->exts, when->exts, options, u, lys_compile_ext, ret, done);
@@ -445,6 +447,8 @@
DUP_STRING(ctx->ctx, must_p->eapptag, must->eapptag);
DUP_STRING(ctx->ctx, must_p->emsg, must->emsg);
+ DUP_STRING(ctx->ctx, must_p->dsc, must->dsc);
+ DUP_STRING(ctx->ctx, must_p->ref, must->ref);
COMPILE_ARRAY_GOTO(ctx, must_p->exts, must->exts, options, u, lys_compile_ext, ret, done);
done:
@@ -499,6 +503,8 @@
COMPILE_CHECK_UNIQUENESS(ctx, idents, name, ident, "identity", ident_p->name);
DUP_STRING(ctx->ctx, ident_p->name, ident->name);
+ DUP_STRING(ctx->ctx, ident_p->ref, ident->dsc);
+ DUP_STRING(ctx->ctx, ident_p->ref, ident->dsc);
COMPILE_ARRAY_GOTO(ctx, ident_p->iffeatures, ident->iffeatures, options, u, lys_compile_iffeature, ret, done);
/* backlings (derived) can be added no sooner than when all the identities in the current module are present */
COMPILE_ARRAY_GOTO(ctx, ident_p->exts, ident->exts, options, u, lys_compile_ext, ret, done);
@@ -627,6 +633,8 @@
COMPILE_CHECK_UNIQUENESS(ctx, features, name, feature, "feature", feature_p->name);
DUP_STRING(ctx->ctx, feature_p->name, feature->name);
+ DUP_STRING(ctx->ctx, feature_p->dsc, feature->dsc);
+ DUP_STRING(ctx->ctx, feature_p->ref, feature->ref);
feature->flags = feature_p->flags;
COMPILE_ARRAY_GOTO(ctx, feature_p->exts, feature->exts, options, u, lys_compile_ext, ret, done);
@@ -1129,6 +1137,7 @@
LY_CHECK_ERR_RET(!(*range), LOGMEM(ctx->ctx), LY_EMEM);
}
+ /* we rewrite the following values as the types chain is being processed */
if (range_p->eapptag) {
lydict_remove(ctx->ctx, (*range)->eapptag);
(*range)->eapptag = lydict_insert(ctx->ctx, range_p->eapptag, 0);
@@ -1137,6 +1146,14 @@
lydict_remove(ctx->ctx, (*range)->emsg);
(*range)->emsg = lydict_insert(ctx->ctx, range_p->emsg, 0);
}
+ if (range_p->dsc) {
+ lydict_remove(ctx->ctx, (*range)->dsc);
+ (*range)->dsc = lydict_insert(ctx->ctx, range_p->dsc, 0);
+ }
+ if (range_p->ref) {
+ lydict_remove(ctx->ctx, (*range)->ref);
+ (*range)->ref = lydict_insert(ctx->ctx, range_p->ref, 0);
+ }
/* extensions are taken only from the last range by the caller */
(*range)->parts = parts;
@@ -1402,6 +1419,8 @@
}
DUP_STRING(ctx->ctx, patterns_p[u].eapptag, (*pattern)->eapptag);
DUP_STRING(ctx->ctx, patterns_p[u].emsg, (*pattern)->emsg);
+ DUP_STRING(ctx->ctx, patterns_p[u].dsc, (*pattern)->dsc);
+ DUP_STRING(ctx->ctx, patterns_p[u].ref, (*pattern)->ref);
COMPILE_ARRAY_GOTO(ctx, patterns_p[u].exts, (*pattern)->exts,
options, v, lys_compile_ext, ret, done);
}
@@ -1472,6 +1491,8 @@
LY_ARRAY_FOR(enums_p, u) {
LY_ARRAY_NEW_RET(ctx->ctx, *enums, e, LY_EMEM);
DUP_STRING(ctx->ctx, enums_p[u].name, e->name);
+ DUP_STRING(ctx->ctx, enums_p[u].ref, e->dsc);
+ DUP_STRING(ctx->ctx, enums_p[u].ref, e->ref);
if (base_enums) {
/* check the enum/bit presence in the base type - the set of enums/bits in the derived type must be a subset */
LY_ARRAY_FOR(base_enums, v) {
@@ -3884,6 +3905,10 @@
DUP_STRING(sp->ctx, sp->name, mod_c->name);
DUP_STRING(sp->ctx, sp->ns, mod_c->ns);
DUP_STRING(sp->ctx, sp->prefix, mod_c->prefix);
+ DUP_STRING(sp->ctx, sp->org, mod_c->org);
+ DUP_STRING(sp->ctx, sp->contact, mod_c->contact);
+ DUP_STRING(sp->ctx, sp->dsc, mod_c->dsc);
+ DUP_STRING(sp->ctx, sp->ref, mod_c->ref);
if (sp->revs) {
DUP_STRING(sp->ctx, sp->revs[0].date, mod_c->revision);
}
diff --git a/src/tree_schema_free.c b/src/tree_schema_free.c
index 595b848..0d58a4d 100644
--- a/src/tree_schema_free.c
+++ b/src/tree_schema_free.c
@@ -451,6 +451,8 @@
lysc_when_free(struct ly_ctx *ctx, struct lysc_when *w)
{
lyxp_expr_free(ctx, w->cond);
+ FREE_STRING(ctx, w->dsc);
+ FREE_STRING(ctx, w->ref);
FREE_ARRAY(ctx, w->exts, lysc_ext_instance_free);
}
@@ -460,6 +462,8 @@
lyxp_expr_free(ctx, must->cond);
FREE_STRING(ctx, must->emsg);
FREE_STRING(ctx, must->eapptag);
+ FREE_STRING(ctx, must->dsc);
+ FREE_STRING(ctx, must->ref);
FREE_ARRAY(ctx, must->exts, lysc_ext_instance_free);
}
@@ -475,6 +479,8 @@
lysc_ident_free(struct ly_ctx *ctx, struct lysc_ident *ident)
{
FREE_STRING(ctx, ident->name);
+ FREE_STRING(ctx, ident->dsc);
+ FREE_STRING(ctx, ident->ref);
FREE_ARRAY(ctx, ident->iffeatures, lysc_iffeature_free);
LY_ARRAY_FREE(ident->derived);
FREE_ARRAY(ctx, ident->exts, lysc_ext_instance_free);
@@ -484,6 +490,8 @@
lysc_feature_free(struct ly_ctx *ctx, struct lysc_feature *feat)
{
FREE_STRING(ctx, feat->name);
+ FREE_STRING(ctx, feat->dsc);
+ FREE_STRING(ctx, feat->ref);
FREE_ARRAY(ctx, feat->iffeatures, lysc_iffeature_free);
LY_ARRAY_FREE(feat->depfeatures);
FREE_ARRAY(ctx, feat->exts, lysc_ext_instance_free);
@@ -495,6 +503,8 @@
LY_ARRAY_FREE(range->parts);
FREE_STRING(ctx, range->eapptag);
FREE_STRING(ctx, range->emsg);
+ FREE_STRING(ctx, range->dsc);
+ FREE_STRING(ctx, range->ref);
FREE_ARRAY(ctx, range->exts, lysc_ext_instance_free);
}
@@ -508,6 +518,8 @@
pcre_free_study((*pattern)->expr_extra);
FREE_STRING(ctx, (*pattern)->eapptag);
FREE_STRING(ctx, (*pattern)->emsg);
+ FREE_STRING(ctx, (*pattern)->dsc);
+ FREE_STRING(ctx, (*pattern)->ref);
FREE_ARRAY(ctx, (*pattern)->exts, lysc_ext_instance_free);
free(*pattern);
}
@@ -516,6 +528,8 @@
lysc_enum_item_free(struct ly_ctx *ctx, struct lysc_type_enum_item *item)
{
FREE_STRING(ctx, item->name);
+ FREE_STRING(ctx, item->dsc);
+ FREE_STRING(ctx, item->ref);
FREE_ARRAY(ctx, item->iffeatures, lysc_iffeature_free);
FREE_ARRAY(ctx, item->exts, lysc_ext_instance_free);
}
@@ -716,6 +730,10 @@
FREE_STRING(ctx, module->ns);
FREE_STRING(ctx, module->prefix);
FREE_STRING(ctx, module->revision);
+ FREE_STRING(ctx, module->org);
+ FREE_STRING(ctx, module->contact);
+ FREE_STRING(ctx, module->dsc);
+ FREE_STRING(ctx, module->ref);
FREE_ARRAY(ctx, module->imports, lysc_import_free);
FREE_ARRAY(ctx, module->features, lysc_feature_free);