diff options
Diffstat (limited to '')
-rw-r--r-- | src/plugins_exts.c | 100 | ||||
-rw-r--r-- | src/plugins_exts.h | 7 | ||||
-rw-r--r-- | src/plugins_exts/metadata.c | 24 | ||||
-rw-r--r-- | src/plugins_exts/structure.c | 84 | ||||
-rw-r--r-- | src/plugins_exts/yangdata.c | 12 |
5 files changed, 115 insertions, 112 deletions
diff --git a/src/plugins_exts.c b/src/plugins_exts.c index cffbe53..71449ba 100644 --- a/src/plugins_exts.c +++ b/src/plugins_exts.c @@ -4,7 +4,7 @@ * @author Michal Vasko <mvasko@cesnet.cz> * @brief helper functions for extension plugins * - * Copyright (c) 2019 - 2022 CESNET, z.s.p.o. + * Copyright (c) 2019 - 2024 CESNET, z.s.p.o. * * This source code is licensed under BSD 3-Clause License (the "License"). * You may not use this file except in compliance with the License. @@ -81,34 +81,34 @@ cleanup: * @brief Compile an instance extension statement. * * @param[in] ctx Compile context. - * @param[in] parsed Parsed ext instance substatement structure. + * @param[in] parsed_p Parsed ext instance substatement structure. * @param[in] ext Compiled ext instance. * @param[in] substmt Compled ext instance substatement info. * @return LY_ERR value. */ static LY_ERR -lys_compile_ext_instance_stmt(struct lysc_ctx *ctx, uint64_t parsed, struct lysc_ext_instance *ext, +lys_compile_ext_instance_stmt(struct lysc_ctx *ctx, void **parsed_p, struct lysc_ext_instance *ext, struct lysc_ext_substmt *substmt) { LY_ERR rc = LY_SUCCESS; ly_bool length_restr = 0; LY_DATA_TYPE basetype; - assert(parsed); + assert(*parsed_p); /* compilation wthout any storage */ if (substmt->stmt == LY_STMT_IF_FEATURE) { ly_bool enabled; /* evaluate */ - LY_CHECK_GOTO(rc = lys_eval_iffeatures(ctx->ctx, VOIDPTR_C(parsed), &enabled), cleanup); + LY_CHECK_GOTO(rc = lys_eval_iffeatures(ctx->ctx, *parsed_p, &enabled), cleanup); if (!enabled) { /* it is disabled, remove the whole extension instance */ rc = LY_ENOT; } } - if (!substmt->storage) { + if (!substmt->storage_p) { /* nothing to store */ goto cleanup; } @@ -133,7 +133,7 @@ lys_compile_ext_instance_stmt(struct lysc_ctx *ctx, uint64_t parsed, struct lysc struct lysc_node *node; lyplg_ext_get_storage(ext, LY_STMT_STATUS, sizeof flags, (const void **)&flags); - pnodes = VOIDPTR_C(parsed); + pnodes = *parsed_p; /* compile nodes */ LY_LIST_FOR(pnodes, pnode) { @@ -163,7 +163,7 @@ lys_compile_ext_instance_stmt(struct lysc_ctx *ctx, uint64_t parsed, struct lysc case LY_STMT_REFERENCE: case LY_STMT_UNITS: /* just make a copy */ - LY_CHECK_GOTO(rc = lydict_insert(ctx->ctx, VOIDPTR_C(parsed), 0, VOIDPTR_C(substmt->storage)), cleanup); + LY_CHECK_GOTO(rc = lydict_insert(ctx->ctx, *parsed_p, 0, (const char **)substmt->storage_p), cleanup); break; case LY_STMT_BIT: @@ -175,7 +175,7 @@ lys_compile_ext_instance_stmt(struct lysc_ctx *ctx, uint64_t parsed, struct lysc } /* compile */ - rc = lys_compile_type_enums(ctx, VOIDPTR_C(parsed), basetype, NULL, VOIDPTR_C(substmt->storage)); + rc = lys_compile_type_enums(ctx, *parsed_p, basetype, NULL, (struct lysc_type_bitenum_item **)substmt->storage_p); LY_CHECK_GOTO(rc, cleanup); break; @@ -183,7 +183,7 @@ lys_compile_ext_instance_stmt(struct lysc_ctx *ctx, uint64_t parsed, struct lysc uint16_t flags; if (!(ctx->compile_opts & LYS_COMPILE_NO_CONFIG)) { - memcpy(&flags, &parsed, 2); + memcpy(&flags, parsed_p, 2); if (flags & LYS_CONFIG_MASK) { /* explicitly set */ flags |= LYS_SET_CONFIG; @@ -194,56 +194,56 @@ lys_compile_ext_instance_stmt(struct lysc_ctx *ctx, uint64_t parsed, struct lysc /* default config */ flags = LYS_CONFIG_W; } - memcpy(VOIDPTR_C(substmt->storage), &flags, 2); + memcpy(substmt->storage_p, &flags, 2); } /* else leave zero */ break; } case LY_STMT_MUST: { - const struct lysp_restr *restrs = VOIDPTR_C(parsed); + const struct lysp_restr *restrs = *parsed_p; /* sized array */ - COMPILE_ARRAY_GOTO(ctx, restrs, *(struct lysc_must **)VOIDPTR_C(substmt->storage), lys_compile_must, rc, cleanup); + COMPILE_ARRAY_GOTO(ctx, restrs, *(struct lysc_must **)substmt->storage_p, lys_compile_must, rc, cleanup); break; } case LY_STMT_WHEN: { const uint16_t flags; - const struct lysp_when *when = VOIDPTR_C(parsed); + const struct lysp_when *when = *parsed_p; /* read compiled status */ lyplg_ext_get_storage(ext, LY_STMT_STATUS, sizeof flags, (const void **)&flags); /* compile */ - LY_CHECK_GOTO(rc = lys_compile_when(ctx, when, flags, NULL, NULL, NULL, VOIDPTR_C(substmt->storage)), cleanup); + LY_CHECK_GOTO(rc = lys_compile_when(ctx, when, flags, NULL, NULL, NULL, (struct lysc_when **)substmt->storage_p), cleanup); break; } case LY_STMT_FRACTION_DIGITS: case LY_STMT_REQUIRE_INSTANCE: /* just make a copy */ - memcpy(VOIDPTR_C(substmt->storage), &parsed, 1); + memcpy(substmt->storage_p, parsed_p, 1); break; case LY_STMT_MANDATORY: case LY_STMT_ORDERED_BY: case LY_STMT_STATUS: /* just make a copy */ - memcpy(VOIDPTR_C(substmt->storage), &parsed, 2); + memcpy(substmt->storage_p, parsed_p, 2); break; case LY_STMT_MAX_ELEMENTS: case LY_STMT_MIN_ELEMENTS: /* just make a copy */ - memcpy(VOIDPTR_C(substmt->storage), &parsed, 4); + memcpy(substmt->storage_p, parsed_p, 4); break; case LY_STMT_POSITION: case LY_STMT_VALUE: /* just make a copy */ - memcpy(VOIDPTR_C(substmt->storage), &parsed, 8); + memcpy(substmt->storage_p, parsed_p, 8); break; case LY_STMT_IDENTITY: /* compile */ - rc = lys_identity_precompile(ctx, NULL, NULL, VOIDPTR_C(parsed), VOIDPTR_C(substmt->storage)); + rc = lys_identity_precompile(ctx, NULL, NULL, *parsed_p, (struct lysc_ident **)substmt->storage_p); LY_CHECK_GOTO(rc, cleanup); break; @@ -252,36 +252,36 @@ lys_compile_ext_instance_stmt(struct lysc_ctx *ctx, uint64_t parsed, struct lysc /* fallthrough */ case LY_STMT_RANGE: /* compile, use uint64 default range */ - rc = lys_compile_type_range(ctx, VOIDPTR_C(parsed), LY_TYPE_UINT64, length_restr, 0, NULL, VOIDPTR_C(substmt->storage)); + rc = lys_compile_type_range(ctx, *parsed_p, LY_TYPE_UINT64, length_restr, 0, NULL, (struct lysc_range **)substmt->storage_p); LY_CHECK_GOTO(rc, cleanup); break; case LY_STMT_PATTERN: /* compile */ - rc = lys_compile_type_patterns(ctx, VOIDPTR_C(parsed), NULL, VOIDPTR_C(substmt->storage)); + rc = lys_compile_type_patterns(ctx, *parsed_p, NULL, (struct lysc_pattern ***)substmt->storage_p); LY_CHECK_GOTO(rc, cleanup); break; case LY_STMT_TYPE: { const uint16_t flags; const char *units; - const struct lysp_type *ptype = VOIDPTR_C(parsed); + const struct lysp_type *ptype = *parsed_p; /* read compiled info */ lyplg_ext_get_storage(ext, LY_STMT_STATUS, sizeof flags, (const void **)&flags); lyplg_ext_get_storage(ext, LY_STMT_UNITS, sizeof units, (const void **)&units); /* compile */ - rc = lys_compile_type(ctx, NULL, flags, ext->def->name, ptype, VOIDPTR_C(substmt->storage), &units, NULL); + rc = lys_compile_type(ctx, NULL, flags, ext->def->name, ptype, (struct lysc_type **)substmt->storage_p, &units, NULL); LY_CHECK_GOTO(rc, cleanup); - LY_ATOMIC_INC_BARRIER((*(struct lysc_type **)VOIDPTR_C(substmt->storage))->refcount); + LY_ATOMIC_INC_BARRIER((*(struct lysc_type **)substmt->storage_p)->refcount); break; } case LY_STMT_EXTENSION_INSTANCE: { - struct lysp_ext_instance *extps = VOIDPTR_C(parsed); + struct lysp_ext_instance *extps = *parsed_p; /* compile sized array */ - COMPILE_EXTS_GOTO(ctx, extps, *(struct lysc_ext_instance **)VOIDPTR_C(substmt->storage), ext, rc, cleanup); + COMPILE_EXTS_GOTO(ctx, extps, *(struct lysc_ext_instance **)substmt->storage_p, ext, rc, cleanup); break; } case LY_STMT_AUGMENT: @@ -330,7 +330,7 @@ lyplg_ext_compile_extension_instance(struct lysc_ctx *ctx, const struct lysp_ext LY_ERR rc = LY_SUCCESS; LY_ARRAY_COUNT_TYPE u, v; enum ly_stmt stmtp; - uint64_t storagep; + void **storagep; struct ly_set storagep_compiled = {0}; LY_CHECK_ARG_RET(ctx ? ctx->ctx : NULL, ctx, extp, ext, LY_EINVAL); @@ -340,9 +340,9 @@ lyplg_ext_compile_extension_instance(struct lysc_ctx *ctx, const struct lysp_ext LY_ARRAY_FOR(extp->substmts, u) { stmtp = extp->substmts[u].stmt; - storagep = *(uint64_t *)VOIDPTR_C(extp->substmts[u].storage); + storagep = extp->substmts[u].storage_p; - if (!storagep || ly_set_contains(&storagep_compiled, VOIDPTR_C(storagep), NULL)) { + if (!*storagep || ly_set_contains(&storagep_compiled, storagep, NULL)) { /* nothing parsed or already compiled (for example, if it is a linked list of parsed nodes) */ continue; } @@ -361,7 +361,7 @@ lyplg_ext_compile_extension_instance(struct lysc_ctx *ctx, const struct lysp_ext } /* compiled */ - ly_set_add(&storagep_compiled, VOIDPTR_C(storagep), 1, NULL); + ly_set_add(&storagep_compiled, storagep, 1, NULL); } cleanup: @@ -420,7 +420,7 @@ lyplg_ext_sprinter_ctree_add_ext_nodes(const struct lyspr_tree_ctx *ctx, struct uint32_t i; struct lysc_node *schema; - LY_CHECK_ARG_RET2(NULL, ctx, ext, LY_EINVAL); + LY_CHECK_ARG_RET(NULL, ctx, ext, LY_EINVAL); LY_ARRAY_FOR(ext->substmts, i) { switch (ext->substmts[i].stmt) { @@ -437,7 +437,7 @@ lyplg_ext_sprinter_ctree_add_ext_nodes(const struct lyspr_tree_ctx *ctx, struct case LY_STMT_LEAF: case LY_STMT_LEAF_LIST: case LY_STMT_LIST: - schema = *VOIDPTR2_C(ext->substmts[i].storage); + schema = *ext->substmts[i].storage_p; if (schema) { rc = lyplg_ext_sprinter_ctree_add_nodes(ctx, schema, clb); return rc; @@ -458,7 +458,7 @@ lyplg_ext_sprinter_ptree_add_ext_nodes(const struct lyspr_tree_ctx *ctx, struct uint32_t i; struct lysp_node *schema; - LY_CHECK_ARG_RET2(NULL, ctx, ext, LY_EINVAL); + LY_CHECK_ARG_RET(NULL, ctx, ext, LY_EINVAL); LY_ARRAY_FOR(ext->substmts, i) { switch (ext->substmts[i].stmt) { @@ -475,7 +475,7 @@ lyplg_ext_sprinter_ptree_add_ext_nodes(const struct lyspr_tree_ctx *ctx, struct case LY_STMT_LEAF: case LY_STMT_LEAF_LIST: case LY_STMT_LIST: - schema = *VOIDPTR2_C(ext->substmts[i].storage); + schema = *ext->substmts[i].storage_p; if (schema) { rc = lyplg_ext_sprinter_ptree_add_nodes(ctx, schema, clb); return rc; @@ -494,7 +494,7 @@ lyplg_ext_sprinter_ctree_add_nodes(const struct lyspr_tree_ctx *ctx, struct lysc { struct lyspr_tree_schema *new; - LY_CHECK_ARG_RET1(NULL, ctx, LY_EINVAL); + LY_CHECK_ARG_RET(NULL, ctx, LY_EINVAL); if (!nodes) { return LY_SUCCESS; @@ -514,7 +514,7 @@ lyplg_ext_sprinter_ptree_add_nodes(const struct lyspr_tree_ctx *ctx, struct lysp { struct lyspr_tree_schema *new; - LY_CHECK_ARG_RET1(NULL, ctx, LY_EINVAL); + LY_CHECK_ARG_RET(NULL, ctx, LY_EINVAL); if (!nodes) { return LY_SUCCESS; @@ -531,7 +531,7 @@ lyplg_ext_sprinter_ptree_add_nodes(const struct lyspr_tree_ctx *ctx, struct lysp LIBYANG_API_DECL LY_ERR lyplg_ext_sprinter_tree_set_priv(const struct lyspr_tree_ctx *ctx, void *plugin_priv, void (*free_clb)(void *plugin_priv)) { - LY_CHECK_ARG_RET1(NULL, ctx, LY_EINVAL); + LY_CHECK_ARG_RET(NULL, ctx, LY_EINVAL); ((struct lyspr_tree_ctx *)ctx)->plugin_priv = plugin_priv; ((struct lyspr_tree_ctx *)ctx)->free_plugin_priv = free_clb; @@ -587,12 +587,12 @@ lyplg_ext_nodetype2stmt(uint16_t nodetype) } LY_ERR -lyplg_ext_get_storage_p(const struct lysc_ext_instance *ext, int stmt, uint64_t *storage_p) +lyplg_ext_get_storage_p(const struct lysc_ext_instance *ext, int stmt, void ***storage_pp) { LY_ARRAY_COUNT_TYPE u; enum ly_stmt match = 0; - *storage_p = 0; + *storage_pp = NULL; if (!(stmt & LY_STMT_NODE_MASK)) { /* matching a non-node statement */ @@ -601,7 +601,7 @@ lyplg_ext_get_storage_p(const struct lysc_ext_instance *ext, int stmt, uint64_t LY_ARRAY_FOR(ext->substmts, u) { if ((match && (ext->substmts[u].stmt == match)) || (!match && (ext->substmts[u].stmt & stmt))) { - *storage_p = ext->substmts[u].storage; + *storage_pp = ext->substmts[u].storage_p; return LY_SUCCESS; } } @@ -613,14 +613,14 @@ LIBYANG_API_DEF LY_ERR lyplg_ext_get_storage(const struct lysc_ext_instance *ext, int stmt, uint32_t storage_size, const void **storage) { LY_ERR rc = LY_SUCCESS; - uint64_t s; + void **s_p; /* get pointer to the storage, is set even on error */ - rc = lyplg_ext_get_storage_p(ext, stmt, &s); + rc = lyplg_ext_get_storage_p(ext, stmt, &s_p); /* assign */ - if (s) { - memcpy(storage, VOIDPTR_C(s), storage_size); + if (s_p) { + memcpy(storage, s_p, storage_size); } else { memset(storage, 0, storage_size); } @@ -634,7 +634,9 @@ lyplg_ext_parsed_get_storage(const struct lysc_ext_instance *ext, int stmt, uint LY_ARRAY_COUNT_TYPE u; const struct lysp_ext_instance *extp = NULL; enum ly_stmt match = 0; - uint64_t s = 0; + void **s_p = NULL; + + LY_CHECK_ARG_RET(NULL, ext, ext->module->parsed, LY_EINVAL); /* find the parsed ext instance */ LY_ARRAY_FOR(ext->module->parsed->exts, u) { @@ -655,14 +657,14 @@ lyplg_ext_parsed_get_storage(const struct lysc_ext_instance *ext, int stmt, uint /* get the substatement */ LY_ARRAY_FOR(extp->substmts, u) { if ((match && (extp->substmts[u].stmt == match)) || (!match && (extp->substmts[u].stmt & stmt))) { - s = extp->substmts[u].storage; + s_p = extp->substmts[u].storage_p; break; } } /* assign */ - if (s) { - memcpy(storage, VOIDPTR_C(s), storage_size); + if (s_p) { + memcpy(storage, s_p, storage_size); } else { memset(storage, 0, storage_size); } diff --git a/src/plugins_exts.h b/src/plugins_exts.h index 74ce215..4cf80b2 100644 --- a/src/plugins_exts.h +++ b/src/plugins_exts.h @@ -109,7 +109,7 @@ extern "C" { /** * @brief Extensions API version */ -#define LYPLG_EXT_API_VERSION 6 +#define LYPLG_EXT_API_VERSION 8 /** * @brief Mask for an operation statement. @@ -393,7 +393,7 @@ struct lysp_stmt { */ struct lysp_ext_substmt { enum ly_stmt stmt; /**< parsed substatement */ - uint64_t storage; /**< (pointer to) the parsed storage of the statement according to the specific + void **storage_p; /**< pointer to the parsed storage of the statement according to the specific lys_ext_substmt::stmt */ }; @@ -419,6 +419,7 @@ struct lysp_ext_instance { parsed data ([sized array](@ref sizedarrays)) */ void *parsed; /**< private plugin parsed data */ struct lysp_stmt *child; /**< list of generic (unknown) YANG statements */ + struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ }; /** @@ -426,7 +427,7 @@ struct lysp_ext_instance { */ struct lysc_ext_substmt { enum ly_stmt stmt; /**< compiled substatement */ - uint64_t storage; /**< (pointer to) the compiled storage of the statement according to the specific + void **storage_p; /**< pointer to the compiled storage of the statement according to the specific lys_ext_substmt::stmt */ }; diff --git a/src/plugins_exts/metadata.c b/src/plugins_exts/metadata.c index aa6cb43..baec86f 100644 --- a/src/plugins_exts/metadata.c +++ b/src/plugins_exts/metadata.c @@ -79,27 +79,27 @@ annotation_parse(struct lysp_ctx *pctx, struct lysp_ext_instance *ext) LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[0].stmt = LY_STMT_IF_FEATURE; - ext->substmts[0].storage = (uint64_t)(uintptr_t)&ann_pdata->iffeatures; + ext->substmts[0].storage_p = (void **)&ann_pdata->iffeatures; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[1].stmt = LY_STMT_UNITS; - ext->substmts[1].storage = (uint64_t)(uintptr_t)&ann_pdata->units; + ext->substmts[1].storage_p = (void **)&ann_pdata->units; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[2].stmt = LY_STMT_STATUS; - ext->substmts[2].storage = (uint64_t)(uintptr_t)&ann_pdata->flags; + ext->substmts[2].storage_p = (void **)&ann_pdata->flags; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[3].stmt = LY_STMT_TYPE; - ext->substmts[3].storage = (uint64_t)(uintptr_t)&ann_pdata->type; + ext->substmts[3].storage_p = (void **)&ann_pdata->type; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[4].stmt = LY_STMT_DESCRIPTION; - ext->substmts[4].storage = (uint64_t)(uintptr_t)&ann_pdata->dsc; + ext->substmts[4].storage_p = (void **)&ann_pdata->dsc; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[5].stmt = LY_STMT_REFERENCE; - ext->substmts[5].storage = (uint64_t)(uintptr_t)&ann_pdata->ref; + ext->substmts[5].storage_p = (void **)&ann_pdata->ref; if ((r = lyplg_ext_parse_extension_instance(pctx, ext))) { return r; @@ -139,27 +139,27 @@ annotation_compile(struct lysc_ctx *cctx, const struct lysp_ext_instance *extp, LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[0].stmt = LY_STMT_IF_FEATURE; - ext->substmts[0].storage = 0; + ext->substmts[0].storage_p = NULL; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[1].stmt = LY_STMT_UNITS; - ext->substmts[1].storage = (uint64_t)(uintptr_t)&ann_cdata->units; + ext->substmts[1].storage_p = (void **)&ann_cdata->units; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[2].stmt = LY_STMT_STATUS; - ext->substmts[2].storage = (uint64_t)(uintptr_t)&ann_cdata->flags; + ext->substmts[2].storage_p = (void **)&ann_cdata->flags; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[3].stmt = LY_STMT_TYPE; - ext->substmts[3].storage = (uint64_t)(uintptr_t)&ann_cdata->type; + ext->substmts[3].storage_p = (void **)&ann_cdata->type; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[4].stmt = LY_STMT_DESCRIPTION; - ext->substmts[4].storage = (uint64_t)(uintptr_t)&ann_cdata->dsc; + ext->substmts[4].storage_p = (void **)&ann_cdata->dsc; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[5].stmt = LY_STMT_REFERENCE; - ext->substmts[5].storage = (uint64_t)(uintptr_t)&ann_cdata->ref; + ext->substmts[5].storage_p = (void **)&ann_cdata->ref; ret = lyplg_ext_compile_extension_instance(cctx, extp, ext); return ret; diff --git a/src/plugins_exts/structure.c b/src/plugins_exts/structure.c index bc2ea0e..6aa902e 100644 --- a/src/plugins_exts/structure.c +++ b/src/plugins_exts/structure.c @@ -90,60 +90,60 @@ structure_parse(struct lysp_ctx *pctx, struct lysp_ext_instance *ext) /* parse substatements */ LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[0].stmt = LY_STMT_MUST; - ext->substmts[0].storage = (uint64_t)(uintptr_t)&struct_pdata->musts; + ext->substmts[0].storage_p = (void **)&struct_pdata->musts; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[1].stmt = LY_STMT_STATUS; - ext->substmts[1].storage = (uint64_t)(uintptr_t)&struct_pdata->flags; + ext->substmts[1].storage_p = (void **)&struct_pdata->flags; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[2].stmt = LY_STMT_DESCRIPTION; - ext->substmts[2].storage = (uint64_t)(uintptr_t)&struct_pdata->dsc; + ext->substmts[2].storage_p = (void **)&struct_pdata->dsc; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[3].stmt = LY_STMT_REFERENCE; - ext->substmts[3].storage = (uint64_t)(uintptr_t)&struct_pdata->ref; + ext->substmts[3].storage_p = (void **)&struct_pdata->ref; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[4].stmt = LY_STMT_TYPEDEF; - ext->substmts[4].storage = (uint64_t)(uintptr_t)&struct_pdata->typedefs; + ext->substmts[4].storage_p = (void **)&struct_pdata->typedefs; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[5].stmt = LY_STMT_GROUPING; - ext->substmts[5].storage = (uint64_t)(uintptr_t)&struct_pdata->groupings; + ext->substmts[5].storage_p = (void **)&struct_pdata->groupings; /* data-def-stmt */ LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[6].stmt = LY_STMT_CONTAINER; - ext->substmts[6].storage = (uint64_t)(uintptr_t)&struct_pdata->child; + ext->substmts[6].storage_p = (void **)&struct_pdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[7].stmt = LY_STMT_LEAF; - ext->substmts[7].storage = (uint64_t)(uintptr_t)&struct_pdata->child; + ext->substmts[7].storage_p = (void **)&struct_pdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[8].stmt = LY_STMT_LEAF_LIST; - ext->substmts[8].storage = (uint64_t)(uintptr_t)&struct_pdata->child; + ext->substmts[8].storage_p = (void **)&struct_pdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[9].stmt = LY_STMT_LIST; - ext->substmts[9].storage = (uint64_t)(uintptr_t)&struct_pdata->child; + ext->substmts[9].storage_p = (void **)&struct_pdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[10].stmt = LY_STMT_CHOICE; - ext->substmts[10].storage = (uint64_t)(uintptr_t)&struct_pdata->child; + ext->substmts[10].storage_p = (void **)&struct_pdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[11].stmt = LY_STMT_ANYDATA; - ext->substmts[11].storage = (uint64_t)(uintptr_t)&struct_pdata->child; + ext->substmts[11].storage_p = (void **)&struct_pdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[12].stmt = LY_STMT_ANYXML; - ext->substmts[12].storage = (uint64_t)(uintptr_t)&struct_pdata->child; + ext->substmts[12].storage_p = (void **)&struct_pdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[13].stmt = LY_STMT_USES; - ext->substmts[13].storage = (uint64_t)(uintptr_t)&struct_pdata->child; + ext->substmts[13].storage_p = (void **)&struct_pdata->child; rc = lyplg_ext_parse_extension_instance(pctx, ext); return rc; @@ -190,60 +190,60 @@ structure_compile(struct lysc_ctx *cctx, const struct lysp_ext_instance *extp, s LY_ARRAY_CREATE_GOTO(cctx->ctx, ext->substmts, 14, rc, emem); LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[0].stmt = LY_STMT_MUST; - ext->substmts[0].storage = (uint64_t)(uintptr_t)&struct_cdata->musts; + ext->substmts[0].storage_p = (void **)&struct_cdata->musts; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[1].stmt = LY_STMT_STATUS; - ext->substmts[1].storage = (uint64_t)(uintptr_t)&struct_cdata->flags; + ext->substmts[1].storage_p = (void **)&struct_cdata->flags; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[2].stmt = LY_STMT_DESCRIPTION; - ext->substmts[2].storage = (uint64_t)(uintptr_t)&struct_cdata->dsc; + ext->substmts[2].storage_p = (void **)&struct_cdata->dsc; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[3].stmt = LY_STMT_REFERENCE; - ext->substmts[3].storage = (uint64_t)(uintptr_t)&struct_cdata->ref; + ext->substmts[3].storage_p = (void **)&struct_cdata->ref; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[4].stmt = LY_STMT_TYPEDEF; - ext->substmts[4].storage = 0; + ext->substmts[4].storage_p = 0; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[5].stmt = LY_STMT_GROUPING; - ext->substmts[5].storage = 0; + ext->substmts[5].storage_p = 0; /* data-def-stmt */ LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[6].stmt = LY_STMT_CONTAINER; - ext->substmts[6].storage = (uint64_t)(uintptr_t)&struct_cdata->child; + ext->substmts[6].storage_p = (void **)&struct_cdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[7].stmt = LY_STMT_LEAF; - ext->substmts[7].storage = (uint64_t)(uintptr_t)&struct_cdata->child; + ext->substmts[7].storage_p = (void **)&struct_cdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[8].stmt = LY_STMT_LEAF_LIST; - ext->substmts[8].storage = (uint64_t)(uintptr_t)&struct_cdata->child; + ext->substmts[8].storage_p = (void **)&struct_cdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[9].stmt = LY_STMT_LIST; - ext->substmts[9].storage = (uint64_t)(uintptr_t)&struct_cdata->child; + ext->substmts[9].storage_p = (void **)&struct_cdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[10].stmt = LY_STMT_CHOICE; - ext->substmts[10].storage = (uint64_t)(uintptr_t)&struct_cdata->child; + ext->substmts[10].storage_p = (void **)&struct_cdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[11].stmt = LY_STMT_ANYDATA; - ext->substmts[11].storage = (uint64_t)(uintptr_t)&struct_cdata->child; + ext->substmts[11].storage_p = (void **)&struct_cdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[12].stmt = LY_STMT_ANYXML; - ext->substmts[12].storage = (uint64_t)(uintptr_t)&struct_cdata->child; + ext->substmts[12].storage_p = (void **)&struct_cdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[13].stmt = LY_STMT_USES; - ext->substmts[13].storage = (uint64_t)(uintptr_t)&struct_cdata->child; + ext->substmts[13].storage_p = (void **)&struct_cdata->child; *lyplg_ext_compile_get_options(cctx) |= LYS_COMPILE_NO_CONFIG | LYS_COMPILE_NO_DISABLED; rc = lyplg_ext_compile_extension_instance(cctx, extp, ext); @@ -339,53 +339,53 @@ structure_aug_parse(struct lysp_ctx *pctx, struct lysp_ext_instance *ext) /* parse substatements */ LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[0].stmt = LY_STMT_STATUS; - ext->substmts[0].storage = (uint64_t)(uintptr_t)&aug_pdata->flags; + ext->substmts[0].storage_p = (void **)&aug_pdata->flags; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[1].stmt = LY_STMT_DESCRIPTION; - ext->substmts[1].storage = (uint64_t)(uintptr_t)&aug_pdata->dsc; + ext->substmts[1].storage_p = (void **)&aug_pdata->dsc; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[2].stmt = LY_STMT_REFERENCE; - ext->substmts[2].storage = (uint64_t)(uintptr_t)&aug_pdata->ref; + ext->substmts[2].storage_p = (void **)&aug_pdata->ref; /* data-def-stmt */ LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[3].stmt = LY_STMT_CONTAINER; - ext->substmts[3].storage = (uint64_t)(uintptr_t)&aug_pdata->child; + ext->substmts[3].storage_p = (void **)&aug_pdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[4].stmt = LY_STMT_LEAF; - ext->substmts[4].storage = (uint64_t)(uintptr_t)&aug_pdata->child; + ext->substmts[4].storage_p = (void **)&aug_pdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[5].stmt = LY_STMT_LEAF_LIST; - ext->substmts[5].storage = (uint64_t)(uintptr_t)&aug_pdata->child; + ext->substmts[5].storage_p = (void **)&aug_pdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[6].stmt = LY_STMT_LIST; - ext->substmts[6].storage = (uint64_t)(uintptr_t)&aug_pdata->child; + ext->substmts[6].storage_p = (void **)&aug_pdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[7].stmt = LY_STMT_CHOICE; - ext->substmts[7].storage = (uint64_t)(uintptr_t)&aug_pdata->child; + ext->substmts[7].storage_p = (void **)&aug_pdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[8].stmt = LY_STMT_ANYDATA; - ext->substmts[8].storage = (uint64_t)(uintptr_t)&aug_pdata->child; + ext->substmts[8].storage_p = (void **)&aug_pdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[9].stmt = LY_STMT_ANYXML; - ext->substmts[9].storage = (uint64_t)(uintptr_t)&aug_pdata->child; + ext->substmts[9].storage_p = (void **)&aug_pdata->child; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[10].stmt = LY_STMT_USES; - ext->substmts[10].storage = (uint64_t)(uintptr_t)&aug_pdata->child; + ext->substmts[10].storage_p = (void **)&aug_pdata->child; /* case */ LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[11].stmt = LY_STMT_CASE; - ext->substmts[11].storage = (uint64_t)(uintptr_t)&aug_pdata->child; + ext->substmts[11].storage_p = (void **)&aug_pdata->child; if ((rc = lyplg_ext_parse_extension_instance(pctx, ext))) { return rc; @@ -394,7 +394,7 @@ structure_aug_parse(struct lysp_ctx *pctx, struct lysp_ext_instance *ext) /* add fake parsed augment node */ LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[12].stmt = LY_STMT_AUGMENT; - ext->substmts[12].storage = (uint64_t)(uintptr_t)&aug_pdata->aug; + ext->substmts[12].storage_p = (void **)&aug_pdata->aug; aug_pdata->aug = calloc(1, sizeof *aug_pdata->aug); if (!aug_pdata->aug) { @@ -476,7 +476,7 @@ structure_aug_sprinter_ptree(struct lysp_ext_instance *ext, const struct lyspr_t assert(ctx); - aug = (struct lysp_node_augment **)(uintptr_t)ext->substmts[12].storage; + aug = (struct lysp_node_augment **)ext->substmts[12].storage_p; rc = lyplg_ext_sprinter_ptree_add_nodes(ctx, (*aug)->child, structure_sprinter_pnode); return rc; diff --git a/src/plugins_exts/yangdata.c b/src/plugins_exts/yangdata.c index c9c5dd8..1736abc 100644 --- a/src/plugins_exts/yangdata.c +++ b/src/plugins_exts/yangdata.c @@ -58,15 +58,15 @@ yangdata_parse(struct lysp_ctx *pctx, struct lysp_ext_instance *ext) LY_ARRAY_CREATE_GOTO(lyplg_ext_parse_get_cur_pmod(pctx)->mod->ctx, ext->substmts, 3, ret, emem); LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[0].stmt = LY_STMT_CONTAINER; - ext->substmts[0].storage = (uint64_t)(uintptr_t)&ext->parsed; + ext->substmts[0].storage_p = (void **)&ext->parsed; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[1].stmt = LY_STMT_CHOICE; - ext->substmts[1].storage = (uint64_t)(uintptr_t)&ext->parsed; + ext->substmts[1].storage_p = (void **)&ext->parsed; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[2].stmt = LY_STMT_USES; - ext->substmts[2].storage = (uint64_t)(uintptr_t)&ext->parsed; + ext->substmts[2].storage_p = (void **)&ext->parsed; if ((ret = lyplg_ext_parse_extension_instance(pctx, ext))) { return ret; @@ -96,15 +96,15 @@ yangdata_compile(struct lysc_ctx *cctx, const struct lysp_ext_instance *extp, st LY_ARRAY_CREATE_GOTO(cctx->ctx, ext->substmts, 3, ret, emem); LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[0].stmt = LY_STMT_CONTAINER; - ext->substmts[0].storage = (uint64_t)(uintptr_t)&ext->compiled; + ext->substmts[0].storage_p = (void **)&ext->compiled; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[1].stmt = LY_STMT_CHOICE; - ext->substmts[1].storage = (uint64_t)(uintptr_t)&ext->compiled; + ext->substmts[1].storage_p = (void **)&ext->compiled; LY_ARRAY_INCREMENT(ext->substmts); ext->substmts[2].stmt = LY_STMT_USES; - ext->substmts[2].storage = (uint64_t)(uintptr_t)&ext->compiled; + ext->substmts[2].storage_p = (void **)&ext->compiled; *lyplg_ext_compile_get_options(cctx) |= LYS_COMPILE_NO_CONFIG | LYS_COMPILE_NO_DISABLED; ret = lyplg_ext_compile_extension_instance(cctx, extp, ext); |