@@ -35,11 +35,6 @@ struct lysp_ext_instance_structure {
3535};
3636
3737struct lysc_ext_instance_structure {
38- struct lysc_must * musts ;
39- uint16_t flags ;
40- const char * dsc ;
41- const char * ref ;
42- struct lysc_node * child ;
4338 struct lysc_node_container * top_cont ;
4439};
4540
@@ -192,23 +187,34 @@ structure_compile(struct lysc_ctx *cctx, const struct lysp_ext_instance *extp, s
192187 }
193188 ext -> compiled = struct_cdata ;
194189
190+ /* add the top-level container with the extension instance name, connect all the other substatements into it */
191+ struct_cdata -> top_cont = calloc (1 , sizeof * struct_cdata -> top_cont );
192+ if (!struct_cdata -> top_cont ) {
193+ goto emem ;
194+ }
195+
196+ struct_cdata -> top_cont -> name = ext -> argument ;
197+ struct_cdata -> top_cont -> nodetype = LYS_CONTAINER ;
198+ struct_cdata -> top_cont -> module = (struct lys_module * )lyplg_ext_compile_get_cur_mod (cctx );
199+ struct_cdata -> top_cont -> prev = & struct_cdata -> top_cont -> node ;
200+
195201 /* compile substatements */
196202 LY_ARRAY_CREATE_GOTO (cctx -> ctx , ext -> substmts , 14 , rc , emem );
197203 LY_ARRAY_INCREMENT (ext -> substmts );
198204 ext -> substmts [0 ].stmt = LY_STMT_MUST ;
199- ext -> substmts [0 ].storage_p = (void * * )& struct_cdata -> musts ;
205+ ext -> substmts [0 ].storage_p = (void * * )& struct_cdata -> top_cont -> musts ;
200206
201207 LY_ARRAY_INCREMENT (ext -> substmts );
202208 ext -> substmts [1 ].stmt = LY_STMT_STATUS ;
203- ext -> substmts [1 ].storage_p = (void * * )& struct_cdata -> flags ;
209+ ext -> substmts [1 ].storage_p = (void * * )& struct_cdata -> top_cont -> flags ;
204210
205211 LY_ARRAY_INCREMENT (ext -> substmts );
206212 ext -> substmts [2 ].stmt = LY_STMT_DESCRIPTION ;
207- ext -> substmts [2 ].storage_p = (void * * )& struct_cdata -> dsc ;
213+ ext -> substmts [2 ].storage_p = (void * * )& struct_cdata -> top_cont -> dsc ;
208214
209215 LY_ARRAY_INCREMENT (ext -> substmts );
210216 ext -> substmts [3 ].stmt = LY_STMT_REFERENCE ;
211- ext -> substmts [3 ].storage_p = (void * * )& struct_cdata -> ref ;
217+ ext -> substmts [3 ].storage_p = (void * * )& struct_cdata -> top_cont -> ref ;
212218
213219 LY_ARRAY_INCREMENT (ext -> substmts );
214220 ext -> substmts [4 ].stmt = LY_STMT_TYPEDEF ;
@@ -221,59 +227,50 @@ structure_compile(struct lysc_ctx *cctx, const struct lysp_ext_instance *extp, s
221227 /* data-def-stmt */
222228 LY_ARRAY_INCREMENT (ext -> substmts );
223229 ext -> substmts [6 ].stmt = LY_STMT_CONTAINER ;
224- ext -> substmts [6 ].storage_p = (void * * )& struct_cdata -> child ;
230+ ext -> substmts [6 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
225231
226232 LY_ARRAY_INCREMENT (ext -> substmts );
227233 ext -> substmts [7 ].stmt = LY_STMT_LEAF ;
228- ext -> substmts [7 ].storage_p = (void * * )& struct_cdata -> child ;
234+ ext -> substmts [7 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
229235
230236 LY_ARRAY_INCREMENT (ext -> substmts );
231237 ext -> substmts [8 ].stmt = LY_STMT_LEAF_LIST ;
232- ext -> substmts [8 ].storage_p = (void * * )& struct_cdata -> child ;
238+ ext -> substmts [8 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
233239
234240 LY_ARRAY_INCREMENT (ext -> substmts );
235241 ext -> substmts [9 ].stmt = LY_STMT_LIST ;
236- ext -> substmts [9 ].storage_p = (void * * )& struct_cdata -> child ;
242+ ext -> substmts [9 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
237243
238244 LY_ARRAY_INCREMENT (ext -> substmts );
239245 ext -> substmts [10 ].stmt = LY_STMT_CHOICE ;
240- ext -> substmts [10 ].storage_p = (void * * )& struct_cdata -> child ;
246+ ext -> substmts [10 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
241247
242248 LY_ARRAY_INCREMENT (ext -> substmts );
243249 ext -> substmts [11 ].stmt = LY_STMT_ANYDATA ;
244- ext -> substmts [11 ].storage_p = (void * * )& struct_cdata -> child ;
250+ ext -> substmts [11 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
245251
246252 LY_ARRAY_INCREMENT (ext -> substmts );
247253 ext -> substmts [12 ].stmt = LY_STMT_ANYXML ;
248- ext -> substmts [12 ].storage_p = (void * * )& struct_cdata -> child ;
254+ ext -> substmts [12 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
249255
250256 LY_ARRAY_INCREMENT (ext -> substmts );
251257 ext -> substmts [13 ].stmt = LY_STMT_USES ;
252- ext -> substmts [13 ].storage_p = (void * * )& struct_cdata -> child ;
258+ ext -> substmts [13 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
253259
254260 * lyplg_ext_compile_get_options (cctx ) |= LYS_COMPILE_NO_CONFIG | LYS_COMPILE_NO_DISABLED ;
255- rc = lyplg_ext_compile_extension_instance (cctx , extp , ext );
261+ rc = lyplg_ext_compile_extension_instance (cctx , extp , ext , ( struct lysc_node * ) struct_cdata -> top_cont );
256262 * lyplg_ext_compile_get_options (cctx ) = prev_options ;
257263 if (rc ) {
258264 return rc ;
259265 }
260266
261- /* add the top-level container with the extension instance name, connect all the other substatements into it */
262- struct_cdata -> top_cont = calloc (1 , sizeof * struct_cdata -> top_cont );
263- if (!struct_cdata -> top_cont ) {
264- goto emem ;
267+ /* compile config properly even though it is ignored */
268+ if (!(struct_cdata -> top_cont -> flags & LYS_CONFIG_MASK )) {
269+ struct_cdata -> top_cont -> flags |= LYS_CONFIG_W ;
265270 }
266271
267- struct_cdata -> top_cont -> name = ext -> argument ;
268- struct_cdata -> top_cont -> nodetype = LYS_CONTAINER ;
269- struct_cdata -> top_cont -> flags = struct_cdata -> flags ;
270- struct_cdata -> top_cont -> module = (struct lys_module * )lyplg_ext_compile_get_cur_mod (cctx );
271- struct_cdata -> top_cont -> prev = & struct_cdata -> top_cont -> node ;
272- struct_cdata -> top_cont -> child = struct_cdata -> child ;
273- LY_LIST_FOR (struct_cdata -> child , child ) {
274- child -> parent = (struct lysc_node * )struct_cdata -> top_cont ;
275- }
276- struct_cdata -> top_cont -> musts = struct_cdata -> musts ;
272+ /* connect any augments */
273+ LY_CHECK_RET (lyplg_ext_compiled_node_augments (cctx , ext , (struct lysc_node * )struct_cdata -> top_cont ));
277274
278275 return LY_SUCCESS ;
279276
@@ -360,37 +357,33 @@ structure_compiled_print(const struct lysc_ext_instance *orig_ext, struct lysc_e
360357 memset (struct_cdata -> top_cont , 0 , sizeof * struct_cdata -> top_cont );
361358
362359 /* substatements */
363- ext -> substmts [0 ].storage_p = (void * * )& struct_cdata -> musts ;
364- ext -> substmts [1 ].storage_p = (void * * )& struct_cdata -> flags ;
365- ext -> substmts [2 ].storage_p = (void * * )& struct_cdata -> dsc ;
366- ext -> substmts [3 ].storage_p = (void * * )& struct_cdata -> ref ;
367-
368- ext -> substmts [6 ].storage_p = (void * * )& struct_cdata -> child ;
369- ext -> substmts [7 ].storage_p = (void * * )& struct_cdata -> child ;
370- ext -> substmts [8 ].storage_p = (void * * )& struct_cdata -> child ;
371- ext -> substmts [9 ].storage_p = (void * * )& struct_cdata -> child ;
372- ext -> substmts [10 ].storage_p = (void * * )& struct_cdata -> child ;
373- ext -> substmts [11 ].storage_p = (void * * )& struct_cdata -> child ;
374- ext -> substmts [12 ].storage_p = (void * * )& struct_cdata -> child ;
375- ext -> substmts [13 ].storage_p = (void * * )& struct_cdata -> child ;
360+ ext -> substmts [0 ].storage_p = (void * * )& struct_cdata -> top_cont -> musts ;
361+ ext -> substmts [1 ].storage_p = (void * * )& struct_cdata -> top_cont -> flags ;
362+ ext -> substmts [2 ].storage_p = (void * * )& struct_cdata -> top_cont -> dsc ;
363+ ext -> substmts [3 ].storage_p = (void * * )& struct_cdata -> top_cont -> ref ;
364+
365+ ext -> substmts [6 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
366+ ext -> substmts [7 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
367+ ext -> substmts [8 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
368+ ext -> substmts [9 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
369+ ext -> substmts [10 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
370+ ext -> substmts [11 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
371+ ext -> substmts [12 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
372+ ext -> substmts [13 ].storage_p = (void * * )& struct_cdata -> top_cont -> child ;
376373
377374 r = lyplg_ext_compiled_stmts_storage_print (orig_ext -> substmts , ext -> substmts , addr_ht , ptr_set , mem );
378375 if (r ) {
379376 return r ;
380377 }
381378
382- /* top_cont substatements that are now in addr_ht (except for musts which are not shared normally) */
379+ /* top_cont substatements that are now in addr_ht */
383380 struct_cdata -> top_cont -> name = lyplg_ext_compiled_print_get_addr (addr_ht , orig_cdata -> top_cont -> name );
384381 assert (struct_cdata -> top_cont -> name );
385382 struct_cdata -> top_cont -> nodetype = orig_cdata -> top_cont -> nodetype ;
386- struct_cdata -> top_cont -> flags = orig_cdata -> top_cont -> flags ;
387383 struct_cdata -> top_cont -> module = lyplg_ext_compiled_print_get_addr (addr_ht , orig_cdata -> top_cont -> module );
388384 assert (struct_cdata -> top_cont -> module );
389385 struct_cdata -> top_cont -> prev = lyplg_ext_compiled_print_get_addr (addr_ht , orig_cdata -> top_cont -> prev );
390386 assert (struct_cdata -> top_cont -> prev );
391- struct_cdata -> top_cont -> child = lyplg_ext_compiled_print_get_addr (addr_ht , orig_cdata -> top_cont -> child );
392- assert (struct_cdata -> top_cont -> child );
393- struct_cdata -> top_cont -> musts = struct_cdata -> musts ;
394387
395388 return LY_SUCCESS ;
396389}
@@ -602,7 +595,7 @@ structure_snode(struct lysc_ext_instance *ext, const struct lyd_node *parent, co
602595
603596 if (in_xpath ) {
604597 /* XPath starts at the substatements */
605- * snode = struct_cdata -> child ;
598+ * snode = struct_cdata -> top_cont -> child ;
606599 } else {
607600 /* data tree start at the top-level virtual container */
608601 * snode = & struct_cdata -> top_cont -> node ;
0 commit comments