1 # SPDX-License-Identifier: MIT
3 # Copyright (c) 2016-2017 Philippe Proulx <pproulx@efficios.com>
5 from bt2
import native_bt
, object
6 from bt2
import field
as bt2_field
10 from bt2
import stream
as bt2_stream
15 class _PacketConst(object._SharedObject
):
16 _get_ref
= staticmethod(native_bt
.packet_get_ref
)
17 _put_ref
= staticmethod(native_bt
.packet_put_ref
)
18 _borrow_stream_ptr
= staticmethod(native_bt
.packet_borrow_stream_const
)
19 _borrow_context_field_ptr
= staticmethod(
20 native_bt
.packet_borrow_context_field_const
22 _stream_pycls
= property(lambda _
: _bt2_stream()._StreamConst
)
23 _create_field_from_ptr
= staticmethod(bt2_field
._create
_field
_from
_const
_ptr
)
27 stream_ptr
= self
._borrow
_stream
_ptr
(self
._ptr
)
28 assert stream_ptr
is not None
29 return self
._stream
_pycls
._create
_from
_ptr
_and
_get
_ref
(stream_ptr
)
32 def context_field(self
):
33 field_ptr
= self
._borrow
_context
_field
_ptr
(self
._ptr
)
38 return self
._create
_field
_from
_ptr
(
39 field_ptr
, self
._ptr
, self
._get
_ref
, self
._put
_ref
43 class _Packet(_PacketConst
):
44 _borrow_stream_ptr
= staticmethod(native_bt
.packet_borrow_stream
)
45 _borrow_context_field_ptr
= staticmethod(native_bt
.packet_borrow_context_field
)
46 _stream_pycls
= property(lambda _
: _bt2_stream()._Stream
)
47 _create_field_from_ptr
= staticmethod(bt2_field
._create
_field
_from
_ptr
)