mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-12-20 07:00:06 +01: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
|
static int
|
||||||
usage(int ret)
|
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);
|
" [input_file output_file]\n", PROGRAM_NAME);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "Converts XML protocol descriptions supplied on "
|
fprintf(stderr, "Converts XML protocol descriptions supplied on "
|
||||||
|
|
@ -1703,6 +1703,35 @@ emit_header(struct protocol *protocol, enum side side)
|
||||||
"#endif\n");
|
"#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
|
static void
|
||||||
emit_null_run(struct protocol *protocol)
|
emit_null_run(struct protocol *protocol)
|
||||||
{
|
{
|
||||||
|
|
@ -1923,6 +1952,7 @@ int main(int argc, char *argv[])
|
||||||
enum {
|
enum {
|
||||||
CLIENT_HEADER,
|
CLIENT_HEADER,
|
||||||
SERVER_HEADER,
|
SERVER_HEADER,
|
||||||
|
ENUM_HEADER,
|
||||||
PRIVATE_CODE,
|
PRIVATE_CODE,
|
||||||
PUBLIC_CODE,
|
PUBLIC_CODE,
|
||||||
CODE,
|
CODE,
|
||||||
|
|
@ -1976,6 +2006,8 @@ int main(int argc, char *argv[])
|
||||||
mode = CLIENT_HEADER;
|
mode = CLIENT_HEADER;
|
||||||
else if (strcmp(argv[0], "server-header") == 0)
|
else if (strcmp(argv[0], "server-header") == 0)
|
||||||
mode = SERVER_HEADER;
|
mode = SERVER_HEADER;
|
||||||
|
else if (strcmp(argv[0], "enum-header") == 0)
|
||||||
|
mode = ENUM_HEADER;
|
||||||
else if (strcmp(argv[0], "private-code") == 0)
|
else if (strcmp(argv[0], "private-code") == 0)
|
||||||
mode = PRIVATE_CODE;
|
mode = PRIVATE_CODE;
|
||||||
else if (strcmp(argv[0], "public-code") == 0)
|
else if (strcmp(argv[0], "public-code") == 0)
|
||||||
|
|
@ -2067,6 +2099,9 @@ int main(int argc, char *argv[])
|
||||||
case SERVER_HEADER:
|
case SERVER_HEADER:
|
||||||
emit_header(&protocol, SERVER);
|
emit_header(&protocol, SERVER);
|
||||||
break;
|
break;
|
||||||
|
case ENUM_HEADER:
|
||||||
|
emit_enum_header(&protocol);
|
||||||
|
break;
|
||||||
case PRIVATE_CODE:
|
case PRIVATE_CODE:
|
||||||
emit_code(&protocol, PRIVATE);
|
emit_code(&protocol, PRIVATE);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue