Dynamic definition scope hierarchy
[babeltrace.git] / include / babeltrace / types.h
index 0bcb8594dfe6e88b548feeefe7403b43480cacdb..34e49aef18b7be474fb74f7221701f5e709deae4 100644 (file)
@@ -105,6 +105,15 @@ struct definition_scope {
        /* Hash table mapping field name GQuark to "struct definition" */
        GHashTable *definitions;
        struct definition_scope *parent_scope;
+       /*
+        * Complete "path" leading to this definition scope.
+        * Includes dynamic scope name '.' field name '.' field name '.' ....
+        * Array of GQuark elements (which are each separated by dots).
+        * The dynamic scope name can contain dots, and is encoded into
+        * a single GQuark. Thus, scope_path[0] returns the GQuark
+        * identifying the dynamic scope.
+        */
+       GArray *scope_path;     /* array of GQuark */
 };
 
 enum ctf_type_id {
@@ -131,7 +140,8 @@ struct declaration {
        void (*declaration_free)(struct declaration *declaration);
        struct definition *
                (*definition_new)(struct declaration *declaration,
-                                 struct definition_scope *parent_scope);
+                                 struct definition_scope *parent_scope,
+                                 GQuark field_name, int index);
        /*
         * definition_free called with definition ref is decremented to 0.
         */
@@ -147,6 +157,7 @@ struct declaration {
 
 struct definition {
        struct declaration *declaration;
+       int index;              /* Position of the definition in its container */
        int ref;                /* number of references to the definition */
 };
 
@@ -360,13 +371,18 @@ void free_declaration_scope(struct declaration_scope *scope);
  * definition scopes.
  */
 struct definition *
-       lookup_field_definition(GQuark field_name,
-                               struct definition_scope *scope);
+       lookup_definition(GArray *cur_path,     /* array of GQuark */
+                         GArray *lookup_path,  /* array of GQuark */
+                         struct definition_scope *scope);
 int register_field_definition(GQuark field_name,
                              struct definition *definition,
                              struct definition_scope *scope);
 struct definition_scope *
-       new_definition_scope(struct definition_scope *parent_scope);
+       new_definition_scope(struct definition_scope *parent_scope,
+                            GQuark field_name);
+struct definition_scope *
+       new_dynamic_definition_scope(struct definition_scope *parent_scope,
+                                    GQuark field_name);
 void free_definition_scope(struct definition_scope *scope);
 
 void declaration_ref(struct declaration *declaration);
@@ -453,11 +469,13 @@ struct_get_field_from_index(struct definition_struct *struct_definition,
  * therefore forbidden.
  */
 struct declaration_variant *variant_declaration_new(const char *name,
-                                     struct declaration_scope *parent_scope);
+               struct declaration_scope *parent_scope);
 void variant_declaration_add_field(struct declaration_variant *variant_declaration,
-                                  const char *tag_name, struct declaration *tag_declaration);
+               const char *tag_name,
+               struct declaration *tag_declaration);
 struct declaration_field *
-       variant_declaration_get_field_from_tag(struct declaration_variant *variant_declaration, GQuark tag);
+       variant_declaration_get_field_from_tag(struct declaration_variant *variant_declaration,
+               GQuark tag);
 /*
  * Returns 0 on success, -EPERM on error.
  */
@@ -477,8 +495,8 @@ struct field *variant_get_current_field(struct definition_variant *variant);
  */
 struct declaration_array *
        array_declaration_new(const char *name,
-                       size_t len, struct declaration *elem_declaration,
-                       struct declaration_scope *parent_scope);
+               size_t len, struct declaration *elem_declaration,
+               struct declaration_scope *parent_scope);
 
 /*
  * int_declaration and elem_declaration passed as parameter now belong
@@ -486,8 +504,8 @@ struct declaration_array *
  */
 struct declaration_sequence *
        sequence_declaration_new(const char *name,
-                       struct declaration_integer *len_declaration, 
-                       struct declaration *elem_declaration,
-                       struct declaration_scope *parent_scope);
+               struct declaration_integer *len_declaration, 
+               struct declaration *elem_declaration,
+               struct declaration_scope *parent_scope);
 
 #endif /* _BABELTRACE_declarationS_H */
This page took 0.024011 seconds and 4 git commands to generate.