[Xcb-commit] 2 commits - xcb

Josh Triplett josh at kemper.freedesktop.org
Sun Jul 30 22:04:40 PDT 2006


 xcb/src/c-client.xsl |   58 ++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 42 insertions(+), 16 deletions(-)

New commits:
diff-tree 091b4c805aa454277aa6b98bee8e8ec0646a9604 (from 197d89aa187c4969f538d41ea9dbe78dd1bb6707)
Author: Josh Triplett <josh at freedesktop.org>
Date:   Sun Jul 30 22:02:37 2006 -0700

    Implement error handling plan 7.
    
    Needs improvement: should not duplicate the code of every request function.

diff --git a/xcb/src/c-client.xsl b/xcb/src/c-client.xsl
index e58d990..218e093 100644
--- a/xcb/src/c-client.xsl
+++ b/xcb/src/c-client.xsl
@@ -217,6 +217,33 @@ authorization from the authors.
     <xsl:text>Cookie</xsl:text>
   </xsl:template>
 
+  <xsl:template name="request-function">
+    <xsl:param name="checked" />
+    <xsl:param name="req" />
+    <function>
+      <xsl:attribute name="name">
+        <xsl:text>XCB</xsl:text>
+        <xsl:value-of select="$ext" />
+        <xsl:value-of select="$req/@name" />
+        <xsl:if test="$checked='true' and not($req/reply)">Checked</xsl:if>
+        <xsl:if test="$checked='false' and $req/reply">Unchecked</xsl:if>
+      </xsl:attribute>
+      <xsl:attribute name="type">
+        <xsl:call-template name="cookie-type">
+          <xsl:with-param name="request" select="$req" />
+        </xsl:call-template>
+      </xsl:attribute>
+      <field type="XCBConnection *" name="c" />
+      <xsl:apply-templates select="$req/*[not(self::reply)]" mode="param" />
+      <do-request ref="XCB{$ext}{$req/@name}Req" opcode="{$req/@opcode}"
+                  checked="{$checked}">
+        <xsl:if test="$req/reply">
+          <xsl:attribute name="has-reply">true</xsl:attribute>
+        </xsl:if>
+      </do-request>
+    </function>
+  </xsl:template>
+  
   <xsl:template match="request" mode="pass1">
     <xsl:variable name="req" select="." />
     <xsl:if test="reply">
@@ -234,20 +261,14 @@ authorization from the authors.
         <field type="CARD16" name="length" no-assign="true" />
       </middle>
     </struct>
-    <function name="XCB{$ext}{$req/@name}">
-      <xsl:attribute name="type">
-        <xsl:call-template name="cookie-type">
-          <xsl:with-param name="request" select="$req" />
-        </xsl:call-template>
-      </xsl:attribute>
-      <field type="XCBConnection *" name="c" />
-      <xsl:apply-templates select="$req/*[not(self::reply)]" mode="param" />
-      <do-request ref="XCB{$ext}{$req/@name}Req" opcode="{$req/@opcode}">
-        <xsl:if test="$req/reply">
-          <xsl:attribute name="has-reply">true</xsl:attribute>
-        </xsl:if>
-      </do-request>
-    </function>
+    <xsl:call-template name="request-function">
+      <xsl:with-param name="checked" select="'true'" />
+      <xsl:with-param name="req" select="$req" />
+    </xsl:call-template>
+    <xsl:call-template name="request-function">
+      <xsl:with-param name="checked" select="'false'" />
+      <xsl:with-param name="req" select="$req" />
+    </xsl:call-template>
     <xsl:if test="reply">
       <struct name="XCB{$ext}{@name}Rep">
         <field type="BYTE" name="response_type" />
@@ -612,7 +633,7 @@ authorization from the authors.
 
     <l>xcb_ret.sequence = XCBSendRequest(c, <!--
     --><xsl:choose>
-         <xsl:when test="@has-reply">XCB_REQUEST_CHECKED</xsl:when>
+         <xsl:when test="@checked='true'">XCB_REQUEST_CHECKED</xsl:when>
          <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose>, xcb_parts + 2, &amp;xcb_req);</l>
     <l>return xcb_ret;</l>
diff-tree 197d89aa187c4969f538d41ea9dbe78dd1bb6707 (from 82b1e18f0b0bef74d5b9d30bc763d7a196866658)
Author: Josh Triplett <josh at freedesktop.org>
Date:   Sun Jul 30 20:28:16 2006 -0700

    Parameterize context in cookie-type and request-matching template.

diff --git a/xcb/src/c-client.xsl b/xcb/src/c-client.xsl
index 8a2d82e..e58d990 100644
--- a/xcb/src/c-client.xsl
+++ b/xcb/src/c-client.xsl
@@ -201,12 +201,14 @@ authorization from the authors.
   </xsl:template>
   
   <!-- Helper template for requests, that outputs the cookie type.  The
-       context node must be the request. -->
+       parameter "request" must be the request node, which defaults to the
+       context node. -->
   <xsl:template name="cookie-type">
+    <xsl:param name="request" select="." />
     <xsl:text>XCB</xsl:text>
     <xsl:choose>
-      <xsl:when test="reply">
-        <xsl:value-of select="concat($ext, @name)" />
+      <xsl:when test="$request/reply">
+        <xsl:value-of select="concat($ext, $request/@name)" />
       </xsl:when>
       <xsl:otherwise>
         <xsl:text>Void</xsl:text>
@@ -216,6 +218,7 @@ authorization from the authors.
   </xsl:template>
 
   <xsl:template match="request" mode="pass1">
+    <xsl:variable name="req" select="." />
     <xsl:if test="reply">
       <struct name="XCB{$ext}{@name}Cookie">
         <field type="unsigned int" name="sequence" />
@@ -231,14 +234,16 @@ authorization from the authors.
         <field type="CARD16" name="length" no-assign="true" />
       </middle>
     </struct>
-    <function name="XCB{$ext}{@name}">
+    <function name="XCB{$ext}{$req/@name}">
       <xsl:attribute name="type">
-        <xsl:call-template name="cookie-type" />
+        <xsl:call-template name="cookie-type">
+          <xsl:with-param name="request" select="$req" />
+        </xsl:call-template>
       </xsl:attribute>
       <field type="XCBConnection *" name="c" />
-      <xsl:apply-templates select="*[not(self::reply)]" mode="param" />
-      <do-request ref="XCB{$ext}{@name}Req" opcode="{@opcode}">
-        <xsl:if test="reply">
+      <xsl:apply-templates select="$req/*[not(self::reply)]" mode="param" />
+      <do-request ref="XCB{$ext}{$req/@name}Req" opcode="{$req/@opcode}">
+        <xsl:if test="$req/reply">
           <xsl:attribute name="has-reply">true</xsl:attribute>
         </xsl:if>
       </do-request>


More information about the xcb-commit mailing list