| 3298 | super(MultiFlagsField, self).__init__(name, default, size) |
| 3299 | |
| 3300 | def any2i(self, pkt, x): |
| 3301 | # type: (Optional[Packet], Any) -> Set[str] |
| 3302 | if not isinstance(x, (set, int)): |
| 3303 | raise ValueError('set expected') |
| 3304 | |
| 3305 | if pkt is not None: |
| 3306 | if isinstance(x, int): |
| 3307 | return self.m2i(pkt, x) |
| 3308 | else: |
| 3309 | v = self.depends_on(pkt) |
| 3310 | if v is not None: |
| 3311 | assert v in self.names, 'invalid dependency' |
| 3312 | these_names = self.names[v] |
| 3313 | s = set() |
| 3314 | for i in x: |
| 3315 | for val in these_names.values(): |
| 3316 | if val.short == i: |
| 3317 | s.add(i) |
| 3318 | break |
| 3319 | else: |
| 3320 | assert False, 'Unknown flag "{}" with this dependency'.format(i) # noqa: E501 |
| 3321 | continue |
| 3322 | return s |
| 3323 | if isinstance(x, int): |
| 3324 | return set() |
| 3325 | return x |
| 3326 | |
| 3327 | def i2m(self, pkt, x): |
| 3328 | # type: (Optional[Packet], Optional[Set[str]]) -> int |