From 2550c437c68a18aa8306f60f6fac142aca900b27 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 11 Sep 2019 11:35:50 -0400 Subject: [PATCH] bt2: template borrow_user_attributes method in _TraceClassConst, _StreamClassConst and _ClockClassConst Change-Id: I74fc9a490278930f980ed8994b98fd7af37c959b Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/2029 CI-Build: Francis Deslauriers Tested-by: jenkins Reviewed-by: Francis Deslauriers --- src/bindings/python/bt2/bt2/clock_class.py | 8 +++++++- src/bindings/python/bt2/bt2/stream_class.py | 9 ++++++++- src/bindings/python/bt2/bt2/trace_class.py | 8 +++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/bindings/python/bt2/bt2/clock_class.py b/src/bindings/python/bt2/bt2/clock_class.py index 3e5297bc..71827b88 100644 --- a/src/bindings/python/bt2/bt2/clock_class.py +++ b/src/bindings/python/bt2/bt2/clock_class.py @@ -54,10 +54,13 @@ class _ClockClassConst(object._SharedObject): _create_value_from_ptr_and_get_ref = staticmethod( bt2_value._create_from_const_ptr_and_get_ref ) + _borrow_user_attributes_ptr = staticmethod( + native_bt.clock_class_borrow_user_attributes_const + ) @property def user_attributes(self): - ptr = native_bt.clock_class_borrow_user_attributes(self._ptr) + ptr = self._borrow_user_attributes_ptr(self._ptr) assert ptr is not None return self._create_value_from_ptr_and_get_ref(ptr) @@ -108,6 +111,9 @@ class _ClockClass(_ClockClassConst): _create_value_from_ptr_and_get_ref = staticmethod( bt2_value._create_from_ptr_and_get_ref ) + _borrow_user_attributes_ptr = staticmethod( + native_bt.clock_class_borrow_user_attributes + ) def _user_attributes(self, user_attributes): value = bt2_value.create_value(user_attributes) diff --git a/src/bindings/python/bt2/bt2/stream_class.py b/src/bindings/python/bt2/bt2/stream_class.py index 8a65fac7..609fe3b2 100644 --- a/src/bindings/python/bt2/bt2/stream_class.py +++ b/src/bindings/python/bt2/bt2/stream_class.py @@ -50,6 +50,9 @@ class _StreamClassConst(object._SharedObject, collections.abc.Mapping): _borrow_default_clock_class_ptr = staticmethod( native_bt.stream_class_borrow_default_clock_class_const ) + _borrow_user_attributes_ptr = staticmethod( + native_bt.stream_class_borrow_user_attributes_const + ) _event_class_cls = property(lambda _: bt2_event_class._EventClassConst) _trace_class_cls = property(lambda _: bt2_trace_class._TraceClassConst) @@ -88,7 +91,7 @@ class _StreamClassConst(object._SharedObject, collections.abc.Mapping): @property def user_attributes(self): - ptr = native_bt.stream_class_borrow_user_attributes(self._ptr) + ptr = self._borrow_user_attributes_ptr(self._ptr) assert ptr is not None return bt2_value._create_from_ptr_and_get_ref(ptr) @@ -193,6 +196,10 @@ class _StreamClass(_StreamClassConst): _borrow_default_clock_class_ptr = staticmethod( native_bt.stream_class_borrow_default_clock_class ) + _borrow_user_attributes_ptr = staticmethod( + native_bt.stream_class_borrow_user_attributes + ) + _event_class_cls = property(lambda s: bt2_event_class._EventClass) _trace_class_cls = property(lambda s: bt2_trace_class._TraceClass) _clock_class_cls = property(lambda s: bt2_clock_class._ClockClass) diff --git a/src/bindings/python/bt2/bt2/trace_class.py b/src/bindings/python/bt2/bt2/trace_class.py index 94343552..e3162915 100644 --- a/src/bindings/python/bt2/bt2/trace_class.py +++ b/src/bindings/python/bt2/bt2/trace_class.py @@ -47,6 +47,9 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping): _borrow_stream_class_ptr_by_id = staticmethod( native_bt.trace_class_borrow_stream_class_by_id_const ) + _borrow_user_attributes_ptr = staticmethod( + native_bt.trace_class_borrow_user_attributes_const + ) _stream_class_pycls = bt2_stream_class._StreamClassConst _create_value_from_ptr_and_get_ref = staticmethod( bt2_value._create_from_const_ptr_and_get_ref @@ -54,7 +57,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping): @property def user_attributes(self): - ptr = native_bt.trace_class_borrow_user_attributes(self._ptr) + ptr = self._borrow_user_attributes_ptr(self._ptr) assert ptr is not None return self._create_value_from_ptr_and_get_ref(ptr) @@ -117,6 +120,9 @@ class _TraceClass(_TraceClassConst): _borrow_stream_class_ptr_by_id = staticmethod( native_bt.trace_class_borrow_stream_class_by_id ) + _borrow_user_attributes_ptr = staticmethod( + native_bt.trace_class_borrow_user_attributes + ) _stream_class_pycls = bt2_stream_class._StreamClass _create_value_from_ptr_and_get_ref = staticmethod( bt2_value._create_from_ptr_and_get_ref -- 2.34.1