Skip to content

Commit

Permalink
structure REFATCOR minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvasko committed Nov 8, 2022
1 parent 1466280 commit 220f055
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions src/plugins_exts/structure.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ structure_compile(struct lysc_ctx *cctx, const struct lysp_ext_instance *extp, s
}

/**
* @brief INFO printer
* @brief Structure schema info printer.
*
* Implementation of ::lyplg_ext_sprinter_info_clb set as ::lyext_plugin::printer_info
*/
Expand Down Expand Up @@ -430,6 +430,11 @@ structure_sprinter_cnode(const struct lysc_node *UNUSED(node), const void *UNUSE
return LY_SUCCESS;
}

/**
* @brief Structure schema compiled tree printer.
*
* Implementation of ::lyplg_ext_sprinter_ctree_clb callback set as lyext_plugin::printer_ctree.
*/
static LY_ERR
structure_sprinter_ctree(struct lysc_ext_instance *ext, const struct lyspr_tree_ctx *ctx,
const char **UNUSED(flags), const char **UNUSED(add_opts))
Expand All @@ -440,6 +445,11 @@ structure_sprinter_ctree(struct lysc_ext_instance *ext, const struct lyspr_tree_
return rc;
}

/**
* @brief Structure schema parsed tree printer.
*
* Implementation of ::lyplg_ext_sprinter_ptree_clb callback set as lyext_plugin::printer_ptree.
*/
static LY_ERR
structure_sprinter_ptree(struct lysp_ext_instance *ext, const struct lyspr_tree_ctx *ctx,
const char **UNUSED(flags), const char **UNUSED(add_opts))
Expand All @@ -450,6 +460,11 @@ structure_sprinter_ptree(struct lysp_ext_instance *ext, const struct lyspr_tree_
return rc;
}

/**
* @brief Augment structure schema parsed tree printer.
*
* Implementation of ::lyplg_ext_sprinter_ptree_clb callback set as lyext_plugin::printer_ptree.
*/
static LY_ERR
structure_aug_sprinter_ptree(struct lysp_ext_instance *ext, const struct lyspr_tree_ctx *ctx,
const char **UNUSED(flags), const char **UNUSED(add_opts))
Expand All @@ -465,9 +480,14 @@ structure_aug_sprinter_ptree(struct lysp_ext_instance *ext, const struct lyspr_t
return rc;
}

/**
* @brief Augment structure schema compiled tree printer.
*
* Implementation of ::lyplg_ext_sprinter_ctree_clb callback set as lyext_plugin::printer_ctree.
*/
static LY_ERR
structure_aug_sprinter_ctree(struct lysc_ext_instance *ext, const struct lyspr_tree_ctx *ctx,
const char **flags, const char **add_opts)
structure_aug_sprinter_ctree(struct lysc_ext_instance *ext, const struct lyspr_tree_ctx *ctx, const char **flags,
const char **add_opts)
{
LY_ERR rc = LY_SUCCESS;

Expand All @@ -476,18 +496,17 @@ structure_aug_sprinter_ctree(struct lysc_ext_instance *ext, const struct lyspr_t

assert(ctx);

/* find the parsed ext structure */
parsed_ext = ext->module->parsed->exts;
LY_ARRAY_FOR(parsed_ext, i) {
if (strcmp(parsed_ext[i].name, "sx:augment-structure")) {
continue;
} else if (strcmp(parsed_ext[i].argument, ext->argument)) {
continue;
if (!strcmp(parsed_ext[i].name, "sx:augment-structure") && !strcmp(parsed_ext[i].argument, ext->argument)) {
break;
}

rc = structure_aug_sprinter_ptree(parsed_ext, ctx, flags, add_opts);
break;
}
assert(i < LY_ARRAY_COUNT(parsed_ext));

/* for augments print the parsed tree */
rc = structure_aug_sprinter_ptree(parsed_ext, ctx, flags, add_opts);
return rc;
}

Expand Down

0 comments on commit 220f055

Please sign in to comment.