@@ -26,10 +26,31 @@ const char *simple = "module libyang-plugins-simple {"
2626 " prefix s;"
2727 " typedef note { type string; }"
2828 " extension hint { argument value; }"
29+ " extension rt;"
2930 " leaf test {"
3031 " type s:note {length 255;}"
3132 " s:hint \"some hint here\";"
3233 " }"
34+ " grouping grp1 {"
35+ " list l1 {key v; leaf v {type string;} leaf k {type string;}}"
36+ " list l2 {key v; leaf v {type string;} leaf k {type string;}}"
37+ " typedef t1 {"
38+ " type string;"
39+ " s:rt;"
40+ " }"
41+ " typedef t2 {"
42+ " type string;"
43+ " s:rt;"
44+ " }"
45+ " }"
46+ " uses grp1 {"
47+ " refine l1 {"
48+ " s:rt;"
49+ " }"
50+ " refine l2 {"
51+ " s:rt;"
52+ " }"
53+ " }"
3354 "}" ;
3455
3556static void
@@ -106,6 +127,29 @@ parse_clb(struct lysp_ctx *UNUSED(pctx), struct lysp_ext_instance *ext)
106127 return LY_SUCCESS ;
107128}
108129
130+ static LY_ERR
131+ parse_clb2 (struct lysp_ctx * UNUSED (pctx ), struct lysp_ext_instance * ext )
132+ {
133+ struct lysp_refine * refine ;
134+ struct lysp_tpdf * tpdf ;
135+ LY_ARRAY_COUNT_TYPE count = 0 ;
136+
137+ if (ext -> parent_stmt == LY_STMT_REFINE ) {
138+ refine = (struct lysp_refine * )ext -> parent ;
139+ count = LY_ARRAY_COUNT (refine -> exts );
140+ } else if (ext -> parent_stmt == LY_STMT_TYPEDEF ) {
141+ tpdf = (struct lysp_tpdf * )ext -> parent ;
142+ count = LY_ARRAY_COUNT (tpdf -> exts );
143+ } else {
144+ return LY_SUCCESS ;
145+ }
146+
147+ if (count != 1 ) {
148+ return LY_EINVAL ;
149+ }
150+ return LY_SUCCESS ;
151+ }
152+
109153struct lyplg_ext_record memory_recs [] = {
110154 {
111155 .module = "libyang-plugins-simple" ,
@@ -124,6 +168,23 @@ struct lyplg_ext_record memory_recs[] = {
124168 .plugin .pfree = NULL ,
125169 .plugin .cfree = NULL
126170 },
171+ {
172+ .module = "libyang-plugins-simple" ,
173+ .revision = NULL ,
174+ .name = "rt" ,
175+
176+ .plugin .id = "memory-plugin-v1" ,
177+ .plugin .parse = parse_clb2 ,
178+ .plugin .compile = NULL ,
179+ .plugin .printer_info = NULL ,
180+ .plugin .printer_ctree = NULL ,
181+ .plugin .printer_ptree = NULL ,
182+ .plugin .node_xpath = NULL ,
183+ .plugin .snode = NULL ,
184+ .plugin .validate = NULL ,
185+ .plugin .pfree = NULL ,
186+ .plugin .cfree = NULL
187+ },
127188 {0 } /* terminating zeroed item */
128189};
129190
0 commit comments