Merge branch 'master' of git+ssh://git.freedesktop.org/git/xcb
[free-sw/xcb/libxcb] / src / c-client.xsl
index 903895d..56dbaac 100644 (file)
@@ -567,7 +567,7 @@ authorization from the authors.
     <xsl:variable name="struct"
                   select="$pass1/xcb/struct[@name=current()/@ref]" />
 
-    <xsl:variable name="num-parts" select="1+count($struct/list)" />
+    <xsl:variable name="num-parts" select="(1+count($struct/list))*2" />
 
     <l>static const XCBProtocolRequest xcb_req = {</l>
     <indent>
@@ -586,7 +586,7 @@ authorization from the authors.
     <l>};</l>
 
     <l />
-    <l>struct iovec xcb_parts[<xsl:value-of select="$num-parts" />];</l>
+    <l>struct iovec xcb_parts[<xsl:value-of select="$num-parts+2" />];</l>
     <l><xsl:value-of select="../@type" /> xcb_ret;</l>
     <l><xsl:value-of select="@ref" /> xcb_out;</l>
 
@@ -596,22 +596,30 @@ authorization from the authors.
                          mode="assign" />
 
     <l />
-    <l>xcb_parts[0].iov_base = &amp;xcb_out;</l>
-    <l>xcb_parts[0].iov_len = sizeof(xcb_out);</l>
+    <l>xcb_parts[2].iov_base = (char *) &amp;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 &amp; 3;</l>
 
     <xsl:for-each select="$struct/list">
-      <l>xcb_parts[<xsl:number />].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 />].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: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 &amp; 3;</l>
     </xsl:for-each>
 
-    <l>XCBSendRequest(c, &amp;xcb_ret.sequence, xcb_parts, &amp;xcb_req);</l>
+    <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 + 2, &amp;xcb_req);</l>
     <l>return xcb_ret;</l>
   </xsl:template>
 
@@ -1081,6 +1089,12 @@ authorization from the authors.
     <xsl:text>)</xsl:text>
   </xsl:template>
 
+  <xsl:template match="bit" mode="output-expression">
+    <xsl:text>(1 &lt;&lt; </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" />