babeltrace 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +7 -0
- data/babeltrace.gemspec +15 -0
- data/ext/babeltrace_c/babeltrace.c +77 -0
- data/ext/babeltrace_c/babeltrace/align.h +82 -0
- data/ext/babeltrace_c/babeltrace/compiler.h +40 -0
- data/ext/babeltrace_c/babeltrace/types.h +565 -0
- data/ext/babeltrace_c/extconf.rb +8 -0
- data/lib/babeltrace.rb +15 -0
- data/lib/babeltrace/clock_type.rb +3 -0
- data/lib/babeltrace/context.rb +33 -0
- data/lib/babeltrace/ctf.rb +10 -0
- data/lib/babeltrace/ctf/callbacks.rb +27 -0
- data/lib/babeltrace/ctf/events.rb +558 -0
- data/lib/babeltrace/ctf/iterator.rb +90 -0
- data/lib/babeltrace/format.rb +54 -0
- data/lib/babeltrace/iterator.rb +62 -0
- data/lib/babeltrace/list.rb +72 -0
- data/lib/babeltrace/trace_handle.rb +28 -0
- data/lib/babeltrace/types.rb +8 -0
- metadata +83 -0
data/lib/babeltrace.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
require 'babeltrace_c'
|
3
|
+
|
4
|
+
module Babeltrace
|
5
|
+
extend FFI::Library
|
6
|
+
ffi_lib "babeltrace"
|
7
|
+
end
|
8
|
+
|
9
|
+
require_relative 'babeltrace/types'
|
10
|
+
require_relative 'babeltrace/list'
|
11
|
+
require_relative 'babeltrace/clock_type'
|
12
|
+
require_relative 'babeltrace/format'
|
13
|
+
require_relative 'babeltrace/context'
|
14
|
+
require_relative 'babeltrace/iterator'
|
15
|
+
require_relative 'babeltrace/trace_handle'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Babeltrace
|
2
|
+
|
3
|
+
class Context # < ManagedStruct
|
4
|
+
def initialize(ptr = Babeltrace.bt_context_create)
|
5
|
+
super(ptr)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.release(ptr)
|
9
|
+
Babeltrace.bt_context_put(ptr)
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_trace(path:, format: "ctf")
|
13
|
+
handle_id = Babeltrace.bt_context_add_trace(self, path, format, nil, nil, nil)
|
14
|
+
case format
|
15
|
+
when "ctf"
|
16
|
+
return CTF::Trace::new(self, handle_id)
|
17
|
+
else
|
18
|
+
return Trace::new(self, handle_id)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def remove_trace(trace_id)
|
23
|
+
Babeltrace.bt_context_remove_trace(self, trace_id)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
attach_function :bt_context_create, [], Context
|
28
|
+
attach_function :bt_context_add_trace, [Context, :string, :string, :packet_seek_callback, :pointer, :pointer], :int
|
29
|
+
attach_function :bt_context_remove_trace, [Context, :int], :int
|
30
|
+
attach_function :bt_context_get, [Context], :void
|
31
|
+
attach_function :bt_context_put, [Context], :void
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Babeltrace
|
2
|
+
module CTF
|
3
|
+
|
4
|
+
CBRet = enum :OK, :OK_STOP, :ERROR_STOP, :ERROR_CONTINUE
|
5
|
+
class Iter < FFI::ManagedStruct
|
6
|
+
layout :dummy, :pointer
|
7
|
+
end
|
8
|
+
|
9
|
+
class Dependencies < FFI::Struct
|
10
|
+
layout :dummy, :pointer
|
11
|
+
|
12
|
+
def initialize(*args)
|
13
|
+
super(CTF.bt_dependencies_create(*args, nil))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Event < FFI::Struct
|
18
|
+
layout :dummy, :pointer
|
19
|
+
end
|
20
|
+
|
21
|
+
attach_function :bt_dependencies_create, [:string, :varargs], Dependencies.by_ref
|
22
|
+
# attach_function :bt_dependencies_destroy, [Dependencies], nil
|
23
|
+
|
24
|
+
callback :iter_callback, [Event, :pointer], CBRet
|
25
|
+
attach_function :bt_ctf_iter_add_callback, [Iter, Babeltrace.find_type(:intern_str), :pointer, :int, :iter_callback, Dependencies, Dependencies, Dependencies], :int
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,558 @@
|
|
1
|
+
module Babeltrace
|
2
|
+
module CTF
|
3
|
+
Scope = enum :TRACE_PACKET_HEADER,
|
4
|
+
:STREAM_PACKET_CONTEXT,
|
5
|
+
:STREAM_EVENT_HEADER,
|
6
|
+
:STREAM_EVENT_CONTEXT,
|
7
|
+
:EVENT_CONTEXT,
|
8
|
+
:EVENT_FIELDS
|
9
|
+
TypeID = enum :UNKNOWN,
|
10
|
+
:INTEGER,
|
11
|
+
:FLOAT,
|
12
|
+
:ENUM,
|
13
|
+
:STRING,
|
14
|
+
:STRUCT,
|
15
|
+
:UNTAGGED_VARIANT,
|
16
|
+
:VARIANT,
|
17
|
+
:ARRAY,
|
18
|
+
:SEQUENCE,
|
19
|
+
:NR
|
20
|
+
|
21
|
+
StringEncoding = enum :NONE,
|
22
|
+
:UTF8,
|
23
|
+
:ASCII,
|
24
|
+
:UNKNOWN
|
25
|
+
|
26
|
+
module Internal
|
27
|
+
class Declaration # < FFI::Struct
|
28
|
+
layout :dummy, :pointer
|
29
|
+
|
30
|
+
def field_type
|
31
|
+
CTF.bt_ctf_field_type(self)
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_int_signedness
|
35
|
+
CTF.bt_ctf_get_int_signedness(self)
|
36
|
+
end
|
37
|
+
|
38
|
+
def int_signed?
|
39
|
+
get_int_signedness == 1
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_int_base
|
43
|
+
CTF.bt_ctf_get_int_base(self)
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_int_byte_order
|
47
|
+
CTF.bt_ctf_get_int_byte_order(self)
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_int_len
|
51
|
+
CTF.bt_ctf_get_int_len(self)
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_encoding
|
55
|
+
CTF.bt_ctf_get_encoding(self)
|
56
|
+
end
|
57
|
+
|
58
|
+
def get_array_len
|
59
|
+
CTF.bt_ctf_get_array_len(self)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
attach_function :bt_ctf_field_type, [Internal::Declaration], TypeID
|
64
|
+
attach_function :bt_ctf_get_int_signedness, [Internal::Declaration], :int
|
65
|
+
attach_function :bt_ctf_get_int_base, [Internal::Declaration], :int
|
66
|
+
attach_function :bt_ctf_get_int_byte_order, [Internal::Declaration], :int
|
67
|
+
attach_function :bt_ctf_get_int_len, [Internal::Declaration], :ssize_t
|
68
|
+
attach_function :bt_ctf_get_encoding, [Internal::Declaration], StringEncoding
|
69
|
+
attach_function :bt_ctf_get_array_len, [Internal::Declaration], :int
|
70
|
+
|
71
|
+
module Internal
|
72
|
+
class FieldDecl < FFI::Struct
|
73
|
+
layout :dummy, :pointer
|
74
|
+
|
75
|
+
def get_decl
|
76
|
+
decl = CTF.bt_ctf_get_decl_from_field_decl(self)
|
77
|
+
CTF::Declaration::create(decl)
|
78
|
+
end
|
79
|
+
alias decl get_decl
|
80
|
+
|
81
|
+
def get_name
|
82
|
+
CTF.bt_ctf_get_decl_field_name(self)
|
83
|
+
end
|
84
|
+
alias name get_name
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
attach_function :bt_ctf_get_decl_from_field_decl, [Internal::FieldDecl], Internal::Declaration.by_ref
|
89
|
+
attach_function :bt_ctf_get_decl_field_name, [Internal::FieldDecl], :string
|
90
|
+
|
91
|
+
module Internal
|
92
|
+
class Definition # < FFI::Struct
|
93
|
+
layout :dummy, :pointer
|
94
|
+
|
95
|
+
def field_name
|
96
|
+
CTF.bt_ctf_field_name(self)
|
97
|
+
end
|
98
|
+
alias name field_name
|
99
|
+
|
100
|
+
def get_decl
|
101
|
+
decl = CTF.bt_ctf_get_decl_from_def(self)
|
102
|
+
CTF::Declaration.create(decl)
|
103
|
+
end
|
104
|
+
alias decl get_decl
|
105
|
+
|
106
|
+
def get_struct_field_count
|
107
|
+
CTF.bt_ctf_get_struct_field_count(self)
|
108
|
+
end
|
109
|
+
alias struct_field_count get_struct_field_count
|
110
|
+
|
111
|
+
def get_uint64
|
112
|
+
CTF.bt_ctf_get_uint64(self)
|
113
|
+
end
|
114
|
+
|
115
|
+
def get_int64
|
116
|
+
CTF.bt_ctf_get_int64(self)
|
117
|
+
end
|
118
|
+
|
119
|
+
def get_enum_int
|
120
|
+
d = CTF.bt_ctf_get_enum_int(self)
|
121
|
+
CTF::Definition.create(d)
|
122
|
+
end
|
123
|
+
|
124
|
+
def get_enum_str
|
125
|
+
CTF.bt_ctf_get_enum_str(self)
|
126
|
+
end
|
127
|
+
|
128
|
+
def get_char_array
|
129
|
+
CTF.bt_ctf_get_char_array(self)
|
130
|
+
end
|
131
|
+
|
132
|
+
def get_string
|
133
|
+
CTF.bt_ctf_get_string(self)
|
134
|
+
end
|
135
|
+
|
136
|
+
def get_float
|
137
|
+
CTF.bt_ctf_get_float(self)
|
138
|
+
end
|
139
|
+
|
140
|
+
def get_variant
|
141
|
+
d = CTF.bt_ctf_get_variant(self)
|
142
|
+
CTF::Definition.create(d)
|
143
|
+
end
|
144
|
+
|
145
|
+
def get_struct_field_index(i)
|
146
|
+
d = CTF.bt_ctf_get_struct_field_index(self, i)
|
147
|
+
CTF::Definition.create(d)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
attach_function :bt_ctf_field_name, [Internal::Definition], :string
|
153
|
+
attach_function :bt_ctf_get_decl_from_def, [Internal::Definition], Internal::Declaration.by_ref
|
154
|
+
attach_function :bt_ctf_get_struct_field_count, [Internal::Definition], :uint64
|
155
|
+
attach_function :bt_ctf_get_uint64, [Internal::Definition], :uint64
|
156
|
+
attach_function :bt_ctf_get_int64, [Internal::Definition], :int64
|
157
|
+
attach_function :bt_ctf_get_enum_int, [Internal::Definition], Internal::Definition.by_ref
|
158
|
+
attach_function :bt_ctf_get_enum_str, [Internal::Definition], :string
|
159
|
+
attach_function :bt_ctf_get_char_array, [Internal::Definition], :pointer
|
160
|
+
attach_function :bt_ctf_get_string, [Internal::Definition], :string
|
161
|
+
attach_function :bt_ctf_get_float, [Internal::Definition], :double
|
162
|
+
attach_function :bt_ctf_get_variant, [Internal::Definition], Internal::Definition.by_ref
|
163
|
+
attach_function :bt_ctf_get_struct_field_index, [Internal::Definition, :uint64], Internal::Definition.by_ref
|
164
|
+
|
165
|
+
module Internal
|
166
|
+
class EventDecl < FFI::Struct
|
167
|
+
layout :dummy, :pointer
|
168
|
+
|
169
|
+
def get_name
|
170
|
+
CTF.bt_ctf_get_decl_event_name(self)
|
171
|
+
end
|
172
|
+
alias name get_name
|
173
|
+
|
174
|
+
def get_decl_fields(scope)
|
175
|
+
count = FFI::MemoryPointer::new(:uint)
|
176
|
+
list = FFI::MemoryPointer::new(:pointer)
|
177
|
+
res = CTF.bt_ctf_get_decl_fields(self, scope, list, count)
|
178
|
+
count = count.read(:uint)
|
179
|
+
list = list.read_pointer.read_array_of_pointer(count)
|
180
|
+
list.collect { |p| FieldDecl::new(p) }
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
attach_function :bt_ctf_get_decl_event_name, [Internal::EventDecl], :string
|
186
|
+
attach_function :bt_ctf_get_decl_fields, [Internal::EventDecl, Scope, :pointer, :pointer], :int
|
187
|
+
|
188
|
+
class Trace < Babeltrace::Trace
|
189
|
+
def get_event_decl_list
|
190
|
+
count = FFI::MemoryPointer::new(:uint)
|
191
|
+
list = FFI::MemoryPointer::new(:pointer)
|
192
|
+
res = CTF.bt_ctf_get_event_decl_list(@handle_id, @context, list, count)
|
193
|
+
count = count.read(:uint)
|
194
|
+
list = list.read_pointer.read_array_of_pointer(count)
|
195
|
+
list.collect { |p| Internal::EventDecl::new(p) }
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
attach_function :bt_ctf_get_event_decl_list, [:int, Context, :pointer, :pointer], :int
|
200
|
+
|
201
|
+
class Event
|
202
|
+
def get_context
|
203
|
+
c = CTF.bt_ctf_event_get_context(self)
|
204
|
+
Babeltrace.bt_context_get(c)
|
205
|
+
c
|
206
|
+
end
|
207
|
+
alias context get_context
|
208
|
+
|
209
|
+
def get_handle_id
|
210
|
+
CTF.bt_ctf_event_get_handle_id(self)
|
211
|
+
end
|
212
|
+
alias handle_id get_handle_id
|
213
|
+
|
214
|
+
def get_top_level_scope(scope)
|
215
|
+
d = CTF.bt_ctf_get_top_level_scope(self, scope)
|
216
|
+
Definition.create(d)
|
217
|
+
end
|
218
|
+
alias top_level_scope get_top_level_scope
|
219
|
+
|
220
|
+
def event_name
|
221
|
+
CTF.bt_ctf_event_name(self)
|
222
|
+
end
|
223
|
+
alias name event_name
|
224
|
+
|
225
|
+
def get_cycles
|
226
|
+
CTF.bt_ctf_get_cycles(self)
|
227
|
+
end
|
228
|
+
alias cycles get_cycles
|
229
|
+
|
230
|
+
def get_timestamp
|
231
|
+
Time.at(0, CTF.bt_ctf_get_timestamp(self), :nsec)
|
232
|
+
end
|
233
|
+
alias timestamp get_timestamp
|
234
|
+
|
235
|
+
def get_field_list(scope)
|
236
|
+
count = FFI::MemoryPointer::new(:uint)
|
237
|
+
list = FFI::MemoryPointer::new(:pointer)
|
238
|
+
res = CTF.bt_ctf_get_field_list(self, scope.definition, list, count)
|
239
|
+
count = count.read(:uint)
|
240
|
+
return [] if count == 0
|
241
|
+
list = list.read_pointer.read_array_of_pointer(count)
|
242
|
+
list.collect { |p| Internal::Definition::new(p) }.collect { |d| Definition.create(d) }
|
243
|
+
end
|
244
|
+
alias field_list get_field_list
|
245
|
+
|
246
|
+
def get_field(scope, field)
|
247
|
+
d = CTF.bt_ctf_get_field(self, scope.definition, field)
|
248
|
+
Definition.create(d)
|
249
|
+
end
|
250
|
+
|
251
|
+
def each_field(scope = :EVENT_FIELDS)
|
252
|
+
if block_given?
|
253
|
+
sc = self.top_level_scope(scope)
|
254
|
+
self.field_list(sc).each { |f| yield f }
|
255
|
+
else
|
256
|
+
return to_enum(:each_field, scope)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def find_field(field, scope = :EVENT_FIELDS)
|
261
|
+
sc = self.top_level_scope(scope)
|
262
|
+
d = get_field(sc, field)
|
263
|
+
Definition.create(d)
|
264
|
+
end
|
265
|
+
|
266
|
+
def get_index(field, index)
|
267
|
+
d = CTF.bt_ctf_get_index(self, field.definition, index)
|
268
|
+
Definition.create(d)
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
272
|
+
|
273
|
+
attach_function :bt_ctf_event_get_context, [Event], Context.by_ref
|
274
|
+
attach_function :bt_ctf_event_get_handle_id, [Event], :int
|
275
|
+
attach_function :bt_ctf_get_top_level_scope, [Event, Scope], Internal::Definition.by_ref
|
276
|
+
attach_function :bt_ctf_event_name, [Event], :string
|
277
|
+
attach_function :bt_ctf_get_cycles, [Event], :uint64
|
278
|
+
attach_function :bt_ctf_get_timestamp, [Event], :uint64
|
279
|
+
attach_function :bt_ctf_get_field_list, [Event, Internal::Definition, :pointer, :pointer], :int
|
280
|
+
attach_function :bt_ctf_get_field, [Event, Internal::Definition, :string], Internal::Definition.by_ref
|
281
|
+
attach_function :bt_ctf_get_index, [Event, Internal::Definition, :uint], Internal::Definition.by_ref
|
282
|
+
# Hack
|
283
|
+
attach_function :bt_array_index, [Internal::Definition, :uint64], Internal::Definition.by_ref
|
284
|
+
attach_function :bt_sequence_len, [Internal::Definition], :uint64
|
285
|
+
attach_function :bt_sequence_index, [Internal::Definition, :uint64], Internal::Definition.by_ref
|
286
|
+
|
287
|
+
class Definition
|
288
|
+
attr_reader :definition
|
289
|
+
|
290
|
+
def self.create(d)
|
291
|
+
return nil if d.pointer.null?
|
292
|
+
d.decl.def_class.new(d)
|
293
|
+
end
|
294
|
+
|
295
|
+
def initialize(definition)
|
296
|
+
@definition = definition
|
297
|
+
end
|
298
|
+
|
299
|
+
def name
|
300
|
+
@definition.name
|
301
|
+
end
|
302
|
+
|
303
|
+
def decl
|
304
|
+
@definition.decl
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
class StructDef < Definition
|
309
|
+
def field_count
|
310
|
+
@definition.get_struct_field_count
|
311
|
+
end
|
312
|
+
|
313
|
+
def field(i)
|
314
|
+
@definition.get_struct_field_index(i)
|
315
|
+
end
|
316
|
+
|
317
|
+
def value
|
318
|
+
field_count.times.collect { |i|
|
319
|
+
f = field(i)
|
320
|
+
[f.name, f.value]
|
321
|
+
}.to_h
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
class IntegerDef < Definition
|
326
|
+
def int
|
327
|
+
@definition.decl.signed? ? @definition.get_int64 : @definition.get_uint64
|
328
|
+
end
|
329
|
+
alias value int
|
330
|
+
end
|
331
|
+
|
332
|
+
class FloatDef < Definition
|
333
|
+
def float
|
334
|
+
@definition.get_float
|
335
|
+
end
|
336
|
+
alias value float
|
337
|
+
end
|
338
|
+
|
339
|
+
class EnumDef < Definition
|
340
|
+
def int
|
341
|
+
IntegerDef::new(@definition.get_enum_int)
|
342
|
+
end
|
343
|
+
|
344
|
+
def string
|
345
|
+
@definition.get_enum_str
|
346
|
+
end
|
347
|
+
alias value string
|
348
|
+
end
|
349
|
+
|
350
|
+
class StringDef < Definition
|
351
|
+
def string
|
352
|
+
@definition.get_string
|
353
|
+
end
|
354
|
+
alias value string
|
355
|
+
end
|
356
|
+
|
357
|
+
class UntaggedVariantDef < Definition
|
358
|
+
def variant
|
359
|
+
@definition.get_variant
|
360
|
+
end
|
361
|
+
|
362
|
+
def value
|
363
|
+
variant.value
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
class VariantDef < Definition
|
368
|
+
def variant
|
369
|
+
@definition.get_variant
|
370
|
+
end
|
371
|
+
|
372
|
+
def value
|
373
|
+
variant.value
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
class ArrayDef < Definition
|
378
|
+
def len
|
379
|
+
@definition.decl.len
|
380
|
+
end
|
381
|
+
|
382
|
+
def index(i)
|
383
|
+
d = CTF.bt_array_index(@definition, i)
|
384
|
+
return Definition.create(d)
|
385
|
+
end
|
386
|
+
|
387
|
+
def value
|
388
|
+
len.times.collect { |i| index(i).value }
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
class ArrayTextDef < Definition
|
393
|
+
def len
|
394
|
+
@definition.decl.array_len
|
395
|
+
end
|
396
|
+
|
397
|
+
def value
|
398
|
+
@definition.get_char_array.read_bytes(len)
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
class SequenceDef < Definition
|
403
|
+
def len
|
404
|
+
CTF.bt_sequence_len(@definition)
|
405
|
+
end
|
406
|
+
|
407
|
+
def index(i)
|
408
|
+
d = CTF.bt_sequence_index(@definition, i)
|
409
|
+
return Definition.create(d)
|
410
|
+
end
|
411
|
+
|
412
|
+
def value
|
413
|
+
len.times.collect { |i| index(i).value }
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
class SequenceTextDef < Definition
|
418
|
+
def len
|
419
|
+
CTF.bt_sequence_len(@definition)
|
420
|
+
end
|
421
|
+
|
422
|
+
def value
|
423
|
+
return [] if len == 0
|
424
|
+
@definition.get_char_sequence.read_bytes(len)
|
425
|
+
end
|
426
|
+
end
|
427
|
+
|
428
|
+
class Declaration
|
429
|
+
attr_reader :declaration
|
430
|
+
|
431
|
+
def self.create(decl)
|
432
|
+
return nil if decl.pointer.null?
|
433
|
+
case decl.field_type
|
434
|
+
when :INTEGER
|
435
|
+
IntegerDecl::new(decl)
|
436
|
+
when :FLOAT
|
437
|
+
FloatDecl::new(decl)
|
438
|
+
when :ENUM
|
439
|
+
EnumDecl::new(decl)
|
440
|
+
when :STRING
|
441
|
+
StringDecl::new(decl)
|
442
|
+
when :STRUCT
|
443
|
+
StructDecl::new(decl)
|
444
|
+
when :UNTAGGED_VARIANT
|
445
|
+
UntaggedVariantDecl::new(decl)
|
446
|
+
when :VARIANT
|
447
|
+
VariantDecl::new(decl)
|
448
|
+
when :ARRAY
|
449
|
+
ArrayDecl::new(decl)
|
450
|
+
when :SEQUENCE
|
451
|
+
SequenceDecl::new(decl)
|
452
|
+
else
|
453
|
+
raise "Unknow declaration type #{d.decl.field_type}!"
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
def initialize(declaration)
|
458
|
+
@declaration = declaration
|
459
|
+
end
|
460
|
+
|
461
|
+
def field_type
|
462
|
+
@declaration.field_type
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
466
|
+
class StructDecl < Declaration
|
467
|
+
def def_class
|
468
|
+
StructDef
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
472
|
+
class IntegerDecl < Declaration
|
473
|
+
def def_class
|
474
|
+
IntegerDef
|
475
|
+
end
|
476
|
+
|
477
|
+
def signed?
|
478
|
+
@declaration.int_signed?
|
479
|
+
end
|
480
|
+
|
481
|
+
def base
|
482
|
+
@declaration.get_int_base
|
483
|
+
end
|
484
|
+
|
485
|
+
def byte_order
|
486
|
+
@declaration.get_int_byte_order
|
487
|
+
end
|
488
|
+
|
489
|
+
def len
|
490
|
+
@declaration.get_int_len
|
491
|
+
end
|
492
|
+
|
493
|
+
def encoding
|
494
|
+
@declaration.get_encoding
|
495
|
+
end
|
496
|
+
|
497
|
+
end
|
498
|
+
|
499
|
+
class FloatDecl < Declaration
|
500
|
+
def def_class
|
501
|
+
FloatDef
|
502
|
+
end
|
503
|
+
end
|
504
|
+
|
505
|
+
class EnumDecl < Declaration
|
506
|
+
def def_class
|
507
|
+
EnumDef
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
511
|
+
class StringDecl < Declaration
|
512
|
+
def def_class
|
513
|
+
StringDef
|
514
|
+
end
|
515
|
+
end
|
516
|
+
|
517
|
+
class UntaggedVariantDecl < Declaration
|
518
|
+
def def_class
|
519
|
+
UntaggedVariantDef
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
class VariantDecl < Declaration
|
524
|
+
def def_class
|
525
|
+
VariantDef
|
526
|
+
end
|
527
|
+
end
|
528
|
+
|
529
|
+
class ArrayDecl # < Declaration
|
530
|
+
def def_class
|
531
|
+
e = elem
|
532
|
+
if e.kind_of?(IntegerDecl) && e.len == 8 &&
|
533
|
+
( e.encoding == :ASCII || e.encoding == :UTF8 )
|
534
|
+
ArrayTextDef
|
535
|
+
else
|
536
|
+
ArrayDef
|
537
|
+
end
|
538
|
+
end
|
539
|
+
|
540
|
+
def len
|
541
|
+
@declaration.get_array_len
|
542
|
+
end
|
543
|
+
end
|
544
|
+
|
545
|
+
class SequenceDecl # < Declaration
|
546
|
+
def def_class
|
547
|
+
e = elem
|
548
|
+
if e.kind_of?(IntegerDecl) && e.len == 8 &&
|
549
|
+
( e.encoding == :ASCII || e.encoding == :UTF8 )
|
550
|
+
SequenceTextDef
|
551
|
+
else
|
552
|
+
SequenceDef
|
553
|
+
end
|
554
|
+
end
|
555
|
+
end
|
556
|
+
|
557
|
+
end
|
558
|
+
end
|