+
+ def __iter__(self):
+ # To only yield unique keys, keep a set of member names that are
+ # already yielded. Two root structure fields (for example,
+ # payload and common context) can contain immediate members
+ # which share the same name.
+ member_names = set()
+
+ if self.payload_field is not None:
+ for field_name in self.payload_field:
+ yield field_name
+ member_names.add(field_name)
+
+ if self.specific_context_field is not None:
+ for field_name in self.specific_context_field:
+ if field_name not in member_names:
+ yield field_name
+ member_names.add(field_name)
+
+ if self.common_context_field is not None:
+ for field_name in self.common_context_field:
+ if field_name not in member_names:
+ yield field_name
+ member_names.add(field_name)
+
+ if self.packet and self.packet.context_field is not None:
+ for field_name in self.packet.context_field:
+ if field_name not in member_names:
+ yield field_name
+ member_names.add(field_name)
+
+ def __len__(self):
+ return sum(1 for _ in self)
+
+
+class _Event(_EventConst):
+ _borrow_class_ptr = staticmethod(native_bt.event_borrow_class)
+ _borrow_packet_ptr = staticmethod(native_bt.event_borrow_packet)
+ _borrow_stream_ptr = staticmethod(native_bt.event_borrow_stream)
+ _borrow_common_context_field_ptr = staticmethod(
+ native_bt.event_borrow_common_context_field
+ )
+ _borrow_specific_context_field_ptr = staticmethod(
+ native_bt.event_borrow_specific_context_field
+ )
+ _borrow_payload_field_ptr = staticmethod(native_bt.event_borrow_payload_field)
+ _create_field_from_ptr = staticmethod(bt2_field._create_field_from_ptr)
+
+ _event_class_pycls = property(lambda _: bt2_event_class._EventClass)
+ _packet_pycls = property(lambda _: bt2_packet._Packet)
+ _stream_pycls = property(lambda _: bt2_stream._Stream)