yang resolve union
This commit is contained in:
parent
fd2a5db31b
commit
0c065dc026
4 changed files with 171 additions and 91 deletions
|
|
@ -1533,17 +1533,26 @@ yang_parse(clicon_handle h,
|
|||
/* Add top module name as dbspec-name */
|
||||
clicon_dbspec_name_set(h, ymod->ys_argument);
|
||||
|
||||
/* Resolve all types */
|
||||
/* Step 2: Go through parse tree and populate it with cv types */
|
||||
if (yang_apply((yang_node*)ysp, -1, ys_populate, NULL) < 0)
|
||||
goto done;
|
||||
|
||||
/* Step 3: Resolve all types: populate type caches. Requires eg length/range cvecs
|
||||
* from ys_populate step
|
||||
*/
|
||||
yang_apply((yang_node*)ysp, Y_TYPE, ys_resolve_type, NULL);
|
||||
|
||||
/* Step 2: Macro expansion of all grouping/uses pairs. Expansion needs marking */
|
||||
/* Up to here resolving is made in the context they are defined, rather than the
|
||||
context they are used. Like static scoping. After this we expand all
|
||||
grouping/uses and unfold all macros into a single tree as they are used.
|
||||
*/
|
||||
|
||||
/* Step 4: Macro expansion of all grouping/uses pairs. Expansion needs marking */
|
||||
if (yang_expand((yang_node*)ysp) < 0)
|
||||
goto done;
|
||||
yang_apply((yang_node*)ymod, -1, ys_flag_reset, (void*)YANG_FLAG_MARK);
|
||||
|
||||
/* Step 3: Go through parse tree and populate it with cv types */
|
||||
if (yang_apply((yang_node*)ysp, -1, ys_populate, NULL) < 0)
|
||||
goto done;
|
||||
|
||||
|
||||
/* Step 4: Top-level augmentation of all modules */
|
||||
if (yang_augment_spec(ysp) < 0)
|
||||
|
|
|
|||
|
|
@ -205,7 +205,11 @@ yang_type_cache_free(yang_type_cache *ycache)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*! Resolve types: populate type caches */
|
||||
/*! Resolve types: populate type caches
|
||||
* @param[in] ys This is a type statement
|
||||
* @param[in] arg Not used
|
||||
* Typically only called once when loading te yang type system.
|
||||
*/
|
||||
int
|
||||
ys_resolve_type(yang_stmt *ys,
|
||||
void *arg)
|
||||
|
|
@ -218,6 +222,7 @@ ys_resolve_type(yang_stmt *ys,
|
|||
uint8_t fraction = 0;
|
||||
yang_stmt *resolved = NULL;
|
||||
|
||||
assert(ys->ys_keyword == Y_TYPE);
|
||||
if (yang_type_resolve((yang_stmt*)ys->ys_parent, ys, &resolved,
|
||||
&options, &mincv, &maxcv, &pattern, &fraction) < 0)
|
||||
goto done;
|
||||
|
|
@ -327,9 +332,10 @@ cv2yang_type(enum cv_type cv_type)
|
|||
* handle case where yang resolve did not succedd (rtype=NULL) and then try
|
||||
* to find special cligen types such as ipv4addr.
|
||||
* not true yang types
|
||||
* @param[in] origtype
|
||||
* @param[in] restype
|
||||
* @param[out] cvtype
|
||||
* @param[in] origtype Name of original type
|
||||
* @param[in] restype Resolved type. may be null, in that case origtype is used
|
||||
* @param[out] cvtype Translation from resolved type
|
||||
* @note Thereis a kludge for handling direct translations of native cligen types
|
||||
*/
|
||||
int
|
||||
clicon_type2cv(char *origtype,
|
||||
|
|
@ -854,7 +860,7 @@ resolve_restrictions(yang_stmt *yrange,
|
|||
/*! Recursively resolve a yang type to built-in type with optional restrictions
|
||||
* @param [in] ys yang-stmt from where the current search is based
|
||||
* @param [in] ytype yang-stmt object containing currently resolving type
|
||||
* @param [out] yrestype resolved type. return built-in type or NULL. mandatory
|
||||
* @param [out] yrestype resolved type. return built-in type or NULL. mandatory
|
||||
* @param [out] options pointer to flags field of optional values. optional
|
||||
* @param [out] mincv pointer to cv with min range or length. If options&YANG_OPTIONS_RANGE
|
||||
* @param [out] maxcv pointer to cv with max range or length. If options&YANG_OPTIONS_RANGE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue