Lines Matching refs:attr_spec

781     def _encode_enum(self, attr_spec, value):  argument
782 enum = self.consts[attr_spec['enum']]
783 if enum.type == 'flags' or attr_spec.get('enum-as-flags', False):
792 def _get_scalar(self, attr_spec, value): argument
796 if 'enum' in attr_spec:
797 return self._encode_enum(attr_spec, value)
798 if attr_spec.display_hint:
799 return self._from_string(value, attr_spec)
910 def _decode_enum(self, raw, attr_spec): argument
911 enum = self.consts[attr_spec['enum']]
912 if enum.type == 'flags' or attr_spec.get('enum-as-flags', False):
924 def _decode_binary(self, attr, attr_spec): argument
925 if attr_spec.struct_name:
926 decoded = self._decode_struct(attr.raw, attr_spec.struct_name)
927 elif attr_spec.sub_type:
928 decoded = attr.as_c_array(attr_spec.sub_type)
929 if 'enum' in attr_spec:
930 decoded = [ self._decode_enum(x, attr_spec) for x in decoded ]
931 elif attr_spec.display_hint:
932 decoded = [ self._formatted_string(x, attr_spec.display_hint)
936 if attr_spec.display_hint:
937 decoded = self._formatted_string(decoded, attr_spec.display_hint)
940 def _decode_array_attr(self, attr, attr_spec): argument
947 if attr_spec["sub-type"] == 'nest':
948 subattrs = self._decode(NlAttrs(item.raw), attr_spec['nested-attributes'])
950 elif attr_spec["sub-type"] == 'binary':
952 if attr_spec.display_hint:
953 subattr = self._formatted_string(subattr, attr_spec.display_hint)
955 elif attr_spec["sub-type"] in NlAttr.type_formats:
956 subattr = item.as_scalar(attr_spec['sub-type'], attr_spec.byte_order)
957 if 'enum' in attr_spec:
958 subattr = self._decode_enum(subattr, attr_spec)
959 elif attr_spec.display_hint:
960 subattr = self._formatted_string(subattr, attr_spec.display_hint)
966 def _decode_nest_type_value(self, attr, attr_spec): argument
969 for name in attr_spec['type-value']:
972 subattrs = self._decode(NlAttrs(value.raw), attr_spec['nested-attributes'])
996 def _resolve_selector(self, attr_spec, search_attrs): argument
997 sub_msg = attr_spec.sub_message
1002 selector = attr_spec.selector
1010 def _decode_sub_msg(self, attr, attr_spec, search_attrs): argument
1011 msg_format, _ = self._resolve_selector(attr_spec, search_attrs)
1036 attr_spec = attr_space.attrs_by_val[attr.type]
1046 if attr_spec["type"] == 'pad':
1048 elif attr_spec["type"] == 'nest':
1050 attr_spec['nested-attributes'],
1053 elif attr_spec["type"] == 'string':
1055 elif attr_spec["type"] == 'binary':
1056 decoded = self._decode_binary(attr, attr_spec)
1057 elif attr_spec["type"] == 'flag':
1059 elif attr_spec.is_auto_scalar:
1060 decoded = attr.as_auto_scalar(attr_spec['type'], attr_spec.byte_order)
1061 if 'enum' in attr_spec:
1062 decoded = self._decode_enum(decoded, attr_spec)
1063 elif attr_spec["type"] in NlAttr.type_formats:
1064 decoded = attr.as_scalar(attr_spec['type'], attr_spec.byte_order)
1065 if 'enum' in attr_spec:
1066 decoded = self._decode_enum(decoded, attr_spec)
1067 elif attr_spec.display_hint:
1068 decoded = self._formatted_string(decoded, attr_spec.display_hint)
1069 elif attr_spec["type"] == 'indexed-array':
1070 decoded = self._decode_array_attr(attr, attr_spec)
1071 elif attr_spec["type"] == 'bitfield32':
1073 if 'enum' in attr_spec:
1074 value = self._decode_enum(value, attr_spec)
1075 selector = self._decode_enum(selector, attr_spec)
1077 elif attr_spec["type"] == 'sub-message':
1078 decoded = self._decode_sub_msg(attr, attr_spec, search_attrs)
1079 elif attr_spec["type"] == 'nest-type-value':
1080 decoded = self._decode_nest_type_value(attr, attr_spec)
1087 self._rsp_add(rsp, attr_spec["name"], attr_spec.is_multi, decoded)
1098 attr_spec = attr_set.attrs_by_val[attr.type]
1105 return '.' + attr_spec.name
1111 pathname = attr_spec.name
1112 if attr_spec['type'] == 'nest':
1113 sub_attrs = self.attr_sets[attr_spec['nested-attributes']]
1114 search_attrs = SpaceAttrs(sub_attrs, search_attrs.lookup(attr_spec['name']))
1115 elif attr_spec['type'] == 'sub-message':
1116 msg_format, value = self._resolve_selector(attr_spec, search_attrs)
1231 def _from_string(self, string, attr_spec): argument
1232 if attr_spec.display_hint in ['ipv4', 'ipv6', 'ipv4-or-v6']:
1234 if attr_spec['type'] == 'binary':
1238 elif attr_spec.display_hint == 'hex':
1239 if attr_spec['type'] == 'binary':
1243 elif attr_spec.display_hint == 'mac':