Update sequence (type specifier -> field ref), fix definition lookup
[babeltrace.git] / include / babeltrace / types.h
index 059c371dea37cd2323b74a1d29d256ef338997d0..2aa45b8a0cdfbe6f33f0cd290bf50064ecaeae88 100644 (file)
@@ -31,6 +31,7 @@
 /* Preallocate this many fields for structures */
 #define DEFAULT_NR_STRUCT_FIELDS 8
 
+struct ctf_stream;
 struct stream_pos;
 struct format;
 struct definition;
@@ -90,7 +91,8 @@ struct declaration {
        struct definition *
                (*definition_new)(struct declaration *declaration,
                                  struct definition_scope *parent_scope,
-                                 GQuark field_name, int index);
+                                 GQuark field_name, int index,
+                                 const char *root_name);
        /*
         * definition_free called with definition ref is decremented to 0.
         */
@@ -102,6 +104,7 @@ struct definition {
        int index;              /* Position of the definition in its container */
        GQuark name;            /* Field name in its container (or 0 if unset) */
        int ref;                /* number of references to the definition */
+       GQuark path;
 };
 
 typedef int (*rw_dispatch)(struct stream_pos *pos,
@@ -111,6 +114,8 @@ typedef int (*rw_dispatch)(struct stream_pos *pos,
 struct stream_pos {
        /* read/write dispatch table. Specific to plugin used for stream. */
        rw_dispatch *rw_table;  /* rw dispatch table */
+       int (*event_cb)(struct stream_pos *pos,
+                       struct ctf_stream *stream);
 };
 
 static inline
@@ -134,6 +139,7 @@ struct declaration_integer {
        size_t len;             /* length, in bits. */
        int byte_order;         /* byte order */
        int signedness;
+       int base;               /* Base for pretty-printing: 2, 8, 10, 16 */
 };
 
 struct definition_integer {
@@ -161,6 +167,7 @@ struct definition_float {
        struct definition_integer *sign;
        struct definition_integer *mantissa;
        struct definition_integer *exp;
+       struct definition_scope *scope;
        /* Last values read */
        long double value;
 };
@@ -213,6 +220,7 @@ struct definition_enum {
        struct definition p;
        struct definition_integer *integer;
        struct declaration_enum *declaration;
+       struct definition_scope *scope;
        /* Last GQuark values read. Keeping a reference on the GQuark array. */
        GArray *value;
 };
@@ -293,7 +301,7 @@ struct definition_array {
 
 struct declaration_sequence {
        struct declaration p;
-       struct declaration_integer *len_declaration;
+       GArray *length_name;            /* Array of GQuark */
        struct declaration *elem;
        struct declaration_scope *scope;
 };
@@ -302,7 +310,7 @@ struct definition_sequence {
        struct definition p;
        struct declaration_sequence *declaration;
        struct definition_scope *scope;
-       struct definition_integer *len;
+       struct definition_integer *length;
        GPtrArray *elems;               /* Array of pointers to struct definition */
 };
 
@@ -353,12 +361,18 @@ int register_field_definition(GQuark field_name,
                              struct definition_scope *scope);
 struct definition_scope *
        new_definition_scope(struct definition_scope *parent_scope,
-                            GQuark field_name);
-void set_dynamic_definition_scope(struct definition *definition,
-                                 struct definition_scope *scope,
-                                 const char *root_name);
+                            GQuark field_name, const char *root_name);
 void free_definition_scope(struct definition_scope *scope);
 
+GQuark new_definition_path(struct definition_scope *parent_scope,
+                          GQuark field_name, const char *root_name);
+
+static inline
+int compare_definition_path(struct definition *definition, GQuark path)
+{
+       return definition->path == path;
+}
+
 void declaration_ref(struct declaration *declaration);
 void declaration_unref(struct declaration *declaration);
 
@@ -366,7 +380,8 @@ void definition_ref(struct definition *definition);
 void definition_unref(struct definition *definition);
 
 struct declaration_integer *integer_declaration_new(size_t len, int byte_order,
-                                     int signedness, size_t alignment);
+                                 int signedness, size_t alignment,
+                                 int base);
 
 /*
  * mantissa_len is the length of the number of bytes represented by the mantissa
@@ -415,7 +430,8 @@ struct declaration_string *
        string_declaration_new(enum ctf_string_encoding encoding);
 
 struct declaration_struct *
-       struct_declaration_new(struct declaration_scope *parent_scope);
+       struct_declaration_new(struct declaration_scope *parent_scope,
+                              uint64_t min_align);
 void struct_declaration_add_field(struct declaration_struct *struct_declaration,
                                  const char *field_name,
                                  struct declaration *field_declaration);
@@ -434,6 +450,7 @@ struct definition *
 struct_definition_get_field_from_index(struct definition_struct *struct_definition,
                                       int index);
 int struct_rw(struct stream_pos *pos, struct definition *definition);
+uint64_t struct_declaration_len(struct declaration_struct *struct_declaration);
 
 /*
  * The tag enumeration is validated to ensure that it contains only mappings
@@ -481,7 +498,7 @@ int array_rw(struct stream_pos *pos, struct definition *definition);
  * to the sequence. No need to free them explicitly.
  */
 struct declaration_sequence *
-       sequence_declaration_new(struct declaration_integer *len_declaration, 
+       sequence_declaration_new(const char *length_name,
                struct declaration *elem_declaration,
                struct declaration_scope *parent_scope);
 uint64_t sequence_len(struct definition_sequence *sequence);
@@ -493,4 +510,4 @@ int sequence_rw(struct stream_pos *pos, struct definition *definition);
  */
 void append_scope_path(const char *path, GArray *q);
 
-#endif /* _BABELTRACE_declarationS_H */
+#endif /* _BABELTRACE_TYPES_H */
This page took 0.026269 seconds and 4 git commands to generate.