struct side_type_description {
uint32_t type; /* enum side_type */
- //TODO: we should add something like a list of user attributes (namespaced strings)
+ uint32_t nr_attr;
+ const struct side_attr *attr;
union {
struct {
uint32_t nr_fields;
#define side_attr_list(...) \
SIDE_COMPOUND_LITERAL(const struct side_attr, __VA_ARGS__)
-#define side_type_decl(_type) { .type = _type }
+#define side_type_decl(_type, _attr) \
+ { \
+ .type = _type, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .attr = _attr, \
+ }
-#define side_field(_name, _type) \
+#define side_field(_name, _type, _attr) \
{ \
.field_name = _name, \
- .side_type = side_type_decl(_type), \
+ .side_type = side_type_decl(_type, SIDE_PARAM(_attr)), \
}
-#define side_type_struct_decl(_fields) \
+#define side_type_struct_decl(_fields, _attr) \
{ \
.type = SIDE_TYPE_STRUCT, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .attr = _attr, \
.u = { \
.side_struct = { \
.nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
}, \
}, \
}
-#define side_field_struct(_name, _fields) \
+#define side_field_struct(_name, _fields, _attr) \
{ \
.field_name = _name, \
- .side_type = side_type_struct_decl(SIDE_PARAM(_fields)), \
+ .side_type = side_type_struct_decl(SIDE_PARAM(_fields), SIDE_PARAM(_attr)), \
}
-#define side_type_array_decl(_elem_type, _length) \
+#define side_type_array_decl(_elem_type, _length, _attr) \
{ \
.type = SIDE_TYPE_ARRAY, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .attr = _attr, \
.u = { \
.side_array = { \
.length = _length, \
}, \
}, \
}
-#define side_field_array(_name, _elem_type, _length) \
+#define side_field_array(_name, _elem_type, _length, _attr) \
{ \
.field_name = _name, \
- .side_type = side_type_array_decl(_elem_type, _length), \
+ .side_type = side_type_array_decl(SIDE_PARAM(_elem_type), _length, SIDE_PARAM(_attr)), \
}
-#define side_type_vla_decl(_elem_type) \
+#define side_type_vla_decl(_elem_type, _attr) \
{ \
.type = SIDE_TYPE_VLA, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .attr = _attr, \
.u = { \
.side_vla = { \
.elem_type = _elem_type, \
}, \
}, \
}
-#define side_field_vla(_name, _elem_type) \
+#define side_field_vla(_name, _elem_type, _attr) \
{ \
.field_name = _name, \
- .side_type = side_type_vla_decl(_elem_type), \
+ .side_type = side_type_vla_decl(SIDE_PARAM(_elem_type), SIDE_PARAM(_attr)), \
}
-#define side_type_vla_visitor_decl(_elem_type, _visitor) \
+#define side_type_vla_visitor_decl(_elem_type, _visitor, _attr) \
{ \
.type = SIDE_TYPE_VLA_VISITOR, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .attr = _attr, \
.u = { \
.side_vla_visitor = { \
.elem_type = SIDE_PARAM(_elem_type), \
}, \
}, \
}
-#define side_field_vla_visitor(_name, _elem_type, _visitor) \
+#define side_field_vla_visitor(_name, _elem_type, _visitor, _attr) \
{ \
.field_name = _name, \
- .side_type = side_type_vla_visitor_decl(SIDE_PARAM(_elem_type), _visitor), \
+ .side_type = side_type_vla_visitor_decl(SIDE_PARAM(_elem_type), _visitor, SIDE_PARAM(_attr)), \
}
#define side_elem(...) \
SIDE_COMPOUND_LITERAL(const struct side_type_description, __VA_ARGS__)
-#define side_elem_type(...) \
- side_elem(side_type_decl(__VA_ARGS__))
+#define side_elem_type(_type, _attr) \
+ side_elem(side_type_decl(_type, SIDE_PARAM(_attr)))
#define side_field_list(...) \
SIDE_COMPOUND_LITERAL(const struct side_event_field, __VA_ARGS__)
static side_define_event(my_provider_event, "myprovider", "myevent", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field("abc", SIDE_TYPE_U32),
- side_field("def", SIDE_TYPE_S64),
- side_field("dynamic", SIDE_TYPE_DYNAMIC),
+ side_field("abc", SIDE_TYPE_U32, side_attr_list()),
+ side_field("def", SIDE_TYPE_S64, side_attr_list()),
+ side_field("dynamic", SIDE_TYPE_DYNAMIC, side_attr_list()),
)
);
side_field_list(
side_field_struct("structfield",
side_field_list(
- side_field("x", SIDE_TYPE_U32),
- side_field("y", SIDE_TYPE_S64),
- )
+ side_field("x", SIDE_TYPE_U32, side_attr_list()),
+ side_field("y", SIDE_TYPE_S64, side_attr_list()),
+ ),
+ side_attr_list()
),
- side_field("z", SIDE_TYPE_U8),
+ side_field("z", SIDE_TYPE_U8, side_attr_list()),
)
);
static side_define_event(my_provider_event_array, "myprovider", "myarray", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field_array("arr", side_elem_type(SIDE_TYPE_U32), 3),
- side_field("v", SIDE_TYPE_S64),
+ side_field_array("arr", side_elem_type(SIDE_TYPE_U32, side_attr_list()), 3, side_attr_list()),
+ side_field("v", SIDE_TYPE_S64, side_attr_list()),
)
);
static side_define_event(my_provider_event_vla, "myprovider", "myvla", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field_vla("vla", side_elem_type(SIDE_TYPE_U32)),
- side_field("v", SIDE_TYPE_S64),
+ side_field_vla("vla", side_elem_type(SIDE_TYPE_U32, side_attr_list()), side_attr_list()),
+ side_field("v", SIDE_TYPE_S64, side_attr_list()),
)
);
static side_define_event(my_provider_event_vla_visitor, "myprovider", "myvlavisit", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field_vla_visitor("vlavisit", side_elem_type(SIDE_TYPE_U32), test_visitor),
- side_field("v", SIDE_TYPE_S64),
+ side_field_vla_visitor("vlavisit", side_elem_type(SIDE_TYPE_U32, side_attr_list()), test_visitor, side_attr_list()),
+ side_field("v", SIDE_TYPE_S64, side_attr_list()),
)
);
side_attr_list(),
side_field_list(
side_field_vla_visitor("vlavisit2d",
- side_elem(side_type_vla_visitor_decl(side_elem_type(SIDE_TYPE_U32), test_inner_visitor)), test_outer_visitor),
- side_field("v", SIDE_TYPE_S64),
+ side_elem(
+ side_type_vla_visitor_decl(
+ side_elem_type(SIDE_TYPE_U32, side_attr_list()),
+ test_inner_visitor,
+ side_attr_list())
+ ), test_outer_visitor, side_attr_list()),
+ side_field("v", SIDE_TYPE_S64, side_attr_list()),
)
);
static side_define_event(my_provider_event_array_fixint, "myprovider", "myarrayfixint", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field_array("arrfixint", side_elem_type(SIDE_TYPE_S64), SIDE_ARRAY_SIZE(array_fixint)),
- side_field("v", SIDE_TYPE_S64),
+ side_field_array("arrfixint", side_elem_type(SIDE_TYPE_S64, side_attr_list()), SIDE_ARRAY_SIZE(array_fixint), side_attr_list()),
+ side_field("v", SIDE_TYPE_S64, side_attr_list()),
)
);
static side_define_event(my_provider_event_vla_fixint, "myprovider", "myvlafixint", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field_vla("vlafixint", side_elem_type(SIDE_TYPE_S64)),
- side_field("v", SIDE_TYPE_S64),
+ side_field_vla("vlafixint", side_elem_type(SIDE_TYPE_S64, side_attr_list()), side_attr_list()),
+ side_field("v", SIDE_TYPE_S64, side_attr_list()),
)
);
"myprovider", "mydynamicbasic", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field("dynamic", SIDE_TYPE_DYNAMIC),
+ side_field("dynamic", SIDE_TYPE_DYNAMIC, side_attr_list()),
)
);
"myprovider", "mydynamicvla", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field("dynamic", SIDE_TYPE_DYNAMIC),
+ side_field("dynamic", SIDE_TYPE_DYNAMIC, side_attr_list()),
)
);
"myprovider", "mydynamicnull", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field("dynamic", SIDE_TYPE_DYNAMIC),
+ side_field("dynamic", SIDE_TYPE_DYNAMIC, side_attr_list()),
)
);
"myprovider", "mydynamicstruct", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field("dynamic", SIDE_TYPE_DYNAMIC),
+ side_field("dynamic", SIDE_TYPE_DYNAMIC, side_attr_list()),
)
);
"myprovider", "mydynamicnestedstruct", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field("dynamic", SIDE_TYPE_DYNAMIC),
+ side_field("dynamic", SIDE_TYPE_DYNAMIC, side_attr_list()),
)
);
"myprovider", "mydynamicvlastruct", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field("dynamic", SIDE_TYPE_DYNAMIC),
+ side_field("dynamic", SIDE_TYPE_DYNAMIC, side_attr_list()),
)
);
"myprovider", "mydynamicstructvla", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field("dynamic", SIDE_TYPE_DYNAMIC),
+ side_field("dynamic", SIDE_TYPE_DYNAMIC, side_attr_list()),
)
);
"myprovider", "mydynamicnestedvla", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field("dynamic", SIDE_TYPE_DYNAMIC),
+ side_field("dynamic", SIDE_TYPE_DYNAMIC, side_attr_list()),
)
);
"myprovider", "mystaticvariadicevent", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field("abc", SIDE_TYPE_U32),
- side_field("def", SIDE_TYPE_U16),
+ side_field("abc", SIDE_TYPE_U32, side_attr_list()),
+ side_field("def", SIDE_TYPE_U16, side_attr_list()),
)
);
static side_define_event(my_provider_event_bool, "myprovider", "myeventbool", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field("a_false", SIDE_TYPE_BOOL),
- side_field("b_true", SIDE_TYPE_BOOL),
- side_field("c_true", SIDE_TYPE_BOOL),
- side_field("d_true", SIDE_TYPE_BOOL),
- side_field("e_true", SIDE_TYPE_BOOL),
- side_field("f_false", SIDE_TYPE_BOOL),
- side_field("g_true", SIDE_TYPE_BOOL),
+ side_field("a_false", SIDE_TYPE_BOOL, side_attr_list()),
+ side_field("b_true", SIDE_TYPE_BOOL, side_attr_list()),
+ side_field("c_true", SIDE_TYPE_BOOL, side_attr_list()),
+ side_field("d_true", SIDE_TYPE_BOOL, side_attr_list()),
+ side_field("e_true", SIDE_TYPE_BOOL, side_attr_list()),
+ side_field("f_false", SIDE_TYPE_BOOL, side_attr_list()),
+ side_field("g_true", SIDE_TYPE_BOOL, side_attr_list()),
)
);
"myprovider", "mydynamicvlavisitor", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field("dynamic", SIDE_TYPE_DYNAMIC),
+ side_field("dynamic", SIDE_TYPE_DYNAMIC, side_attr_list()),
)
);
"myprovider", "mydynamicstructvisitor", SIDE_LOGLEVEL_DEBUG,
side_attr_list(),
side_field_list(
- side_field("dynamic", SIDE_TYPE_DYNAMIC),
+ side_field("dynamic", SIDE_TYPE_DYNAMIC, side_attr_list()),
)
);
side_attr("user_attribute_b", "val2"),
),
side_field_list(
- side_field("abc", SIDE_TYPE_U32),
- side_field("def", SIDE_TYPE_S64),
+ side_field("abc", SIDE_TYPE_U32, side_attr_list()),
+ side_field("def", SIDE_TYPE_S64, side_attr_list()),
)
);
side_event(&my_provider_event_user_attribute, side_arg_list(side_arg_u32(1), side_arg_s64(2)));
}
-
int main()
{
test_fields();