X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fmessage.py;h=a2e885b8208bdd8dfc994d5359bbe7bc5f83cf07;hb=26fc5aedf;hp=56b545daa98faf1c0220f424b5e2dd8f6cec7aec;hpb=578e048b5debf169e286e5b5cc747b5d6c16886d;p=babeltrace.git diff --git a/src/bindings/python/bt2/bt2/message.py b/src/bindings/python/bt2/bt2/message.py index 56b545da..a2e885b8 100644 --- a/src/bindings/python/bt2/bt2/message.py +++ b/src/bindings/python/bt2/bt2/message.py @@ -60,7 +60,7 @@ class _EventMessage(_Message, _MessageWithDefaultClockSnapshot): @property def default_clock_snapshot(self): - self._check_has_default_clock_class(self.event.packet.stream.cls.default_clock_class) + self._check_has_default_clock_class(self.event.stream.cls.default_clock_class) return self._get_default_clock_snapshot(self._borrow_default_clock_snapshot_ptr) @property @@ -94,64 +94,42 @@ class _PacketEndMessage(_PacketMessage): _borrow_default_clock_snapshot_ptr = staticmethod(native_bt.message_packet_end_borrow_default_clock_snapshot_const) -class _StreamMessage(_Message): +class _StreamMessage(_Message, _MessageWithDefaultClockSnapshot): @property def stream(self): stream_ptr = self._borrow_stream_ptr(self._ptr) assert stream_ptr return bt2.stream._Stream._create_from_ptr_and_get_ref(stream_ptr) - -class _StreamBeginningMessage(_StreamMessage): - _borrow_stream_ptr = staticmethod(native_bt.message_stream_beginning_borrow_stream) - - -class _StreamEndMessage(_StreamMessage): - _borrow_stream_ptr = staticmethod(native_bt.message_stream_end_borrow_stream) - - -class _StreamActivityMessage(_Message): @property def default_clock_snapshot(self): self._check_has_default_clock_class(self.stream.cls.default_clock_class) - status, snapshot_ptr = self._borrow_default_clock_snapshot_ptr(self._ptr) - if status == native_bt.MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN: - snapshot_type = bt2.clock_snapshot._ClockSnapshot - elif status == native_bt.MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_UNKNOWN: - snapshot_type = bt2.clock_snapshot._UnknownClockSnapshot - elif status == native_bt.MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_INFINITE: - snapshot_type = bt2.clock_snapshot._InfiniteClockSnapshot - else: - raise bt2.Error('cannot borrow default clock snapshot from message') + status, snapshot_ptr = self._borrow_default_clock_snapshot_ptr(self._ptr) - assert snapshot_ptr is not None + if status == native_bt.MESSAGE_STREAM_CLOCK_SNAPSHOT_STATE_UNKNOWN: + return bt2.clock_snapshot._UnknownClockSnapshot() - return snapshot_type._create_from_ptr_and_get_ref( + return bt2.clock_snapshot._ClockSnapshot._create_from_ptr_and_get_ref( snapshot_ptr, self._ptr, self._get_ref, self._put_ref) - def _default_clock_snapshot(self, value): - self._set_default_clock_snapshot_ptr(self._ptr, value) + def _default_clock_snapshot(self, raw_value): + utils._check_uint64(raw_value) + self._set_default_clock_snapshot(self._ptr, raw_value) _default_clock_snapshot = property(fset=_default_clock_snapshot) - @property - def stream(self): - stream_ptr = self._borrow_stream_ptr(self._ptr) - assert stream_ptr - return bt2.stream._Stream._create_from_ptr_and_get_ref(stream_ptr) - -class _StreamActivityBeginningMessage(_StreamActivityMessage): - _borrow_default_clock_snapshot_ptr = staticmethod(native_bt.message_stream_activity_beginning_borrow_default_clock_snapshot_const) - _set_default_clock_snapshot_ptr = staticmethod(native_bt.message_stream_activity_beginning_set_default_clock_snapshot) - _borrow_stream_ptr = staticmethod(native_bt.message_stream_activity_beginning_borrow_stream) +class _StreamBeginningMessage(_StreamMessage): + _borrow_stream_ptr = staticmethod(native_bt.message_stream_beginning_borrow_stream) + _borrow_default_clock_snapshot_ptr = staticmethod(native_bt.message_stream_beginning_borrow_default_clock_snapshot_const) + _set_default_clock_snapshot = staticmethod(native_bt.message_stream_beginning_set_default_clock_snapshot) -class _StreamActivityEndMessage(_StreamActivityMessage): - _borrow_default_clock_snapshot_ptr = staticmethod(native_bt.message_stream_activity_end_borrow_default_clock_snapshot_const) - _set_default_clock_snapshot_ptr = staticmethod(native_bt.message_stream_activity_end_set_default_clock_snapshot) - _borrow_stream_ptr = staticmethod(native_bt.message_stream_activity_end_borrow_stream) +class _StreamEndMessage(_StreamMessage): + _borrow_stream_ptr = staticmethod(native_bt.message_stream_end_borrow_stream) + _borrow_default_clock_snapshot_ptr = staticmethod(native_bt.message_stream_end_borrow_default_clock_snapshot_const) + _set_default_clock_snapshot = staticmethod(native_bt.message_stream_end_set_default_clock_snapshot) class _MessageIteratorInactivityMessage(_Message, _MessageWithDefaultClockSnapshot): @@ -229,8 +207,6 @@ _MESSAGE_TYPE_TO_CLS = { native_bt.MESSAGE_TYPE_STREAM_END: _StreamEndMessage, native_bt.MESSAGE_TYPE_PACKET_BEGINNING: _PacketBeginningMessage, native_bt.MESSAGE_TYPE_PACKET_END: _PacketEndMessage, - native_bt.MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING: _StreamActivityBeginningMessage, - native_bt.MESSAGE_TYPE_STREAM_ACTIVITY_END: _StreamActivityEndMessage, native_bt.MESSAGE_TYPE_DISCARDED_EVENTS: _DiscardedEventsMessage, native_bt.MESSAGE_TYPE_DISCARDED_PACKETS: _DiscardedPacketsMessage, }