bt2: add option field class and field support
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 13 Aug 2019 15:58:10 +0000 (11:58 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 4 Sep 2019 15:58:21 +0000 (11:58 -0400)
commit84eba0d9b419444e95b2f560c660ea57bb2142d8
tree7cd06759c37b22213c5bbd2b0a75ed8a16018884
parentc27259b025303a64f2c1ae387bf9e34b95e401bb
bt2: add option field class and field support

This patch adds option field class and field support to the Python
bindings.

You can create an option field class with
_TraceClass.create_option_field_class(). This method requires the
optional field class and also accepts an optional selector field class
(just like the library's equivalent bt_field_class_option_create()
function).

An option field class only has the `field_class` (the optional field
class) and `selector_field_path` (can be `None`) properties.

An option field is similar to a variant field:

* You can use the `has_field` property to set whether or not the option
  field has an optional field.

* You can access the optional field with the `field` property, which
  returns `None` when the option field has no field.

* The __bool__() operator of an option field is the equivalent of the
  `has_field` property.

* You can use the `value` property (write only, like
  `_VariantField.value`) to assign a value to the optional field. This
  property also sets `has_field` to `True` so it's always safe to use.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I90aa9ef2dbcb7422ee25aaeb191a18fd9fa4998b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1902
Tested-by: jenkins <jenkins@lttng.org>
src/bindings/python/bt2/bt2/__init__.py
src/bindings/python/bt2/bt2/field.py
src/bindings/python/bt2/bt2/field_class.py
src/bindings/python/bt2/bt2/field_path.py
src/bindings/python/bt2/bt2/trace_class.py
src/lib/trace-ir/resolve-field-path.c
tests/bindings/python/bt2/test_field.py
tests/bindings/python/bt2/test_field_class.py
tests/bindings/python/bt2/test_package.py
This page took 0.026301 seconds and 4 git commands to generate.