<div dir="ltr"><div>Looks correct to me.<br><br></div>I had a slightly different patch in patchwork which changes protocol-to-docbook. It puts the enumeration into it's own statement, rather than a nested if statement, and it adds the object:: prefix to the documentation for all enumerations, not just the cross-object ones.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 29, 2015 at 5:54 AM, Auke Booij <span dir="ltr"><<a href="mailto:auke@tulcod.com" target="_blank">auke@tulcod.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The enum attribute, for which scanner support was introduced in<br>
1771299, can be used to link message arguments to <enum>s. However,<br>
some arguments refer to <enum>s in a different <interface>.<br>
<br>
This adds scanner support for referring to an <enum> in a different<br>
<interface> using dot notation. It also sets the attributes in this<br>
style in the wayland XML protocol (wl_shm_pool::create_buffer::format<br>
to wl_shm::format, and wl_surface::set_buffer_transform::transform to<br>
wl_output::transform), and updates the documentation XSL so that this<br>
new style is supported.<br>
<br>
Changes since v1:<br>
- several implementation bugs fixed<br>
<br>
Signed-off-by: Auke Booij <<a href="mailto:auke@tulcod.com">auke@tulcod.com</a>><br>
---<br>
doc/publican/protocol-to-docbook.xsl | 17 +++++++++--<br>
protocol/wayland.xml | 4 +--<br>
src/scanner.c | 59 +++++++++++++++++++++++++++---------<br>
3 files changed, 61 insertions(+), 19 deletions(-)<br>
<br>
diff --git a/doc/publican/protocol-to-docbook.xsl b/doc/publican/protocol-to-docbook.xsl<br>
index fad207a..1fa066d 100644<br>
--- a/doc/publican/protocol-to-docbook.xsl<br>
+++ b/doc/publican/protocol-to-docbook.xsl<br>
@@ -103,9 +103,20 @@<br>
<listitem><br>
<simpara><br>
<xsl:if test="@enum"><br>
- <link linkend="protocol-spec-{../../@name}-enum-{@enum}"><br>
- <xsl:value-of select="@enum"/><br>
- </link><br>
+ <xsl:choose><br>
+ <xsl:when test="contains(@enum, '.')"><br>
+ <link linkend="protocol-spec-{substring-before(@enum, '.')}-enum-{substring-after(@enum, '.')}"><br>
+ <xsl:value-of select="substring-before(@enum, '.')"/><br>
+ <xsl:text>::</xsl:text><br>
+ <xsl:value-of select="substring-after(@enum, '.')"/><br>
+ </link><br>
+ </xsl:when><br>
+ <xsl:otherwise><br>
+ <link linkend="protocol-spec-{../../@name}-enum-{@enum}"><br>
+ <xsl:value-of select="@enum"/><br>
+ </link><br>
+ </xsl:otherwise><br>
+ </xsl:choose><br>
<xsl:text> </xsl:text><br>
</xsl:if><br>
<xsl:value-of select="@type"/><br>
diff --git a/protocol/wayland.xml b/protocol/wayland.xml<br>
index f9e6d76..0873553 100644<br>
--- a/protocol/wayland.xml<br>
+++ b/protocol/wayland.xml<br>
@@ -229,7 +229,7 @@<br>
<arg name="width" type="int"/><br>
<arg name="height" type="int"/><br>
<arg name="stride" type="int"/><br>
- <arg name="format" type="uint"/><br>
+ <arg name="format" type="uint" enum="wl_shm.format"/><br>
</request><br>
<br>
<request name="destroy" type="destructor"><br>
@@ -1292,7 +1292,7 @@<br>
wl_output.transform enum the invalid_transform protocol error<br>
is raised.<br>
</description><br>
- <arg name="transform" type="int"/><br>
+ <arg name="transform" type="int" enum="wl_output.transform"/><br>
</request><br>
<br>
<!-- Version 3 additions --><br>
diff --git a/src/scanner.c b/src/scanner.c<br>
index 406519f..e69bd2a 100644<br>
--- a/src/scanner.c<br>
+++ b/src/scanner.c<br>
@@ -785,32 +785,62 @@ start_element(void *data, const char *element_name, const char **atts)<br>
}<br>
}<br>
<br>
+static struct enumeration *<br>
+find_enumeration(struct protocol *protocol, struct interface *interface, char *enum_attribute)<br>
+{<br>
+ struct interface *i;<br>
+ struct enumeration *e, *f = NULL;<br>
+ char *enum_name;<br>
+ int idx = 0, j;<br>
+<br>
+ for (j = 0; j + 1 < (int)strlen(enum_attribute); j++) {<br>
+ if (enum_attribute[j] == '.') {<br>
+ idx = j;<br>
+ }<br>
+ }<br>
+<br>
+ if (idx > 0) {<br>
+ enum_name = enum_attribute + idx + 1;<br>
+<br>
+ wl_list_for_each(i, &protocol->interface_list, link)<br>
+ if (strncmp(i->name, enum_attribute, idx) == 0)<br>
+ wl_list_for_each(e, &i->enumeration_list, link)<br>
+ if(strcmp(e->name, enum_name) == 0)<br>
+ f = e;<br>
+ } else if (interface) {<br>
+ enum_name = enum_attribute;<br>
+<br>
+ wl_list_for_each(e, &interface->enumeration_list, link)<br>
+ if(strcmp(e->name, enum_name) == 0)<br>
+ f = e;<br>
+ }<br>
+<br>
+ return f;<br>
+}<br>
+<br>
static void<br>
-verify_arguments(struct parse_context *ctx, struct wl_list *messages, struct wl_list *enumerations)<br>
+verify_arguments(struct parse_context *ctx, struct interface *interface, struct wl_list *messages, struct wl_list *enumerations)<br>
{<br>
struct message *m;<br>
wl_list_for_each(m, messages, link) {<br>
struct arg *a;<br>
wl_list_for_each(a, &m->arg_list, link) {<br>
- struct enumeration *e, *f;<br>
+ struct enumeration *e;<br>
<br>
if (!a->enumeration_name)<br>
continue;<br>
<br>
- f = NULL;<br>
- wl_list_for_each(e, enumerations, link) {<br>
- if(strcmp(e->name, a->enumeration_name) == 0)<br>
- f = e;<br>
- }<br>
<br>
- if (f == NULL)<br>
+ e = find_enumeration(ctx->protocol, interface, a->enumeration_name);<br>
+<br>
+ if (e == NULL)<br>
fail(&ctx->loc,<br>
"could not find enumeration %s",<br>
a->enumeration_name);<br>
<br>
switch (a->type) {<br>
case INT:<br>
- if (f->bitfield)<br>
+ if (e->bitfield)<br>
fail(&ctx->loc,<br>
"bitfield-style enum must only be referenced by uint");<br>
break;<br>
@@ -848,12 +878,13 @@ end_element(void *data, const XML_Char *name)<br>
ctx->enumeration->name);<br>
}<br>
ctx->enumeration = NULL;<br>
- } else if (strcmp(name, "interface") == 0) {<br>
- struct interface *i = ctx->interface;<br>
-<br>
- verify_arguments(ctx, &i->request_list, &i->enumeration_list);<br>
- verify_arguments(ctx, &i->event_list, &i->enumeration_list);<br>
+ } else if (strcmp(name, "protocol") == 0) {<br>
+ struct interface *i;<br>
<br>
+ wl_list_for_each(i, &ctx->protocol->interface_list, link) {<br>
+ verify_arguments(ctx, i, &i->request_list, &i->enumeration_list);<br>
+ verify_arguments(ctx, i, &i->event_list, &i->enumeration_list);<br>
+ }<br>
}<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.6.2<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</font></span></blockquote></div><br></div>