Dynamic scope: child position is MAX_INT
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 16 Apr 2011 00:36:51 +0000 (20:36 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 16 Apr 2011 00:36:51 +0000 (20:36 -0400)
Ensure that lookup knows the parent fields are prior to the child
location.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/metadata/ctf-visitor-generate-io-struct.c
include/babeltrace/types.h
types/types.c

index f54a276a486305a001aa1eae9038a69e9c0c0826..2c01a9a2510bbf2087daa45ff53588549e256af3 100644 (file)
@@ -515,7 +515,8 @@ int ctf_event_visit(FILE *fd, int depth, struct ctf_node *node,
                event->context =
                        event->context_decl->definition_new(event->context_decl,
                                parent_def_scope, 0, 0);
-               set_dynamic_definition_scope(event->context->scope,
+               set_dynamic_definition_scope(&event->context->p,
+                                            event->context->scope,
                                             g_quark_from_string("event.context"));
                parent_def_scope = event->context->scope;
                declaration_unref(event->context_decl);
@@ -524,7 +525,8 @@ int ctf_event_visit(FILE *fd, int depth, struct ctf_node *node,
                event->fields =
                        event->fields_decl->definition_new(event->fields_decl,
                                parent_def_scope, 0, 0);
-               set_dynamic_definition_scope(event->fields->scope,
+               set_dynamic_definition_scope(&event->fields->p,
+                                            event->fields->scope,
                                             g_quark_from_string("event.fields"));
                parent_def_scope = event->fields->scope;
                declaration_unref(event->fields_decl);
@@ -652,7 +654,8 @@ int ctf_stream_visit(FILE *fd, int depth, struct ctf_node *node,
                stream->packet_context =
                        stream->packet_context_decl->definition_new(stream->packet_context_decl,
                                parent_def_scope, 0, 0);
-               set_dynamic_definition_scope(stream->packet_context->scope,
+               set_dynamic_definition_scope(&stream->packet_context->p,
+                                            stream->packet_context->scope,
                                             g_quark_from_string("stream.packet.context"));
                parent_def_scope = stream->packet_context->scope;
                declaration_unref(stream->packet_context_decl);
@@ -661,7 +664,8 @@ int ctf_stream_visit(FILE *fd, int depth, struct ctf_node *node,
                stream->event_header =
                        stream->event_header_decl->definition_new(stream->event_header_decl,
                                parent_def_scope, 0, 0);
-               set_dynamic_definition_scope(stream->event_header->scope,
+               set_dynamic_definition_scope(&stream->event_header->p,
+                                            stream->event_header->scope,
                                             g_quark_from_string("stream.event.header"));
                parent_def_scope = stream->event_header->scope;
                declaration_unref(stream->event_header_decl);
@@ -670,7 +674,8 @@ int ctf_stream_visit(FILE *fd, int depth, struct ctf_node *node,
                stream->event_context =
                        stream->event_context_decl->definition_new(stream->event_context_decl,
                                parent_def_scope, 0, 0);
-               set_dynamic_definition_scope(stream->event_context_scope,
+               set_dynamic_definition_scope(&stream->event_context->p,
+                                            stream->event_context->scope,
                                             g_quark_from_string("stream.event.context"));
                parent_def_scope = stream->event_context->scope;
                declaration_unref(stream->event_context_decl);
index 44c9e5b228f49293cc2c9356e7011355274ff2af..21dd66f246f0c9d71845858320bb359d7313ae60 100644 (file)
@@ -380,7 +380,8 @@ int register_field_definition(GQuark field_name,
 struct definition_scope *
        new_definition_scope(struct definition_scope *parent_scope,
                             GQuark field_name);
-void set_dynamic_definition_scope(struct definition_scope *scope,
+void set_dynamic_definition_scope(struct definition *definition,
+                                 struct definition_scope *scope,
                                  GQuark root_name);
 void free_definition_scope(struct definition_scope *scope);
 
index 1f93da4e245dba471d27ae5a5b314f905b05079c..fe1538f0102c6a1824bac0485eef3e2cb8125fed 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <babeltrace/format.h>
+#include <limits.h>
 #include <glib.h>
 #include <errno.h>
 
@@ -445,11 +446,17 @@ struct definition_scope *
        return scope;
 }
 
-void set_dynamic_definition_scope(struct definition_scope *scope,
+void set_dynamic_definition_scope(struct definition *definition,
+                                 struct definition_scope *scope,
                                  GQuark root_name)
 {
        g_array_set_size(scope->scope_path, 1);
        g_array_index(scope->scope_path, GQuark, 0) = root_name;
+       /*
+        * Use INT_MAX order to ensure that all fields of the parent
+        * scope are seen as being prior to this scope.
+        */
+       definition->index = INT_MAX;
 }
 
 void free_definition_scope(struct definition_scope *scope)
This page took 0.03657 seconds and 4 git commands to generate.