X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fcdump%2Fcdump.h;h=30822ec50c7f84fab449d7b253615cb304b9f847;hb=979071e8587d4819a7f78613b68d29e222e5db63;hp=ede6310e40e9a45e7e3391f5ce796db999cc7df9;hpb=158691ae36fe1da78ec54dbcc0006f603398dae2;p=ccan diff --git a/ccan/cdump/cdump.h b/ccan/cdump/cdump.h index ede6310e..30822ec5 100644 --- a/ccan/cdump/cdump.h +++ b/ccan/cdump/cdump.h @@ -15,6 +15,7 @@ enum cdump_type_kind { struct cdump_member { const char *name; + const char *note; /* const, volatile */ const char *qualifiers; struct cdump_type *type; @@ -22,6 +23,7 @@ struct cdump_member { struct cdump_enum_val { const char *name; + const char *note; /* Either NULL, or whatever follows '=' sign */ const char *value; }; @@ -34,6 +36,7 @@ struct cdump_array { struct cdump_type { enum cdump_type_kind kind; const char *name; + const char *note; union { /* CDUMP_STRUCT / CDUMP_UNION: array */ struct cdump_member *members; @@ -47,14 +50,12 @@ struct cdump_type { }; /* 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; }; /** @@ -67,6 +68,11 @@ struct cdump_definitions { * 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, @@ -88,6 +94,8 @@ struct cdump_definitions { * 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; * } */