mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-03 09:01:42 -05:00
scanner: Use an enum to determine the type of thing we're writing out
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
parent
ced769ac92
commit
eb223cc2f6
1 changed files with 11 additions and 6 deletions
|
|
@ -30,6 +30,11 @@
|
||||||
|
|
||||||
#include "wayland-util.h"
|
#include "wayland-util.h"
|
||||||
|
|
||||||
|
enum side {
|
||||||
|
CLIENT,
|
||||||
|
SERVER,
|
||||||
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
usage(int ret)
|
usage(int ret)
|
||||||
{
|
{
|
||||||
|
|
@ -974,10 +979,10 @@ format_copyright(const char *copyright)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
emit_header(struct protocol *protocol, int server)
|
emit_header(struct protocol *protocol, enum side side)
|
||||||
{
|
{
|
||||||
struct interface *i;
|
struct interface *i;
|
||||||
const char *s = server ? "SERVER" : "CLIENT";
|
const char *s = (side == SERVER) ? "SERVER" : "CLIENT";
|
||||||
|
|
||||||
if (protocol->copyright)
|
if (protocol->copyright)
|
||||||
format_copyright(protocol->copyright);
|
format_copyright(protocol->copyright);
|
||||||
|
|
@ -996,7 +1001,7 @@ emit_header(struct protocol *protocol, int server)
|
||||||
"struct wl_resource;\n\n",
|
"struct wl_resource;\n\n",
|
||||||
protocol->uppercase_name, s,
|
protocol->uppercase_name, s,
|
||||||
protocol->uppercase_name, s,
|
protocol->uppercase_name, s,
|
||||||
server ? "wayland-util.h" : "wayland-client.h");
|
(side == SERVER) ? "wayland-util.h" : "wayland-client.h");
|
||||||
|
|
||||||
wl_list_for_each(i, &protocol->interface_list, link)
|
wl_list_for_each(i, &protocol->interface_list, link)
|
||||||
printf("struct %s;\n", i->name);
|
printf("struct %s;\n", i->name);
|
||||||
|
|
@ -1013,7 +1018,7 @@ emit_header(struct protocol *protocol, int server)
|
||||||
|
|
||||||
emit_enumerations(i);
|
emit_enumerations(i);
|
||||||
|
|
||||||
if (server) {
|
if (side == SERVER) {
|
||||||
emit_structs(&i->request_list, i);
|
emit_structs(&i->request_list, i);
|
||||||
emit_opcodes(&i->event_list, i);
|
emit_opcodes(&i->event_list, i);
|
||||||
emit_opcode_versions(&i->event_list, i);
|
emit_opcode_versions(&i->event_list, i);
|
||||||
|
|
@ -1300,10 +1305,10 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case CLIENT_HEADER:
|
case CLIENT_HEADER:
|
||||||
emit_header(&protocol, 0);
|
emit_header(&protocol, CLIENT);
|
||||||
break;
|
break;
|
||||||
case SERVER_HEADER:
|
case SERVER_HEADER:
|
||||||
emit_header(&protocol, 1);
|
emit_header(&protocol, SERVER);
|
||||||
break;
|
break;
|
||||||
case CODE:
|
case CODE:
|
||||||
emit_code(&protocol);
|
emit_code(&protocol);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue