Esempio n. 1
0
    def __getitem__(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        notif_iter_ptr = self._get_func(self._comp._ptr, index)
        utils._handle_ptr(notif_iter_ptr, "cannot get component object's input notification iterator")
        return bt2.notification_iterator._GenericNotificationIterator._create_from_ptr(notif_iter_ptr)
Esempio n. 2
0
    def __next__(self):
        if self._at == len(self._attributes):
            raise StopIteration

        name = native_bt.ctf_event_class_get_attribute_name(self._attributes._event_class_ptr,
                                                            self._at)
        utils._handle_ptr("cannot get event class object's attribute name")
        self._at += 1
        return name
Esempio n. 3
0
    def __getitem__(self, index):
        utils._check_uint64(index)

        if index >= len(self):
            raise IndexError

        cc_ptr = native_bt.plugin_get_component_class(self._ptr, index)
        utils._handle_ptr(cc_ptr, "cannot get plugin object's component class object")
        return bt2.component._create_generic_component_class_from_ptr(cc_ptr)
Esempio n. 4
0
    def __next__(self):
        if self._at == len(self._trace_env):
            raise StopIteration

        trace_ptr = self._trace_env._trace._ptr
        entry_name = native_bt.ctf_trace_get_environment_field_name(trace_ptr,
                                                                    self._at)
        utils._handle_ptr(entry_name, "cannot get trace class object's environment entry name")
        self._at += 1
        return entry_name
Esempio n. 5
0
def _create_from_ptr(ptr):
    # recreate the event class wrapper of this event's class (the
    # identity could be different, but the underlying address should be
    # the same)
    event_class_ptr = native_bt.ctf_event_get_class(ptr)
    utils._handle_ptr(event_class_ptr, "cannot get event object's class")
    event_class = bt2.EventClass._create_from_ptr(event_class_ptr)
    event = _Event._create_from_ptr(ptr)
    event._event_class = event_class
    return event
Esempio n. 6
0
    def field(self, tag_field=None):
        if tag_field is None:
            field_ptr = native_bt.ctf_field_variant_get_current_field(self._ptr)
            utils._handle_ptr(field_ptr, "cannot get variant field object's selected field")
        else:
            utils._check_type(tag_field, _EnumerationField)
            field_ptr = native_bt.ctf_field_variant_get_field(self._ptr, tag_field._ptr)
            utils._handle_ptr(field_ptr, "cannot select variant field object's field")

        return _create_from_ptr(field_ptr)
Esempio n. 7
0
def _create_from_ptr(ptr):
    # recreate the field type wrapper of this field's type (the identity
    # could be different, but the underlying address should be the
    # same)
    field_type_ptr = native_bt.ctf_field_get_type(ptr)
    utils._handle_ptr(field_type_ptr, "cannot get field object's type")
    field_type = bt2.field_types._create_from_ptr(field_type_ptr)
    typeid = native_bt.ctf_field_type_get_type_id(field_type._ptr)
    field = _TYPE_ID_TO_OBJ[typeid]._create_from_ptr(ptr)
    field._field_type = field_type
    return field
Esempio n. 8
0
    def __next__(self):
        if self._at == len(self._stream_class):
            raise StopIteration

        ec_ptr = native_bt.ctf_stream_class_get_event_class(self._stream_class._ptr,
                                                            self._at)
        utils._handle_ptr(ec_ptr, "cannot get stream class object's event class object")
        name = native_bt.ctf_event_class_get_name(ec_ptr)
        native_bt.put(ec_ptr)
        utils._handle_ptr(name, "cannot get event class object's name")
        self._at += 1
        return name
Esempio n. 9
0
    def __getitem__(self, index):
        if not isinstance(index, numbers.Integral):
            raise TypeError("'{}' is not an integral number object: invalid index".format(index.__class__.__name__))

        index = int(index)

        if index < 0 or index >= len(self):
            raise IndexError('{} field object index is out of range'.format(self._NAME))

        field_ptr = self._get_field_ptr_at_index(index)
        utils._handle_ptr(field_ptr, "cannot get {} field object's field".format(self._NAME))
        return _create_from_ptr(field_ptr)
Esempio n. 10
0
    def __next__(self):
        if self._at == len(self._trace_clock_classes):
            raise StopIteration

        trace_ptr = self._trace_clock_classes._trace._ptr
        cc_ptr = native_bt.ctf_trace_get_clock_class(trace_ptr, self._at)
        utils._handle_ptr(cc_ptr, "cannot get trace class object's clock class")
        name = native_bt.ctf_clock_class_get_name(cc_ptr)
        native_bt.put(cc_ptr)
        utils._handle_ptr(name, "cannot get clock class object's name")
        self._at += 1
        return name
Esempio n. 11
0
def _create_private_from_ptr(ptr):
    pub_ptr = native_bt.port_from_private(ptr)
    utils._handle_ptr(pub_ptr, 'cannot get port object from private port object')
    port_type = native_bt.port_get_type(pub_ptr)
    assert(port_type == native_bt.PORT_TYPE_INPUT or port_type == native_bt.PORT_TYPE_OUTPUT)

    if port_type == native_bt.PORT_TYPE_INPUT:
        cls = _PrivateInputPort
    elif port_type == native_bt.PORT_TYPE_OUTPUT:
        cls = _PrivateOutputPort

    obj = cls._create_from_ptr(ptr)
    obj._pub_ptr = pub_ptr
    return obj
Esempio n. 12
0
    def __next__(self):
        if self._at == len(self._trace):
            raise StopIteration

        sc_ptr = native_bt.ctf_trace_get_stream_class(self._trace._ptr,
                                                      self._at)
        utils._handle_ptr(sc_ptr, "cannot get trace class object's stream class object")
        id = native_bt.ctf_stream_class_get_id(sc_ptr)
        native_bt.put(sc_ptr)

        if utils._is_m1ull(id):
            raise bt2.Error("cannot get stream class object's ID")

        self._at += 1
        return id
Esempio n. 13
0
    def __next__(self):
        if self._at == len(self._trace):
            raise StopIteration

        sc_ptr = native_bt.ctf_trace_get_stream_class(self._trace._ptr,
                                                      self._at)
        utils._handle_ptr(
            sc_ptr, "cannot get trace class object's stream class object")
        id = native_bt.ctf_stream_class_get_id(sc_ptr)
        native_bt.put(sc_ptr)

        if utils._is_m1ull(id):
            raise bt2.Error("cannot get stream class object's ID")

        self._at += 1
        return id
Esempio n. 14
0
def _create_private_from_ptr(ptr):
    pub_ptr = native_bt.port_from_private(ptr)
    utils._handle_ptr(pub_ptr,
                      'cannot get port object from private port object')
    port_type = native_bt.port_get_type(pub_ptr)
    assert (port_type == native_bt.PORT_TYPE_INPUT
            or port_type == native_bt.PORT_TYPE_OUTPUT)

    if port_type == native_bt.PORT_TYPE_INPUT:
        cls = _PrivateInputPort
    elif port_type == native_bt.PORT_TYPE_OUTPUT:
        cls = _PrivateOutputPort

    obj = cls._create_from_ptr(ptr)
    obj._pub_ptr = pub_ptr
    return obj
Esempio n. 15
0
    def __getitem__(self, index):
        if not isinstance(index, numbers.Integral):
            raise TypeError(
                "'{}' is not an integral number object: invalid index".format(
                    index.__class__.__name__))

        index = int(index)

        if index < 0 or index >= len(self):
            raise IndexError('{} field object index is out of range'.format(
                self._NAME))

        field_ptr = self._get_field_ptr_at_index(index)
        utils._handle_ptr(
            field_ptr, "cannot get {} field object's field".format(self._NAME))
        return _create_from_ptr(field_ptr)
Esempio n. 16
0
 def value(self):
     value = native_bt.ctf_field_string_get_value(self._ptr)
     utils._handle_ptr(value, "cannot get string field object's value")
     return value
Esempio n. 17
0
 def tag_field(self):
     field_ptr = native_bt.ctf_field_variant_get_tag(self._ptr)
     utils._handle_ptr(field_ptr, "cannot get variant field object's tag field")
     return _create_from_ptr(field_ptr)
Esempio n. 18
0
 def value(self):
     value = native_bt.ctf_field_string_get_value(self._ptr)
     utils._handle_ptr(value, "cannot get string field object's value")
     return value
Esempio n. 19
0
 def integer_field_type(self):
     ptr = native_bt.ctf_field_type_enumeration_get_container_type(self._ptr)
     utils._handle_ptr(ptr, "cannot get enumeration field type object's integer field type")
     return _create_from_ptr(ptr)
Esempio n. 20
0
 def tag_name(self):
     tag_name = native_bt.ctf_field_type_variant_get_tag_name(self._ptr)
     utils._handle_ptr(tag_name, "cannot get variant field type object's tag name")
     return tag_name
Esempio n. 21
0
 def component_class(self):
     cc_ptr = native_bt.component_get_class(self._ptr)
     utils._handle_ptr(cc_ptr, "cannot get component object's class object")
     return _create_generic_component_class_from_ptr(cc_ptr)
Esempio n. 22
0
 def element_field_type(self):
     ptr = native_bt.ctf_field_type_sequence_get_element_type(self._ptr)
     utils._handle_ptr(ptr, "cannot get sequence field type object's element field type")
     return _create_from_ptr(ptr)
Esempio n. 23
0
 def stream(self):
     stream_ptr = native_bt.notification_stream_end_get_stream(self._ptr)
     utils._handle_ptr(
         stream_ptr,
         "cannot get end of stream notification object's stream object")
     return bt2.stream._create_from_ptr(stream_ptr)
Esempio n. 24
0
 def trace(self):
     trace_ptr = native_bt.notification_new_trace_get_trace(self._ptr)
     utils._handle_ptr(
         trace_ptr,
         "cannot get new trace notification object's trace object")
     return bt2.trace._create_from_ptr(trace_ptr)
Esempio n. 25
0
 def stream_class(self):
     stream_class_ptr = native_bt.ctf_stream_get_class(self._ptr)
     utils._handle_ptr(stream_class_ptr,
                       "cannot get stream object's stream class object")
     return bt2.StreamClass._create_from_ptr(stream_class_ptr)
Esempio n. 26
0
 def packet(self):
     packet_ptr = native_bt.notification_packet_end_get_packet(self._ptr)
     utils._handle_ptr(
         packet_ptr,
         "cannot get end of packet notification object's packet object")
     return bt2.packet._Packet._create_from_ptr(packet_ptr)
Esempio n. 27
0
 def name(self):
     name = native_bt.ctf_clock_get_name(self._ptr)
     utils._handle_ptr(name, "cannot get CTF writer clock object's name")
     return name
Esempio n. 28
0
 def stream(self):
     stream_ptr = native_bt.ctf_packet_get_stream(self._ptr)
     utils._handle_ptr(stream_ptr,
                       "cannot get packet object's stream object")
     return bt2.stream._Stream._create_from_ptr(stream_ptr)
Esempio n. 29
0
 def event_class_with_id(self, id):
     utils._check_int64(id)
     ec_ptr = native_bt.ctf_stream_class_get_event_class_by_id(self._ptr, id)
     utils._handle_ptr(ec_ptr, "cannot get stream class object's event class object")
     return bt2.EventClass._create_from_ptr(ec_ptr)
Esempio n. 30
0
 def name(self):
     name = native_bt.plugin_get_name(self._ptr)
     utils._handle_ptr(name, "cannot get plugin object's name")
     return name
Esempio n. 31
0
 def integer_field(self):
     int_field_ptr = native_bt.ctf_field_enumeration_get_container(self._ptr)
     utils._handle_ptr(int_field_ptr,
                       "cannot get enumeration field object's underlying integer field")
     return _create_from_ptr(int_field_ptr)
Esempio n. 32
0
 def _upstream_port(ptr):
     port_ptr = native_bt.connection_get_upstream_port(ptr)
     utils._handle_ptr(port_ptr, "cannot get connection object's upstream port object")
     return bt2.port._create_from_ptr(port_ptr)
Esempio n. 33
0
 def at_index(self, index):
     utils._check_uint64(index)
     field_ptr = native_bt.ctf_field_structure_get_field_by_index(self._ptr, index)
     utils._handle_ptr(field_ptr, "cannot get structure field object's field")
     return _create_from_ptr(field_ptr)
Esempio n. 34
0
 def __copy__(self):
     ptr = native_bt.field_class_copy(self._ptr)
     utils._handle_ptr(ptr, 'cannot copy {} field class object'.format(self._NAME.lower()))
     return _create_from_ptr(ptr)
Esempio n. 35
0
 def mapped_clock_class(self):
     ptr = native_bt.ctf_field_type_integer_get_mapped_clock_class(self._ptr)
     utils._handle_ptr(ptr, "cannot get integer field type object's mapped clock class")
     return bt2.ClockClass._create_from_ptr(ptr)
Esempio n. 36
0
 def component(self):
     comp_ptr = native_bt.notification_iterator_get_component(self._ptr)
     utils._handle_ptr(comp_ptr, "cannot get notification iterator object's component object")
     return bt2.component._create_generic_component_from_ptr(comp_ptr)
Esempio n. 37
0
 def length_field(self):
     field_ptr = native_bt.ctf_field_sequence_get_length(self._ptr)
     utils._handle_ptr("cannot get sequence field object's length field")
     return _create_from_ptr(field_ptr)
Esempio n. 38
0
 def clock_class(self):
     ptr = native_bt.ctf_clock_value_get_class(self._ptr)
     utils._handle_ptr(ptr, "cannot get clock value object's clock class object")
     return ClockClass._create_from_ptr(ptr)
Esempio n. 39
0
 def _get_msg(self):
     msg_ptr = native_bt.message_iterator_get_message(self._ptr)
     utils._handle_ptr(msg_ptr, "cannot get message iterator object's current message object")
     return bt2.message._create_from_ptr(msg_ptr)
Esempio n. 40
0
 def length_name(self):
     length_name = native_bt.ctf_field_type_sequence_get_length_field_name(self._ptr)
     utils._handle_ptr(length_name, "cannot get sequence field type object's length name")
     return length_name
Esempio n. 41
0
 def tag_field(self):
     field_ptr = native_bt.ctf_field_variant_get_tag(self._ptr)
     utils._handle_ptr(field_ptr,
                       "cannot get variant field object's tag field")
     return _create_from_ptr(field_ptr)
Esempio n. 42
0
 def event(self):
     event_ptr = native_bt.notification_event_get_event(self._ptr)
     utils._handle_ptr(
         event_ptr,
         "cannot get trace event notification object's event object")
     return bt2.event._create_from_ptr(event_ptr)
Esempio n. 43
0
 def length_field(self):
     field_ptr = native_bt.ctf_field_sequence_get_length(self._ptr)
     utils._handle_ptr("cannot get sequence field object's length field")
     return _create_from_ptr(field_ptr)
Esempio n. 44
0
 def _upstream_port(ptr):
     port_ptr = native_bt.connection_get_upstream_port(ptr)
     utils._handle_ptr(
         port_ptr, "cannot get connection object's upstream port object")
     return bt2.port._create_from_ptr(port_ptr)
Esempio n. 45
0
 def stream_class(self):
     stream_class_ptr = native_bt.ctf_stream_get_class(self._ptr)
     utils._handle_ptr(stream_class_ptr, "cannot get stream object's stream class object")
     return bt2.StreamClass._create_from_ptr(stream_class_ptr)
Esempio n. 46
0
 def name(self):
     name = native_bt.ctf_clock_class_get_name(self._ptr)
     utils._handle_ptr(name, "cannot get clock class object's name")
     return name
Esempio n. 47
0
 def notification(self):
     notif_ptr = native_bt.notification_iterator_get_notification(self._ptr)
     utils._handle_ptr(notif_ptr, "cannot get notification iterator object's current notification object")
     return bt2.notification._create_from_ptr(notif_ptr)
Esempio n. 48
0
 def clock_class(self):
     ptr = native_bt.ctf_clock_value_get_class(self._ptr)
     utils._handle_ptr(
         ptr, "cannot get clock value object's clock class object")
     return ClockClass._create_from_ptr(ptr)
Esempio n. 49
0
 def name(self):
     name = native_bt.ctf_clock_class_get_name(self._ptr)
     utils._handle_ptr(name, "cannot get clock class object's name")
     return name
Esempio n. 50
0
 def trace(self):
     trace_ptr = native_bt.ctf_writer_get_trace(self._ptr)
     utils._handle_ptr(name, "cannot get CTF writer object's trace class")
     return bt2.Trace._create_from_ptr(trace_ptr)
Esempio n. 51
0
 def __copy__(self):
     ptr = native_bt.field_copy(self._ptr)
     utils._handle_ptr(
         ptr, 'cannot copy {} field object'.format(self._NAME.lower()))
     return _create_from_ptr(ptr)
Esempio n. 52
0
 def metadata_string(self):
     metadata_string = native_bt.ctf_writer_get_metadata_string(self._ptr)
     utils._handle_ptr(metadata_string,
                       "cannot get CTF writer object's metadata string")
     return metadata_string