metababel 0.0.5 → 1.0.1
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 +380 -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} +200 -19
- 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 -12
- data/template/downstream.c.erb +49 -19
- data/template/downstream.h.erb +11 -1
- data/template/filter.c.erb +29 -37
- data/template/sink.c.erb +17 -37
- data/template/source.c.erb +19 -12
- data/template/upstream.c.erb +62 -111
- data/template/upstream.h.erb +10 -36
- metadata +8 -5
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,22 +17,35 @@ struct common_data_s;
|
|
|
14
17
|
typedef struct common_data_s common_data_t;
|
|
15
18
|
|
|
16
19
|
// Params
|
|
20
|
+
// Avoid icx error: empty struct has size 0 in C, size 1 in C++
|
|
21
|
+
// [-Werror,-Wextern-c-compat]
|
|
17
22
|
struct btx_params_s {
|
|
23
|
+
<% if params_declaration %>
|
|
18
24
|
<%= params_declaration %>
|
|
25
|
+
<% else %>
|
|
26
|
+
char _dummy;
|
|
27
|
+
<% end %>
|
|
19
28
|
|
|
20
29
|
}; <%# Need empty line for nice code gen %>
|
|
21
30
|
typedef struct btx_params_s btx_params_t;
|
|
22
31
|
|
|
23
32
|
void btx_populate_params(common_data_t *common_data_t);
|
|
24
33
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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;
|
|
28
44
|
|
|
29
45
|
struct name_to_dispatcher_s {
|
|
30
46
|
const char *name;
|
|
31
47
|
void *dispatcher;
|
|
32
|
-
|
|
48
|
+
callbacks_t *callbacks;
|
|
33
49
|
UT_hash_handle hh;
|
|
34
50
|
};
|
|
35
51
|
typedef struct name_to_dispatcher_s name_to_dispatcher_t;
|
|
@@ -46,6 +62,10 @@ struct el {
|
|
|
46
62
|
<% if options[:component_type] == 'SOURCE' %>
|
|
47
63
|
struct common_data_s {
|
|
48
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 %>
|
|
49
69
|
void *usr_data;
|
|
50
70
|
const bt_value *params;
|
|
51
71
|
btx_params_t *btx_params;
|
|
@@ -84,7 +104,11 @@ typedef enum btx_source_status_e btx_source_status_t;
|
|
|
84
104
|
<% elsif options[:component_type] == 'FILTER' %>
|
|
85
105
|
struct common_data_s {
|
|
86
106
|
name_to_dispatcher_t *name_to_dispatcher;
|
|
87
|
-
|
|
107
|
+
static_callbacks_t *static_callbacks;
|
|
108
|
+
<% unless options[:disable_callbaks].include?('on_downstream') %>
|
|
109
|
+
void *on_downstream_message_callback;
|
|
110
|
+
<% end %>
|
|
111
|
+
|
|
88
112
|
void *usr_data;
|
|
89
113
|
const bt_value *params;
|
|
90
114
|
btx_params_t *btx_params;
|
|
@@ -134,7 +158,8 @@ typedef struct btx_message_iterator_s btx_message_iterator_t;
|
|
|
134
158
|
<% elsif options[:component_type] == 'SINK' %>
|
|
135
159
|
struct common_data_s {
|
|
136
160
|
name_to_dispatcher_t *name_to_dispatcher;
|
|
137
|
-
|
|
161
|
+
static_callbacks_t *static_callbacks;
|
|
162
|
+
|
|
138
163
|
void *usr_data;
|
|
139
164
|
const bt_value *params;
|
|
140
165
|
btx_params_t *btx_params;
|
|
@@ -145,19 +170,25 @@ struct common_data_s {
|
|
|
145
170
|
|
|
146
171
|
void btx_register_usr_callbacks(void *btx_handle);
|
|
147
172
|
|
|
148
|
-
<%
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
<%= e.
|
|
152
|
-
|
|
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
|
+
|
|
153
178
|
<%# The Function who register the callbacks to the dispatcher %>
|
|
154
179
|
void btx_register_callbacks_<%= e.name_sanitized %>(
|
|
155
|
-
void *btx_handle, <%= e.name_sanitized %>
|
|
180
|
+
void *btx_handle, <%= e.name_sanitized %>_static_callback_f *callback);
|
|
156
181
|
|
|
157
182
|
void btx_call_callbacks_<%= e.name_sanitized %>(
|
|
158
183
|
common_data_t *common_data, <%= e.args.map{ |s| s.type }.join(", ") %>);
|
|
159
184
|
<% end %>
|
|
160
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
|
+
|
|
161
192
|
#ifdef __cplusplus
|
|
162
193
|
}
|
|
163
194
|
#endif
|
data/template/downstream.c.erb
CHANGED
|
@@ -20,9 +20,9 @@ void btx_downstream_move_messages(
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
static inline
|
|
24
|
+
void _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,30 @@ 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 *
|
|
170
|
+
btx_message_iterator_t *_message_iterator_private_data =
|
|
141
171
|
bt_self_message_iterator_get_data(common_data->self_message_iterator);
|
|
142
|
-
btx_downstream_push_message(
|
|
172
|
+
btx_downstream_push_message(_message_iterator_private_data, _message);
|
|
143
173
|
}
|
|
144
174
|
<% 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
|
@@ -104,35 +104,18 @@ static inline void filter_message_iterator_next_call_dispatchers(
|
|
|
104
104
|
/* Borrow the event message's event and its class */
|
|
105
105
|
const bt_event *event = bt_message_event_borrow_event_const(upstream_message);
|
|
106
106
|
const bt_event_class *event_class = bt_event_borrow_class_const(event);
|
|
107
|
-
|
|
108
|
-
bool is_callback_called = false;
|
|
107
|
+
|
|
109
108
|
/* 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) {
|
|
109
|
+
const char *class_name = bt_event_class_get_name(event_class);
|
|
110
|
+
name_to_dispatcher_t *s = NULL;
|
|
111
|
+
HASH_FIND_STR(common_data->name_to_dispatcher, class_name, s);
|
|
112
|
+
if (s) {
|
|
113
|
+
(*((dispatcher_t(*))(s->dispatcher)))(s->callbacks, common_data,
|
|
114
|
+
upstream_message);
|
|
115
|
+
/* Drop message */
|
|
134
116
|
bt_message_put_ref(upstream_message);
|
|
135
117
|
} else {
|
|
118
|
+
/* Push upstream message to downstream */
|
|
136
119
|
btx_downstream_push_message(message_iterator_private_data,
|
|
137
120
|
upstream_message);
|
|
138
121
|
}
|
|
@@ -142,10 +125,12 @@ static inline void
|
|
|
142
125
|
filter_message_iterator_next_processing_reading_to_finalizing(
|
|
143
126
|
bt_self_message_iterator *self_message_iterator,
|
|
144
127
|
btx_message_iterator_t *message_iterator_private_data) {
|
|
128
|
+
|
|
145
129
|
/* Call Finalize user callback */
|
|
146
|
-
|
|
130
|
+
btx_call_callbacks_finalize_processing(
|
|
147
131
|
message_iterator_private_data->common_data,
|
|
148
132
|
message_iterator_private_data->common_data->usr_data);
|
|
133
|
+
|
|
149
134
|
/* End of Stream */
|
|
150
135
|
btx_push_messages_stream_end(self_message_iterator,
|
|
151
136
|
message_iterator_private_data);
|
|
@@ -279,14 +264,9 @@ filter_message_iterator_next_initializing(
|
|
|
279
264
|
message_iterator_private_data);
|
|
280
265
|
|
|
281
266
|
/* Call Initialize user callback */
|
|
282
|
-
|
|
267
|
+
btx_call_callbacks_initialize_processing(
|
|
283
268
|
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);
|
|
269
|
+
message_iterator_private_data->common_data->usr_data);
|
|
290
270
|
|
|
291
271
|
/* We need to transition to the processing state*/
|
|
292
272
|
message_iterator_private_data->state = BTX_FILTER_STATE_PROCESSING;
|
|
@@ -355,14 +335,22 @@ filter_initialize(bt_self_component_filter *self_component_filter,
|
|
|
355
335
|
|
|
356
336
|
/* Allocate a private data structure */
|
|
357
337
|
common_data_t *common_data = calloc(1, sizeof(common_data_t));
|
|
338
|
+
common_data->static_callbacks = calloc(1, sizeof(static_callbacks_t));
|
|
358
339
|
common_data->btx_params = calloc(1, sizeof(btx_params_t));
|
|
359
340
|
common_data->params = params;
|
|
341
|
+
|
|
360
342
|
/* Read parameters */
|
|
361
343
|
btx_populate_params(common_data);
|
|
362
344
|
bt_value_get_ref(common_data->params);
|
|
363
345
|
|
|
364
346
|
/* Register User Callbacks */
|
|
365
347
|
btx_register_usr_callbacks((void *)common_data);
|
|
348
|
+
/* Call initialize_processing*/
|
|
349
|
+
btx_call_callbacks_initialize_component((void *)common_data,
|
|
350
|
+
&common_data->usr_data);
|
|
351
|
+
/* Call read callbacks */
|
|
352
|
+
btx_call_callbacks_read_params(common_data, common_data->usr_data,
|
|
353
|
+
common_data->btx_params);
|
|
366
354
|
|
|
367
355
|
/* Set the component's user data to our private data structure */
|
|
368
356
|
bt_self_component_set_data(
|
|
@@ -401,7 +389,8 @@ filter_initialize(bt_self_component_filter *self_component_filter,
|
|
|
401
389
|
/* Create message classes that will be used by the filter */
|
|
402
390
|
bt_self_component *self_component =
|
|
403
391
|
bt_self_component_filter_as_self_component(self_component_filter);
|
|
404
|
-
/* Create a `trace_class` and all the children's classes (stream and events)
|
|
392
|
+
/* Create a `trace_class` and all the children's classes (stream and events)
|
|
393
|
+
*/
|
|
405
394
|
bt_trace_class *trace_class =
|
|
406
395
|
btx_downstream_trace_class_create_rec(self_component);
|
|
407
396
|
/* Instantiate a `downstream_trace` of `trace_class` and all the children
|
|
@@ -435,7 +424,7 @@ static bt_message_iterator_class_initialize_method_status
|
|
|
435
424
|
filter_message_iterator_initialize(
|
|
436
425
|
bt_self_message_iterator *self_message_iterator,
|
|
437
426
|
bt_self_message_iterator_configuration *configuration,
|
|
438
|
-
bt_self_component_port_output *
|
|
427
|
+
bt_self_component_port_output *self_port_output) {
|
|
439
428
|
/* Allocate a private data structure */
|
|
440
429
|
btx_message_iterator_t *message_iterator_private_data =
|
|
441
430
|
calloc(1, sizeof(btx_message_iterator_t));
|
|
@@ -484,16 +473,19 @@ static void filter_finalize(bt_self_component_filter *self_component_filter) {
|
|
|
484
473
|
common_data_t *common_data = bt_self_component_get_data(
|
|
485
474
|
bt_self_component_filter_as_self_component(self_component_filter));
|
|
486
475
|
|
|
476
|
+
/* Finalize Component */
|
|
477
|
+
btx_call_callbacks_finalize_component(common_data, common_data->usr_data);
|
|
478
|
+
|
|
487
479
|
btx_streams_put_ref(common_data->downstream_trace); // ??
|
|
488
480
|
/* We allocate it, we need to put ref */
|
|
489
481
|
bt_trace_put_ref(common_data->downstream_trace);
|
|
490
482
|
|
|
491
483
|
/* Delete name_to_dispatchers */
|
|
492
484
|
btx_delete_dispatchers(common_data);
|
|
493
|
-
btx_delete_matching_dispatchers(common_data);
|
|
494
485
|
|
|
495
486
|
/* We allocate it, we need to free it */
|
|
496
487
|
free(common_data->btx_params);
|
|
488
|
+
free(common_data->static_callbacks);
|
|
497
489
|
bt_value_put_ref(common_data->params);
|
|
498
490
|
free(common_data);
|
|
499
491
|
}
|
data/template/sink.c.erb
CHANGED
|
@@ -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);
|
|
@@ -103,18 +83,19 @@ sink_initialize(bt_self_component_sink *self_component_sink,
|
|
|
103
83
|
const bt_value *params, void *initialize_method_data) {
|
|
104
84
|
/* Allocate a private data structure */
|
|
105
85
|
common_data_t *common_data = calloc(1, sizeof(common_data_t));
|
|
86
|
+
common_data->static_callbacks = calloc(1, sizeof(static_callbacks_t));
|
|
106
87
|
common_data->btx_params = calloc(1, sizeof(btx_params_t));
|
|
107
88
|
common_data->params = params;
|
|
108
|
-
// Read parameters
|
|
109
|
-
btx_populate_params(common_data);
|
|
110
89
|
|
|
90
|
+
/* Read parameters */
|
|
91
|
+
btx_populate_params(common_data);
|
|
111
92
|
bt_value_get_ref(common_data->params);
|
|
112
93
|
|
|
113
94
|
/* Register User Callbacks */
|
|
114
95
|
btx_register_usr_callbacks((void *)common_data);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
96
|
+
/* Call initialize_processing*/
|
|
97
|
+
btx_call_callbacks_initialize_component((void *)common_data,
|
|
98
|
+
&common_data->usr_data);
|
|
118
99
|
/* Call read callbacks */
|
|
119
100
|
btx_call_callbacks_read_params(common_data, common_data->usr_data,
|
|
120
101
|
common_data->btx_params);
|
|
@@ -140,16 +121,15 @@ static void sink_finalize(bt_self_component_sink *self_component_sink) {
|
|
|
140
121
|
common_data_t *common_data = bt_self_component_get_data(
|
|
141
122
|
bt_self_component_sink_as_self_component(self_component_sink));
|
|
142
123
|
|
|
143
|
-
/* Finalize
|
|
144
|
-
|
|
145
|
-
btx_call_callbacks_finalize_usr_data(common_data, common_data->usr_data);
|
|
124
|
+
/* Finalize Component */
|
|
125
|
+
btx_call_callbacks_finalize_component(common_data, common_data->usr_data);
|
|
146
126
|
|
|
147
127
|
// Delete name_to_dispatcher
|
|
148
128
|
btx_delete_dispatchers(common_data);
|
|
149
|
-
btx_delete_matching_dispatchers(common_data);
|
|
150
129
|
|
|
151
130
|
// We allocate it, we need to free it
|
|
152
131
|
free(common_data->btx_params);
|
|
132
|
+
free(common_data->static_callbacks);
|
|
153
133
|
bt_value_put_ref(common_data->params);
|
|
154
134
|
|
|
155
135
|
/* Free the allocated structure */
|
data/template/source.c.erb
CHANGED
|
@@ -32,16 +32,10 @@ source_message_iterator_next(bt_self_message_iterator *self_message_iterator,
|
|
|
32
32
|
/* Begining of Stream */
|
|
33
33
|
btx_push_messages_stream_beginning(self_message_iterator,
|
|
34
34
|
message_iterator_private_data);
|
|
35
|
-
|
|
36
35
|
/* Call Initialize user callback */
|
|
37
|
-
|
|
38
|
-
message_iterator_private_data->common_data,
|
|
39
|
-
&message_iterator_private_data->common_data->usr_data);
|
|
40
|
-
/* Call read callbacks */
|
|
41
|
-
btx_call_callbacks_read_params(
|
|
36
|
+
btx_call_callbacks_initialize_processing(
|
|
42
37
|
message_iterator_private_data->common_data,
|
|
43
|
-
message_iterator_private_data->common_data->usr_data
|
|
44
|
-
message_iterator_private_data->common_data->btx_params);
|
|
38
|
+
message_iterator_private_data->common_data->usr_data);
|
|
45
39
|
|
|
46
40
|
message_iterator_private_data->state = BTX_SOURCE_STATE_PROCESSING;
|
|
47
41
|
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN;
|
|
@@ -58,9 +52,8 @@ source_message_iterator_next(bt_self_message_iterator *self_message_iterator,
|
|
|
58
52
|
message_iterator_private_data->common_data,
|
|
59
53
|
message_iterator_private_data->common_data->usr_data, &status);
|
|
60
54
|
if (status == BTX_SOURCE_END) {
|
|
61
|
-
|
|
62
55
|
/* Call Finalize user callback */
|
|
63
|
-
|
|
56
|
+
btx_call_callbacks_finalize_processing(
|
|
64
57
|
message_iterator_private_data->common_data,
|
|
65
58
|
message_iterator_private_data->common_data->usr_data);
|
|
66
59
|
/* End of Stream */
|
|
@@ -93,14 +86,23 @@ source_initialize(bt_self_component_source *self_component_source,
|
|
|
93
86
|
const bt_value *params, void *initialize_method_data) {
|
|
94
87
|
/* Allocate a private data structure */
|
|
95
88
|
common_data_t *common_data = calloc(1, sizeof(common_data_t));
|
|
89
|
+
common_data->static_callbacks = calloc(1, sizeof(static_callbacks_t));
|
|
96
90
|
common_data->btx_params = calloc(1, sizeof(btx_params_t));
|
|
97
91
|
common_data->params = params;
|
|
98
|
-
|
|
92
|
+
|
|
93
|
+
/* Read parameters */
|
|
99
94
|
btx_populate_params(common_data);
|
|
100
95
|
bt_value_get_ref(common_data->params);
|
|
101
96
|
|
|
102
97
|
/* Register User Callbacks */
|
|
103
98
|
btx_register_usr_callbacks((void *)common_data);
|
|
99
|
+
/* Call initialize_processing*/
|
|
100
|
+
btx_call_callbacks_initialize_component((void *)common_data,
|
|
101
|
+
&common_data->usr_data);
|
|
102
|
+
/* Call read callbacks */
|
|
103
|
+
btx_call_callbacks_read_params(common_data, common_data->usr_data,
|
|
104
|
+
common_data->btx_params);
|
|
105
|
+
|
|
104
106
|
/* Upcast `self_component_source` to the `bt_self_component` type */
|
|
105
107
|
bt_self_component *self_component =
|
|
106
108
|
bt_self_component_source_as_self_component(self_component_source);
|
|
@@ -165,6 +167,9 @@ static void source_finalize(bt_self_component_source *self_component_source) {
|
|
|
165
167
|
common_data_t *common_data = bt_self_component_get_data(
|
|
166
168
|
bt_self_component_source_as_self_component(self_component_source));
|
|
167
169
|
|
|
170
|
+
/* Finalize Component */
|
|
171
|
+
btx_call_callbacks_finalize_component(common_data, common_data->usr_data);
|
|
172
|
+
|
|
168
173
|
btx_streams_put_ref(common_data->downstream_trace); // ??
|
|
169
174
|
// We allocate it, we need to put ref
|
|
170
175
|
bt_trace_put_ref(common_data->downstream_trace);
|
|
@@ -173,12 +178,14 @@ static void source_finalize(bt_self_component_source *self_component_source) {
|
|
|
173
178
|
name_to_dispatcher_t *current, *tmp;
|
|
174
179
|
HASH_ITER(hh, common_data->name_to_dispatcher, current, tmp) {
|
|
175
180
|
HASH_DEL(common_data->name_to_dispatcher, current);
|
|
176
|
-
utarray_free(current->callbacks);
|
|
181
|
+
utarray_free(current->callbacks->generic);
|
|
182
|
+
free(current->callbacks);
|
|
177
183
|
free(current);
|
|
178
184
|
}
|
|
179
185
|
|
|
180
186
|
// We allocate it, we need to free it
|
|
181
187
|
free(common_data->btx_params);
|
|
188
|
+
free(common_data->static_callbacks);
|
|
182
189
|
bt_value_put_ref(common_data->params);
|
|
183
190
|
free(common_data);
|
|
184
191
|
}
|