pass
def __init__(self):
- if self._ft is None:
+ if self._field_type is None:
raise ValueError("FieldDeclaration creation failed.")
@staticmethod
raise TypeError("Invalid field declaration instance.")
declaration = Field.__new__(Field)
- declaration._ft = field_type
+ declaration._field_type = field_type
declaration.__class__ = _BT2_FIELD_TYPE_TO_BT_DECLARATION[
type(field_type)]
return declaration
"""
try:
- return self._ft.alignment
+ return self._field_type.alignment
except:
raise ValueError(
"Could not get alignment field declaration attribute.")
@alignment.setter
def alignment(self, alignment):
try:
- self._ft.alignment = alignment
+ self._field_type.alignment = alignment
except:
raise ValueError("Invalid alignment value.")
"""
try:
- return _BT2_BYTE_ORDER_TO_BYTE_ORDER[self._ft.byte_order]
+ return _BT2_BYTE_ORDER_TO_BYTE_ORDER[self._field_type.byte_order]
except:
raise ValueError(
"Could not get byte order field declaration attribute.")
@byte_order.setter
def byte_order(self, byte_order):
try:
- self._ft.byte_order = _BYTE_ORDER_TO_BT2_BYTE_ORDER[byte_order]
+ self._field_type.byte_order = _BYTE_ORDER_TO_BT2_BYTE_ORDER[byte_order]
except:
raise ValueError("Could not set byte order value.")
"""
try:
- return _BT2_ENCODING_TO_ENCODING[self._ft.encoding]
+ return _BT2_ENCODING_TO_ENCODING[self._field_type.encoding]
except:
raise ValueError("Could not get field encoding.")
@encoding.setter
def encoding(self, encoding):
try:
- self._ft.encoding = _ENCODING_TO_BT2_ENCODING[encoding]
+ self._field_type.encoding = _ENCODING_TO_BT2_ENCODING[encoding]
except:
raise ValueError("Could not set field encoding.")
:exc:`ValueError` is raised on error.
"""
- self._ft = bt2.IntegerFieldType(size)
+ self._field_type = bt2.IntegerFieldType(size)
super().__init__()
@property
"""
try:
- return self._ft.size
+ return self._field_type.size
except:
raise ValueError("Could not get Integer size attribute.")
"""
try:
- return self._ft.is_signed
+ return self._field_type.is_signed
except:
raise ValueError("Could not get Integer signed attribute.")
@signed.setter
def signed(self, signed):
try:
- self._ft.is_signed = signed
+ self._field_type.is_signed = signed
except:
raise ValueError("Could not set Integer signed attribute.")
"""
try:
- return self._ft.base
+ return self._field_type.base
except:
raise ValueError("Could not get Integer base attribute.")
@base.setter
def base(self, base):
try:
- self._ft.base = base
+ self._field_type.base = base
except:
raise ValueError("Could not set Integer base.")
if integer_type is None or not isinst:
raise TypeError("Invalid integer container.")
- self._ft = bt2.EnumerationFieldType(integer_type._ft)
+ self._field_type = bt2.EnumerationFieldType(integer_type._field_type)
super().__init__()
@property
try:
return FieldDeclaration._create_field_declaration(
- self._ft.integer_field_type)
+ self._field_type.integer_field_type)
except:
raise TypeError("Invalid enumeration declaration")
"""
try:
- self._ft.append_mapping(name, range_start, range_end)
+ self._field_type.append_mapping(name, range_start, range_end)
except:
raise ValueError(
"Could not add mapping to enumeration declaration.")
:exc:`TypeError` is raised on error.
"""
- for mapping in self._ft:
+ for mapping in self._field_type:
yield EnumerationMapping(mapping.name, mapping.lower,
mapping.upper)
"""
try:
- mappings = list(self._ft.mappings_by_name(name))
+ mappings = list(self._field_type.mappings_by_name(name))
except:
raise TypeError(
'Could not get enumeration mappings by name \'{}\''.format(
"""
try:
- mappings = list(self._ft.mappings_by_value(value))
+ mappings = list(self._field_type.mappings_by_value(value))
except:
raise TypeError(
'Could not get enumeration mappings by value \'{}\''.format(
:exc:`ValueError` is raised on error.
"""
- self._ft = bt2.FloatingPointNumberFieldType()
+ self._field_type = bt2.FloatingPointNumberFieldType()
super().__init__()
@property
"""
try:
- return self._ft.exponent_size
+ return self._field_type.exponent_size
except:
raise TypeError(
"Could not get Floating point exponent digit count")
@exponent_digits.setter
def exponent_digits(self, exponent_digits):
try:
- self._ft.exponent_size = exponent_digits
+ self._field_type.exponent_size = exponent_digits
except:
raise ValueError("Could not set exponent digit count.")
"""
try:
- return self._ft.mantissa_size
+ return self._field_type.mantissa_size
except:
raise TypeError(
"Could not get Floating point mantissa digit count")
@mantissa_digits.setter
def mantissa_digits(self, mantissa_digits):
try:
- self._ft.mantissa_size = mantissa_digits
+ self._field_type.mantissa_size = mantissa_digits
except:
raise ValueError("Could not set mantissa digit count.")
:exc:`ValueError` is raised on error.
"""
- self._ft = bt2.StructureFieldType()
+ self._field_type = bt2.StructureFieldType()
super().__init__()
def add_field(self, field_type, field_name):
"""
try:
- self._ft.append_field(field_name, field_type._ft)
+ self._field_type.append_field(field_name, field_type._field_type)
except:
raise ValueError("Could not add field to structure.")
:exc:`TypeError` is raised on error.
"""
- for name, field_type in self._ft.items():
+ for name, field_type in self._field_type.items():
yield (name,
FieldDeclaration._create_field_declaration(
field_type))
:exc:`TypeError` is raised on error.
"""
- if name not in self._ft:
+ if name not in self._field_type:
msg = "Could not find Structure field with name {}".format(name)
raise TypeError(msg)
- field_type = self._ft[name]
+ field_type = self._field_type[name]
return FieldDeclaration._create_field_declaration(
field_type)
if enum_tag is None or not isinst:
raise TypeError("Invalid tag type; must be of type EnumerationFieldDeclaration.")
- self._ft = bt2.VariantFieldType(tag_name=tag_name,
- tag_field_type=enum_tag._ft)
+ self._field_type = bt2.VariantFieldType(tag_name=tag_name,
+ tag_field_type=enum_tag._field_type)
super().__init__()
@property
"""
try:
- self._ft.tag_name
+ self._field_type.tag_name
except:
raise TypeError("Could not get Variant tag name")
try:
return FieldDeclaration._create_field_declaration(
- self._ft.tag_field_type)
+ self._field_type.tag_field_type)
except:
raise TypeError("Could not get Variant tag type")
"""
try:
- self._ft.append_field(name=field_name, field_type=field_type._ft)
+ self._field_type.append_field(name=field_name, field_type=field_type._field_type)
except:
raise ValueError("Could not add field to variant.")
:exc:`TypeError` is raised on error.
"""
- for name, member in self._ft.items():
+ for name, member in self._field_type.items():
yield (name, FieldDeclaration._create_field_declaration(member))
def get_field_by_name(self, name):
:exc:`TypeError` is raised on error.
"""
- if name not in self._ft:
+ if name not in self._field_type:
raise TypeError(
'Could not find Variant field with name {}'.format(name))
- field_type = self._ft[name]
+ field_type = self._field_type[name]
return FieldDeclaration._create_field_declaration(field_type)
def get_field_from_tag(self, tag):
"""
try:
- self._ft = bt2.ArrayFieldType(element_type._ft, length)
+ self._field_type = bt2.ArrayFieldType(element_type._field_type, length)
except:
raise ValueError('Failed to create ArrayFieldDeclaration.')
super().__init__()
try:
return FieldDeclaration._create_field_declaration(
- self._ft.element_field_type)
+ self._field_type.element_field_type)
except:
raise TypeError("Could not get Array element type")
"""
try:
- return self._ft.length
+ return self._field_type.length
except:
raise TypeError("Could not get Array length")
"""
try:
- self._ft = bt2.SequenceFieldType(element_type, length_field_name)
+ self._field_type = bt2.SequenceFieldType(element_type, length_field_name)
except:
raise ValueError('Failed to create SequenceFieldDeclaration.')
super().__init__()
try:
return FieldDeclaration._create_field_declaration(
- self._ft.element_field_type)
+ self._field_type.element_field_type)
except:
raise TypeError("Could not get Sequence element type")
"""
try:
- return self._ft.length_name
+ return self._field_type.length_name
except:
raise TypeError("Could not get Sequence element type")
:exc:`ValueError` is raised on error.
"""
- self._ft = bt2.StringFieldType()
+ self._field_type = bt2.StringFieldType()
super().__init__()
raise TypeError("Invalid field_type argument.")
try:
- self._f = field_type._ft()
+ self._f = field_type._field_type()
except:
raise ValueError("Field creation failed.")
@value.setter
def value(self, value):
try:
- self._f = value
+ self._f.value = value
except:
raise ValueError("Could not set integer field value.")
try:
self._ec.payload_field_type.append_field(field_name,
- field_type._ft)
+ field_type._field_type)
except:
raise ValueError("Could not add field to event class.")
return
stream_class = StreamClass.__new__(StreamClass)
- stream_class._sc = bt2_stream_class
+ stream_class._stream_class = bt2_stream_class
return stream_class
"""
try:
- return self._sc.name
+ return self._stream_class.name
except:
raise TypeError("Could not get StreamClass name")
:exc:`ValueError` is raised on error.
"""
- if self._sc.clock is None:
+ if self._stream_class.clock is None:
return
clock = Clock.__new__(Clock)
- clock._c = self._sc.clock
+ clock._c = self._stream_class.clock
return clock
@clock.setter
raise TypeError("Invalid clock type.")
try:
- self._sc.clock = clock._c
+ self._stream_class.clock = clock._clock
except:
raise ValueError("Could not set stream class clock.")
"""
try:
- return self._sc.id
+ return self._stream_class.id
except:
raise TypeError("Could not get StreamClass id")
@id.setter
def id(self, id):
try:
- self._sc.id = id
+ self._stream_class.id = id
except:
raise TypeError("Could not set stream class id.")
:exc:`TypeError` is raised on error.
"""
- for bt2_ec in self._sc.values():
+ for bt2_ec in self._stream_class.values():
event_class = EventClass.__new__(EventClass)
event_class._ec = bt2_ec
yield event_class
raise TypeError("Invalid event_class type.")
try:
- self._sc.add_event_class(event_class._ec)
+ self._stream_class.add_event_class(event_class._ec)
except:
raise ValueError("Could not add event class.")
"""
try:
- bt2_field_type = self._sc.packet_context_field_type
+ bt2_field_type = self._stream_class.packet_context_field_type
if bt2_field_type is None:
raise ValueError("Invalid StreamClass")
raise TypeError("field_type argument must be of type StructureFieldDeclaration.")
try:
- self._sc.packet_context_field_type = field_type._ft
+ self._stream_class.packet_context_field_type = field_type._field_type
except:
raise ValueError("Failed to set packet context type.")
"""
try:
- bt2_field_type = self._sc.event_context_field_type
+ bt2_field_type = self._stream_class.event_context_field_type
if bt2_field_type is None:
raise ValueError("Invalid StreamClass")
raise TypeError("field_type argument must be of type StructureFieldDeclaration.")
try:
- self._sc.event_context_field_type = field_type._ft
+ self._stream_class.event_context_field_type = field_type._field_type
except:
raise ValueError("Failed to set event context type.")
:exc:`ValueError` is raised on error.
"""
- ret = nbt._bt_ctf_stream_append_event(self._s, event._e)
-
- if ret < 0:
+ try:
+ self._s.append_event(event._e)
+ except:
raise ValueError("Could not append event to stream.")
@property
if not isinstance(stream_class, StreamClass):
raise TypeError("Invalid stream_class type.")
- if stream_class.sc.trace is None:
- self._w.trace.add_stream_class(stream_class._sc)
+ if stream_class._stream_class.trace is None:
+ self._w.trace.add_stream_class(stream_class._stream_class)
stream = Stream.__new__(Stream)
- stream._s = stream_class._sc()
+ stream._s = stream_class._stream_class()
+ stream.__class__ = Stream
return stream
def add_environment_field(self, name, value):
"""
try:
- self._w.trace.add_clock(clock._c)
+ self._w.add_clock(clock._clock)
except:
raise ValueError("Could not add clock to Writer.")