<xsl:for-each select="/xcb/import">
<path><xsl:value-of select="concat($extension-path, ., '.xml')" /></path>
</xsl:for-each>
- <xsl:choose>
- <xsl:when test="$header='xproto'">
- <path><xsl:value-of select="concat($base-path,
- 'xcb_types.xml')" /></path>
- </xsl:when>
- <xsl:when test="$header='xcb_types'" />
- <xsl:otherwise>
- <path><xsl:value-of select="concat($base-path,
- 'xproto.xml')" /></path>
- <path><xsl:value-of select="concat($base-path,
- 'xcb_types.xml')" /></path>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:if test="not($header='xproto')">
+ <path><xsl:value-of select="concat($base-path, 'xproto.xml')" /></path>
+ </xsl:if>
</xsl:variable>
<xsl:variable name="search-path" select="e:node-set($search-path-rtf)/path"/>
<xsl:variable name="struct"
select="$pass1/xcb/struct[@name=current()/@ref]" />
- <xsl:variable name="num-parts" select="1+count($struct/list)*2" />
+ <xsl:variable name="num-parts" select="(1+count($struct/list))*2" />
<l>static const XCBProtocolRequest xcb_req = {</l>
<indent>
mode="assign" />
<l />
- <l>xcb_parts[0].iov_base = &xcb_out;</l>
- <l>xcb_parts[0].iov_len = sizeof(xcb_out);</l>
- <l>xcb_parts[1].iov_base = 0;</l>
- <l>xcb_parts[1].iov_len = -xcb_parts[0].iov_len & 3;</l>
+ <l>xcb_parts[2].iov_base = (char *) &xcb_out;</l>
+ <l>xcb_parts[2].iov_len = sizeof(xcb_out);</l>
+ <l>xcb_parts[3].iov_base = 0;</l>
+ <l>xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;</l>
<xsl:for-each select="$struct/list">
- <l>xcb_parts[<xsl:number /> * 2].iov_base = (void *) <!--
+ <l>xcb_parts[<xsl:value-of select="2 + position() * 2"/>].iov_base = (char *) <!--
--><xsl:value-of select="@name" />;</l>
- <l>xcb_parts[<xsl:number /> * 2].iov_len = <!--
+ <l>xcb_parts[<xsl:value-of select="2 + position() * 2"/>].iov_len = <!--
--><xsl:apply-templates mode="output-expression" /><!--
--><xsl:if test="not(@type = 'void')">
<xsl:text> * sizeof(</xsl:text>
<xsl:value-of select="@type" />
<xsl:text>)</xsl:text>
</xsl:if>;</l>
- <l>xcb_parts[<xsl:number /> * 2 + 1].iov_base = 0;</l>
- <l>xcb_parts[<xsl:number /> * 2 + 1].iov_len = -xcb_parts[<xsl:number /> * 2].iov_len & 3;</l>
+ <l>xcb_parts[<xsl:value-of select="3 + position() * 2"/>].iov_base = 0;</l>
+ <l>xcb_parts[<xsl:value-of select="3 + position() * 2"/>].iov_len = -xcb_parts[<xsl:value-of select="2 + position() * 2"/>].iov_len & 3;</l>
</xsl:for-each>
- <l>XCBSendRequest(c, &xcb_ret.sequence, <!--
+ <l>xcb_ret.sequence = XCBSendRequest(c, <!--
--><xsl:choose>
<xsl:when test="@has-reply">XCB_REQUEST_CHECKED</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
- </xsl:choose>, xcb_parts, &xcb_req);</l>
+ </xsl:choose>, xcb_parts + 2, &xcb_req);</l>
<l>return xcb_ret;</l>
</xsl:template>
/*[self::valueparam or self::list]" />
<xsl:if test="not($is-variable)">
<function type="{@type} *" name="{$ref}{$field-name}">
- <field type="{$ref}{$kind} *" name="R" />
+ <field type="const {$ref}{$kind} *" name="R" />
<xsl:choose>
<xsl:when test="$is-first">
<l>return (<xsl:value-of select="@type" /> *) <!--
</function>
</xsl:if>
<function type="int" name="{$ref}{$field-name}Length">
- <field type="{$ref}{$kind} *" name="R" />
+ <field type="const {$ref}{$kind} *" name="R" />
<l>return <xsl:apply-templates mode="output-expression">
<xsl:with-param name="field-prefix" select="'R->'" />
</xsl:apply-templates>;</l>
<xsl:choose>
<xsl:when test="substring(@type, 1, 3) = 'XCB'">
<function type="{@type}Iter" name="{$ref}{$field-name}Iter">
- <field type="{$ref}{$kind} *" name="R" />
+ <field type="const {$ref}{$kind} *" name="R" />
<l><xsl:value-of select="@type" />Iter i;</l>
<xsl:choose>
<xsl:when test="$is-first">
</xsl:choose>
</xsl:variable>
<function type="XCBGenericIter" name="{$ref}{$field-name}End">
- <field type="{$ref}{$kind} *" name="R" />
+ <field type="const {$ref}{$kind} *" name="R" />
<l>XCBGenericIter i;</l>
<xsl:choose>
<xsl:when test="$is-first">
<xsl:text>)</xsl:text>
</xsl:template>
+ <xsl:template match="bit" mode="output-expression">
+ <xsl:text>(1 << </xsl:text>
+ <xsl:value-of select="." />
+ <xsl:text>)</xsl:text>
+ </xsl:template>
+
<xsl:template match="function-call" mode="output-expression">
<xsl:param name="field-prefix" />
<xsl:value-of select="@name" />