-
Notifications
You must be signed in to change notification settings - Fork 296
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
base: so4
Are you sure you want to change the base?
Conversation
if (!record) { | ||
/* try to find shared plugin */ | ||
record = lyplg_record_find(NULL, LYPLG_EXTENSION, module, revision, name); | ||
if (!strncmp(record->plugin.id, "ly2 - ", 6)) { |
There was a problem hiding this comment.
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() */ |
There was a problem hiding this comment.
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 */ |
There was a problem hiding this comment.
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)) && |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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)); \ |
There was a problem hiding this comment.
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
.
Numerous other smaller changes included, including widening ctx opts from 16 to 32-bits and adding a new flag for
ly_ctx_new
.