Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using type/extension plugins within printed context #2340

Open
wants to merge 17 commits into
base: so4
Choose a base branch
from

Conversation

Roytak
Copy link

@Roytak Roytak commented Jan 22, 2025

Numerous other smaller changes included, including widening ctx opts from 16 to 32-bits and adding a new flag for ly_ctx_new.

if (!record) {
/* try to find shared plugin */
record = lyplg_record_find(NULL, LYPLG_EXTENSION, module, revision, name);
if (!strncmp(record->plugin.id, "ly2 - ", 6)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a good check, learn this rather by comparing the index with the number of internal plugins, they are always loaded first and their number is a compile-time variable.

@@ -405,7 +405,7 @@ struct lysp_ext_instance {
const char *argument; /**< optional value of the extension's argument */
LY_VALUE_FORMAT format; /**< prefix format of the extension name/argument (::LY_VALUE_XML is YIN format) */
void *prefix_data; /**< format-specific data for prefix resolution (see ly_resolve_prefix()) */
struct lyplg_ext *plugin; /**< pointer to the extension plugin, if any */
uintptr_t plugin; /**< extension plugin, use ::lysc_get_ext_plugin() */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> use ::lysc_get_ext_plugin() to get the plugin

ctxp_set(&orig_ctx->modules, &ctx->modules, mem);
for (i = 0; i < ctx->modules.count; ++i) {
/* build the address ht */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better allocate the shared module and store its new address in HT so it can be referenced.


assert(term->value.realtype && term->value.realtype->plugin && term->value.realtype->plugin->print &&
term->schema);
assert(term->value.realtype && (type = lysc_get_type_plugin(term->value.realtype->plugin)) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert is not executed at all in Release build!

@@ -356,6 +356,7 @@ yprc_extension_instances(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t
{
LY_ARRAY_COUNT_TYPE u;
ly_bool inner_flag;
struct lyplg_ext *ext;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to ext_plg at least.

@@ -933,7 +933,7 @@ struct utest_context {
* @param[in] CANNONICAL_VAL expected cannonical value
*/
#define CHECK_LYD_VALUE_EMPTY(NODE, CANNONICAL_VAL) \
assert_non_null((NODE).realtype->plugin->print(UTEST_LYCTX, &(NODE), LY_VALUE_CANON, NULL, NULL, NULL)); \
assert_non_null(lysc_get_type_plugin((NODE).realtype->plugin)->print(UTEST_LYCTX, &(NODE), LY_VALUE_CANON, NULL, NULL, NULL)); \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The canonical value can be retrieved simply by calling lyd_get_value() on NODE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants