Commit | Line | Data |
---|---|---|
58f6d595 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 | ||
475e740e | 27 | #define BT_COMP_LOG_SELF_COMP (md_maps->self_comp) |
a07aba4f | 28 | #define BT_LOG_OUTPUT_LEVEL (md_maps->log_level) |
b03487ab | 29 | #define BT_LOG_TAG "PLUGIN/FLT.LTTNG-UTILS.DEBUG-INFO/TRACE-IR-META-FC-COPY" |
3fa1b6a3 | 30 | #include "logging/comp-logging.h" |
58f6d595 | 31 | |
57952005 MJ |
32 | #include "common/assert.h" |
33 | #include "common/common.h" | |
34 | #include "compat/compiler.h" | |
71c5da58 | 35 | #include <babeltrace2/babeltrace.h> |
58f6d595 FD |
36 | |
37 | #include "trace-ir-metadata-copy.h" | |
38 | #include "trace-ir-metadata-field-class-copy.h" | |
39 | ||
40 | /* | |
41 | * This fonction walks througth the nested structures field class to resolve a | |
42 | * field path object. A field path is made of indexes inside possibly nested | |
43 | * structures ultimately leading to a field class. | |
44 | */ | |
45 | static | |
a07aba4f PP |
46 | const bt_field_class *walk_field_path(struct trace_ir_metadata_maps *md_maps, |
47 | const bt_field_path *fp, const bt_field_class *fc) | |
58f6d595 | 48 | { |
1d4afa5f | 49 | uint64_t i, fp_item_count; |
58f6d595 FD |
50 | const bt_field_class *curr_fc; |
51 | ||
52 | BT_ASSERT(bt_field_class_get_type(fc) == BT_FIELD_CLASS_TYPE_STRUCTURE); | |
475e740e | 53 | BT_COMP_LOGD("Walking field path on field class: fp-addr=%p, fc-addr=%p", |
9a51bfb2 | 54 | fp, fc); |
58f6d595 | 55 | |
1d4afa5f | 56 | fp_item_count = bt_field_path_get_item_count(fp); |
58f6d595 | 57 | curr_fc = fc; |
1d4afa5f | 58 | for (i = 0; i < fp_item_count; i++) { |
58f6d595 | 59 | bt_field_class_type fc_type = bt_field_class_get_type(curr_fc); |
1d4afa5f PP |
60 | const bt_field_path_item *fp_item = |
61 | bt_field_path_borrow_item_by_index_const(fp, i); | |
58f6d595 | 62 | |
94847783 | 63 | if (fc_type == BT_FIELD_CLASS_TYPE_STRUCTURE) { |
1d4afa5f PP |
64 | const bt_field_class_structure_member *member; |
65 | ||
66 | BT_ASSERT(bt_field_path_item_get_type(fp_item) == | |
67 | BT_FIELD_PATH_ITEM_TYPE_INDEX); | |
68 | member = bt_field_class_structure_borrow_member_by_index_const( | |
69 | curr_fc, | |
70 | bt_field_path_item_index_get_index(fp_item)); | |
e24f271a PP |
71 | curr_fc = bt_field_class_structure_member_borrow_field_class_const( |
72 | member); | |
94847783 | 73 | } else if (bt_field_class_type_is(fc_type, BT_FIELD_CLASS_TYPE_OPTION)) { |
978237e9 PP |
74 | BT_ASSERT(bt_field_path_item_get_type(fp_item) == |
75 | BT_FIELD_PATH_ITEM_TYPE_CURRENT_OPTION_CONTENT); | |
76 | curr_fc = bt_field_class_option_borrow_field_class_const( | |
77 | curr_fc); | |
94847783 PP |
78 | |
79 | } else if (bt_field_class_type_is(fc_type, BT_FIELD_CLASS_TYPE_VARIANT)) { | |
1d4afa5f PP |
80 | const bt_field_class_variant_option *option; |
81 | ||
82 | BT_ASSERT(bt_field_path_item_get_type(fp_item) == | |
83 | BT_FIELD_PATH_ITEM_TYPE_INDEX); | |
84 | option = bt_field_class_variant_borrow_option_by_index_const( | |
85 | curr_fc, | |
86 | bt_field_path_item_index_get_index(fp_item)); | |
e24f271a PP |
87 | curr_fc = bt_field_class_variant_option_borrow_field_class_const( |
88 | option); | |
58f6d595 | 89 | break; |
94847783 | 90 | } else if (bt_field_class_type_is(fc_type, BT_FIELD_CLASS_TYPE_ARRAY)) { |
1d4afa5f PP |
91 | BT_ASSERT(bt_field_path_item_get_type(fp_item) == |
92 | BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT); | |
93 | curr_fc = bt_field_class_array_borrow_element_field_class_const( | |
94 | curr_fc); | |
95 | break; | |
94847783 | 96 | } else { |
58f6d595 FD |
97 | abort(); |
98 | } | |
99 | } | |
100 | ||
101 | return curr_fc; | |
102 | } | |
103 | ||
104 | static | |
105 | const bt_field_class *resolve_field_path_to_field_class(const bt_field_path *fp, | |
106 | struct trace_ir_metadata_maps *md_maps) | |
107 | { | |
108 | struct field_class_resolving_context *fc_resolving_ctx; | |
109 | const bt_field_class *fc; | |
056995e5 | 110 | bt_field_path_scope fp_scope; |
58f6d595 | 111 | |
475e740e | 112 | BT_COMP_LOGD("Resolving field path: fp-addr=%p", fp); |
58f6d595 FD |
113 | |
114 | fc_resolving_ctx = md_maps->fc_resolving_ctx; | |
115 | fp_scope = bt_field_path_get_root_scope(fp); | |
116 | ||
117 | switch (fp_scope) { | |
056995e5 | 118 | case BT_FIELD_PATH_SCOPE_PACKET_CONTEXT: |
a07aba4f PP |
119 | fc = walk_field_path(md_maps, fp, |
120 | fc_resolving_ctx->packet_context); | |
58f6d595 | 121 | break; |
056995e5 | 122 | case BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT: |
a07aba4f PP |
123 | fc = walk_field_path(md_maps, fp, |
124 | fc_resolving_ctx->event_common_context); | |
58f6d595 | 125 | break; |
056995e5 | 126 | case BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT: |
a07aba4f PP |
127 | fc = walk_field_path(md_maps, fp, |
128 | fc_resolving_ctx->event_specific_context); | |
58f6d595 | 129 | break; |
056995e5 | 130 | case BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD: |
a07aba4f PP |
131 | fc = walk_field_path(md_maps, fp, |
132 | fc_resolving_ctx->event_payload); | |
58f6d595 FD |
133 | break; |
134 | default: | |
135 | abort(); | |
136 | } | |
137 | ||
138 | return fc; | |
139 | } | |
140 | ||
141 | static inline | |
142 | void field_class_integer_set_props(const bt_field_class *input_fc, | |
143 | bt_field_class *output_fc) | |
144 | { | |
145 | bt_field_class_integer_set_preferred_display_base(output_fc, | |
9a51bfb2 | 146 | bt_field_class_integer_get_preferred_display_base(input_fc)); |
58f6d595 | 147 | bt_field_class_integer_set_field_value_range(output_fc, |
9a51bfb2 | 148 | bt_field_class_integer_get_field_value_range(input_fc)); |
58f6d595 FD |
149 | } |
150 | ||
41bdd7c1 | 151 | static inline |
9a51bfb2 | 152 | int field_class_bool_copy(struct trace_ir_metadata_maps *md_maps, |
41bdd7c1 PP |
153 | const bt_field_class *in_field_class, |
154 | bt_field_class *out_field_class) | |
155 | { | |
156 | BT_COMP_LOGD("Copying content of boolean field class: " | |
9a51bfb2 FD |
157 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
158 | /* | |
159 | * There is no content to copy. Keep this function call anyway for | |
160 | * logging purposes. | |
161 | */ | |
41bdd7c1 | 162 | BT_COMP_LOGD("Copied content of boolean field class: " |
9a51bfb2 | 163 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
41bdd7c1 PP |
164 | return 0; |
165 | } | |
166 | ||
f5f2c882 PP |
167 | static inline |
168 | int field_class_bit_array_copy( | |
169 | struct trace_ir_metadata_maps *md_maps, | |
170 | const bt_field_class *in_field_class, | |
171 | bt_field_class *out_field_class) | |
172 | { | |
173 | BT_COMP_LOGD("Copying content of bit array field class: " | |
9a51bfb2 FD |
174 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
175 | /* | |
176 | * There is no content to copy. Keep this function call anyway for | |
177 | * logging purposes. | |
178 | */ | |
f5f2c882 | 179 | BT_COMP_LOGD("Copied content of bit array field class: " |
9a51bfb2 | 180 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
f5f2c882 PP |
181 | return 0; |
182 | } | |
183 | ||
58f6d595 FD |
184 | static inline |
185 | int field_class_unsigned_integer_copy( | |
186 | struct trace_ir_metadata_maps *md_maps, | |
187 | const bt_field_class *in_field_class, | |
188 | bt_field_class *out_field_class) | |
189 | { | |
475e740e | 190 | BT_COMP_LOGD("Copying content of unsigned integer field class: " |
9a51bfb2 | 191 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
58f6d595 FD |
192 | |
193 | field_class_integer_set_props(in_field_class, out_field_class); | |
194 | ||
475e740e | 195 | BT_COMP_LOGD("Copied content of unsigned integer field class: " |
9a51bfb2 | 196 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
58f6d595 FD |
197 | return 0; |
198 | } | |
199 | ||
200 | static inline | |
201 | int field_class_signed_integer_copy( | |
202 | struct trace_ir_metadata_maps *md_maps, | |
203 | const bt_field_class *in_field_class, | |
204 | bt_field_class *out_field_class) | |
205 | { | |
475e740e | 206 | BT_COMP_LOGD("Copying content of signed integer field class: " |
9a51bfb2 | 207 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
58f6d595 FD |
208 | |
209 | field_class_integer_set_props(in_field_class, out_field_class); | |
210 | ||
475e740e | 211 | BT_COMP_LOGD("Copied content of signed integer field class: " |
9a51bfb2 | 212 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
58f6d595 FD |
213 | return 0; |
214 | } | |
215 | ||
216 | BT_HIDDEN | |
217 | int field_class_unsigned_enumeration_copy( | |
218 | struct trace_ir_metadata_maps *md_maps, | |
219 | const bt_field_class *in_field_class, | |
220 | bt_field_class *out_field_class) | |
221 | { | |
222 | uint64_t i, enum_mapping_count; | |
223 | int ret = 0; | |
224 | ||
475e740e | 225 | BT_COMP_LOGD("Copying content of unsigned enumeration field class: " |
9a51bfb2 | 226 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
58f6d595 FD |
227 | |
228 | /* Copy properties of the inner integer. */ | |
229 | field_class_integer_set_props(in_field_class, out_field_class); | |
230 | ||
231 | /* Copy all enumeration entries. */ | |
9a51bfb2 FD |
232 | enum_mapping_count = bt_field_class_enumeration_get_mapping_count( |
233 | in_field_class); | |
58f6d595 FD |
234 | for (i = 0; i < enum_mapping_count; i++) { |
235 | const char *label; | |
02b61fe0 | 236 | const bt_integer_range_set_unsigned *range_set; |
60bbfc7c | 237 | const bt_field_class_enumeration_unsigned_mapping *u_mapping; |
b6baf3bb | 238 | const bt_field_class_enumeration_mapping *mapping; |
58f6d595 | 239 | |
60bbfc7c | 240 | u_mapping = bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const( |
9a51bfb2 | 241 | in_field_class, i); |
60bbfc7c | 242 | mapping = bt_field_class_enumeration_unsigned_mapping_as_mapping_const( |
b6baf3bb | 243 | u_mapping); |
02b61fe0 | 244 | label = bt_field_class_enumeration_mapping_get_label(mapping); |
60bbfc7c | 245 | range_set = bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const( |
02b61fe0 | 246 | u_mapping); |
60bbfc7c | 247 | ret = bt_field_class_enumeration_unsigned_add_mapping( |
02b61fe0 PP |
248 | out_field_class, label, range_set); |
249 | if (ret) { | |
250 | goto error; | |
58f6d595 FD |
251 | } |
252 | } | |
253 | ||
475e740e | 254 | BT_COMP_LOGD("Copied content of unsigned enumeration field class: " |
9a51bfb2 | 255 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
58f6d595 FD |
256 | |
257 | error: | |
258 | return ret; | |
259 | } | |
260 | ||
261 | static inline | |
262 | int field_class_signed_enumeration_copy( | |
263 | struct trace_ir_metadata_maps *md_maps, | |
264 | const bt_field_class *in_field_class, | |
265 | bt_field_class *out_field_class) | |
266 | { | |
267 | uint64_t i, enum_mapping_count; | |
268 | int ret = 0; | |
269 | ||
475e740e | 270 | BT_COMP_LOGD("Copying content of signed enumeration field class: " |
9a51bfb2 | 271 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
58f6d595 FD |
272 | |
273 | /* Copy properties of the inner integer. */ | |
274 | field_class_integer_set_props(in_field_class, out_field_class); | |
275 | ||
276 | /* Copy all enumeration entries. */ | |
277 | enum_mapping_count = | |
278 | bt_field_class_enumeration_get_mapping_count(in_field_class); | |
279 | for (i = 0; i < enum_mapping_count; i++) { | |
280 | const char *label; | |
02b61fe0 | 281 | const bt_integer_range_set_signed *range_set; |
60bbfc7c | 282 | const bt_field_class_enumeration_signed_mapping *s_mapping; |
b6baf3bb | 283 | const bt_field_class_enumeration_mapping *mapping; |
58f6d595 | 284 | |
60bbfc7c | 285 | s_mapping = bt_field_class_enumeration_signed_borrow_mapping_by_index_const( |
9a51bfb2 | 286 | in_field_class, i); |
60bbfc7c | 287 | mapping = bt_field_class_enumeration_signed_mapping_as_mapping_const( |
02b61fe0 PP |
288 | s_mapping); |
289 | label = bt_field_class_enumeration_mapping_get_label(mapping); | |
60bbfc7c | 290 | range_set = bt_field_class_enumeration_signed_mapping_borrow_ranges_const( |
02b61fe0 | 291 | s_mapping); |
60bbfc7c | 292 | ret = bt_field_class_enumeration_signed_add_mapping( |
02b61fe0 PP |
293 | out_field_class, label, range_set); |
294 | if (ret) { | |
295 | goto error; | |
58f6d595 FD |
296 | } |
297 | } | |
298 | ||
475e740e | 299 | BT_COMP_LOGD("Copied content of signed enumeration field class: " |
9a51bfb2 | 300 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
58f6d595 FD |
301 | |
302 | error: | |
303 | return ret; | |
304 | } | |
305 | ||
306 | static inline | |
76276a81 | 307 | int field_class_single_precision_real_copy( |
58f6d595 FD |
308 | struct trace_ir_metadata_maps *md_maps, |
309 | const bt_field_class *in_field_class, | |
310 | bt_field_class *out_field_class) | |
311 | { | |
76276a81 FD |
312 | BT_COMP_LOGD("Copying content of single-precision real field class: " |
313 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); | |
58f6d595 | 314 | |
76276a81 FD |
315 | BT_COMP_LOGD("Copied content single-precision real field class:" |
316 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); | |
58f6d595 | 317 | |
76276a81 FD |
318 | return 0; |
319 | } | |
320 | ||
321 | static inline | |
322 | int field_class_double_precision_real_copy( | |
323 | struct trace_ir_metadata_maps *md_maps, | |
324 | const bt_field_class *in_field_class, | |
325 | bt_field_class *out_field_class) | |
326 | { | |
327 | BT_COMP_LOGD("Copying content of double-precision real field class: " | |
328 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); | |
329 | ||
330 | BT_COMP_LOGD("Copied content double-precision real field class:" | |
331 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); | |
58f6d595 FD |
332 | |
333 | return 0; | |
334 | } | |
335 | ||
336 | static inline | |
337 | int field_class_structure_copy( | |
338 | struct trace_ir_metadata_maps *md_maps, | |
339 | const bt_field_class *in_field_class, | |
340 | bt_field_class *out_field_class) | |
341 | { | |
342 | uint64_t i, struct_member_count; | |
58f6d595 FD |
343 | int ret = 0; |
344 | ||
475e740e | 345 | BT_COMP_LOGD("Copying content of structure field class: " |
9a51bfb2 | 346 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
58f6d595 FD |
347 | /* Get the number of member in that struct. */ |
348 | struct_member_count = | |
349 | bt_field_class_structure_get_member_count(in_field_class); | |
350 | ||
351 | /* Iterate over all the members of the struct. */ | |
352 | for (i = 0; i < struct_member_count; i++) { | |
84ff66df PP |
353 | const bt_field_class_structure_member *in_member; |
354 | bt_field_class_structure_member *out_member; | |
58f6d595 | 355 | const char *member_name; |
84ff66df | 356 | const bt_field_class *in_member_fc; |
58f6d595 FD |
357 | bt_field_class *out_member_field_class; |
358 | ||
84ff66df | 359 | in_member = bt_field_class_structure_borrow_member_by_index_const( |
e24f271a | 360 | in_field_class, i); |
84ff66df PP |
361 | in_member_fc = bt_field_class_structure_member_borrow_field_class_const( |
362 | in_member); | |
363 | member_name = bt_field_class_structure_member_get_name(in_member); | |
475e740e | 364 | BT_COMP_LOGD("Copying structure field class's field: " |
9a51bfb2 | 365 | "index=%" PRId64 ", member-fc-addr=%p, field-name=\"%s\"", |
84ff66df | 366 | i, in_member_fc, member_name); |
58f6d595 FD |
367 | |
368 | out_member_field_class = create_field_class_copy(md_maps, | |
84ff66df | 369 | in_member_fc); |
58f6d595 | 370 | if (!out_member_field_class) { |
475e740e | 371 | BT_COMP_LOGE("Cannot copy structure field class's field: " |
9a51bfb2 | 372 | "index=%" PRId64 ", field-fc-addr=%p, field-name=\"%s\"", |
84ff66df | 373 | i, in_member_fc, member_name); |
58f6d595 FD |
374 | ret = -1; |
375 | goto error; | |
376 | } | |
84ff66df | 377 | ret = copy_field_class_content(md_maps, in_member_fc, |
58f6d595 FD |
378 | out_member_field_class); |
379 | if (ret) { | |
380 | goto error; | |
381 | } | |
382 | ||
fb25b9e3 PP |
383 | if (bt_field_class_structure_append_member(out_field_class, |
384 | member_name, out_member_field_class) != | |
385 | BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK) { | |
475e740e | 386 | BT_COMP_LOGE("Cannot append structure field class's field: " |
58f6d595 FD |
387 | "index=%" PRId64 ", " |
388 | "field-fc-addr=%p, field-name=\"%s\"", | |
84ff66df | 389 | i, in_member_fc, member_name); |
58f6d595 FD |
390 | BT_FIELD_CLASS_PUT_REF_AND_RESET(out_member_field_class); |
391 | ret = -1; | |
392 | goto error; | |
393 | } | |
84ff66df PP |
394 | |
395 | out_member = bt_field_class_structure_borrow_member_by_index( | |
396 | out_field_class, i); | |
397 | BT_ASSERT(out_member); | |
398 | ||
399 | /* | |
400 | * Safe to use the same value object because it's frozen | |
401 | * at this point. | |
402 | */ | |
403 | bt_field_class_structure_member_set_user_attributes( | |
404 | out_member, | |
405 | bt_field_class_structure_member_borrow_user_attributes_const( | |
406 | in_member)); | |
58f6d595 FD |
407 | } |
408 | ||
475e740e | 409 | BT_COMP_LOGD("Copied structure field class: original-fc-addr=%p, copy-fc-addr=%p", |
58f6d595 FD |
410 | in_field_class, out_field_class); |
411 | ||
412 | error: | |
413 | return ret; | |
414 | } | |
415 | ||
416 | static inline | |
417 | int field_class_variant_copy( | |
418 | struct trace_ir_metadata_maps *md_maps, | |
419 | const bt_field_class *in_field_class, | |
420 | bt_field_class *out_field_class) | |
421 | { | |
98d2f974 | 422 | bt_field_class *out_tag_field_class = NULL; |
58f6d595 | 423 | uint64_t i, variant_option_count; |
02b61fe0 | 424 | bt_field_class_type fc_type = bt_field_class_get_type(in_field_class); |
58f6d595 FD |
425 | int ret = 0; |
426 | ||
475e740e | 427 | BT_COMP_LOGD("Copying content of variant field class: " |
9a51bfb2 | 428 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
58f6d595 FD |
429 | variant_option_count = |
430 | bt_field_class_variant_get_option_count(in_field_class); | |
431 | for (i = 0; i < variant_option_count; i++) { | |
84ff66df | 432 | const bt_field_class *in_option_fc; |
58f6d595 FD |
433 | const char *option_name; |
434 | bt_field_class *out_option_field_class; | |
84ff66df PP |
435 | const bt_field_class_variant_option *in_option; |
436 | bt_field_class_variant_option *out_option; | |
58f6d595 | 437 | |
84ff66df | 438 | in_option = bt_field_class_variant_borrow_option_by_index_const( |
e24f271a | 439 | in_field_class, i); |
84ff66df PP |
440 | in_option_fc = bt_field_class_variant_option_borrow_field_class_const( |
441 | in_option); | |
442 | option_name = bt_field_class_variant_option_get_name(in_option); | |
58f6d595 | 443 | out_option_field_class = create_field_class_copy_internal( |
84ff66df | 444 | md_maps, in_option_fc); |
58f6d595 | 445 | if (!out_option_field_class) { |
475e740e | 446 | BT_COMP_LOGE_STR("Cannot copy field class."); |
58f6d595 FD |
447 | ret = -1; |
448 | goto error; | |
449 | } | |
84ff66df | 450 | ret = copy_field_class_content_internal(md_maps, in_option_fc, |
9a51bfb2 | 451 | out_option_field_class); |
58f6d595 | 452 | if (ret) { |
475e740e | 453 | BT_COMP_LOGE_STR("Error copying content of option variant " |
58f6d595 FD |
454 | "field class'"); |
455 | goto error; | |
456 | } | |
457 | ||
8bc207af PP |
458 | if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD) { |
459 | const bt_field_class_variant_with_selector_field_integer_unsigned_option *spec_opt = | |
460 | bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const( | |
02b61fe0 PP |
461 | in_field_class, i); |
462 | const bt_integer_range_set_unsigned *ranges = | |
8bc207af | 463 | bt_field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges_const( |
02b61fe0 PP |
464 | spec_opt); |
465 | ||
8bc207af | 466 | if (bt_field_class_variant_with_selector_field_integer_unsigned_append_option( |
02b61fe0 PP |
467 | out_field_class, option_name, |
468 | out_option_field_class, ranges) != | |
8bc207af | 469 | BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK) { |
0822832b | 470 | BT_COMP_LOGE_STR("Cannot append option to variant field class with unsigned integer selector'"); |
02b61fe0 PP |
471 | BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class); |
472 | ret = -1; | |
473 | goto error; | |
474 | } | |
8bc207af PP |
475 | } else if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD) { |
476 | const bt_field_class_variant_with_selector_field_integer_signed_option *spec_opt = | |
477 | bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const( | |
02b61fe0 PP |
478 | in_field_class, i); |
479 | const bt_integer_range_set_signed *ranges = | |
8bc207af | 480 | bt_field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_const( |
02b61fe0 PP |
481 | spec_opt); |
482 | ||
8bc207af | 483 | if (bt_field_class_variant_with_selector_field_integer_signed_append_option( |
02b61fe0 PP |
484 | out_field_class, option_name, |
485 | out_option_field_class, ranges) != | |
8bc207af | 486 | BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK) { |
0822832b | 487 | BT_COMP_LOGE_STR("Cannot append option to variant field class with signed integer selector'"); |
02b61fe0 PP |
488 | BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class); |
489 | ret = -1; | |
490 | goto error; | |
491 | } | |
492 | } else { | |
8bc207af | 493 | BT_ASSERT(fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD); |
02b61fe0 PP |
494 | |
495 | if (bt_field_class_variant_without_selector_append_option( | |
496 | out_field_class, option_name, | |
497 | out_option_field_class) != | |
8bc207af | 498 | BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK) { |
02b61fe0 PP |
499 | BT_COMP_LOGE_STR("Cannot append option to variant field class'"); |
500 | BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class); | |
501 | ret = -1; | |
502 | goto error; | |
503 | } | |
58f6d595 | 504 | } |
84ff66df PP |
505 | |
506 | out_option = bt_field_class_variant_borrow_option_by_index( | |
507 | out_field_class, i); | |
508 | BT_ASSERT(out_option); | |
509 | ||
510 | /* | |
511 | * Safe to use the same value object because it's frozen | |
512 | * at this point. | |
513 | */ | |
514 | bt_field_class_variant_option_set_user_attributes( | |
515 | out_option, | |
516 | bt_field_class_variant_option_borrow_user_attributes_const( | |
517 | in_option)); | |
58f6d595 FD |
518 | } |
519 | ||
475e740e | 520 | BT_COMP_LOGD("Copied content of variant field class: in-fc-addr=%p, " |
58f6d595 FD |
521 | "out-fc-addr=%p", in_field_class, out_field_class); |
522 | ||
523 | error: | |
524 | return ret; | |
525 | } | |
526 | ||
527 | static inline | |
528 | int field_class_static_array_copy( | |
529 | struct trace_ir_metadata_maps *md_maps, | |
530 | const bt_field_class *in_field_class, | |
531 | bt_field_class *out_field_class) | |
532 | { | |
475e740e | 533 | BT_COMP_LOGD("Copying content of static array field class: in-fc-addr=%p, " |
9a51bfb2 | 534 | "out-fc-addr=%p", in_field_class, out_field_class); |
58f6d595 FD |
535 | /* |
536 | * There is no content to copy. Keep this function call anyway for | |
537 | * logging purposes. | |
538 | */ | |
475e740e | 539 | BT_COMP_LOGD("Copied content of static array field class: in-fc-addr=%p, " |
9a51bfb2 | 540 | "out-fc-addr=%p", in_field_class, out_field_class); |
58f6d595 FD |
541 | |
542 | return 0; | |
543 | } | |
544 | ||
545 | static inline | |
546 | int field_class_dynamic_array_copy( | |
547 | struct trace_ir_metadata_maps *md_maps, | |
548 | const bt_field_class *in_field_class, | |
549 | bt_field_class *out_field_class) | |
550 | { | |
475e740e | 551 | BT_COMP_LOGD("Copying content of dynamic array field class: " |
9a51bfb2 | 552 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
93d7d5d1 PP |
553 | /* |
554 | * There is no content to copy. Keep this function call anyway for | |
555 | * logging purposes. | |
556 | */ | |
9a51bfb2 FD |
557 | BT_COMP_LOGD("Copied content of dynamic array field class: " |
558 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); | |
58f6d595 | 559 | |
93d7d5d1 | 560 | return 0; |
58f6d595 FD |
561 | } |
562 | ||
978237e9 PP |
563 | static inline |
564 | int field_class_option_copy( | |
565 | struct trace_ir_metadata_maps *md_maps, | |
566 | const bt_field_class *in_field_class, | |
567 | bt_field_class *out_field_class) | |
568 | { | |
569 | BT_COMP_LOGD("Copying content of option field class: " | |
9a51bfb2 | 570 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); |
978237e9 | 571 | |
467673c1 | 572 | if (bt_field_class_get_type(out_field_class) == |
8bc207af PP |
573 | BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD) { |
574 | bt_field_class_option_with_selector_field_bool_set_selector_is_reversed( | |
467673c1 | 575 | out_field_class, |
8bc207af | 576 | bt_field_class_option_with_selector_field_bool_selector_is_reversed( |
467673c1 PP |
577 | in_field_class)); |
578 | } | |
579 | ||
9a51bfb2 FD |
580 | BT_COMP_LOGD("Copied content of option field class: " |
581 | "in-fc-addr=%p, out-fc-addr=%p", in_field_class, out_field_class); | |
978237e9 PP |
582 | |
583 | return 0; | |
584 | } | |
585 | ||
58f6d595 FD |
586 | static inline |
587 | int field_class_string_copy(struct trace_ir_metadata_maps *md_maps, | |
588 | const bt_field_class *in_field_class, | |
589 | bt_field_class *out_field_class) | |
590 | { | |
475e740e | 591 | BT_COMP_LOGD("Copying content of string field class: in-fc-addr=%p, " |
9a51bfb2 | 592 | "out-fc-addr=%p", in_field_class, out_field_class); |
58f6d595 FD |
593 | /* |
594 | * There is no content to copy. Keep this function call anyway for | |
595 | * logging purposes. | |
596 | */ | |
475e740e | 597 | BT_COMP_LOGD("Copied content of string field class: in-fc-addr=%p, " |
9a51bfb2 | 598 | "out-fc-addr=%p", in_field_class, out_field_class); |
58f6d595 FD |
599 | |
600 | return 0; | |
601 | } | |
602 | ||
603 | static | |
604 | bt_field_class *copy_field_class_array_element(struct trace_ir_metadata_maps *md_maps, | |
605 | const bt_field_class *in_elem_fc) | |
606 | { | |
607 | int ret; | |
608 | bt_field_class *out_elem_fc = | |
609 | create_field_class_copy_internal(md_maps, in_elem_fc); | |
610 | if (!out_elem_fc) { | |
475e740e | 611 | BT_COMP_LOGE("Error creating output elem field class " |
9a51bfb2 FD |
612 | "from input elem field class for static array: " |
613 | "in-fc-addr=%p", in_elem_fc); | |
58f6d595 FD |
614 | goto error; |
615 | } | |
616 | ||
617 | ret = copy_field_class_content_internal(md_maps, in_elem_fc, out_elem_fc); | |
618 | if (ret) { | |
475e740e | 619 | BT_COMP_LOGE("Error creating output elem field class " |
9a51bfb2 FD |
620 | "from input elem field class for static array: " |
621 | "in-fc-addr=%p", in_elem_fc); | |
58f6d595 FD |
622 | BT_FIELD_CLASS_PUT_REF_AND_RESET(out_elem_fc); |
623 | goto error; | |
624 | } | |
625 | ||
626 | error: | |
627 | return out_elem_fc; | |
628 | } | |
629 | ||
630 | BT_HIDDEN | |
631 | bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *md_maps, | |
632 | const bt_field_class *in_field_class) | |
633 | { | |
634 | bt_field_class *out_field_class = NULL; | |
02b61fe0 | 635 | bt_field_class_type fc_type = bt_field_class_get_type(in_field_class); |
58f6d595 | 636 | |
475e740e | 637 | BT_COMP_LOGD("Creating bare field class based on field class: in-fc-addr=%p", |
9a51bfb2 | 638 | in_field_class); |
58f6d595 | 639 | |
02b61fe0 | 640 | switch (fc_type) { |
41bdd7c1 PP |
641 | case BT_FIELD_CLASS_TYPE_BOOL: |
642 | out_field_class = bt_field_class_bool_create( | |
9a51bfb2 | 643 | md_maps->output_trace_class); |
41bdd7c1 | 644 | break; |
f5f2c882 PP |
645 | case BT_FIELD_CLASS_TYPE_BIT_ARRAY: |
646 | out_field_class = bt_field_class_bit_array_create( | |
9a51bfb2 FD |
647 | md_maps->output_trace_class, |
648 | bt_field_class_bit_array_get_length( | |
649 | in_field_class)); | |
f5f2c882 | 650 | break; |
58f6d595 | 651 | case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER: |
60bbfc7c | 652 | out_field_class = bt_field_class_integer_unsigned_create( |
9a51bfb2 | 653 | md_maps->output_trace_class); |
58f6d595 FD |
654 | break; |
655 | case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER: | |
60bbfc7c | 656 | out_field_class = bt_field_class_integer_signed_create( |
9a51bfb2 | 657 | md_maps->output_trace_class); |
58f6d595 FD |
658 | break; |
659 | case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: | |
60bbfc7c | 660 | out_field_class = bt_field_class_enumeration_unsigned_create( |
9a51bfb2 | 661 | md_maps->output_trace_class); |
58f6d595 FD |
662 | break; |
663 | case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION: | |
60bbfc7c | 664 | out_field_class = bt_field_class_enumeration_signed_create( |
9a51bfb2 | 665 | md_maps->output_trace_class); |
58f6d595 | 666 | break; |
76276a81 FD |
667 | case BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL: |
668 | out_field_class = bt_field_class_real_single_precision_create( | |
9a51bfb2 | 669 | md_maps->output_trace_class); |
76276a81 FD |
670 | break; |
671 | case BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL: | |
672 | out_field_class = bt_field_class_real_double_precision_create( | |
9a51bfb2 | 673 | md_maps->output_trace_class); |
58f6d595 FD |
674 | break; |
675 | case BT_FIELD_CLASS_TYPE_STRING: | |
676 | out_field_class = bt_field_class_string_create( | |
9a51bfb2 | 677 | md_maps->output_trace_class); |
58f6d595 FD |
678 | break; |
679 | case BT_FIELD_CLASS_TYPE_STRUCTURE: | |
680 | out_field_class = bt_field_class_structure_create( | |
9a51bfb2 | 681 | md_maps->output_trace_class); |
58f6d595 FD |
682 | break; |
683 | case BT_FIELD_CLASS_TYPE_STATIC_ARRAY: | |
684 | { | |
685 | const bt_field_class *in_elem_fc = | |
686 | bt_field_class_array_borrow_element_field_class_const( | |
687 | in_field_class); | |
9a51bfb2 FD |
688 | uint64_t array_len = bt_field_class_array_static_get_length( |
689 | in_field_class); | |
58f6d595 FD |
690 | |
691 | bt_field_class *out_elem_fc = copy_field_class_array_element( | |
692 | md_maps, in_elem_fc); | |
693 | if (!out_elem_fc) { | |
694 | out_field_class = NULL; | |
695 | goto error; | |
696 | } | |
697 | ||
60bbfc7c | 698 | out_field_class = bt_field_class_array_static_create( |
9a51bfb2 FD |
699 | md_maps->output_trace_class, |
700 | out_elem_fc, array_len); | |
58f6d595 FD |
701 | break; |
702 | } | |
94847783 PP |
703 | default: |
704 | break; | |
705 | } | |
706 | ||
707 | if (bt_field_class_type_is(fc_type, | |
708 | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY)) { | |
58f6d595 FD |
709 | const bt_field_class *in_elem_fc = |
710 | bt_field_class_array_borrow_element_field_class_const( | |
711 | in_field_class); | |
93d7d5d1 | 712 | bt_field_class *out_length_fc = NULL; |
58f6d595 | 713 | bt_field_class *out_elem_fc = copy_field_class_array_element( |
93d7d5d1 | 714 | md_maps, in_elem_fc); |
b8ddb4f0 | 715 | |
58f6d595 FD |
716 | if (!out_elem_fc) { |
717 | out_field_class = NULL; | |
718 | goto error; | |
719 | } | |
720 | ||
b8ddb4f0 PP |
721 | if (fc_type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) { |
722 | const bt_field_path *length_fp = | |
723 | bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const( | |
724 | in_field_class); | |
93d7d5d1 PP |
725 | const bt_field_class *in_length_fc = |
726 | resolve_field_path_to_field_class(length_fp, | |
727 | md_maps); | |
728 | ||
729 | BT_ASSERT(in_length_fc); | |
730 | out_length_fc = g_hash_table_lookup(md_maps->field_class_map, | |
731 | in_length_fc); | |
732 | BT_ASSERT(out_length_fc); | |
733 | } | |
734 | ||
60bbfc7c | 735 | out_field_class = bt_field_class_array_dynamic_create( |
9a51bfb2 FD |
736 | md_maps->output_trace_class, |
737 | out_elem_fc, out_length_fc); | |
94847783 PP |
738 | } else if (bt_field_class_type_is(fc_type, |
739 | BT_FIELD_CLASS_TYPE_OPTION)) { | |
978237e9 PP |
740 | const bt_field_class *in_content_fc = |
741 | bt_field_class_option_borrow_field_class_const( | |
9a51bfb2 | 742 | in_field_class); |
978237e9 PP |
743 | bt_field_class *out_selector_fc = NULL; |
744 | bt_field_class *out_content_fc; | |
745 | int ret; | |
746 | ||
747 | out_content_fc = create_field_class_copy_internal( | |
9a51bfb2 | 748 | md_maps, in_content_fc); |
978237e9 PP |
749 | if (!out_content_fc) { |
750 | BT_COMP_LOGE_STR("Cannot copy option's content field class."); | |
751 | goto error; | |
752 | } | |
753 | ||
754 | ret = copy_field_class_content_internal(md_maps, | |
755 | in_content_fc, out_content_fc); | |
756 | if (ret) { | |
757 | BT_COMP_LOGE_STR("Error copying content of option's " | |
758 | "content field class"); | |
759 | goto error; | |
760 | } | |
761 | ||
8bc207af | 762 | if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD) { |
467673c1 PP |
763 | out_field_class = |
764 | bt_field_class_option_without_selector_create( | |
765 | md_maps->output_trace_class, | |
766 | out_content_fc); | |
767 | } else { | |
768 | const bt_field_path *in_selector_fp = | |
8bc207af | 769 | bt_field_class_option_with_selector_field_borrow_selector_field_path_const( |
467673c1 PP |
770 | in_field_class); |
771 | const bt_field_class *in_selector_fc; | |
978237e9 | 772 | |
467673c1 PP |
773 | BT_ASSERT(in_selector_fp); |
774 | in_selector_fc = resolve_field_path_to_field_class( | |
775 | in_selector_fp, md_maps); | |
978237e9 PP |
776 | BT_ASSERT(in_selector_fc); |
777 | out_selector_fc = g_hash_table_lookup( | |
778 | md_maps->field_class_map, in_selector_fc); | |
779 | BT_ASSERT(out_selector_fc); | |
467673c1 | 780 | |
8bc207af | 781 | if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD) { |
467673c1 | 782 | out_field_class = |
8bc207af | 783 | bt_field_class_option_with_selector_field_bool_create( |
467673c1 PP |
784 | md_maps->output_trace_class, |
785 | out_content_fc, out_selector_fc); | |
8bc207af | 786 | } else if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD) { |
467673c1 | 787 | const bt_integer_range_set_unsigned *ranges = |
8bc207af | 788 | bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const( |
467673c1 PP |
789 | in_field_class); |
790 | ||
791 | BT_ASSERT(ranges); | |
792 | out_field_class = | |
8bc207af | 793 | bt_field_class_option_with_selector_field_integer_unsigned_create( |
467673c1 PP |
794 | md_maps->output_trace_class, |
795 | out_content_fc, out_selector_fc, | |
796 | ranges); | |
8bc207af | 797 | } else if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD) { |
467673c1 | 798 | const bt_integer_range_set_signed *ranges = |
8bc207af | 799 | bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const( |
467673c1 PP |
800 | in_field_class); |
801 | ||
802 | BT_ASSERT(ranges); | |
803 | out_field_class = | |
8bc207af | 804 | bt_field_class_option_with_selector_field_integer_signed_create( |
467673c1 PP |
805 | md_maps->output_trace_class, |
806 | out_content_fc, out_selector_fc, | |
807 | ranges); | |
808 | } | |
978237e9 PP |
809 | } |
810 | ||
467673c1 | 811 | BT_ASSERT(out_field_class); |
94847783 PP |
812 | } else if (bt_field_class_type_is(fc_type, |
813 | BT_FIELD_CLASS_TYPE_VARIANT)) { | |
02b61fe0 PP |
814 | bt_field_class *out_sel_fc = NULL; |
815 | ||
94847783 PP |
816 | if (bt_field_class_type_is(fc_type, |
817 | BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD)) { | |
02b61fe0 PP |
818 | const bt_field_class *in_sel_fc; |
819 | const bt_field_path *sel_fp = | |
8bc207af | 820 | bt_field_class_variant_with_selector_field_borrow_selector_field_path_const( |
02b61fe0 PP |
821 | in_field_class); |
822 | ||
823 | BT_ASSERT(sel_fp); | |
824 | in_sel_fc = resolve_field_path_to_field_class(sel_fp, | |
825 | md_maps); | |
826 | BT_ASSERT(in_sel_fc); | |
827 | out_sel_fc = g_hash_table_lookup( | |
828 | md_maps->field_class_map, in_sel_fc); | |
829 | BT_ASSERT(out_sel_fc); | |
830 | } | |
831 | ||
58f6d595 | 832 | out_field_class = bt_field_class_variant_create( |
02b61fe0 | 833 | md_maps->output_trace_class, out_sel_fc); |
58f6d595 FD |
834 | } |
835 | ||
836 | /* | |
837 | * Add mapping from in_field_class to out_field_class. This simplifies | |
838 | * the resolution of field paths in variant and dynamic array field | |
839 | * classes. | |
840 | */ | |
94847783 | 841 | BT_ASSERT(out_field_class); |
58f6d595 | 842 | g_hash_table_insert(md_maps->field_class_map, |
9a51bfb2 | 843 | (gpointer) in_field_class, out_field_class); |
58f6d595 FD |
844 | |
845 | error: | |
846 | if(out_field_class){ | |
475e740e | 847 | BT_COMP_LOGD("Created bare field class based on field class: in-fc-addr=%p, " |
58f6d595 FD |
848 | "out-fc-addr=%p", in_field_class, out_field_class); |
849 | } else { | |
475e740e | 850 | BT_COMP_LOGE("Error creating output field class from input field " |
58f6d595 FD |
851 | "class: in-fc-addr=%p", in_field_class); |
852 | } | |
853 | ||
854 | return out_field_class; | |
855 | } | |
856 | ||
857 | BT_HIDDEN | |
858 | int copy_field_class_content_internal( | |
859 | struct trace_ir_metadata_maps *md_maps, | |
860 | const bt_field_class *in_field_class, | |
861 | bt_field_class *out_field_class) | |
862 | { | |
863 | int ret = 0; | |
94847783 PP |
864 | bt_field_class_type in_fc_type = |
865 | bt_field_class_get_type(in_field_class); | |
84ff66df PP |
866 | |
867 | /* | |
868 | * Safe to use the same value object because it's frozen at this | |
869 | * point. | |
870 | */ | |
871 | bt_field_class_set_user_attributes(out_field_class, | |
872 | bt_field_class_borrow_user_attributes_const(in_field_class)); | |
873 | ||
94847783 | 874 | if (in_fc_type == BT_FIELD_CLASS_TYPE_BOOL) { |
41bdd7c1 PP |
875 | ret = field_class_bool_copy(md_maps, |
876 | in_field_class, out_field_class); | |
94847783 | 877 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_BIT_ARRAY) { |
f5f2c882 PP |
878 | ret = field_class_bit_array_copy(md_maps, |
879 | in_field_class, out_field_class); | |
94847783 | 880 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER) { |
58f6d595 FD |
881 | ret = field_class_unsigned_integer_copy(md_maps, |
882 | in_field_class, out_field_class); | |
94847783 | 883 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER) { |
58f6d595 FD |
884 | ret = field_class_signed_integer_copy(md_maps, |
885 | in_field_class, out_field_class); | |
94847783 | 886 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION) { |
58f6d595 FD |
887 | ret = field_class_unsigned_enumeration_copy(md_maps, |
888 | in_field_class, out_field_class); | |
94847783 | 889 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) { |
58f6d595 FD |
890 | ret = field_class_signed_enumeration_copy(md_maps, |
891 | in_field_class, out_field_class); | |
94847783 | 892 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL) { |
76276a81 FD |
893 | ret = field_class_single_precision_real_copy(md_maps, |
894 | in_field_class, out_field_class); | |
94847783 | 895 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL) { |
76276a81 | 896 | ret = field_class_double_precision_real_copy(md_maps, |
58f6d595 | 897 | in_field_class, out_field_class); |
94847783 | 898 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_STRING) { |
58f6d595 FD |
899 | ret = field_class_string_copy(md_maps, |
900 | in_field_class, out_field_class); | |
94847783 | 901 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_STRUCTURE) { |
58f6d595 FD |
902 | ret = field_class_structure_copy(md_maps, |
903 | in_field_class, out_field_class); | |
94847783 | 904 | } else if (in_fc_type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY) { |
58f6d595 FD |
905 | ret = field_class_static_array_copy(md_maps, |
906 | in_field_class, out_field_class); | |
94847783 PP |
907 | } else if (bt_field_class_type_is(in_fc_type, |
908 | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY)) { | |
58f6d595 FD |
909 | ret = field_class_dynamic_array_copy(md_maps, |
910 | in_field_class, out_field_class); | |
94847783 PP |
911 | } else if (bt_field_class_type_is(in_fc_type, |
912 | BT_FIELD_CLASS_TYPE_OPTION)) { | |
978237e9 PP |
913 | ret = field_class_option_copy(md_maps, |
914 | in_field_class, out_field_class); | |
94847783 PP |
915 | } else if (bt_field_class_type_is(in_fc_type, |
916 | BT_FIELD_CLASS_TYPE_VARIANT)) { | |
58f6d595 FD |
917 | ret = field_class_variant_copy(md_maps, |
918 | in_field_class, out_field_class); | |
94847783 | 919 | } else { |
58f6d595 FD |
920 | abort(); |
921 | } | |
922 | ||
923 | return ret; | |
924 | } |