bt2: update object model
This patch updates the Babeltrace Python object model (what all
Babeltrace Python objects inherit from) to match the current status of
the API.
We have both Shared and Unique objects. Both types have a _ptr
member, a SWIG Python object wrapping a typed pointer (e.g. pointer to
struct bt_value).
A Shared object type is defined by inheriting from _SharedObject. It
wraps and owns a reference to a Babeltrace object that is reference
counted. The reference count is dropped when the Python object gets
deleted. The _SharedObject base class defines two class methods,
_get_ref and _put_ref, which must be implemented by subclasses. These
implementations must respectively get and put a reference of the
specialized pointer (_ptr) they wrap.
A Unique object type is defined by inheriting from _UniqueObject. It is
not refcounted. Rather, it is wholly owned by another object (the
owner) that is itself refcounted. A Unique object, in the Babeltrace
API, is destroyed when its parent is destroyed. There is therefore a
risk that someone would keep a (Python) reference to a unique object
that got destroyed, because its parent got destroyed, resulting in some
use-after-free bug. To avoid this, we make it so that when a Python
object representing a Babeltrace Unique object is created, that Python
object obtains a reference on the owner Shared object. When the Unique
Python object is destroyed, the reference on the Shared parent is
dropped.
The concepts of Freezable and Private objects don't exist anymore, so
they are removed. I have also removed the _PrivateConnection class,
since it won't be needed in the end and inherited from _PrivateObject.
For other classes representing Babeltrace concepts, I have made them
inherit the object type they'll need to inherit in the end (when all the
Python bindings will be fixed), even though none of these classes is
functional at the moment.
Change-Id: I9ab743dd7a28407913945648c1d74c467550df14
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1021
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
22 files changed:
This page took 0.027359 seconds and 4 git commands to generate.