From: Julien Desfossez Date: Fri, 30 Mar 2012 19:50:12 +0000 (-0400) Subject: fix/breakage API : replace bt_ctf_event X-Git-Tag: v1.0.0-rc1~16 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=8a4722b0ccf5cf30ee76a85bdf6bea2fa0515153;hp=d3ded99df05c7602749aa50530a1dc69db4cc066 fix/breakage API : replace bt_ctf_event Following the namespace cleanup, the bt_ctf_event structure is now a ctf_event_definition structure. Users of the API only have to do this substitution. Signed-off-by: Julien Desfossez Signed-off-by: Mathieu Desnoyers --- diff --git a/converter/babeltrace.c b/converter/babeltrace.c index aadeb441..fc590ecc 100644 --- a/converter/babeltrace.c +++ b/converter/babeltrace.c @@ -407,7 +407,7 @@ int convert_trace(struct trace_descriptor *td_write, struct bt_ctf_iter *iter; struct ctf_text_stream_pos *sout; struct bt_iter_pos begin_pos; - struct bt_ctf_event *ctf_event; + struct ctf_event_definition *ctf_event; int ret; sout = container_of(td_write, struct ctf_text_stream_pos, diff --git a/formats/ctf/callbacks.c b/formats/ctf/callbacks.c index 0b4da9c5..8e0d61e6 100644 --- a/formats/ctf/callbacks.c +++ b/formats/ctf/callbacks.c @@ -64,7 +64,7 @@ struct bt_dependencies *babeltrace_dependencies_create(const char *first, ...) */ int bt_ctf_iter_add_callback(struct bt_ctf_iter *iter, bt_intern_str event, void *private_data, int flags, - enum bt_cb_ret (*callback)(struct bt_ctf_event *ctf_data, + enum bt_cb_ret (*callback)(struct ctf_event_definition *ctf_data, void *private_data), struct bt_dependencies *depends, struct bt_dependencies *weak_depends, @@ -179,10 +179,9 @@ void process_callbacks(struct bt_ctf_iter *iter, struct bt_callback *cb; int i; enum bt_cb_ret ret; - struct bt_ctf_event ctf_data; + struct ctf_event_definition *ctf_data; - ctf_data.event = extract_ctf_stream_event(stream); - ctf_data.stream = stream; + ctf_data = extract_ctf_stream_event(stream); /* process all events callback first */ if (iter->main_callbacks.callback) { @@ -190,7 +189,7 @@ void process_callbacks(struct bt_ctf_iter *iter, cb = &g_array_index(iter->main_callbacks.callback, struct bt_callback, i); if (!cb) goto end; - ret = cb->callback(&ctf_data, cb->private_data); + ret = cb->callback(ctf_data, cb->private_data); switch (ret) { case BT_CB_OK_STOP: case BT_CB_ERROR_STOP: @@ -218,7 +217,7 @@ void process_callbacks(struct bt_ctf_iter *iter, cb = &g_array_index(bt_chain->callback, struct bt_callback, i); if (!cb) goto end; - ret = cb->callback(&ctf_data, cb->private_data); + ret = cb->callback(ctf_data, cb->private_data); switch (ret) { case BT_CB_OK_STOP: case BT_CB_ERROR_STOP: diff --git a/formats/ctf/events.c b/formats/ctf/events.c index 71665ce0..714216f3 100644 --- a/formats/ctf/events.c +++ b/formats/ctf/events.c @@ -38,7 +38,7 @@ */ __thread int bt_ctf_last_field_error = 0; -const struct definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *event, +const struct definition *bt_ctf_get_top_level_scope(const struct ctf_event_definition *event, enum bt_ctf_scope scope) { struct definition *tmp = NULL; @@ -69,16 +69,12 @@ const struct definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *e tmp = &event->stream->stream_event_context->p; break; case BT_EVENT_CONTEXT: - if (!event->event) - goto error; - if (event->event->event_context) - tmp = &event->event->event_context->p; + if (event->event_context) + tmp = &event->event_context->p; break; case BT_EVENT_FIELDS: - if (!event->event) - goto error; - if (event->event->event_fields) - tmp = &event->event->event_fields->p; + if (event->event_fields) + tmp = &event->event_fields->p; break; } return tmp; @@ -87,7 +83,7 @@ error: return NULL; } -const struct definition *bt_ctf_get_field(const struct bt_ctf_event *event, +const struct definition *bt_ctf_get_field(const struct ctf_event_definition *event, const struct definition *scope, const char *field) { @@ -118,7 +114,7 @@ const struct definition *bt_ctf_get_field(const struct bt_ctf_event *event, return NULL; } -const struct definition *bt_ctf_get_index(const struct bt_ctf_event *event, +const struct definition *bt_ctf_get_index(const struct ctf_event_definition *event, const struct definition *field, unsigned int index) { @@ -138,7 +134,7 @@ const struct definition *bt_ctf_get_index(const struct bt_ctf_event *event, return ret; } -const char *bt_ctf_event_name(const struct bt_ctf_event *event) +const char *bt_ctf_event_name(const struct ctf_event_definition *event) { struct ctf_event_declaration *event_class; struct ctf_stream_declaration *stream_class; @@ -165,7 +161,7 @@ enum ctf_type_id bt_ctf_field_type(const struct definition *def) return CTF_TYPE_UNKNOWN; } -int bt_ctf_get_field_list(const struct bt_ctf_event *event, +int bt_ctf_get_field_list(const struct ctf_event_definition *event, const struct definition *scope, struct definition const * const **list, unsigned int *count) @@ -251,7 +247,7 @@ error: return -1; } -struct bt_context *bt_ctf_event_get_context(const struct bt_ctf_event *event) +struct bt_context *bt_ctf_event_get_context(const struct ctf_event_definition *event) { struct bt_context *ret = NULL; struct ctf_file_stream *cfs; @@ -266,7 +262,7 @@ struct bt_context *bt_ctf_event_get_context(const struct bt_ctf_event *event) return ret; } -int bt_ctf_event_get_handle_id(const struct bt_ctf_event *event) +int bt_ctf_event_get_handle_id(const struct ctf_event_definition *event) { int ret = -1; struct ctf_file_stream *cfs; @@ -281,7 +277,7 @@ int bt_ctf_event_get_handle_id(const struct bt_ctf_event *event) return ret; } -uint64_t bt_ctf_get_timestamp_raw(const struct bt_ctf_event *event) +uint64_t bt_ctf_get_timestamp_raw(const struct ctf_event_definition *event) { if (event && event->stream->has_timestamp) return ctf_get_timestamp_raw(event->stream, @@ -290,7 +286,7 @@ uint64_t bt_ctf_get_timestamp_raw(const struct bt_ctf_event *event) return -1ULL; } -uint64_t bt_ctf_get_timestamp(const struct bt_ctf_event *event) +uint64_t bt_ctf_get_timestamp(const struct ctf_event_definition *event) { if (event && event->stream->has_timestamp) return ctf_get_timestamp(event->stream, diff --git a/formats/ctf/iterator.c b/formats/ctf/iterator.c index 3597010a..5cc7dbad 100644 --- a/formats/ctf/iterator.c +++ b/formats/ctf/iterator.c @@ -86,19 +86,20 @@ struct bt_iter *bt_ctf_get_iter(struct bt_ctf_iter *iter) return &iter->parent; } -struct bt_ctf_event *bt_ctf_iter_read_event(struct bt_ctf_iter *iter) +struct ctf_event_definition *bt_ctf_iter_read_event(struct bt_ctf_iter *iter) { struct ctf_file_stream *file_stream; - struct bt_ctf_event *ret = &iter->current_ctf_event; + struct ctf_event_definition *ret = &iter->current_ctf_event; + struct ctf_stream_definition *stream; file_stream = heap_maximum(iter->parent.stream_heap); if (!file_stream) { /* end of file for all streams */ goto stop; } - ret->stream = &file_stream->parent; - ret->event = g_ptr_array_index(ret->stream->events_by_id, - ret->stream->event_id); + stream = &file_stream->parent; + ret = g_ptr_array_index(stream->events_by_id, + stream->event_id); if (ret->stream->stream_id > iter->callbacks->len) goto end; diff --git a/include/babeltrace/context.h b/include/babeltrace/context.h index 4a85ff99..9fa22fbf 100644 --- a/include/babeltrace/context.h +++ b/include/babeltrace/context.h @@ -29,7 +29,7 @@ /* struct bt_context is opaque to the user */ struct bt_context; struct stream_pos; -struct bt_ctf_event; +struct ctf_event_definition; /* * bt_context_create : create a Babeltrace context @@ -102,6 +102,6 @@ void bt_context_put(struct bt_context *ctx); * * Returns NULL on error */ -struct bt_context *bt_ctf_event_get_context(const struct bt_ctf_event *event); +struct bt_context *bt_ctf_event_get_context(const struct ctf_event_definition *event); #endif /* _BABELTRACE_CONTEXT_H */ diff --git a/include/babeltrace/ctf/callbacks-internal.h b/include/babeltrace/ctf/callbacks-internal.h index b76f82e1..e9528da5 100644 --- a/include/babeltrace/ctf/callbacks-internal.h +++ b/include/babeltrace/ctf/callbacks-internal.h @@ -31,7 +31,7 @@ struct bt_callback { struct bt_dependencies *depends; struct bt_dependencies *weak_depends; struct bt_dependencies *provides; - enum bt_cb_ret (*callback)(struct bt_ctf_event *ctf_data, + enum bt_cb_ret (*callback)(struct ctf_event_definition *ctf_data, void *private_data); }; diff --git a/include/babeltrace/ctf/callbacks.h b/include/babeltrace/ctf/callbacks.h index 328762ca..43d7af1c 100644 --- a/include/babeltrace/ctf/callbacks.h +++ b/include/babeltrace/ctf/callbacks.h @@ -84,7 +84,7 @@ void babeltrace_dependencies_destroy(struct bt_dependencies *dep); */ int bt_ctf_iter_add_callback(struct bt_ctf_iter *iter, bt_intern_str event, void *private_data, int flags, - enum bt_cb_ret (*callback)(struct bt_ctf_event *ctf_data, + enum bt_cb_ret (*callback)(struct ctf_event_definition *ctf_data, void *caller_data), struct bt_dependencies *depends, struct bt_dependencies *weak_depends, diff --git a/include/babeltrace/ctf/events-internal.h b/include/babeltrace/ctf/events-internal.h index 2ff37545..bd50100d 100644 --- a/include/babeltrace/ctf/events-internal.h +++ b/include/babeltrace/ctf/events-internal.h @@ -26,21 +26,14 @@ #include #include #include +#include #include struct ctf_stream_definition; -struct ctf_event_definition; -/* - * the structure to manipulate events - */ -struct bt_ctf_event { - struct ctf_stream_definition *stream; - struct ctf_event_definition *event; -}; struct bt_ctf_iter { struct bt_iter parent; - struct bt_ctf_event current_ctf_event; /* last read event */ + struct ctf_event_definition current_ctf_event; /* last read event */ GArray *callbacks; /* Array of struct bt_stream_callbacks */ struct bt_callback_chain main_callbacks; /* For all events */ /* diff --git a/include/babeltrace/ctf/events.h b/include/babeltrace/ctf/events.h index 80fbdcf2..2fc82db2 100644 --- a/include/babeltrace/ctf/events.h +++ b/include/babeltrace/ctf/events.h @@ -26,7 +26,7 @@ #include struct definition; -struct bt_ctf_event; +struct ctf_event_definition; /* * the top-level scopes in CTF @@ -77,32 +77,32 @@ enum ctf_string_encoding { * between the enum and the actual definition of top-level scopes. * On error return NULL. */ -const struct definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *event, +const struct definition *bt_ctf_get_top_level_scope(const struct ctf_event_definition *event, 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(const struct bt_ctf_event *event); +const char *bt_ctf_event_name(const struct ctf_event_definition *event); /* * 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(const struct bt_ctf_event *event); +uint64_t bt_ctf_get_timestamp_raw(const struct ctf_event_definition *event); /* * 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(const struct bt_ctf_event *event); +uint64_t bt_ctf_get_timestamp(const struct ctf_event_definition *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. */ -int bt_ctf_get_field_list(const struct bt_ctf_event *event, +int bt_ctf_get_field_list(const struct ctf_event_definition *event, const struct definition *scope, struct definition const * const **list, unsigned int *count); @@ -110,7 +110,7 @@ int bt_ctf_get_field_list(const struct bt_ctf_event *event, /* * bt_ctf_get_field: returns the definition of a specific field */ -const struct definition *bt_ctf_get_field(const struct bt_ctf_event *event, +const struct definition *bt_ctf_get_field(const struct ctf_event_definition *event, const struct definition *scope, const char *field); @@ -118,7 +118,7 @@ const struct definition *bt_ctf_get_field(const struct bt_ctf_event *event, * bt_ctf_get_index: if the field is an array or a sequence, return the element * at position index, otherwise return NULL; */ -const struct definition *bt_ctf_get_index(const struct bt_ctf_event *event, +const struct definition *bt_ctf_get_index(const struct ctf_event_definition *event, const struct definition *field, unsigned int index); diff --git a/include/babeltrace/ctf/iterator.h b/include/babeltrace/ctf/iterator.h index 1071def8..7aeb032c 100644 --- a/include/babeltrace/ctf/iterator.h +++ b/include/babeltrace/ctf/iterator.h @@ -26,7 +26,7 @@ #include struct bt_ctf_iter; -struct bt_ctf_event; +struct ctf_event_definition; /* * bt_ctf_iter_create - Allocate a CTF trace collection iterator. @@ -68,6 +68,6 @@ void bt_ctf_iter_destroy(struct bt_ctf_iter *iter); * * Return current event on success, NULL on end of trace. */ -struct bt_ctf_event *bt_ctf_iter_read_event(struct bt_ctf_iter *iter); +struct ctf_event_definition *bt_ctf_iter_read_event(struct bt_ctf_iter *iter); #endif /* _BABELTRACE_CTF_ITERATOR_H */ diff --git a/include/babeltrace/trace-handle.h b/include/babeltrace/trace-handle.h index 31877ee1..0c83bf74 100644 --- a/include/babeltrace/trace-handle.h +++ b/include/babeltrace/trace-handle.h @@ -31,7 +31,7 @@ * It is a unique identifier representing a trace file. */ struct bt_trace_handle; -struct bt_ctf_event; +struct ctf_event_definition; /* * bt_trace_handle_get_path : returns the path of a trace_handle. @@ -55,6 +55,6 @@ uint64_t bt_trace_handle_get_timestamp_end(struct bt_context *ctx, int handle_id * * Returns -1 on error */ -int bt_ctf_event_get_handle_id(const struct bt_ctf_event *event); +int bt_ctf_event_get_handle_id(const struct ctf_event_definition *event); #endif /* _BABELTRACE_TRACE_HANDLE_H */