@@ -688,7 +688,10 @@ def _complex_member_type(self, ri):
688
688
raise Exception (f"Sub-type { self .attr ['sub-type' ]} not supported yet" )
689
689
690
690
def _attr_typol (self ):
691
- return f'.type = YNL_PT_NEST, .nest = &{ self .nested_render_name } _nest, '
691
+ if self .attr ['sub-type' ] in scalars :
692
+ return f'.type = YNL_PT_U{ c_upper (self .sub_type [1 :])} , '
693
+ else :
694
+ return f'.type = YNL_PT_NEST, .nest = &{ self .nested_render_name } _nest, '
692
695
693
696
def _attr_get (self , ri , var ):
694
697
local_vars = ['const struct nlattr *attr2;' ]
@@ -890,7 +893,7 @@ def new_attr(self, elem, value):
890
893
elif elem ['type' ] == 'nest' :
891
894
t = TypeNest (self .family , self , elem , value )
892
895
elif elem ['type' ] == 'indexed-array' and 'sub-type' in elem :
893
- if elem ["sub-type" ] == 'nest' :
896
+ if elem ["sub-type" ] in [ 'nest' , 'u32' ] :
894
897
t = TypeArrayNest (self .family , self , elem , value )
895
898
else :
896
899
raise Exception (f'new_attr: unsupported sub-type { elem ["sub-type" ]} ' )
@@ -1674,6 +1677,9 @@ def _multi_parse(ri, struct, init_lines, local_vars):
1674
1677
if aspec ["sub-type" ] == 'nest' :
1675
1678
local_vars .append (f'const struct nlattr *attr_{ aspec .c_name } ;' )
1676
1679
array_nests .add (arg )
1680
+ elif aspec ['sub-type' ] in scalars :
1681
+ local_vars .append (f'const struct nlattr *attr_{ aspec .c_name } ;' )
1682
+ array_nests .add (arg )
1677
1683
else :
1678
1684
raise Exception (f'Not supported sub-type { aspec ["sub-type" ]} ' )
1679
1685
if 'multi-attr' in aspec :
@@ -1729,11 +1735,17 @@ def _multi_parse(ri, struct, init_lines, local_vars):
1729
1735
ri .cw .p (f"dst->{ aspec .c_name } = calloc(n_{ aspec .c_name } , sizeof(*dst->{ aspec .c_name } ));" )
1730
1736
ri .cw .p (f"dst->n_{ aspec .c_name } = n_{ aspec .c_name } ;" )
1731
1737
ri .cw .p ('i = 0;' )
1732
- ri .cw .p (f"parg.rsp_policy = &{ aspec .nested_render_name } _nest;" )
1738
+ if 'nested-attributes' in aspec :
1739
+ ri .cw .p (f"parg.rsp_policy = &{ aspec .nested_render_name } _nest;" )
1733
1740
ri .cw .block_start (line = f"ynl_attr_for_each_nested(attr, attr_{ aspec .c_name } )" )
1734
- ri .cw .p (f"parg.data = &dst->{ aspec .c_name } [i];" )
1735
- ri .cw .p (f"if ({ aspec .nested_render_name } _parse(&parg, attr, ynl_attr_type(attr)))" )
1736
- ri .cw .p ('return YNL_PARSE_CB_ERROR;' )
1741
+ if 'nested-attributes' in aspec :
1742
+ ri .cw .p (f"parg.data = &dst->{ aspec .c_name } [i];" )
1743
+ ri .cw .p (f"if ({ aspec .nested_render_name } _parse(&parg, attr, ynl_attr_type(attr)))" )
1744
+ ri .cw .p ('return YNL_PARSE_CB_ERROR;' )
1745
+ elif aspec .sub_type in scalars :
1746
+ ri .cw .p (f"dst->{ aspec .c_name } [i] = ynl_attr_get_{ aspec .sub_type } (attr);" )
1747
+ else :
1748
+ raise Exception (f"Nest parsing type not supported in { aspec ['name' ]} " )
1737
1749
ri .cw .p ('i++;' )
1738
1750
ri .cw .block_end ()
1739
1751
ri .cw .block_end ()
0 commit comments