struct cdump_member {
const char *name;
+ const char *note;
/* const, volatile */
const char *qualifiers;
struct cdump_type *type;
struct cdump_enum_val {
const char *name;
+ const char *note;
/* Either NULL, or whatever follows '=' sign */
const char *value;
};
struct cdump_type {
enum cdump_type_kind kind;
const char *name;
+ const char *note;
union {
/* CDUMP_STRUCT / CDUMP_UNION: array */
struct cdump_member *members;
};
/* The map of typenames to definitions */
-struct cdump_map {
- STRMAP_MEMBERS(struct cdump_type *);
-};
+typedef STRMAP(struct cdump_type *) cdump_map_t;
struct cdump_definitions {
- struct cdump_map enums;
- struct cdump_map structs;
- struct cdump_map unions;
+ cdump_map_t enums;
+ cdump_map_t structs;
+ cdump_map_t unions;
};
/**
* into the return. If there is a parse error, it will return NULL and
* allocate a problem string for human consumption.
*
+ * Annotations can be attached to structures, unions, enums, members
+ * and enum values using CDUMP(). This comes after the name (or
+ * after [] for array member declarations) and usually is removed from
+ * C compilation using "#define CDUMP(x)".
+ *
* Example:
* // Returns name of first field of 'struct @name' in @code.
* static const char *first_field_of_struct(const char *code,
* return NULL;
* }
* assert(t->kind == CDUMP_STRUCT);
+ * if (t->note)
+ * printf("Note on struct %s: %s\n", name, t->note);
* return t->u.members[0].name;
* }
*/