Fix API: add const qualifiers, privatize struct bt_ctf_event
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 12 Mar 2012 15:12:12 +0000 (11:12 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 12 Mar 2012 15:12:12 +0000 (11:12 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
converter/babeltrace.c
formats/ctf/events.c
formats/ctf/iterator.c
include/babeltrace/ctf/events-internal.h
include/babeltrace/ctf/events.h
include/babeltrace/ctf/iterator.h
include/babeltrace/iterator-internal.h
include/babeltrace/types.h
lib/iterator.c
types/types.c

index 54efdfe0b0aa288be3ec47ef6c85b7182f484634..de9b49600fc5e0543690bc2104bfc6f194195e82 100644 (file)
@@ -25,6 +25,8 @@
 #include <babeltrace/context.h>
 #include <babeltrace/ctf/types.h>
 #include <babeltrace/ctf/events.h>
 #include <babeltrace/context.h>
 #include <babeltrace/ctf/types.h>
 #include <babeltrace/ctf/events.h>
+/* TODO: fix object model for format-agnostic callbacks */
+#include <babeltrace/ctf/events-internal.h>
 #include <babeltrace/ctf/iterator.h>
 #include <babeltrace/ctf-text/types.h>
 #include <babeltrace/iterator.h>
 #include <babeltrace/ctf/iterator.h>
 #include <babeltrace/ctf-text/types.h>
 #include <babeltrace/iterator.h>
index 0e32d21e3542b72bee804c6eba37a39527e0c9ea..ebc4f1b057143d046ccee603b11e5da2eafabdd7 100644 (file)
@@ -38,7 +38,7 @@
  */
 __thread int bt_ctf_last_field_error = 0;
 
  */
 __thread int bt_ctf_last_field_error = 0;
 
-struct definition *bt_ctf_get_top_level_scope(struct bt_ctf_event *event,
+const struct definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *event,
                enum bt_ctf_scope scope)
 {
        struct definition *tmp = NULL;
                enum bt_ctf_scope scope)
 {
        struct definition *tmp = NULL;
@@ -87,8 +87,8 @@ error:
        return NULL;
 }
 
        return NULL;
 }
 
-struct definition *bt_ctf_get_field(struct bt_ctf_event *event,
-               struct definition *scope,
+const struct definition *bt_ctf_get_field(const struct bt_ctf_event *event,
+               const struct definition *scope,
                const char *field)
 {
        struct definition *def;
                const char *field)
 {
        struct definition *def;
@@ -118,8 +118,8 @@ struct definition *bt_ctf_get_field(struct bt_ctf_event *event,
        return NULL;
 }
 
        return NULL;
 }
 
-struct definition *bt_ctf_get_index(struct bt_ctf_event *event,
-               struct definition *field,
+const struct definition *bt_ctf_get_index(const struct bt_ctf_event *event,
+               const struct definition *field,
                unsigned int index)
 {
        struct definition *ret = NULL;
                unsigned int index)
 {
        struct definition *ret = NULL;
@@ -138,7 +138,7 @@ struct definition *bt_ctf_get_index(struct bt_ctf_event *event,
        return ret;
 }
 
        return ret;
 }
 
-const char *bt_ctf_event_name(struct bt_ctf_event *event)
+const char *bt_ctf_event_name(const struct bt_ctf_event *event)
 {
        struct ctf_event *event_class;
        struct ctf_stream_class *stream_class;
 {
        struct ctf_event *event_class;
        struct ctf_stream_class *stream_class;
@@ -165,8 +165,8 @@ enum ctf_type_id bt_ctf_field_type(const struct definition *def)
        return CTF_TYPE_UNKNOWN;
 }
 
        return CTF_TYPE_UNKNOWN;
 }
 
-int bt_ctf_get_field_list(struct bt_ctf_event *event,
-               struct definition *scope,
+int bt_ctf_get_field_list(const struct bt_ctf_event *event,
+               const struct definition *scope,
                struct definition const * const **list,
                unsigned int *count)
 {
                struct definition const * const **list,
                unsigned int *count)
 {
@@ -178,9 +178,9 @@ int bt_ctf_get_field_list(struct bt_ctf_event *event,
                goto error;
        case CTF_TYPE_STRUCT:
        {
                goto error;
        case CTF_TYPE_STRUCT:
        {
-               struct definition_struct *def_struct;
+               const struct definition_struct *def_struct;
 
 
-               def_struct = container_of(scope, struct definition_struct, p);
+               def_struct = container_of(scope, const struct definition_struct, p);
                if (!def_struct)
                        goto error;
                if (def_struct->fields->pdata) {
                if (!def_struct)
                        goto error;
                if (def_struct->fields->pdata) {
@@ -195,9 +195,9 @@ int bt_ctf_get_field_list(struct bt_ctf_event *event,
                goto error;
        case CTF_TYPE_VARIANT:
        {
                goto error;
        case CTF_TYPE_VARIANT:
        {
-               struct definition_variant *def_variant;
+               const struct definition_variant *def_variant;
 
 
-               def_variant = container_of(scope, struct definition_variant, p);
+               def_variant = container_of(scope, const struct definition_variant, p);
                if (!def_variant)
                        goto error;
                if (def_variant->fields->pdata) {
                if (!def_variant)
                        goto error;
                if (def_variant->fields->pdata) {
@@ -210,9 +210,9 @@ int bt_ctf_get_field_list(struct bt_ctf_event *event,
        }
        case CTF_TYPE_ARRAY:
        {
        }
        case CTF_TYPE_ARRAY:
        {
-               struct definition_array *def_array;
+               const struct definition_array *def_array;
 
 
-               def_array = container_of(scope, struct definition_array, p);
+               def_array = container_of(scope, const struct definition_array, p);
                if (!def_array)
                        goto error;
                if (def_array->elems->pdata) {
                if (!def_array)
                        goto error;
                if (def_array->elems->pdata) {
@@ -225,9 +225,9 @@ int bt_ctf_get_field_list(struct bt_ctf_event *event,
        }
        case CTF_TYPE_SEQUENCE:
        {
        }
        case CTF_TYPE_SEQUENCE:
        {
-               struct definition_sequence *def_sequence;
+               const struct definition_sequence *def_sequence;
 
 
-               def_sequence = container_of(scope, struct definition_sequence, p);
+               def_sequence = container_of(scope, const struct definition_sequence, p);
                if (!def_sequence)
                        goto error;
                if (def_sequence->elems->pdata) {
                if (!def_sequence)
                        goto error;
                if (def_sequence->elems->pdata) {
@@ -251,7 +251,7 @@ error:
        return -1;
 }
 
        return -1;
 }
 
-uint64_t bt_ctf_get_timestamp_raw(struct bt_ctf_event *event)
+uint64_t bt_ctf_get_timestamp_raw(const struct bt_ctf_event *event)
 {
        if (event && event->stream->has_timestamp)
                return ctf_get_timestamp_raw(event->stream,
 {
        if (event && event->stream->has_timestamp)
                return ctf_get_timestamp_raw(event->stream,
@@ -260,7 +260,7 @@ uint64_t bt_ctf_get_timestamp_raw(struct bt_ctf_event *event)
                return -1ULL;
 }
 
                return -1ULL;
 }
 
-uint64_t bt_ctf_get_timestamp(struct bt_ctf_event *event)
+uint64_t bt_ctf_get_timestamp(const struct bt_ctf_event *event)
 {
        if (event && event->stream->has_timestamp)
                return ctf_get_timestamp(event->stream,
 {
        if (event && event->stream->has_timestamp)
                return ctf_get_timestamp(event->stream,
index 3413dbb02e07a2885e76aa2dc3f497bf1906953a..3597010a5b0b6d36a5c5b98bfc1028f19552bb5d 100644 (file)
@@ -32,8 +32,8 @@
 #include "events-private.h"
 
 struct bt_ctf_iter *bt_ctf_iter_create(struct bt_context *ctx,
 #include "events-private.h"
 
 struct bt_ctf_iter *bt_ctf_iter_create(struct bt_context *ctx,
-               struct bt_iter_pos *begin_pos,
-               struct bt_iter_pos *end_pos)
+               const struct bt_iter_pos *begin_pos,
+               const struct bt_iter_pos *end_pos)
 {
        struct bt_ctf_iter *iter;
        int ret;
 {
        struct bt_ctf_iter *iter;
        int ret;
index c78470ecab9fce91e4071984bc5470595c7f9200..9f579a060ded3cc272e40eeccfab3ef34475e46c 100644 (file)
 #include <babeltrace/ctf/callbacks-internal.h>
 #include <glib.h>
 
 #include <babeltrace/ctf/callbacks-internal.h>
 #include <glib.h>
 
+struct ctf_stream;
+struct ctf_stream_event;
+/*
+ * the structure to manipulate events
+ */
+struct bt_ctf_event {
+       struct ctf_stream *stream;
+       struct ctf_stream_event *event;
+};
+
 struct bt_ctf_iter {
        struct bt_iter parent;
        struct bt_ctf_event current_ctf_event;  /* last read event */
 struct bt_ctf_iter {
        struct bt_iter parent;
        struct bt_ctf_event current_ctf_event;  /* last read event */
index d0ec3e10615b3beefcee75bff226cc58431eacc0..80fbdcf2f5b634b9a720bec49c3aa8f69edd384e 100644 (file)
@@ -25,9 +25,8 @@
 
 #include <stdint.h>
 
 
 #include <stdint.h>
 
-struct ctf_stream;
-struct ctf_stream_event;
 struct definition;
 struct definition;
+struct bt_ctf_event;
 
 /*
  * the top-level scopes in CTF
 
 /*
  * the top-level scopes in CTF
@@ -68,14 +67,6 @@ enum ctf_string_encoding {
        CTF_STRING_UNKNOWN,
 };
 
        CTF_STRING_UNKNOWN,
 };
 
-/*
- * the structure to manipulate events
- */
-struct bt_ctf_event {
-       struct ctf_stream *stream;
-       struct ctf_stream_event *event;
-};
-
 /*
  * bt_ctf_get_top_level_scope: return a definition of the top-level scope
  *
 /*
  * bt_ctf_get_top_level_scope: return a definition of the top-level scope
  *
@@ -86,49 +77,49 @@ struct bt_ctf_event {
  * between the enum and the actual definition of top-level scopes.
  * On error return NULL.
  */
  * between the enum and the actual definition of top-level scopes.
  * On error return NULL.
  */
-struct definition *bt_ctf_get_top_level_scope(struct bt_ctf_event *event,
+const struct definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *event,
                enum bt_ctf_scope scope);
 
 /*
  * bt_ctf_event_get_name: returns the name of the event or NULL on error
  */
                enum bt_ctf_scope scope);
 
 /*
  * bt_ctf_event_get_name: returns the name of the event or NULL on error
  */
-const char *bt_ctf_event_name(struct bt_ctf_event *event);
+const char *bt_ctf_event_name(const struct bt_ctf_event *event);
 
 /*
  * bt_ctf_get_timestamp_raw: returns the timestamp of the event as written in
  * the packet or -1ULL on error
  */
 
 /*
  * bt_ctf_get_timestamp_raw: returns the timestamp of the event as written in
  * the packet or -1ULL on error
  */
-uint64_t bt_ctf_get_timestamp_raw(struct bt_ctf_event *event);
+uint64_t bt_ctf_get_timestamp_raw(const struct bt_ctf_event *event);
 
 /*
  * bt_ctf_get_timestamp: returns the timestamp of the event offsetted with the
  * system clock source or -1ULL on error
  */
 
 /*
  * bt_ctf_get_timestamp: returns the timestamp of the event offsetted with the
  * system clock source or -1ULL on error
  */
-uint64_t bt_ctf_get_timestamp(struct bt_ctf_event *event);
+uint64_t bt_ctf_get_timestamp(const struct bt_ctf_event *event);
 
 /*
  * bt_ctf_get_field_list: set list pointer to an array of definition
  * pointers and set count to the number of elements in the array.
  * Return 0 on success and a negative value on error.
  */
 
 /*
  * bt_ctf_get_field_list: set list pointer to an array of definition
  * pointers and set count to the number of elements in the array.
  * Return 0 on success and a negative value on error.
  */
-int bt_ctf_get_field_list(struct bt_ctf_event *event,
-               struct definition *scope,
+int bt_ctf_get_field_list(const struct bt_ctf_event *event,
+               const struct definition *scope,
                struct definition const * const **list,
                unsigned int *count);
 
 /*
  * bt_ctf_get_field: returns the definition of a specific field
  */
                struct definition const * const **list,
                unsigned int *count);
 
 /*
  * bt_ctf_get_field: returns the definition of a specific field
  */
-struct definition *bt_ctf_get_field(struct bt_ctf_event *event,
-               struct definition *scope,
+const struct definition *bt_ctf_get_field(const struct bt_ctf_event *event,
+               const struct definition *scope,
                const char *field);
 
 /*
  * bt_ctf_get_index: if the field is an array or a sequence, return the element
  * at position index, otherwise return NULL;
  */
                const char *field);
 
 /*
  * bt_ctf_get_index: if the field is an array or a sequence, return the element
  * at position index, otherwise return NULL;
  */
-struct definition *bt_ctf_get_index(struct bt_ctf_event *event,
-               struct definition *field,
+const struct definition *bt_ctf_get_index(const struct bt_ctf_event *event,
+               const struct definition *field,
                unsigned int index);
 
 /*
                unsigned int index);
 
 /*
index 8f9af0e19e3b8af855f2e3fae71200014b8af16c..71f935a0fe581c557ea8e3585b19c9fcde763de9 100644 (file)
@@ -41,8 +41,8 @@ struct bt_ctf_event;
  * trace) is the EOF criterion.
  */
 struct bt_ctf_iter *bt_ctf_iter_create(struct bt_context *ctx,
  * trace) is the EOF criterion.
  */
 struct bt_ctf_iter *bt_ctf_iter_create(struct bt_context *ctx,
-               struct bt_iter_pos *begin_pos,
-               struct bt_iter_pos *end_pos);
+               const struct bt_iter_pos *begin_pos,
+               const struct bt_iter_pos *end_pos);
 
 /*
  * bt_ctf_get_iter - get iterator from ctf iterator.
 
 /*
  * bt_ctf_get_iter - get iterator from ctf iterator.
index ea47745a723c9b1a84d82942daa8434885be9917..8000875ec5cefa76897f418448dfde77ab83be23 100644 (file)
@@ -30,7 +30,7 @@
 struct bt_iter {
        struct ptr_heap *stream_heap;
        struct bt_context *ctx;
 struct bt_iter {
        struct ptr_heap *stream_heap;
        struct bt_context *ctx;
-       struct bt_iter_pos *end_pos;
+       const struct bt_iter_pos *end_pos;
 };
 
 /*
 };
 
 /*
@@ -46,8 +46,8 @@ struct bt_iter {
  * trace) is the EOF criterion.
  */
 struct bt_iter *bt_iter_create(struct bt_context *ctx,
  * trace) is the EOF criterion.
  */
 struct bt_iter *bt_iter_create(struct bt_context *ctx,
-               struct bt_iter_pos *begin_pos,
-               struct bt_iter_pos *end_pos);
+               const struct bt_iter_pos *begin_pos,
+               const struct bt_iter_pos *end_pos);
 
 /*
  * bt_iter_destroy - Free a trace collection iterator.
 
 /*
  * bt_iter_destroy - Free a trace collection iterator.
@@ -56,8 +56,8 @@ void bt_iter_destroy(struct bt_iter *iter);
 
 int bt_iter_init(struct bt_iter *iter,
                struct bt_context *ctx,
 
 int bt_iter_init(struct bt_iter *iter,
                struct bt_context *ctx,
-               struct bt_iter_pos *begin_pos,
-               struct bt_iter_pos *end_pos);
+               const struct bt_iter_pos *begin_pos,
+               const struct bt_iter_pos *end_pos);
 void bt_iter_fini(struct bt_iter *iter);
 
 #endif /* _BABELTRACE_ITERATOR_INTERNAL_H */
 void bt_iter_fini(struct bt_iter *iter);
 
 #endif /* _BABELTRACE_ITERATOR_INTERNAL_H */
index dd116f10ed49be0f42f32ccfcece918d20731502..9addebb20e7405c05e65593d785ae535c88be662 100644 (file)
@@ -507,15 +507,15 @@ void append_scope_path(const char *path, GArray *q);
 /*
  * Lookup helpers.
  */
 /*
  * Lookup helpers.
  */
-struct definition *lookup_definition(struct definition *definition,
+struct definition *lookup_definition(const struct definition *definition,
                                     const char *field_name);
                                     const char *field_name);
-struct definition_integer *lookup_integer(struct definition *definition,
+struct definition_integer *lookup_integer(const struct definition *definition,
                                          const char *field_name,
                                          int signedness);
                                          const char *field_name,
                                          int signedness);
-struct definition_enum *lookup_enum(struct definition *definition,
+struct definition_enum *lookup_enum(const struct definition *definition,
                                    const char *field_name,
                                    int signedness);
                                    const char *field_name,
                                    int signedness);
-struct definition *lookup_variant(struct definition *definition,
+struct definition *lookup_variant(const struct definition *definition,
                                  const char *field_name);
 
 static inline
                                  const char *field_name);
 
 static inline
index 0af151402b429d3fe95d9c92c42e9e07eb9436f5..e50846f4cb6179a7cd2eb1ac1903f042d4da5f1e 100644 (file)
@@ -430,8 +430,8 @@ end:
 
 int bt_iter_init(struct bt_iter *iter,
                struct bt_context *ctx,
 
 int bt_iter_init(struct bt_iter *iter,
                struct bt_context *ctx,
-               struct bt_iter_pos *begin_pos,
-               struct bt_iter_pos *end_pos)
+               const struct bt_iter_pos *begin_pos,
+               const struct bt_iter_pos *end_pos)
 {
        int i, stream_id;
        int ret = 0;
 {
        int i, stream_id;
        int ret = 0;
@@ -496,8 +496,8 @@ error_heap_init:
 }
 
 struct bt_iter *bt_iter_create(struct bt_context *ctx,
 }
 
 struct bt_iter *bt_iter_create(struct bt_context *ctx,
-               struct bt_iter_pos *begin_pos,
-               struct bt_iter_pos *end_pos)
+               const struct bt_iter_pos *begin_pos,
+               const struct bt_iter_pos *end_pos)
 {
        struct bt_iter *iter;
        int ret;
 {
        struct bt_iter *iter;
        int ret;
index d3c204aeed8f2a20c8d084ecd70c869414f2fb4b..450c93ba6b5206c9edcdd8fb726e92c0b029d73a 100644 (file)
@@ -147,7 +147,7 @@ end:
 }
 
 static struct definition_scope *
 }
 
 static struct definition_scope *
-       get_definition_scope(struct definition *definition)
+       get_definition_scope(const struct definition *definition)
 {
        return definition->scope;
 }
 {
        return definition->scope;
 }
@@ -600,7 +600,7 @@ void free_definition_scope(struct definition_scope *scope)
        g_free(scope);
 }
 
        g_free(scope);
 }
 
-struct definition *lookup_definition(struct definition *definition,
+struct definition *lookup_definition(const struct definition *definition,
                                     const char *field_name)
 {
        struct definition_scope *scope = get_definition_scope(definition);
                                     const char *field_name)
 {
        struct definition_scope *scope = get_definition_scope(definition);
@@ -612,7 +612,7 @@ struct definition *lookup_definition(struct definition *definition,
                                             scope);
 }
 
                                             scope);
 }
 
-struct definition_integer *lookup_integer(struct definition *definition,
+struct definition_integer *lookup_integer(const struct definition *definition,
                                          const char *field_name,
                                          int signedness)
 {
                                          const char *field_name,
                                          int signedness)
 {
@@ -630,7 +630,7 @@ struct definition_integer *lookup_integer(struct definition *definition,
        return lookup_integer;
 }
 
        return lookup_integer;
 }
 
-struct definition_enum *lookup_enum(struct definition *definition,
+struct definition_enum *lookup_enum(const struct definition *definition,
                                    const char *field_name,
                                    int signedness)
 {
                                    const char *field_name,
                                    int signedness)
 {
@@ -648,7 +648,7 @@ struct definition_enum *lookup_enum(struct definition *definition,
        return lookup_enum;
 }
 
        return lookup_enum;
 }
 
-struct definition *lookup_variant(struct definition *definition,
+struct definition *lookup_variant(const struct definition *definition,
                                  const char *field_name)
 {
        struct definition *lookup;
                                  const char *field_name)
 {
        struct definition *lookup;
This page took 0.032808 seconds and 4 git commands to generate.