Support noexcept with a conditional.

Turns out Doxygen doesn't like BOOST_NOEXCEPT_IF. Text parsing in XSL is an
almighty pain, it might be better to just combine whatever follows the
arguments in argsstring with the values from the attributes.

[SVN r86285]
This commit is contained in:
Daniel James 2013-10-13 11:10:38 +00:00
parent 9e391505c4
commit 885ed7e8c7
3 changed files with 56 additions and 4 deletions

View File

@ -31,7 +31,9 @@
<method name="const_method" cv="const"><type>void</type></method> <method name="const_method" cv="const"><type>void</type></method>
<method name="volatile_method" cv="volatile"><type>void</type></method> <method name="volatile_method" cv="volatile"><type>void</type></method>
<method name="trad_noexcept" cv="noexcept"><type>void</type></method> <method name="trad_noexcept" cv="noexcept"><type>void</type></method>
<method name="trad_noexcept_if" cv="noexcept(a==b &amp;&amp;(c||d)))"><type>void</type></method>
<method name="boost_noexcept" cv="noexcept"><type>void</type></method> <method name="boost_noexcept" cv="noexcept"><type>void</type></method>
<method name="boost_noexcept_if" cv="noexcept(condition)"><type>void</type></method>
<method name="trad_constexpr" cv="constexpr"><type>void</type></method> <method name="trad_constexpr" cv="constexpr"><type>void</type></method>
<method name="boost_constexpr" cv="constexpr"><type>void</type></method> <method name="boost_constexpr" cv="constexpr"><type>void</type></method>
<method name="boost_constexpr_or_const" cv="constexpr"><type>void</type></method> <method name="boost_constexpr_or_const" cv="constexpr"><type>void</type></method>

View File

@ -55,7 +55,9 @@ namespace example
void volatile_method() volatile; void volatile_method() volatile;
void trad_noexcept() noexcept; void trad_noexcept() noexcept;
void trad_noexcept_if() noexcept(a == b && (c || d));
void boost_noexcept() BOOST_NOEXCEPT; void boost_noexcept() BOOST_NOEXCEPT;
void boost_noexcept_if() BOOST_NOEXCEPT_IF(a == b && (c || d));
void trad_constexpr() constexpr; void trad_constexpr() constexpr;
void boost_constexpr() BOOST_CONSTEXPR; void boost_constexpr() BOOST_CONSTEXPR;

View File

@ -1078,19 +1078,43 @@
<!-- CV Qualifiers --> <!-- CV Qualifiers -->
<!-- Plus deleted and defaulted function markers as they're not properly <!-- Plus deleted and defaulted function markers as they're not properly
supported in boostbook --> supported in boostbook -->
<!-- The 'substring' trick includes the string if the condition is true -->
<!-- noexcept is complicated because is can have parameters.
TODO: should really remove the noexcept parameters before doing
anything else. -->
<xsl:variable name="noexcept">
<xsl:choose>
<xsl:when test="contains($extra-qualifiers, ' noexcept(')">
<xsl:call-template name="noexcept-if">
<xsl:with-param name="condition" select="substring-after($extra-qualifiers, ' noexcept(')" />
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($extra-qualifiers, ' BOOST_NOEXCEPT_IF(')">
<xsl:call-template name="noexcept-if">
<xsl:with-param name="condition" select="substring-after($extra-qualifiers, ' BOOST_NOEXCEPT_IF(')" />
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($extra-qualifiers, ' noexcept ') or contains($extra-qualifiers, ' BOOST_NOEXCEPT ')">
<xsl:value-of select="'noexcept '" />
</xsl:when>
</xsl:choose>
</xsl:variable>
<!-- Calculate constexpr now, so that we can avoid it getting confused
with const -->
<xsl:variable name="constexpr" select=" <xsl:variable name="constexpr" select="
contains($extra-qualifiers, ' const expr ') or contains($extra-qualifiers, ' const expr ') or
contains($extra-qualifiers, ' BOOST_CONSTEXPR ') or contains($extra-qualifiers, ' BOOST_CONSTEXPR ') or
contains($extra-qualifiers, ' BOOST_CONSTEXPR_OR_CONST ')" /> contains($extra-qualifiers, ' BOOST_CONSTEXPR_OR_CONST ')" />
<!-- The 'substring' trick includes the string if the condition is true -->
<xsl:variable name="cv-qualifiers" select="normalize-space(concat( <xsl:variable name="cv-qualifiers" select="normalize-space(concat(
substring('constexpr ', 1, 999 * $constexpr), substring('constexpr ', 1, 999 * $constexpr),
substring('const ', 1, 999 * (not($constexpr) and @const='yes')), substring('const ', 1, 999 * (not($constexpr) and @const='yes')),
substring('volatile ', 1, 999 * (@volatile='yes' or contains($extra-qualifiers, ' volatile '))), substring('volatile ', 1, 999 * (@volatile='yes' or contains($extra-qualifiers, ' volatile '))),
substring('noexcept ', 1, 999 * ( $noexcept,
contains($extra-qualifiers, ' noexcept ') or
contains($extra-qualifiers, ' BOOST_NOEXCEPT '))),
substring('= delete ', 1, 999 * contains($extra-qualifiers, ' =delete ')), substring('= delete ', 1, 999 * contains($extra-qualifiers, ' =delete ')),
substring('= default ', 1, 999 * contains($extra-qualifiers, ' =default ')), substring('= default ', 1, 999 * contains($extra-qualifiers, ' =default ')),
substring('= 0 ', 1, 999 * (@virt = 'pure-virtual')), substring('= 0 ', 1, 999 * (@virt = 'pure-virtual')),
@ -1118,6 +1142,30 @@
</xsl:template> </xsl:template>
<!-- $condition = string after the opening bracket of the condition -->
<xsl:template name="noexcept-if">
<xsl:param name="condition"/>
<xsl:variable name="trailing">
<xsl:call-template name="strip-brackets">
<xsl:with-param name="text" select="$condition" />
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="string-length($trailing)">
<xsl:value-of select="concat(
'noexcept(',
substring($condition, 1, string-length($condition) - string-length($trailing)),
') ')" />
</xsl:when>
<xsl:otherwise>
<!-- Something has gone wrong so: -->
<xsl:value-of select="'noexcept(condition) '" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- $text = substring after the opening bracket --> <!-- $text = substring after the opening bracket -->
<xsl:template name="strip-brackets"> <xsl:template name="strip-brackets">
<xsl:param name="text"/> <xsl:param name="text"/>