Commit | Line | Data |
---|---|---|
d79865b9 MD |
1 | #ifndef _BABELTRACE_TYPES_H |
2 | #define _BABELTRACE_TYPES_H | |
3 | ||
4 | /* | |
5 | * BabelTrace | |
6 | * | |
fc93b2bd | 7 | * Type Header |
d79865b9 | 8 | * |
64fa3fec MD |
9 | * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation |
10 | * | |
11 | * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
d79865b9 | 12 | * |
ccd7e1c8 MD |
13 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
14 | * of this software and associated documentation files (the "Software"), to deal | |
15 | * in the Software without restriction, including without limitation the rights | |
16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
17 | * copies of the Software, and to permit persons to whom the Software is | |
18 | * furnished to do so, subject to the following conditions: | |
d79865b9 | 19 | * |
ccd7e1c8 MD |
20 | * The above copyright notice and this permission notice shall be included in |
21 | * all copies or substantial portions of the Software. | |
d79865b9 MD |
22 | */ |
23 | ||
bed864a7 | 24 | #include <babeltrace/align.h> |
d65d8abb | 25 | #include <babeltrace/list.h> |
9843982d | 26 | #include <babeltrace/ctf/events.h> |
4c8bfb7e MD |
27 | #include <stdbool.h> |
28 | #include <stdint.h> | |
29 | #include <limits.h> | |
bed864a7 | 30 | #include <string.h> |
4c8bfb7e | 31 | #include <glib.h> |
8eab883c | 32 | #include <assert.h> |
bed864a7 | 33 | |
11796b96 MD |
34 | /* Preallocate this many fields for structures */ |
35 | #define DEFAULT_NR_STRUCT_FIELDS 8 | |
36 | ||
764af3f4 | 37 | struct ctf_stream; |
dd2544fd | 38 | struct stream_pos; |
4c8bfb7e | 39 | struct format; |
e1151715 | 40 | struct definition; |
56e60373 | 41 | struct ctf_clock; |
4c8bfb7e | 42 | |
64893f33 | 43 | /* type scope */ |
f6625916 | 44 | struct declaration_scope { |
c13cbf74 | 45 | /* Hash table mapping type name GQuark to "struct declaration" */ |
1ee8e81d | 46 | /* Used for both typedef and typealias. */ |
f6625916 MD |
47 | GHashTable *typedef_declarations; |
48 | /* Hash table mapping struct name GQuark to "struct declaration_struct" */ | |
49 | GHashTable *struct_declarations; | |
50 | /* Hash table mapping variant name GQuark to "struct declaration_variant" */ | |
51 | GHashTable *variant_declarations; | |
c13cbf74 | 52 | /* Hash table mapping enum name GQuark to "struct type_enum" */ |
f6625916 MD |
53 | GHashTable *enum_declarations; |
54 | struct declaration_scope *parent_scope; | |
64893f33 MD |
55 | }; |
56 | ||
e1151715 MD |
57 | /* definition scope */ |
58 | struct definition_scope { | |
59 | /* Hash table mapping field name GQuark to "struct definition" */ | |
60 | GHashTable *definitions; | |
61 | struct definition_scope *parent_scope; | |
05c749e5 MD |
62 | /* |
63 | * Complete "path" leading to this definition scope. | |
9e29e16e | 64 | * Includes dynamic scope name '.' field name '.' field name '.' .... |
05c749e5 | 65 | * Array of GQuark elements (which are each separated by dots). |
9e29e16e MD |
66 | * The dynamic scope name can contain dots, and is encoded into |
67 | * a single GQuark. Thus, scope_path[0] returns the GQuark | |
68 | * identifying the dynamic scope. | |
05c749e5 MD |
69 | */ |
70 | GArray *scope_path; /* array of GQuark */ | |
6b71274a MD |
71 | }; |
72 | ||
f6625916 | 73 | struct declaration { |
05628561 | 74 | enum ctf_type_id id; |
fc93b2bd | 75 | size_t alignment; /* type alignment, in bits */ |
e19c3d69 | 76 | int ref; /* number of references to the type */ |
c054553d | 77 | /* |
f6625916 | 78 | * declaration_free called with declaration ref is decremented to 0. |
c054553d | 79 | */ |
f6625916 | 80 | void (*declaration_free)(struct declaration *declaration); |
e1151715 | 81 | struct definition * |
f6625916 | 82 | (*definition_new)(struct declaration *declaration, |
05c749e5 | 83 | struct definition_scope *parent_scope, |
98df1c9f MD |
84 | GQuark field_name, int index, |
85 | const char *root_name); | |
c054553d | 86 | /* |
e1151715 | 87 | * definition_free called with definition ref is decremented to 0. |
e19c3d69 | 88 | */ |
e1151715 | 89 | void (*definition_free)(struct definition *definition); |
c054553d MD |
90 | }; |
91 | ||
e1151715 | 92 | struct definition { |
f6625916 | 93 | struct declaration *declaration; |
05c749e5 | 94 | int index; /* Position of the definition in its container */ |
b1a2f580 | 95 | GQuark name; /* Field name in its container (or 0 if unset) */ |
e1151715 | 96 | int ref; /* number of references to the definition */ |
31262354 | 97 | GQuark path; |
a35173fe | 98 | struct definition_scope *scope; |
fc93b2bd MD |
99 | }; |
100 | ||
c5e74408 MD |
101 | typedef int (*rw_dispatch)(struct stream_pos *pos, |
102 | struct definition *definition); | |
d11e9c49 MD |
103 | |
104 | /* Parent of per-plugin positions */ | |
105 | struct stream_pos { | |
106 | /* read/write dispatch table. Specific to plugin used for stream. */ | |
107 | rw_dispatch *rw_table; /* rw dispatch table */ | |
31262354 | 108 | int (*event_cb)(struct stream_pos *pos, |
764af3f4 | 109 | struct ctf_stream *stream); |
d11e9c49 MD |
110 | }; |
111 | ||
112 | static inline | |
c5e74408 | 113 | int generic_rw(struct stream_pos *pos, struct definition *definition) |
d11e9c49 MD |
114 | { |
115 | enum ctf_type_id dispatch_id = definition->declaration->id; | |
116 | rw_dispatch call; | |
117 | ||
118 | assert(pos->rw_table[dispatch_id] != NULL); | |
119 | call = pos->rw_table[dispatch_id]; | |
c5e74408 | 120 | return call(pos, definition); |
d11e9c49 MD |
121 | } |
122 | ||
81dee1bb MD |
123 | enum ctf_string_encoding { |
124 | CTF_STRING_NONE = 0, | |
125 | CTF_STRING_UTF8, | |
126 | CTF_STRING_ASCII, | |
127 | CTF_STRING_UNKNOWN, | |
128 | }; | |
129 | ||
bed864a7 MD |
130 | /* |
131 | * Because we address in bits, bitfields end up being exactly the same as | |
132 | * integers, except that their read/write functions must be able to deal with | |
133 | * read/write non aligned on CHAR_BIT. | |
134 | */ | |
f6625916 MD |
135 | struct declaration_integer { |
136 | struct declaration p; | |
7fe00194 MD |
137 | size_t len; /* length, in bits. */ |
138 | int byte_order; /* byte order */ | |
139 | int signedness; | |
164078da | 140 | int base; /* Base for pretty-printing: 2, 8, 10, 16 */ |
81dee1bb | 141 | enum ctf_string_encoding encoding; |
56e60373 | 142 | struct ctf_clock *clock; |
fc93b2bd MD |
143 | }; |
144 | ||
e1151715 MD |
145 | struct definition_integer { |
146 | struct definition p; | |
f6625916 | 147 | struct declaration_integer *declaration; |
c054553d MD |
148 | /* Last values read */ |
149 | union { | |
150 | uint64_t _unsigned; | |
151 | int64_t _signed; | |
152 | } value; | |
153 | }; | |
154 | ||
f6625916 MD |
155 | struct declaration_float { |
156 | struct declaration p; | |
157 | struct declaration_integer *sign; | |
158 | struct declaration_integer *mantissa; | |
159 | struct declaration_integer *exp; | |
fc93b2bd | 160 | int byte_order; |
0a46062b | 161 | /* TODO: we might want to express more info about NaN, +inf and -inf */ |
fc93b2bd MD |
162 | }; |
163 | ||
e1151715 MD |
164 | struct definition_float { |
165 | struct definition p; | |
f6625916 | 166 | struct declaration_float *declaration; |
d11e9c49 MD |
167 | struct definition_integer *sign; |
168 | struct definition_integer *mantissa; | |
169 | struct definition_integer *exp; | |
c054553d | 170 | /* Last values read */ |
f72803ca | 171 | double value; |
c054553d MD |
172 | }; |
173 | ||
d65d8abb MD |
174 | /* |
175 | * enum_val_equal assumes that signed and unsigned memory layout overlap. | |
176 | */ | |
177 | struct enum_range { | |
178 | union { | |
179 | int64_t _signed; | |
180 | uint64_t _unsigned; | |
181 | } start; /* lowest range value */ | |
182 | union { | |
183 | int64_t _signed; | |
184 | uint64_t _unsigned; | |
185 | } end; /* highest range value */ | |
186 | }; | |
187 | ||
188 | struct enum_range_to_quark { | |
3122e6f0 | 189 | struct bt_list_head node; |
d65d8abb MD |
190 | struct enum_range range; |
191 | GQuark quark; | |
192 | }; | |
193 | ||
194 | /* | |
195 | * We optimize the common case (range of size 1: single value) by creating a | |
196 | * hash table mapping values to quark sets. We then lookup the ranges to | |
197 | * complete the quark set. | |
198 | * | |
199 | * TODO: The proper structure to hold the range to quark set mapping would be an | |
200 | * interval tree, with O(n) size, O(n*log(n)) build time and O(log(n)) query | |
201 | * time. Using a simple O(n) list search for now for implementation speed and | |
202 | * given that we can expect to have a _relatively_ small number of enumeration | |
203 | * ranges. This might become untrue if we are fed with symbol tables often | |
204 | * required to lookup function names from instruction pointer value. | |
205 | */ | |
448d3cc7 | 206 | struct enum_table { |
d65d8abb | 207 | GHashTable *value_to_quark_set; /* (value, GQuark GArray) */ |
3122e6f0 | 208 | struct bt_list_head range_to_quark; /* (range, GQuark) */ |
d65d8abb | 209 | GHashTable *quark_to_range_set; /* (GQuark, range GArray) */ |
448d3cc7 MD |
210 | }; |
211 | ||
f6625916 MD |
212 | struct declaration_enum { |
213 | struct declaration p; | |
214 | struct declaration_integer *integer_declaration; | |
448d3cc7 | 215 | struct enum_table table; |
fc93b2bd MD |
216 | }; |
217 | ||
e1151715 MD |
218 | struct definition_enum { |
219 | struct definition p; | |
220 | struct definition_integer *integer; | |
f6625916 | 221 | struct declaration_enum *declaration; |
c054553d MD |
222 | /* Last GQuark values read. Keeping a reference on the GQuark array. */ |
223 | GArray *value; | |
224 | }; | |
225 | ||
f6625916 MD |
226 | struct declaration_string { |
227 | struct declaration p; | |
ab4cf058 | 228 | enum ctf_string_encoding encoding; |
c054553d MD |
229 | }; |
230 | ||
e1151715 MD |
231 | struct definition_string { |
232 | struct definition p; | |
f6625916 | 233 | struct declaration_string *declaration; |
e1151715 | 234 | char *value; /* freed at definition_string teardown */ |
d11e9c49 | 235 | size_t len, alloc_len; |
11796b96 MD |
236 | }; |
237 | ||
f6625916 | 238 | struct declaration_field { |
e19c3d69 | 239 | GQuark name; |
f6625916 | 240 | struct declaration *declaration; |
c054553d MD |
241 | }; |
242 | ||
f6625916 MD |
243 | struct declaration_struct { |
244 | struct declaration p; | |
e19c3d69 | 245 | GHashTable *fields_by_name; /* Tuples (field name, field index) */ |
f6625916 MD |
246 | struct declaration_scope *scope; |
247 | GArray *fields; /* Array of declaration_field */ | |
e19c3d69 MD |
248 | }; |
249 | ||
e1151715 MD |
250 | struct definition_struct { |
251 | struct definition p; | |
f6625916 | 252 | struct declaration_struct *declaration; |
b1a2f580 | 253 | GPtrArray *fields; /* Array of pointers to struct definition */ |
c054553d MD |
254 | }; |
255 | ||
d60cb676 | 256 | struct declaration_untagged_variant { |
f6625916 | 257 | struct declaration p; |
c054553d | 258 | GHashTable *fields_by_tag; /* Tuples (field tag, field index) */ |
f6625916 MD |
259 | struct declaration_scope *scope; |
260 | GArray *fields; /* Array of declaration_field */ | |
c054553d MD |
261 | }; |
262 | ||
d60cb676 MD |
263 | struct declaration_variant { |
264 | struct declaration p; | |
265 | struct declaration_untagged_variant *untagged_variant; | |
266 | GArray *tag_name; /* Array of GQuark */ | |
267 | }; | |
268 | ||
269 | /* A variant needs to be tagged to be defined. */ | |
e1151715 MD |
270 | struct definition_variant { |
271 | struct definition p; | |
f6625916 | 272 | struct declaration_variant *declaration; |
e1151715 | 273 | struct definition *enum_tag; |
b1a2f580 MD |
274 | GPtrArray *fields; /* Array of pointers to struct definition */ |
275 | struct definition *current_field; /* Last field read */ | |
11796b96 MD |
276 | }; |
277 | ||
f6625916 MD |
278 | struct declaration_array { |
279 | struct declaration p; | |
11796b96 | 280 | size_t len; |
f6625916 MD |
281 | struct declaration *elem; |
282 | struct declaration_scope *scope; | |
11796b96 MD |
283 | }; |
284 | ||
e1151715 MD |
285 | struct definition_array { |
286 | struct definition p; | |
f6625916 | 287 | struct declaration_array *declaration; |
b1a2f580 | 288 | GPtrArray *elems; /* Array of pointers to struct definition */ |
81dee1bb | 289 | GString *string; /* String for encoded integer children */ |
c054553d MD |
290 | }; |
291 | ||
f6625916 MD |
292 | struct declaration_sequence { |
293 | struct declaration p; | |
98df1c9f | 294 | GArray *length_name; /* Array of GQuark */ |
f6625916 MD |
295 | struct declaration *elem; |
296 | struct declaration_scope *scope; | |
e19c3d69 MD |
297 | }; |
298 | ||
e1151715 MD |
299 | struct definition_sequence { |
300 | struct definition p; | |
f6625916 | 301 | struct declaration_sequence *declaration; |
98df1c9f | 302 | struct definition_integer *length; |
b1a2f580 | 303 | GPtrArray *elems; /* Array of pointers to struct definition */ |
81dee1bb | 304 | GString *string; /* String for encoded integer children */ |
c054553d MD |
305 | }; |
306 | ||
f6625916 MD |
307 | int register_declaration(GQuark declaration_name, |
308 | struct declaration *declaration, | |
309 | struct declaration_scope *scope); | |
310 | struct declaration *lookup_declaration(GQuark declaration_name, | |
78af2bcd | 311 | struct declaration_scope *scope); |
c13cbf74 MD |
312 | |
313 | /* | |
314 | * Type scopes also contain a separate registry for struct, variant and | |
e1151715 | 315 | * enum types. Those register types rather than type definitions, so |
c13cbf74 MD |
316 | * that a named variant can be declared without specifying its target |
317 | * "choice" tag field immediately. | |
318 | */ | |
f6625916 MD |
319 | int register_struct_declaration(GQuark struct_name, |
320 | struct declaration_struct *struct_declaration, | |
321 | struct declaration_scope *scope); | |
322 | struct declaration_struct * | |
323 | lookup_struct_declaration(GQuark struct_name, | |
324 | struct declaration_scope *scope); | |
325 | int register_variant_declaration(GQuark variant_name, | |
a0720417 | 326 | struct declaration_untagged_variant *untagged_variant_declaration, |
f6625916 | 327 | struct declaration_scope *scope); |
a0720417 | 328 | struct declaration_untagged_variant *lookup_variant_declaration(GQuark variant_name, |
f6625916 MD |
329 | struct declaration_scope *scope); |
330 | int register_enum_declaration(GQuark enum_name, | |
331 | struct declaration_enum *enum_declaration, | |
332 | struct declaration_scope *scope); | |
333 | struct declaration_enum * | |
334 | lookup_enum_declaration(GQuark enum_name, | |
335 | struct declaration_scope *scope); | |
336 | ||
337 | struct declaration_scope * | |
338 | new_declaration_scope(struct declaration_scope *parent_scope); | |
339 | void free_declaration_scope(struct declaration_scope *scope); | |
c054553d | 340 | |
c13cbf74 | 341 | /* |
e1151715 MD |
342 | * field_definition is for field definitions. They are registered into |
343 | * definition scopes. | |
c13cbf74 | 344 | */ |
e1151715 | 345 | struct definition * |
a35173fe MD |
346 | lookup_path_definition(GArray *cur_path, /* array of GQuark */ |
347 | GArray *lookup_path, /* array of GQuark */ | |
348 | struct definition_scope *scope); | |
e1151715 MD |
349 | int register_field_definition(GQuark field_name, |
350 | struct definition *definition, | |
351 | struct definition_scope *scope); | |
352 | struct definition_scope * | |
05c749e5 | 353 | new_definition_scope(struct definition_scope *parent_scope, |
98df1c9f | 354 | GQuark field_name, const char *root_name); |
e1151715 | 355 | void free_definition_scope(struct definition_scope *scope); |
4c8bfb7e | 356 | |
98df1c9f MD |
357 | GQuark new_definition_path(struct definition_scope *parent_scope, |
358 | GQuark field_name, const char *root_name); | |
31262354 MD |
359 | |
360 | static inline | |
361 | int compare_definition_path(struct definition *definition, GQuark path) | |
362 | { | |
363 | return definition->path == path; | |
364 | } | |
365 | ||
f6625916 MD |
366 | void declaration_ref(struct declaration *declaration); |
367 | void declaration_unref(struct declaration *declaration); | |
64893f33 | 368 | |
e1151715 MD |
369 | void definition_ref(struct definition *definition); |
370 | void definition_unref(struct definition *definition); | |
698f0fe4 | 371 | |
add40b62 | 372 | struct declaration_integer *integer_declaration_new(size_t len, int byte_order, |
164078da | 373 | int signedness, size_t alignment, |
56e60373 MD |
374 | int base, enum ctf_string_encoding encoding, |
375 | struct ctf_clock *clock); | |
343c801f JD |
376 | uint64_t get_unsigned_int(struct definition *field); |
377 | int64_t get_signed_int(struct definition *field); | |
0a46062b | 378 | |
11d43b90 MD |
379 | /* |
380 | * mantissa_len is the length of the number of bytes represented by the mantissa | |
381 | * (e.g. result of DBL_MANT_DIG). It includes the leading 1. | |
382 | */ | |
add40b62 | 383 | struct declaration_float *float_declaration_new(size_t mantissa_len, |
e19c3d69 MD |
384 | size_t exp_len, int byte_order, |
385 | size_t alignment); | |
0a46062b | 386 | |
448d3cc7 MD |
387 | /* |
388 | * A GQuark can be translated to/from strings with g_quark_from_string() and | |
389 | * g_quark_to_string(). | |
390 | */ | |
47e0f2e2 MD |
391 | |
392 | /* | |
393 | * Returns a GArray of GQuark or NULL. | |
394 | * Caller must release the GArray with g_array_unref(). | |
395 | */ | |
f6625916 MD |
396 | GArray *enum_uint_to_quark_set(const struct declaration_enum *enum_declaration, |
397 | uint64_t v); | |
d65d8abb MD |
398 | |
399 | /* | |
47e0f2e2 | 400 | * Returns a GArray of GQuark or NULL. |
d65d8abb MD |
401 | * Caller must release the GArray with g_array_unref(). |
402 | */ | |
f6625916 | 403 | GArray *enum_int_to_quark_set(const struct declaration_enum *enum_declaration, |
bcdf4cf2 | 404 | int64_t v); |
47e0f2e2 MD |
405 | |
406 | /* | |
407 | * Returns a GArray of struct enum_range or NULL. | |
fdacfb73 MD |
408 | * Callers do _not_ own the returned GArray (and therefore _don't_ need to |
409 | * release it). | |
47e0f2e2 | 410 | */ |
f6625916 MD |
411 | GArray *enum_quark_to_range_set(const struct declaration_enum *enum_declaration, |
412 | GQuark q); | |
413 | void enum_signed_insert(struct declaration_enum *enum_declaration, | |
d65d8abb | 414 | int64_t start, int64_t end, GQuark q); |
f6625916 | 415 | void enum_unsigned_insert(struct declaration_enum *enum_declaration, |
d65d8abb | 416 | uint64_t start, uint64_t end, GQuark q); |
f6625916 MD |
417 | size_t enum_get_nr_enumerators(struct declaration_enum *enum_declaration); |
418 | ||
419 | struct declaration_enum * | |
ab4cf058 | 420 | enum_declaration_new(struct declaration_integer *integer_declaration); |
f6625916 | 421 | |
e397791f MD |
422 | struct declaration_string * |
423 | string_declaration_new(enum ctf_string_encoding encoding); | |
98b68326 | 424 | char *get_string(struct definition *field); |
e397791f | 425 | |
f6625916 | 426 | struct declaration_struct * |
b7e35bad MD |
427 | struct_declaration_new(struct declaration_scope *parent_scope, |
428 | uint64_t min_align); | |
f6625916 MD |
429 | void struct_declaration_add_field(struct declaration_struct *struct_declaration, |
430 | const char *field_name, | |
431 | struct declaration *field_declaration); | |
11796b96 MD |
432 | /* |
433 | * Returns the index of a field within a structure. | |
434 | */ | |
0f980a35 | 435 | int struct_declaration_lookup_field_index(struct declaration_struct *struct_declaration, |
f6625916 | 436 | GQuark field_name); |
11796b96 MD |
437 | /* |
438 | * field returned only valid as long as the field structure is not appended to. | |
439 | */ | |
f6625916 MD |
440 | struct declaration_field * |
441 | struct_declaration_get_field_from_index(struct declaration_struct *struct_declaration, | |
0f980a35 | 442 | int index); |
b1a2f580 | 443 | struct definition * |
0f980a35 MD |
444 | struct_definition_get_field_from_index(struct definition_struct *struct_definition, |
445 | int index); | |
c5e74408 | 446 | int struct_rw(struct stream_pos *pos, struct definition *definition); |
fd3382e8 | 447 | uint64_t struct_declaration_len(struct declaration_struct *struct_declaration); |
11796b96 | 448 | |
c054553d MD |
449 | /* |
450 | * The tag enumeration is validated to ensure that it contains only mappings | |
451 | * from numeric values to a single tag. Overlapping tag value ranges are | |
452 | * therefore forbidden. | |
453 | */ | |
ab4cf058 | 454 | struct declaration_untagged_variant *untagged_variant_declaration_new( |
1934b94f | 455 | struct declaration_scope *parent_scope); |
d60cb676 MD |
456 | struct declaration_variant *variant_declaration_new(struct declaration_untagged_variant *untagged_variant, |
457 | const char *tag); | |
458 | ||
459 | void untagged_variant_declaration_add_field(struct declaration_untagged_variant *untagged_variant_declaration, | |
460 | const char *field_name, | |
461 | struct declaration *field_declaration); | |
f6625916 | 462 | struct declaration_field * |
d60cb676 | 463 | untagged_variant_declaration_get_field_from_tag(struct declaration_untagged_variant *untagged_variant_declaration, |
1934b94f | 464 | GQuark tag); |
c054553d MD |
465 | /* |
466 | * Returns 0 on success, -EPERM on error. | |
467 | */ | |
e1151715 MD |
468 | int variant_definition_set_tag(struct definition_variant *variant, |
469 | struct definition *enum_tag); | |
c054553d MD |
470 | /* |
471 | * Returns the field selected by the current tag value. | |
472 | * field returned only valid as long as the variant structure is not appended | |
473 | * to. | |
474 | */ | |
b1a2f580 | 475 | struct definition *variant_get_current_field(struct definition_variant *variant); |
c5e74408 | 476 | int variant_rw(struct stream_pos *pos, struct definition *definition); |
c054553d | 477 | |
d06d03db | 478 | /* |
f6625916 MD |
479 | * elem_declaration passed as parameter now belongs to the array. No |
480 | * need to free it explicitly. "len" is the number of elements in the | |
481 | * array. | |
d06d03db | 482 | */ |
f6625916 | 483 | struct declaration_array * |
ab4cf058 | 484 | array_declaration_new(size_t len, struct declaration *elem_declaration, |
1934b94f | 485 | struct declaration_scope *parent_scope); |
3838df27 | 486 | uint64_t array_len(struct definition_array *array); |
0f980a35 | 487 | struct definition *array_index(struct definition_array *array, uint64_t i); |
c5e74408 | 488 | int array_rw(struct stream_pos *pos, struct definition *definition); |
343c801f | 489 | GString *get_char_array(struct definition *field); |
11796b96 | 490 | |
d06d03db | 491 | /* |
f6625916 MD |
492 | * int_declaration and elem_declaration passed as parameter now belong |
493 | * to the sequence. No need to free them explicitly. | |
d06d03db | 494 | */ |
f6625916 | 495 | struct declaration_sequence * |
98df1c9f | 496 | sequence_declaration_new(const char *length_name, |
1934b94f MD |
497 | struct declaration *elem_declaration, |
498 | struct declaration_scope *parent_scope); | |
3838df27 | 499 | uint64_t sequence_len(struct definition_sequence *sequence); |
0f980a35 | 500 | struct definition *sequence_index(struct definition_sequence *sequence, uint64_t i); |
c5e74408 | 501 | int sequence_rw(struct stream_pos *pos, struct definition *definition); |
11796b96 | 502 | |
d60cb676 MD |
503 | /* |
504 | * in: path (dot separated), out: q (GArray of GQuark) | |
505 | */ | |
506 | void append_scope_path(const char *path, GArray *q); | |
507 | ||
a35173fe MD |
508 | /* |
509 | * Lookup helpers. | |
510 | */ | |
620961f6 MD |
511 | struct definition *lookup_definition(struct definition *definition, |
512 | const char *field_name); | |
a35173fe MD |
513 | struct definition_integer *lookup_integer(struct definition *definition, |
514 | const char *field_name, | |
515 | int signedness); | |
516 | struct definition_enum *lookup_enum(struct definition *definition, | |
517 | const char *field_name, | |
518 | int signedness); | |
519 | struct definition *lookup_variant(struct definition *definition, | |
520 | const char *field_name); | |
521 | ||
31262354 | 522 | #endif /* _BABELTRACE_TYPES_H */ |