Fix: pretty/print.c: print comma and space after trace name
[babeltrace.git] / plugins / lttng-utils / trace-ir-metadata-field-class-copy.c
CommitLineData
ca9f27f3
FD
1/*
2 * Babeltrace - Trace IR field copy
3 *
4 * Copyright (c) 2015-2019 EfficiOS Inc. and Linux Foundation
5 * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
6 * Copyright (c) 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 */
26
27#define BT_LOG_TAG "PLUGIN-LTTNG-UTILS-DEBUG-INFO-TRACE-IR-METADATA-FC-COPY"
28#include "logging.h"
29
30#include <babeltrace/assert-internal.h>
31#include <babeltrace/common-internal.h>
32#include <babeltrace/compiler-internal.h>
33#include <babeltrace/babeltrace.h>
34
35#include "trace-ir-metadata-copy.h"
36#include "trace-ir-metadata-field-class-copy.h"
37
38/*
39 * This fonction walks througth the nested structures field class to resolve a
40 * field path object. A field path is made of indexes inside possibly nested
41 * structures ultimately leading to a field class.
42 */
43static
44const bt_field_class *walk_field_path(const bt_field_path *fp,
45 const bt_field_class *fc)
46{
47 uint64_t i, fp_index_count;
48 const bt_field_class *curr_fc;
49
50 BT_ASSERT(bt_field_class_get_type(fc) == BT_FIELD_CLASS_TYPE_STRUCTURE);
51 BT_LOGD("Walking field path on field class: fp-addr=%p, fc-addr=%p",
52 fp, fc);
53
54 fp_index_count = bt_field_path_get_index_count(fp);
55 curr_fc = fc;
56 for (i = 0; i < fp_index_count; i++) {
57 const char *fc_name;
58 bt_field_class_type fc_type = bt_field_class_get_type(curr_fc);
59 uint64_t curr_index = bt_field_path_get_index_by_index(fp, i);
60
61 switch (fc_type) {
62 case BT_FIELD_CLASS_TYPE_STRUCTURE:
63 bt_field_class_structure_borrow_member_by_index_const(
64 curr_fc, curr_index, &fc_name, &curr_fc);
65 break;
66 case BT_FIELD_CLASS_TYPE_VARIANT:
67 bt_field_class_variant_borrow_option_by_index_const(
68 curr_fc, curr_index, &fc_name, &curr_fc);
69 break;
70 default:
71 abort();
72 }
73 }
74
75 return curr_fc;
76}
77
78static
79const bt_field_class *resolve_field_path_to_field_class(const bt_field_path *fp,
80 struct trace_ir_metadata_maps *md_maps)
81{
82 struct field_class_resolving_context *fc_resolving_ctx;
83 const bt_field_class *fc;
84 bt_scope fp_scope;
85
86 BT_LOGD("Resolving field path: fp-addr=%p", fp);
87
88 fc_resolving_ctx = md_maps->fc_resolving_ctx;
89 fp_scope = bt_field_path_get_root_scope(fp);
90
91 switch (fp_scope) {
92 case BT_SCOPE_PACKET_CONTEXT:
93 fc = walk_field_path(fp, fc_resolving_ctx->packet_context);
94 break;
95 case BT_SCOPE_EVENT_COMMON_CONTEXT:
96 fc = walk_field_path(fp, fc_resolving_ctx->event_common_context);
97 break;
98 case BT_SCOPE_EVENT_SPECIFIC_CONTEXT:
99 fc = walk_field_path(fp, fc_resolving_ctx->event_specific_context);
100 break;
101 case BT_SCOPE_EVENT_PAYLOAD:
102 fc = walk_field_path(fp, fc_resolving_ctx->event_payload);
103 break;
104 default:
105 abort();
106 }
107
108 return fc;
109}
110
111static inline
112void field_class_integer_set_props(const bt_field_class *input_fc,
113 bt_field_class *output_fc)
114{
115 bt_field_class_integer_set_preferred_display_base(output_fc,
116 bt_field_class_integer_get_preferred_display_base(input_fc));
117 bt_field_class_integer_set_field_value_range(output_fc,
118 bt_field_class_integer_get_field_value_range(input_fc));
119}
120
121static inline
122int field_class_unsigned_integer_copy(
123 struct trace_ir_metadata_maps *md_maps,
124 const bt_field_class *in_field_class,
125 bt_field_class *out_field_class)
126{
127 BT_LOGD("Copying content of unsigned integer field class: "
128 "in-fc-addr=%p, out-fc-addr=%p",
129 in_field_class, out_field_class);
130
131 field_class_integer_set_props(in_field_class, out_field_class);
132
133 BT_LOGD("Copied content of unsigned integer field class: "
134 "in-fc-addr=%p, out-fc-addr=%p",
135 in_field_class, out_field_class);
136 return 0;
137}
138
139static inline
140int field_class_signed_integer_copy(
141 struct trace_ir_metadata_maps *md_maps,
142 const bt_field_class *in_field_class,
143 bt_field_class *out_field_class)
144{
145 BT_LOGD("Copying content of signed integer field class: "
146 "in-fc-addr=%p, out-fc-addr=%p",
147 in_field_class, out_field_class);
148
149 field_class_integer_set_props(in_field_class, out_field_class);
150
151 BT_LOGD("Copied content of signed integer field class: "
152 "in-fc-addr=%p, out-fc-addr=%p",
153 in_field_class, out_field_class);
154 return 0;
155}
156
157BT_HIDDEN
158int field_class_unsigned_enumeration_copy(
159 struct trace_ir_metadata_maps *md_maps,
160 const bt_field_class *in_field_class,
161 bt_field_class *out_field_class)
162{
163 uint64_t i, enum_mapping_count;
164 int ret = 0;
165
166 BT_LOGD("Copying content of unsigned enumeration field class: "
167 "in-fc-addr=%p, out-fc-addr=%p",
168 in_field_class, out_field_class);
169
170 /* Copy properties of the inner integer. */
171 field_class_integer_set_props(in_field_class, out_field_class);
172
173 /* Copy all enumeration entries. */
174 enum_mapping_count = bt_field_class_enumeration_get_mapping_count(in_field_class);
175 for (i = 0; i < enum_mapping_count; i++) {
176 const char *label;
177 const bt_field_class_unsigned_enumeration_mapping_ranges *ranges;
178 uint64_t range_index, range_count;
179
180 /* Get the ranges and the range count. */
181 bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
182 in_field_class, i, &label, &ranges);
183 range_count =
184 bt_field_class_unsigned_enumeration_mapping_ranges_get_range_count(
185 ranges);
186 /*
187 * Iterate over all the ranges to add them to copied field
188 * class.
189 */
190 for (range_index = 0; range_index < range_count; range_index++) {
191 uint64_t lower, upper;
192 bt_field_class_status status;
193 bt_field_class_unsigned_enumeration_mapping_ranges_get_range_by_index(
194 ranges, range_index, &lower, &upper);
195
196 BT_LOGD("Copying range in enumeration field class: "
197 "label=%s, lower=%"PRId64", upper=%"PRId64,
198 label, lower, upper);
199
200 /* Add the label and its range to the copy field class. */
201 status = bt_field_class_unsigned_enumeration_map_range(
202 out_field_class, label, lower, upper);
203
204 if (status != BT_FIELD_CLASS_STATUS_OK) {
205 BT_LOGE_STR("Failed to add range to unsigned "
206 "enumeration.");
207 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_field_class);
208 ret = -1;
209 goto error;
210 }
211 }
212 }
213
214 BT_LOGD("Copied content of unsigned enumeration field class: "
215 "in-fc-addr=%p, out-fc-addr=%p",
216 in_field_class, out_field_class);
217
218error:
219 return ret;
220}
221
222static inline
223int field_class_signed_enumeration_copy(
224 struct trace_ir_metadata_maps *md_maps,
225 const bt_field_class *in_field_class,
226 bt_field_class *out_field_class)
227{
228 uint64_t i, enum_mapping_count;
229 int ret = 0;
230
231 BT_LOGD("Copying content of signed enumeration field class: "
232 "in-fc-addr=%p, out-fc-addr=%p",
233 in_field_class, out_field_class);
234
235 /* Copy properties of the inner integer. */
236 field_class_integer_set_props(in_field_class, out_field_class);
237
238 /* Copy all enumeration entries. */
239 enum_mapping_count =
240 bt_field_class_enumeration_get_mapping_count(in_field_class);
241 for (i = 0; i < enum_mapping_count; i++) {
242 const char *label;
243 const bt_field_class_signed_enumeration_mapping_ranges *ranges;
244 uint64_t range_index, range_count;
245
246 /* Get the ranges and the range count. */
247 bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
248 in_field_class, i, &label, &ranges);
249 range_count =
250 bt_field_class_signed_enumeration_mapping_ranges_get_range_count(
251 ranges);
252 /*
253 * Iterate over all the ranges to add them to copied field
254 * class.
255 */
256 for (range_index = 0; range_index < range_count; range_index++) {
257 int64_t lower, upper;
258 bt_field_class_status status;
259 bt_field_class_signed_enumeration_mapping_ranges_get_range_by_index(
260 ranges, range_index, &lower, &upper);
261
262 BT_LOGD("Copying range in enumeration field class: "
263 "label=%s, lower=%ld, upper=%ld",
264 label, lower, upper);
265
266 /* Add the label and its range to the copy field class. */
267 status = bt_field_class_signed_enumeration_map_range(
268 out_field_class, label, lower, upper);
269 if (status != BT_FIELD_CLASS_STATUS_OK) {
270 BT_LOGE_STR("Failed to add range to signed "
271 "enumeration.");
272 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_field_class);
273 ret = -1;
274 goto error;
275 }
276 }
277 }
278
279 BT_LOGD("Copied content of signed enumeration field class: "
280 "in-fc-addr=%p, out-fc-addr=%p",
281 in_field_class, out_field_class);
282
283error:
284 return ret;
285}
286
287static inline
288int field_class_real_copy(
289 struct trace_ir_metadata_maps *md_maps,
290 const bt_field_class *in_field_class,
291 bt_field_class *out_field_class)
292{
293 BT_LOGD("Copying content of real field class: "
294 "in-fc-addr=%p, out-fc-addr=%p",
295 in_field_class, out_field_class);
296
297 bt_field_class_real_set_is_single_precision(out_field_class,
298 bt_field_class_real_is_single_precision(in_field_class));
299
300 BT_LOGD("Copied content real field class: in-fc-addr=%p, "
301 "out-fc-addr=%p", in_field_class, out_field_class);
302
303 return 0;
304}
305
306static inline
307int field_class_structure_copy(
308 struct trace_ir_metadata_maps *md_maps,
309 const bt_field_class *in_field_class,
310 bt_field_class *out_field_class)
311{
312 uint64_t i, struct_member_count;
313 bt_field_class_status status;
314 int ret = 0;
315
316 BT_LOGD("Copying content of structure field class: "
317 "in-fc-addr=%p, out-fc-addr=%p",
318 in_field_class, out_field_class);
319 /* Get the number of member in that struct. */
320 struct_member_count =
321 bt_field_class_structure_get_member_count(in_field_class);
322
323 /* Iterate over all the members of the struct. */
324 for (i = 0; i < struct_member_count; i++) {
325 const char *member_name;
326 const bt_field_class *member_fc;
327 bt_field_class *out_member_field_class;
328
329 bt_field_class_structure_borrow_member_by_index_const(
330 in_field_class, i, &member_name, &member_fc);
331 BT_LOGD("Copying structure field class's field: "
332 "index=%" PRId64 ", "
333 "member-fc-addr=%p, field-name=\"%s\"",
334 i, member_fc, member_name);
335
336 out_member_field_class = create_field_class_copy(md_maps,
337 member_fc);
338 if (!out_member_field_class) {
339 BT_LOGE("Cannot copy structure field class's field: "
340 "index=%" PRId64 ", "
341 "field-fc-addr=%p, field-name=\"%s\"",
342 i, member_fc, member_name);
343 ret = -1;
344 goto error;
345 }
346 ret = copy_field_class_content(md_maps, member_fc,
347 out_member_field_class);
348 if (ret) {
349 goto error;
350 }
351
352 status = bt_field_class_structure_append_member(out_field_class,
353 member_name, out_member_field_class);
354 if (status != BT_FIELD_CLASS_STATUS_OK) {
355 BT_LOGE("Cannot append structure field class's field: "
356 "index=%" PRId64 ", "
357 "field-fc-addr=%p, field-name=\"%s\"",
358 i, member_fc, member_name);
359 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_member_field_class);
360 ret = -1;
361 goto error;
362 }
363 }
364
365 BT_LOGD("Copied structure field class: original-fc-addr=%p, copy-fc-addr=%p",
366 in_field_class, out_field_class);
367
368error:
369 return ret;
370}
371
372static inline
373int field_class_variant_copy(
374 struct trace_ir_metadata_maps *md_maps,
375 const bt_field_class *in_field_class,
376 bt_field_class *out_field_class)
377{
378 bt_field_class *out_tag_field_class;
379 uint64_t i, variant_option_count;
380 const bt_field_path *tag_fp;
381 const bt_field_class *tag_fc;
382 int ret = 0;
383
384 BT_LOGD("Copying content of variant field class: "
385 "in-fc-addr=%p, out-fc-addr=%p",
386 in_field_class, out_field_class);
387
388 tag_fp = bt_field_class_variant_borrow_selector_field_path_const(
389 in_field_class);
390 if (tag_fp) {
391 tag_fc = resolve_field_path_to_field_class(tag_fp,
392 md_maps);
393
394 out_tag_field_class = g_hash_table_lookup(
395 md_maps->field_class_map, tag_fc);
396 if (!out_tag_field_class) {
397 BT_LOGE_STR("Cannot find the tag field class.");
398 ret = -1;
399 goto error;
400 }
401 bt_field_class_variant_set_selector_field_class(out_field_class,
402 out_tag_field_class);
403 }
404
405 variant_option_count =
406 bt_field_class_variant_get_option_count(in_field_class);
407 for (i = 0; i < variant_option_count; i++) {
408 const bt_field_class *option;
409 const char *option_name;
410 bt_field_class *out_option_field_class;
411 bt_field_class_status status;
412
413 bt_field_class_variant_borrow_option_by_index_const(in_field_class,
414 i, &option_name, &option);
415
416 out_option_field_class = create_field_class_copy_internal(
417 md_maps, option);
418 if (!out_option_field_class) {
419 BT_LOGE_STR("Cannot copy field class.");
420 ret = -1;
421 goto error;
422 }
423 ret = copy_field_class_content_internal(md_maps, option,
424 out_option_field_class);
425 if (ret) {
426 BT_LOGE_STR("Error copying content of option variant "
427 "field class'");
428 goto error;
429 }
430
431 status = bt_field_class_variant_append_option(
432 out_field_class, option_name,
433 out_option_field_class);
434 if (status != BT_FIELD_CLASS_STATUS_OK) {
435 BT_LOGE_STR("Cannot append option to variant field class'");
436 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class);
437 ret = -1;
438 goto error;
439 }
440 }
441
442 BT_LOGD("Copied content of variant field class: in-fc-addr=%p, "
443 "out-fc-addr=%p", in_field_class, out_field_class);
444
445error:
446 return ret;
447}
448
449static inline
450int field_class_static_array_copy(
451 struct trace_ir_metadata_maps *md_maps,
452 const bt_field_class *in_field_class,
453 bt_field_class *out_field_class)
454{
455 BT_LOGD("Copying content of static array field class: in-fc-addr=%p, "
456 "out-fc-addr=%p", in_field_class, out_field_class);
457 /*
458 * There is no content to copy. Keep this function call anyway for
459 * logging purposes.
460 */
461 BT_LOGD("Copied content of static array field class: in-fc-addr=%p, "
462 "out-fc-addr=%p", in_field_class, out_field_class);
463
464 return 0;
465}
466
467static inline
468int field_class_dynamic_array_copy(
469 struct trace_ir_metadata_maps *md_maps,
470 const bt_field_class *in_field_class,
471 bt_field_class *out_field_class)
472{
3b40fbf9 473 const bt_field_class *len_fc;
ca9f27f3
FD
474 const bt_field_path *len_fp;
475 bt_field_class_status status;
476 bt_field_class *out_len_field_class;
477 int ret = 0;
478
479 BT_LOGD("Copying content of dynamic array field class: "
480 "in-fc-addr=%p, out-fc-addr=%p",
481 in_field_class, out_field_class);
482
ca9f27f3
FD
483 len_fp = bt_field_class_dynamic_array_borrow_length_field_path_const(
484 in_field_class);
485
486 if (len_fp) {
487 BT_LOGD("Copying dynamic array length field class using "
488 "field path: in-len-fp=%p", len_fp);
489 len_fc = resolve_field_path_to_field_class(
490 len_fp, md_maps);
491 out_len_field_class = g_hash_table_lookup(
492 md_maps->field_class_map, len_fc);
493 if (!out_len_field_class) {
494 BT_LOGE_STR("Cannot find the output matching length"
495 "field class.");
496 ret = -1;
497 goto error;
498 }
499
500 status = bt_field_class_dynamic_array_set_length_field_class(
501 out_field_class, out_len_field_class);
502 if (status != BT_FIELD_CLASS_STATUS_OK) {
503 BT_LOGE_STR("Cannot set dynamic array field class' "
504 "length field class.");
505 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_len_field_class);
506 ret = -1;
507 goto error;
508 }
509 }
510
511 BT_LOGD("Copied dynamic array field class: in-fc-addr=%p, "
512 "out-fc-addr=%p", in_field_class, out_field_class);
513
514error:
515 return ret;
516}
517
518static inline
519int field_class_string_copy(struct trace_ir_metadata_maps *md_maps,
520 const bt_field_class *in_field_class,
521 bt_field_class *out_field_class)
522{
523 BT_LOGD("Copying content of string field class: in-fc-addr=%p, "
524 "out-fc-addr=%p", in_field_class, out_field_class);
525 /*
526 * There is no content to copy. Keep this function call anyway for
527 * logging purposes.
528 */
529 BT_LOGD("Copied content of string field class: in-fc-addr=%p, "
530 "out-fc-addr=%p", in_field_class, out_field_class);
531
532 return 0;
533}
534
535static
536bt_field_class *copy_field_class_array_element(struct trace_ir_metadata_maps *md_maps,
537 const bt_field_class *in_elem_fc)
538{
539 int ret;
540 bt_field_class *out_elem_fc =
541 create_field_class_copy_internal(md_maps, in_elem_fc);
542 if (!out_elem_fc) {
543 BT_LOGE("Error creating output elem field class "
544 "from input elem field class for static array: "
545 "in-fc-addr=%p", in_elem_fc);
546 goto error;
547 }
548
549 ret = copy_field_class_content_internal(md_maps, in_elem_fc, out_elem_fc);
550 if (ret) {
551 BT_LOGE("Error creating output elem field class "
552 "from input elem field class for static array: "
553 "in-fc-addr=%p", in_elem_fc);
554 BT_FIELD_CLASS_PUT_REF_AND_RESET(out_elem_fc);
555 goto error;
556 }
557
558error:
559 return out_elem_fc;
560}
561
562BT_HIDDEN
563bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *md_maps,
564 const bt_field_class *in_field_class)
565{
566 bt_field_class *out_field_class = NULL;
567
568 BT_LOGD("Creating bare field class based on field class: in-fc-addr=%p",
569 in_field_class);
570
571 switch(bt_field_class_get_type(in_field_class)) {
572 case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
573 out_field_class = bt_field_class_unsigned_integer_create(
574 md_maps->output_trace_class);
575 break;
576 case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
577 out_field_class = bt_field_class_signed_integer_create(
578 md_maps->output_trace_class);
579 break;
580 case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
581 out_field_class = bt_field_class_unsigned_enumeration_create(
582 md_maps->output_trace_class);
583 break;
584 case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION:
585 out_field_class = bt_field_class_signed_enumeration_create(
586 md_maps->output_trace_class);
587 break;
588 case BT_FIELD_CLASS_TYPE_REAL:
589 out_field_class = bt_field_class_real_create(
590 md_maps->output_trace_class);
591 break;
592 case BT_FIELD_CLASS_TYPE_STRING:
593 out_field_class = bt_field_class_string_create(
594 md_maps->output_trace_class);
595 break;
596 case BT_FIELD_CLASS_TYPE_STRUCTURE:
597 out_field_class = bt_field_class_structure_create(
598 md_maps->output_trace_class);
599 break;
600 case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
601 {
602 const bt_field_class *in_elem_fc =
603 bt_field_class_array_borrow_element_field_class_const(
604 in_field_class);
605 uint64_t array_len =
606 bt_field_class_static_array_get_length(in_field_class);
607
608 bt_field_class *out_elem_fc = copy_field_class_array_element(
609 md_maps, in_elem_fc);
610 if (!out_elem_fc) {
611 out_field_class = NULL;
612 goto error;
613 }
614
615 out_field_class = bt_field_class_static_array_create(
616 md_maps->output_trace_class,
617 out_elem_fc, array_len);
618 break;
619 }
620 case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
621 {
622 const bt_field_class *in_elem_fc =
623 bt_field_class_array_borrow_element_field_class_const(
624 in_field_class);
625
626 bt_field_class *out_elem_fc = copy_field_class_array_element(
627 md_maps, in_elem_fc);
628 if (!out_elem_fc) {
629 out_field_class = NULL;
630 goto error;
631 }
632
633 out_field_class = bt_field_class_dynamic_array_create(
634 md_maps->output_trace_class,
635 out_elem_fc);
636 break;
637 }
638 case BT_FIELD_CLASS_TYPE_VARIANT:
639 out_field_class = bt_field_class_variant_create(
640 md_maps->output_trace_class);
641 break;
642 default:
643 abort();
644 }
645
646 /*
647 * Add mapping from in_field_class to out_field_class. This simplifies
648 * the resolution of field paths in variant and dynamic array field
649 * classes.
650 */
651 g_hash_table_insert(md_maps->field_class_map,
652 (gpointer) in_field_class, out_field_class);
653
654error:
655 if(out_field_class){
656 BT_LOGD("Created bare field class based on field class: in-fc-addr=%p, "
657 "out-fc-addr=%p", in_field_class, out_field_class);
658 } else {
659 BT_LOGE("Error creating output field class from input field "
660 "class: in-fc-addr=%p", in_field_class);
661 }
662
663 return out_field_class;
664}
665
666BT_HIDDEN
667int copy_field_class_content_internal(
668 struct trace_ir_metadata_maps *md_maps,
669 const bt_field_class *in_field_class,
670 bt_field_class *out_field_class)
671{
672 int ret = 0;
673 switch(bt_field_class_get_type(in_field_class)) {
674 case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
675 ret = field_class_unsigned_integer_copy(md_maps,
676 in_field_class, out_field_class);
677 break;
678 case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
679 ret = field_class_signed_integer_copy(md_maps,
680 in_field_class, out_field_class);
681 break;
682 case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
683 ret = field_class_unsigned_enumeration_copy(md_maps,
684 in_field_class, out_field_class);
685 break;
686 case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION:
687 ret = field_class_signed_enumeration_copy(md_maps,
688 in_field_class, out_field_class);
689 break;
690 case BT_FIELD_CLASS_TYPE_REAL:
691 ret = field_class_real_copy(md_maps,
692 in_field_class, out_field_class);
693 break;
694 case BT_FIELD_CLASS_TYPE_STRING:
695 ret = field_class_string_copy(md_maps,
696 in_field_class, out_field_class);
697 break;
698 case BT_FIELD_CLASS_TYPE_STRUCTURE:
699 ret = field_class_structure_copy(md_maps,
700 in_field_class, out_field_class);
701 break;
702 case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
703 ret = field_class_static_array_copy(md_maps,
704 in_field_class, out_field_class);
705 break;
706 case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
707 ret = field_class_dynamic_array_copy(md_maps,
708 in_field_class, out_field_class);
709 break;
710 case BT_FIELD_CLASS_TYPE_VARIANT:
711 ret = field_class_variant_copy(md_maps,
712 in_field_class, out_field_class);
713 break;
714 default:
715 abort();
716 }
717
718 return ret;
719}
This page took 0.050618 seconds and 4 git commands to generate.