side_ptr_t(const struct side_type_vla_visitor) side_vla_visitor;
side_ptr_t(const struct side_type_struct) side_struct;
side_ptr_t(const struct side_type_variant) side_variant;
- side_ptr_t(const struct side_type) side_optional;
+ side_ptr_t(const struct side_type_optional) side_optional;
/* Stack-copy enumeration types */
struct side_type_enum side_enum;
} SIDE_PACKED;
side_check_size(struct side_type_variant, 40 + sizeof(const struct side_type));
+struct side_type_optional {
+ side_ptr_t(const struct side_type) elem_type;
+};
+
struct side_event_field {
side_ptr_t(const char) field_name;
struct side_type side_type;
.type = SIDE_ENUM_INIT(SIDE_TYPE_OPTIONAL), \
.u = { \
.side_optional = SIDE_PTR_INIT(_optional), \
- }, \
+ } \
+ }
+
+#define _side_type_optional_define(_elem_type) \
+ { \
+ .elem_type = SIDE_PTR_INIT(_elem_type), \
}
#define _side_define_optional(_identifier, _elem_type) \
- const struct side_type _identifier = _side_type_optional(SIDE_PARAM(_elem_type))
+ const struct side_type_optional _identifier = _side_type_optional_define(SIDE_PARAM(_elem_type))
#define _side_field_optional(_name, _identifier) \
- _side_field(_name, _side_type_optional(&(_identifier)))
+ _side_field(_name, _side_type_optional(SIDE_PARAM(&(_identifier))))
#define _side_field_optional_literal(_name, _elem_type) \
- _side_field(_name, _side_type_optional(SIDE_PARAM(_elem_type)))
+ _side_field(_name, _side_type_optional(SIDE_COMPOUND_LITERAL(struct side_type_optional, _side_type_optional_define(SIDE_PARAM(_elem_type)))))
#define _side_type_array(_array) \
{ \
if (side_arg_optional->selector == SIDE_OPTIONAL_DISABLED)
return;
- type = side_ptr_get(type_desc->u.side_optional);
+ type = side_ptr_get(side_ptr_get(type_desc->u.side_optional)->elem_type);
arg = &side_arg_optional->side_static;
side_visit_type(type_visitor, &new_ctx, type, arg, priv);
static
void description_visitor_optional(const struct side_description_visitor *description_visitor,
- const struct side_type *type_desc, void *priv)
+ const struct side_type_optional *optional, void *priv)
{
- const struct side_type *optional = side_ptr_get(type_desc->u.side_optional);
+ const struct side_type *type_desc = side_ptr_get(optional->elem_type);
if (description_visitor->before_optional_type_func)
- description_visitor->before_optional_type_func(optional, priv);
- side_visit_type(description_visitor, optional, priv);
+ description_visitor->before_optional_type_func(type_desc, priv);
+ side_visit_type(description_visitor, type_desc, priv);
if (description_visitor->after_optional_type_func)
- description_visitor->after_optional_type_func(optional, priv);
+ description_visitor->after_optional_type_func(type_desc, priv);
}
static
break;
case SIDE_TYPE_OPTIONAL:
- description_visitor_optional(description_visitor, type_desc, priv);
+ description_visitor_optional(description_visitor, side_ptr_get(type_desc->u.side_optional), priv);
break;
default: