Add Python bindings for CTF-IR stream getters
[babeltrace.git] / bindings / python / babeltrace.i.in
index 1dec941fb5c9e68bc68f03d280f18f3df51515a1..ee4ceccce13eeeeb27d45ce71076b725c9316231 100644 (file)
@@ -33,6 +33,7 @@ trace to it."
 
 %module(docstring=DOCSTRING) babeltrace
 
+%include "stdint.i"
 %include "typemaps.i"
 %{
 #define SWIG_FILE_WITH_INIT
@@ -57,17 +58,14 @@ trace to it."
 #include <babeltrace/ctf-writer/writer.h>
 %}
 
-typedef unsigned long long uint64_t;
-typedef long long int64_t;
 typedef int bt_intern_str;
+typedef int64_t ssize_t;
 
 /* =================================================================
                PYTHON-COMPLEMENTS.H
                ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
 */
 
-FILE *_bt_file_open(char *file_path, char *mode);
-void _bt_file_close(FILE *fp);
 struct bt_definition **_bt_python_field_listcaller(
                const struct bt_ctf_event *ctf_event,
                const struct bt_definition *scope,
@@ -90,8 +88,32 @@ struct definition_array *_bt_python_get_array_from_def(
                struct bt_definition *field);
 struct definition_sequence *_bt_python_get_sequence_from_def(
                struct bt_definition *field);
+struct bt_declaration *_bt_python_get_array_element_declaration(
+               struct bt_declaration *field);
+struct bt_declaration *_bt_python_get_sequence_element_declaration(
+               struct bt_declaration *field);
+const char *_bt_python_get_array_string(struct bt_definition *field);
+const char *_bt_python_get_sequence_string(struct bt_definition *field);
 int _bt_python_field_integer_get_signedness(const struct bt_ctf_field *field);
 enum ctf_type_id _bt_python_get_field_type(const struct bt_ctf_field *field);
+const char *_bt_python_ctf_field_type_enumeration_get_mapping(
+               struct bt_ctf_field_type *enumeration, size_t index,
+               int64_t *OUTPUT, int64_t *OUTPUT);
+const char *_bt_python_ctf_field_type_enumeration_get_mapping_unsigned(
+               struct bt_ctf_field_type *enumeration, size_t index,
+               uint64_t *OUTPUT, uint64_t *OUTPUT);
+const char *_bt_python_ctf_field_type_structure_get_field_name(
+               struct bt_ctf_field_type *structure, size_t index);
+struct bt_ctf_field_type *_bt_python_ctf_field_type_structure_get_field_type(
+               struct bt_ctf_field_type *structure, size_t index);
+const char *_bt_python_ctf_field_type_variant_get_field_name(
+               struct bt_ctf_field_type *variant, size_t index);
+struct bt_ctf_field_type *_bt_python_ctf_field_type_variant_get_field_type(
+               struct bt_ctf_field_type *variant, size_t index);
+const char *_bt_python_ctf_event_class_get_field_name(
+               struct bt_ctf_event_class *event_class, size_t index);
+struct bt_ctf_field_type *_bt_python_ctf_event_class_get_field_type(
+               struct bt_ctf_event_class *event_class, size_t index);
 
 /* =================================================================
                CONTEXT.H, CONTEXT-INTERNAL.H
@@ -386,7 +408,7 @@ int bt_ctf_event_get_handle_id(const struct bt_ctf_event *event);
 
 %pythoncode%{
 
-# Based on enum bt_clock_type in clock-type.h­
+# Based on enum bt_clock_type in clock-type.h
 class ClockType:
        CLOCK_CYCLES = 0
        CLOCK_REAL = 1
@@ -426,6 +448,22 @@ class TraceHandle(object):
                return _bt_trace_handle_get_timestamp_end(
                        self._trace_collection._tc, self._id, ClockType.CLOCK_REAL)
 
+       @property
+       def events(self):
+               """
+               Generator returning all events (EventDeclaration) in a trace.
+               """
+               ret = _bt_python_event_decl_listcaller(self.id, self._trace_collection._tc)
+
+               if not isinstance(ret, list):
+                       return
+
+               ptr_list, count = ret
+               for i in range(count):
+                       tmp = EventDeclaration.__new__(EventDeclaration)
+                       tmp._ed =  _bt_python_decl_one_from_list(ptr_list, i)
+                       yield tmp
+
 %}
 
 
@@ -456,7 +494,6 @@ struct bt_ctf_event *bt_ctf_iter_read_event(struct bt_ctf_iter *iter);
 
 
 //Events
-
 %rename("_bt_ctf_get_top_level_scope") bt_ctf_get_top_level_scope(const struct
                bt_ctf_event *event, enum bt_ctf_scope scope);
 %rename("_bt_ctf_event_name") bt_ctf_event_name(const struct bt_ctf_event *ctf_event);
@@ -490,10 +527,14 @@ struct bt_ctf_event *bt_ctf_iter_read_event(struct bt_ctf_iter *iter);
 %rename("_bt_ctf_field_get_error") bt_ctf_field_get_error(void);
 %rename("_bt_ctf_get_decl_event_name") bt_ctf_get_decl_event_name(const struct
                bt_ctf_event_decl *event);
+%rename("_bt_ctf_get_decl_event_id") bt_ctf_get_decl_event_id(const struct
+               bt_ctf_event_decl *event);
 %rename("_bt_ctf_get_decl_field_name") bt_ctf_get_decl_field_name(
                const struct bt_ctf_field_decl *field);
 %rename("_bt_ctf_get_decl_from_def") bt_ctf_get_decl_from_def(
                const struct bt_definition *field);
+%rename("_bt_ctf_get_decl_from_field_decl") bt_ctf_get_decl_from_field_decl(
+               const struct bt_ctf_field_decl *field);
 %rename("_bt_array_index") bt_array_index(struct definition_array *array, uint64_t i);
 %rename("_bt_sequence_len")  bt_sequence_len(struct definition_sequence *sequence);
 %rename("_bt_sequence_index") bt_sequence_index(struct definition_sequence *sequence, uint64_t i);
@@ -530,8 +571,10 @@ double bt_ctf_get_float(const struct bt_definition *field);
 const struct bt_definition *bt_ctf_get_variant(const struct bt_definition *field);
 int bt_ctf_field_get_error(void);
 const char *bt_ctf_get_decl_event_name(const struct bt_ctf_event_decl *event);
+uint64_t bt_ctf_get_decl_event_id(const struct bt_ctf_event_decl *event);
 const char *bt_ctf_get_decl_field_name(const struct bt_ctf_field_decl *field);
 const struct bt_declaration *bt_ctf_get_decl_from_def(const struct bt_definition *field);
+const struct bt_declaration *bt_ctf_get_decl_from_field_decl(const struct bt_ctf_field_decl *field);
 uint64_t bt_sequence_len(struct definition_sequence *sequence);
 struct bt_definition *bt_sequence_index(struct definition_sequence *sequence, uint64_t i);
 uint64_t bt_ctf_get_struct_field_count(const struct bt_definition *structure);
@@ -545,6 +588,14 @@ class CTFStringEncoding:
        ASCII = 2
        UNKNOWN = 3
 
+# Based on the enum in ctf-writer/writer.h
+class ByteOrder:
+       BYTE_ORDER_NATIVE = 0
+       BYTE_ORDER_LITTLE_ENDIAN = 1
+       BYTE_ORDER_BIG_ENDIAN = 2
+       BYTE_ORDER_NETWORK = 3
+       BYTE_ORDER_UNKNOWN = 4 # Python-specific entry
+
 #enum equivalent, accessible constants
 #These are taken directly from ctf/events.h
 #All changes to enums must also be made here
@@ -560,9 +611,8 @@ class CTFTypeId:
        ARRAY = 8
        SEQUENCE = 9
        NR_CTF_TYPES = 10
-
-       def get_type_name(id):
-               name = "UNKNOWN"
+       def type_name(id):
+               name = "UNKNOWN_TYPE"
                constants = [attr for attr in dir(CTFTypeId) if not callable(getattr(CTFTypeId, attr)) and not attr.startswith("__")]
                for attr in constants:
                        if getattr(CTFTypeId, attr) == id:
@@ -570,8 +620,7 @@ class CTFTypeId:
                                break
                return name
 
-
-class scope:
+class CTFScope:
        TRACE_PACKET_HEADER = 0
        STREAM_PACKET_CONTEXT = 1
        STREAM_EVENT_HEADER = 2
@@ -579,6 +628,19 @@ class scope:
        EVENT_CONTEXT = 4
        EVENT_FIELDS = 5
 
+       def scope_name(scope):
+               name = "UNKNOWN_SCOPE"
+               constants = [attr for attr in dir(CTFScope) if not callable(getattr(CTFScope, attr)) and not attr.startswith("__")]
+               for attr in constants:
+                       if getattr(CTFScope, attr) == scope:
+                               name = attr
+                               break
+               return name
+
+# Priority of the scopes when searching for event fields
+_scopes = [CTFScope.EVENT_FIELDS, CTFScope.EVENT_CONTEXT, CTFScope.STREAM_EVENT_CONTEXT,
+       CTFScope.STREAM_EVENT_HEADER, CTFScope.STREAM_PACKET_CONTEXT, CTFScope.TRACE_PACKET_HEADER]
+
 import collections
 class Event(collections.Mapping):
        """
@@ -586,10 +648,6 @@ class Event(collections.Mapping):
        It is obtained using the TraceCollection generator functions.
        Do not instantiate.
        """
-       i = scope.EVENT_FIELDS
-       _scopes = [scope.EVENT_FIELDS, scope.EVENT_CONTEXT, scope.STREAM_EVENT_CONTEXT,
-               scope.STREAM_EVENT_HEADER, scope.STREAM_PACKET_CONTEXT, scope.TRACE_PACKET_HEADER]
-
        def __init__(self):
                raise NotImplementedError("Event cannot be instantiated")
 
@@ -619,7 +677,7 @@ class Event(collections.Mapping):
                Get field_name's value in scope.
                None is returned if no field matches field_name.
                """
-               if not scope in self._scopes:
+               if not scope in _scopes:
                        raise ValueError("Invalid scope provided")
                field = self._field_with_scope(field_name, scope)
                if field is not None:
@@ -628,7 +686,7 @@ class Event(collections.Mapping):
 
        def field_list_with_scope(self, scope):
                """Return a list of field names in scope."""
-               if not scope in self._scopes:
+               if not scope in _scopes:
                        raise ValueError("Invalid scope provided")
                field_names = []
                for field in self._field_list_with_scope(scope):
@@ -690,7 +748,7 @@ class Event(collections.Mapping):
 
        def __len__(self):
                count = 0
-               for scope in self._scopes:
+               for scope in _scopes:
                        scope_ptr = _bt_ctf_get_top_level_scope(self._e, scope)
                        ret = _bt_python_field_listcaller(self._e, scope_ptr)
                        if isinstance(ret, list):
@@ -703,7 +761,7 @@ class Event(collections.Mapping):
        def keys(self):
                """Return a list of field names."""
                field_names = set()
-               for scope in self._scopes:
+               for scope in _scopes:
                        for name in self.field_list_with_scope(scope):
                                field_names.add(name)
                return list(field_names)
@@ -732,7 +790,7 @@ class Event(collections.Mapping):
 
        def _field(self, field_name):
                field = None
-               for scope in self._scopes:
+               for scope in _scopes:
                        field = self._field_with_scope(field_name, scope)
                        if field is not None:
                                break
@@ -764,58 +822,192 @@ class FieldError(Exception):
        def __str__(self):
                return repr(self.value)
 
-class EventDecl(object):
+class EventDeclaration(object):
        """Event declaration class.  Do not instantiate."""
+       MAX_UINT64 = 0xFFFFFFFFFFFFFFFF
+
+       def __init__(self):
+               raise NotImplementedError("EventDeclaration cannot be instantiated")
+
+       @property
+       def name(self):
+               """Return the name of the event or None on error"""
+               return _bt_ctf_get_decl_event_name(self._ed)
+
+       @property
+       def id(self):
+               """Return the event-ID of the event or -1 on error"""
+               id = _bt_ctf_get_decl_event_id(self._ed)
+               if id == self.MAX_UINT64:
+                       id = -1
+               return id
+
+       @property
+       def fields(self):
+               """
+               Generator returning all FieldDeclarations of an event, going through
+               each scope in the following order:
+               1) EVENT_FIELDS
+               2) EVENT_CONTEXT
+               3) STREAM_EVENT_CONTEXT
+               4) STREAM_EVENT_HEADER
+               5) STREAM_PACKET_CONTEXT
+               6) TRACE_PACKET_HEADER
+               """
+               for scope in _scopes:
+                       for declaration in self.fields_scope(scope):
+                               yield declaration
+
+       def fields_scope(self, scope):
+               """
+               Generator returning FieldDeclarations of the current event in scope.
+               """
+               ret = _by_python_field_decl_listcaller(self._ed, scope)
+
+               if not isinstance(ret, list):
+                       return
 
+               list_ptr, count = ret
+               for i in range(count):
+                       field_declaration_ptr = _bt_python_field_decl_one_from_list(list_ptr, i)
+                       if field_declaration_ptr is not None:
+                               declaration_ptr = _bt_ctf_get_decl_from_field_decl(field_declaration_ptr)
+                               field_declaration = _create_field_declaration(declaration_ptr, _bt_ctf_get_decl_field_name(field_declaration_ptr), scope)
+                               yield field_declaration
+
+class FieldDeclaration(object):
+       """Field declaration class. Do not instantiate."""
        def __init__(self):
-               raise NotImplementedError("EventDecl cannot be instantiated")
+               raise NotImplementedError("FieldDeclaration cannot be instantiated")
 
        def __repr__(self):
-               return "Babeltrace EventDecl: name {0}".format(self.get_name())
+               return "({0}) {1} {2}".format(CTFScope.scope_name(self.scope), CTFTypeId.type_name(self.type), self.name)
 
-       def get_name(self):
-               """Return the name of the event or None on error"""
-               return _bt_ctf_get_decl_event_name(self._d)
+       @property
+       def name(self):
+               """Return the name of a FieldDeclaration or None on error."""
+               return self._name
 
-       def get_decl_fields(self, scope):
+       @property
+       def type(self):
                """
-               Return a list of FieldDecl
-               Return None on error.
+               Return the FieldDeclaration's type. One of the entries in class
+               CTFTypeId.
                """
-               ptr_list = _by_python_field_decl_listcaller(self._d, scope)
+               return _bt_ctf_field_type(self._fd)
 
-               if ptr_list is None:
-                       return None
+       @property
+       def scope(self):
+               """
+               Return the FieldDeclaration's scope.
+               """
+               return self._s
 
-               decl_list = []
-               i = 0
-               while True:
-                       tmp = FieldDecl.__new__(FieldDecl)
-                       tmp._d =  _bt_python_field_decl_one_from_list(
-                               ptr_list, i)
+class IntegerFieldDeclaration(FieldDeclaration):
+       """Do not instantiate."""
+       def __init__(self):
+               raise NotImplementedError("IntegerFieldDeclaration cannot be instantiated")
 
-                       if tmp._d is None:
-                               #Last item of list is None
-                               break
+       @property
+       def signedness(self):
+               """
+               Return the signedness of an integer:
+               0 if unsigned; 1 if signed; -1 on error.
+               """
+               return _bt_ctf_get_int_signedness(self._fd)
+
+       @property
+       def base(self):
+               """Return the base of an int or a negative value on error."""
+               return _bt_ctf_get_int_base(self._fd)
+
+       @property
+       def byte_order(self):
+               """
+               Return the byte order. One of class ByteOrder's entries.
+               """
+               ret = _bt_ctf_get_int_byte_order(self._fd)
+               if ret == 1234:
+                       return ByteOrder.BYTE_ORDER_LITTLE_ENDIAN
+               elif ret == 4321:
+                       return ByteOrder.BYTE_ORDER_BIG_ENDIAN
+               else:
+                       return ByteOrder.BYTE_ORDER_UNKNOWN
 
-                       decl_list.append(tmp)
-                       i += 1
-               return decl_list
+       @property
+       def length(self):
+               """
+               Return the size, in bits, of an int or a negative
+               value on error.
+               """
+               return _bt_ctf_get_int_len(self._fd)
 
+       @property
+       def encoding(self):
+               """
+               Return the encoding. One of class CTFStringEncoding's entries.
+               Return a negative value on error.
+               """
+               return _bt_ctf_get_encoding(self._fd)
 
-class FieldDecl(object):
-       """Field declaration class.  Do not instantiate."""
+class EnumerationFieldDeclaration(FieldDeclaration):
+       """Do not instantiate."""
+       def __init__(self):
+               raise NotImplementedError("EnumerationFieldDeclaration cannot be instantiated")
 
+class ArrayFieldDeclaration(FieldDeclaration):
+       """Do not instantiate."""
        def __init__(self):
-               raise NotImplementedError("FieldDecl cannot be instantiated")
+               raise NotImplementedError("ArrayFieldDeclaration cannot be instantiated")
 
-       def __repr__(self):
-               return "Babeltrace FieldDecl: name {0}".format(self.get_name())
+       @property
+       def length(self):
+               """
+               Return the length of an array or a negative
+               value on error.
+               """
+               return _bt_ctf_get_array_len(self._fd)
+
+       @property
+       def element_declaration(self):
+               """
+               Return element declaration.
+               """
+               field_decl_ptr = _bt_python_get_array_element_declaration(self._fd)
+               return _create_field_declaration(field_decl_ptr, "", self.scope)
+
+class SequenceFieldDeclaration(FieldDeclaration):
+       """Do not instantiate."""
+       def __init__(self):
+               raise NotImplementedError("SequenceFieldDeclaration cannot be instantiated")
+
+       @property
+       def element_declaration(self):
+               """
+               Return element declaration.
+               """
+               field_decl_ptr = _bt_python_get_sequence_element_declaration(self._fd)
+               return _create_field_declaration(field_decl_ptr, "", self.scope)
+
+class FloatFieldDeclaration(FieldDeclaration):
+       """Do not instantiate."""
+       def __init__(self):
+               raise NotImplementedError("FloatFieldDeclaration cannot be instantiated")
+
+class StructureFieldDeclaration(FieldDeclaration):
+       """Do not instantiate."""
+       def __init__(self):
+               raise NotImplementedError("StructureFieldDeclaration cannot be instantiated")
 
-       def get_name(self):
-               """Return the name of a FieldDecl or None on error"""
-               return _bt_ctf_get_decl_field_name(self._d)
+class StringFieldDeclaration(FieldDeclaration):
+       """Do not instantiate."""
+       def __init__(self):
+               raise NotImplementedError("StringFieldDeclaration cannot be instantiated")
 
+class VariantFieldDeclaration(FieldDeclaration):
+       """Do not instantiate."""
+       def __init__(self):
+               raise NotImplementedError("VariantFieldDeclaration cannot be instantiated")
 
 def field_error():
        """
@@ -825,100 +1017,71 @@ def field_error():
        """
        return _bt_ctf_field_get_error()
 
-def get_event_decl_list(trace_handle, trace_collection):
+def _create_field_declaration(declaration_ptr, name, scope):
        """
-       Return a list of EventDecl
-       Return None on error.
+       Private field declaration factory.
        """
-       try:
-               handle_id = trace_handle._id
-       except AttributeError:
-                       raise TypeError("in get_event_decl_list, "
-                               "argument 1 must be a TraceHandle instance")
-       try:
-               ptr_list, count = _bt_python_event_decl_listcaller(handle_id, trace_collection._tc)
-       except AttributeError:
-                       raise TypeError("in get_event_decl_list, "
-                               "argument 2 must be a TraceCollection instance")
-
-       if ptr_list is None:
-               return None
-
-       decl_list = []
-       for i in range(count):
-               tmp = EventDecl.__new__(EventDecl)
-               tmp._d =  _bt_python_decl_one_from_list(ptr_list, i)
-               decl_list.append(tmp)
-
-       return decl_list
+       if declaration_ptr is None:
+               raise ValueError("declaration_ptr must be valid")
+       if not scope in _scopes:
+               raise ValueError("Invalid scope provided")
+
+       type = _bt_ctf_field_type(declaration_ptr)
+       declaration = None
+       if type == CTFTypeId.INTEGER:
+               declaration = IntegerFieldDeclaration.__new__(IntegerFieldDeclaration)
+       elif type == CTFTypeId.ENUM:
+               declaration = EnumerationFieldDeclaration.__new__(EnumerationFieldDeclaration)
+       elif type == CTFTypeId.ARRAY:
+               declaration = ArrayFieldDeclaration.__new__(ArrayFieldDeclaration)
+       elif type == CTFTypeId.SEQUENCE:
+               declaration = SequenceFieldDeclaration.__new__(SequenceFieldDeclaration)
+       elif type == CTFTypeId.FLOAT:
+               declaration = FloatFieldDeclaration.__new__(FloatFieldDeclaration)
+       elif type == CTFTypeId.STRUCT:
+               declaration = StructureFieldDeclaration.__new__(StructureFieldDeclaration)
+       elif type == CTFTypeId.STRING:
+               declaration = StringFieldDeclaration.__new__(StringFieldDeclaration)
+       elif type == CTFTypeId.VARIANT:
+               declaration = VariantFieldDeclaration.__new__(VariantFieldDeclaration)
+       else:
+               return declaration
+
+       declaration._fd = declaration_ptr
+       declaration._s = scope
+       declaration._name = name
+       return declaration
 
 class _Definition(object):
        def __init__(self, definition_ptr, scope):
                self._d = definition_ptr
                self._s = scope
-               if not scope in Event._scopes:
+               if not scope in _scopes:
                        ValueError("Invalid scope provided")
 
-       def __repr__(self):
-               return "Babeltrace Definition: name('{0}'), type({1})".format(self.name, self.type)
-
        @property
        def name(self):
                """Return the name of a field or None on error."""
                return _bt_ctf_field_name(self._d)
 
-       @property       
+       @property
        def type(self):
                """Return the type of a field or -1 if unknown."""
                return _bt_ctf_field_type(_bt_ctf_get_decl_from_def(self._d))
 
-       def get_int_signedness(self):
-               """
-               Return the signedness of an integer:
-               0 if unsigned; 1 if signed; -1 on error.
-               """
-               return _bt_ctf_get_int_signedness(_bt_ctf_get_decl_from_def(self._d))
-
-       def get_int_base(self):
-               """Return the base of an int or a negative value on error."""
-               return _bt_ctf_get_int_base(_bt_ctf_get_decl_from_def(self._d))
-
-       def get_int_byte_order(self):
-               """
-               Return the byte order of an int or a negative
-               value on error.
-               """
-               return _bt_ctf_get_int_byte_order(_bt_ctf_get_decl_from_def(self._d))
-
-       def get_int_len(self):
-               """
-               Return the size, in bits, of an int or a negative
-               value on error.
-               """
-               return _bt_ctf_get_int_len(_bt_ctf_get_decl_from_def(self._d))
+       @property
+       def declaration(self):
+               """Return the associated Definition object."""
+               return _create_field_declaration(_bt_ctf_get_decl_from_def(self._d), self.name, self.scope)
 
-       def get_enum_str(self):
+       def _get_enum_str(self):
                """
                Return the string matching the current enumeration.
                Return None on error.
                """
                return _bt_ctf_get_enum_str(self._d)
 
-       def get_encoding(self):
-               """
-               Return the encoding of an int or a string.
-               Return a negative value on error.
-               """
-               return _bt_ctf_get_encoding(_bt_ctf_get_decl_from_def(self._d))
-
-       def get_array_len(self):
-               """
-               Return the len of an array or a negative
-               value on error.
-               """
-               return _bt_ctf_get_array_len(_bt_ctf_get_decl_from_def(self._d))
-
-       def get_array_element_at(self, index):
+       def _get_array_element_at(self, index):
                """
                Return the array's element at position index.
                Return None on error
@@ -932,7 +1095,7 @@ class _Definition(object):
                        return None
                return _Definition(definition_ptr, self.scope)
 
-       def get_sequence_len(self):
+       def _get_sequence_len(self):
                """
                Return the len of a sequence or a negative
                value on error.
@@ -940,7 +1103,7 @@ class _Definition(object):
                seq = _bt_python_get_sequence_from_def(self._d)
                return _bt_sequence_len(seq)
 
-       def get_sequence_element_at(self, index):
+       def _get_sequence_element_at(self, index):
                """
                Return the sequence's element at position index,
                otherwise return None
@@ -952,7 +1115,7 @@ class _Definition(object):
                                return _Definition(definition_ptr, self.scope)
                return None
 
-       def get_uint64(self):
+       def _get_uint64(self):
                """
                Return the value associated with the field.
                If the field does not exist or is not of the type requested,
@@ -961,7 +1124,7 @@ class _Definition(object):
                """
                return _bt_ctf_get_uint64(self._d)
 
-       def get_int64(self):
+       def _get_int64(self):
                """
                Return the value associated with the field.
                If the field does not exist or is not of the type requested,
@@ -970,7 +1133,7 @@ class _Definition(object):
                """
                return _bt_ctf_get_int64(self._d)
 
-       def get_char_array(self):
+       def _get_char_array(self):
                """
                Return the value associated with the field.
                If the field does not exist or is not of the type requested,
@@ -979,7 +1142,7 @@ class _Definition(object):
                """
                return _bt_ctf_get_char_array(self._d)
 
-       def get_str(self):
+       def _get_str(self):
                """
                Return the value associated with the field.
                If the field does not exist or is not of the type requested,
@@ -988,7 +1151,7 @@ class _Definition(object):
                """
                return _bt_ctf_get_string(self._d)
 
-       def get_float(self):
+       def _get_float(self):
                """
                Return the value associated with the field.
                If the field does not exist or is not of the type requested,
@@ -997,7 +1160,7 @@ class _Definition(object):
                """
                return _bt_ctf_get_float(self._d)
 
-       def get_variant(self):
+       def _get_variant(self):
                """
                Return the variant's selected field.
                If the field does not exist or is not of the type requested,
@@ -1006,7 +1169,7 @@ class _Definition(object):
                """
                return _bt_ctf_get_variant(self._d)
 
-       def get_struct_field_count(self):
+       def _get_struct_field_count(self):
                """
                Return the number of fields contained in the structure.
                If the field does not exist or is not of the type requested,
@@ -1014,7 +1177,7 @@ class _Definition(object):
                """
                return _bt_ctf_get_struct_field_count(self._d)
 
-       def get_struct_field_at(self, i):
+       def _get_struct_field_at(self, i):
                """
                Return the structure's field at position i.
                If the field does not exist or is not of the type requested,
@@ -1031,40 +1194,53 @@ class _Definition(object):
                """
                id = self.type
                value = None
+
                if id == CTFTypeId.STRING:
-                       value = self.get_str()
+                       value = self._get_str()
                elif id == CTFTypeId.ARRAY:
-                       value = []
-                       for i in range(self.get_array_len()):
-                               element = self.get_array_element_at(i)
-                               value.append(element.value)
+                       element_decl = self.declaration.element_declaration
+                       if ((element_decl.type == CTFTypeId.INTEGER
+                               and element_decl.length == 8)
+                               and (element_decl.encoding == CTFStringEncoding.ASCII or element_decl.encoding == CTFStringEncoding.UTF8)):
+                               value = _bt_python_get_array_string(self._d)
+                       else:
+                               value = []
+                               for i in range(self.declaration.length):
+                                       element = self._get_array_element_at(i)
+                                       value.append(element.value)
                elif id == CTFTypeId.INTEGER:
-                       if self.get_int_signedness() == 0:
-                               value = self.get_uint64()
+                       if self.declaration.signedness == 0:
+                               value = self._get_uint64()
                        else:
-                               value = self.get_int64()
+                               value = self._get_int64()
                elif id == CTFTypeId.ENUM:
-                       value = self.get_enum_str()
+                       value = self._get_enum_str()
                elif id == CTFTypeId.SEQUENCE:
-                       seq_len = self.get_sequence_len()
-                       value = []
-                       for i in range(seq_len):
-                               evDef = self.get_sequence_element_at(i)
-                               value.append(evDef.value)
+                       element_decl = self.declaration.element_declaration
+                       if ((element_decl.type == CTFTypeId.INTEGER
+                               and element_decl.length == 8)
+                               and (element_decl.encoding == CTFStringEncoding.ASCII or element_decl.encoding == CTFStringEncoding.UTF8)):
+                               value = _bt_python_get_sequence_string(self._d)
+                       else:
+                               seq_len = self._get_sequence_len()
+                               value = []
+                               for i in range(seq_len):
+                                       evDef = self._get_sequence_element_at(i)
+                                       value.append(evDef.value)
                elif id == CTFTypeId.FLOAT:
-                       value = self.get_float()
+                       value = self._get_float()
                elif id == CTFTypeId.VARIANT:
-                       variant = Definition.__new__(Definition)
-                       variant._d = self.get_variant();
+                       variant = _Definition.__new__(_Definition)
+                       variant._d = self._get_variant();
                        value = variant.value
                elif id == CTFTypeId.STRUCT:
                        value = {}
-                       for i in range(self.get_struct_field_count()):
-                               member = _Definition(self.get_struct_field_at(i), self.scope)
+                       for i in range(self._get_struct_field_count()):
+                               member = _Definition(self._get_struct_field_at(i), self.scope)
                                value[member.name] = member.value
 
                if field_error():
-                       raise FieldError("Error occurred while accessing field {} of type {}".format(self.field_name(), CTFTypeId.get_type_name(self.field_type())))
+                       raise FieldError("Error occurred while accessing field {} of type {}".format(self.name, CTFTypeId.type_name(id)))
                return value
 
        @property
@@ -1084,23 +1260,39 @@ class _Definition(object):
                ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
 */
 %rename("_bt_ctf_clock_create") bt_ctf_clock_create(const char *name);
+%rename("_bt_ctf_clock_get_name") bt_ctf_clock_get_name(struct bt_ctf_clock *clock);
+%rename("_bt_ctf_clock_get_description") bt_ctf_clock_get_description(struct bt_ctf_clock *clock);
 %rename("_bt_ctf_clock_set_description") bt_ctf_clock_set_description(struct bt_ctf_clock *clock, const char *desc);
+%rename("_bt_ctf_clock_get_frequency") bt_ctf_clock_get_frequency(struct bt_ctf_clock *clock);
 %rename("_bt_ctf_clock_set_frequency") bt_ctf_clock_set_frequency(struct bt_ctf_clock *clock, uint64_t freq);
+%rename("_bt_ctf_clock_get_precision") bt_ctf_clock_get_precision(struct bt_ctf_clock *clock);
 %rename("_bt_ctf_clock_set_precision") bt_ctf_clock_set_precision(struct bt_ctf_clock *clock, uint64_t precision);
+%rename("_bt_ctf_clock_get_offset_s") bt_ctf_clock_get_offset_s(struct bt_ctf_clock *clock);
 %rename("_bt_ctf_clock_set_offset_s") bt_ctf_clock_set_offset_s(struct bt_ctf_clock *clock, uint64_t offset_s);
+%rename("_bt_ctf_clock_get_offset") bt_ctf_clock_get_offset(struct bt_ctf_clock *clock);
 %rename("_bt_ctf_clock_set_offset") bt_ctf_clock_set_offset(struct bt_ctf_clock *clock, uint64_t offset);
+%rename("_bt_ctf_clock_get_is_absolute") bt_ctf_clock_get_is_absolute(struct bt_ctf_clock *clock);
 %rename("_bt_ctf_clock_set_is_absolute") bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock, int is_absolute);
+%rename("_bt_ctf_clock_get_time") bt_ctf_clock_get_time(struct bt_ctf_clock *clock);
 %rename("_bt_ctf_clock_set_time") bt_ctf_clock_set_time(struct bt_ctf_clock *clock, uint64_t time);
 %rename("_bt_ctf_clock_get") bt_ctf_clock_get(struct bt_ctf_clock *clock);
 %rename("_bt_ctf_clock_put") bt_ctf_clock_put(struct bt_ctf_clock *clock);
 
 struct bt_ctf_clock *bt_ctf_clock_create(const char *name);
+const char *bt_ctf_clock_get_name(struct bt_ctf_clock *clock);
+const char *bt_ctf_clock_get_description(struct bt_ctf_clock *clock);
 int bt_ctf_clock_set_description(struct bt_ctf_clock *clock, const char *desc);
+uint64_t bt_ctf_clock_get_frequency(struct bt_ctf_clock *clock);
 int bt_ctf_clock_set_frequency(struct bt_ctf_clock *clock, uint64_t freq);
+uint64_t bt_ctf_clock_get_precision(struct bt_ctf_clock *clock);
 int bt_ctf_clock_set_precision(struct bt_ctf_clock *clock, uint64_t precision);
+uint64_t bt_ctf_clock_get_offset_s(struct bt_ctf_clock *clock);
 int bt_ctf_clock_set_offset_s(struct bt_ctf_clock *clock, uint64_t offset_s);
+uint64_t bt_ctf_clock_get_offset(struct bt_ctf_clock *clock);
 int bt_ctf_clock_set_offset(struct bt_ctf_clock *clock, uint64_t offset);
+int bt_ctf_clock_get_is_absolute(struct bt_ctf_clock *clock);
 int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock, int is_absolute);
+uint64_t bt_ctf_clock_get_time(struct bt_ctf_clock *clock);
 int bt_ctf_clock_set_time(struct bt_ctf_clock *clock, uint64_t time);
 void bt_ctf_clock_get(struct bt_ctf_clock *clock);
 void bt_ctf_clock_put(struct bt_ctf_clock *clock);
@@ -1110,46 +1302,108 @@ void bt_ctf_clock_put(struct bt_ctf_clock *clock);
                ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
 */
 %rename("_bt_ctf_field_type_integer_create") bt_ctf_field_type_integer_create(unsigned int size);
+%rename("_bt_ctf_field_type_integer_get_size") bt_ctf_field_type_integer_get_size(struct bt_ctf_field_type *integer);
+%rename("_bt_ctf_field_type_integer_get_signed") bt_ctf_field_type_integer_get_signed(struct bt_ctf_field_type *integer);
 %rename("_bt_ctf_field_type_integer_set_signed") bt_ctf_field_type_integer_set_signed(struct bt_ctf_field_type *integer, int is_signed);
+%rename("_bt_ctf_field_type_integer_get_base") bt_ctf_field_type_integer_get_base(struct bt_ctf_field_type *integer);
 %rename("_bt_ctf_field_type_integer_set_base") bt_ctf_field_type_integer_set_base(struct bt_ctf_field_type *integer, enum bt_ctf_integer_base base);
+%rename("_bt_ctf_field_type_integer_get_encoding") bt_ctf_field_type_integer_get_encoding(struct bt_ctf_field_type *integer);
 %rename("_bt_ctf_field_type_integer_set_encoding") bt_ctf_field_type_integer_set_encoding(struct bt_ctf_field_type *integer, enum ctf_string_encoding encoding);
 %rename("_bt_ctf_field_type_enumeration_create") bt_ctf_field_type_enumeration_create(struct bt_ctf_field_type *integer_container_type);
-%rename("_bt_ctf_field_type_enumeration_add_mapping") bt_ctf_field_type_enumeration_add_mapping(struct bt_ctf_field_type *enumeration, const char *string, int64_t range_start, int64_t range_end);
+%rename("_bt_ctf_field_type_enumeration_get_container_type") bt_ctf_field_type_enumeration_get_container_type(struct bt_ctf_field_type *enumeration);
+%rename("_bt_ctf_field_type_enumeration_add_mapping") bt_ctf_field_type_enumeration_add_mapping(struct bt_ctf_field_type *enumeration, const char *name, int64_t range_start, int64_t range_end);
+%rename("_bt_ctf_field_type_enumeration_add_mapping_unsigned") bt_ctf_field_type_enumeration_add_mapping_unsigned(struct bt_ctf_field_type *enumeration, const char *name, uint64_t range_start, uint64_t range_end);
+%rename("_bt_ctf_field_type_enumeration_get_mapping_count") bt_ctf_field_type_enumeration_get_mapping_count(struct bt_ctf_field_type *enumeration);
+%rename("_bt_ctf_field_type_enumeration_get_mapping") bt_ctf_field_type_enumeration_get_mapping(struct bt_ctf_field_type *enumeration, size_t index, const char **name, int64_t *range_start, int64_t *range_end);
+%rename("_bt_ctf_field_type_enumeration_get_mapping_unsigned") bt_ctf_field_type_enumeration_get_mapping_unsigned(struct bt_ctf_field_type *enumeration, size_t index, const char **name, uint64_t *range_start, uint64_t *range_end);
+%rename("_bt_ctf_field_type_enumeration_get_mapping_index_by_name") bt_ctf_field_type_enumeration_get_mapping_index_by_name(struct bt_ctf_field_type *enumeration, const char *name, size_t *index);
+%rename("_bt_ctf_field_type_enumeration_get_mapping_index_by_value") bt_ctf_field_type_enumeration_get_mapping_index_by_value(struct bt_ctf_field_type *enumeration, int64_t value, size_t *index);
+%rename("_bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value") bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(struct bt_ctf_field_type *enumeration, uint64_t value, size_t *index);
 %rename("_bt_ctf_field_type_floating_point_create") bt_ctf_field_type_floating_point_create(void);
+%rename("_bt_ctf_field_type_floating_point_get_exponent_digits") bt_ctf_field_type_floating_point_get_exponent_digits(struct bt_ctf_field_type *floating_point);
 %rename("_bt_ctf_field_type_floating_point_set_exponent_digits") bt_ctf_field_type_floating_point_set_exponent_digits(struct bt_ctf_field_type *floating_point, unsigned int exponent_digits);
+%rename("_bt_ctf_field_type_floating_point_get_mantissa_digits") bt_ctf_field_type_floating_point_get_mantissa_digits(struct bt_ctf_field_type *floating_point);
 %rename("_bt_ctf_field_type_floating_point_set_mantissa_digits") bt_ctf_field_type_floating_point_set_mantissa_digits(struct bt_ctf_field_type *floating_point, unsigned int mantissa_digits);
 %rename("_bt_ctf_field_type_structure_create") bt_ctf_field_type_structure_create(void);
 %rename("_bt_ctf_field_type_structure_add_field") bt_ctf_field_type_structure_add_field(struct bt_ctf_field_type *structure, struct bt_ctf_field_type *field_type, const char *field_name);
+%rename("_bt_ctf_field_type_structure_get_field_count") bt_ctf_field_type_structure_get_field_count(struct bt_ctf_field_type *structure);
+%rename("_bt_ctf_field_type_structure_get_field") bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *structure, const char **field_name, struct bt_ctf_field_type **field_type, size_t index);
+%rename("_bt_ctf_field_type_structure_get_field_type_by_name") bt_ctf_field_type_structure_get_field_type_by_name(struct bt_ctf_field_type *structure, const char *field_name);
 %rename("_bt_ctf_field_type_variant_create") bt_ctf_field_type_variant_create(struct bt_ctf_field_type *enum_tag, const char *tag_name);
+%rename("_bt_ctf_field_type_variant_get_tag_type") bt_ctf_field_type_variant_get_tag_type(struct bt_ctf_field_type *variant);
+%rename("_bt_ctf_field_type_variant_get_tag_name") bt_ctf_field_type_variant_get_tag_name(struct bt_ctf_field_type *variant);
 %rename("_bt_ctf_field_type_variant_add_field") bt_ctf_field_type_variant_add_field(struct bt_ctf_field_type *variant, struct bt_ctf_field_type *field_type, const char *field_name);
+%rename("_bt_ctf_field_type_variant_get_field_type_by_name") bt_ctf_field_type_variant_get_field_type_by_name(struct bt_ctf_field_type *variant, const char *field_name);
+%rename("_bt_ctf_field_type_variant_get_field_type_from_tag") bt_ctf_field_type_variant_get_field_type_from_tag(struct bt_ctf_field_type *variant, struct bt_ctf_field *tag);
+%rename("_bt_ctf_field_type_variant_get_field_count") bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *variant);
+%rename("_bt_ctf_field_type_variant_get_field") bt_ctf_field_type_variant_get_field(struct bt_ctf_field_type *variant, const char **field_name, struct bt_ctf_field_type **field_type, size_t index);
 %rename("_bt_ctf_field_type_array_create") bt_ctf_field_type_array_create(struct bt_ctf_field_type *element_type, unsigned int length);
+%rename("_bt_ctf_field_type_array_get_element_type") bt_ctf_field_type_array_get_element_type(struct bt_ctf_field_type *array);
+%rename("_bt_ctf_field_type_array_get_length") bt_ctf_field_type_array_get_length(struct bt_ctf_field_type *array);
 %rename("_bt_ctf_field_type_sequence_create") bt_ctf_field_type_sequence_create(struct bt_ctf_field_type *element_type, const char *length_field_name);
+%rename("_bt_ctf_field_type_sequence_get_element_type") bt_ctf_field_type_sequence_get_element_type(struct bt_ctf_field_type *sequence);
+%rename("_bt_ctf_field_type_sequence_get_length_field_name") bt_ctf_field_type_sequence_get_length_field_name(struct bt_ctf_field_type *sequence);
 %rename("_bt_ctf_field_type_string_create") bt_ctf_field_type_string_create(void);
-%rename("_bt_ctf_field_type_string_set_encoding") bt_ctf_field_type_string_set_encoding(struct bt_ctf_field_type *string, enum ctf_string_encoding encoding);
+%rename("_bt_ctf_field_type_string_get_encoding") bt_ctf_field_type_string_get_encoding(struct bt_ctf_field_type *string_type);
+%rename("_bt_ctf_field_type_string_set_encoding") bt_ctf_field_type_string_set_encoding(struct bt_ctf_field_type *string_type, enum ctf_string_encoding encoding);
+%rename("_bt_ctf_field_type_get_alignment") bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type);
 %rename("_bt_ctf_field_type_set_alignment") bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *type, unsigned int alignment);
+%rename("_bt_ctf_field_type_get_byte_order") bt_ctf_field_type_get_byte_order(struct bt_ctf_field_type *type);
 %rename("_bt_ctf_field_type_set_byte_order") bt_ctf_field_type_set_byte_order(struct bt_ctf_field_type *type, enum bt_ctf_byte_order byte_order);
+%rename("_bt_ctf_field_type_get_type_id") bt_ctf_field_type_get_type_id(struct bt_ctf_field_type *type);
 %rename("_bt_ctf_field_type_get") bt_ctf_field_type_get(struct bt_ctf_field_type *type);
 %rename("_bt_ctf_field_type_put") bt_ctf_field_type_put(struct bt_ctf_field_type *type);
 
 struct bt_ctf_field_type *bt_ctf_field_type_integer_create(unsigned int size);
+int bt_ctf_field_type_integer_get_size(struct bt_ctf_field_type *integer);
+int bt_ctf_field_type_integer_get_signed(struct bt_ctf_field_type *integer);
 int bt_ctf_field_type_integer_set_signed(struct bt_ctf_field_type *integer, int is_signed);
+enum bt_ctf_integer_base bt_ctf_field_type_integer_get_base(struct bt_ctf_field_type *integer);
 int bt_ctf_field_type_integer_set_base(struct bt_ctf_field_type *integer, enum bt_ctf_integer_base base);
+enum ctf_string_encoding bt_ctf_field_type_integer_get_encoding(struct bt_ctf_field_type *integer);
 int bt_ctf_field_type_integer_set_encoding(struct bt_ctf_field_type *integer, enum ctf_string_encoding encoding);
 struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create(struct bt_ctf_field_type *integer_container_type);
-int bt_ctf_field_type_enumeration_add_mapping(struct bt_ctf_field_type *enumeration, const char *string, int64_t range_start, int64_t range_end);
+struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_type(struct bt_ctf_field_type *enumeration);
+int bt_ctf_field_type_enumeration_add_mapping(struct bt_ctf_field_type *enumeration, const char *name, int64_t range_start, int64_t range_end);
+int bt_ctf_field_type_enumeration_add_mapping_unsigned(struct bt_ctf_field_type *enumeration, const char *name, uint64_t range_start, uint64_t range_end);
+int64_t bt_ctf_field_type_enumeration_get_mapping_count(struct bt_ctf_field_type *enumeration);
+int bt_ctf_field_type_enumeration_get_mapping(struct bt_ctf_field_type *enumeration, size_t index, const char **OUTPUT, int64_t *OUTPUT, int64_t *OUTPUT);
+int bt_ctf_field_type_enumeration_get_mapping_unsigned(struct bt_ctf_field_type *enumeration, size_t index, const char **OUTPUT, uint64_t *OUTPUT, uint64_t *OUTPUT);
+int bt_ctf_field_type_enumeration_get_mapping_index_by_name(struct bt_ctf_field_type *enumeration, const char *name, size_t *OUTPUT);
+int bt_ctf_field_type_enumeration_get_mapping_index_by_value(struct bt_ctf_field_type *enumeration, int64_t value, size_t *OUTPUT);
+int bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(struct bt_ctf_field_type *enumeration, uint64_t value, size_t *OUTPUT);
 struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void);
+int bt_ctf_field_type_floating_point_get_exponent_digits(struct bt_ctf_field_type *floating_point);
 int bt_ctf_field_type_floating_point_set_exponent_digits(struct bt_ctf_field_type *floating_point, unsigned int exponent_digits);
+int bt_ctf_field_type_floating_point_get_mantissa_digits(struct bt_ctf_field_type *floating_point);
 int bt_ctf_field_type_floating_point_set_mantissa_digits(struct bt_ctf_field_type *floating_point, unsigned int mantissa_digits);
 struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void);
 int bt_ctf_field_type_structure_add_field(struct bt_ctf_field_type *structure, struct bt_ctf_field_type *field_type, const char *field_name);
+int64_t bt_ctf_field_type_structure_get_field_count(struct bt_ctf_field_type *structure);
+int bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *structure, const char **OUTPUT, struct bt_ctf_field_type **OUTPUT, size_t index);
+struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name(struct bt_ctf_field_type *structure, const char *field_name);
 struct bt_ctf_field_type *bt_ctf_field_type_variant_create(struct bt_ctf_field_type *enum_tag, const char *tag_name);
+struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_type(struct bt_ctf_field_type *variant);
+const char *bt_ctf_field_type_variant_get_tag_name(struct bt_ctf_field_type *variant);
 int bt_ctf_field_type_variant_add_field(struct bt_ctf_field_type *variant, struct bt_ctf_field_type *field_type, const char *field_name);
+struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_by_name(struct bt_ctf_field_type *variant, const char *field_name);
+struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag(struct bt_ctf_field_type *variant, struct bt_ctf_field *tag);
+int64_t bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *variant);
+int bt_ctf_field_type_variant_get_field(struct bt_ctf_field_type *variant, const char **OUTPUT, struct bt_ctf_field_type **OUTPUT, size_t index);
 struct bt_ctf_field_type *bt_ctf_field_type_array_create(struct bt_ctf_field_type *element_type, unsigned int length);
+struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_type(struct bt_ctf_field_type *array);
+int64_t bt_ctf_field_type_array_get_length(struct bt_ctf_field_type *array);
 struct bt_ctf_field_type *bt_ctf_field_type_sequence_create(struct bt_ctf_field_type *element_type, const char *length_field_name);
+struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_type(struct bt_ctf_field_type *sequence);
+const char *bt_ctf_field_type_sequence_get_length_field_name(struct bt_ctf_field_type *sequence);
 struct bt_ctf_field_type *bt_ctf_field_type_string_create(void);
-int bt_ctf_field_type_string_set_encoding(struct bt_ctf_field_type *string, enum ctf_string_encoding encoding);
+enum ctf_string_encoding bt_ctf_field_type_string_get_encoding(struct bt_ctf_field_type *string_type);
+int bt_ctf_field_type_string_set_encoding(struct bt_ctf_field_type *string_type, enum ctf_string_encoding encoding);
+int bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type);
 int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *type, unsigned int alignment);
+enum bt_ctf_byte_order bt_ctf_field_type_get_byte_order(struct bt_ctf_field_type *type);
 int bt_ctf_field_type_set_byte_order(struct bt_ctf_field_type *type, enum bt_ctf_byte_order byte_order);
+enum ctf_type_id bt_ctf_field_type_get_type_id(struct bt_ctf_field_type *type);
 void bt_ctf_field_type_get(struct bt_ctf_field_type *type);
 void bt_ctf_field_type_put(struct bt_ctf_field_type *type);
 
@@ -1160,28 +1414,42 @@ void bt_ctf_field_type_put(struct bt_ctf_field_type *type);
 %rename("_bt_ctf_field_create") bt_ctf_field_create(struct bt_ctf_field_type *type);
 %rename("_bt_ctf_field_structure_get_field") bt_ctf_field_structure_get_field(struct bt_ctf_field *structure, const char *name);
 %rename("_bt_ctf_field_array_get_field") bt_ctf_field_array_get_field(struct bt_ctf_field *array, uint64_t index);
+%rename("_bt_ctf_field_sequence_get_length") bt_ctf_field_sequence_get_length(struct bt_ctf_field *sequence);
 %rename("_bt_ctf_field_sequence_set_length") bt_ctf_field_sequence_set_length(struct bt_ctf_field *sequence, struct bt_ctf_field *length_field);
 %rename("_bt_ctf_field_sequence_get_field") bt_ctf_field_sequence_get_field(struct bt_ctf_field *sequence, uint64_t index);
 %rename("_bt_ctf_field_variant_get_field") bt_ctf_field_variant_get_field(struct bt_ctf_field *variant, struct bt_ctf_field *tag);
 %rename("_bt_ctf_field_enumeration_get_container") bt_ctf_field_enumeration_get_container(struct bt_ctf_field *enumeration);
+%rename("_bt_ctf_field_enumeration_get_mapping_name") bt_ctf_field_enumeration_get_mapping_name(struct bt_ctf_field *enumeration);
+%rename("_bt_ctf_field_signed_integer_get_value") bt_ctf_field_signed_integer_get_value(struct bt_ctf_field *integer, int64_t *value);
 %rename("_bt_ctf_field_signed_integer_set_value") bt_ctf_field_signed_integer_set_value(struct bt_ctf_field *integer, int64_t value);
+%rename("_bt_ctf_field_unsigned_integer_get_value") bt_ctf_field_unsigned_integer_get_value(struct bt_ctf_field *integer, uint64_t *value);
 %rename("_bt_ctf_field_unsigned_integer_set_value") bt_ctf_field_unsigned_integer_set_value(struct bt_ctf_field *integer, uint64_t value);
+%rename("_bt_ctf_field_floating_point_get_value") bt_ctf_field_floating_point_get_value(struct bt_ctf_field *floating_point, double *value);
 %rename("_bt_ctf_field_floating_point_set_value") bt_ctf_field_floating_point_set_value(struct bt_ctf_field *floating_point, double value);
-%rename("_bt_ctf_field_string_set_value") bt_ctf_field_string_set_value(struct bt_ctf_field *string, const char *value);
+%rename("_bt_ctf_field_string_get_value") bt_ctf_field_string_get_value(struct bt_ctf_field *string_field);
+%rename("_bt_ctf_field_string_set_value") bt_ctf_field_string_set_value(struct bt_ctf_field *string_field, const char *value);
+%rename("_bt_ctf_field_get_type") bt_ctf_field_get_type(struct bt_ctf_field *field);
 %rename("_bt_ctf_field_get") bt_ctf_field_get(struct bt_ctf_field *field);
 %rename("_bt_ctf_field_put") bt_ctf_field_put(struct bt_ctf_field *field);
 
 struct bt_ctf_field *bt_ctf_field_create(struct bt_ctf_field_type *type);
 struct bt_ctf_field *bt_ctf_field_structure_get_field(struct bt_ctf_field *structure, const char *name);
 struct bt_ctf_field *bt_ctf_field_array_get_field(struct bt_ctf_field *array, uint64_t index);
+struct bt_ctf_field * bt_ctf_field_sequence_get_length(struct bt_ctf_field *sequence);
 int bt_ctf_field_sequence_set_length(struct bt_ctf_field *sequence, struct bt_ctf_field *length_field);
 struct bt_ctf_field *bt_ctf_field_sequence_get_field(struct bt_ctf_field *sequence, uint64_t index);
 struct bt_ctf_field *bt_ctf_field_variant_get_field(struct bt_ctf_field *variant, struct bt_ctf_field *tag);
 struct bt_ctf_field *bt_ctf_field_enumeration_get_container(struct bt_ctf_field *enumeration);
+const char *bt_ctf_field_enumeration_get_mapping_name(struct bt_ctf_field *enumeration);
+int bt_ctf_field_signed_integer_get_value(struct bt_ctf_field *integer, int64_t *OUTPUT);
 int bt_ctf_field_signed_integer_set_value(struct bt_ctf_field *integer, int64_t value);
+int bt_ctf_field_unsigned_integer_get_value(struct bt_ctf_field *integer, uint64_t *OUTPUT);
 int bt_ctf_field_unsigned_integer_set_value(struct bt_ctf_field *integer, uint64_t value);
+int bt_ctf_field_floating_point_get_value(struct bt_ctf_field *floating_point, double *OUTPUT);
 int bt_ctf_field_floating_point_set_value(struct bt_ctf_field *floating_point, double value);
-int bt_ctf_field_string_set_value(struct bt_ctf_field *string, const char *value);
+const char *bt_ctf_field_string_get_value(struct bt_ctf_field *string_field);
+int bt_ctf_field_string_set_value(struct bt_ctf_field *string_field, const char *value);
+struct bt_ctf_field_type *bt_ctf_field_get_type(struct bt_ctf_field *field);
 void bt_ctf_field_get(struct bt_ctf_field *field);
 void bt_ctf_field_put(struct bt_ctf_field *field);
 
@@ -1190,22 +1458,42 @@ void bt_ctf_field_put(struct bt_ctf_field *field);
                ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
 */
 %rename("_bt_ctf_event_class_create") bt_ctf_event_class_create(const char *name);
+%rename("_bt_ctf_event_class_get_name") bt_ctf_event_class_get_name(struct bt_ctf_event_class *event_class);
+%rename("_bt_ctf_event_class_get_id") bt_ctf_event_class_get_id(struct bt_ctf_event_class *event_class);
+%rename("_bt_ctf_event_class_set_id") bt_ctf_event_class_set_id(struct bt_ctf_event_class *event_class, uint32_t id);
+%rename("_bt_ctf_event_class_get_stream_class") bt_ctf_event_class_get_stream_class(struct bt_ctf_event_class *event_class);
 %rename("_bt_ctf_event_class_add_field") bt_ctf_event_class_add_field(struct bt_ctf_event_class *event_class, struct bt_ctf_field_type *type, const char *name);
+%rename("_bt_ctf_event_class_get_field_count") bt_ctf_event_class_get_field_count(struct bt_ctf_event_class *event_class);
+%rename("_bt_ctf_event_class_get_field") bt_ctf_event_class_get_field(struct bt_ctf_event_class *event_class, const char **field_name, struct bt_ctf_field_type **field_type, size_t index);
+%rename("_bt_ctf_event_class_get_field_by_name") bt_ctf_event_class_get_field_by_name(struct bt_ctf_event_class *event_class, const char *name);
 %rename("_bt_ctf_event_class_get") bt_ctf_event_class_get(struct bt_ctf_event_class *event_class);
 %rename("_bt_ctf_event_class_put") bt_ctf_event_class_put(struct bt_ctf_event_class *event_class);
 %rename("_bt_ctf_event_create") bt_ctf_event_create(struct bt_ctf_event_class *event_class);
-%rename("_bt_ctf_event_set_payload") bt_ctf_event_set_payload(struct bt_ctf_event *event, const char *name, struct bt_ctf_field *value);
+%rename("_bt_ctf_event_get_class") bt_ctf_event_get_class(struct bt_ctf_event *event);
+%rename("_bt_ctf_event_get_clock") bt_ctf_event_get_clock(struct bt_ctf_event *event);
 %rename("_bt_ctf_event_get_payload") bt_ctf_event_get_payload(struct bt_ctf_event *event, const char *name);
+%rename("_bt_ctf_event_set_payload") bt_ctf_event_set_payload(struct bt_ctf_event *event, const char *name, struct bt_ctf_field *value);
+%rename("_bt_ctf_event_get_payload_by_index") bt_ctf_event_get_payload_by_index(struct bt_ctf_event *event, size_t index);
 %rename("_bt_ctf_event_get") bt_ctf_event_get(struct bt_ctf_event *event);
 %rename("_bt_ctf_event_put") bt_ctf_event_put(struct bt_ctf_event *event);
 
 struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name);
+const char *bt_ctf_event_class_get_name(struct bt_ctf_event_class *event_class);
+int64_t bt_ctf_event_class_get_id(struct bt_ctf_event_class *event_class);
+int bt_ctf_event_class_set_id(struct bt_ctf_event_class *event_class, uint32_t id);
+struct bt_ctf_stream_class *bt_ctf_event_class_get_stream_class(struct bt_ctf_event_class *event_class);
 int bt_ctf_event_class_add_field(struct bt_ctf_event_class *event_class, struct bt_ctf_field_type *type, const char *name);
+int64_t bt_ctf_event_class_get_field_count(struct bt_ctf_event_class *event_class);
+int bt_ctf_event_class_get_field(struct bt_ctf_event_class *event_class, const char **field_name, struct bt_ctf_field_type **field_type, size_t index);
+struct bt_ctf_field_type *bt_ctf_event_class_get_field_by_name(struct bt_ctf_event_class *event_class, const char *name);
 void bt_ctf_event_class_get(struct bt_ctf_event_class *event_class);
 void bt_ctf_event_class_put(struct bt_ctf_event_class *event_class);
 struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class);
-int bt_ctf_event_set_payload(struct bt_ctf_event *event, const char *name, struct bt_ctf_field *value);
+struct bt_ctf_event_class *bt_ctf_event_get_class(struct bt_ctf_event *event);
+struct bt_ctf_clock *bt_ctf_event_get_clock(struct bt_ctf_event *event);
 struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event, const char *name);
+int bt_ctf_event_set_payload(struct bt_ctf_event *event, const char *name, struct bt_ctf_field *value);
+struct bt_ctf_field *bt_ctf_event_get_payload_by_index(struct bt_ctf_event *event, size_t index);
 void bt_ctf_event_get(struct bt_ctf_event *event);
 void bt_ctf_event_put(struct bt_ctf_event *event);
 
@@ -1214,10 +1502,18 @@ void bt_ctf_event_put(struct bt_ctf_event *event);
                ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
 */
 %rename("_bt_ctf_stream_class_create") bt_ctf_stream_class_create(const char *name);
+%rename("_bt_ctf_stream_class_get_name") bt_ctf_stream_class_get_name(struct bt_ctf_stream_class *stream_class);
+%rename("_bt_ctf_stream_class_get_clock") bt_ctf_stream_class_get_clock(struct bt_ctf_stream_class *stream_class);
 %rename("_bt_ctf_stream_class_set_clock") bt_ctf_stream_class_set_clock(struct bt_ctf_stream_class *stream_class, struct bt_ctf_clock *clock);
+%rename("_bt_ctf_stream_class_get_id") bt_ctf_stream_class_get_id(struct bt_ctf_stream_class *stream_class);
+%rename("_bt_ctf_stream_class_set_id") bt_ctf_stream_class_set_id(struct bt_ctf_stream_class *stream_class, uint32_t id);
 %rename("_bt_ctf_stream_class_add_event_class") bt_ctf_stream_class_add_event_class(struct bt_ctf_stream_class *stream_class, struct bt_ctf_event_class *event_class);
+%rename("_bt_ctf_stream_class_get_event_class_count") bt_ctf_stream_class_get_event_class_count(struct bt_ctf_stream_class *stream_class);
+%rename("_bt_ctf_stream_class_get_event_class") bt_ctf_stream_class_get_event_class(struct bt_ctf_stream_class *stream_class, size_t index);
+%rename("_bt_ctf_stream_class_get_event_class_by_name") bt_ctf_stream_class_get_event_class_by_name(struct bt_ctf_stream_class *stream_class, const char *name);
 %rename("_bt_ctf_stream_class_get") bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class);
 %rename("_bt_ctf_stream_class_put") bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class);
+%rename("_bt_ctf_stream_get_discarded_events_count") bt_ctf_stream_get_discarded_events_count(struct bt_ctf_stream *stream, uint64_t *count);
 %rename("_bt_ctf_stream_append_discarded_events") bt_ctf_stream_append_discarded_events(struct bt_ctf_stream *stream, uint64_t event_count);
 %rename("_bt_ctf_stream_append_event") bt_ctf_stream_append_event(struct bt_ctf_stream *stream, struct bt_ctf_event *event);
 %rename("_bt_ctf_stream_flush") bt_ctf_stream_flush(struct bt_ctf_stream *stream);
@@ -1225,10 +1521,18 @@ void bt_ctf_event_put(struct bt_ctf_event *event);
 %rename("_bt_ctf_stream_put") bt_ctf_stream_put(struct bt_ctf_stream *stream);
 
 struct bt_ctf_stream_class *bt_ctf_stream_class_create(const char *name);
+const char *bt_ctf_stream_class_get_name(struct bt_ctf_stream_class *stream_class);
+struct bt_ctf_clock *bt_ctf_stream_class_get_clock(struct bt_ctf_stream_class *stream_class);
 int bt_ctf_stream_class_set_clock(struct bt_ctf_stream_class *stream_class, struct bt_ctf_clock *clock);
+int64_t bt_ctf_stream_class_get_id(struct bt_ctf_stream_class *stream_class);
+int bt_ctf_stream_class_set_id(struct bt_ctf_stream_class *stream_class, uint32_t id);
 int bt_ctf_stream_class_add_event_class(struct bt_ctf_stream_class *stream_class, struct bt_ctf_event_class *event_class);
+int64_t bt_ctf_stream_class_get_event_class_count(struct bt_ctf_stream_class *stream_class);
+struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class(struct bt_ctf_stream_class *stream_class, size_t index);
+struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_name(struct bt_ctf_stream_class *stream_class, const char *name);
 void bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class);
 void bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class);
+int bt_ctf_stream_get_discarded_events_count(struct bt_ctf_stream *stream, uint64_t *OUTPUT);
 void bt_ctf_stream_append_discarded_events(struct bt_ctf_stream *stream, uint64_t event_count);
 int bt_ctf_stream_append_event(struct bt_ctf_stream *stream, struct bt_ctf_event *event);
 int bt_ctf_stream_flush(struct bt_ctf_stream *stream);
@@ -1263,11 +1567,17 @@ void bt_ctf_writer_put(struct bt_ctf_writer *writer);
 %pythoncode %{
 
 class CTFWriter:
-       class ByteOrder:
-               BYTE_ORDER_NATIVE = 0
-               BYTE_ORDER_LITTLE_ENDIAN = 1
-               BYTE_ORDER_BIG_ENDIAN = 2
-               BYTE_ORDER_NETWORK = 3
+       # Used to compare to -1ULL in error checks
+       _MAX_UINT64 = 0xFFFFFFFFFFFFFFFF
+
+       """
+       Enumeration mapping class. start and end values are inclusive.
+       """
+       class EnumerationMapping:
+               def __init__(self, name, start, end):
+                       self.name = name
+                       self.start = start
+                       self.end = end
 
        class Clock:
                def __init__(self, name):
@@ -1278,68 +1588,154 @@ class CTFWriter:
                def __del__(self):
                        _bt_ctf_clock_put(self._c)
 
+               """
+               Get the clock's name.
+               """
+               @property
+               def name(self):
+                       name = _bt_ctf_clock_get_name(self._c)
+                       if name is None:
+                               raise ValueError("Invalid clock instance.")
+                       return name
+
+               """
+               Get the clock's description. None if unset.
+               """
+               @property
+               def description(self):
+                       return _bt_ctf_clock_get_description(self._c)
+
                """
                Set the clock's description. The description appears in the clock's TSDL
                meta-data.
                """
-               def set_description(self, desc):
-                       ret = _bt_ctf_clock_set_description(self._c, desc)
+               @description.setter
+               def description(self, desc):
+                       ret = _bt_ctf_clock_set_description(self._c, str(desc))
                        if ret < 0:
                                raise ValueError("Invalid clock description.")
 
+               """
+               Get the clock's frequency (Hz).
+               """
+               @property
+               def frequency(self):
+                       freq = _bt_ctf_clock_get_frequency(self._c)
+                       if freq == CTFWriter._MAX_UINT64:
+                               raise ValueError("Invalid clock instance")
+                       return freq
+
                """
                Set the clock's frequency (Hz).
                """
-               def set_frequency(self, freq):
+               @frequency.setter
+               def frequency(self, freq):
                        ret = _bt_ctf_clock_set_frequency(self._c, freq)
                        if ret < 0:
                                raise ValueError("Invalid frequency value.")
 
+               """
+               Get the clock's precision (in clock ticks).
+               """
+               @property
+               def precision(self):
+                       precision = _bt_ctf_clock_get_precision(self._c)
+                       if precision == CTFWriter._MAX_UINT64:
+                               raise ValueError("Invalid clock instance")
+                       return precision
+
                """
                Set the clock's precision (in clock ticks).
                """
-               def set_precision(self, precision):
+               @precision.setter
+               def precision(self, precision):
                        ret = _bt_ctf_clock_set_precision(self._c, precision)
 
+               """
+               Get the clock's offset in seconds from POSIX.1 Epoch.
+               """
+               @property
+               def offset_seconds(self):
+                       offset_s = _bt_ctf_clock_get_offset_s(self._c)
+                       if offset_s == CTFWriter._MAX_UINT64:
+                               raise ValueError("Invalid clock instance")
+                       return offset_s
+
                """
                Set the clock's offset in seconds from POSIX.1 Epoch.
                """
-               def set_offset_seconds(self, offset_s):
+               @offset_seconds.setter
+               def offset_seconds(self, offset_s):
                        ret = _bt_ctf_clock_set_offset_s(self._c, offset_s)
                        if ret < 0:
                                raise ValueError("Invalid offset value.")
 
+               """
+               Get the clock's offset in ticks from POSIX.1 Epoch + offset in seconds.
+               """
+               @property
+               def offset(self):
+                       offset = _bt_ctf_clock_get_offset(self._c)
+                       if offset == CTFWriter._MAX_UINT64:
+                               raise ValueError("Invalid clock instance")
+                       return offset
+
                """
                Set the clock's offset in ticks from POSIX.1 Epoch + offset in seconds.
                """
-               def set_offset_seconds(self, offset):
+               @offset.setter
+               def offset(self, offset):
                        ret = _bt_ctf_clock_set_offset(self._c, offset)
                        if ret < 0:
                                raise ValueError("Invalid offset value.")
 
+               """
+               Get a clock's absolute attribute. A clock is absolute if the clock
+               is a global reference across the trace's other clocks.
+               """
+               @property
+               def absolute(self):
+                       is_absolute = _bt_ctf_clock_get_is_absolute(self._c)
+                       if is_absolute == -1:
+                               raise ValueError("Invalid clock instance")
+                       return False if is_absolute == 0 else True
+
                """
                Set a clock's absolute attribute. A clock is absolute if the clock
                is a global reference across the trace's other clocks.
                """
-               def set_is_absolute(self, is_absolute):
-                       ret = _bt_ctf_clock_set_is_absolute(self._c, is_absolute)
+               @absolute.setter
+               def absolute(self, is_absolute):
+                       ret = _bt_ctf_clock_set_is_absolute(self._c, int(is_absolute))
                        if ret < 0:
                                raise ValueError("Could not set the clock's absolute attribute.")
 
+               """
+               Get the current time in nanoseconds since the clock's origin (offset and
+               offset_s attributes).
+               """
+               @property
+               def time(self):
+                       time = _bt_ctf_clock_get_time(self._c)
+                       if time == CTFWriter._MAX_UINT64:
+                               raise ValueError("Invalid clock instance")
+                       return time
+
                """
                Set the current time in nanoseconds since the clock's origin (offset and
                offset_s attributes). The clock's value will be sampled as events are
                appended to a stream.
                """
-               def set_time(self, time):
+               @time.setter
+               def time(self, time):
                        ret = _bt_ctf_clock_set_time(self._c, time)
                        if ret < 0:
                                raise ValueError("Invalid time value.")
 
-       class FieldType:
+       class FieldDeclaration:
                """
-               FieldType should not be instantiated directly. Please instantiate
-               one of the concrete FieldType classes.
+               FieldDeclaration should not be instantiated directly. Instantiate
+               one of the concrete FieldDeclaration classes.
                """
                class IntegerBase:
                        # These values are based on the bt_ctf_integer_base enum
@@ -1352,119 +1748,296 @@ class CTFWriter:
 
                def __init__(self):
                        if self._ft is None:
-                               raise ValueError("FieldType creation failed.")
+                               raise ValueError("FieldDeclaration creation failed.")
 
                def __del__(self):
                        _bt_ctf_field_type_put(self._ft)
 
+               @staticmethod
+               def _create_field_declaration_from_native_instance(native_field_declaration):
+                       type_dict = {
+                               CTFTypeId.INTEGER : CTFWriter.IntegerFieldDeclaration,
+                               CTFTypeId.FLOAT : CTFWriter.FloatFieldDeclaration,
+                               CTFTypeId.ENUM : CTFWriter.EnumerationFieldDeclaration,
+                               CTFTypeId.STRING : CTFWriter.StringFieldDeclaration,
+                               CTFTypeId.STRUCT : CTFWriter.StructureFieldDeclaration,
+                               CTFTypeId.VARIANT : CTFWriter.VariantFieldDeclaration,
+                               CTFTypeId.ARRAY : CTFWriter.ArrayFieldDeclaration,
+                               CTFTypeId.SEQUENCE : CTFWriter.SequenceFieldDeclaration
+                       }
+
+                       field_type_id = _bt_ctf_field_type_get_type_id(native_field_declaration)
+                       if field_type_id == CTFTypeId.UNKNOWN:
+                               raise TypeError("Invalid field instance")
+
+                       declaration = CTFWriter.Field.__new__(CTFWriter.Field)
+                       declaration._ft = native_field_declaration
+                       declaration.__class__ = type_dict[field_type_id]
+                       return declaration
+
+               """
+               Get the field declaration's alignment. Returns -1 on error.
+               """
+               @property
+               def alignment(self):
+                       return _bt_ctf_field_type_get_alignment(self._ft)
+
                """
-               Set the field type's alignment. Defaults to 1 (bit-aligned). However,
+               Set the field declaration's alignment. Defaults to 1 (bit-aligned). However,
                some types, such as structures and string, may impose other alignment
                constraints.
                """
-               def set_alignment(self, alignment):
+               @alignment.setter
+               def alignment(self, alignment):
                        ret = _bt_ctf_field_type_set_alignment(self._ft, alignment)
                        if ret < 0:
                                raise ValueError("Invalid alignment value.")
 
                """
-               Set the field type's byte order. Use constants defined in the ByteOrder
+               Get the field declaration's byte order. One of the ByteOrder's constant.
+               """
+               @property
+               def byte_order(self):
+                       return _bt_ctf_field_type_get_byte_order(self._ft)
+
+               """
+               Set the field declaration's byte order. Use constants defined in the ByteOrder
                class.
                """
-               def set_byte_order(self, byte_order):
+               @byte_order.setter
+               def byte_order(self, byte_order):
                        ret = _bt_ctf_field_type_set_byte_order(self._ft, byte_order)
                        if ret < 0:
                                raise ValueError("Could not set byte order value.")
 
-       class FieldTypeInteger(FieldType):
+       class IntegerFieldDeclaration(FieldDeclaration):
                """
-               Create a new integer field type of the given size.
+               Create a new integer field declaration of the given size.
                """
                def __init__(self, size):
                        self._ft = _bt_ctf_field_type_integer_create(size)
                        super().__init__()
 
                """
-               Set an integer type's signedness attribute.
+               Get an integer's size.
+               """
+               @property
+               def size(self):
+                       ret = _bt_ctf_field_type_integer_get_size(self._ft)
+                       if ret < 0:
+                               raise ValueError("Could not get Integer's size attribute.")
+                       else:
+                               return ret
+
+               """
+               Get an integer's signedness attribute.
                """
-               def set_signed(self, signed):
+               @property
+               def signed(self):
+                       ret = _bt_ctf_field_type_integer_get_signed(self._ft)
+                       if ret < 0:
+                               raise ValueError("Could not get Integer's signed attribute.")
+                       elif ret > 0:
+                               return True
+                       else:
+                               return False
+
+               """
+               Set an integer's signedness attribute.
+               """
+               @signed.setter
+               def signed(self, signed):
                        ret = _bt_ctf_field_type_integer_set_signed(self._ft, signed)
                        if ret < 0:
-                               raise ValueError("Could not set signed attribute.")
+                               raise ValueError("Could not set Integer's signed attribute.")
+
+               """
+               Get the integer's base used to pretty-print the resulting trace.
+               Returns a constant from the FieldDeclaration.IntegerBase class.
+               """
+               @property
+               def base(self):
+                       return _bt_ctf_field_type_integer_get_base(self._ft)
 
                """
-               Set the integer type's base used to pretty-print the resulting trace.
-               The base must be a constant of the IntegerBase class.
+               Set the integer's base used to pretty-print the resulting trace.
+               The base must be a constant of the FieldDeclarationIntegerBase class.
                """
-               def set_base(self, base):
+               @base.setter
+               def base(self, base):
                        ret = _bt_ctf_field_type_integer_set_base(self._ft, base)
                        if ret < 0:
-                               raise ValueError("Could not set base value.")
+                               raise ValueError("Could not set Integer's base.")
+
+               """
+               Get the integer's encoding (one of the constants of the
+               CTFStringEncoding class).
+               Returns a constant from the CTFStringEncoding class.
+               """
+               @property
+               def encoding(self):
+                       return _bt_ctf_field_type_integer_get_encoding(self._ft)
 
                """
                An integer encoding may be set to signal that the integer must be printed
                as a text character. Must be a constant from the CTFStringEncoding class.
                """
-               def set_encoding(self, encoding):
+               @encoding.setter
+               def encoding(self, encoding):
                        ret = _bt_ctf_field_type_integer_set_encoding(self._ft, encoding)
                        if ret < 0:
-                               raise ValueError("Could not set integer encoding.")
+                               raise ValueError("Could not set Integer's encoding.")
 
-       class FieldTypeEnumeration(FieldType):
+       class EnumerationFieldDeclaration(FieldDeclaration):
                """
-               Create a new enumeration field type with the given underlying type.
+               Create a new enumeration field declaration with the given underlying container type.
                """
                def __init__(self, integer_type):
-                       if integer_type is None or not isinstance(integer_type, CTFWriter.FieldTypeInteger):
+                       if integer_type is None or not isinstance(integer_type, CTFWriter.IntegerFieldDeclaration):
                                raise TypeError("Invalid integer container.")
 
                        self._ft = _bt_ctf_field_type_enumeration_create(integer_type._ft)
                        super().__init__()
 
+               """
+               Get the enumeration's underlying container type.
+               """
+               @property
+               def container(self):
+                       ret = _bt_ctf_field_type_enumeration_get_container_type(self._ft)
+                       if ret is None:
+                               raise TypeError("Invalid enumeration declaration")
+                       return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(ret)
+
                """
                Add a mapping to the enumeration. The range's values are inclusive.
                """
                def add_mapping(self, name, range_start, range_end):
-                       ret = _bt_ctf_field_type_enumeration_add_mapping(self._ft, name, range_start, range_end)
+                       if range_start < 0 or range_end < 0:
+                               ret = _bt_ctf_field_type_enumeration_add_mapping(self._ft, str(name), range_start, range_end)
+                       else:
+                               ret = _bt_ctf_field_type_enumeration_add_mapping_unsigned(self._ft, str(name), range_start, range_end)
+
+                       if ret < 0:
+                               raise ValueError("Could not add mapping to enumeration declaration.")
+
+               """
+               Generator returning instances of EnumerationMapping.
+               """
+               @property
+               def mappings(self):
+                       signed = self.container.signed
+
+                       count = _bt_ctf_field_type_enumeration_get_mapping_count(self._ft)
+                       for i in range(count):
+                               if signed:
+                                       ret = _bt_python_ctf_field_type_enumeration_get_mapping(self._ft, i)
+                               else:
+                                       ret = _bt_python_ctf_field_type_enumeration_get_mapping_unsigned(self._ft, i)
+
+                               if len(ret) != 3:
+                                       raise TypeError("Could not get Enumeration mapping at index {}".format(i))
+                               name, range_start, range_end = ret
+                               yield CTFWriter.EnumerationMapping(name, range_start, range_end)
+
+               """
+               Get a mapping by name (EnumerationMapping).
+               """
+               def get_mapping_by_name(self, name):
+                       ret, index = _bt_ctf_field_type_enumeration_get_mapping_index_by_name(self._ft, name);
+                       if ret < 0:
+                               return None
+
+                       if self.container.signed:
+                               ret = _bt_python_ctf_field_type_enumeration_get_mapping(self._ft, index)
+                       else:
+                               ret = _bt_python_ctf_field_type_enumeration_get_mapping_unsigned(self._ft, index)
+
+                       if len(ret) != 3:
+                               raise TypeError("Could not get Enumeration mapping at index {}".format(i))
+                       name, range_start, range_end = ret
+                       return CTFWriter.EnumerationMapping(name, range_start, range_end)
+
+               """
+               Get a mapping by value (EnumerationMapping).
+               """
+               def get_mapping_by_value(self, value):
+                       if value < 0:
+                               ret, index = _bt_ctf_field_type_enumeration_get_mapping_index_by_value(self._ft, value);
+                       else:
+                               ret, index = _bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(self._ft, value);
+
                        if ret < 0:
-                               raise ValueError("Could not add mapping to enumeration type.")
+                               return None
+
+                       if self.container.signed:
+                               ret = _bt_python_ctf_field_type_enumeration_get_mapping(self._ft, index)
+                       else:
+                               ret = _bt_python_ctf_field_type_enumeration_get_mapping_unsigned(self._ft, index)
 
-       class FieldTypeFloatingPoint(FieldType):
+                       if len(ret) != 3:
+                               raise TypeError("Could not get Enumeration mapping at index {}".format(i))
+                       name, range_start, range_end = ret
+                       return CTFWriter.EnumerationMapping(name, range_start, range_end)
+
+       class FloatFieldDeclaration(FieldDeclaration):
                FLT_EXP_DIG = 8
                DBL_EXP_DIG = 11
                FLT_MANT_DIG = 24
                DBL_MANT_DIG = 53
 
                """
-               Create a new floating point field type.
+               Create a new floating point field declaration.
                """
                def __init__(self):
                        self._ft = _bt_ctf_field_type_floating_point_create()
                        super().__init__()
 
                """
-               Set the number of exponent digits to use to store the floatingpoint field.
+               Get the number of exponent digits used to store the floating point field.
+               """
+               @property
+               def exponent_digits(self):
+                       ret = _bt_ctf_field_type_floating_point_get_exponent_digits(self._ft)
+                       if ret < 0:
+                               raise TypeError("Could not get Floating point exponent digit count")
+                       return ret
+
+               """
+               Set the number of exponent digits to use to store the floating point field.
                The only values currently supported are FLT_EXP_DIG and DBL_EXP_DIG which
                are defined as constants of this class.
                """
-               def set_exponent_digits(self, exponent_digits):
+               @exponent_digits.setter
+               def exponent_digits(self, exponent_digits):
                        ret = _bt_ctf_field_type_floating_point_set_exponent_digits(self._ft, exponent_digits)
                        if ret < 0:
                                raise ValueError("Could not set exponent digit count.")
 
                """
-               Set the numberof mantissa digits to use to store the floatingpoint field.
+               Get the number of mantissa digits used to store the floating point field.
+               """
+               @property
+               def mantissa_digits(self):
+                       ret = _bt_ctf_field_type_floating_point_get_mantissa_digits(self._ft)
+                       if ret < 0:
+                               raise TypeError("Could not get Floating point mantissa digit count")
+                       return ret
+
+               """
+               Set the number of mantissa digits to use to store the floating point field.
                The only values currently supported are FLT_MANT_DIG and DBL_MANT_DIG which
                are defined as constants of this class.
                """
-               def set_mantissa_digits(self, mantissa_digits):
+               @mantissa_digits.setter
+               def mantissa_digits(self, mantissa_digits):
                        ret = _bt_ctf_field_type_floating_point_set_mantissa_digits(self._ft, mantissa_digits)
                        if ret < 0:
                                raise ValueError("Could not set mantissa digit count.")
 
-       class FieldTypeStructure(FieldType):
+       class StructureFieldDeclaration(FieldDeclaration):
                """
-               Create a new structure field type.
+               Create a new structure field declaration.
                """
                def __init__(self):
                        self._ft = _bt_ctf_field_type_structure_create()
@@ -1474,57 +2047,197 @@ class CTFWriter:
                Add a field of type "field_type" to the structure.
                """
                def add_field(self, field_type, field_name):
-                       ret = _bt_ctf_field_type_structure_add_field(self._ft, field_type._ft, field_name)
+                       ret = _bt_ctf_field_type_structure_add_field(self._ft, field_type._ft, str(field_name))
                        if ret < 0:
                                raise ValueError("Could not add field to structure.")
 
-       class FieldTypeVariant(FieldType):
                """
-               Create a new variant field type.
+               Generator returning the structure's field as tuples of (field name, field declaration).
+               """
+               @property
+               def fields(self):
+                       count = _bt_ctf_field_type_structure_get_field_count(self._ft)
+                       if count < 0:
+                               raise TypeError("Could not get Structure field count")
+
+                       for i in range(count):
+                               field_name = _bt_python_ctf_field_type_structure_get_field_name(self._ft, i)
+                               if field_name is None:
+                                       raise TypeError("Could not get Structure field name at index {}".format(i))
+
+                               field_type_native = _bt_python_ctf_field_type_structure_get_field_type(self._ft, i)
+                               if field_type_native is None:
+                                       raise TypeError("Could not get Structure field type at index {}".format(i))
+
+                               field_type = CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(field_type_native)
+                               yield (field_name, field_type)
+
+               """
+               Get a field declaration by name (FieldDeclaration).
+               """
+               def get_field_by_name(self, name):
+                       field_type_native = _bt_ctf_field_type_structure_get_field_type_by_name(self._ft, name)
+                       if field_type_native is None:
+                               raise TypeError("Could not find Structure field with name {}".format(name))
+
+                       return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(field_type_native)
+
+       class VariantFieldDeclaration(FieldDeclaration):
+               """
+               Create a new variant field declaration.
                """
                def __init__(self, enum_tag, tag_name):
-                       if enum_tag is None or not isinstance(enum_tag, CTFWriter.FieldTypeEnumeration):
-                               raise TypeError("Invalid tag type; must be of type FieldTypeEnumeration.")
+                       if enum_tag is None or not isinstance(enum_tag, CTFWriter.EnumerationFieldDeclaration):
+                               raise TypeError("Invalid tag type; must be of type EnumerationFieldDeclaration.")
 
-                       self._ft = _bt_ctf_field_type_variant_create(enum_tag._ft, tag_name)
+                       self._ft = _bt_ctf_field_type_variant_create(enum_tag._ft, str(tag_name))
                        super().__init__()
 
+               """
+               Get the variant's tag name.
+               """
+               @property
+               def tag_name(self):
+                       ret = _bt_ctf_field_type_variant_get_tag_name(self._ft)
+                       if ret is None:
+                               raise TypeError("Could not get Variant tag name")
+                       return ret
+
+               """
+               Get the variant's tag type.
+               """
+               @property
+               def tag_type(self):
+                       ret = _bt_ctf_field_type_variant_get_tag_type(self._ft)
+                       if ret is None:
+                               raise TypeError("Could not get Variant tag type")
+                       return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(ret)
+
                """
                Add a field of type "field_type" to the variant.
                """
                def add_field(self, field_type, field_name):
-                       ret = _bt_ctf_field_type_variant_add_field(self._ft, field_type._ft, field_name)
+                       ret = _bt_ctf_field_type_variant_add_field(self._ft, field_type._ft, str(field_name))
                        if ret < 0:
                                raise ValueError("Could not add field to variant.")
 
-       class FieldTypeArray(FieldType):
                """
-               Create a new array field type.
+               Generator returning the variant's field as tuples of (field name, field declaration).
+               """
+               @property
+               def fields(self):
+                       count = _bt_ctf_field_type_variant_get_field_count(self._ft)
+                       if count < 0:
+                               raise TypeError("Could not get Variant field count")
+
+                       for i in range(count):
+                               field_name = _bt_python_ctf_field_type_variant_get_field_name(self._ft, i)
+                               if field_name is None:
+                                       raise TypeError("Could not get Variant field name at index {}".format(i))
+
+                               field_type_native = _bt_python_ctf_field_type_variant_get_field_type(self._ft, i)
+                               if field_type_native is None:
+                                       raise TypeError("Could not get Variant field type at index {}".format(i))
+
+                               field_type = CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(field_type_native)
+                               yield (field_name, field_type)
+
+               """
+               Get a field declaration by name (FieldDeclaration).
+               """
+               def get_field_by_name(self, name):
+                       field_type_native = _bt_ctf_field_type_variant_get_field_type_by_name(self._ft, name)
+                       if field_type_native is None:
+                               raise TypeError("Could not find Variant field with name {}".format(name))
+
+                       return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(field_type_native)
+
+               """
+               Get a field declaration from tag (EnumerationField).
+               """
+               def get_field_from_tag(self, tag):
+                       field_type_native = _bt_ctf_field_type_variant_get_field_type_from_tag(self._ft, tag._f)
+                       if field_type_native is None:
+                               raise TypeError("Could not find Variant field with tag value {}".format(tag.value))
+
+                       return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(field_type_native)
+
+       class ArrayFieldDeclaration(FieldDeclaration):
+               """
+               Create a new array field declaration.
                """
                def __init__(self, element_type, length):
                        self._ft = _bt_ctf_field_type_array_create(element_type._ft, length)
                        super().__init__()
 
-       class FieldTypeSequence(FieldType):
                """
-               Create a new sequence field type.
+               Get the array's element type.
+               """
+               @property
+               def element_type(self):
+                       ret = _bt_ctf_field_type_array_get_element_type(self._ft)
+                       if ret is None:
+                               raise TypeError("Could not get Array element type")
+                       return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(ret)
+
+               """
+               Get the array's length.
+               """
+               @property
+               def length(self):
+                       ret = _bt_ctf_field_type_array_get_length(self._ft)
+                       if ret < 0:
+                               raise TypeError("Could not get Array length")
+                       return ret
+
+       class SequenceFieldDeclaration(FieldDeclaration):
+               """
+               Create a new sequence field declaration.
                """
                def __init__(self, element_type, length_field_name):
-                       self._ft = _bt_ctf_field_type_sequence_create(element_type._ft, length_field_name)
+                       self._ft = _bt_ctf_field_type_sequence_create(element_type._ft, str(length_field_name))
                        super().__init__()
 
-       class FieldTypeString(FieldType):
                """
-               Create a new string field type.
+               Get the sequence's element type.
+               """
+               @property
+               def element_type(self):
+                       ret = _bt_ctf_field_type_sequence_get_element_type(self._ft)
+                       if ret is None:
+                               raise TypeError("Could not get Sequence element type")
+                       return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(ret)
+
+               """
+               Get the sequence's length field name.
+               """
+               @property
+               def length_field_name(self):
+                       ret = _bt_ctf_field_type_sequence_get_length_field_name(self._ft)
+                       if ret is None:
+                               raise TypeError("Could not get Sequence length field name")
+                       return ret
+
+       class StringFieldDeclaration(FieldDeclaration):
+               """
+               Create a new string field declaration.
                """
                def __init__(self):
                        self._ft = _bt_ctf_field_type_string_create()
                        super().__init__()
 
                """
-               Set a string type's encoding. Must be a constant from the CTFStringEncoding class.
+               Get a string declaration's encoding (a constant from the CTFStringEncoding class).
+               """
+               @property
+               def encoding(self):
+                       return _bt_ctf_field_type_string_get_encoding(self._ft)
+
+               """
+               Set a string declaration's encoding. Must be a constant from the CTFStringEncoding class.
                """
-               def set_encoding(self, encoding):
+               @encoding.setter
+               def encoding(self, encoding):
                        ret = _bt_ctf_field_type_string_set_encoding(self._ft, encoding)
                        if ret < 0:
                                raise ValueError("Could not set string encoding.")
@@ -1533,33 +2246,33 @@ class CTFWriter:
        Create an instance of a field.
        """
        @staticmethod
-       def create_field(self, field_type):
-               if field_type is None or not isinstance(field_type, CTFWriter.FieldType):
-                       raise TypeError("Invalid field_type. Type must be a FieldType-derived class.")
-
-               if isinstance(field_type, CTFWriter.FieldTypeInteger):
-                       return CTFWriter.FieldInteger(field_type)
-               elif isinstance(field_type, CTFWriter.FieldTypeEnumeration):
-                       return CTFWriter.FieldEnumeration(field_type)
-               elif isinstance(field_type, CTFWriter.FieldTypeFloatingPoint):
-                       return CTFWriter.FieldFloatingPoint(field_type)
-               elif isinstance(field_type, CTFWriter.FieldTypeStructure):
-                       return CTFWriter.FieldStructure(field_type)
-               elif isinstance(field_type, CTFWriter.FieldTypeVariant):
-                       return CTFWriter.FieldVariant(field_type)
-               elif isinstance(field_type, CTFWriter.FieldTypeArray):
-                       return CTFWriter.FieldArray(field_type)
-               elif isinstance(field_type, CTFWriter.FieldTypeSequence):
-                       return CTFWriter.FieldSequence(field_type)
-               elif isinstance(field_type, CTFWriter.FieldTypeString):
-                       return CTFWriter.FieldString(field_type)
+       def create_field(field_type):
+               if field_type is None or not isinstance(field_type, CTFWriter.FieldDeclaration):
+                       raise TypeError("Invalid field_type. Type must be a FieldDeclaration-derived class.")
+
+               if isinstance(field_type, CTFWriter.IntegerFieldDeclaration):
+                       return CTFWriter.IntegerField(field_type)
+               elif isinstance(field_type, CTFWriter.EnumerationFieldDeclaration):
+                       return CTFWriter.EnumerationField(field_type)
+               elif isinstance(field_type, CTFWriter.FloatFieldDeclaration):
+                       return CTFWriter.FloatFieldingPoint(field_type)
+               elif isinstance(field_type, CTFWriter.StructureFieldDeclaration):
+                       return CTFWriter.StructureField(field_type)
+               elif isinstance(field_type, CTFWriter.VariantFieldDeclaration):
+                       return CTFWriter.VariantField(field_type)
+               elif isinstance(field_type, CTFWriter.ArrayFieldDeclaration):
+                       return CTFWriter.ArrayField(field_type)
+               elif isinstance(field_type, CTFWriter.SequenceFieldDeclaration):
+                       return CTFWriter.SequenceField(field_type)
+               elif isinstance(field_type, CTFWriter.StringFieldDeclaration):
+                       return CTFWriter.StringField(field_type)
 
        class Field:
                """
                Base class, do not instantiate.
                """
                def __init__(self, field_type):
-                       if not isinstance(field_type, CTFWriter.FieldType):
+                       if not isinstance(field_type, CTFWriter.FieldDeclaration):
                                raise TypeError("Invalid field_type argument.")
 
                        self._f = _bt_ctf_field_create(field_type._ft)
@@ -1572,14 +2285,14 @@ class CTFWriter:
                @staticmethod
                def _create_field_from_native_instance(native_field_instance):
                        type_dict = {
-                               CTFTypeId.INTEGER : CTFWriter.FieldInteger,
-                               CTFTypeId.FLOAT : CTFWriter.FieldFloatingPoint,
-                               CTFTypeId.ENUM : CTFWriter.FieldEnumeration,
-                               CTFTypeId.STRING : CTFWriter.FieldString,
-                               CTFTypeId.STRUCT : CTFWriter.FieldStructure,
-                               CTFTypeId.VARIANT : CTFWriter.FieldVariant,
-                               CTFTypeId.ARRAY : CTFWriter.FieldArray,
-                               CTFTypeId.SEQUENCE : CTFWriter.FieldSequence
+                               CTFTypeId.INTEGER : CTFWriter.IntegerField,
+                               CTFTypeId.FLOAT : CTFWriter.FloatFieldingPoint,
+                               CTFTypeId.ENUM : CTFWriter.EnumerationField,
+                               CTFTypeId.STRING : CTFWriter.StringField,
+                               CTFTypeId.STRUCT : CTFWriter.StructureField,
+                               CTFTypeId.VARIANT : CTFWriter.VariantField,
+                               CTFTypeId.ARRAY : CTFWriter.ArrayField,
+                               CTFTypeId.SEQUENCE : CTFWriter.SequenceField
                        }
 
                        field_type = _bt_python_get_field_type(native_field_instance)
@@ -1591,11 +2304,40 @@ class CTFWriter:
                        field.__class__ = type_dict[field_type]
                        return field
 
-       class FieldInteger(Field):
+               @property
+               def declaration(self):
+                       native_field_type = _bt_ctf_field_get_type(self._f)
+                       if native_field_type is None:
+                               raise TypeError("Invalid field instance")
+                       return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(native_field_type)
+
+       class IntegerField(Field):
+               """
+               Get an integer field's value.
+               """
+               @property
+               def value(self):
+                       signedness = _bt_python_field_integer_get_signedness(self._f)
+                       if signedness < 0:
+                               raise TypeError("Invalid integer instance.")
+
+                       if signedness == 0:
+                               ret, value = _bt_ctf_field_unsigned_integer_get_value(self._f)
+                       else:
+                               ret, value = _bt_ctf_field_signed_integer_get_value(self._f)
+
+                       if ret < 0:
+                               raise ValueError("Could not get integer field value.")
+                       return value
+
                """
                Set an integer field's value.
                """
-               def set_value(self, value):
+               @value.setter
+               def value(self, value):
+                       if not isinstance(value, int):
+                               raise TypeError("IntegerField's value must be an int")
+
                        signedness = _bt_python_field_integer_get_signedness(self._f)
                        if signedness < 0:
                                raise TypeError("Invalid integer instance.")
@@ -1608,82 +2350,138 @@ class CTFWriter:
                        if ret < 0:
                                raise ValueError("Could not set integer field value.")
 
-       class FieldEnumeration(Field):
+       class EnumerationField(Field):
                """
                Return the enumeration's underlying container field (an integer field).
                """
-               def get_container(self):
-                       container = CTFWriter.FieldInteger.__new__(CTFWriter.FieldInteger)
+               @property
+               def container(self):
+                       container = CTFWriter.IntegerField.__new__(CTFWriter.IntegerField)
                        container._f = _bt_ctf_field_enumeration_get_container(self._f)
                        if container._f is None:
                                raise TypeError("Invalid enumeration field type.")
                        return container
 
-       class FieldFloatingPoint(Field):
+               """
+               Get the enumeration field's mapping name.
+               """
+               @property
+               def value(self):
+                       value = _bt_ctf_field_enumeration_get_mapping_name(self._f)
+                       if value is None:
+                               raise ValueError("Could not get enumeration's mapping name.")
+                       return value
+
+               """
+               Set the enumeration field's value. Must be an integer as mapping names
+               may be ambiguous.
+               """
+               @value.setter
+               def value(self, value):
+                       if not isinstance(value, int):
+                               raise TypeError("EnumerationField value must be an int")
+                       self.container.value = value
+
+       class FloatFieldingPoint(Field):
+               """
+               Get a floating point field's value.
+               """
+               @property
+               def value(self):
+                       ret, value = _bt_ctf_field_floating_point_get_value(self._f)
+                       if ret < 0:
+                               raise ValueError("Could not get floating point field value.")
+                       return value
+
                """
                Set a floating point field's value.
                """
-               def set_value(self, value):
-                       ret = _bt_ctf_field_floating_point_set_value(self._f, value)
+               @value.setter
+               def value(self, value):
+                       if not isinstance(value, int) and not isinstance(value, float):
+                               raise TypeError("Value must be either a float or an int")
+
+                       ret = _bt_ctf_field_floating_point_set_value(self._f, float(value))
                        if ret < 0:
                                raise ValueError("Could not set floating point field value.")
 
-       class FieldStructure(Field):
+       class StructureField(Field):
                """
                Get the structure's field corresponding to the provided field name.
                """
-               def get_field(self, field_name):
-                       native_instance = _bt_ctf_field_structure_get_field(self._f, field_name)
+               def field(self, field_name):
+                       native_instance = _bt_ctf_field_structure_get_field(self._f, str(field_name))
                        if native_instance is None:
                                raise ValueError("Invalid field_name provided.")
                        return CTFWriter.Field._create_field_from_native_instance(native_instance)
 
-       class FieldVariant(Field):
+       class VariantField(Field):
                """
                Return the variant's selected field. The "tag" field is the selector enum field.
                """
-               def get_field(self, tag):
+               def field(self, tag):
                        native_instance = _bt_ctf_field_variant_get_field(self._f, tag._f)
                        if native_instance is None:
                                raise ValueError("Invalid tag provided.")
                        return CTFWriter.Field._create_field_from_native_instance(native_instance)
 
-       class FieldArray(Field):
+       class ArrayField(Field):
                """
                Return the array's field at position "index".
                """
-               def get_field(self, index):
+               def field(self, index):
                        native_instance = _bt_ctf_field_array_get_field(self._f, index)
                        if native_instance is None:
                                raise IndexError("Invalid index provided.")
                        return CTFWriter.Field._create_field_from_native_instance(native_instance)
 
-       class FieldSequence(Field):
+       class SequenceField(Field):
+               """
+               Get the sequence's length field (IntegerField).
+               """
+               @property
+               def length(self):
+                       native_instance = _bt_ctf_field_sequence_get_length(self._f)
+                       if native_instance is None:
+                               length = -1
+                       return CTFWriter.Field._create_field_from_native_instance(native_instance)
+
                """
                Set the sequence's length field (IntegerField).
                """
-               def set_length(self, length):
-                       if not isinstance(length, CTFWriter.FieldInteger):
+               @length.setter
+               def length(self, length_field):
+                       if not isinstance(length_field, CTFWriter.IntegerField):
                                raise TypeError("Invalid length field.")
-                       ret = _bt_ctf_field_sequence_set_length(self._f, length._f)
+                       if length_field.declaration.signed:
+                               raise TypeError("Sequence field length must be unsigned")
+                       ret = _bt_ctf_field_sequence_set_length(self._f, length_field._f)
                        if ret < 0:
                                raise ValueError("Could not set sequence length.")
 
                """
                Return the sequence's field at position "index".
                """
-               def get_field(self, index):
+               def field(self, index):
                        native_instance = _bt_ctf_field_sequence_get_field(self._f, index)
                        if native_instance is None:
                                raise ValueError("Could not get sequence element at index.")
                        return CTFWriter.Field._create_field_from_native_instance(native_instance)
 
-       class FieldString(Field):
+       class StringField(Field):
+               """
+               Get a string field's value.
+               """
+               @property
+               def value(self):
+                       return _bt_ctf_field_string_get_value(self._f)
+
                """
                Set a string field's value.
                """
-               def set_value(self, value):
-                       ret = _bt_ctf_field_string_set_value(self._f, value)
+               @value.setter
+               def value(self, value):
+                       ret = _bt_ctf_field_string_set_value(self._f, str(value))
                        if ret < 0:
                                raise ValueError("Could not set string field value.")
 
@@ -1703,10 +2501,82 @@ class CTFWriter:
                Add a field of type "field_type" to the event class.
                """
                def add_field(self, field_type, field_name):
-                       ret = _bt_ctf_event_class_add_field(self._ec, field_type._ft, field_name)
+                       ret = _bt_ctf_event_class_add_field(self._ec, field_type._ft, str(field_name))
                        if ret < 0:
                                raise ValueError("Could not add field to event class.")
 
+               """
+               Get the event class' name.
+               """
+               @property
+               def name(self):
+                       name = _bt_ctf_event_class_get_name(self._ec)
+                       if name is None:
+                               raise TypeError("Could not get EventClass name")
+                       return name
+
+               """
+               Get the event class' id. Returns a negative value if unset.
+               """
+               @property
+               def id(self):
+                       id = _bt_ctf_event_class_get_id(self._ec)
+                       if id < 0:
+                               raise TypeError("Could not get EventClass id")
+                       return id
+
+               """
+               Set the event class' id. Throws a TypeError if the event class
+               is already registered to a stream class.
+               """
+               @id.setter
+               def id(self, id):
+                       ret = _bt_ctf_event_class_set_id(self._ec, id)
+                       if ret < 0:
+                               raise TypeError("Can't change an Event Class's id after it has been assigned to a stream class")
+
+               """
+               Get the event class' stream class. Returns None if unset.
+               """
+               @property
+               def stream_class(self):
+                       stream_class_native = _bt_ctf_event_class_get_stream_class(self._ec)
+                       if stream_class_native is None:
+                               return None
+                       stream_class = CTFWriter.StreamClass.__new__(CTFWriter.StreamClass)
+                       stream_class._sc = stream_class_native
+                       return stream_class
+
+               """
+               Generator returning the event class' fields as tuples of (field name, field declaration).
+               """
+               @property
+               def fields(self):
+                       count = _bt_ctf_event_class_get_field_count(self._ec)
+                       if count < 0:
+                               raise TypeError("Could not get EventClass' field count")
+
+                       for i in range(count):
+                               field_name = _bt_python_ctf_event_class_get_field_name(self._ec, i)
+                               if field_name is None:
+                                       raise TypeError("Could not get EventClass' field name at index {}".format(i))
+
+                               field_type_native = _bt_python_ctf_event_class_get_field_type(self._ec, i)
+                               if field_type_native is None:
+                                       raise TypeError("Could not get EventClass' field type at index {}".format(i))
+
+                               field_type = CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(field_type_native)
+                               yield (field_name, field_type)
+
+               """
+               Get a field declaration by name (FieldDeclaration).
+               """
+               def get_field_by_name(self, name):
+                       field_type_native = _bt_ctf_event_class_get_field_by_name(self._ec, name)
+                       if field_type_native is None:
+                               raise TypeError("Could not find EventClass field with name {}".format(name))
+                       return CTFWriter.FieldDeclaration._create_field_declaration_from_native_instance(field_type_native)
+
        class Event:
                """
                Create a new event of the given event class.
@@ -1723,24 +2593,48 @@ class CTFWriter:
                        _bt_ctf_event_put(self._e)
 
                """
-               Set a manually created field as an event's payload.
+               Get the event's class.
                """
-               def set_payload(self, field_name, value):
-                       if not isinstance(value, CTFWriter.Field):
-                               raise TypeError("Invalid value type.")
-                       ret = _bt_ctf_event_set_payload(self._e, field_name, value._f)
-                       if ret < 0:
-                               raise ValueError("Could not set event field payload.")
+               @property
+               def event_class(self):
+                       event_class_native = _bt_ctf_event_get_class(self._e)
+                       if event_class_native is None:
+                               return None
+                       event_class = CTFWriter.EventClass.__new__(CTFWriter.EventClass)
+                       event_class._ec = event_class_native
+                       return event_class
 
                """
-               Set a manually created field as an event's payload.
+               Get a clock from event. Returns None if the event's class
+               is not registered to a stream class.
+               """
+               def clock(self):
+                       clock_instance = _bt_ctf_event_get_clock(self._e)
+                       if clock_instance is None:
+                               return None
+                       clock = CTFWriter.Clock.__new__(CTFWriter.Clock)
+                       clock._c = clock_instance
+                       return clock
+
+               """
+               Get a field from event.
                """
-               def get_payload(self, field_name):
-                       native_instance = _bt_ctf_event_get_payload(self._e, field_name)
+               def payload(self, field_name):
+                       native_instance = _bt_ctf_event_get_payload(self._e, str(field_name))
                        if native_instance is None:
                                raise ValueError("Could not get event payload.")
                        return CTFWriter.Field._create_field_from_native_instance(native_instance)
 
+               """
+               Set a manually created field as an event's payload.
+               """
+               def set_payload(self, field_name, value_field):
+                       if not isinstance(value, CTFWriter.Field):
+                               raise TypeError("Invalid value type.")
+                       ret = _bt_ctf_event_set_payload(self._e, str(field_name), value_field._f)
+                       if ret < 0:
+                               raise ValueError("Could not set event field payload.")
+
        class StreamClass:
                """
                Create a new stream class of the given name.
@@ -1753,10 +2647,33 @@ class CTFWriter:
                def __del__(self):
                        _bt_ctf_stream_class_put(self._sc)
 
+               """
+               Get a stream class' name.
+               """
+               @property
+               def name(self):
+                       name = _bt_ctf_stream_class_get_name(self._sc)
+                       if name is None:
+                               raise TypeError("Could not get StreamClass name")
+                       return name
+
+               """
+               Get a stream class' clock.
+               """
+               @property
+               def clock(self):
+                       clock_instance = _bt_ctf_stream_class_get_clock(self._sc)
+                       if clock_instance is None:
+                               return None
+                       clock = CTFWriter.Clock.__new__(CTFWriter.Clock)
+                       clock._c = clock_instance
+                       return clock
+
                """
                Assign a clock to a stream class.
                """
-               def set_clock(self, clock):
+               @clock.setter
+               def clock(self, clock):
                        if not isinstance(clock, CTFWriter.Clock):
                                raise TypeError("Invalid clock type.")
 
@@ -1764,9 +2681,46 @@ class CTFWriter:
                        if ret < 0:
                                raise ValueError("Could not set stream class clock.")
 
+               """
+               Get a stream class' id.
+               """
+               @property
+               def id(self):
+                       ret = _bt_ctf_stream_class_get_id(self._sc)
+                       if ret < 0:
+                               raise TypeError("Could not get StreamClass id")
+                       return ret
+
+               """
+               Assign an id to a stream class.
+               """
+               @id.setter
+               def id(self, id):
+                       ret = _bt_ctf_stream_class_set_id(self._sc, id)
+                       if ret < 0:
+                               raise TypeError("Could not set stream class id.")
+
+               """
+               Generator returning the stream class' event classes.
+               """
+               @property
+               def event_classes(self):
+                       count = _bt_ctf_stream_class_get_event_class_count(self._sc)
+                       if count < 0:
+                               raise TypeError("Could not get StreamClass' event class count")
+
+                       for i in range(count):
+                               event_class_native = _bt_ctf_stream_class_get_event_class(self._sc, i)
+                               if event_class_native is None:
+                                       raise TypeError("Could not get StreamClass' event class at index {}".format(i))
+
+                               event_class = CTFWriter.EventClass.__new__(CTFWriter.EventClass)
+                               event_class._ec = event_class_native
+                               yield event_class
+
                """
                Add an event class to a stream class. New events can be added even after a
-               stream has beem instanciated and events have been appended. However, a stream
+               stream has been instantiated and events have been appended. However, a stream
                will not accept events of a class that has not been registered beforehand.
                """
                def add_event_class(self, event_class):
@@ -1792,13 +2746,21 @@ class CTFWriter:
                def __del__(self):
                        _bt_ctf_stream_put(self._s)
 
+               """
+               Get a stream's discarded event count.
+               """
+               @property
+               def discarded_events(self):
+                       ret, count = _bt_ctf_stream_get_discarded_events_count(self._s)
+                       if ret < 0:
+                               raise ValueError("Could not get the stream's discarded events count")
+                       return count
+
                """
                Increase the current packet's discarded event count.
                """
                def append_discarded_events(self, event_count):
-                       ret = _bt_ctf_stream_append_discarded_events(self._s, event_count)
-                       if ret < 0:
-                               raise ValueError("Could not append discarded events.")
+                       _bt_ctf_stream_append_discarded_events(self._s, event_count)
 
                """
                Append "event" to the stream's current packet. The stream's associated clock
@@ -1846,7 +2808,7 @@ class CTFWriter:
                Add an environment field to the trace.
                """
                def add_environment_field(self, name, value):
-                       ret = _bt_ctf_writer_add_environment_field(self._w, name, value)
+                       ret = _bt_ctf_writer_add_environment_field(self._w, str(name), str(value))
                        if ret < 0:
                                raise ValueError("Could not add environment field to trace.")
 
@@ -1862,7 +2824,8 @@ class CTFWriter:
                """
                Get the trace's TSDL meta-data.
                """
-               def get_metadata(self):
+               @property
+               def metadata(self):
                        return _bt_ctf_writer_get_metadata_string(self._w)
 
                """
@@ -1871,11 +2834,20 @@ class CTFWriter:
                def flush_metadata(self):
                        _bt_ctf_writer_flush_metadata(self._w)
 
+               """
+               Get the trace's byte order. Must be a constant from the ByteOrder
+               class.
+               """
+               @property
+               def byte_order(self):
+                       raise NotImplementedError("Getter not implemented.")
+
                """
                Set the trace's byte order. Must be a constant from the ByteOrder
                class. Defaults to BYTE_ORDER_NATIVE, the host machine's endianness.
                """
-               def set_byte_order(self, byte_order):
+               @byte_order.setter
+               def byte_order(self, byte_order):
                        ret = _bt_ctf_writer_set_byte_order(self._w, byte_order)
                        if ret < 0:
                                raise ValueError("Could not set trace's byte order.")
This page took 0.058735 seconds and 4 git commands to generate.