Move stream pos declaration into CTF header
[babeltrace.git] / include / babeltrace / types.h
index ad28ac0912c85e98e8bc2c27acd0474e446e1d47..3d2b70a4ed92d878588ff5547d7fc85537ac43b8 100644 (file)
 /* Preallocate this many fields for structures */
 #define DEFAULT_NR_STRUCT_FIELDS 8
 
-/*
- * Always update stream_pos with move_pos and init_pos.
- */
-struct stream_pos {
-       char *base;             /* Base address */
-       size_t offset;          /* Offset from base, in bits */
-       int dummy;              /* Dummy position, for length calculation */
-};
-
-static inline
-void init_pos(struct stream_pos *pos, char *base)
-{
-       pos->base = base;       /* initial base, page-aligned */
-       pos->offset = 0;
-       pos->dummy = false;
-}
-
-/*
- * move_pos - move position of a relative bit offset
- *
- * TODO: allow larger files by updating base too.
- */
-static inline
-void move_pos(struct stream_pos *pos, size_t offset)
-{
-       pos->offset = pos->offset + offset;
-}
-
-/*
- * align_pos - align position on a bit offset (> 0)
- *
- * TODO: allow larger files by updating base too.
- */
-static inline
-void align_pos(struct stream_pos *pos, size_t offset)
-{
-       pos->offset += offset_align(pos->offset, offset);
-}
-
-static inline
-void copy_pos(struct stream_pos *dest, struct stream_pos *src)
-{
-       memcpy(dest, src, sizeof(struct stream_pos));
-}
-
-static inline
-char *get_pos_addr(struct stream_pos *pos)
-{
-       /* Only makes sense to get the address after aligning on CHAR_BIT */
-       assert(!(pos->offset % CHAR_BIT));
-       return pos->base + (pos->offset / CHAR_BIT);
-}
-
+struct stream_pos;
 struct format;
 struct definition;
 
@@ -133,7 +81,6 @@ enum ctf_type_id {
 
 struct declaration {
        enum ctf_type_id id;
-       GQuark name;            /* type name */
        size_t alignment;       /* type alignment, in bits */
        int ref;                /* number of references to the type */
        /*
@@ -253,8 +200,15 @@ struct definition_enum {
        GArray *value;
 };
 
+enum ctf_string_encoding {
+       CTF_STRING_UTF8 = 0,
+       CTF_STRING_ASCII,
+       CTF_STRING_UNKNOWN,
+};
+
 struct declaration_string {
        struct declaration p;
+       enum ctf_string_encoding encoding;
 };
 
 struct definition_string {
@@ -343,7 +297,7 @@ int register_declaration(GQuark declaration_name,
                         struct declaration *declaration,
                         struct declaration_scope *scope);
 struct declaration *lookup_declaration(GQuark declaration_name,
-                                      struct declaration_scope *scope);
+                               struct declaration_scope *scope);
 
 /*
  * Type scopes also contain a separate registry for struct, variant and
@@ -358,9 +312,9 @@ struct declaration_struct *
        lookup_struct_declaration(GQuark struct_name,
                                  struct declaration_scope *scope);
 int register_variant_declaration(GQuark variant_name,
-                         struct declaration_variant *variant_declaration,
+                         struct declaration_untagged_variant *untagged_variant_declaration,
                          struct declaration_scope *scope);
-struct declaration_variant *lookup_variant_declaration(GQuark variant_name,
+struct declaration_untagged_variant *lookup_variant_declaration(GQuark variant_name,
                                         struct declaration_scope *scope);
 int register_enum_declaration(GQuark enum_name,
                              struct declaration_enum *enum_declaration,
@@ -398,18 +352,14 @@ void declaration_unref(struct declaration *declaration);
 void definition_ref(struct definition *definition);
 void definition_unref(struct definition *definition);
 
-/* Nameless declarations can be created by passing a NULL name */
-
-struct declaration_integer *integer_declaration_new(const char *name,
-                                     size_t len, int byte_order,
+struct declaration_integer *integer_declaration_new(size_t len, int byte_order,
                                      int signedness, size_t alignment);
 
 /*
  * mantissa_len is the length of the number of bytes represented by the mantissa
  * (e.g. result of DBL_MANT_DIG). It includes the leading 1.
  */
-struct declaration_float *float_declaration_new(const char *name,
-                                 size_t mantissa_len,
+struct declaration_float *float_declaration_new(size_t mantissa_len,
                                  size_t exp_len, int byte_order,
                                  size_t alignment);
 
@@ -446,12 +396,13 @@ void enum_unsigned_insert(struct declaration_enum *enum_declaration,
 size_t enum_get_nr_enumerators(struct declaration_enum *enum_declaration);
 
 struct declaration_enum *
-       enum_declaration_new(const char *name,
-                            struct declaration_integer *integer_declaration);
+       enum_declaration_new(struct declaration_integer *integer_declaration);
+
+struct declaration_string *
+       string_declaration_new(enum ctf_string_encoding encoding);
 
 struct declaration_struct *
-       struct_declaration_new(const char *name,
-                              struct declaration_scope *parent_scope);
+       struct_declaration_new(struct declaration_scope *parent_scope);
 void struct_declaration_add_field(struct declaration_struct *struct_declaration,
                                  const char *field_name,
                                  struct declaration *field_declaration);
@@ -475,7 +426,7 @@ struct_get_field_from_index(struct definition_struct *struct_definition,
  * from numeric values to a single tag. Overlapping tag value ranges are
  * therefore forbidden.
  */
-struct declaration_untagged_variant *untagged_variant_declaration_new(const char *name,
+struct declaration_untagged_variant *untagged_variant_declaration_new(
                struct declaration_scope *parent_scope);
 struct declaration_variant *variant_declaration_new(struct declaration_untagged_variant *untagged_variant,
                const char *tag);
@@ -504,8 +455,7 @@ struct field *variant_get_current_field(struct definition_variant *variant);
  * array.
  */
 struct declaration_array *
-       array_declaration_new(const char *name,
-               size_t len, struct declaration *elem_declaration,
+       array_declaration_new(size_t len, struct declaration *elem_declaration,
                struct declaration_scope *parent_scope);
 
 /*
@@ -513,8 +463,7 @@ struct declaration_array *
  * to the sequence. No need to free them explicitly.
  */
 struct declaration_sequence *
-       sequence_declaration_new(const char *name,
-               struct declaration_integer *len_declaration, 
+       sequence_declaration_new(struct declaration_integer *len_declaration, 
                struct declaration *elem_declaration,
                struct declaration_scope *parent_scope);
 
This page took 0.02479 seconds and 4 git commands to generate.