schema REFACTOR rename argument member in extension definition
The argname better describes meaning of the data and avoids conflicts
with the argument member in extension instances. The change affects both
the parsed and compiled extension definition structures (lysp_ext and
lysc_ext)
diff --git a/src/parser_yang.c b/src/parser_yang.c
index a3b5c03..e2a749e 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -3637,7 +3637,7 @@
LY_CHECK_RET(parse_status(ctx, &ex->flags, &ex->exts));
break;
case LY_STMT_ARGUMENT:
- LY_CHECK_RET(parse_argument(ctx, &ex->argument, &ex->flags, &ex->exts));
+ LY_CHECK_RET(parse_argument(ctx, &ex->argname, &ex->flags, &ex->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_EXTENSION, 0, &ex->exts));
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 5c9ae31..034142e 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -2071,7 +2071,7 @@
LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_NAME, &ex->name, Y_IDENTIF_ARG, LY_STMT_EXTENSION));
- struct yin_argument_meta arg_info = {&ex->flags, &ex->argument};
+ struct yin_argument_meta arg_info = {&ex->flags, &ex->argname};
struct yin_subelement subelems[] = {
{LY_STMT_ARGUMENT, &arg_info, YIN_SUBELEM_UNIQUE},
{LY_STMT_DESCRIPTION, &ex->dsc, YIN_SUBELEM_UNIQUE},
diff --git a/src/printer_yang.c b/src/printer_yang.c
index ccf321b..c5700b4 100644
--- a/src/printer_yang.c
+++ b/src/printer_yang.c
@@ -232,7 +232,7 @@
ypr_open(ctx->out, flag);
- if (ext_def->argument) {
+ if (ext_def->argname) {
ly_print_(ctx->out, "%*s%s \"", INDENT, ext[u].name);
lysp_ext_instance_resolve_argument(ctx->module->ctx, &ext[u], ext_def);
ypr_encode(ctx->out, ext[u].argument, -1);
@@ -432,9 +432,9 @@
yprp_extension_instances(ctx, LY_STMT_EXTENSION, 0, ext->exts, &flag, 0);
}
- if (ext->argument) {
+ if (ext->argname) {
ypr_open(ctx->out, &flag);
- ly_print_(ctx->out, "%*sargument %s", INDENT, ext->argument);
+ ly_print_(ctx->out, "%*sargument %s", INDENT, ext->argname);
LEVEL++;
if (ext->exts) {
u = -1;
diff --git a/src/printer_yin.c b/src/printer_yin.c
index 2604e9c..5ccea30 100644
--- a/src/printer_yin.c
+++ b/src/printer_yin.c
@@ -257,9 +257,9 @@
yprp_extension_instances(ctx, LY_STMT_EXTENSION, 0, ext->exts, &flag, 0);
}
- if (ext->argument) {
+ if (ext->argname) {
ypr_close_parent(ctx, &flag);
- ypr_open(ctx, "argument", "name", ext->argument, flag2);
+ ypr_open(ctx, "argument", "name", ext->argname, flag2);
LEVEL++;
if (ext->exts) {
@@ -1273,11 +1273,11 @@
ypr_close_parent(ctx, flag);
inner_flag = 0;
- if (ext_def->argument) {
+ if (ext_def->argname) {
lysp_ext_instance_resolve_argument(ctx->module->ctx, &ext[u], ext_def);
}
- ypr_open(ctx, ext[u].name, (ext_def->flags & LYS_YINELEM_TRUE) ? NULL : ext_def->argument, ext[u].argument, inner_flag);
+ ypr_open(ctx, ext[u].name, (ext_def->flags & LYS_YINELEM_TRUE) ? NULL : ext_def->argname, ext[u].argument, inner_flag);
LEVEL++;
if (ext_def->flags & LYS_YINELEM_TRUE) {
const char *prefix, *name, *id;
@@ -1288,9 +1288,9 @@
/* we need to use the same namespace as for the extension instance element */
id = ext[u].name;
ly_parse_nodeid(&id, &prefix, &prefix_len, &name, &name_len);
- ly_print_(ctx->out, "%*s<%.*s:%s>", INDENT, (int)prefix_len, prefix, ext_def->argument);
+ ly_print_(ctx->out, "%*s<%.*s:%s>", INDENT, (int)prefix_len, prefix, ext_def->argname);
lyxml_dump_text(ctx->out, ext[u].argument, 0);
- ly_print_(ctx->out, "</%.*s:%s>\n", (int)prefix_len, prefix, ext_def->argument);
+ ly_print_(ctx->out, "</%.*s:%s>\n", (int)prefix_len, prefix, ext_def->argname);
}
LY_LIST_FOR(ext[u].child, stmt) {
if (stmt->flags & (LYS_YIN_ATTR | LYS_YIN_ARGUMENT)) {
diff --git a/src/schema_compile.c b/src/schema_compile.c
index 39ba42b..d949b49 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -67,7 +67,7 @@
ext_p->compiled = calloc(1, sizeof **ext);
ext_p->compiled->refcount = 1;
DUP_STRING_GOTO(ctx->ctx, ext_p->name, ext_p->compiled->name, ret, done);
- DUP_STRING_GOTO(ctx->ctx, ext_p->argument, ext_p->compiled->argument, ret, done);
+ DUP_STRING_GOTO(ctx->ctx, ext_p->argname, ext_p->compiled->argname, ret, done);
ext_p->compiled->module = (struct lys_module *)ext_mod;
COMPILE_EXTS_GOTO(ctx, ext_p->exts, ext_p->compiled->exts, *ext, ret, done);
@@ -106,7 +106,7 @@
LY_CHECK_GOTO(ret = lysp_ext_find_definition(ctx->ctx, ext_p, &ext_mod, &ext_def), cleanup);
LY_CHECK_GOTO(ret = lys_compile_extension(ctx, ext_mod, ext_def, &ext->def), cleanup);
- if (ext_def->argument) {
+ if (ext_def->argname) {
LY_CHECK_GOTO(ret = lysp_ext_instance_resolve_argument(ctx->ctx, ext_p, ext_def), cleanup);
}
diff --git a/src/tree_schema.h b/src/tree_schema.h
index dc7772f..2af9a56 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -470,7 +470,7 @@
*/
struct lysp_ext {
const char *name; /**< extension name */
- const char *argument; /**< argument name, NULL if not specified */
+ const char *argname; /**< argument name, NULL if not specified */
const char *dsc; /**< description statement */
const char *ref; /**< reference statement */
struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
@@ -1369,10 +1369,14 @@
/**
* @brief Compiled YANG extension-stmt
+ *
+ * Note that the compiled extension definition is created only in case the extension is instantiated. It is not available
+ * from the compiled schema, but from the parsed extension definition which is being searched when an extension instance
+ * is being compiled.
*/
struct lysc_ext {
const char *name; /**< extension name */
- const char *argument; /**< argument name, NULL if not specified */
+ const char *argname; /**< argument name, NULL if not specified */
struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
struct lyext_plugin *plugin; /**< Plugin implementing the specific extension */
struct lys_module *module; /**< module structure */
diff --git a/src/tree_schema_free.c b/src/tree_schema_free.c
index 89a5612..cea7784 100644
--- a/src/tree_schema_free.c
+++ b/src/tree_schema_free.c
@@ -119,7 +119,7 @@
lysp_ext_free(struct ly_ctx *ctx, struct lysp_ext *ext)
{
lydict_remove(ctx, ext->name);
- lydict_remove(ctx, ext->argument);
+ lydict_remove(ctx, ext->argname);
lydict_remove(ctx, ext->dsc);
lydict_remove(ctx, ext->ref);
FREE_ARRAY(ctx, ext->exts, lysp_ext_instance_free);
@@ -502,7 +502,7 @@
return;
}
lydict_remove(ctx, (*ext)->name);
- lydict_remove(ctx, (*ext)->argument);
+ lydict_remove(ctx, (*ext)->argname);
FREE_ARRAY(ctx, (*ext)->exts, lysc_ext_instance_free);
free(*ext);
*ext = NULL;
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index 526ee61..bb6c89d 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -1869,7 +1869,7 @@
LY_ERR
lysp_ext_instance_resolve_argument(struct ly_ctx *ctx, struct lysp_ext_instance *ext_p, struct lysp_ext *ext_def)
{
- if (!ext_def->argument || ext_p->argument) {
+ if (!ext_def->argname || ext_p->argument) {
/* nothing to do */
return LY_SUCCESS;
}
@@ -1889,9 +1889,9 @@
arg = stmt->stmt;
ly_parse_nodeid(&arg, &prefix_arg, &prefix_arg_len, &name_arg, &name_arg_len);
- if (ly_strncmp(ext_def->argument, name_arg, name_arg_len)) {
+ if (ly_strncmp(ext_def->argname, name_arg, name_arg_len)) {
LOGVAL(ctx, LYVE_SEMANTICS, "Extension instance \"%s\" expects argument element \"%s\" as its first XML child, "
- "but \"%.*s\" element found.", ext_p->name, ext_def->argument, (int)name_arg_len, name_arg);
+ "but \"%.*s\" element found.", ext_p->name, ext_def->argname, (int)name_arg_len, name_arg);
return LY_EVALID;
}
@@ -1903,7 +1903,7 @@
if (ly_resolve_prefix(ctx, prefix_ext, prefix_ext_len, ext_p->format, ext_p->prefix_data) !=
ly_resolve_prefix(ctx, prefix_arg, prefix_arg_len, stmt->format, stmt->prefix_data)) {
LOGVAL(ctx, LYVE_SEMANTICS, "Extension instance \"%s\" element and its argument element \"%s\" are "
- "expected in the same namespace, but they differ.", ext_p->name, ext_def->argument);
+ "expected in the same namespace, but they differ.", ext_p->name, ext_def->argname);
return LY_EVALID;
}
}
@@ -1911,7 +1911,7 @@
/* ... argument was one of the XML attributes which are represented as child stmt
* with LYS_YIN_ATTR flag */
for (stmt = ext_p->child; stmt && (stmt->flags & LYS_YIN_ATTR); stmt = stmt->next) {
- if (!strcmp(stmt->stmt, ext_def->argument)) {
+ if (!strcmp(stmt->stmt, ext_def->argname)) {
/* this is the extension's argument */
break;
}
@@ -1927,7 +1927,7 @@
if (!ext_p->argument) {
/* missing extension's argument */
LOGVAL(ctx, LYVE_SEMANTICS, "Extension instance \"%s\" misses argument %s\"%s\".",
- ext_p->name, (ext_def->flags & LYS_YINELEM_TRUE) ? "element " : "", ext_def->argument);
+ ext_p->name, (ext_def->flags & LYS_YINELEM_TRUE) ? "element " : "", ext_def->argname);
return LY_EVALID;
}