mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
scanner: add new enum-header mode
This generates a header with only enum definitions. This is useful to share enum headers between libraries and library users. Signed-off-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
parent
2621484037
commit
fbd7460737
1 changed files with 36 additions and 1 deletions
|
|
@ -67,7 +67,7 @@ enum visibility {
|
|||
static int
|
||||
usage(int ret)
|
||||
{
|
||||
fprintf(stderr, "usage: %s [OPTION] [client-header|server-header|private-code|public-code]"
|
||||
fprintf(stderr, "usage: %s [OPTION] [client-header|server-header|enum-header|private-code|public-code]"
|
||||
" [input_file output_file]\n", PROGRAM_NAME);
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Converts XML protocol descriptions supplied on "
|
||||
|
|
@ -1703,6 +1703,35 @@ emit_header(struct protocol *protocol, enum side side)
|
|||
"#endif\n");
|
||||
}
|
||||
|
||||
static void
|
||||
emit_enum_header(struct protocol *protocol)
|
||||
{
|
||||
struct interface *i, *i_next;
|
||||
|
||||
printf("/* Generated by %s %s */\n\n", PROGRAM_NAME, WAYLAND_VERSION);
|
||||
|
||||
printf("#ifndef %s_ENUM_PROTOCOL_H\n"
|
||||
"#define %s_ENUM_PROTOCOL_H\n"
|
||||
"\n"
|
||||
"#ifdef __cplusplus\n"
|
||||
"extern \"C\" {\n"
|
||||
"#endif\n\n",
|
||||
protocol->uppercase_name,
|
||||
protocol->uppercase_name);
|
||||
|
||||
wl_list_for_each_safe(i, i_next, &protocol->interface_list, link) {
|
||||
emit_enumerations(i);
|
||||
|
||||
free_interface(i);
|
||||
}
|
||||
|
||||
printf("#ifdef __cplusplus\n"
|
||||
"}\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#endif\n");
|
||||
}
|
||||
|
||||
static void
|
||||
emit_null_run(struct protocol *protocol)
|
||||
{
|
||||
|
|
@ -1923,6 +1952,7 @@ int main(int argc, char *argv[])
|
|||
enum {
|
||||
CLIENT_HEADER,
|
||||
SERVER_HEADER,
|
||||
ENUM_HEADER,
|
||||
PRIVATE_CODE,
|
||||
PUBLIC_CODE,
|
||||
CODE,
|
||||
|
|
@ -1976,6 +2006,8 @@ int main(int argc, char *argv[])
|
|||
mode = CLIENT_HEADER;
|
||||
else if (strcmp(argv[0], "server-header") == 0)
|
||||
mode = SERVER_HEADER;
|
||||
else if (strcmp(argv[0], "enum-header") == 0)
|
||||
mode = ENUM_HEADER;
|
||||
else if (strcmp(argv[0], "private-code") == 0)
|
||||
mode = PRIVATE_CODE;
|
||||
else if (strcmp(argv[0], "public-code") == 0)
|
||||
|
|
@ -2067,6 +2099,9 @@ int main(int argc, char *argv[])
|
|||
case SERVER_HEADER:
|
||||
emit_header(&protocol, SERVER);
|
||||
break;
|
||||
case ENUM_HEADER:
|
||||
emit_enum_header(&protocol);
|
||||
break;
|
||||
case PRIVATE_CODE:
|
||||
emit_code(&protocol, PRIVATE);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue