babeltrace2 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.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/babeltrace2.gemspec +13 -0
  4. data/lib/babeltrace2.rb +49 -0
  5. data/lib/babeltrace2/error-reporting.rb +432 -0
  6. data/lib/babeltrace2/func-status.rb +26 -0
  7. data/lib/babeltrace2/graph/component-class-dev.rb +801 -0
  8. data/lib/babeltrace2/graph/component-class.rb +134 -0
  9. data/lib/babeltrace2/graph/component-descriptor-set.rb +78 -0
  10. data/lib/babeltrace2/graph/component.rb +362 -0
  11. data/lib/babeltrace2/graph/connection.rb +35 -0
  12. data/lib/babeltrace2/graph/graph.rb +523 -0
  13. data/lib/babeltrace2/graph/interrupter.rb +57 -0
  14. data/lib/babeltrace2/graph/message-iterator-class.rb +374 -0
  15. data/lib/babeltrace2/graph/message-iterator.rb +253 -0
  16. data/lib/babeltrace2/graph/message.rb +721 -0
  17. data/lib/babeltrace2/graph/port.rb +124 -0
  18. data/lib/babeltrace2/graph/private-query-executor.rb +4 -0
  19. data/lib/babeltrace2/graph/query-executor.rb +142 -0
  20. data/lib/babeltrace2/graph/self-component-class.rb +37 -0
  21. data/lib/babeltrace2/graph/self-component-port.rb +35 -0
  22. data/lib/babeltrace2/graph/self-component.rb +264 -0
  23. data/lib/babeltrace2/graph/self-message-iterator.rb +147 -0
  24. data/lib/babeltrace2/integer-range-set.rb +275 -0
  25. data/lib/babeltrace2/logging-defs.rb +19 -0
  26. data/lib/babeltrace2/logging.rb +77 -0
  27. data/lib/babeltrace2/plugin/plugin-dev.rb +335 -0
  28. data/lib/babeltrace2/plugin/plugin-loading.rb +459 -0
  29. data/lib/babeltrace2/trace-ir/clock-class.rb +258 -0
  30. data/lib/babeltrace2/trace-ir/clock-snapshot.rb +45 -0
  31. data/lib/babeltrace2/trace-ir/event-class.rb +292 -0
  32. data/lib/babeltrace2/trace-ir/event.rb +91 -0
  33. data/lib/babeltrace2/trace-ir/field-class.rb +1416 -0
  34. data/lib/babeltrace2/trace-ir/field-path.rb +123 -0
  35. data/lib/babeltrace2/trace-ir/field.rb +871 -0
  36. data/lib/babeltrace2/trace-ir/packet.rb +57 -0
  37. data/lib/babeltrace2/trace-ir/stream-class.rb +425 -0
  38. data/lib/babeltrace2/trace-ir/stream.rb +137 -0
  39. data/lib/babeltrace2/trace-ir/trace-class.rb +343 -0
  40. data/lib/babeltrace2/trace-ir/trace.rb +321 -0
  41. data/lib/babeltrace2/types.rb +667 -0
  42. data/lib/babeltrace2/util.rb +23 -0
  43. data/lib/babeltrace2/value.rb +869 -0
  44. data/lib/babeltrace2/version.rb +126 -0
  45. metadata +105 -0
@@ -0,0 +1,91 @@
1
+ module Babeltrace2
2
+ attach_function :bt_event_borrow_class,
3
+ [ :bt_event_handle ],
4
+ :bt_event_class_handle
5
+
6
+ attach_function :bt_event_borrow_class_const,
7
+ [ :bt_event_handle ],
8
+ :bt_event_class_handle
9
+
10
+ attach_function :bt_event_borrow_stream,
11
+ [ :bt_event_handle ],
12
+ :bt_stream_handle
13
+
14
+ attach_function :bt_event_borrow_stream_const,
15
+ [ :bt_event_handle ],
16
+ :bt_stream_handle
17
+
18
+ attach_function :bt_event_borrow_packet,
19
+ [ :bt_event_handle ],
20
+ :bt_packet_handle
21
+
22
+ attach_function :bt_event_borrow_packet_const,
23
+ [ :bt_event_handle ],
24
+ :bt_packet_handle
25
+
26
+ attach_function :bt_event_borrow_payload_field,
27
+ [ :bt_event_handle ],
28
+ :bt_field_handle
29
+
30
+ attach_function :bt_event_borrow_payload_field_const,
31
+ [ :bt_event_handle ],
32
+ :bt_field_handle
33
+
34
+ attach_function :bt_event_borrow_specific_context_field,
35
+ [ :bt_event_handle ],
36
+ :bt_field_handle
37
+
38
+ attach_function :bt_event_borrow_specific_context_field_const,
39
+ [ :bt_event_handle ],
40
+ :bt_field_handle
41
+
42
+ attach_function :bt_event_borrow_common_context_field,
43
+ [ :bt_event_handle ],
44
+ :bt_field_handle
45
+
46
+ attach_function :bt_event_borrow_common_context_field_const,
47
+ [ :bt_event_handle ],
48
+ :bt_field_handle
49
+
50
+ class BTEvent < BTObject
51
+ def get_class
52
+ handle = Babeltrace2.bt_event_borrow_class(@handle)
53
+ BTEventClass.new(handle, retain: true)
54
+ end
55
+
56
+ def get_stream
57
+ handle = Babeltrace2.bt_event_borrow_stream(@handle)
58
+ BTStream.new(handle, retain: true)
59
+ end
60
+ alias stream get_stream
61
+
62
+ def get_packet
63
+ return nil unless stream.get_class.supports_packets?
64
+ handle = Babeltrace2.bt_event_borrow_packet(@handle)
65
+ BTPacket.new(handle, retain: true)
66
+ end
67
+ alias packet get_packet
68
+
69
+ def get_payload_field
70
+ handle = Babeltrace2.bt_event_borrow_payload_field(@handle)
71
+ return nil if handle.null?
72
+ BTField.from_handle(handle)
73
+ end
74
+ alias payload_field get_payload_field
75
+
76
+ def get_specific_context_field
77
+ handle = Babeltrace2.bt_event_borrow_specific_context_field(@handle)
78
+ return nil if handle.null?
79
+ BTField.from_handle(handle)
80
+ end
81
+ alias specific_context_field get_specific_context_field
82
+
83
+ def get_common_context_field
84
+ handle = Babeltrace2.bt_event_borrow_common_context_field(@handle)
85
+ return nil if handle.null?
86
+ BTField.from_handle(handle)
87
+ end
88
+ alias common_context_field get_common_context_field
89
+ end
90
+
91
+ end
@@ -0,0 +1,1416 @@
1
+ module Babeltrace2
2
+
3
+ BT_FIELD_CLASS_TYPE_BOOL = 1 << 0
4
+ BT_FIELD_CLASS_TYPE_BIT_ARRAY = 1 << 1
5
+ BT_FIELD_CLASS_TYPE_INTEGER = 1 << 2
6
+ BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER = 1 << 3 | BT_FIELD_CLASS_TYPE_INTEGER
7
+ BT_FIELD_CLASS_TYPE_SIGNED_INTEGER = 1 << 4 | BT_FIELD_CLASS_TYPE_INTEGER
8
+ BT_FIELD_CLASS_TYPE_ENUMERATION = 1 << 5
9
+ BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION =
10
+ BT_FIELD_CLASS_TYPE_ENUMERATION | BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER
11
+ BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION =
12
+ BT_FIELD_CLASS_TYPE_ENUMERATION | BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
13
+ BT_FIELD_CLASS_TYPE_REAL = 1 << 6
14
+ BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL = 1 << 7 | BT_FIELD_CLASS_TYPE_REAL
15
+ BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL = 1 << 8 | BT_FIELD_CLASS_TYPE_REAL
16
+ BT_FIELD_CLASS_TYPE_STRING = 1 << 9
17
+ BT_FIELD_CLASS_TYPE_STRUCTURE = 1 << 10
18
+ BT_FIELD_CLASS_TYPE_ARRAY = 1 << 11
19
+ BT_FIELD_CLASS_TYPE_STATIC_ARRAY = 1 << 12 | BT_FIELD_CLASS_TYPE_ARRAY
20
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY = 1 << 13 | BT_FIELD_CLASS_TYPE_ARRAY
21
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD =
22
+ 1 << 14 | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY
23
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD =
24
+ 1 << 15 | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY
25
+ BT_FIELD_CLASS_TYPE_OPTION = 1 << 16
26
+ BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD =
27
+ 1 << 17 | BT_FIELD_CLASS_TYPE_OPTION
28
+ BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD =
29
+ 1 << 18 | BT_FIELD_CLASS_TYPE_OPTION
30
+ BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD =
31
+ 1 << 19 | BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD
32
+ BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD =
33
+ 1 << 20 | BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD
34
+ BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD =
35
+ 1 << 21 | BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD
36
+ BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD =
37
+ 1 << 22 | BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD
38
+ BT_FIELD_CLASS_TYPE_VARIANT = 1 << 23
39
+ BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD =
40
+ 1 << 24 | BT_FIELD_CLASS_TYPE_VARIANT
41
+ BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD =
42
+ 1 << 25 | BT_FIELD_CLASS_TYPE_VARIANT
43
+ BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD =
44
+ 1 << 26 | BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD
45
+ BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD =
46
+ 1 << 27 | BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD
47
+ BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD =
48
+ 1 << 28 | BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD
49
+ BTFieldClassType = enum FFI::Type::INT64, :bt_field_class_type,
50
+ [ :BT_FIELD_CLASS_TYPE_BOOL,
51
+ BT_FIELD_CLASS_TYPE_BOOL,
52
+ :BT_FIELD_CLASS_TYPE_BIT_ARRAY,
53
+ BT_FIELD_CLASS_TYPE_BIT_ARRAY,
54
+ :BT_FIELD_CLASS_TYPE_INTEGER,
55
+ BT_FIELD_CLASS_TYPE_INTEGER,
56
+ :BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER,
57
+ BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER,
58
+ :BT_FIELD_CLASS_TYPE_SIGNED_INTEGER,
59
+ BT_FIELD_CLASS_TYPE_SIGNED_INTEGER,
60
+ :BT_FIELD_CLASS_TYPE_ENUMERATION,
61
+ BT_FIELD_CLASS_TYPE_ENUMERATION,
62
+ :BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION,
63
+ BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION,
64
+ :BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
65
+ BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
66
+ :BT_FIELD_CLASS_TYPE_REAL,
67
+ BT_FIELD_CLASS_TYPE_REAL,
68
+ :BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL,
69
+ BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL,
70
+ :BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL,
71
+ BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL,
72
+ :BT_FIELD_CLASS_TYPE_STRING,
73
+ BT_FIELD_CLASS_TYPE_STRING,
74
+ :BT_FIELD_CLASS_TYPE_STRUCTURE,
75
+ BT_FIELD_CLASS_TYPE_STRUCTURE,
76
+ :BT_FIELD_CLASS_TYPE_ARRAY,
77
+ BT_FIELD_CLASS_TYPE_ARRAY,
78
+ :BT_FIELD_CLASS_TYPE_STATIC_ARRAY,
79
+ BT_FIELD_CLASS_TYPE_STATIC_ARRAY,
80
+ :BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
81
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
82
+ :BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD,
83
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD,
84
+ :BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD,
85
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD,
86
+ :BT_FIELD_CLASS_TYPE_OPTION,
87
+ BT_FIELD_CLASS_TYPE_OPTION,
88
+ :BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD,
89
+ BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD,
90
+ :BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD,
91
+ BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD,
92
+ :BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD,
93
+ BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD,
94
+ :BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD,
95
+ BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD,
96
+ :BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
97
+ BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
98
+ :BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
99
+ BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
100
+ :BT_FIELD_CLASS_TYPE_VARIANT,
101
+ BT_FIELD_CLASS_TYPE_VARIANT,
102
+ :BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD,
103
+ BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD,
104
+ :BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD,
105
+ BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD,
106
+ :BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD,
107
+ BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD,
108
+ :BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
109
+ BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
110
+ :BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
111
+ BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD ]
112
+
113
+ attach_function :bt_field_class_get_type,
114
+ [ :bt_field_class_handle ],
115
+ :bt_field_class_type
116
+
117
+ attach_function :bt_field_class_set_user_attributes,
118
+ [ :bt_field_class_handle, :bt_value_map_handle ],
119
+ :void
120
+
121
+ attach_function :bt_field_class_borrow_user_attributes,
122
+ [ :bt_field_class_handle ],
123
+ :bt_value_map_handle
124
+
125
+ attach_function :bt_field_class_borrow_user_attributes_const,
126
+ [ :bt_field_class_handle ],
127
+ :bt_value_map_handle
128
+
129
+ attach_function :bt_field_class_get_ref,
130
+ [ :bt_field_class_handle ],
131
+ :void
132
+
133
+ attach_function :bt_field_class_put_ref,
134
+ [ :bt_field_class_handle ],
135
+ :void
136
+
137
+ class BTFieldClass < BTSharedObject
138
+ @get_ref = :bt_field_class_get_ref
139
+ @put_ref = :bt_field_class_put_ref
140
+
141
+ TYPE_MAP = {}
142
+
143
+ def self.from_handle(handle, retain: true, auto_release: true)
144
+ clss = TYPE_MAP[Babeltrace2.bt_field_class_get_type(handle)]
145
+ raise "unsupported field class type" unless clss
146
+ handle = clss[0].new(handle)
147
+ clss[1].new(handle, retain: retain, auto_release: auto_release)
148
+ end
149
+
150
+ def get_type
151
+ Babeltrace2.bt_field_class_get_type(@handle)
152
+ end
153
+ alias type get_type
154
+
155
+ def type_is(other_type)
156
+ (type & other_type) == other_type
157
+ end
158
+ alias type_is? type_is
159
+ alias type? type_is
160
+
161
+ def set_user_attributes(user_attributes)
162
+ Babeltrace2.bt_field_class_set_user_attributes(@handle, BTValue.from_value(user_attributes))
163
+ self
164
+ end
165
+
166
+ def user_attributes=(user_attributes)
167
+ set_user_attributes(user_attributes)
168
+ user_attributes
169
+ end
170
+
171
+ def get_user_attributes
172
+ BTValueMap.new(Babeltrace2.bt_field_class_borrow_user_attributes(@handle), retain: true)
173
+ end
174
+ alias user_attributes get_user_attributes
175
+ end
176
+
177
+ attach_function :bt_field_class_bool_create,
178
+ [ :bt_trace_class_handle ],
179
+ :bt_field_class_bool_handle
180
+
181
+ class BTFieldClass::Bool < BTFieldClass
182
+ def initialize(handle = nil, retain: true, auto_release: true,
183
+ trace_class: nil)
184
+ if handle
185
+ super(handle, retain: retain, auto_release: auto_release)
186
+ else
187
+ handle = Babeltrace2.bt_field_class_bool_create(trace_class)
188
+ raise Babeltrace2.process_error if handle.null?
189
+ super(handle, retain: false)
190
+ end
191
+ end
192
+ end
193
+ BTFieldClassBool = BTFieldClass::Bool
194
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_BOOL] = [
195
+ BTFieldClassBoolHandle,
196
+ BTFieldClassBool ]
197
+
198
+ attach_function :bt_field_class_bit_array_create,
199
+ [ :bt_trace_class_handle, :uint64 ],
200
+ :bt_field_class_bit_array_handle
201
+
202
+ attach_function :bt_field_class_bit_array_get_length,
203
+ [ :bt_field_class_bit_array_handle ],
204
+ :uint64
205
+
206
+ class BTFieldClass::BitArray < BTFieldClass
207
+ def initialize(handle = nil, retain: true, auto_release: true,
208
+ trace_class: nil, length: nil)
209
+ if handle
210
+ super(handle, retain: retain, auto_release: auto_release)
211
+ else
212
+ handle = Babeltrace2.bt_field_class_bit_array_create(trace_class, length)
213
+ raise Babeltrace2.process_error if handle.null?
214
+ super(handle, retain: false)
215
+ end
216
+ end
217
+
218
+ def get_length
219
+ Babeltrace2.bt_field_class_bit_array_get_length(@handle)
220
+ end
221
+ alias length get_length
222
+ end
223
+ BTFieldClassBitArray = BTFieldClass::BitArray
224
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_BIT_ARRAY] = [
225
+ BTFieldClassBitArrayHandle,
226
+ BTFieldClassBitArray ]
227
+
228
+ attach_function :bt_field_class_integer_set_field_value_range,
229
+ [ :bt_field_class_integer_handle, :uint64 ],
230
+ :void
231
+
232
+ attach_function :bt_field_class_integer_get_field_value_range,
233
+ [ :bt_field_class_integer_handle ],
234
+ :uint64
235
+
236
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY = 2
237
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL = 8
238
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL = 10
239
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL = 16
240
+ BTFieldClassIntegerPreferredDisplayBase =
241
+ enum :bt_field_class_integer_preferred_display_base,
242
+ [ :BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY,
243
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY,
244
+ :BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL,
245
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL,
246
+ :BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
247
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
248
+ :BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL,
249
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL ]
250
+
251
+ attach_function :bt_field_class_integer_set_preferred_display_base,
252
+ [ :bt_field_class_integer_handle,
253
+ :bt_field_class_integer_preferred_display_base ],
254
+ :void
255
+
256
+ attach_function :bt_field_class_integer_get_preferred_display_base,
257
+ [ :bt_field_class_integer_handle ],
258
+ :bt_field_class_integer_preferred_display_base
259
+
260
+ class BTFieldClass::Integer < BTFieldClass
261
+
262
+ def set_field_value_range(n)
263
+ raise "invalid range" if n < 0 || n > 63
264
+ Babeltrace2.bt_field_class_integer_set_field_value_range(@handle, n)
265
+ self
266
+ end
267
+
268
+ def field_value_range=(n)
269
+ set_field_value_range(n)
270
+ n
271
+ end
272
+
273
+ def get_field_value_range
274
+ Babeltrace2.bt_field_class_integer_get_field_value_range(@handle)
275
+ end
276
+ alias field_value_range get_field_value_range
277
+
278
+ def set_preferred_display_base(preferred_display_base)
279
+ Babeltrace2.bt_field_class_integer_set_preferred_display_base(
280
+ @handle, preferred_display_base)
281
+ self
282
+ end
283
+
284
+ def preferred_display_base=(preferred_display_base)
285
+ set_preferred_display_base(preferred_display_base)
286
+ preferred_display_base
287
+ end
288
+
289
+ def get_preferred_display_base
290
+ Babeltrace2.bt_field_class_integer_get_preferred_display_base(@handle)
291
+ end
292
+ alias preferred_display_base get_preferred_display_base
293
+
294
+ def preferred_display_base_integer
295
+ case preferred_display_base
296
+ when :BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY
297
+ 2
298
+ when :BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL
299
+ 8
300
+ when :BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL
301
+ 10
302
+ when :BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL
303
+ 16
304
+ else
305
+ preferred_display_base
306
+ end
307
+ end
308
+ end
309
+ BTFieldClassInteger = BTFieldClass::Integer
310
+
311
+ attach_function :bt_field_class_integer_unsigned_create,
312
+ [ :bt_trace_class_handle ],
313
+ :bt_field_class_integer_unsigned_handle
314
+
315
+ class BTFieldClass::Integer::Unsigned < BTFieldClassInteger
316
+ def initialize(handle = nil, retain: true, auto_release: true,
317
+ trace_class: nil)
318
+ if handle
319
+ super(handle, retain: retain, auto_release: auto_release)
320
+ else
321
+ handle = Babeltrace2.bt_field_class_integer_unsigned_create(trace_class)
322
+ raise Babeltrace2.process_error if handle.null?
323
+ super(handle, retain: false)
324
+ end
325
+ end
326
+ end
327
+ BTFieldClass::IntegerUnsigned = BTFieldClass::Integer::Unsigned
328
+ BTFieldClassIntegerUnsigned = BTFieldClass::Integer::Unsigned
329
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER] = [
330
+ BTFieldClassIntegerUnsignedHandle,
331
+ BTFieldClassIntegerUnsigned ]
332
+
333
+ attach_function :bt_field_class_integer_signed_create,
334
+ [ :bt_trace_class_handle ],
335
+ :bt_field_class_integer_signed_handle
336
+
337
+ class BTFieldClass::Integer::Signed < BTFieldClassInteger
338
+ def initialize(handle = nil, retain: true, auto_release: true,
339
+ trace_class: nil)
340
+ if handle
341
+ super(handle, retain: retain, auto_release: auto_release)
342
+ else
343
+ handle = Babeltrace2.bt_field_class_integer_signed_create(trace_class)
344
+ raise Babeltrace2.process_error if handle.null?
345
+ super(handle, retain: false)
346
+ end
347
+ end
348
+ end
349
+ BTFieldClass::IntegerSigned = BTFieldClass::Integer::Signed
350
+ BTFieldClassIntegerSigned = BTFieldClass::Integer::Signed
351
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_SIGNED_INTEGER] = [
352
+ BTFieldClassIntegerSignedHandle,
353
+ BTFieldClassIntegerSigned ]
354
+
355
+ class BTFieldClass::Real < BTFieldClass
356
+ end
357
+ BTFieldClassReal = BTFieldClass::Real
358
+
359
+ attach_function :bt_field_class_real_single_precision_create,
360
+ [ :bt_trace_class_handle ],
361
+ :bt_field_class_real_single_precision_handle
362
+
363
+ class BTFieldClass::Real::SinglePrecision < BTFieldClassReal
364
+ def initialize(handle = nil, retain: true, auto_release: true,
365
+ trace_class: nil)
366
+ if handle
367
+ super(handle, retain: retain, auto_release: auto_release)
368
+ else
369
+ handle = Babeltrace2.bt_field_class_real_single_precision_create(trace_class)
370
+ raise Babeltrace2.process_error if handle.null?
371
+ super(handle, retain: false)
372
+ end
373
+ end
374
+ end
375
+ BTFieldClass::RealSinglePrecision = BTFieldClass::Real::SinglePrecision
376
+ BTFieldClassRealSinglePrecision = BTFieldClass::Real::SinglePrecision
377
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL] = [
378
+ BTFieldClassRealSinglePrecisionHandle,
379
+ BTFieldClassRealSinglePrecision ]
380
+
381
+ attach_function :bt_field_class_real_double_precision_create,
382
+ [ :bt_trace_class_handle ],
383
+ :bt_field_class_real_double_precision_handle
384
+
385
+ class BTFieldClass::Real::DoublePrecision < BTFieldClassReal
386
+ def initialize(handle = nil, retain: true, auto_release: true,
387
+ trace_class: nil)
388
+ if handle
389
+ super(handle, retain: retain, auto_release: auto_release)
390
+ else
391
+ handle = Babeltrace2.bt_field_class_real_double_precision_create(trace_class)
392
+ raise Babeltrace2.process_error if handle.null?
393
+ super(handle, retain: false)
394
+ end
395
+ end
396
+ end
397
+ BTFieldClass::RealDoublePrecision = BTFieldClass::Real::DoublePrecision
398
+ BTFieldClassRealDoublePrecision = BTFieldClass::Real::DoublePrecision
399
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL] = [
400
+ BTFieldClassRealDoublePrecisionHandle,
401
+ BTFieldClassRealDoublePrecision ]
402
+
403
+ BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_OK = BT_FUNC_STATUS_OK
404
+ BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
405
+ BTFieldClassEnumerationGetMappingLabelsForValueStatus =
406
+ enum :bt_field_class_enumeration_get_mapping_labels_for_value_status,
407
+ [ :BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_OK,
408
+ BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_OK,
409
+ :BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_MEMORY_ERROR,
410
+ BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_MEMORY_ERROR ]
411
+
412
+ BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_OK = BT_FUNC_STATUS_OK
413
+ BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
414
+ BTFieldClassEnumerationAddMappingStatus =
415
+ enum :bt_field_class_enumeration_add_mapping_status,
416
+ [ :BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_OK,
417
+ BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_OK,
418
+ :BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_MEMORY_ERROR,
419
+ BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_MEMORY_ERROR ]
420
+
421
+ attach_function :bt_field_class_enumeration_get_mapping_count,
422
+ [ :bt_field_class_enumeration_handle ],
423
+ :uint64
424
+
425
+ attach_function :bt_field_class_enumeration_mapping_get_label,
426
+ [ :bt_field_class_enumeration_mapping_handle ],
427
+ :string
428
+
429
+ module BTFieldClass::Enumeration
430
+ GetMappingLabelsForValueStatus = BTFieldClassEnumerationGetMappingLabelsForValueStatus
431
+ AddMappingStatus = BTFieldClassEnumerationAddMappingStatus
432
+
433
+ def get_mapping_count
434
+ Babeltrace2.bt_field_class_enumeration_get_mapping_count(@handle)
435
+ end
436
+ alias mapping_count get_mapping_count
437
+ alias size get_mapping_count
438
+
439
+ def get_mapping(map)
440
+ case map
441
+ when Integer
442
+ get_mapping_by_index(map)
443
+ when String, Symbol
444
+ get_mapping_by_label(map)
445
+ else
446
+ raise "unsupported mapping query"
447
+ end
448
+ end
449
+ alias mapping get_mapping
450
+
451
+ class Mapping < BTObject
452
+ def get_label
453
+ label = Babeltrace2.bt_field_class_enumeration_mapping_get_label(@handle)
454
+ if label[0] == ':'
455
+ label[1..-1].to_sym
456
+ else
457
+ label
458
+ end
459
+ end
460
+ alias label get_label
461
+ end
462
+ end
463
+ BTFieldClassEnumeration = BTFieldClass::Enumeration
464
+ BTFieldClassEnumerationMapping = BTFieldClass::Enumeration::Mapping
465
+
466
+ attach_function :bt_field_class_enumeration_unsigned_create,
467
+ [ :bt_trace_class_handle ],
468
+ :bt_field_class_enumeration_unsigned_handle
469
+
470
+ attach_function :bt_field_class_enumeration_unsigned_add_mapping,
471
+ [ :bt_field_class_enumeration_unsigned_handle, :string,
472
+ :bt_integer_range_set_unsigned_handle ],
473
+ :bt_field_class_enumeration_add_mapping_status
474
+
475
+ attach_function :bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const,
476
+ [ :bt_field_class_enumeration_unsigned_handle, :uint64 ],
477
+ :bt_field_class_enumeration_unsigned_mapping_handle
478
+
479
+ attach_function :bt_field_class_enumeration_unsigned_borrow_mapping_by_label_const,
480
+ [ :bt_field_class_enumeration_unsigned_handle, :string ],
481
+ :bt_field_class_enumeration_unsigned_mapping_handle
482
+
483
+ attach_function :bt_field_class_enumeration_unsigned_get_mapping_labels_for_value,
484
+ [ :bt_field_class_enumeration_unsigned_handle,
485
+ :uint64, :pointer, :pointer ],
486
+ :bt_field_class_enumeration_get_mapping_labels_for_value_status
487
+
488
+ attach_function :bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const,
489
+ [ :bt_field_class_enumeration_unsigned_mapping_handle ],
490
+ :bt_integer_range_set_unsigned_handle
491
+
492
+ class BTFieldClass::Enumeration::Unsigned < BTFieldClass::Integer::Unsigned
493
+ include BTFieldClass::Enumeration
494
+ class Mapping < BTFieldClass::Enumeration::Mapping
495
+ def get_ranges
496
+ BTIntegerRangeSetUnsigned.new(
497
+ Babeltrace2.bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const(
498
+ @handle), retain: true)
499
+ end
500
+ alias ranges get_ranges
501
+ end
502
+
503
+ def initialize(handle = nil, retain: true, auto_release: true,
504
+ trace_class: nil)
505
+ if handle
506
+ super(handle, retain: retain, auto_release: auto_release)
507
+ else
508
+ handle = Babeltrace2.bt_field_class_enumeration_unsigned_create(trace_class)
509
+ raise Babeltrace2.process_error if handle.null?
510
+ super(handle, retain: false)
511
+ end
512
+ end
513
+
514
+ def add_mapping(label, ranges)
515
+ label = label.inspect if label.kind_of?(Symbol)
516
+ ranges = BTIntegerRangeSetUnsigned.from_value(ranges)
517
+ res = Babeltrace2.bt_field_class_enumeration_unsigned_add_mapping(
518
+ @handle, label, ranges)
519
+ raise Babeltrace2.process_error(res) if res != :BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_OK
520
+ self
521
+ end
522
+
523
+ def get_mapping_by_index(index)
524
+ count = get_mapping_count
525
+ index += count if index < 0
526
+ return nil if index >= count || index < 0
527
+ handle =
528
+ Babeltrace2.bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const(
529
+ @handle, index)
530
+ BTFieldClassEnumerationUnsignedMapping.new(handle)
531
+ end
532
+
533
+ def get_mapping_by_label(label)
534
+ label = label.inspect if label.kind_of?(Symbol)
535
+ handle =
536
+ Babeltrace2.bt_field_class_enumeration_unsigned_borrow_mapping_by_label_const(
537
+ @handle, label)
538
+ BTFieldClassEnumerationUnsignedMapping.new(handle)
539
+ end
540
+
541
+ def get_mapping_labels_for_value(value)
542
+ ptr1 = FFI::MemoryPointer.new(:pointer)
543
+ ptr2 = FFI::MemoryPointer.new(:uint64)
544
+ res = Babeltrace2.bt_field_class_enumeration_unsigned_get_mapping_labels_for_value(
545
+ @handle, value, ptr1, ptr2)
546
+ raise Babeltrace2.process_error(res) if res != :BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_OK
547
+ count = ptr2.read_uint64
548
+ return [] if count == 0
549
+ ptr1 = ptr1.read_pointer
550
+ ptr1.read_array_of_pointer(count).collect.collect { |v|
551
+ v = v.read_string
552
+ v[0] == ':' ? v[1..-1].to_sym : v
553
+ }
554
+ end
555
+ alias mapping_labels_for_value get_mapping_labels_for_value
556
+ end
557
+ BTFieldClassEnumerationUnsigned = BTFieldClass::Enumeration::Unsigned
558
+ BTFieldClassEnumerationUnsignedMapping = BTFieldClass::Enumeration::Unsigned::Mapping
559
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION] = [
560
+ BTFieldClassEnumerationUnsignedHandle,
561
+ BTFieldClassEnumerationUnsigned ]
562
+
563
+ attach_function :bt_field_class_enumeration_signed_create,
564
+ [ :bt_trace_class_handle ],
565
+ :bt_field_class_enumeration_signed_handle
566
+
567
+ attach_function :bt_field_class_enumeration_signed_add_mapping,
568
+ [ :bt_field_class_enumeration_signed_handle, :string,
569
+ :bt_integer_range_set_signed_handle ],
570
+ :bt_field_class_enumeration_add_mapping_status
571
+
572
+ attach_function :bt_field_class_enumeration_signed_borrow_mapping_by_index_const,
573
+ [ :bt_field_class_enumeration_signed_handle, :uint64 ],
574
+ :bt_field_class_enumeration_signed_mapping_handle
575
+
576
+ attach_function :bt_field_class_enumeration_signed_borrow_mapping_by_label_const,
577
+ [ :bt_field_class_enumeration_signed_handle, :string ],
578
+ :bt_field_class_enumeration_signed_mapping_handle
579
+
580
+ attach_function :bt_field_class_enumeration_signed_get_mapping_labels_for_value,
581
+ [ :bt_field_class_enumeration_signed_handle,
582
+ :uint64, :pointer, :pointer ],
583
+ :bt_field_class_enumeration_get_mapping_labels_for_value_status
584
+
585
+ attach_function :bt_field_class_enumeration_signed_mapping_borrow_ranges_const,
586
+ [ :bt_field_class_enumeration_signed_mapping_handle ],
587
+ :bt_integer_range_set_signed_handle
588
+
589
+ class BTFieldClass::Enumeration::Signed < BTFieldClass::Integer::Signed
590
+ include BTFieldClass::Enumeration
591
+ class Mapping < BTFieldClass::Enumeration::Mapping
592
+ def get_ranges
593
+ BTIntegerRangeSetSigned.new(
594
+ Babeltrace2.bt_field_class_enumeration_signed_mapping_borrow_ranges_const(
595
+ @handle), retain: true)
596
+ end
597
+ alias ranges get_ranges
598
+ end
599
+
600
+ def initialize(handle = nil, retain: true, auto_release: true,
601
+ trace_class: nil)
602
+ if handle
603
+ super(handle, retain: retain, auto_release: auto_release)
604
+ else
605
+ handle = Babeltrace2.bt_field_class_enumeration_signed_create(trace_class)
606
+ raise Babeltrace2.process_error if handle.null?
607
+ super(handle, retain: false)
608
+ end
609
+ end
610
+
611
+ def add_mapping(label, ranges)
612
+ label = label.inspect if label.kind_of?(Symbol)
613
+ ranges = BTIntegerRangeSetSigned.from_value(ranges)
614
+ res = Babeltrace2.bt_field_class_enumeration_signed_add_mapping(
615
+ @handle, label, ranges)
616
+ raise Babeltrace2.process_error(res) if res != :BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_OK
617
+ self
618
+ end
619
+
620
+ def get_mapping_by_index(index)
621
+ count = get_mapping_count
622
+ index += count if index < 0
623
+ return nil if index >= count || index < 0
624
+ handle =
625
+ Babeltrace2.bt_field_class_enumeration_signed_borrow_mapping_by_index_const(
626
+ @handle, index)
627
+ BTFieldClassEnumerationSignedMapping.new(handle)
628
+ end
629
+
630
+ def get_mapping_by_label(label)
631
+ label = label.inspect if label.kind_of?(Symbol)
632
+ handle =
633
+ Babeltrace2.bt_field_class_enumeration_signed_borrow_mapping_by_label_const(
634
+ @handle, label)
635
+ BTFieldClassEnumerationSignedMapping.new(handle)
636
+ end
637
+
638
+ def get_mapping_labels_for_value(value)
639
+ ptr1 = FFI::MemoryPointer.new(:pointer)
640
+ ptr2 = FFI::MemoryPointer.new(:uint64)
641
+ res = Babeltrace2.bt_field_class_enumeration_signed_get_mapping_labels_for_value(
642
+ @handle, value, ptr1, ptr2)
643
+ raise Babeltrace2.process_error(res) if res != :BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_OK
644
+ count = ptr2.read_uint64
645
+ return [] if count == 0
646
+ ptr1 = ptr1.read_pointer
647
+ ptr1.read_array_of_pointer(count).collect.collect { |v|
648
+ v = v.read_string
649
+ v[0] == ':' ? v[1..-1].to_sym : v
650
+ }
651
+ end
652
+ alias mapping_labels_for_value get_mapping_labels_for_value
653
+ end
654
+ BTFieldClassEnumerationSigned = BTFieldClass::Enumeration::Signed
655
+ BTFieldClassEnumerationSignedMapping = BTFieldClass::Enumeration::Signed::Mapping
656
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION] = [
657
+ BTFieldClassEnumerationSignedHandle,
658
+ BTFieldClassEnumerationSigned ]
659
+
660
+ attach_function :bt_field_class_string_create,
661
+ [ :bt_trace_class_handle ],
662
+ :bt_field_class_string_handle
663
+
664
+ class BTFieldClass::String < BTFieldClass
665
+ def initialize(handle = nil, retain: true, auto_release: true,
666
+ trace_class: nil)
667
+ if handle
668
+ super(handle, retain: retain, auto_release: auto_release)
669
+ else
670
+ handle = Babeltrace2.bt_field_class_string_create(trace_class)
671
+ raise Babeltrace2.process_error if handle.null?
672
+ super(handle, retain: false)
673
+ end
674
+ end
675
+ end
676
+ BTFieldClassString = BTFieldClass::String
677
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_STRING] = [
678
+ BTFieldClassStringHandle,
679
+ BTFieldClassString ]
680
+
681
+ attach_function :bt_field_class_array_borrow_element_field_class,
682
+ [ :bt_field_class_array_handle ],
683
+ :bt_field_class_handle
684
+
685
+ attach_function :bt_field_class_array_borrow_element_field_class_const,
686
+ [ :bt_field_class_array_handle ],
687
+ :bt_field_class_handle
688
+
689
+ class BTFieldClass::Array < BTFieldClass
690
+ def get_element_field_class
691
+ BTFieldClass.from_handle(
692
+ Babeltrace2.bt_field_class_array_borrow_element_field_class(@handle))
693
+ end
694
+ alias element_field_class get_element_field_class
695
+ end
696
+ BTFieldClassArray = BTFieldClass::Array
697
+
698
+ attach_function :bt_field_class_array_static_create,
699
+ [ :bt_trace_class_handle, :bt_field_class_handle, :uint64 ],
700
+ :bt_field_class_array_static_handle
701
+
702
+ attach_function :bt_field_class_array_static_get_length,
703
+ [ :bt_field_class_array_static_handle ],
704
+ :uint64
705
+
706
+ class BTFieldClass::Array::Static < BTFieldClass::Array
707
+ def initialize(handle = nil, retain: true, auto_release: true,
708
+ trace_class: nil, element_field_class: nil, length: nil)
709
+ if handle
710
+ super(handle, retain: retain, auto_release: auto_release)
711
+ else
712
+ handle = Babeltrace2.bt_field_class_array_static_create(
713
+ trace_class, element_field_class, length)
714
+ raise Babeltrace2.process_error if handle.null?
715
+ super(handle, retain: false)
716
+ end
717
+ end
718
+
719
+ def get_length
720
+ Babeltrace2.bt_field_class_array_static_get_length(@handle)
721
+ end
722
+ alias length get_length
723
+ alias size get_length
724
+ end
725
+ BTFieldClassArrayStatic = BTFieldClass::Array::Static
726
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_STATIC_ARRAY] = [
727
+ BTFieldClassArrayStaticHandle,
728
+ BTFieldClassArrayStatic ]
729
+
730
+ attach_function :bt_field_class_array_dynamic_create,
731
+ [ :bt_trace_class_handle, :bt_field_class_handle,
732
+ :bt_field_class_integer_unsigned_handle ],
733
+ :bt_field_class_array_dynamic_handle
734
+
735
+ attach_function :bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const,
736
+ [ :bt_field_class_array_dynamic_handle ],
737
+ :bt_field_path_handle
738
+
739
+ class BTFieldClass::Array::Dynamic < BTFieldClass::Array
740
+ module WithLengthField
741
+ def get_length_field_path
742
+ handle = Babeltrace2.bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(@handle)
743
+ return nil if handle.null?
744
+ BTFieldPath.new(handle, retain: true)
745
+ end
746
+ alias length_field_path get_length_field_path
747
+ end
748
+ def initialize(handle = nil, retain: true, auto_release: true,
749
+ trace_class: nil, element_field_class: nil, length_field_class: nil)
750
+ if handle
751
+ self.extend(WithLengthField) if Babeltrace2.bt_field_class_get_type(handle) ==
752
+ :BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD
753
+ super(handle, retain: retain, auto_release: auto_release)
754
+ else
755
+ handle = Babeltrace2.bt_field_class_array_dynamic_create(
756
+ trace_class, element_field_class, length_field_class)
757
+ raise Babeltrace2.process_error if handle.null?
758
+ self.extend(WithLengthField) if length_field_class
759
+ super(handle, retain: false)
760
+ end
761
+ end
762
+ end
763
+ BTFieldClassArrayDynamic = BTFieldClass::Array::Dynamic
764
+ BTFieldClassArrayDynamicWithLengthField = BTFieldClass::Array::Dynamic::WithLengthField
765
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD] = [
766
+ BTFieldClassArrayDynamicHandle,
767
+ BTFieldClassArrayDynamic ]
768
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD] = [
769
+ BTFieldClassArrayDynamicHandle,
770
+ BTFieldClassArrayDynamic ]
771
+
772
+ attach_function :bt_field_class_structure_create,
773
+ [ :bt_trace_class_handle ],
774
+ :bt_field_class_structure_handle
775
+
776
+ BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK = BT_FUNC_STATUS_OK
777
+ BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
778
+ BTFieldClassStructureAppendMemberStatus =
779
+ enum :bt_field_class_structure_append_member_status,
780
+ [ :BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK,
781
+ BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK,
782
+ :BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_MEMORY_ERROR,
783
+ BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_MEMORY_ERROR ]
784
+
785
+ attach_function :bt_field_class_structure_append_member,
786
+ [ :bt_field_class_structure_handle, :string, :bt_field_class_handle ],
787
+ :bt_field_class_structure_append_member_status
788
+
789
+ attach_function :bt_field_class_structure_get_member_count,
790
+ [ :bt_field_class_structure_handle ],
791
+ :uint64
792
+
793
+ attach_function :bt_field_class_structure_borrow_member_by_index,
794
+ [ :bt_field_class_structure_handle, :uint64],
795
+ :bt_field_class_structure_member_handle
796
+
797
+ attach_function :bt_field_class_structure_borrow_member_by_index_const,
798
+ [ :bt_field_class_structure_handle, :uint64],
799
+ :bt_field_class_structure_member_handle
800
+
801
+ attach_function :bt_field_class_structure_borrow_member_by_name,
802
+ [ :bt_field_class_structure_handle, :string ],
803
+ :bt_field_class_structure_member_handle
804
+
805
+ attach_function :bt_field_class_structure_borrow_member_by_name_const,
806
+ [ :bt_field_class_structure_handle, :string ],
807
+ :bt_field_class_structure_member_handle
808
+
809
+ attach_function :bt_field_class_structure_member_get_name,
810
+ [ :bt_field_class_structure_member_handle ],
811
+ :string
812
+
813
+ attach_function :bt_field_class_structure_member_borrow_field_class,
814
+ [ :bt_field_class_structure_member_handle ],
815
+ :bt_field_class_handle
816
+
817
+ attach_function :bt_field_class_structure_member_borrow_field_class_const,
818
+ [ :bt_field_class_structure_member_handle ],
819
+ :bt_field_class_handle
820
+
821
+ attach_function :bt_field_class_structure_member_set_user_attributes,
822
+ [ :bt_field_class_structure_member_handle, :bt_value_map_handle ],
823
+ :void
824
+
825
+ attach_function :bt_field_class_structure_member_borrow_user_attributes,
826
+ [ :bt_field_class_structure_member_handle ],
827
+ :bt_value_map_handle
828
+
829
+ attach_function :bt_field_class_structure_member_borrow_user_attributes_const,
830
+ [ :bt_field_class_structure_member_handle ],
831
+ :bt_value_map_handle
832
+
833
+ class BTFieldClass::Structure < BTFieldClass
834
+ class Member < BTObject
835
+ def get_name
836
+ name = Babeltrace2.bt_field_class_structure_member_get_name(@handle)
837
+ name[0] == ':' ? name[1..-1].to_sym : name
838
+ end
839
+ alias name get_name
840
+
841
+ def get_field_class
842
+ BTFieldClass.from_handle(
843
+ Babeltrace2.bt_field_class_structure_member_borrow_field_class(@handle))
844
+ end
845
+ alias field_class get_field_class
846
+
847
+ def set_user_attributes(user_attributes)
848
+ Babeltrace2.bt_field_class_structure_member_set_user_attributes(@handle, BTValue.from_value(user_attributes))
849
+ self
850
+ end
851
+
852
+ def user_attributes=(user_attributes)
853
+ set_user_attributes(user_attributes)
854
+ user_attributes
855
+ end
856
+
857
+ def get_user_attributes
858
+ BTValueMap.new(Babeltrace2.bt_field_class_structure_member_borrow_user_attributes(@handle), retain: true)
859
+ end
860
+ alias user_attributes get_user_attributes
861
+ end
862
+
863
+ def initialize(handle = nil, retain: true, auto_release: true,
864
+ trace_class: nil)
865
+ if handle
866
+ super(handle, retain: retain, auto_release: auto_release)
867
+ else
868
+ handle = Babeltrace2.bt_field_class_structure_create(trace_class)
869
+ raise Babeltrace2.process_error if handle.null?
870
+ super(handle, retain: false)
871
+ end
872
+ end
873
+
874
+ def append_member(name, member_field_class)
875
+ name = name.inspect if name.kind_of?(Symbol)
876
+ res = Babeltrace2.bt_field_class_structure_append_member(
877
+ @handle, name, member_field_class)
878
+ raise Babeltrace2.process_error(res) if res != :BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK
879
+ self
880
+ end
881
+ alias append append_member
882
+
883
+ def get_member_count
884
+ Babeltrace2.bt_field_class_structure_get_member_count(@handle)
885
+ end
886
+ alias member_count get_member_count
887
+
888
+ def get_member_by_index(index)
889
+ count = get_member_count
890
+ index += count if index < 0
891
+ return nil if index >= count || index < 0
892
+ BTFieldClassStructureMember.new(
893
+ Babeltrace2.bt_field_class_structure_borrow_member_by_index(@handle, index))
894
+ end
895
+
896
+ def get_member_by_name(name)
897
+ name = name.inspect if name.kind_of?(Symbol)
898
+ handle = Babeltrace2.bt_field_class_structure_borrow_member_by_name(@handle, name)
899
+ return nil if handle.null?
900
+ BTFieldClassStructureMember.new(handle)
901
+ end
902
+
903
+ def get_member(member)
904
+ case member
905
+ when ::String, ::Symbol
906
+ get_member_by_name(member)
907
+ when ::Integer
908
+ get_member_by_index(member)
909
+ else
910
+ raise TypeError, "wrong type for member query"
911
+ end
912
+ end
913
+ alias [] get_member
914
+ end
915
+ BTFieldClassStructure = BTFieldClass::Structure
916
+ BTFieldClassStructureMember = BTFieldClass::Structure::Member
917
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_STRUCTURE] = [
918
+ BTFieldClassStructureHandle,
919
+ BTFieldClassStructure ]
920
+
921
+ attach_function :bt_field_class_option_borrow_field_class,
922
+ [ :bt_field_class_option_handle ],
923
+ :bt_field_class_handle
924
+
925
+ attach_function :bt_field_class_option_borrow_field_class_const,
926
+ [ :bt_field_class_option_handle ],
927
+ :bt_field_class_handle
928
+
929
+ class BTFieldClass::Option < BTFieldClass
930
+ def get_field_class
931
+ BTFieldClass.from_handle(
932
+ Babeltrace2.bt_field_class_option_borrow_field_class(@handle))
933
+ end
934
+ alias field_class get_field_class
935
+ end
936
+ BTFieldClassOption = BTFieldClass::Option
937
+
938
+ attach_function :bt_field_class_option_without_selector_create,
939
+ [ :bt_trace_class_handle, :bt_field_class_handle ],
940
+ :bt_field_class_option_without_selector_field_handle
941
+
942
+ class BTFieldClass::Option::WithoutSelectorField < BTFieldClass::Option
943
+ def initialize(handle = nil, retain: true, auto_release: true,
944
+ trace_class: nil, optional_field_class: nil)
945
+ if handle
946
+ super(handle, retain: retain, auto_release: auto_release)
947
+ else
948
+ handle = Babeltrace2.bt_field_class_option_without_selector_create(
949
+ trace_class, optional_field_class)
950
+ raise Babeltrace2.process_error if handle.null?
951
+ super(handle, retain: false)
952
+ end
953
+ end
954
+ end
955
+ BTFieldClassOptionWithoutSelectorField = BTFieldClass::Option::WithoutSelectorField
956
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD] = [
957
+ BTFieldClassOptionWithoutSelectorFieldHandle,
958
+ BTFieldClassOptionWithoutSelectorField ]
959
+
960
+ attach_function :bt_field_class_option_with_selector_field_borrow_selector_field_path_const,
961
+ [ :bt_field_class_option_with_selector_field_handle ],
962
+ :bt_field_path_handle
963
+
964
+ class BTFieldClass::Option::WithSelectorField < BTFieldClass::Option
965
+ def get_selector_field_path
966
+ handle = Babeltrace2.bt_field_class_option_with_selector_field_borrow_selector_field_path_const(@handle)
967
+ return nil if handle.null?
968
+ BTFieldPath.new(handle, retain: true)
969
+ end
970
+ alias selector_field_path get_selector_field_path
971
+ end
972
+ BTFieldClassOptionWithSelectorField = BTFieldClass::Option::WithSelectorField
973
+
974
+ attach_function :bt_field_class_option_with_selector_field_bool_create,
975
+ [ :bt_trace_class_handle, :bt_field_class_handle,
976
+ :bt_field_class_bool_handle ],
977
+ :bt_field_class_option_with_selector_field_bool_handle
978
+
979
+ attach_function :bt_field_class_option_with_selector_field_bool_set_selector_is_reversed,
980
+ [ :bt_field_class_option_with_selector_field_bool_handle,
981
+ :bt_bool ],
982
+ :void
983
+
984
+ attach_function :bt_field_class_option_with_selector_field_bool_selector_is_reversed,
985
+ [ :bt_field_class_option_with_selector_field_bool_handle ],
986
+ :bt_bool
987
+
988
+ class BTFieldClass::Option::WithSelectorField::Bool < BTFieldClass::Option::WithSelectorField
989
+ def initialize(handle = nil, retain: true, auto_release: true,
990
+ trace_class: nil, optional_field_class: nil, selector_field_class: nil)
991
+ if handle
992
+ super(handle, retain: retain, auto_release: auto_release)
993
+ else
994
+ handle = Babeltrace2.bt_field_class_option_with_selector_field_bool_create(
995
+ trace_class, optional_field_class, selector_field_class)
996
+ raise Babeltrace2.process_error if handle.null?
997
+ super(handle, retain: false)
998
+ end
999
+ end
1000
+
1001
+ def set_selector_is_reversed(selector_is_reversed)
1002
+ Babeltrace2.bt_field_class_option_with_selector_field_bool_set_selector_is_reversed(
1003
+ @handle, selector_is_reversed ? BT_TRUE : BT_FALSE)
1004
+ self
1005
+ end
1006
+
1007
+ def selector_is_reversed=(selector_is_reversed)
1008
+ set_selector_is_reversed(selector_is_reversed)
1009
+ selector_is_reversed
1010
+ end
1011
+
1012
+ def selector_is_reversed
1013
+ Babeltrace2.bt_field_class_option_with_selector_field_bool_selector_is_reversed(
1014
+ @handle) != BT_FALSE
1015
+ end
1016
+ alias selector_is_reversed? selector_is_reversed
1017
+ end
1018
+ BTFieldClassOptionWithSelectorFieldBool = BTFieldClass::Option::WithSelectorField::Bool
1019
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD] = [
1020
+ BTFieldClassOptionWithSelectorFieldBoolHandle,
1021
+ BTFieldClassOptionWithSelectorFieldBool ]
1022
+
1023
+ attach_function :bt_field_class_option_with_selector_field_integer_unsigned_create,
1024
+ [ :bt_trace_class_handle, :bt_field_class_handle,
1025
+ :bt_field_class_integer_unsigned_handle,
1026
+ :bt_integer_range_set_unsigned_handle ],
1027
+ :bt_field_class_option_with_selector_field_integer_unsigned_handle
1028
+
1029
+ attach_function :bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const,
1030
+ [ :bt_field_class_option_with_selector_field_integer_unsigned_handle ],
1031
+ :bt_integer_range_set_unsigned_handle
1032
+
1033
+ class BTFieldClass::Option::WithSelectorField::IntegerUnsigned < BTFieldClass::Option::WithSelectorField
1034
+ def initialize(handle = nil, retain: true, auto_release: true,
1035
+ trace_class: nil, optional_field_class: nil, selector_field_class: nil,
1036
+ ranges: nil)
1037
+ if handle
1038
+ super(handle, retain: retain, auto_release: auto_release)
1039
+ else
1040
+ ranges = BTIntegerRangeSetUnsigned.from_value(ranges)
1041
+ handle = Babeltrace2.bt_field_class_option_with_selector_field_integer_unsigned_create(
1042
+ trace_class, optional_field_class, selector_field_class, ranges)
1043
+ raise Babeltrace2.process_error if handle.null?
1044
+ super(handle, retain: false)
1045
+ end
1046
+ end
1047
+
1048
+ def get_selector_ranges
1049
+ BTIntegerRangeSetUnsigned.new(
1050
+ Babeltrace2.bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const(
1051
+ @handle), retain: true)
1052
+ end
1053
+ alias selector_ranges get_selector_ranges
1054
+ end
1055
+ BTFieldClassOptionWithSelectorFieldIntegerUnsigned = BTFieldClass::Option::WithSelectorField::IntegerUnsigned
1056
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD] = [
1057
+ BTFieldClassOptionWithSelectorFieldIntegerUnsignedHandle,
1058
+ BTFieldClassOptionWithSelectorFieldIntegerUnsigned ]
1059
+
1060
+ attach_function :bt_field_class_option_with_selector_field_integer_signed_create,
1061
+ [ :bt_trace_class_handle, :bt_field_class_handle,
1062
+ :bt_field_class_integer_signed_handle,
1063
+ :bt_integer_range_set_signed_handle ],
1064
+ :bt_field_class_option_with_selector_field_integer_signed_handle
1065
+
1066
+ attach_function :bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const,
1067
+ [ :bt_field_class_option_with_selector_field_integer_signed_handle ],
1068
+ :bt_integer_range_set_signed_handle
1069
+
1070
+ class BTFieldClass::Option::WithSelectorField::IntegerSigned < BTFieldClass::Option::WithSelectorField
1071
+ def initialize(handle = nil, retain: true, auto_release: true,
1072
+ trace_class: nil, optional_field_class: nil, selector_field_class: nil,
1073
+ ranges: nil)
1074
+ if handle
1075
+ super(handle, retain: retain, auto_release: auto_release)
1076
+ else
1077
+ ranges = BTIntegerRangeSetSigned.from_value(ranges)
1078
+ handle = Babeltrace2.bt_field_class_option_with_selector_field_integer_signed_create(
1079
+ trace_class, optional_field_class, selector_field_class, ranges)
1080
+ raise Babeltrace2.process_error if handle.null?
1081
+ super(handle, retain: false)
1082
+ end
1083
+ end
1084
+
1085
+ def get_selector_ranges
1086
+ BTIntegerRangeSetSigned.new(
1087
+ Babeltrace2.bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const(
1088
+ @handle), retain: true)
1089
+ end
1090
+ alias selector_ranges get_selector_ranges
1091
+ end
1092
+ BTFieldClassOptionWithSelectorFieldIntegerSigned = BTFieldClass::Option::WithSelectorField::IntegerSigned
1093
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD] = [
1094
+ BTFieldClassOptionWithSelectorFieldIntegerSignedHandle,
1095
+ BTFieldClassOptionWithSelectorFieldIntegerSigned ]
1096
+
1097
+ attach_function :bt_field_class_variant_create,
1098
+ [ :bt_trace_class_handle, :bt_field_class_integer_handle ],
1099
+ :bt_field_class_variant_handle
1100
+
1101
+ attach_function :bt_field_class_variant_get_option_count,
1102
+ [ :bt_field_class_variant_handle ],
1103
+ :uint64
1104
+
1105
+ attach_function :bt_field_class_variant_borrow_option_by_index,
1106
+ [ :bt_field_class_variant_handle, :uint64 ],
1107
+ :bt_field_class_variant_option_handle
1108
+
1109
+ attach_function :bt_field_class_variant_borrow_option_by_index_const,
1110
+ [ :bt_field_class_variant_handle, :uint64 ],
1111
+ :bt_field_class_variant_option_handle
1112
+
1113
+ attach_function :bt_field_class_variant_borrow_option_by_name,
1114
+ [ :bt_field_class_variant_handle, :string ],
1115
+ :bt_field_class_variant_option_handle
1116
+
1117
+ attach_function :bt_field_class_variant_borrow_option_by_name_const,
1118
+ [ :bt_field_class_variant_handle, :string ],
1119
+ :bt_field_class_variant_option_handle
1120
+
1121
+ attach_function :bt_field_class_variant_option_get_name,
1122
+ [ :bt_field_class_variant_option_handle ],
1123
+ :string
1124
+
1125
+ attach_function :bt_field_class_variant_option_borrow_field_class,
1126
+ [ :bt_field_class_variant_option_handle ],
1127
+ :bt_field_class_handle
1128
+
1129
+ attach_function :bt_field_class_variant_option_borrow_field_class_const,
1130
+ [ :bt_field_class_variant_option_handle ],
1131
+ :bt_field_class_handle
1132
+
1133
+ attach_function :bt_field_class_variant_option_set_user_attributes,
1134
+ [ :bt_field_class_variant_option_handle,
1135
+ :bt_value_map_handle ],
1136
+ :void
1137
+
1138
+ attach_function :bt_field_class_variant_option_borrow_user_attributes,
1139
+ [ :bt_field_class_variant_option_handle ],
1140
+ :bt_value_map_handle
1141
+
1142
+ attach_function :bt_field_class_variant_option_borrow_user_attributes_const,
1143
+ [ :bt_field_class_variant_option_handle ],
1144
+ :bt_value_map_handle
1145
+
1146
+ class BTFieldClass::Variant < BTFieldClass
1147
+ class Option < BTObject
1148
+ def get_name
1149
+ name = Babeltrace2.bt_field_class_variant_option_get_name(@handle)
1150
+ name[0] == ':' ? name[1..-1].to_sym : name
1151
+ end
1152
+ alias name get_name
1153
+
1154
+ def get_field_class
1155
+ BTFieldClass.from_handle(
1156
+ Babeltrace2.bt_field_class_variant_option_borrow_field_class(@handle))
1157
+ end
1158
+ alias field_class get_field_class
1159
+
1160
+ def set_user_attributes(user_attributes)
1161
+ Babeltrace2.bt_field_class_variant_option_set_user_attributes(@handle,
1162
+ BTValue.from_value(user_attributes))
1163
+ self
1164
+ end
1165
+
1166
+ def user_attributes=(user_attributes)
1167
+ set_user_attributes(user_attributes)
1168
+ user_attributes
1169
+ end
1170
+
1171
+ def get_user_attributes
1172
+ BTValueMap.new(
1173
+ Babeltrace2.bt_field_class_variant_option_borrow_user_attributes_const(
1174
+ @handle), retain: true)
1175
+ end
1176
+ alias user_attributes get_user_attributes
1177
+ end
1178
+ end
1179
+ BTFieldClassVariantOption = BTFieldClass::Variant::Option
1180
+
1181
+ BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK = BT_FUNC_STATUS_OK
1182
+ BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
1183
+ BTFieldClassVariantWithoutSelectorAppendOptionStatus =
1184
+ enum :bt_field_class_variant_without_selector_append_option_status,
1185
+ [ :BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK,
1186
+ BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK,
1187
+ :BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR,
1188
+ BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR ]
1189
+
1190
+ attach_function :bt_field_class_variant_without_selector_append_option,
1191
+ [ :bt_field_class_variant_handle, :string,
1192
+ :bt_field_class_handle ],
1193
+ :bt_field_class_variant_without_selector_append_option_status
1194
+
1195
+ BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK = BT_FUNC_STATUS_OK
1196
+ BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
1197
+ BTFieldClassVariantWithSelectorAppendOptionStatus =
1198
+ enum :bt_field_class_variant_with_selector_field_integer_append_option_status,
1199
+ [ :BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK,
1200
+ BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK,
1201
+ :BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR,
1202
+ BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR ]
1203
+
1204
+ attach_function :bt_field_class_variant_with_selector_field_borrow_selector_field_path_const,
1205
+ [ :bt_field_class_variant_handle ],
1206
+ :bt_field_path_handle
1207
+
1208
+ attach_function :bt_field_class_variant_with_selector_field_integer_unsigned_append_option,
1209
+ [ :bt_field_class_variant_handle, :string,
1210
+ :bt_field_class_handle, :bt_integer_range_set_unsigned_handle ],
1211
+ :bt_field_class_variant_with_selector_field_integer_append_option_status
1212
+
1213
+ attach_function :bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const,
1214
+ [ :bt_field_class_variant_handle, :uint64 ],
1215
+ :bt_field_class_variant_with_selector_field_integer_unsigned_option_handle
1216
+
1217
+ attach_function :bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const,
1218
+ [ :bt_field_class_variant_handle, :string ],
1219
+ :bt_field_class_variant_with_selector_field_integer_unsigned_option_handle
1220
+
1221
+ attach_function :bt_field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges_const,
1222
+ [ :bt_field_class_variant_with_selector_field_integer_unsigned_option_handle ],
1223
+ :bt_integer_range_set_unsigned_handle
1224
+
1225
+ attach_function :bt_field_class_variant_with_selector_field_integer_signed_append_option,
1226
+ [ :bt_field_class_variant_handle, :string,
1227
+ :bt_field_class_handle, :bt_integer_range_set_signed_handle ],
1228
+ :bt_field_class_variant_with_selector_field_integer_append_option_status
1229
+
1230
+ attach_function :bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const,
1231
+ [ :bt_field_class_variant_handle, :uint64 ],
1232
+ :bt_field_class_variant_with_selector_field_integer_signed_option_handle
1233
+
1234
+ attach_function :bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_const,
1235
+ [ :bt_field_class_variant_handle, :string ],
1236
+ :bt_field_class_variant_with_selector_field_integer_signed_option_handle
1237
+
1238
+ attach_function :bt_field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_const,
1239
+ [ :bt_field_class_variant_with_selector_field_integer_signed_option_handle ],
1240
+ :bt_integer_range_set_signed_handle
1241
+
1242
+ class BTFieldClass::Variant
1243
+ module WithoutSelectorField
1244
+ AppendOptionStatus = BTFieldClassVariantWithoutSelectorAppendOptionStatus
1245
+ def append_option(name, option_field_class)
1246
+ name = name.inspect if name.kind_of?(Symbol)
1247
+ res = Babeltrace2.bt_field_class_variant_without_selector_append_option(
1248
+ @handle, name, option_field_class)
1249
+ raise Babeltrace2.process_error(res) if res != :BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK
1250
+ self
1251
+ end
1252
+ alias append append_option
1253
+ end
1254
+ module WithSelectorField
1255
+ AppendOptionStatus = BTFieldClassVariantWithSelectorAppendOptionStatus
1256
+ def get_selector_field_path
1257
+ handle = Babeltrace2.bt_field_class_variant_with_selector_field_borrow_selector_field_path_const(@handle)
1258
+ return nil if handle.null?
1259
+ BTFieldPath.new(handle, retain: true)
1260
+ end
1261
+ alias selector_field_path get_selector_field_path
1262
+ module IntegerUnsigned
1263
+ class Option < BTFieldClassVariantOption
1264
+ def get_ranges
1265
+ BTIntegerRangeSetUnsigned.new(
1266
+ Babeltrace2.bt_field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges_const(
1267
+ @handle), retain: true)
1268
+ end
1269
+ alias ranges get_ranges
1270
+ end
1271
+ include WithSelectorField
1272
+ def append_option(name, option_field_class, ranges)
1273
+ name = name.inspect if name.kind_of?(Symbol)
1274
+ ranges = BTIntegerRangeSetUnsigned.from_value(ranges)
1275
+ res = Babeltrace2.bt_field_class_variant_with_selector_field_integer_unsigned_append_option(
1276
+ @handle, name, option_field_class, ranges)
1277
+ raise Babeltrace2.process_error(res) if res != :BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK
1278
+ self
1279
+ end
1280
+ alias append append_option
1281
+
1282
+ def get_option_by_index(index)
1283
+ count = get_option_count
1284
+ index += count if index < 0
1285
+ return nil if index >= count || index < 0
1286
+ BTFieldClassVariantWithSelectorFieldIntegerUnsignedOption.new(
1287
+ Babeltrace2.bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const(
1288
+ @handle, index))
1289
+ end
1290
+
1291
+ def get_option_by_name(name)
1292
+ name = name.inspect if name.kind_of?(Symbol)
1293
+ handle = Babeltrace2.bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const(@handle, name)
1294
+ return nil if handle.null?
1295
+ BTFieldClassVariantWithSelectorFieldIntegerUnsignedOption.new(handle)
1296
+ end
1297
+ end
1298
+ module IntegerSigned
1299
+ class Option < BTFieldClassVariantOption
1300
+ def get_ranges
1301
+ BTIntegerRangeSetSigned.new(
1302
+ Babeltrace2.bt_field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_const(
1303
+ @handle), retain: true)
1304
+ end
1305
+ alias ranges get_ranges
1306
+ end
1307
+ include WithSelectorField
1308
+ def append_option(name, option_field_class, ranges)
1309
+ name = name.inspect if name.kind_of?(Symbol)
1310
+ ranges = BTIntegerRangeSetSigned.from_value(ranges)
1311
+ res = Babeltrace2.bt_field_class_variant_with_selector_field_integer_signed_append_option(
1312
+ @handle, name, option_field_class, ranges)
1313
+ raise Babeltrace2.process_error(res) if res != :BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK
1314
+ self
1315
+ end
1316
+ alias append append_option
1317
+
1318
+ def get_option_by_index(index)
1319
+ count = get_option_count
1320
+ index += count if index < 0
1321
+ return nil if index >= count || index < 0
1322
+ BTFieldClassVariantWithSelectorFieldIntegerSignedOption.new(
1323
+ Babeltrace2.bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const(@handle, index))
1324
+ end
1325
+
1326
+ def get_option_by_name(name)
1327
+ name = name.inspect if name.kind_of?(Symbol)
1328
+ handle = Babeltrace2.bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_const(@handle, name)
1329
+ return nil if handle.null?
1330
+ BTFieldClassVariantWithSelectorFieldIntegerSignedOption.new(handle)
1331
+ end
1332
+ end
1333
+ end
1334
+ def initialize(handle = nil, retain: true, auto_release: true,
1335
+ trace_class: nil, selector_field_class: nil)
1336
+ if handle
1337
+ case Babeltrace2.bt_field_class_get_type(handle)
1338
+ when :BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD
1339
+ self.extend(BTFieldClass::Variant::WithoutSelectorField)
1340
+ when :BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD
1341
+ self.extend(BTFieldClass::Variant::WithSelectorField::IntegerUnsigned)
1342
+ when :BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD
1343
+ self.extend(BTFieldClass::Variant::WithSelectorField::IntegerSigned)
1344
+ else
1345
+ raise "unsupported variant type"
1346
+ end
1347
+ super(handle, retain: retain, auto_release: auto_release)
1348
+ else
1349
+ handle =
1350
+ Babeltrace2.bt_field_class_variant_create(trace_class, selector_field_class)
1351
+ raise Babeltrace2.process_error if handle.null?
1352
+ case Babeltrace2.bt_field_class_get_type(handle)
1353
+ when :BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD
1354
+ self.extend(BTFieldClass::Variant::WithoutSelectorField)
1355
+ when :BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD
1356
+ self.extend(BTFieldClass::Variant::WithSelectorField::IntegerUnsigned)
1357
+ when :BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD
1358
+ self.extend(BTFieldClass::Variant::WithSelectorField::IntegerSigned)
1359
+ else
1360
+ raise "unsupported variant type"
1361
+ end
1362
+ super(handle, retain: false)
1363
+ end
1364
+ end
1365
+
1366
+ def get_option_count
1367
+ Babeltrace2.bt_field_class_variant_get_option_count(@handle)
1368
+ end
1369
+ alias option_count get_option_count
1370
+
1371
+ def get_option_by_index(index)
1372
+ count = get_option_count
1373
+ index += count if index < 0
1374
+ return nil if index >= count || index < 0
1375
+ BTFieldClassVariantOption.new(
1376
+ Babeltrace2.bt_field_class_variant_borrow_option_by_index(@handle, index))
1377
+ end
1378
+
1379
+ def get_option_by_name(name)
1380
+ name = name.inspect if name.kind_of?(Symbol)
1381
+ handle = Babeltrace2.bt_field_class_variant_borrow_option_by_name(@handle, name)
1382
+ return nil if handle.null?
1383
+ BTFieldClassVariantOption.new(handle)
1384
+ end
1385
+
1386
+ def get_option(option)
1387
+ case option
1388
+ when ::String, Symbol
1389
+ get_option_by_name(option)
1390
+ when ::Integer
1391
+ get_option_by_index(option)
1392
+ else
1393
+ raise TypeError, "wrong type for option query"
1394
+ end
1395
+ end
1396
+ alias [] get_option
1397
+
1398
+ end
1399
+ BTFieldClassVariantWithoutSelectorField =
1400
+ BTFieldClass::Variant::WithoutSelectorField
1401
+ BTFieldClassVariantWithSelectorFieldIntegerUnsigned =
1402
+ BTFieldClass::Variant::WithSelectorField::IntegerUnsigned
1403
+ BTFieldClassVariantWithSelectorFieldIntegerSigned =
1404
+ BTFieldClass::Variant::WithSelectorField::IntegerSigned
1405
+ BTFieldClassVariantWithSelectorFieldIntegerUnsignedOption =
1406
+ BTFieldClass::Variant::WithSelectorField::IntegerUnsigned::Option
1407
+ BTFieldClassVariantWithSelectorFieldIntegerSignedOption =
1408
+ BTFieldClass::Variant::WithSelectorField::IntegerSigned::Option
1409
+ BTFieldClassVariant = BTFieldClass::Variant
1410
+ vcls = [
1411
+ BTFieldClassVariantHandle,
1412
+ BTFieldClassVariant ]
1413
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD] = vcls
1414
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD] = vcls
1415
+ BTFieldClass::TYPE_MAP[:BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD] = vcls
1416
+ end