+ <func:function name="xcb:xcb-prefix">
+ <xsl:param name="name" />
+ <func:result>
+ <xsl:text>xcb</xsl:text>
+ <xsl:choose>
+ <xsl:when test="/xcb/@extension-name = 'RandR'">
+ <xsl:text>_randr</xsl:text>
+ </xsl:when>
+ <xsl:when test="/xcb/@extension-name = 'ScreenSaver'">
+ <xsl:text>_screensaver</xsl:text>
+ </xsl:when>
+ <xsl:when test="/xcb/@extension-name = 'XF86Dri'">
+ <xsl:text>_xf86dri</xsl:text>
+ </xsl:when>
+ <xsl:when test="/xcb/@extension-name = 'XFixes'">
+ <xsl:text>_xfixes</xsl:text>
+ </xsl:when>
+ <xsl:when test="/xcb/@extension-name = 'XvMC'">
+ <xsl:text>_xvmc</xsl:text>
+ </xsl:when>
+ <xsl:when test="/xcb/@extension-name">
+ <xsl:text>_</xsl:text>
+ <xsl:call-template name="camelcase-to-underscore">
+ <xsl:with-param name="camelcase" select="/xcb/@extension-name" />
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:if test="$name">
+ <xsl:text>_</xsl:text>
+ <xsl:call-template name="camelcase-to-underscore">
+ <xsl:with-param name="camelcase" select="$name" />
+ </xsl:call-template>
+ </xsl:if>
+ </func:result>
+ </func:function>
+
+ <func:function name="xcb:lowercase">
+ <xsl:param name="name" />
+ <func:result>
+ <xsl:call-template name="camelcase-to-underscore">
+ <xsl:with-param name="camelcase" select="$name" />
+ </xsl:call-template>
+ </func:result>
+ </func:function>
+
+ <func:function name="xcb:get-char-void">
+ <xsl:param name="name" />
+ <xsl:variable name="ctype" select="substring-before($name, '_t')" />
+ <func:result>
+ <xsl:choose>
+ <xsl:when test="$ctype = 'char' or $ctype = 'void' or $ctype = 'float' or $ctype = 'double'">
+ <xsl:value-of select="$ctype" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$name" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </func:result>
+ </func:function>
+
+ <func:function name="xcb:remove-void">
+ <xsl:param name="name" />
+ <xsl:variable name="ctype" select="substring-before($name, '_t')" />
+ <func:result>
+ <xsl:choose>
+ <xsl:when test="$ctype = 'char' or $ctype = 'void' or $ctype = 'float' or $ctype = 'double'">
+ <xsl:choose>
+ <xsl:when test="$ctype = 'void'">
+ <xsl:text>char</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$ctype" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$name" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </func:result>
+ </func:function>
+
+ <!-- split camel case into words and insert underscore -->
+ <xsl:template name="camelcase-to-underscore">
+ <xsl:param name="camelcase"/>
+ <xsl:choose>
+ <xsl:when test="$camelcase='CHAR2B' or $camelcase='INT64'
+ or $camelcase='FLOAT32' or $camelcase='FLOAT64'
+ or $camelcase='BOOL32' or $camelcase='STRING8'
+ or $camelcase='Family_DECnet'">
+ <xsl:value-of select="translate($camelcase, $ucase, $lcase)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:for-each select="str:split($camelcase, '')">
+ <xsl:variable name="a" select="."/>
+ <xsl:variable name="b" select="following::*[1]"/>
+ <xsl:variable name="c" select="following::*[2]"/>
+ <xsl:value-of select="translate(., $ucase, $lcase)"/>
+ <xsl:if test="($b and contains($lcase, $a) and contains($ucase, $b))
+ or ($b and contains($digits, $a)
+ and contains($letters, $b))
+ or ($b and contains($letters, $a)
+ and contains($digits, $b))
+ or ($c and contains($ucase, $a)
+ and contains($ucase, $b)
+ and contains($lcase, $c))">
+ <xsl:text>_</xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+