metababel 1.1.3 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 833addc848667ae6e79f054444feb055f89f6d92a6b5ea06e091c3120e6ae108
4
- data.tar.gz: 489687cf9d30edf2cbed47696f0c0314fff308ff3527c41c68fbd3ef65c2202b
3
+ metadata.gz: 59de2133e8a84ac9fb121c0a66ab94c7f8e8dc84b59d85f5dfc21fe68d7ff600
4
+ data.tar.gz: c18c4499cef1af36847f4dc4ced58107e3e52ec5cd9d3e8bfe69f1d3d50ef793
5
5
  SHA512:
6
- metadata.gz: 59c42bc311b8ab39e51a87abab2c74aa4d62df0611f2f3c4bcfafe78d1833bb87bb007849e716edf654bc05f658e7ef45dedd6b2778b70e6fe5f3879c5887162
7
- data.tar.gz: 57049a2e114b394126fe382ed205edf608047e3ce59610fb3acca3d98ec48dad94d1076983a18a11e34ee35cbc78678c66229a76ee4f5747288501ee64b0d9dd
6
+ metadata.gz: d7ed22589acca08ad6ab56f7db2e209cdb13ffd4b4b1ddf11964c412ba6383b387dbf7a928aea61a12ac182dd057d43535756df896c616f4280b94b2d365b51d
7
+ data.tar.gz: '0291a811c6adc80c0ffa94bd4c04af15c66990efc491f479b6ac9e83fe40968bebb5da964a9fdfd1dfa4270990bf86772e2e72b137c458388da341ae7261d1c3'
data/bin/metababel CHANGED
@@ -125,18 +125,17 @@ class Dispatcher < BaseDispatch
125
125
  end
126
126
  end
127
127
 
128
- # We preprent an empty new line from the body as a hack, to correct the indentation
129
- # Indeeed the <%= body %> will be indented, but we don't don't want it,
130
- # in the body string is already indented
131
- # But we clean the white space empty line afterward \o/
128
+ # Prepend a newline to align the rendered body correctly.
129
+ # Without this, ERB adds unwanted indentation to <%= body %>.
130
+ # Since body_args[1] is already indented, we avoid double-indentation.
131
+ # The extra leading blank line is removed later.
132
132
  def body
133
133
  "\n" + body_args[1]
134
134
  end
135
135
 
136
136
  def args
137
- evt_args = []
138
- evt_args += [GeneratedArg.new('int64_t', '_timestamp')] if @default_clock_class
139
- evt_args += body_args[0].fetch('outputs', [])
137
+ timestamp = @default_clock_class ? [GeneratedArg.new('int64_t', '_timestamp')] : []
138
+ timestamp + body_args[0].fetch('outputs', [])
140
139
  end
141
140
 
142
141
  def args_to_free
@@ -191,16 +190,15 @@ def parse_argv
191
190
  parser.on('-o', '--output FOLDER', '[Optional] Output folder path.')
192
191
  parser.on('-i', '--usr-data-header NAME', '[Optional] User datatypes definitions.')
193
192
  parser.on('--enable-callbacks NAME', Array, '[Optional] Enable some callbacks type')
194
- parser.on('--display-shared-callback PLUGIN') { |plugin|
193
+ parser.on('--display-shared-callback PLUGIN') do |plugin|
195
194
  path = Dir["#{__dir__}/../shared/*#{plugin}*"].first
196
195
  puts File.readlines(path)
197
196
  exit
198
- }
199
- parser.on('--drop','[Optional] Drop unknow messages')
197
+ end
198
+ parser.on('--drop', '[Optional] Drop unknow messages')
200
199
 
201
200
  options = { 'disable-callbaks': ['on_downstream'].to_set,
202
- 'component-name': 'btx',
203
- }
201
+ 'component-name': 'btx' }
204
202
  parser.parse!(into: options)
205
203
  raise OptionParser::MissingArgument if options[:'component-type'].nil?
206
204
 
@@ -44,23 +44,45 @@ module Babeltrace2Gen
44
44
  def rec_member_class
45
45
  is_a?(Babeltrace2Gen::BTMemberClass) ? self : @parent.rec_member_class
46
46
  end
47
+ end
48
+
49
+ class BTFieldLocation
50
+ include BTLocator
51
+ include BTPrinter
52
+
53
+ # root_scope is the full babeltrace enum name, e.g.
54
+ # BT_FIELD_LOCATION_SCOPE_EVENT_PAYLOAD (mirrors the C bt_field_location API).
55
+ attr_reader :root_scope, :items
56
+
57
+ def initialize(parent:, root_scope:, items:)
58
+ raise "nested field locations are not supported (items: #{items})" unless items.size == 1
47
59
 
48
- def resolve_path(path)
49
- root, id = path.match(/^(PACKET_CONTEXT|EVENT_COMMON_CONTEXT|EVENT_SPECIFIC_CONTEXT|EVENT_PAYLOAD)\["?(.+)?"\]/).captures
60
+ @parent = parent
61
+ @root_scope = root_scope
62
+ @items = items
63
+ end
64
+
65
+ def member
50
66
  field_class =
51
- case root
52
- when 'PACKET_CONTEXT'
67
+ case @root_scope.to_s
68
+ when 'BT_FIELD_LOCATION_SCOPE_PACKET_CONTEXT'
53
69
  rec_stream_class.packet_context_field_class
54
- when 'EVENT_COMMON_CONTEXT'
70
+ when 'BT_FIELD_LOCATION_SCOPE_EVENT_COMMON_CONTEXT'
55
71
  rec_stream_class.event_common_context_field_class
56
- when 'EVENT_SPECIFIC_CONTEXT'
72
+ when 'BT_FIELD_LOCATION_SCOPE_EVENT_SPECIFIC_CONTEXT'
57
73
  rec_event_class.specific_context_field_class
58
- when 'EVENT_PAYLOAD'
74
+ when 'BT_FIELD_LOCATION_SCOPE_EVENT_PAYLOAD'
59
75
  rec_event_class.payload_field_class
60
76
  else
61
- raise "invalid path #{path}"
77
+ raise "invalid field-location root scope #{@root_scope}"
62
78
  end
63
- [field_class, id]
79
+ field_class[@items.first]
80
+ end
81
+
82
+ def get_declarator(trace_class:, variable:)
83
+ items_var = "#{variable}_items"
84
+ pr "const char *const #{items_var}[] = { #{@items.map { |i| "\"#{i}\"" }.join(', ')} };"
85
+ pr "#{variable} = bt_field_location_create(#{trace_class}, #{@root_scope}, #{items_var}, #{@items.length});"
64
86
  end
65
87
  end
66
88
 
@@ -249,7 +271,6 @@ module Babeltrace2Gen
249
271
 
250
272
  def initialize(parent:, name: nil, specific_context_field_class: nil, payload_field_class: nil, id: nil,
251
273
  set_id: nil, domain: nil, register: true)
252
-
253
274
  @set_id = set_id
254
275
  @domain = domain
255
276
  @register = register
@@ -365,6 +386,7 @@ module Babeltrace2Gen
365
386
  include BTLocator
366
387
  include BTPrinter
367
388
  include BTMatch
389
+
368
390
  using HashRefinements
369
391
 
370
392
  BT_MATCH_ATTRS = %i[type cast_type cast_type_is_struct]
@@ -394,6 +416,8 @@ module Babeltrace2Gen
394
416
  'string' => BTFieldClass::String,
395
417
  'array_static' => BTFieldClass::Array::Static,
396
418
  'array_dynamic' => BTFieldClass::Array::Dynamic,
419
+ 'blob_static' => BTFieldClass::Blob::Static,
420
+ 'blob_dynamic' => BTFieldClass::Blob::Dynamic,
397
421
  'structure' => BTFieldClass::Structure,
398
422
  'option_without_selector_field' => BTFieldClass::Option::WithoutSelectorField,
399
423
  'option_with_selector_field_bool' => BTFieldClass::Option::WithSelectorField::Bool,
@@ -470,6 +494,7 @@ module Babeltrace2Gen
470
494
 
471
495
  class BTFieldClass::BitArray < BTFieldClass
472
496
  extend BTFromH
497
+
473
498
  attr_reader :length
474
499
 
475
500
  @bt_type = 'uint64_t'
@@ -597,6 +622,7 @@ module Babeltrace2Gen
597
622
 
598
623
  class BTFieldClass::Enumeration::Unsigned < BTFieldClass::Integer::Unsigned
599
624
  include BTFieldClass::Enumeration
625
+
600
626
  class BTFieldClass::Enumeration::Unsigned::Mapping < BTFieldClass::Enumeration::Mapping
601
627
  @bt_type_internal = 'unsigned'
602
628
  end
@@ -608,6 +634,7 @@ module Babeltrace2Gen
608
634
 
609
635
  class BTFieldClass::Enumeration::Signed < BTFieldClass::Integer::Signed
610
636
  include BTFieldClass::Enumeration
637
+
611
638
  class BTFieldClass::Enumeration::Signed::Mapping < BTFieldClass::Enumeration::Mapping
612
639
  @bt_type_internal = 'signed'
613
640
  end
@@ -629,7 +656,7 @@ module Babeltrace2Gen
629
656
  end
630
657
 
631
658
  def get_getter(field:, arg_variables:)
632
- return super(field: field, arg_variables: arg_variables) unless @cast_type_is_struct
659
+ return super unless @cast_type_is_struct
633
660
 
634
661
  bt_func_get = self.class.instance_variable_get(:@bt_func) % 'get'
635
662
  variable = bt_get_variable(arg_variables).name
@@ -639,7 +666,7 @@ module Babeltrace2Gen
639
666
  end
640
667
 
641
668
  def get_setter(field:, arg_variables:)
642
- return super(field: field, arg_variables: arg_variables) unless @cast_type_is_struct
669
+ return super unless @cast_type_is_struct
643
670
 
644
671
  variable = bt_get_variable(arg_variables).name
645
672
 
@@ -667,6 +694,7 @@ module Babeltrace2Gen
667
694
 
668
695
  class BTFieldClass::Array::Static < BTFieldClass::Array
669
696
  extend BTFromH
697
+
670
698
  using HashRefinements
671
699
  attr_reader :length
672
700
 
@@ -712,17 +740,19 @@ module Babeltrace2Gen
712
740
 
713
741
  class BTFieldClass::Array::Dynamic < BTFieldClass::Array
714
742
  extend BTFromH
743
+
715
744
  module WithLengthField
716
- attr_reader :length_field_path
745
+ attr_reader :length_field_location
717
746
  end
718
747
  using HashRefinements
719
748
 
720
- def initialize(parent:, element_field_class:, length_field_path: nil)
749
+ def initialize(parent:, element_field_class:, length_field_location: nil)
721
750
  super(parent: parent, element_field_class: element_field_class)
722
- return unless length_field_path
751
+ return unless length_field_location
723
752
 
724
753
  extend(WithLengthField)
725
- @length_field_path = length_field_path
754
+
755
+ @length_field_location = BTFieldLocation.new(parent: self, **length_field_location)
726
756
  end
727
757
 
728
758
  def get_declarator(trace_class:, variable:)
@@ -730,34 +760,26 @@ module Babeltrace2Gen
730
760
  scope do
731
761
  pr "bt_field_class *#{element_field_class_variable};"
732
762
  @element_field_class.get_declarator(trace_class: trace_class, variable: element_field_class_variable)
733
- if @length_field_path
734
- element_field_class_variable_length = "#{element_field_class_variable}_length"
735
- pr "bt_field_class *#{element_field_class_variable_length};"
763
+ if @length_field_location
764
+ # MIP 1: reference the length field via a field-location instead of a
765
+ # length field class (bt_field_class_array_dynamic_create is MIP 0 only).
766
+ loc = "#{element_field_class_variable}_length_loc"
767
+ pr "const bt_field_location *#{loc};"
736
768
  scope do
737
- element_field_class_variable_length_sm = "#{element_field_class_variable_length}_sm"
738
- pr "bt_field_class_structure_member *#{element_field_class_variable_length_sm};"
739
- field_class, id = resolve_path(@length_field_path)
740
- id.scan(/(\w+)|(\d+)/).each do |name, index|
741
- # String
742
- if name
743
- pr "#{element_field_class_variable_length_sm} = bt_field_class_structure_borrow_member_by_name(#{field_class.variable}, \"#{name}\");"
744
- else
745
- pr "#{element_field_class_variable_length_sm} = bt_field_class_structure_borrow_member_by_index(#{field_class.variable}, #{index});"
746
- end
747
- end
748
- pr "#{element_field_class_variable_length} = bt_field_class_structure_member_borrow_field_class(#{element_field_class_variable_length_sm});"
769
+ @length_field_location.get_declarator(trace_class: trace_class, variable: loc)
749
770
  end
750
- pr "#{variable} = bt_field_class_array_dynamic_create(#{trace_class}, #{element_field_class_variable}, #{element_field_class_variable_length});"
771
+ pr "#{variable} = bt_field_class_array_dynamic_with_length_field_location_create(#{trace_class}, #{element_field_class_variable}, #{loc});"
772
+ pr "bt_field_location_put_ref(#{loc});"
751
773
  pr "bt_field_class_put_ref(#{element_field_class_variable});"
752
774
  else
753
- pr "#{variable} = bt_field_class_array_dynamic_create(#{trace_class}, #{element_field_class_variable}, NULL);"
775
+ pr "#{variable} = bt_field_class_array_dynamic_without_length_field_location_create(#{trace_class}, #{element_field_class_variable});"
776
+ pr "bt_field_class_put_ref(#{element_field_class_variable});"
754
777
  end
755
778
  end
756
779
  end
757
780
 
758
781
  def get_setter(field:, arg_variables:)
759
- field_class, id = resolve_path(@length_field_path)
760
- length_field = field_class[id]
782
+ length_field = @length_field_location.member
761
783
  pr "bt_field_array_dynamic_set_length(#{field}, #{length_field.name});"
762
784
  usr_var = bt_get_variable(arg_variables, is_array: true)
763
785
  pr "for(uint64_t _i=0; _i < #{length_field.name} ; _i++)"
@@ -784,6 +806,92 @@ module Babeltrace2Gen
784
806
  end
785
807
  end
786
808
 
809
+ # BLOB fields (CTF2 / MIP 1): a raw byte buffer with an associated IANA media
810
+ # type. Used by THAPI to record structs/unions and opaque byte buffers as
811
+ # uninterpreted bytes instead of smuggling them through text sequences.
812
+ class BTFieldClass::Blob < BTFieldClass
813
+ DEFAULT_MEDIA_TYPE = 'application/octet-stream'
814
+
815
+ attr_reader :media_type
816
+
817
+ # Emit the media-type assignment shared by static and dynamic blobs.
818
+ def declare_media_type(variable)
819
+ pr "bt_field_class_blob_set_media_type(#{variable}, \"#{@media_type || DEFAULT_MEDIA_TYPE}\");"
820
+ end
821
+ end
822
+
823
+ class BTFieldClass::Blob::Static < BTFieldClass::Blob
824
+ extend BTFromH
825
+
826
+ attr_reader :length
827
+
828
+ def initialize(parent:, length:, media_type: nil)
829
+ @parent = parent
830
+ @length = length
831
+ @media_type = media_type
832
+ end
833
+
834
+ def get_declarator(trace_class:, variable:)
835
+ pr "#{variable} = bt_field_class_blob_static_create(#{trace_class}, #{@length});"
836
+ declare_media_type(variable)
837
+ end
838
+
839
+ # A fixed-length blob carries the raw bytes of a struct/union; reconstruct it
840
+ # by memcpy, mirroring BTFieldClass::String with cast_type_is_struct.
841
+ def get_setter(field:, arg_variables:)
842
+ variable = bt_get_variable(arg_variables).name
843
+ pr "memcpy(bt_field_blob_get_data(#{field}), &#{variable}, #{@length});"
844
+ end
845
+
846
+ def get_getter(field:, arg_variables:)
847
+ variable = bt_get_variable(arg_variables).name
848
+ pr "memcpy(&#{variable}, bt_field_blob_get_data_const(#{field}), #{@length});"
849
+ end
850
+ end
851
+
852
+ class BTFieldClass::Blob::Dynamic < BTFieldClass::Blob
853
+ extend BTFromH
854
+
855
+ attr_reader :length_field_location
856
+
857
+ @bt_type = 'uint8_t*'
858
+
859
+ def initialize(parent:, length_field_location: nil, media_type: nil)
860
+ @parent = parent
861
+ @length_field_location = BTFieldLocation.new(parent: self, **length_field_location) if length_field_location
862
+ @media_type = media_type
863
+ end
864
+
865
+ def get_declarator(trace_class:, variable:)
866
+ if @length_field_location
867
+ loc = "#{variable}_length_loc"
868
+ pr "const bt_field_location *#{loc};"
869
+ scope do
870
+ @length_field_location.get_declarator(trace_class: trace_class, variable: loc)
871
+ end
872
+ pr "#{variable} = bt_field_class_blob_dynamic_with_length_field_location_create(#{trace_class}, #{loc});"
873
+ pr "bt_field_location_put_ref(#{loc});"
874
+ else
875
+ pr "#{variable} = bt_field_class_blob_dynamic_without_length_field_location_create(#{trace_class});"
876
+ end
877
+ declare_media_type(variable)
878
+ end
879
+
880
+ def get_setter(field:, arg_variables:)
881
+ length_field = @length_field_location.member
882
+ usr_var = bt_get_variable(arg_variables)
883
+ pr "bt_field_blob_dynamic_set_length(#{field}, #{length_field.name});"
884
+ pr "memcpy(bt_field_blob_get_data(#{field}), #{usr_var.name}, #{length_field.name});"
885
+ end
886
+
887
+ # The returned pointer is valid until the field is modified, so hand it to the
888
+ # callback directly instead of copying (mirrors BTFieldClass::String).
889
+ def get_getter(field:, arg_variables:)
890
+ usr_var = bt_get_variable(arg_variables)
891
+ pr "#{usr_var.name} = (#{usr_var.type})bt_field_blob_get_data_const(#{field});"
892
+ end
893
+ end
894
+
787
895
  class BTMemberClass
788
896
  include BTMatch
789
897
  include BTLocator
@@ -891,6 +999,7 @@ module Babeltrace2Gen
891
999
 
892
1000
  class BTFieldClass::Option::WithSelectorField::Bool < BTFieldClass::Option::WithSelectorField
893
1001
  extend BTFromH
1002
+
894
1003
  attr_reader :selector_is_reversed
895
1004
 
896
1005
  def initialize(parent:, field_class:, selector_field_path:, selector_is_reversed: nil)
@@ -901,6 +1010,7 @@ module Babeltrace2Gen
901
1010
 
902
1011
  class BTFieldClass::Option::WithSelectorField::IntegerUnsigned < BTFieldClass::Option::WithSelectorField
903
1012
  extend BTFromH
1013
+
904
1014
  attr_reader :selector_ranges
905
1015
 
906
1016
  def initialize(parent:, field_class:, selector_field_path:, selector_ranges:)
@@ -911,6 +1021,7 @@ module Babeltrace2Gen
911
1021
 
912
1022
  class BTFieldClass::Option::WithSelectorField::IntegerSigned < BTFieldClass::Option::WithSelectorField
913
1023
  extend BTFromH
1024
+
914
1025
  attr_reader :selector_ranges
915
1026
 
916
1027
  def initialize(parent:, field_class:, selector_field_path:, selector_ranges:)
@@ -921,6 +1032,7 @@ module Babeltrace2Gen
921
1032
 
922
1033
  class BTFieldClass::Variant < BTFieldClass
923
1034
  extend BTFromH
1035
+
924
1036
  attr_reader :options
925
1037
 
926
1038
  class Option
@@ -953,6 +1065,7 @@ module Babeltrace2Gen
953
1065
  @parent = parent
954
1066
  if selector_field_class
955
1067
  extend(WithSelectorField)
1068
+
956
1069
  @selector_field_class = selector_field_class
957
1070
  @options = options.collect do |o|
958
1071
  BTFieldClass::Variant::WithSelectorField::Option.new(name: o[:name], field_class: o[:field_class],
@@ -960,6 +1073,7 @@ module Babeltrace2Gen
960
1073
  end
961
1074
  else
962
1075
  extend(WithoutSelectorField)
1076
+
963
1077
  @options = options.collect do |o|
964
1078
  BTFieldClass::Variant::Option.new(name: o[:name], field_class: o[:field_class])
965
1079
  end
@@ -972,6 +1086,7 @@ module Babeltrace2Gen
972
1086
  include BTLocator
973
1087
  include BTMatchMembers
974
1088
  extend BTFromH
1089
+
975
1090
  attr_reader :parent, :entries
976
1091
 
977
1092
  BT_MATCH_ATTRS = [:entries]
@@ -993,6 +1108,7 @@ module Babeltrace2Gen
993
1108
  class BTEntryClass
994
1109
  include BTPrinter
995
1110
  include BTMatch
1111
+
996
1112
  using HashRefinements
997
1113
 
998
1114
  BT_MATCH_ATTRS = %i[name type]
@@ -1012,6 +1128,7 @@ module Babeltrace2Gen
1012
1128
  raise "No type in #{model}" unless type || is_match_model
1013
1129
 
1014
1130
  h = { 'string' => BTEntryClass::String,
1131
+ 'integer_unsigned' => BTEntryClass::IntegerUnsigned,
1015
1132
  'integer_signed' => BTEntryClass::IntegerSigned }.freeze
1016
1133
 
1017
1134
  raise "Type #{type} not supported" unless h.include?(type) || is_match_model
@@ -1055,4 +1172,12 @@ module Babeltrace2Gen
1055
1172
  # Sadly it's ` bt_trace_set_environment_entry_integer() ` and not ` bt_trace_set_environment_entry_integer_signed()`
1056
1173
  @bt_type_set = 'integer'
1057
1174
  end
1175
+
1176
+ class BTEntryClass::IntegerUnsigned < BTEntryClass
1177
+ extend BTFromH
1178
+
1179
+ @bt_type = 'uint64_t'
1180
+ # Sadly it's ` bt_trace_set_environment_entry_integer() ` and not ` bt_trace_set_environment_entry_integer_unsigned()`
1181
+ @bt_type_set = 'integer'
1182
+ end
1058
1183
  end
@@ -11,7 +11,8 @@ module Babeltrace2Gen
11
11
  h = { 'map' => BTValueCLass::Map,
12
12
  'string' => BTValueCLass::String,
13
13
  'bool' => BTValueCLass::Bool,
14
- 'integer_unsigned' => BTValueCLass::IntegerUnsigned }.freeze
14
+ 'integer_unsigned' => BTValueCLass::IntegerUnsigned,
15
+ 'integer_signed' => BTValueCLass::IntegerSigned }.freeze
15
16
  raise "Type #{key} not supported" unless h.include?(key)
16
17
 
17
18
  cast_type = model.delete(:cast_type)
@@ -45,7 +46,7 @@ module Babeltrace2Gen
45
46
  default_value = @usr_default_value || bt_default_value
46
47
 
47
48
  pr "if (#{val} != NULL) {"
48
- pr " if (!#{bt_type_is}(#{val})) {"
49
+ pr " if (#{bt_type_is}(#{val}) != BT_TRUE) {"
49
50
  pr " fprintf(stderr,\"Bad value for command line argument '%s' the value must be '%s'. \\n\",\"#{@name}\",\"#{bt_type}\");"
50
51
  pr ' exit(1);'
51
52
  pr ' }'
@@ -96,7 +97,7 @@ module Babeltrace2Gen
96
97
  raise "Bad default_value for '#{name}' in params.yaml, it must be #{bt_type} (BT_TRUE or BT_FALSE) but provided '#{usr_default_value}'."
97
98
  end
98
99
 
99
- super(name, usr_default_value)
100
+ super
100
101
  end
101
102
  end
102
103
 
@@ -119,17 +120,35 @@ module Babeltrace2Gen
119
120
 
120
121
  class BTValueCLass::IntegerUnsigned < BTValueCLass::Scalar
121
122
  @bt_type = 'integer_unsigned'
122
- @bt_type_is = 'bt_value_is_signed_integer'
123
+ @bt_type_is = 'bt_value_is_unsigned_integer'
123
124
  @bt_return_type = 'uint64_t'
125
+ @bt_default_value = '+0'
126
+
127
+ def initialize(name, usr_default_value)
128
+ bt_type = self.class.instance_variable_get(:@bt_type)
129
+ if !usr_default_value.nil? && (!usr_default_value.is_a?(Integer) || !usr_default_value.between?(0,
130
+ (2**64) - 1))
131
+ raise "Bad default_value for '#{name}' in params.yaml, it must be #{bt_type} and must be in [0, 2**64 - 1], but provided '#{usr_default_value}'."
132
+ end
133
+
134
+ super
135
+ end
136
+ end
137
+
138
+ class BTValueCLass::IntegerSigned < BTValueCLass::Scalar
139
+ @bt_type = 'integer_signed'
140
+ @bt_type_is = 'bt_value_is_signed_integer'
141
+ @bt_return_type = 'int64_t'
124
142
  @bt_default_value = '0'
125
143
 
126
144
  def initialize(name, usr_default_value)
127
145
  bt_type = self.class.instance_variable_get(:@bt_type)
128
- if !usr_default_value.nil? && (!usr_default_value.is_a?(Integer) || !usr_default_value.between?(0, (2**64) - 1))
129
- raise "Bad default_value for '#{name}' in params.yaml, it must be #{bt_type} and must be in [0,2^64-1], but provided '#{usr_default_value}'."
146
+ if !usr_default_value.nil? && (!usr_default_value.is_a?(Integer) || !usr_default_value.between?(-2**63,
147
+ (2**63) - 1))
148
+ raise "Bad default_value for '#{name}' in params.yaml, it must be #{bt_type} and must be in [-2**63, 2**63 - 1], but provided '#{usr_default_value}'."
130
149
  end
131
150
 
132
- super(name, usr_default_value)
151
+ super
133
152
  end
134
153
  end
135
154
  end
@@ -1,3 +1,3 @@
1
1
  module Metababel
2
- VERSION = '1.1.3'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -523,6 +523,20 @@ static void filter_message_iterator_finalize(
523
523
  free(message_iterator_private_data);
524
524
  }
525
525
 
526
+ /* Advertise support for MIP version 1, required for CTF2 features such as
527
+ * BLOB fields. Without this method a component defaults to MIP 0 only. */
528
+ static bt_component_class_get_supported_mip_versions_method_status
529
+ filter_get_supported_mip_versions(
530
+ bt_self_component_class_filter *self_component_class,
531
+ const bt_value *params, void *initialize_method_data,
532
+ bt_logging_level logging_level,
533
+ bt_integer_range_set_unsigned *supported_versions) {
534
+ if (bt_integer_range_set_unsigned_add_range(supported_versions, 1, 1) !=
535
+ BT_INTEGER_RANGE_SET_ADD_RANGE_STATUS_OK)
536
+ return BT_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_STATUS_MEMORY_ERROR;
537
+ return BT_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_STATUS_OK;
538
+ }
539
+
526
540
  /* Mandatory */
527
541
  BT_PLUGIN_MODULE();
528
542
 
@@ -530,6 +544,8 @@ BT_PLUGIN(<%= options[:'plugin-name'] %>);
530
544
  BT_PLUGIN_FILTER_COMPONENT_CLASS(<%= options[:'component-name'] %>,
531
545
  filter_message_iterator_next);
532
546
 
547
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD(
548
+ <%= options[:'component-name'] %>, filter_get_supported_mip_versions);
533
549
  BT_PLUGIN_FILTER_COMPONENT_CLASS_INITIALIZE_METHOD(
534
550
  <%= options[:'component-name'] %>, filter_initialize);
535
551
  BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD(
data/template/sink.c.erb CHANGED
@@ -160,12 +160,28 @@ sink_graph_is_configured(bt_self_component_sink *self_component_sink) {
160
160
  return BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK;
161
161
  }
162
162
 
163
+ /* Advertise support for MIP version 1, required for CTF2 features such as
164
+ * BLOB fields. Without this method a component defaults to MIP 0 only. */
165
+ static bt_component_class_get_supported_mip_versions_method_status
166
+ sink_get_supported_mip_versions(
167
+ bt_self_component_class_sink *self_component_class,
168
+ const bt_value *params, void *initialize_method_data,
169
+ bt_logging_level logging_level,
170
+ bt_integer_range_set_unsigned *supported_versions) {
171
+ if (bt_integer_range_set_unsigned_add_range(supported_versions, 1, 1) !=
172
+ BT_INTEGER_RANGE_SET_ADD_RANGE_STATUS_OK)
173
+ return BT_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_STATUS_MEMORY_ERROR;
174
+ return BT_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_STATUS_OK;
175
+ }
176
+
163
177
  /* Mandatory */
164
178
  BT_PLUGIN_MODULE();
165
179
 
166
180
  BT_PLUGIN(<%= options[:'plugin-name'] %>);
167
181
  BT_PLUGIN_SINK_COMPONENT_CLASS(<%= options[:'component-name'] %>, sink_consume);
168
182
 
183
+ BT_PLUGIN_SINK_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD(
184
+ <%= options[:'component-name'] %>, sink_get_supported_mip_versions);
169
185
  BT_PLUGIN_SINK_COMPONENT_CLASS_INITIALIZE_METHOD(
170
186
  <%= options[:'component-name'] %>, sink_initialize);
171
187
  BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(
@@ -206,6 +206,20 @@ static void source_message_iterator_finalize(
206
206
  free(message_iterator_private_data);
207
207
  }
208
208
 
209
+ /* Advertise support for MIP version 1, required for CTF2 features such as
210
+ * BLOB fields. Without this method a component defaults to MIP 0 only. */
211
+ static bt_component_class_get_supported_mip_versions_method_status
212
+ source_get_supported_mip_versions(
213
+ bt_self_component_class_source *self_component_class,
214
+ const bt_value *params, void *initialize_method_data,
215
+ bt_logging_level logging_level,
216
+ bt_integer_range_set_unsigned *supported_versions) {
217
+ if (bt_integer_range_set_unsigned_add_range(supported_versions, 1, 1) !=
218
+ BT_INTEGER_RANGE_SET_ADD_RANGE_STATUS_OK)
219
+ return BT_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_STATUS_MEMORY_ERROR;
220
+ return BT_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_STATUS_OK;
221
+ }
222
+
209
223
  /* Mandatory */
210
224
  BT_PLUGIN_MODULE();
211
225
 
@@ -213,6 +227,8 @@ BT_PLUGIN(<%= options[:'plugin-name'] %>);
213
227
  BT_PLUGIN_SOURCE_COMPONENT_CLASS(<%= options[:'component-name'] %>,
214
228
  source_message_iterator_next);
215
229
 
230
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD(
231
+ <%= options[:'component-name'] %>, source_get_supported_mip_versions);
216
232
  BT_PLUGIN_SOURCE_COMPONENT_CLASS_INITIALIZE_METHOD(
217
233
  <%= options[:'component-name'] %>, source_initialize);
218
234
  BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD(
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.1.3
4
+ version: 2.0.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: 2025-08-28 00:00:00.000000000 Z
13
+ date: 2026-09-21 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description:
16
16
  email:
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  requirements: []
63
- rubygems_version: 3.3.3
63
+ rubygems_version: 3.5.16
64
64
  signing_key:
65
65
  specification_version: 4
66
66
  summary: Helper for creation Babeltrace plugins