metababel 1.0.4 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94a55badce2025551858542b3ad05ec6f2fadfa18ea7a3d32e43dfc8fa588505
4
- data.tar.gz: 861f4853f64c5de23d47f6678e8a369b49b1e5f84cd4ad1944b077a32e5a8a87
3
+ metadata.gz: fcf5e88ccc5e61854e63063f8bca911bf5ab66b4a73ebc2d19f62d3458e9126b
4
+ data.tar.gz: 773927d69d8240bdc04611eef6131d6c6e0a0e583ff67bc8982fc0ade6d13e1d
5
5
  SHA512:
6
- metadata.gz: 10357d19a20bb264699f6f586f49fd2d5229a7da0ea7dd51234d5b5733bee78340c83f564a2084a26a99db9d13073332ad211c67def4b469c6251e2f219b4efa
7
- data.tar.gz: 92a55fb2d187388088d13d30a827548b1543bec100f81ff4fa58a7dae41d77ad52f53268b33abd93a1149ea9479c838354b3d1b1773e6dbdf8f2b54a0ae1351b
6
+ metadata.gz: 7bfccb7ef5b523fee9b91cd078ae3a070506bca1758bf22c10b3304a407513d9f1167718c6aea7b822a7235b13b8773c294e956d04c0cc4af8701d9224320de2
7
+ data.tar.gz: 2481d7b5db7fc44247c72f6aaeb9dddc5176af852da2fa6706facd0af89b840b2095b5ff96fd86a6b25859325458e5686b2a185a3013e8a69a926e4e2dcd9b1b
data/bin/metababel CHANGED
@@ -8,6 +8,7 @@ require 'fileutils'
8
8
  require 'set'
9
9
  require 'ostruct'
10
10
  require 'abbrev'
11
+ require 'pathname'
11
12
 
12
13
  class Array
13
14
  def join_with_prefix(sep)
@@ -92,7 +93,7 @@ class DispatchType < BaseDispatch
92
93
  end
93
94
 
94
95
  class Dispatcher < BaseDispatch
95
- attr_reader :event_nane, :event, :name,
96
+ attr_reader :event_name, :event, :name,
96
97
  :index_stream_class, :index_event_class,
97
98
  :default_clock_class,
98
99
  :dispatch_types
@@ -160,75 +161,51 @@ def parse_argv
160
161
  # Display help if no arguments.
161
162
  ARGV << '-h' if ARGV.empty?
162
163
 
163
- options = {}
164
-
165
- options[:disable_callbaks] = ['on_downstream'].to_set
166
-
167
- OptionParser.new do |opts|
168
- opts.banner = 'Usage: example.rb [options]'
169
-
170
- opts.on('-h', '--help', 'Prints this help') do
171
- puts opts
172
- exit
173
- end
164
+ parser = OptionParser.new
165
+ parser.on('-h', '--help', 'Prints this help') do
166
+ puts parser.help
167
+ exit
168
+ end
174
169
 
175
- opts.on('-v', '--version', 'Prints this help') do
176
- puts "Ruby: #{RUBY_VERSION}"
177
- puts "Metababel: #{Metababel::VERSION}"
178
- exit
179
- end
170
+ parser.on('-v', '--version', 'Prints this help') do
171
+ puts "Ruby: #{RUBY_VERSION}"
172
+ puts "Metababel: #{Metababel::VERSION}"
173
+ exit
174
+ end
180
175
 
181
- opts.on('-t', '--component TYPE',
176
+ parser.on('-t', '--component-type TYPE',
182
177
  '[Mandatory] Node within a trace processing graph [one of: SINK, SOURCE, FILTER].') do |p|
183
- l = %w[SOURCE FILTER SINK]
184
- h = Abbrev.abbrev(l)
185
- raise "Invalid component type, should be #{l} (case insentitive)" unless h.include?(p.upcase)
186
-
187
- options[:component_type] = h[p.upcase]
188
- end
189
-
190
- opts.on('-u', '--upstreams PATH', Array, '[Mandatory] Path to the bt2 YAML files for the upstream model.') do |p|
191
- options[:upstreams] = p
192
- end
193
-
194
- opts.on('-d', '--downstream PATH', '[Optional] Path to the bt2 YAML file for the downstream model.') do |p|
195
- options[:downstream] = p
196
- end
197
-
198
- opts.on('-p', '--plugin-name PATH', '[Optional] Name of the bt2 plugin created.') do |p|
199
- options[:plugin_name] = p
200
- end
201
-
202
- opts.on('-c', '--component-name PATH', '[Optional] Name of the bt2 componant created.') do |p|
203
- options[:component_name] = p
204
- end
178
+ l = %w[SOURCE FILTER SINK]
179
+ h = Abbrev.abbrev(l)
180
+ raise "Invalid component type, should be #{l} (case insensitive)" unless h.include?(p.upcase)
205
181
 
206
- opts.on('--params PATH', '[Optional] Paht to the bt2 YAML params definition.') do |p|
207
- options[:params] = p
208
- end
209
-
210
- opts.on('-m', '--matching PATH', '[Optional] Path to bt2 YAML matching-callbacks definitions.') do |p|
211
- options[:matching] = p
212
- end
213
-
214
- opts.on('-o', '--output FOLDER', '[Optional] Output folder path.') do |p|
215
- options[:folder] = p
216
- end
217
-
218
- opts.on('-i', '--usr-data-header NAME', '[Optional] User datatypes definitions.') do |p|
219
- options[:usr_data_header] = p
220
- end
221
-
222
- opts.on('--enable-callbacks NAME', Array, '[Optional] Enable some callbacks type') do |p|
223
- options[:disable_callbaks] -= p.to_set
224
- end
225
- end.parse!
226
-
227
- raise OptionParser::MissingArgument if options[:component_type].nil?
228
-
229
- options[:plugin_name] ||= "metababel_#{options[:component_type].downcase}"
230
- options[:component_name] ||= 'btx'
182
+ h[p.upcase]
183
+ end
231
184
 
185
+ parser.on('-u', '--upstreams PATHS', Array, '[Mandatory] Path to the bt2 YAML files for the upstream model.')
186
+ parser.on('-d', '--downstream PATH', '[Optional] Path to the bt2 YAML file for the downstream model.')
187
+ parser.on('-p', '--plugin-name PATH', '[Optional] Name of the bt2 plugin created.')
188
+ parser.on('-c', '--component-name PATH', '[Optional] Name of the bt2 component created.')
189
+ parser.on('--params PATH', '[Optional] Path to the bt2 YAML params definition.')
190
+ parser.on('-m', '--matching PATH', '[Optional] Path to bt2 YAML matching-callbacks definitions.')
191
+ parser.on('-o', '--output FOLDER', '[Optional] Output folder path.')
192
+ parser.on('-i', '--usr-data-header NAME', '[Optional] User datatypes definitions.')
193
+ parser.on('--enable-callbacks NAME', Array, '[Optional] Enable some callbacks type')
194
+ parser.on('--display-shared-callback PLUGIN') { |plugin|
195
+ path = Dir["#{__dir__}/../shared/*#{plugin}*"].first
196
+ puts File.readlines(path)
197
+ exit
198
+ }
199
+
200
+
201
+ options = { 'disable-callbaks': ['on_downstream'].to_set,
202
+ 'component-name': 'btx',
203
+ }
204
+ parser.parse!(into: options)
205
+ raise OptionParser::MissingArgument if options[:'component-type'].nil?
206
+
207
+ options[:'plugin-name'] ||= "metababel_#{options[:'component-type'].downcase}"
208
+ options[:'disable-callbaks'] -= (options[:'enable-callbacks'] || []).to_set
232
209
  options
233
210
  end
234
211
 
@@ -313,7 +290,7 @@ class ContextBuilder
313
290
 
314
291
  def base_folder
315
292
  @base_folder ||= begin
316
- f = @cli_options[:folder] || "#{@cli_options[:component_type]}.#{@cli_options[:plugin_name]}.#{@cli_options[:component_name]}"
293
+ f = @cli_options[:output] || "#{@cli_options[:'component-type']}.#{@cli_options[:'plugin-name']}.#{@cli_options[:'component-name']}"
317
294
  FileUtils.mkdir_p(f)
318
295
  f
319
296
  end
@@ -377,15 +354,15 @@ class ContextBuilder
377
354
  [GeneratedArg.new('void *', 'usr_data'),
378
355
  GeneratedArg.new('btx_params_t *', 'usr_params')],
379
356
  no_btx_handle: true)]
380
- # Usefull to push message
381
- if %w[SOURCE FILTER].include?(@cli_options[:component_type])
357
+
358
+ if %w[SOURCE FILTER].include?(@cli_options[:'component-type'])
382
359
  static_callbacks += [StaticDispatcher.new('initialize_processing',
383
360
  [GeneratedArg.new('void *', 'usr_data_p')]),
384
361
  StaticDispatcher.new('finalize_processing',
385
362
  [GeneratedArg.new('void *', 'usr_data')])]
386
363
  end
387
364
 
388
- if %w[SOURCE].include?(@cli_options[:component_type])
365
+ if %w[SOURCE].include?(@cli_options[:'component-type'])
389
366
  static_callbacks << StaticDispatcher.new('push_usr_messages',
390
367
  [GeneratedArg.new('void *', 'usr_data'),
391
368
  GeneratedArg.new('btx_source_status_t*', 'status')])
@@ -398,9 +375,11 @@ class ContextBuilder
398
375
 
399
376
  def downstream
400
377
  @downstream ||= begin
401
- raise 'Missing downstream model' unless @cli_options[:downstream]
378
+ unless @cli_options[:downstream] || !@cli_options[:'disable-callbaks'].include?('on_downstream')
379
+ raise 'Missing downstream model'
380
+ end
402
381
 
403
- y = load_models(@cli_options[:downstream])
382
+ y = @cli_options[:downstream] ? load_models(@cli_options[:downstream]) : { stream_classes: [] }
404
383
  t = Babeltrace2Gen::BTTraceClass.from_h(nil, y)
405
384
 
406
385
  event_name = '_event'
@@ -434,7 +413,15 @@ class ContextBuilder
434
413
 
435
414
  def upstream
436
415
  @upstream ||= begin
437
- raise 'Missing upstreams models' unless @cli_options[:upstreams]
416
+ unless @cli_options[:upstreams] || !@cli_options[:'disable-callbaks'].include?('on_downstream')
417
+ raise 'Missing upstreams models'
418
+ end
419
+
420
+ unless @cli_options[:upstreams]
421
+ return { dispatchers: [],
422
+ dispatch_types: [],
423
+ event_name: nil }
424
+ end
438
425
 
439
426
  y = load_models(@cli_options[:upstreams])
440
427
  t = Babeltrace2Gen::BTTraceClass.from_h(nil, y)
@@ -491,7 +478,7 @@ def wrote_component(cb)
491
478
  end
492
479
 
493
480
  def wrote_main(cb)
494
- erb_render_and_save(cb.get_context(%w[params options]), "#{cb.cli_options[:component_type].downcase}.c",
481
+ erb_render_and_save(cb.get_context(%w[params options]), "#{cb.cli_options[:'component-type'].downcase}.c",
495
482
  cb.base_folder, out_name: 'main.c')
496
483
  end
497
484
 
@@ -505,5 +492,5 @@ context_builder = ContextBuilder.new
505
492
  wrote_header(context_builder)
506
493
  wrote_main(context_builder)
507
494
  wrote_component(context_builder)
508
- wrote_downstream(context_builder) if %w[SOURCE FILTER].include?(context_builder.cli_options[:component_type])
509
- wrote_upstream(context_builder) if %w[FILTER SINK].include?(context_builder.cli_options[:component_type])
495
+ wrote_downstream(context_builder) if %w[SOURCE FILTER].include?(context_builder.cli_options[:'component-type'])
496
+ wrote_upstream(context_builder) if %w[FILTER SINK].include?(context_builder.cli_options[:'component-type'])
@@ -41,8 +41,8 @@ module Babeltrace2Gen
41
41
  is_a?(Babeltrace2Gen::BTEventClass) ? self : @parent.rec_event_class
42
42
  end
43
43
 
44
- def rec_menber_class
45
- is_a?(Babeltrace2Gen::BTMemberClass) ? self : @parent.rec_menber_class
44
+ def rec_member_class
45
+ is_a?(Babeltrace2Gen::BTMemberClass) ? self : @parent.rec_member_class
46
46
  end
47
47
 
48
48
  def resolve_path(path)
@@ -432,7 +432,7 @@ module Babeltrace2Gen
432
432
  else
433
433
  self.class.instance_variable_get(:@bt_type)
434
434
  end
435
- var = GeneratedArg.new(@cast_type || type, rec_menber_class.name)
435
+ var = GeneratedArg.new(@cast_type || type, rec_member_class.name)
436
436
 
437
437
  arg_variables.fetch_append('outputs_allocated', var) if is_array
438
438
  arg_variables.fetch_append('outputs', var)
@@ -448,7 +448,7 @@ module Babeltrace2Gen
448
448
  def get_setter(field:, arg_variables:)
449
449
  bt_func_get = self.class.instance_variable_get(:@bt_func) % 'set'
450
450
  variable = bt_get_variable(arg_variables).name
451
- # We always explicitly cast to the proper bebeltrace type when sending messsages.
451
+ # We always explicitly cast to the proper bebeltrace type when sending messages.
452
452
  pr "#{bt_func_get}(#{field}, (#{self.class.instance_variable_get(:@bt_type)})#{variable});"
453
453
  end
454
454
  end
@@ -552,32 +552,69 @@ module Babeltrace2Gen
552
552
  end
553
553
 
554
554
  module BTFieldClass::Enumeration
555
- attr_reader :mappings
555
+ class BTFieldClass::Enumeration::Mapping
556
+ extend BTFromH
557
+ include BTUtils
558
+ include BTPrinter
556
559
 
557
- class Mapping
560
+ def initialize(parent:, label:, integer_range_set:)
561
+ @parent = parent
562
+ @label = label
563
+ # Form [ [lower,upper], ...]
564
+ @ranges = integer_range_set
565
+ end
566
+
567
+ def get_declarator(field_class:)
568
+ bt_type_internal = self.class.instance_variable_get(:@bt_type_internal)
569
+ scope do
570
+ pr "bt_integer_range_set_#{bt_type_internal} *#{field_class}_range;"
571
+ pr "#{field_class}_range = bt_integer_range_set_#{bt_type_internal}_create();"
572
+ @ranges.each do |l, u|
573
+ pr "bt_integer_range_set_#{bt_type_internal}_add_range(#{field_class}_range, #{l}, #{u});"
574
+ end
575
+ pr "bt_field_class_enumeration_#{bt_type_internal}_add_mapping(#{field_class}, \"#{@label}\", #{field_class}_range);"
576
+ pr "bt_integer_range_set_#{bt_type_internal}_put_ref(#{field_class}_range);"
577
+ end
578
+ end
579
+ end
580
+
581
+ def initialize(parent:, mappings:)
582
+ @parent = parent
583
+ @mappings = mappings.map do |mapping|
584
+ # Handle inheritence
585
+ self.class.const_get('Mapping').from_h(self, mapping)
586
+ end
587
+ end
588
+
589
+ def get_declarator(trace_class:, variable:)
590
+ bt_type_internal = self.class.instance_variable_get(:@bt_type_internal)
591
+ pr "#{variable} = bt_field_class_enumeration_#{bt_type_internal}_create(#{trace_class});"
592
+ @mappings.each do |mapping|
593
+ mapping.get_declarator(field_class: variable)
594
+ end
558
595
  end
559
596
  end
560
597
 
561
598
  class BTFieldClass::Enumeration::Unsigned < BTFieldClass::Integer::Unsigned
562
599
  include BTFieldClass::Enumeration
563
- class Mapping < BTFieldClass::Enumeration::Mapping
600
+ class BTFieldClass::Enumeration::Unsigned::Mapping < BTFieldClass::Enumeration::Mapping
601
+ @bt_type_internal = 'unsigned'
564
602
  end
565
603
 
566
- def initialize(parent:, field_value_range:, mappings:, preferred_display_base: 10)
567
- @mappings = mappings # TODO: init Mapping
568
- super(parent: parent, field_value_range: field_value_range, preferred_display_base: preferred_display_base)
569
- end
604
+ @bt_type = 'uint64_t'
605
+ @bt_type_internal = 'unsigned'
606
+ @bt_func = 'bt_field_integer_unsigned_%s_value'
570
607
  end
571
608
 
572
609
  class BTFieldClass::Enumeration::Signed < BTFieldClass::Integer::Signed
573
610
  include BTFieldClass::Enumeration
574
- class Mapping < BTFieldClass::Enumeration::Mapping
611
+ class BTFieldClass::Enumeration::Signed::Mapping < BTFieldClass::Enumeration::Mapping
612
+ @bt_type_internal = 'signed'
575
613
  end
576
614
 
577
- def initialize(parent:, field_value_range:, mappings:, preferred_display_base: 10)
578
- @mappings = mappings # TODO: init Mapping
579
- super(parent: parent, field_value_range: field_value_range, preferred_display_base: preferred_display_base)
580
- end
615
+ @bt_type = 'int64_t'
616
+ @bt_type_internal = 'signed'
617
+ @bt_func = 'bt_field_integer_signed_%s_value'
581
618
  end
582
619
 
583
620
  class BTFieldClass::String < BTFieldClass
@@ -597,7 +634,7 @@ module Babeltrace2Gen
597
634
  bt_func_get = self.class.instance_variable_get(:@bt_func) % 'get'
598
635
  variable = bt_get_variable(arg_variables).name
599
636
 
600
- pr "// Dump string data to the struct."
637
+ pr '// Dump string data to the struct.'
601
638
  pr "memcpy(&#{variable}, #{bt_func_get}(#{field}), sizeof(#{variable}));"
602
639
  end
603
640
 
@@ -606,12 +643,12 @@ module Babeltrace2Gen
606
643
 
607
644
  variable = bt_get_variable(arg_variables).name
608
645
 
609
- pr "// Dump data to a temporal string."
646
+ pr '// Dump data to a temporal string.'
610
647
  pr "char *#{field}_temp = (char *)malloc(sizeof(#{variable}));"
611
648
  pr "assert(#{field}_temp != NULL && \"Out of memory\");"
612
649
  pr "memcpy(#{field}_temp, &#{variable}, sizeof(#{variable}));"
613
- pr ""
614
- pr "// Set string field with dumped data."
650
+ pr ''
651
+ pr '// Set string field with dumped data.'
615
652
  pr "bt_field_string_clear(#{field});"
616
653
  pr "bt_field_string_append_status #{field}_status = bt_field_string_append_with_length(#{field}, #{field}_temp, sizeof(#{variable}));"
617
654
  pr "assert(#{field}_status == BT_FIELD_STRING_APPEND_STATUS_OK && \"Out of memory\");"
@@ -671,7 +708,6 @@ module Babeltrace2Gen
671
708
  @element_field_class.get_getter(field: v, arg_variables: arg_variables)
672
709
  end
673
710
  end
674
-
675
711
  end
676
712
 
677
713
  class BTFieldClass::Array::Dynamic < BTFieldClass::Array
@@ -759,13 +795,14 @@ module Babeltrace2Gen
759
795
  def initialize(parent:, field_class: nil, name: nil)
760
796
  @parent = parent
761
797
  is_match_model = parent.rec_trace_class.match
762
- raise ArgumentError.new("missing keyword: :name") unless name || is_match_model
763
- raise ArgumentError.new("missing keyword: :field_class") unless field_class || is_match_model
798
+ raise ArgumentError, 'missing keyword: :name' unless name || is_match_model
799
+ raise ArgumentError, 'missing keyword: :field_class' unless field_class || is_match_model
800
+
764
801
  @name = name # Name can be nil in the matching callbacks
765
- @field_class = BTFieldClass.from_h(self, field_class || {} )
802
+ @field_class = BTFieldClass.from_h(self, field_class || {})
766
803
  end
767
804
 
768
- def bt_get_variable()
805
+ def bt_get_variable
769
806
  @field_class.bt_get_variable({})
770
807
  end
771
808
  end
@@ -994,7 +1031,7 @@ module Babeltrace2Gen
994
1031
  pr "bt_trace_set_environment_entry_#{bt_type_set}(#{trace}, \"#{var_name}\", #{var_name});"
995
1032
  end
996
1033
 
997
- def bt_get_variable(arg_variables={})
1034
+ def bt_get_variable(arg_variables = {})
998
1035
  var = GeneratedArg.new(self.class.instance_variable_get(:@bt_type), @name)
999
1036
  arg_variables.fetch_append('outputs', var)
1000
1037
  end
@@ -26,7 +26,7 @@ module Babeltrace2Gen
26
26
 
27
27
  include BTPrinter
28
28
 
29
- # Scalars are leafs, avoid recursion
29
+ # Scalars are leaves, avoid recursion
30
30
  def self.from_h(model)
31
31
  new(model[:name], model.fetch(:default_value, nil))
32
32
  end
@@ -1,3 +1,3 @@
1
1
  module Metababel
2
- VERSION = '1.0.4'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -0,0 +1,96 @@
1
+ #include <babeltrace2/babeltrace.h>
2
+ #include <metababel/metababel.h>
3
+ #include <unordered_map>
4
+
5
+ typedef std::unordered_map<const bt_stream *, const bt_message *> StreamToMessage_t;
6
+ typedef std::unordered_map<const bt_packet *, const bt_message *> PacketToMessage_t;
7
+
8
+ struct StreamToMessages_s {
9
+ StreamToMessage_t stream_beginning;
10
+ PacketToMessage_t packet_beginning;
11
+ };
12
+ typedef struct StreamToMessages_s StreamToMessages_t;
13
+
14
+ static void btx_initialize_usr_data(void **usr_data) { *usr_data = new StreamToMessages_t{}; }
15
+
16
+ static void btx_finalize_usr_data(void *usr_data) { delete ((StreamToMessages_t *)(usr_data)); }
17
+
18
+ static void push_associated_beginnings(void *btx_handle, StreamToMessages_t *h,
19
+ const bt_message *message) {
20
+
21
+ const bt_event *event = bt_message_event_borrow_event_const(message);
22
+ const bt_stream *stream = bt_event_borrow_stream_const(event);
23
+
24
+ auto it_stream = h->stream_beginning.find(stream);
25
+ if (it_stream != h->stream_beginning.end()) {
26
+ btx_push_message(btx_handle, it_stream->second);
27
+ h->stream_beginning.erase(it_stream);
28
+ }
29
+
30
+ if (bt_stream_class_supports_packets(bt_stream_borrow_class_const(stream))) {
31
+ const auto packet = bt_event_borrow_packet_const(event);
32
+ auto it_packet = h->packet_beginning.find(packet);
33
+ if (it_packet != h->packet_beginning.end()) {
34
+ btx_push_message(btx_handle, it_packet->second);
35
+ h->packet_beginning.erase(it_packet);
36
+ }
37
+ }
38
+ }
39
+
40
+ template <typename T>
41
+ static void push_or_drop_message(void *btx_handle,
42
+ std::unordered_map<const T *, const bt_message *> &stm,
43
+ const T *key, const bt_message *message) {
44
+ auto it = stm.find(key);
45
+ if (it == stm.end()) {
46
+ btx_push_message(btx_handle, message);
47
+ } else {
48
+ bt_message_put_ref(message);
49
+ bt_message_put_ref(it->second);
50
+ stm.erase(it);
51
+ }
52
+ }
53
+
54
+ static void on_downstream_message_callback(void *btx_handle, void *usr_data,
55
+ const bt_message *message) {
56
+
57
+ auto *h = (StreamToMessages_t *)usr_data;
58
+ switch (bt_message_get_type(message)) {
59
+ // Save begins
60
+ case (BT_MESSAGE_TYPE_STREAM_BEGINNING): {
61
+ const bt_stream *stream = bt_message_stream_beginning_borrow_stream_const(message);
62
+ h->stream_beginning.insert({stream, message});
63
+ break;
64
+ }
65
+ case (BT_MESSAGE_TYPE_PACKET_BEGINNING): {
66
+ const bt_packet *packet = bt_message_packet_beginning_borrow_packet_const(message);
67
+ h->packet_beginning.insert({packet, message});
68
+ break;
69
+ }
70
+ // Push event and associated beginnings
71
+ case (BT_MESSAGE_TYPE_EVENT): {
72
+ push_associated_beginnings(btx_handle, h, message);
73
+ btx_push_message(btx_handle, message);
74
+ break;
75
+ }
76
+ // Drop or push ends
77
+ case (BT_MESSAGE_TYPE_PACKET_END): {
78
+ const bt_packet *packet = bt_message_packet_end_borrow_packet_const(message);
79
+ push_or_drop_message(btx_handle, h->packet_beginning, packet, message);
80
+ break;
81
+ }
82
+ case (BT_MESSAGE_TYPE_STREAM_END): {
83
+ const bt_stream *stream = bt_message_stream_end_borrow_stream_const(message);
84
+ push_or_drop_message(btx_handle, h->stream_beginning, stream, message);
85
+ break;
86
+ }
87
+ default:
88
+ btx_push_message(btx_handle, message);
89
+ }
90
+ }
91
+
92
+ void btx_register_usr_callbacks(void *btx_handle) {
93
+ btx_register_callbacks_initialize_component(btx_handle, &btx_initialize_usr_data);
94
+ btx_register_callbacks_finalize_component(btx_handle, &btx_finalize_usr_data);
95
+ btx_register_on_downstream_message_callback(btx_handle, &on_downstream_message_callback);
96
+ }
@@ -27,8 +27,8 @@ void btx_call_callbacks_<%= e.name_sanitized %>(
27
27
  <%= e.name_sanitized %>_static_callback_f *p =
28
28
  common_data->static_callbacks-><%= e.name_sanitized %>;
29
29
  if (p)
30
- p( <%= "(void *)common_data," unless e.no_btx_handle %>
31
- <%= e.args.map{ |s| s.name }.join(", ") %>);
30
+ p(<%= "(void *)common_data," unless e.no_btx_handle %>
31
+ <%= e.args.map{ |s| s.name }.join(", ") %>);
32
32
  }
33
33
  <% end %>
34
34
 
@@ -4,8 +4,8 @@
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] %>"
7
+ <% if options.key?(:'usr-data-header') %>
8
+ #include "<%= options[:'usr-data-header'] %>"
9
9
  <% end %>
10
10
 
11
11
  #ifdef __cplusplus
@@ -50,7 +50,7 @@ struct name_to_dispatcher_s {
50
50
  };
51
51
  typedef struct name_to_dispatcher_s name_to_dispatcher_t;
52
52
 
53
- <% if ['SOURCE', 'FILTER'].include?(options[:component_type]) %>
53
+ <% if ['SOURCE', 'FILTER'].include?(options[:'component-type']) %>
54
54
  // Structure for Downstream Message
55
55
  struct el {
56
56
  const bt_message *message;
@@ -59,11 +59,11 @@ struct el {
59
59
 
60
60
  <% end %>
61
61
  // Struct stored in the component via `bt_self_component_set_data`
62
- <% if options[:component_type] == 'SOURCE' %>
62
+ <% if options[:'component-type'] == 'SOURCE' %>
63
63
  struct common_data_s {
64
64
  name_to_dispatcher_t *name_to_dispatcher;
65
65
  static_callbacks_t *static_callbacks;
66
- <% unless options[:disable_callbaks].include?('on_downstream') %>
66
+ <% unless options[:'disable-callbaks'].include?('on_downstream') %>
67
67
  void *on_downstream_message_callback;
68
68
  <% end %>
69
69
  void *usr_data;
@@ -101,11 +101,11 @@ enum btx_source_status_e {
101
101
  };
102
102
  typedef enum btx_source_status_e btx_source_status_t;
103
103
 
104
- <% elsif options[:component_type] == 'FILTER' %>
104
+ <% elsif options[:'component-type'] == 'FILTER' %>
105
105
  struct common_data_s {
106
106
  name_to_dispatcher_t *name_to_dispatcher;
107
107
  static_callbacks_t *static_callbacks;
108
- <% unless options[:disable_callbaks].include?('on_downstream') %>
108
+ <% unless options[:'disable-callbaks'].include?('on_downstream') %>
109
109
  void *on_downstream_message_callback;
110
110
  <% end %>
111
111
 
@@ -155,7 +155,7 @@ struct btx_message_iterator_s {
155
155
  };
156
156
  typedef struct btx_message_iterator_s btx_message_iterator_t;
157
157
 
158
- <% elsif options[:component_type] == 'SINK' %>
158
+ <% elsif options[:'component-type'] == 'SINK' %>
159
159
  struct common_data_s {
160
160
  name_to_dispatcher_t *name_to_dispatcher;
161
161
  static_callbacks_t *static_callbacks;
@@ -173,8 +173,8 @@ void btx_unregister_callbacks(common_data_t *common_data);
173
173
 
174
174
  <% static_callback_types.each do |e| %>
175
175
  typedef void <%= e.name_sanitized %>_static_callback_f(
176
- <%= "void *btx_handle," unless e.no_btx_handle %>
177
- <%= e.args.map{ |s| s.type }.join(", ") %>);
176
+ <%= "void *btx_handle," unless e.no_btx_handle %>
177
+ <%= e.args.map{ |s| s.type }.join(", ") %>);
178
178
 
179
179
  <%# The Function who register the callbacks to the dispatcher %>
180
180
  void btx_register_callbacks_<%= e.name_sanitized %>(
@@ -35,7 +35,7 @@ _btx_push_message(btx_message_iterator_t *message_iterator_private_data,
35
35
  DL_APPEND(message_iterator_private_data->queue, elt);
36
36
  }
37
37
 
38
- <% unless options[:disable_callbaks].include?('on_downstream') %>
38
+ <% unless options[:'disable-callbaks'].include?('on_downstream') %>
39
39
  void btx_push_message(void *btx_handle, const bt_message *message) {
40
40
  _btx_push_message((btx_message_iterator_t *)btx_handle, message);
41
41
  }
@@ -46,12 +46,12 @@ void btx_register_on_downstream_message_callback(
46
46
  (void *)callback;
47
47
  }
48
48
  <% end %>
49
- // Used internaly to push messages downstreams
49
+ // Used internally to push messages downstreams
50
50
  void btx_downstream_push_message(
51
51
  btx_message_iterator_t *message_iterator_private_data,
52
52
  const bt_message *message) {
53
53
 
54
- <% unless options[:disable_callbaks].include?('on_downstream') %>
54
+ <% unless options[:'disable-callbaks'].include?('on_downstream') %>
55
55
  on_downstream_message_callback_f *p =
56
56
  (on_downstream_message_callback_f *)message_iterator_private_data
57
57
  ->common_data->on_downstream_message_callback;
@@ -84,7 +84,7 @@ bt_trace *btx_downstream_trace_create_rec(bt_trace_class *trace_class) {
84
84
  return trace;
85
85
  }
86
86
 
87
- // Workarround of a bug where gepping trace alive (and not the stream) provoke
87
+ // Workaround of a bug where gepping trace alive (and not the stream) provoke
88
88
  // some segfault
89
89
  void btx_streams_get_ref(bt_trace *trace) {
90
90
  <% stream_classes.each_with_index do |_,i| %>
@@ -118,6 +118,7 @@ void btx_push_messages_stream_beginning(
118
118
  btx_downstream_push_message(message_iterator_private_data, message);
119
119
  }
120
120
  <% end %>
121
+ (void)trace;
121
122
  }
122
123
 
123
124
  void btx_push_messages_stream_end(
@@ -134,6 +135,7 @@ void btx_push_messages_stream_end(
134
135
  btx_downstream_push_message(message_iterator_private_data, message);
135
136
  }
136
137
  <% end %>
138
+ (void)trace;
137
139
  }
138
140
 
139
141
  <% downstream_events.each do |e| %>
@@ -175,8 +177,8 @@ void btx_push_message_<%= e.name_sanitized %>(
175
177
  <% end %>
176
178
 
177
179
  <% downstream_environements.each do |arg, body| %>
178
- void btx_downstream_set_environment_<%= arg.name%>(void *btx_handle,
179
- <%= arg.type%> <%= arg.name%>) {
180
+ void btx_downstream_set_environment_<%= arg.name%>(
181
+ void *btx_handle, <%= arg.type%> <%= arg.name%>) {
180
182
  common_data_t *common_data = (common_data_t *)btx_handle;
181
183
  bt_trace *_trace = common_data->downstream_trace;
182
184
  <%= body %>
@@ -33,7 +33,7 @@ void btx_push_message_<%= e.name_sanitized %>(
33
33
  btx_handle<%= e.args.map{ |s| "#{s.type} #{s.name}" }.join_with_prefix(", ") %>);
34
34
  <% end %>
35
35
 
36
- <% unless options[:disable_callbaks].include?('on_downstream') %>
36
+ <% unless options[:'disable-callbaks'].include?('on_downstream') %>
37
37
  void btx_push_message(void *btx_handle, const bt_message *message);
38
38
 
39
39
  typedef void on_downstream_message_callback_f(void *btx_handle, void *usr_data,
@@ -43,8 +43,8 @@ void btx_register_on_downstream_message_callback(
43
43
  <% end %>
44
44
 
45
45
  <% downstream_environements.each do |arg, body| %>
46
- void btx_downstream_set_environment_<%= arg.name%>(void *btx_handle,
47
- <%= arg.type%> <%= arg.name%>);
46
+ void btx_downstream_set_environment_<%= arg.name%>(
47
+ void *btx_handle, <%= arg.type%> <%= arg.name%>);
48
48
  <% end %>
49
49
 
50
50
  #ifdef __cplusplus
@@ -264,7 +264,7 @@ filter_message_iterator_next_initializing(
264
264
  (btx_message_iterator_t *)bt_self_message_iterator_get_data(
265
265
  self_message_iterator);
266
266
 
267
- /* Begining of Stream */
267
+ /* Beginning of Stream */
268
268
  btx_push_messages_stream_beginning(self_message_iterator,
269
269
  message_iterator_private_data);
270
270
 
@@ -404,7 +404,7 @@ filter_initialize(bt_self_component_filter *self_component_filter,
404
404
  btx_call_callbacks_initialize_component(common_data, &common_data->usr_data);
405
405
  /* Call read callbacks */
406
406
  btx_call_callbacks_read_params(common_data, common_data->usr_data,
407
- common_data->btx_params);
407
+ common_data->btx_params);
408
408
 
409
409
  return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
410
410
  }
@@ -519,17 +519,17 @@ static void filter_message_iterator_finalize(
519
519
  /* Mandatory */
520
520
  BT_PLUGIN_MODULE();
521
521
 
522
- BT_PLUGIN(<%= options[:plugin_name] %>);
523
- BT_PLUGIN_FILTER_COMPONENT_CLASS(<%= options[:component_name] %>,
522
+ BT_PLUGIN(<%= options[:'plugin-name'] %>);
523
+ BT_PLUGIN_FILTER_COMPONENT_CLASS(<%= options[:'component-name'] %>,
524
524
  filter_message_iterator_next);
525
525
 
526
526
  BT_PLUGIN_FILTER_COMPONENT_CLASS_INITIALIZE_METHOD(
527
- <%= options[:component_name] %>, filter_initialize);
527
+ <%= options[:'component-name'] %>, filter_initialize);
528
528
  BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD(
529
- <%= options[:component_name] %>, filter_finalize);
529
+ <%= options[:'component-name'] %>, filter_finalize);
530
530
  BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(
531
- <%= options[:component_name] %>, filter_message_iterator_initialize);
531
+ <%= options[:'component-name'] %>, filter_message_iterator_initialize);
532
532
  BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(
533
- <%= options[:component_name] %>, filter_message_iterator_finalize);
533
+ <%= options[:'component-name'] %>, filter_message_iterator_finalize);
534
534
  BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(
535
- <%= options[:component_name] %>, filter_input_port_connected);
535
+ <%= options[:'component-name'] %>, filter_input_port_connected);
@@ -1,7 +1,7 @@
1
1
  #include <metababel/btx_component.h>
2
- <% if ['SOURCE', 'FILTER'].include?(options[:component_type]) %>
2
+ <% if ['SOURCE', 'FILTER'].include?(options[:'component-type']) %>
3
3
  #include <metababel/btx_downstream.h>
4
4
  <% end %>
5
- <% if ['FILTER', 'SINK'].include?(options[:component_type]) %>
5
+ <% if ['FILTER', 'SINK'].include?(options[:'component-type']) %>
6
6
  #include <metababel/btx_upstream.h>
7
7
  <% end %>
data/template/sink.c.erb CHANGED
@@ -18,7 +18,7 @@ sink_consume(bt_self_component_sink *self_component_sink) {
18
18
  BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
19
19
 
20
20
  /* Retrieve our private data from the component's user data */
21
- /* This containt user data and the message iterator */
21
+ /* This contain user data and the message iterator */
22
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
 
@@ -153,7 +153,7 @@ sink_graph_is_configured(bt_self_component_sink *self_component_sink) {
153
153
  bt_self_component_port_input *in_port =
154
154
  bt_self_component_sink_borrow_input_port_by_index(self_component_sink, 0);
155
155
 
156
- /* Create the uptream message iterator */
156
+ /* Create the upstream message iterator */
157
157
  bt_message_iterator_create_from_sink_component(
158
158
  self_component_sink, in_port, &common_data->message_iterator);
159
159
 
@@ -163,15 +163,12 @@ sink_graph_is_configured(bt_self_component_sink *self_component_sink) {
163
163
  /* Mandatory */
164
164
  BT_PLUGIN_MODULE();
165
165
 
166
- BT_PLUGIN(<%= options[:plugin_name] %>);
167
- // Maybe we should createonly one pluging
168
- /* Add the output component class */
169
- BT_PLUGIN_SINK_COMPONENT_CLASS(<%= options[:component_name] %>, sink_consume);
166
+ BT_PLUGIN(<%= options[:'plugin-name'] %>);
167
+ BT_PLUGIN_SINK_COMPONENT_CLASS(<%= options[:'component-name'] %>, sink_consume);
170
168
 
171
169
  BT_PLUGIN_SINK_COMPONENT_CLASS_INITIALIZE_METHOD(
172
- <%= options[:component_name] %>, sink_initialize);
173
- BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(<%= options[:component_name] %>,
174
- sink_finalize);
175
-
170
+ <%= options[:'component-name'] %>, sink_initialize);
171
+ BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(
172
+ <%= options[:'component-name'] %>, sink_finalize);
176
173
  BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD(
177
- <%= options[:component_name] %>, sink_graph_is_configured);
174
+ <%= options[:'component-name'] %>, sink_graph_is_configured);
@@ -33,7 +33,7 @@ source_message_iterator_next(bt_self_message_iterator *self_message_iterator,
33
33
  * not put any message into the message array */
34
34
  switch (message_iterator_private_data->state) {
35
35
  case BTX_SOURCE_STATE_INITIALIZING:
36
- /* Begining of Stream */
36
+ /* Beginning of Stream */
37
37
  btx_push_messages_stream_beginning(self_message_iterator,
38
38
  message_iterator_private_data);
39
39
  /* Call Initialize user callback */
@@ -132,7 +132,7 @@ source_initialize(bt_self_component_source *self_component_source,
132
132
  btx_call_callbacks_initialize_component(common_data, &common_data->usr_data);
133
133
  /* Call read callbacks */
134
134
  btx_call_callbacks_read_params(common_data, common_data->usr_data,
135
- common_data->btx_params);
135
+ common_data->btx_params);
136
136
 
137
137
  return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
138
138
  }
@@ -209,15 +209,15 @@ static void source_message_iterator_finalize(
209
209
  /* Mandatory */
210
210
  BT_PLUGIN_MODULE();
211
211
 
212
- BT_PLUGIN(<%= options[:plugin_name] %>);
213
- BT_PLUGIN_SOURCE_COMPONENT_CLASS(<%= options[:component_name] %>,
212
+ BT_PLUGIN(<%= options[:'plugin-name'] %>);
213
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS(<%= options[:'component-name'] %>,
214
214
  source_message_iterator_next);
215
215
 
216
216
  BT_PLUGIN_SOURCE_COMPONENT_CLASS_INITIALIZE_METHOD(
217
- <%= options[:component_name] %>, source_initialize);
217
+ <%= options[:'component-name'] %>, source_initialize);
218
218
  BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD(
219
- <%= options[:component_name] %>, source_finalize);
219
+ <%= options[:'component-name'] %>, source_finalize);
220
220
  BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(
221
- <%= options[:component_name] %>, source_message_iterator_initialize);
221
+ <%= options[:'component-name'] %>, source_message_iterator_initialize);
222
222
  BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(
223
- <%= options[:component_name] %>, source_message_iterator_finalize);
223
+ <%= options[:'component-name'] %>, source_message_iterator_finalize);
@@ -55,9 +55,9 @@ static void btx_dispatch_<%= dispatcher.name_sanitized %>(
55
55
 
56
56
  <% end %>
57
57
 
58
- static void bt_register_callbacks(void *btx_handle, const char *dispatcher_name,
59
- void *btx_dispatch_p, const char *id,
60
- void *callback) {
58
+ static void __attribute__((unused))
59
+ bt_register_callbacks(void *btx_handle, const char *dispatcher_name,
60
+ void *btx_dispatch_p, const char *id, void *callback) {
61
61
 
62
62
  name_to_dispatcher_t *s = NULL;
63
63
 
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: 1.0.4
4
+ version: 1.1.1
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: 2024-02-16 00:00:00.000000000 Z
13
+ date: 2024-04-03 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description:
16
16
  email:
@@ -29,6 +29,7 @@ files:
29
29
  - lib/metababel/bt2_trace_class_generator.rb
30
30
  - lib/metababel/bt2_values_generator.rb
31
31
  - lib/metababel/version.rb
32
+ - shared/stripper.cpp
32
33
  - template/component.c.erb
33
34
  - template/component.h.erb
34
35
  - template/downstream.c.erb