+ break;
+ }
+ case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
+ case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR:
+ case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR:
+ {
+ uint64_t option_count =
+ bt_field_class_variant_get_option_count(fc);
+ const bt_field_path *sel_field_path = NULL;
+
+ if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR ||
+ fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR) {
+ sel_field_path =
+ bt_field_class_variant_with_selector_borrow_selector_field_path_const(
+ fc);
+ BT_ASSERT(sel_field_path);
+ }
+
+ g_string_append(ctx->str, " (");
+ write_uint_prop_value(ctx, option_count);
+ g_string_append_printf(ctx->str, " option%s",
+ plural(option_count));
+
+ if (sel_field_path) {
+ g_string_append(ctx->str, ", Selector field path ");
+ write_field_path(ctx, sel_field_path);
+ }
+
+ g_string_append_c(ctx->str, ')');
+ break;
+ }
+ default:
+ break;
+ }
+
+ incr_indent(ctx);
+ user_attrs = bt_field_class_borrow_user_attributes_const(fc);
+ if (!bt_value_map_is_empty(user_attrs)) {
+ g_string_append(ctx->str, ":\n");
+ write_user_attributes(ctx, user_attrs, false, NULL);
+ wrote_user_attrs = true;
+ }
+
+ /* Write field class's complex properties */
+ switch (fc_type) {
+ case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
+ case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION:
+ {
+ uint64_t mapping_count =
+ bt_field_class_enumeration_get_mapping_count(fc);
+
+ if (mapping_count > 0) {
+ if (wrote_user_attrs) {
+ write_nl(ctx);
+ write_indent(ctx);
+ write_prop_name(ctx, "Mappings");
+ g_string_append_c(ctx->str, ':');
+ incr_indent(ctx);
+ } else {
+ /* Each mapping starts with its own newline */
+ g_string_append_c(ctx->str, ':');
+ }
+
+ write_enum_field_class_mappings(ctx, fc);
+
+ if (wrote_user_attrs) {
+ decr_indent(ctx);
+ }
+ }
+
+ break;
+ }
+ case BT_FIELD_CLASS_TYPE_STRUCTURE:
+ {
+ uint64_t member_count =
+ bt_field_class_structure_get_member_count(fc);
+
+ if (member_count > 0) {
+ if (wrote_user_attrs) {
+ write_nl(ctx);
+ write_indent(ctx);
+ write_prop_name(ctx, "Members");
+ g_string_append_c(ctx->str, ':');
+ incr_indent(ctx);
+ } else {
+ /* Each member starts with its own newline */
+ g_string_append_c(ctx->str, ':');
+ }
+
+ for (i = 0; i < member_count; i++) {
+ const bt_field_class_structure_member *member =
+ bt_field_class_structure_borrow_member_by_index_const(
+ fc, i);
+ const bt_value *user_attrs;
+ const bt_field_class *member_fc =
+ bt_field_class_structure_member_borrow_field_class_const(member);
+
+ write_nl(ctx);
+ write_compound_member_name(ctx,
+ bt_field_class_structure_member_get_name(member));
+ user_attrs = bt_field_class_structure_member_borrow_user_attributes_const(
+ member);
+
+ if (bt_value_map_is_empty(user_attrs)) {
+ write_sp(ctx);
+ write_field_class(ctx, member_fc);
+ } else {
+ write_nl(ctx);
+ incr_indent(ctx);
+
+ /* Field class */
+ write_prop_name_line(ctx, "Field class");
+ write_sp(ctx);
+ write_field_class(ctx, member_fc);
+ write_nl(ctx);
+
+ /* User attributes */
+ write_user_attributes(ctx, user_attrs,
+ false, NULL);
+
+ decr_indent(ctx);
+ }
+ }
+
+ if (wrote_user_attrs) {
+ decr_indent(ctx);
+ }
+ }
+
+ break;
+ }
+ case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ if (wrote_user_attrs) {
+ write_nl(ctx);
+ } else {
+ g_string_append(ctx->str, ":\n");
+ }
+
+ write_prop_name_line(ctx, "Element");
+ write_sp(ctx);
+ write_field_class(ctx,
+ bt_field_class_array_borrow_element_field_class_const(fc));
+ break;
+ case BT_FIELD_CLASS_TYPE_OPTION:
+ if (wrote_user_attrs) {
+ write_nl(ctx);
+ } else {
+ g_string_append(ctx->str, ":\n");
+ }
+
+ write_prop_name_line(ctx, "Content");