metababel 0.1.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -1
- data/bin/metababel +392 -165
- data/lib/metababel/bt2_generator_utils.rb +2 -2
- data/lib/metababel/bt2_matching_utils.rb +72 -0
- data/lib/metababel/{bt2_stream_classes_generator.rb → bt2_trace_class_generator.rb} +204 -20
- data/lib/metababel/bt2_values_generator.rb +3 -3
- data/lib/metababel/version.rb +1 -1
- data/lib/metababel.rb +1 -1
- data/template/component.c.erb +15 -49
- data/template/component.h.erb +43 -17
- data/template/downstream.c.erb +51 -20
- data/template/downstream.h.erb +11 -1
- data/template/filter.c.erb +49 -49
- data/template/sink.c.erb +23 -42
- data/template/source.c.erb +33 -20
- data/template/upstream.c.erb +63 -111
- data/template/upstream.h.erb +10 -36
- metadata +6 -4
data/template/component.h.erb
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
#include "uthash.h"
|
|
5
5
|
#include <babeltrace2/babeltrace.h>
|
|
6
6
|
#include <stdbool.h>
|
|
7
|
+
<% if options.key?(:usr_data_header) %>
|
|
8
|
+
#include "<%= options[:usr_data_header] %>"
|
|
9
|
+
<% end %>
|
|
7
10
|
|
|
8
11
|
#ifdef __cplusplus
|
|
9
12
|
extern "C" {
|
|
@@ -14,27 +17,35 @@ struct common_data_s;
|
|
|
14
17
|
typedef struct common_data_s common_data_t;
|
|
15
18
|
|
|
16
19
|
// Params
|
|
17
|
-
// Avoid icx error: empty struct has size 0 in C, size 1 in C++
|
|
20
|
+
// Avoid icx error: empty struct has size 0 in C, size 1 in C++
|
|
21
|
+
// [-Werror,-Wextern-c-compat]
|
|
18
22
|
struct btx_params_s {
|
|
19
|
-
<% if params_declaration %>
|
|
23
|
+
<% if params_declaration %>
|
|
20
24
|
<%= params_declaration %>
|
|
21
|
-
<% else %>
|
|
22
|
-
|
|
23
|
-
<% end %>
|
|
25
|
+
<% else %>
|
|
26
|
+
char _dummy;
|
|
27
|
+
<% end %>
|
|
24
28
|
|
|
25
29
|
}; <%# Need empty line for nice code gen %>
|
|
26
30
|
typedef struct btx_params_s btx_params_t;
|
|
27
31
|
|
|
28
32
|
void btx_populate_params(common_data_t *common_data_t);
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
struct callbacks_s {
|
|
35
|
+
<% callback_types.each do |c| %>
|
|
36
|
+
UT_array *<%= c %>;
|
|
37
|
+
<% end %>
|
|
38
|
+
};
|
|
39
|
+
typedef struct callbacks_s callbacks_t;
|
|
40
|
+
|
|
41
|
+
<%# Forward Declaration %>
|
|
42
|
+
struct static_callbacks_s;
|
|
43
|
+
typedef struct static_callbacks_s static_callbacks_t;
|
|
33
44
|
|
|
34
45
|
struct name_to_dispatcher_s {
|
|
35
46
|
const char *name;
|
|
36
47
|
void *dispatcher;
|
|
37
|
-
|
|
48
|
+
callbacks_t *callbacks;
|
|
38
49
|
UT_hash_handle hh;
|
|
39
50
|
};
|
|
40
51
|
typedef struct name_to_dispatcher_s name_to_dispatcher_t;
|
|
@@ -51,6 +62,10 @@ struct el {
|
|
|
51
62
|
<% if options[:component_type] == 'SOURCE' %>
|
|
52
63
|
struct common_data_s {
|
|
53
64
|
name_to_dispatcher_t *name_to_dispatcher;
|
|
65
|
+
static_callbacks_t *static_callbacks;
|
|
66
|
+
<% unless options[:disable_callbaks].include?('on_downstream') %>
|
|
67
|
+
void *on_downstream_message_callback;
|
|
68
|
+
<% end %>
|
|
54
69
|
void *usr_data;
|
|
55
70
|
const bt_value *params;
|
|
56
71
|
btx_params_t *btx_params;
|
|
@@ -89,7 +104,11 @@ typedef enum btx_source_status_e btx_source_status_t;
|
|
|
89
104
|
<% elsif options[:component_type] == 'FILTER' %>
|
|
90
105
|
struct common_data_s {
|
|
91
106
|
name_to_dispatcher_t *name_to_dispatcher;
|
|
92
|
-
|
|
107
|
+
static_callbacks_t *static_callbacks;
|
|
108
|
+
<% unless options[:disable_callbaks].include?('on_downstream') %>
|
|
109
|
+
void *on_downstream_message_callback;
|
|
110
|
+
<% end %>
|
|
111
|
+
|
|
93
112
|
void *usr_data;
|
|
94
113
|
const bt_value *params;
|
|
95
114
|
btx_params_t *btx_params;
|
|
@@ -139,7 +158,8 @@ typedef struct btx_message_iterator_s btx_message_iterator_t;
|
|
|
139
158
|
<% elsif options[:component_type] == 'SINK' %>
|
|
140
159
|
struct common_data_s {
|
|
141
160
|
name_to_dispatcher_t *name_to_dispatcher;
|
|
142
|
-
|
|
161
|
+
static_callbacks_t *static_callbacks;
|
|
162
|
+
|
|
143
163
|
void *usr_data;
|
|
144
164
|
const bt_value *params;
|
|
145
165
|
btx_params_t *btx_params;
|
|
@@ -150,19 +170,25 @@ struct common_data_s {
|
|
|
150
170
|
|
|
151
171
|
void btx_register_usr_callbacks(void *btx_handle);
|
|
152
172
|
|
|
153
|
-
<%
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
<%= e.
|
|
157
|
-
|
|
173
|
+
<% static_callback_types.each do |e| %>
|
|
174
|
+
typedef void <%= e.name_sanitized %>_static_callback_f(
|
|
175
|
+
<%= "void *btx_handle," unless e.no_btx_handle %>
|
|
176
|
+
<%= e.args.map{ |s| s.type }.join(", ") %>);
|
|
177
|
+
|
|
158
178
|
<%# The Function who register the callbacks to the dispatcher %>
|
|
159
179
|
void btx_register_callbacks_<%= e.name_sanitized %>(
|
|
160
|
-
void *btx_handle, <%= e.name_sanitized %>
|
|
180
|
+
void *btx_handle, <%= e.name_sanitized %>_static_callback_f *callback);
|
|
161
181
|
|
|
162
182
|
void btx_call_callbacks_<%= e.name_sanitized %>(
|
|
163
183
|
common_data_t *common_data, <%= e.args.map{ |s| s.type }.join(", ") %>);
|
|
164
184
|
<% end %>
|
|
165
185
|
|
|
186
|
+
struct static_callbacks_s {
|
|
187
|
+
<% static_callback_types.each do |e| %>
|
|
188
|
+
<%= e.name_sanitized %>_static_callback_f *<%= e.name_sanitized %>;
|
|
189
|
+
<% end %>
|
|
190
|
+
};
|
|
191
|
+
|
|
166
192
|
#ifdef __cplusplus
|
|
167
193
|
}
|
|
168
194
|
#endif
|
data/template/downstream.c.erb
CHANGED
|
@@ -20,9 +20,9 @@ void btx_downstream_move_messages(
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
void
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
static inline void
|
|
24
|
+
_btx_push_message(btx_message_iterator_t *message_iterator_private_data,
|
|
25
|
+
const bt_message *message) {
|
|
26
26
|
|
|
27
27
|
struct el *elt;
|
|
28
28
|
if (message_iterator_private_data->pool) {
|
|
@@ -35,11 +35,41 @@ void btx_downstream_push_message(
|
|
|
35
35
|
DL_APPEND(message_iterator_private_data->queue, elt);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
<% unless options[:disable_callbaks].include?('on_downstream') %>
|
|
39
|
+
void btx_push_message(void *btx_handle, const bt_message *message) {
|
|
40
|
+
_btx_push_message((btx_message_iterator_t *)btx_handle, message);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void btx_register_on_downstream_message_callback(
|
|
44
|
+
void *btx_handle, on_downstream_message_callback_f *callback) {
|
|
45
|
+
((common_data_t *)btx_handle)->on_downstream_message_callback =
|
|
46
|
+
(void *)callback;
|
|
47
|
+
}
|
|
48
|
+
<% end %>
|
|
49
|
+
// Used internaly to push messages downstreams
|
|
50
|
+
void btx_downstream_push_message(
|
|
51
|
+
btx_message_iterator_t *message_iterator_private_data,
|
|
52
|
+
const bt_message *message) {
|
|
53
|
+
|
|
54
|
+
<% unless options[:disable_callbaks].include?('on_downstream') %>
|
|
55
|
+
on_downstream_message_callback_f *p =
|
|
56
|
+
(on_downstream_message_callback_f *)message_iterator_private_data
|
|
57
|
+
->common_data->on_downstream_message_callback;
|
|
58
|
+
if (p) {
|
|
59
|
+
p(((void *)message_iterator_private_data),
|
|
60
|
+
message_iterator_private_data->common_data->usr_data, message);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
<% end %>
|
|
64
|
+
_btx_push_message(message_iterator_private_data, message);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Register callbacks
|
|
38
68
|
bt_trace_class *
|
|
39
|
-
btx_downstream_trace_class_create_rec(bt_self_component *
|
|
40
|
-
bt_trace_class *
|
|
69
|
+
btx_downstream_trace_class_create_rec(bt_self_component *_self_component) {
|
|
70
|
+
bt_trace_class *_trace_class;
|
|
41
71
|
<%= body_declarator_classes %>
|
|
42
|
-
return
|
|
72
|
+
return _trace_class;
|
|
43
73
|
}
|
|
44
74
|
|
|
45
75
|
bt_trace *btx_downstream_trace_create_rec(bt_trace_class *trace_class) {
|
|
@@ -115,30 +145,31 @@ static void btx_set_message_<%= e.name_sanitized %>(
|
|
|
115
145
|
|
|
116
146
|
void btx_push_message_<%= e.name_sanitized %>(
|
|
117
147
|
void *
|
|
118
|
-
btx_handle<%=
|
|
148
|
+
btx_handle<%= e.args.map{ |s| "#{s.type} #{s.name}" }.join_with_prefix(", ") %>) {
|
|
119
149
|
|
|
120
150
|
common_data_t *common_data = (common_data_t *)btx_handle;
|
|
121
151
|
|
|
122
|
-
bt_stream *
|
|
152
|
+
bt_stream *_stream = bt_trace_borrow_stream_by_index(
|
|
123
153
|
common_data->downstream_trace, <%= e.index_stream_class %>);
|
|
124
|
-
bt_stream_class *
|
|
125
|
-
bt_event_class *
|
|
126
|
-
|
|
154
|
+
bt_stream_class *_stream_class = bt_stream_borrow_class(_stream);
|
|
155
|
+
bt_event_class *_event_class = bt_stream_class_borrow_event_class_by_index(
|
|
156
|
+
_stream_class, <%= e.index_event_class %>);
|
|
127
157
|
<% if !e.default_clock_class %>
|
|
128
|
-
bt_message *
|
|
129
|
-
common_data->self_message_iterator,
|
|
158
|
+
bt_message *_message = bt_message_event_create(
|
|
159
|
+
common_data->self_message_iterator, _event_class, _stream);
|
|
130
160
|
<% else %>
|
|
131
|
-
bt_message *
|
|
132
|
-
common_data->self_message_iterator,
|
|
161
|
+
bt_message *_message = bt_message_event_create_with_default_clock_snapshot(
|
|
162
|
+
common_data->self_message_iterator, _event_class, _stream, _timestamp);
|
|
133
163
|
<% end %>
|
|
134
164
|
|
|
135
|
-
bt_event *
|
|
165
|
+
bt_event *_downstream_event = bt_message_event_borrow_event(_message);
|
|
136
166
|
|
|
137
167
|
btx_set_message_<%= e.name_sanitized %>(
|
|
138
|
-
|
|
168
|
+
_downstream_event<%= e.args.map{ |s| s.name }.join_with_prefix(", ") %>);
|
|
139
169
|
|
|
140
|
-
btx_message_iterator_t *
|
|
141
|
-
bt_self_message_iterator_get_data(
|
|
142
|
-
|
|
170
|
+
btx_message_iterator_t *_message_iterator_private_data =
|
|
171
|
+
(btx_message_iterator_t *)bt_self_message_iterator_get_data(
|
|
172
|
+
common_data->self_message_iterator);
|
|
173
|
+
btx_downstream_push_message(_message_iterator_private_data, _message);
|
|
143
174
|
}
|
|
144
175
|
<% end %>
|
data/template/downstream.h.erb
CHANGED
|
@@ -30,8 +30,18 @@ void btx_push_messages_stream_end(
|
|
|
30
30
|
<% downstream_events.each do |e| %>
|
|
31
31
|
void btx_push_message_<%= e.name_sanitized %>(
|
|
32
32
|
void *
|
|
33
|
-
btx_handle<%=
|
|
33
|
+
btx_handle<%= e.args.map{ |s| "#{s.type} #{s.name}" }.join_with_prefix(", ") %>);
|
|
34
34
|
<% end %>
|
|
35
|
+
|
|
36
|
+
<% unless options[:disable_callbaks].include?('on_downstream') %>
|
|
37
|
+
void btx_push_message(void *btx_handle, const bt_message *message);
|
|
38
|
+
|
|
39
|
+
typedef void on_downstream_message_callback_f(void *btx_handle, void *usr_data,
|
|
40
|
+
const bt_message *message);
|
|
41
|
+
void btx_register_on_downstream_message_callback(
|
|
42
|
+
void *btx_handle, on_downstream_message_callback_f *callback);
|
|
43
|
+
<% end %>
|
|
44
|
+
|
|
35
45
|
#ifdef __cplusplus
|
|
36
46
|
}
|
|
37
47
|
#endif
|
data/template/filter.c.erb
CHANGED
|
@@ -28,7 +28,8 @@ filter_message_iterator_next_finalizing(
|
|
|
28
28
|
bt_message_array_const messages, uint64_t capacity, uint64_t *count) {
|
|
29
29
|
|
|
30
30
|
btx_message_iterator_t *message_iterator_private_data =
|
|
31
|
-
bt_self_message_iterator_get_data(
|
|
31
|
+
(btx_message_iterator_t *)bt_self_message_iterator_get_data(
|
|
32
|
+
self_message_iterator);
|
|
32
33
|
|
|
33
34
|
/* No more messages, we can stop the plugin, and transition to END */
|
|
34
35
|
if (!message_iterator_private_data->queue) {
|
|
@@ -55,7 +56,8 @@ filter_message_iterator_next_processing_sending(
|
|
|
55
56
|
bt_message_array_const messages, uint64_t capacity, uint64_t *count) {
|
|
56
57
|
/* Retrieve our private data from the message iterator's user data */
|
|
57
58
|
btx_message_iterator_t *message_iterator_private_data =
|
|
58
|
-
bt_self_message_iterator_get_data(
|
|
59
|
+
(btx_message_iterator_t *)bt_self_message_iterator_get_data(
|
|
60
|
+
self_message_iterator);
|
|
59
61
|
|
|
60
62
|
/* This should never append. When transitioning to sending,
|
|
61
63
|
we check that we have some messages to send */
|
|
@@ -104,35 +106,18 @@ static inline void filter_message_iterator_next_call_dispatchers(
|
|
|
104
106
|
/* Borrow the event message's event and its class */
|
|
105
107
|
const bt_event *event = bt_message_event_borrow_event_const(upstream_message);
|
|
106
108
|
const bt_event_class *event_class = bt_event_borrow_class_const(event);
|
|
107
|
-
|
|
108
|
-
bool is_callback_called = false;
|
|
109
|
+
|
|
109
110
|
/* Event dispatcher */
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
/* Matching Dispacher */
|
|
119
|
-
{
|
|
120
|
-
const bt_stream_class *stream_class =
|
|
121
|
-
bt_event_class_borrow_stream_class_const(event_class);
|
|
122
|
-
const char *stream_class_name = bt_stream_class_get_name(stream_class);
|
|
123
|
-
|
|
124
|
-
name_to_dispatcher_t *s = NULL;
|
|
125
|
-
if (stream_class_name)
|
|
126
|
-
HASH_FIND_STR(common_data->name_to_matching_dispatcher,
|
|
127
|
-
stream_class_name, s);
|
|
128
|
-
if (s)
|
|
129
|
-
(*((dispatcher_t(*))(s->dispatcher)))(
|
|
130
|
-
s->callbacks, common_data, upstream_message, &is_callback_called);
|
|
131
|
-
}
|
|
132
|
-
/* Drop or push upstream message*/
|
|
133
|
-
if (is_callback_called) {
|
|
111
|
+
const char *class_name = bt_event_class_get_name(event_class);
|
|
112
|
+
name_to_dispatcher_t *s = NULL;
|
|
113
|
+
HASH_FIND_STR(common_data->name_to_dispatcher, class_name, s);
|
|
114
|
+
if (s) {
|
|
115
|
+
(*((dispatcher_t(*))(s->dispatcher)))(s->callbacks, common_data,
|
|
116
|
+
upstream_message);
|
|
117
|
+
/* Drop message */
|
|
134
118
|
bt_message_put_ref(upstream_message);
|
|
135
119
|
} else {
|
|
120
|
+
/* Push upstream message to downstream */
|
|
136
121
|
btx_downstream_push_message(message_iterator_private_data,
|
|
137
122
|
upstream_message);
|
|
138
123
|
}
|
|
@@ -142,10 +127,12 @@ static inline void
|
|
|
142
127
|
filter_message_iterator_next_processing_reading_to_finalizing(
|
|
143
128
|
bt_self_message_iterator *self_message_iterator,
|
|
144
129
|
btx_message_iterator_t *message_iterator_private_data) {
|
|
130
|
+
|
|
145
131
|
/* Call Finalize user callback */
|
|
146
|
-
|
|
132
|
+
btx_call_callbacks_finalize_processing(
|
|
147
133
|
message_iterator_private_data->common_data,
|
|
148
134
|
message_iterator_private_data->common_data->usr_data);
|
|
135
|
+
|
|
149
136
|
/* End of Stream */
|
|
150
137
|
btx_push_messages_stream_end(self_message_iterator,
|
|
151
138
|
message_iterator_private_data);
|
|
@@ -182,7 +169,8 @@ filter_message_iterator_next_processing_reading(
|
|
|
182
169
|
bt_message_array_const messages, uint64_t capacity, uint64_t *count) {
|
|
183
170
|
/* Retrieve our private data from the message iterator's user data */
|
|
184
171
|
btx_message_iterator_t *message_iterator_private_data =
|
|
185
|
-
bt_self_message_iterator_get_data(
|
|
172
|
+
(btx_message_iterator_t *)bt_self_message_iterator_get_data(
|
|
173
|
+
self_message_iterator);
|
|
186
174
|
|
|
187
175
|
common_data_t *common_data = message_iterator_private_data->common_data;
|
|
188
176
|
|
|
@@ -244,7 +232,8 @@ filter_message_iterator_next_processing(
|
|
|
244
232
|
bt_message_array_const messages, uint64_t capacity, uint64_t *count) {
|
|
245
233
|
|
|
246
234
|
btx_message_iterator_t *message_iterator_private_data =
|
|
247
|
-
bt_self_message_iterator_get_data(
|
|
235
|
+
(btx_message_iterator_t *)bt_self_message_iterator_get_data(
|
|
236
|
+
self_message_iterator);
|
|
248
237
|
|
|
249
238
|
switch (message_iterator_private_data->processing_state) {
|
|
250
239
|
case BTX_FILTER_PROCESSING_STATE_READING:
|
|
@@ -272,21 +261,17 @@ filter_message_iterator_next_initializing(
|
|
|
272
261
|
|
|
273
262
|
/* Retrieve our private data from the message iterator's user data */
|
|
274
263
|
btx_message_iterator_t *message_iterator_private_data =
|
|
275
|
-
bt_self_message_iterator_get_data(
|
|
264
|
+
(btx_message_iterator_t *)bt_self_message_iterator_get_data(
|
|
265
|
+
self_message_iterator);
|
|
276
266
|
|
|
277
267
|
/* Begining of Stream */
|
|
278
268
|
btx_push_messages_stream_beginning(self_message_iterator,
|
|
279
269
|
message_iterator_private_data);
|
|
280
270
|
|
|
281
271
|
/* Call Initialize user callback */
|
|
282
|
-
|
|
272
|
+
btx_call_callbacks_initialize_processing(
|
|
283
273
|
message_iterator_private_data->common_data,
|
|
284
|
-
|
|
285
|
-
/* Call read callbacks */
|
|
286
|
-
btx_call_callbacks_read_params(
|
|
287
|
-
message_iterator_private_data->common_data,
|
|
288
|
-
message_iterator_private_data->common_data->usr_data,
|
|
289
|
-
message_iterator_private_data->common_data->btx_params);
|
|
274
|
+
message_iterator_private_data->common_data->usr_data);
|
|
290
275
|
|
|
291
276
|
/* We need to transition to the processing state*/
|
|
292
277
|
message_iterator_private_data->state = BTX_FILTER_STATE_PROCESSING;
|
|
@@ -313,7 +298,8 @@ filter_message_iterator_next(bt_self_message_iterator *self_message_iterator,
|
|
|
313
298
|
|
|
314
299
|
/* Retrieve our private data from the message iterator's user data */
|
|
315
300
|
btx_message_iterator_t *message_iterator_private_data =
|
|
316
|
-
bt_self_message_iterator_get_data(
|
|
301
|
+
(btx_message_iterator_t *)bt_self_message_iterator_get_data(
|
|
302
|
+
self_message_iterator);
|
|
317
303
|
|
|
318
304
|
switch (message_iterator_private_data->state) {
|
|
319
305
|
case BTX_FILTER_STATE_INITIALIZING:
|
|
@@ -354,15 +340,24 @@ filter_initialize(bt_self_component_filter *self_component_filter,
|
|
|
354
340
|
const bt_value *params, void *initialize_method_data) {
|
|
355
341
|
|
|
356
342
|
/* Allocate a private data structure */
|
|
357
|
-
common_data_t *common_data =
|
|
358
|
-
|
|
343
|
+
common_data_t *common_data =
|
|
344
|
+
(common_data_t *)calloc(1, sizeof(common_data_t));
|
|
345
|
+
common_data->static_callbacks =
|
|
346
|
+
(static_callbacks_t *)calloc(1, sizeof(static_callbacks_t));
|
|
347
|
+
common_data->btx_params = (btx_params_t *)calloc(1, sizeof(btx_params_t));
|
|
359
348
|
common_data->params = params;
|
|
349
|
+
|
|
360
350
|
/* Read parameters */
|
|
361
351
|
btx_populate_params(common_data);
|
|
362
352
|
bt_value_get_ref(common_data->params);
|
|
363
353
|
|
|
364
354
|
/* Register User Callbacks */
|
|
365
355
|
btx_register_usr_callbacks((void *)common_data);
|
|
356
|
+
/* Call initialize_processing*/
|
|
357
|
+
btx_call_callbacks_initialize_component(common_data, &common_data->usr_data);
|
|
358
|
+
/* Call read callbacks */
|
|
359
|
+
btx_call_callbacks_read_params(common_data, common_data->usr_data,
|
|
360
|
+
common_data->btx_params);
|
|
366
361
|
|
|
367
362
|
/* Set the component's user data to our private data structure */
|
|
368
363
|
bt_self_component_set_data(
|
|
@@ -401,7 +396,8 @@ filter_initialize(bt_self_component_filter *self_component_filter,
|
|
|
401
396
|
/* Create message classes that will be used by the filter */
|
|
402
397
|
bt_self_component *self_component =
|
|
403
398
|
bt_self_component_filter_as_self_component(self_component_filter);
|
|
404
|
-
/* Create a `trace_class` and all the children's classes (stream and events)
|
|
399
|
+
/* Create a `trace_class` and all the children's classes (stream and events)
|
|
400
|
+
*/
|
|
405
401
|
bt_trace_class *trace_class =
|
|
406
402
|
btx_downstream_trace_class_create_rec(self_component);
|
|
407
403
|
/* Instantiate a `downstream_trace` of `trace_class` and all the children
|
|
@@ -435,13 +431,13 @@ static bt_message_iterator_class_initialize_method_status
|
|
|
435
431
|
filter_message_iterator_initialize(
|
|
436
432
|
bt_self_message_iterator *self_message_iterator,
|
|
437
433
|
bt_self_message_iterator_configuration *configuration,
|
|
438
|
-
bt_self_component_port_output *
|
|
434
|
+
bt_self_component_port_output *self_port_output) {
|
|
439
435
|
/* Allocate a private data structure */
|
|
440
436
|
btx_message_iterator_t *message_iterator_private_data =
|
|
441
|
-
calloc(1, sizeof(btx_message_iterator_t));
|
|
437
|
+
(btx_message_iterator_t *)calloc(1, sizeof(btx_message_iterator_t));
|
|
442
438
|
|
|
443
439
|
/* Retrieve the component's private data from its user data */
|
|
444
|
-
common_data_t *common_data = bt_self_component_get_data(
|
|
440
|
+
common_data_t *common_data = (common_data_t *)bt_self_component_get_data(
|
|
445
441
|
bt_self_message_iterator_borrow_component(self_message_iterator));
|
|
446
442
|
|
|
447
443
|
/* Save a link to the self_message_iterator */
|
|
@@ -481,19 +477,22 @@ filter_message_iterator_initialize(
|
|
|
481
477
|
}
|
|
482
478
|
|
|
483
479
|
static void filter_finalize(bt_self_component_filter *self_component_filter) {
|
|
484
|
-
common_data_t *common_data = bt_self_component_get_data(
|
|
480
|
+
common_data_t *common_data = (common_data_t *)bt_self_component_get_data(
|
|
485
481
|
bt_self_component_filter_as_self_component(self_component_filter));
|
|
486
482
|
|
|
483
|
+
/* Finalize Component */
|
|
484
|
+
btx_call_callbacks_finalize_component(common_data, common_data->usr_data);
|
|
485
|
+
|
|
487
486
|
btx_streams_put_ref(common_data->downstream_trace); // ??
|
|
488
487
|
/* We allocate it, we need to put ref */
|
|
489
488
|
bt_trace_put_ref(common_data->downstream_trace);
|
|
490
489
|
|
|
491
490
|
/* Delete name_to_dispatchers */
|
|
492
491
|
btx_delete_dispatchers(common_data);
|
|
493
|
-
btx_delete_matching_dispatchers(common_data);
|
|
494
492
|
|
|
495
493
|
/* We allocate it, we need to free it */
|
|
496
494
|
free(common_data->btx_params);
|
|
495
|
+
free(common_data->static_callbacks);
|
|
497
496
|
bt_value_put_ref(common_data->params);
|
|
498
497
|
free(common_data);
|
|
499
498
|
}
|
|
@@ -502,7 +501,8 @@ static void filter_message_iterator_finalize(
|
|
|
502
501
|
bt_self_message_iterator *self_message_iterator) {
|
|
503
502
|
/* Retrieve our private data from the message iterator's user data */
|
|
504
503
|
btx_message_iterator_t *message_iterator_private_data =
|
|
505
|
-
bt_self_message_iterator_get_data(
|
|
504
|
+
(btx_message_iterator_t *)bt_self_message_iterator_get_data(
|
|
505
|
+
self_message_iterator);
|
|
506
506
|
|
|
507
507
|
{
|
|
508
508
|
struct el *elt, *tmp;
|
data/template/sink.c.erb
CHANGED
|
@@ -19,7 +19,7 @@ sink_consume(bt_self_component_sink *self_component_sink) {
|
|
|
19
19
|
|
|
20
20
|
/* Retrieve our private data from the component's user data */
|
|
21
21
|
/* This containt user data and the message iterator */
|
|
22
|
-
common_data_t *common_data = bt_self_component_get_data(
|
|
22
|
+
common_data_t *common_data = (common_data_t *)bt_self_component_get_data(
|
|
23
23
|
bt_self_component_sink_as_self_component(self_component_sink));
|
|
24
24
|
|
|
25
25
|
/* Consume a batch of messages from the upstream message iterator */
|
|
@@ -55,37 +55,17 @@ sink_consume(bt_self_component_sink *self_component_sink) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/* Borrow the event message's event and its class */
|
|
58
|
-
const bt_event *event =
|
|
58
|
+
const bt_event *event =
|
|
59
|
+
bt_message_event_borrow_event_const(upstream_message);
|
|
59
60
|
const bt_event_class *event_class = bt_event_borrow_class_const(event);
|
|
60
61
|
|
|
61
|
-
/*
|
|
62
|
-
bool is_callback_called = false;
|
|
62
|
+
/* Event dispatcher */
|
|
63
63
|
const char *class_name = bt_event_class_get_name(event_class);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(*((dispatcher_t(*))(s->dispatcher)))(s->callbacks, common_data, upstream_message,
|
|
70
|
-
&is_callback_called);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
{
|
|
75
|
-
const bt_stream_class *stream_class =
|
|
76
|
-
bt_event_class_borrow_stream_class_const(event_class);
|
|
77
|
-
const char *stream_class_name = bt_stream_class_get_name(stream_class);
|
|
78
|
-
|
|
79
|
-
name_to_dispatcher_t *s = NULL;
|
|
80
|
-
if (stream_class_name)
|
|
81
|
-
HASH_FIND_STR(common_data->name_to_matching_dispatcher, stream_class_name,
|
|
82
|
-
s);
|
|
83
|
-
if (s) {
|
|
84
|
-
// is_callback_called will only be modified if at least one callback is
|
|
85
|
-
// called.
|
|
86
|
-
(*((dispatcher_t(*))(s->dispatcher)))(s->callbacks, common_data, upstream_message,
|
|
87
|
-
&is_callback_called);
|
|
88
|
-
}
|
|
64
|
+
name_to_dispatcher_t *s = NULL;
|
|
65
|
+
HASH_FIND_STR(common_data->name_to_dispatcher, class_name, s);
|
|
66
|
+
if (s) {
|
|
67
|
+
(*((dispatcher_t(*))(s->dispatcher)))(s->callbacks, common_data,
|
|
68
|
+
upstream_message);
|
|
89
69
|
}
|
|
90
70
|
|
|
91
71
|
bt_message_put_ref(upstream_message);
|
|
@@ -102,19 +82,21 @@ sink_initialize(bt_self_component_sink *self_component_sink,
|
|
|
102
82
|
bt_self_component_sink_configuration *configuration,
|
|
103
83
|
const bt_value *params, void *initialize_method_data) {
|
|
104
84
|
/* Allocate a private data structure */
|
|
105
|
-
common_data_t *common_data =
|
|
106
|
-
|
|
85
|
+
common_data_t *common_data =
|
|
86
|
+
(common_data_t *)calloc(1, sizeof(common_data_t));
|
|
87
|
+
common_data->static_callbacks =
|
|
88
|
+
(static_callbacks_t *)calloc(1, sizeof(static_callbacks_t));
|
|
89
|
+
common_data->btx_params = (btx_params_t *)calloc(1, sizeof(btx_params_t));
|
|
107
90
|
common_data->params = params;
|
|
108
|
-
// Read parameters
|
|
109
|
-
btx_populate_params(common_data);
|
|
110
91
|
|
|
92
|
+
/* Read parameters */
|
|
93
|
+
btx_populate_params(common_data);
|
|
111
94
|
bt_value_get_ref(common_data->params);
|
|
112
95
|
|
|
113
96
|
/* Register User Callbacks */
|
|
114
97
|
btx_register_usr_callbacks((void *)common_data);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
btx_call_callbacks_initialize_usr_data(common_data, &common_data->usr_data);
|
|
98
|
+
/* Call initialize_processing*/
|
|
99
|
+
btx_call_callbacks_initialize_component(common_data, &common_data->usr_data);
|
|
118
100
|
/* Call read callbacks */
|
|
119
101
|
btx_call_callbacks_read_params(common_data, common_data->usr_data,
|
|
120
102
|
common_data->btx_params);
|
|
@@ -137,19 +119,18 @@ sink_initialize(bt_self_component_sink *self_component_sink,
|
|
|
137
119
|
}
|
|
138
120
|
|
|
139
121
|
static void sink_finalize(bt_self_component_sink *self_component_sink) {
|
|
140
|
-
common_data_t *common_data = bt_self_component_get_data(
|
|
122
|
+
common_data_t *common_data = (common_data_t *)bt_self_component_get_data(
|
|
141
123
|
bt_self_component_sink_as_self_component(self_component_sink));
|
|
142
124
|
|
|
143
|
-
/* Finalize
|
|
144
|
-
|
|
145
|
-
btx_call_callbacks_finalize_usr_data(common_data, common_data->usr_data);
|
|
125
|
+
/* Finalize Component */
|
|
126
|
+
btx_call_callbacks_finalize_component(common_data, common_data->usr_data);
|
|
146
127
|
|
|
147
128
|
// Delete name_to_dispatcher
|
|
148
129
|
btx_delete_dispatchers(common_data);
|
|
149
|
-
btx_delete_matching_dispatchers(common_data);
|
|
150
130
|
|
|
151
131
|
// We allocate it, we need to free it
|
|
152
132
|
free(common_data->btx_params);
|
|
133
|
+
free(common_data->static_callbacks);
|
|
153
134
|
bt_value_put_ref(common_data->params);
|
|
154
135
|
|
|
155
136
|
/* Free the allocated structure */
|
|
@@ -165,7 +146,7 @@ static void sink_finalize(bt_self_component_sink *self_component_sink) {
|
|
|
165
146
|
static bt_component_class_sink_graph_is_configured_method_status
|
|
166
147
|
sink_graph_is_configured(bt_self_component_sink *self_component_sink) {
|
|
167
148
|
/* Retrieve our private data from the component's user data */
|
|
168
|
-
common_data_t *common_data = bt_self_component_get_data(
|
|
149
|
+
common_data_t *common_data = (common_data_t *)bt_self_component_get_data(
|
|
169
150
|
bt_self_component_sink_as_self_component(self_component_sink));
|
|
170
151
|
|
|
171
152
|
/* Borrow our unique port */
|