import babeltrace.common as common
import bt2
+
class EnumerationMapping:
"""
Mapping from an enumeration label to a range of integers.
common.CTFStringEncoding.UTF8: bt2.Encoding.UTF8,
}
+
class FieldDeclaration:
"""
Base class of all field declarations. This class is not meant to
raise TypeError(
"Could not get Floating point exponent digit count")
-
@exponent_digits.setter
def exponent_digits(self, exponent_digits):
try:
raise TypeError(
"Could not get Floating point mantissa digit count")
-
@mantissa_digits.setter
def mantissa_digits(self, mantissa_digits):
try:
raise TypeError("Invalid tag type; must be of type EnumerationFieldDeclaration.")
self._field_type = bt2.VariantFieldType(tag_name=tag_name,
- tag_field_type=enum_tag._field_type)
+ tag_field_type=enum_tag._field_type)
super().__init__()
@property
except:
raise ValueError("Invalid stream context field.")
+
class StreamClass:
"""
A stream class contains the properties of specific
try:
# Set default event header and packet context.
event_header_type = bt2.StructureFieldType()
- uint32_ft = bt2.IntegerFieldType(32, is_signed=False)
- uint64_ft = bt2.IntegerFieldType(32, is_signed=False)
+ uint32_ft = bt2.IntegerFieldType(32)
+ uint64_ft = bt2.IntegerFieldType(64)
event_header_type.append_field('id', uint32_ft)
event_header_type.append_field('timestamp', uint64_ft)
@packet_context_type.setter
def packet_context_type(self, field_type):
- if not isinstance(field_type, StructureFieldDeclaration):
+ if field_type is not None and not isinstance(field_type,
+ StructureFieldDeclaration):
raise TypeError("field_type argument must be of type StructureFieldDeclaration.")
+ bt2_field_type = None if field_type is None else field_type._field_type
try:
- self._stream_class.packet_context_field_type = field_type._field_type
+ self._stream_class.packet_context_field_type = bt2_field_type
except:
raise ValueError("Failed to set packet context type.")
@event_context_type.setter
def event_context_type(self, field_type):
- if not isinstance(field_type, StructureFieldDeclaration):
+ if field_type is not None and not isinstance(field_type,
+ StructureFieldDeclaration):
raise TypeError("field_type argument must be of type StructureFieldDeclaration.")
+ bt2_field_type = None if field_type is None else field_type._field_type
try:
- self._stream_class.event_context_field_type = field_type._field_type
+ self._stream_class.event_context_field_type = bt2_field_type
except:
raise ValueError("Failed to set event context type.")
:exc:`ValueError` is raised on error.
"""
- self._s.flush()
+ try:
+ self._s.flush()
+ except:
+ raise ValueError('Failed to flush CTF writer stream')
class Writer:
raise TypeError("Value type is not supported.")
try:
- self._w.trace.env += {name: value}
+ self._w.trace.env[name] = value
except:
raise ValueError("Could not add environment field to trace.")