mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-04-04 07:15:53 -04:00
scanner: Make emit_structs more explicit
"is_interface" is a really terrible name for the client or server variants, and instead of checking whether we were passed the requests or the events, just pass an argument through. Reviewed-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
parent
eb223cc2f6
commit
edddb0f58e
1 changed files with 12 additions and 13 deletions
|
|
@ -851,16 +851,15 @@ emit_enumerations(struct interface *interface)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
emit_structs(struct wl_list *message_list, struct interface *interface)
|
emit_structs(struct wl_list *message_list, struct interface *interface, enum side side)
|
||||||
{
|
{
|
||||||
struct message *m;
|
struct message *m;
|
||||||
struct arg *a;
|
struct arg *a;
|
||||||
int is_interface, n;
|
int n;
|
||||||
|
|
||||||
if (wl_list_empty(message_list))
|
if (wl_list_empty(message_list))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
is_interface = message_list == &interface->request_list;
|
|
||||||
if (interface->description) {
|
if (interface->description) {
|
||||||
struct description *desc = interface->description;
|
struct description *desc = interface->description;
|
||||||
printf("/**\n");
|
printf("/**\n");
|
||||||
|
|
@ -876,7 +875,7 @@ emit_structs(struct wl_list *message_list, struct interface *interface)
|
||||||
printf(" */\n");
|
printf(" */\n");
|
||||||
}
|
}
|
||||||
printf("struct %s_%s {\n", interface->name,
|
printf("struct %s_%s {\n", interface->name,
|
||||||
is_interface ? "interface" : "listener");
|
(side == SERVER) ? "interface" : "listener");
|
||||||
|
|
||||||
wl_list_for_each(m, message_list, link) {
|
wl_list_for_each(m, message_list, link) {
|
||||||
struct description *mdesc = m->description;
|
struct description *mdesc = m->description;
|
||||||
|
|
@ -886,7 +885,7 @@ emit_structs(struct wl_list *message_list, struct interface *interface)
|
||||||
"\t * %s - ", m->name);
|
"\t * %s - ", m->name);
|
||||||
wl_list_for_each(a, &m->arg_list, link) {
|
wl_list_for_each(a, &m->arg_list, link) {
|
||||||
|
|
||||||
if (is_interface && a->type == NEW_ID &&
|
if (side == SERVER && a->type == NEW_ID &&
|
||||||
a->interface_name == NULL)
|
a->interface_name == NULL)
|
||||||
printf("\t * @interface: name of the objects interface\n"
|
printf("\t * @interface: name of the objects interface\n"
|
||||||
"\t * @version: version of the objects interface\n");
|
"\t * @version: version of the objects interface\n");
|
||||||
|
|
@ -906,7 +905,7 @@ emit_structs(struct wl_list *message_list, struct interface *interface)
|
||||||
printf("\tvoid (*%s)(", m->name);
|
printf("\tvoid (*%s)(", m->name);
|
||||||
|
|
||||||
n = strlen(m->name) + 17;
|
n = strlen(m->name) + 17;
|
||||||
if (is_interface) {
|
if (side == SERVER) {
|
||||||
printf("struct wl_client *client,\n"
|
printf("struct wl_client *client,\n"
|
||||||
"%sstruct wl_resource *resource",
|
"%sstruct wl_resource *resource",
|
||||||
indent(n));
|
indent(n));
|
||||||
|
|
@ -919,14 +918,14 @@ emit_structs(struct wl_list *message_list, struct interface *interface)
|
||||||
wl_list_for_each(a, &m->arg_list, link) {
|
wl_list_for_each(a, &m->arg_list, link) {
|
||||||
printf(",\n%s", indent(n));
|
printf(",\n%s", indent(n));
|
||||||
|
|
||||||
if (is_interface && a->type == OBJECT)
|
if (side == SERVER && a->type == OBJECT)
|
||||||
printf("struct wl_resource *");
|
printf("struct wl_resource *");
|
||||||
else if (is_interface && a->type == NEW_ID && a->interface_name == NULL)
|
else if (side == SERVER && a->type == NEW_ID && a->interface_name == NULL)
|
||||||
printf("const char *interface, uint32_t version, uint32_t ");
|
printf("const char *interface, uint32_t version, uint32_t ");
|
||||||
else if (!is_interface && a->type == OBJECT && a->interface_name == NULL)
|
else if (side == CLIENT && a->type == OBJECT && a->interface_name == NULL)
|
||||||
printf("void *");
|
printf("void *");
|
||||||
|
|
||||||
else if (!is_interface && a->type == NEW_ID)
|
else if (side == CLIENT && a->type == NEW_ID)
|
||||||
printf("struct %s *", a->interface_name);
|
printf("struct %s *", a->interface_name);
|
||||||
else
|
else
|
||||||
emit_type(a);
|
emit_type(a);
|
||||||
|
|
@ -939,7 +938,7 @@ emit_structs(struct wl_list *message_list, struct interface *interface)
|
||||||
|
|
||||||
printf("};\n\n");
|
printf("};\n\n");
|
||||||
|
|
||||||
if (!is_interface) {
|
if (side == CLIENT) {
|
||||||
printf("static inline int\n"
|
printf("static inline int\n"
|
||||||
"%s_add_listener(struct %s *%s,\n"
|
"%s_add_listener(struct %s *%s,\n"
|
||||||
"%sconst struct %s_listener *listener, void *data)\n"
|
"%sconst struct %s_listener *listener, void *data)\n"
|
||||||
|
|
@ -1019,12 +1018,12 @@ emit_header(struct protocol *protocol, enum side side)
|
||||||
emit_enumerations(i);
|
emit_enumerations(i);
|
||||||
|
|
||||||
if (side == SERVER) {
|
if (side == SERVER) {
|
||||||
emit_structs(&i->request_list, i);
|
emit_structs(&i->request_list, i, side);
|
||||||
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);
|
||||||
emit_event_wrappers(&i->event_list, i);
|
emit_event_wrappers(&i->event_list, i);
|
||||||
} else {
|
} else {
|
||||||
emit_structs(&i->event_list, i);
|
emit_structs(&i->event_list, i, side);
|
||||||
emit_opcodes(&i->request_list, i);
|
emit_opcodes(&i->request_list, i);
|
||||||
emit_stubs(&i->request_list, i);
|
emit_stubs(&i->request_list, i);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue