metababel 0.0.4 → 0.1.0
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/lib/metababel/version.rb +1 -1
- data/template/component.h.erb +5 -0
- data/template/filter.c.erb +245 -170
- data/template/sink.c.erb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2f9cdd491e69bf7414791f771ed3902bb4d8ba27dd28c6b2e66bb677662a6c9d
|
|
4
|
+
data.tar.gz: 13c2e7c0c201b9a3f51d55e8ea9438284f77285ad6f8c640f20567c88e5f6f88
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a908872fc837088e86f43aa08ca113795287c35a3d249c140295c9471089cc418b8ff8cab7dc7817acb0193df5d42c2fd51d191cd63ef1d22539b0428d2c5180
|
|
7
|
+
data.tar.gz: e7d44bcafe7a4be48336a5da021f911b31db8877d06b7d7c6c3918ee520adbd51093567d9a502a6a52395b490d306b04ede726be97dceaea7b8e2b6276025993
|
data/lib/metababel/version.rb
CHANGED
data/template/component.h.erb
CHANGED
|
@@ -14,8 +14,13 @@ struct common_data_s;
|
|
|
14
14
|
typedef struct common_data_s common_data_t;
|
|
15
15
|
|
|
16
16
|
// Params
|
|
17
|
+
// Avoid icx error: empty struct has size 0 in C, size 1 in C++ [-Werror,-Wextern-c-compat]
|
|
17
18
|
struct btx_params_s {
|
|
19
|
+
<% if params_declaration %>
|
|
18
20
|
<%= params_declaration %>
|
|
21
|
+
<% else %>
|
|
22
|
+
int dummy;
|
|
23
|
+
<% end %>
|
|
19
24
|
|
|
20
25
|
}; <%# Need empty line for nice code gen %>
|
|
21
26
|
typedef struct btx_params_s btx_params_t;
|
data/template/filter.c.erb
CHANGED
|
@@ -9,49 +9,46 @@
|
|
|
9
9
|
* https://babeltrace.org/docs/v2.0/libbabeltrace2/example-simple-flt-cmp-cls.html
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
static char *get_port_name(uint64_t current) {
|
|
13
|
-
int num_len = snprintf(NULL, 0, "in%ld", current);
|
|
14
|
-
char *result = (char *)malloc(num_len + 1);
|
|
15
|
-
sprintf(result, "in%ld", current);
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
12
|
/*
|
|
20
|
-
*
|
|
13
|
+
* _____ _ _ ___ ___ _ _
|
|
14
|
+
* / ___| | | | | \/ | | | (_)
|
|
15
|
+
* \ `--.| |_ __ _| |_ ___ | . . | __ _ ___| |__ _ _ __ ___ ___
|
|
16
|
+
* `--. \ __/ _` | __/ _ \ | |\/| |/ _` |/ __| '_ \| | '_ \ / _ \/ __|
|
|
17
|
+
* /\__/ / || (_| | || __/ | | | | (_| | (__| | | | | | | | __/\__ \
|
|
18
|
+
* \____/ \__\__,_|\__\___| \_| |_/\__,_|\___|_| |_|_|_| |_|\___||___/
|
|
21
19
|
*/
|
|
22
20
|
|
|
21
|
+
/* _
|
|
22
|
+
* |_ o ._ _. | o _ _
|
|
23
|
+
* | | | | (_| | | /_ (/_
|
|
24
|
+
*/
|
|
23
25
|
static inline bt_message_iterator_class_next_method_status
|
|
24
|
-
|
|
26
|
+
filter_message_iterator_next_finalizing(
|
|
25
27
|
bt_self_message_iterator *self_message_iterator,
|
|
26
28
|
bt_message_array_const messages, uint64_t capacity, uint64_t *count) {
|
|
27
29
|
|
|
28
|
-
/* Retrieve our private data from the message iterator's user data */
|
|
29
30
|
btx_message_iterator_t *message_iterator_private_data =
|
|
30
31
|
bt_self_message_iterator_get_data(self_message_iterator);
|
|
31
32
|
|
|
32
|
-
/*
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
message_iterator_private_data->common_data->btx_params);
|
|
45
|
-
|
|
46
|
-
// We need to transition in the procesing state
|
|
47
|
-
message_iterator_private_data->state = BTX_FILTER_STATE_PROCESSING;
|
|
48
|
-
if (message_iterator_private_data->queue)
|
|
49
|
-
message_iterator_private_data->processing_state =
|
|
50
|
-
BTX_FILTER_PROCESSING_STATE_SENDING;
|
|
51
|
-
|
|
52
|
-
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN;
|
|
33
|
+
/* No more messages, we can stop the plugin, and transition to END */
|
|
34
|
+
if (!message_iterator_private_data->queue) {
|
|
35
|
+
message_iterator_private_data->state = BTX_FILTER_STATE_FINISHED;
|
|
36
|
+
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END;
|
|
37
|
+
}
|
|
38
|
+
/* Still some message, because we moved message, we can send
|
|
39
|
+
BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK, and we will be recalled
|
|
40
|
+
latter by BT
|
|
41
|
+
*/
|
|
42
|
+
btx_downstream_move_messages(message_iterator_private_data, messages,
|
|
43
|
+
capacity, count);
|
|
44
|
+
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
|
|
53
45
|
}
|
|
54
46
|
|
|
47
|
+
/* _ __
|
|
48
|
+
* |_) ._ _ _ _ _ _ o ._ _ (_ _ ._ _| o ._ _
|
|
49
|
+
* | | (_) (_ (/_ _> _> | | | (_| __) (/_ | | (_| | | | (_|
|
|
50
|
+
* _| _|
|
|
51
|
+
*/
|
|
55
52
|
static inline bt_message_iterator_class_next_method_status
|
|
56
53
|
filter_message_iterator_next_processing_sending(
|
|
57
54
|
bt_self_message_iterator *self_message_iterator,
|
|
@@ -60,9 +57,19 @@ filter_message_iterator_next_processing_sending(
|
|
|
60
57
|
btx_message_iterator_t *message_iterator_private_data =
|
|
61
58
|
bt_self_message_iterator_get_data(self_message_iterator);
|
|
62
59
|
|
|
60
|
+
/* This should never append. When transitioning to sending,
|
|
61
|
+
we check that we have some messages to send */
|
|
62
|
+
if (!message_iterator_private_data->queue) {
|
|
63
|
+
message_iterator_private_data->state = BTX_FILTER_STATE_ERROR;
|
|
64
|
+
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
|
|
65
|
+
}
|
|
66
|
+
|
|
63
67
|
btx_downstream_move_messages(message_iterator_private_data, messages,
|
|
64
68
|
capacity, count);
|
|
65
69
|
|
|
70
|
+
/* No more messages to send; we can transition back to reading
|
|
71
|
+
If not, this function will be called again
|
|
72
|
+
in order to minimize memory usage */
|
|
66
73
|
if (!message_iterator_private_data->queue) {
|
|
67
74
|
message_iterator_private_data->processing_state =
|
|
68
75
|
BTX_FILTER_PROCESSING_STATE_READING;
|
|
@@ -70,138 +77,172 @@ filter_message_iterator_next_processing_sending(
|
|
|
70
77
|
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
|
|
71
78
|
}
|
|
72
79
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
/* _ _
|
|
81
|
+
* |_) ._ _ _ _ _ _ o ._ _ |_) _ _. _| o ._ _
|
|
82
|
+
* | | (_) (_ (/_ _> _> | | | (_| | \ (/_ (_| (_| | | | (_|
|
|
83
|
+
* _| _|
|
|
84
|
+
*/
|
|
85
|
+
static inline bool filter_message_iterator_next_unregister(
|
|
86
|
+
btx_message_iterator_t *message_iterator_private_data) {
|
|
87
|
+
|
|
88
|
+
/* Unregister from BT */
|
|
89
|
+
bt_message_iterator_put_ref(
|
|
90
|
+
message_iterator_private_data->head_mi->message_iterator);
|
|
91
|
+
/* Delete from our ring buffer */
|
|
92
|
+
struct el_mi *tmp = message_iterator_private_data->head_mi;
|
|
93
|
+
CDL_DELETE(message_iterator_private_data->head_mi, tmp);
|
|
94
|
+
free(tmp);
|
|
95
|
+
/* Return if empty or not */
|
|
96
|
+
return message_iterator_private_data->head_mi;
|
|
97
|
+
}
|
|
80
98
|
|
|
81
|
-
|
|
99
|
+
static inline void filter_message_iterator_next_call_dispatchers(
|
|
100
|
+
const bt_message *upstream_message,
|
|
101
|
+
btx_message_iterator_t *message_iterator_private_data) {
|
|
82
102
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
103
|
+
common_data_t *common_data = message_iterator_private_data->common_data;
|
|
104
|
+
/* Borrow the event message's event and its class */
|
|
105
|
+
const bt_event *event = bt_message_event_borrow_event_const(upstream_message);
|
|
106
|
+
const bt_event_class *event_class = bt_event_borrow_class_const(event);
|
|
107
|
+
/* Lazy modified variable */
|
|
108
|
+
bool is_callback_called = false;
|
|
109
|
+
/* Event dispatcher */
|
|
110
|
+
{
|
|
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)))(
|
|
116
|
+
s->callbacks, common_data, upstream_message, &is_callback_called);
|
|
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) {
|
|
134
|
+
bt_message_put_ref(upstream_message);
|
|
135
|
+
} else {
|
|
136
|
+
btx_downstream_push_message(message_iterator_private_data,
|
|
137
|
+
upstream_message);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
86
140
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
141
|
+
static inline void
|
|
142
|
+
filter_message_iterator_next_processing_reading_to_finalizing(
|
|
143
|
+
bt_self_message_iterator *self_message_iterator,
|
|
144
|
+
btx_message_iterator_t *message_iterator_private_data) {
|
|
145
|
+
/* Call Finalize user callback */
|
|
146
|
+
btx_call_callbacks_finalize_usr_data(
|
|
147
|
+
message_iterator_private_data->common_data,
|
|
148
|
+
message_iterator_private_data->common_data->usr_data);
|
|
149
|
+
/* End of Stream */
|
|
150
|
+
btx_push_messages_stream_end(self_message_iterator,
|
|
151
|
+
message_iterator_private_data);
|
|
90
152
|
|
|
91
|
-
/*
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
/* We are setting the state, so this function will never being call twice */
|
|
97
|
-
bt_message_iterator_put_ref(
|
|
98
|
-
message_iterator_private_data->head_mi->message_iterator);
|
|
99
|
-
struct el_mi *tmp = message_iterator_private_data->head_mi;
|
|
100
|
-
CDL_DELETE(message_iterator_private_data->head_mi, tmp);
|
|
101
|
-
free(tmp);
|
|
102
|
-
|
|
103
|
-
if (!message_iterator_private_data->head_mi) {
|
|
104
|
-
/* Call Finalize user callback */
|
|
105
|
-
btx_call_callbacks_finalize_usr_data(
|
|
106
|
-
message_iterator_private_data->common_data,
|
|
107
|
-
message_iterator_private_data->common_data->usr_data);
|
|
108
|
-
/* End of Stream */
|
|
109
|
-
btx_push_messages_stream_end(self_message_iterator,
|
|
110
|
-
message_iterator_private_data);
|
|
111
|
-
message_iterator_private_data->state = BTX_FILTER_STATE_FINALIZING;
|
|
112
|
-
message_iterator_private_data->processing_state =
|
|
113
|
-
BTX_FILTER_PROCESSING_STATE_FINISHED;
|
|
114
|
-
}
|
|
115
|
-
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN;
|
|
116
|
-
case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN:
|
|
117
|
-
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN;
|
|
118
|
-
case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR:
|
|
119
|
-
message_iterator_private_data->state = BTX_FILTER_STATE_ERROR;
|
|
120
|
-
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
|
|
121
|
-
case BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR:
|
|
122
|
-
message_iterator_private_data->state = BTX_FILTER_STATE_ERROR;
|
|
123
|
-
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
|
|
124
|
-
case BT_MESSAGE_ITERATOR_NEXT_STATUS_OK:
|
|
125
|
-
break;
|
|
126
|
-
default:
|
|
127
|
-
message_iterator_private_data->state = BTX_FILTER_STATE_ERROR;
|
|
128
|
-
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
|
|
129
|
-
}
|
|
153
|
+
/* Transition to switch */
|
|
154
|
+
message_iterator_private_data->state = BTX_FILTER_STATE_FINALIZING;
|
|
155
|
+
message_iterator_private_data->processing_state =
|
|
156
|
+
BTX_FILTER_PROCESSING_STATE_FINISHED;
|
|
157
|
+
}
|
|
130
158
|
|
|
159
|
+
static inline void filter_message_iterator_next_processing_reading_callbacks(
|
|
160
|
+
btx_message_iterator_t *message_iterator_private_data,
|
|
161
|
+
common_data_t *common_data, uint64_t upstream_message_count,
|
|
162
|
+
bt_message_array_const upstream_messages) {
|
|
131
163
|
/* For each consumed message */
|
|
132
164
|
for (uint64_t upstream_i = 0; upstream_i < upstream_message_count;
|
|
133
165
|
upstream_i++) {
|
|
134
166
|
/* Current message */
|
|
135
167
|
const bt_message *upstream_message = upstream_messages[upstream_i];
|
|
136
|
-
/* Forward all non
|
|
168
|
+
/* Forward all non-event-messages downstream */
|
|
137
169
|
if (bt_message_get_type(upstream_message) != BT_MESSAGE_TYPE_EVENT) {
|
|
138
170
|
btx_downstream_push_message(message_iterator_private_data,
|
|
139
171
|
upstream_message);
|
|
140
|
-
|
|
141
|
-
|
|
172
|
+
} else {
|
|
173
|
+
filter_message_iterator_next_call_dispatchers(
|
|
174
|
+
upstream_message, message_iterator_private_data);
|
|
142
175
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
bt_message_event_borrow_event_const(upstream_message);
|
|
146
|
-
const bt_event_class *event_class = bt_event_borrow_class_const(event);
|
|
147
|
-
|
|
148
|
-
/* Call dispatcher or forward message downstream */
|
|
149
|
-
bool is_callback_called = false;
|
|
150
|
-
const char *class_name = bt_event_class_get_name(event_class);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
151
178
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
179
|
+
static inline bt_message_iterator_class_next_method_status
|
|
180
|
+
filter_message_iterator_next_processing_reading(
|
|
181
|
+
bt_self_message_iterator *self_message_iterator,
|
|
182
|
+
bt_message_array_const messages, uint64_t capacity, uint64_t *count) {
|
|
183
|
+
/* Retrieve our private data from the message iterator's user data */
|
|
184
|
+
btx_message_iterator_t *message_iterator_private_data =
|
|
185
|
+
bt_self_message_iterator_get_data(self_message_iterator);
|
|
160
186
|
|
|
161
|
-
|
|
162
|
-
const bt_stream_class *stream_class =
|
|
163
|
-
bt_event_class_borrow_stream_class_const(event_class);
|
|
164
|
-
const char *stream_class_name = bt_stream_class_get_name(stream_class);
|
|
165
|
-
|
|
166
|
-
name_to_dispatcher_t *s = NULL;
|
|
167
|
-
HASH_FIND_STR(common_data->name_to_matching_dispatcher, stream_class_name,
|
|
168
|
-
s);
|
|
169
|
-
if (s) {
|
|
170
|
-
// is_callback_called will only be modified if at least one callback is
|
|
171
|
-
// called.
|
|
172
|
-
(*((dispatcher_t(*))(s->dispatcher)))(s->callbacks, common_data, upstream_message,
|
|
173
|
-
&is_callback_called);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
187
|
+
common_data_t *common_data = message_iterator_private_data->common_data;
|
|
176
188
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
189
|
+
while (!message_iterator_private_data->queue) {
|
|
190
|
+
/* Consume a batch of messages from the upstream message iterator */
|
|
191
|
+
uint64_t upstream_message_count;
|
|
192
|
+
bt_message_array_const upstream_messages;
|
|
193
|
+
|
|
194
|
+
bt_message_iterator_next_status next_status = bt_message_iterator_next(
|
|
195
|
+
message_iterator_private_data->head_mi->message_iterator,
|
|
196
|
+
&upstream_messages, &upstream_message_count);
|
|
197
|
+
|
|
198
|
+
switch (next_status) {
|
|
199
|
+
case BT_MESSAGE_ITERATOR_NEXT_STATUS_OK:
|
|
200
|
+
filter_message_iterator_next_processing_reading_callbacks(
|
|
201
|
+
message_iterator_private_data, common_data, upstream_message_count,
|
|
202
|
+
upstream_messages);
|
|
203
|
+
/* Round Robin between Upstream MessageIterator */
|
|
204
|
+
message_iterator_private_data->head_mi =
|
|
205
|
+
message_iterator_private_data->head_mi->next;
|
|
206
|
+
break;
|
|
207
|
+
case BT_MESSAGE_ITERATOR_NEXT_STATUS_END:
|
|
208
|
+
if (filter_message_iterator_next_unregister(
|
|
209
|
+
message_iterator_private_data))
|
|
210
|
+
break;
|
|
211
|
+
filter_message_iterator_next_processing_reading_to_finalizing(
|
|
212
|
+
self_message_iterator, message_iterator_private_data);
|
|
213
|
+
return filter_message_iterator_next_finalizing(self_message_iterator,
|
|
214
|
+
messages, capacity, count);
|
|
215
|
+
case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN:
|
|
216
|
+
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN;
|
|
217
|
+
case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR:
|
|
218
|
+
message_iterator_private_data->state = BTX_FILTER_STATE_ERROR;
|
|
219
|
+
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
|
|
220
|
+
case BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR:
|
|
221
|
+
message_iterator_private_data->state = BTX_FILTER_STATE_ERROR;
|
|
222
|
+
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
|
|
223
|
+
default:
|
|
224
|
+
message_iterator_private_data->state = BTX_FILTER_STATE_ERROR;
|
|
225
|
+
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
|
|
183
226
|
}
|
|
184
227
|
}
|
|
185
228
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
message_iterator_private_data->processing_state =
|
|
192
|
-
BTX_FILTER_PROCESSING_STATE_SENDING;
|
|
193
|
-
/* optimization */
|
|
194
|
-
return filter_message_iterator_next_processing_sending(
|
|
195
|
-
self_message_iterator, messages, capacity, count);
|
|
196
|
-
} else
|
|
197
|
-
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN;
|
|
229
|
+
message_iterator_private_data->processing_state =
|
|
230
|
+
BTX_FILTER_PROCESSING_STATE_SENDING;
|
|
231
|
+
/* optimization to not send AGAIN */
|
|
232
|
+
return filter_message_iterator_next_processing_sending(
|
|
233
|
+
self_message_iterator, messages, capacity, count);
|
|
198
234
|
}
|
|
199
235
|
|
|
236
|
+
/* _ __
|
|
237
|
+
* |_) ._ _ _ _ _ _ o ._ _ (_ o _|_ _ |_
|
|
238
|
+
* | | (_) (_ (/_ _> _> | | | (_| __) \/\/ | |_ (_ | |
|
|
239
|
+
* _|
|
|
240
|
+
*/
|
|
200
241
|
static inline bt_message_iterator_class_next_method_status
|
|
201
242
|
filter_message_iterator_next_processing(
|
|
202
243
|
bt_self_message_iterator *self_message_iterator,
|
|
203
244
|
bt_message_array_const messages, uint64_t capacity, uint64_t *count) {
|
|
204
|
-
|
|
245
|
+
|
|
205
246
|
btx_message_iterator_t *message_iterator_private_data =
|
|
206
247
|
bt_self_message_iterator_get_data(self_message_iterator);
|
|
207
248
|
|
|
@@ -219,26 +260,52 @@ filter_message_iterator_next_processing(
|
|
|
219
260
|
}
|
|
220
261
|
}
|
|
221
262
|
|
|
263
|
+
/* ___
|
|
264
|
+
* | ._ o _|_ o _. | o _ o ._ _
|
|
265
|
+
* _|_ | | | |_ | (_| | | /_ | | | (_|
|
|
266
|
+
* _|
|
|
267
|
+
*/
|
|
222
268
|
static inline bt_message_iterator_class_next_method_status
|
|
223
|
-
|
|
269
|
+
filter_message_iterator_next_initializing(
|
|
224
270
|
bt_self_message_iterator *self_message_iterator,
|
|
225
271
|
bt_message_array_const messages, uint64_t capacity, uint64_t *count) {
|
|
272
|
+
|
|
226
273
|
/* Retrieve our private data from the message iterator's user data */
|
|
227
274
|
btx_message_iterator_t *message_iterator_private_data =
|
|
228
275
|
bt_self_message_iterator_get_data(self_message_iterator);
|
|
229
276
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
message_iterator_private_data->state = BTX_FILTER_STATE_FINISHED;
|
|
234
|
-
return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END;
|
|
235
|
-
}
|
|
277
|
+
/* Begining of Stream */
|
|
278
|
+
btx_push_messages_stream_beginning(self_message_iterator,
|
|
279
|
+
message_iterator_private_data);
|
|
236
280
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
281
|
+
/* Call Initialize user callback */
|
|
282
|
+
btx_call_callbacks_initialize_usr_data(
|
|
283
|
+
message_iterator_private_data->common_data,
|
|
284
|
+
&message_iterator_private_data->common_data->usr_data);
|
|
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);
|
|
290
|
+
|
|
291
|
+
/* We need to transition to the processing state*/
|
|
292
|
+
message_iterator_private_data->state = BTX_FILTER_STATE_PROCESSING;
|
|
293
|
+
if (message_iterator_private_data->queue) {
|
|
294
|
+
message_iterator_private_data->processing_state =
|
|
295
|
+
BTX_FILTER_PROCESSING_STATE_SENDING;
|
|
296
|
+
} else {
|
|
297
|
+
message_iterator_private_data->processing_state =
|
|
298
|
+
BTX_FILTER_PROCESSING_STATE_READING;
|
|
299
|
+
}
|
|
300
|
+
return filter_message_iterator_next_processing(self_message_iterator,
|
|
301
|
+
messages, capacity, count);
|
|
240
302
|
}
|
|
241
303
|
|
|
304
|
+
/* _ __
|
|
305
|
+
* / _ ._ _ ._ _ ._ _ ._ _|_ (_ o _|_ _ |_
|
|
306
|
+
* \_ (_) | | | |_) (_) | | (/_ | | |_ __) \/\/ | |_ (_ | |
|
|
307
|
+
* |
|
|
308
|
+
*/
|
|
242
309
|
static bt_message_iterator_class_next_method_status
|
|
243
310
|
filter_message_iterator_next(bt_self_message_iterator *self_message_iterator,
|
|
244
311
|
bt_message_array_const messages, uint64_t capacity,
|
|
@@ -265,9 +332,22 @@ filter_message_iterator_next(bt_self_message_iterator *self_message_iterator,
|
|
|
265
332
|
}
|
|
266
333
|
}
|
|
267
334
|
|
|
268
|
-
/*
|
|
269
|
-
*
|
|
335
|
+
/* _____ _
|
|
336
|
+
* / __ \ | |
|
|
337
|
+
* | / \/ ___ _ __ ___ _ __ ___ _ __ ___ _ __ | |_
|
|
338
|
+
* | | / _ \| '_ ` _ \| '_ \ / _ \| '_ \ / _ \ '_ \| __|
|
|
339
|
+
* | \__/\ (_) | | | | | | |_) | (_) | | | | __/ | | | |_
|
|
340
|
+
* \____/\___/|_| |_| |_| .__/ \___/|_| |_|\___|_| |_|\__|
|
|
341
|
+
* | |
|
|
342
|
+
* |_|
|
|
270
343
|
*/
|
|
344
|
+
static char *_btx_get_port_name(uint64_t current) {
|
|
345
|
+
int num_len = snprintf(NULL, 0, "in%ld", current);
|
|
346
|
+
char *result = (char *)malloc(num_len + 1);
|
|
347
|
+
sprintf(result, "in%ld", current);
|
|
348
|
+
return result;
|
|
349
|
+
}
|
|
350
|
+
|
|
271
351
|
static bt_component_class_initialize_method_status
|
|
272
352
|
filter_initialize(bt_self_component_filter *self_component_filter,
|
|
273
353
|
bt_self_component_filter_configuration *configuration,
|
|
@@ -277,7 +357,7 @@ filter_initialize(bt_self_component_filter *self_component_filter,
|
|
|
277
357
|
common_data_t *common_data = calloc(1, sizeof(common_data_t));
|
|
278
358
|
common_data->btx_params = calloc(1, sizeof(btx_params_t));
|
|
279
359
|
common_data->params = params;
|
|
280
|
-
|
|
360
|
+
/* Read parameters */
|
|
281
361
|
btx_populate_params(common_data);
|
|
282
362
|
bt_value_get_ref(common_data->params);
|
|
283
363
|
|
|
@@ -310,19 +390,18 @@ filter_initialize(bt_self_component_filter *self_component_filter,
|
|
|
310
390
|
const uint64_t current =
|
|
311
391
|
bt_component_filter_get_input_port_count(common_data->component);
|
|
312
392
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
393
|
+
char *name = _btx_get_port_name(current);
|
|
394
|
+
bt_self_component_filter_add_input_port(self_component_filter, name, NULL,
|
|
395
|
+
NULL);
|
|
396
|
+
free(name);
|
|
397
|
+
|
|
319
398
|
bt_self_component_filter_add_output_port(self_component_filter, "out", NULL,
|
|
320
399
|
NULL);
|
|
321
400
|
|
|
322
|
-
/* Create message that will be used by the filter */
|
|
401
|
+
/* Create message classes that will be used by the filter */
|
|
323
402
|
bt_self_component *self_component =
|
|
324
403
|
bt_self_component_filter_as_self_component(self_component_filter);
|
|
325
|
-
/* Create a `trace_class` and all the children classes (stream and events) */
|
|
404
|
+
/* Create a `trace_class` and all the children's classes (stream and events) */
|
|
326
405
|
bt_trace_class *trace_class =
|
|
327
406
|
btx_downstream_trace_class_create_rec(self_component);
|
|
328
407
|
/* Instantiate a `downstream_trace` of `trace_class` and all the children
|
|
@@ -338,15 +417,14 @@ bt_component_class_port_connected_method_status
|
|
|
338
417
|
filter_input_port_connected(bt_self_component_filter *self_component_filter,
|
|
339
418
|
bt_self_component_port_input *self_port,
|
|
340
419
|
const bt_port_output *other_port) {
|
|
420
|
+
|
|
341
421
|
const uint64_t current = bt_component_filter_get_input_port_count(
|
|
342
422
|
bt_self_component_filter_as_component_filter(self_component_filter));
|
|
343
423
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
free(name);
|
|
349
|
-
}
|
|
424
|
+
char *name = _btx_get_port_name(current);
|
|
425
|
+
bt_self_component_filter_add_input_port(self_component_filter, name, NULL,
|
|
426
|
+
NULL);
|
|
427
|
+
free(name);
|
|
350
428
|
|
|
351
429
|
return BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_OK;
|
|
352
430
|
}
|
|
@@ -399,9 +477,6 @@ filter_message_iterator_initialize(
|
|
|
399
477
|
message_iterator_private_data);
|
|
400
478
|
|
|
401
479
|
message_iterator_private_data->state = BTX_FILTER_STATE_INITIALIZING;
|
|
402
|
-
message_iterator_private_data->processing_state =
|
|
403
|
-
BTX_FILTER_PROCESSING_STATE_READING;
|
|
404
|
-
|
|
405
480
|
return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
|
|
406
481
|
}
|
|
407
482
|
|
|
@@ -410,14 +485,14 @@ static void filter_finalize(bt_self_component_filter *self_component_filter) {
|
|
|
410
485
|
bt_self_component_filter_as_self_component(self_component_filter));
|
|
411
486
|
|
|
412
487
|
btx_streams_put_ref(common_data->downstream_trace); // ??
|
|
413
|
-
|
|
488
|
+
/* We allocate it, we need to put ref */
|
|
414
489
|
bt_trace_put_ref(common_data->downstream_trace);
|
|
415
490
|
|
|
416
|
-
|
|
491
|
+
/* Delete name_to_dispatchers */
|
|
417
492
|
btx_delete_dispatchers(common_data);
|
|
418
493
|
btx_delete_matching_dispatchers(common_data);
|
|
419
494
|
|
|
420
|
-
|
|
495
|
+
/* We allocate it, we need to free it */
|
|
421
496
|
free(common_data->btx_params);
|
|
422
497
|
bt_value_put_ref(common_data->params);
|
|
423
498
|
free(common_data);
|
data/template/sink.c.erb
CHANGED
|
@@ -77,8 +77,9 @@ sink_consume(bt_self_component_sink *self_component_sink) {
|
|
|
77
77
|
const char *stream_class_name = bt_stream_class_get_name(stream_class);
|
|
78
78
|
|
|
79
79
|
name_to_dispatcher_t *s = NULL;
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
if (stream_class_name)
|
|
81
|
+
HASH_FIND_STR(common_data->name_to_matching_dispatcher, stream_class_name,
|
|
82
|
+
s);
|
|
82
83
|
if (s) {
|
|
83
84
|
// is_callback_called will only be modified if at least one callback is
|
|
84
85
|
// called.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metababel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas Applencourt
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2023-
|
|
13
|
+
date: 2023-08-16 00:00:00.000000000 Z
|
|
14
14
|
dependencies: []
|
|
15
15
|
description:
|
|
16
16
|
email:
|