YANG deviation: Resolve deviated types lexically in deviation context

This commit is contained in:
Olof hagsand 2024-08-16 13:32:00 +02:00
parent 1709537701
commit b1a4656f72
4 changed files with 84 additions and 6 deletions

View file

@ -2416,6 +2416,14 @@ yang_deviation(yang_stmt *ys,
/* Make a copy of deviate child and insert. */
if ((yc1 = ys_dup(yc)) == NULL)
goto done;
/* Special case: resolve types in temporary old deviation context */
if (yn_insert(yd, yc1) < 0)
goto done;
if (yang_apply(yc1, Y_TYPE, ys_resolve_type, -1, h) < 0)
goto done;
if (ys_prune_self(yc1) < 0)
goto done;
/* Mark all as refined */
if (yang_apply(yc1, -1, (yang_applyfn_t*)yang_flag_set, -1, (void*)YANG_FLAG_REFINE) < 0)
goto done;
if (yn_insert(ytarget, yc1) < 0)
@ -2451,6 +2459,14 @@ yang_deviation(yang_stmt *ys,
/* Make a copy of deviate child and insert. */
if ((yc1 = ys_dup(yc)) == NULL)
goto done;
/* Special case: resolve types in temporary old deviation context */
if (yn_insert(yd, yc1) < 0)
goto done;
if (yang_apply(yc1, Y_TYPE, ys_resolve_type, -1, h) < 0)
goto done;
if (ys_prune_self(yc1) < 0)
goto done;
/* Mark all as refined */
if (yang_apply(yc1, -1, (yang_applyfn_t*)yang_flag_set, -1, (void*)YANG_FLAG_REFINE) < 0)
goto done;
if (yn_insert(ytarget, yc1) < 0)

View file

@ -256,11 +256,16 @@ ys_resolve_type(yang_stmt *ytype,
uint8_t fraction = 0;
yang_stmt *resolved = NULL;
cvec *regexps = NULL;
yang_stmt *yp;
if (yang_keyword_get(ytype) != Y_TYPE){
clixon_err(OE_YANG, EINVAL, "Expected Y_TYPE");
goto done;
}
if ((yp = yang_parent_get(ytype)) == NULL){
clixon_err(OE_YANG, EINVAL, "ytype has no parent");
goto done;
}
if ((patterns = cvec_new(0)) == NULL){
clixon_err(OE_UNIX, errno, "cvec_new");
goto done;
@ -268,8 +273,7 @@ ys_resolve_type(yang_stmt *ytype,
/* Recursively resolve ytype -> resolve with restrictions(options, etc)
* Note that the resolved type could be ytype itself.
*/
if (yang_type_resolve(yang_parent_get(ytype), yang_parent_get(ytype),
ytype, &resolved,
if (yang_type_resolve(yp, yp, ytype, &resolved,
&options, &cvv, patterns, NULL, &fraction) < 0){
goto done;
}