diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-06-07 12:07:23 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-06-07 12:07:23 +0000 |
commit | 6e1ed7a03fdd32024c08a3f69f8a803df3d34cf4 (patch) | |
tree | 952815c0d4b63a28b94fe407d302f2daace63dab /extensions | |
parent | 18981b9ccbee44b6db0dcbce68f4414db9585a11 (diff) | |
download | telepathy-salut-6e1ed7a03fdd32024c08a3f69f8a803df3d34cf4.tar.gz |
Update c-constants-generator from telepathy-glib (requires --stringparam mixed-case-prefix)
20070607120723-53eee-9918302df001ec6649c73b5072c21c0454c4d4cb.gz
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/tools/c-constants-generator.xsl | 134 |
1 files changed, 97 insertions, 37 deletions
diff --git a/extensions/tools/c-constants-generator.xsl b/extensions/tools/c-constants-generator.xsl index 2013ff14..c2492409 100644 --- a/extensions/tools/c-constants-generator.xsl +++ b/extensions/tools/c-constants-generator.xsl @@ -14,7 +14,7 @@ Library General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" @@ -23,15 +23,31 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA <xsl:output method="text" indent="no" encoding="ascii"/> - <xsl:param name="mixed-case-prefix" select="'Tp'"/> - <xsl:param name="upper-case-prefix" select="'TP_'"/> + <xsl:param name="mixed-case-prefix" select="''"/> <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/> + <xsl:variable name="upper-case-prefix" select="concat(translate($mixed-case-prefix, $lower, $upper), '_')"/> + <xsl:variable name="lower-case-prefix" select="concat(translate($mixed-case-prefix, $upper, $lower), '_')"/> + + <xsl:template match="tp:flags"> + <xsl:variable name="name"> + <xsl:choose> + <xsl:when test="@plural"> + <xsl:value-of select="@plural"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@name"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> <xsl:variable name="value-prefix"> <xsl:choose> + <xsl:when test="@singular"> + <xsl:value-of select="@singular"/> + </xsl:when> <xsl:when test="@value-prefix"> <xsl:value-of select="@value-prefix"/> </xsl:when> @@ -41,19 +57,19 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA </xsl:choose> </xsl:variable> /** - * <xsl:value-of select="translate(concat($mixed-case-prefix, @name), '_', '')"/>: + * <xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>: <xsl:apply-templates mode="flag-or-enumvalue-gtkdoc"> <xsl:with-param name="value-prefix" select="$value-prefix"/> </xsl:apply-templates> * <xsl:if test="tp:docstring"> - * <xsl:value-of select="translate(string (tp:docstring), ' ', ' ')"/> + * <![CDATA[<xsl:value-of select="translate(string (tp:docstring), ' ', ' ')"/>]]> * </xsl:if> * Bitfield/set of flags generated from the Telepathy specification. */ typedef enum { <xsl:apply-templates> <xsl:with-param name="value-prefix" select="$value-prefix"/> -</xsl:apply-templates>} <xsl:value-of select="translate(concat($mixed-case-prefix, @name), '_', '')"/>; +</xsl:apply-templates>} <xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>; </xsl:template> @@ -63,23 +79,36 @@ typedef enum { <xsl:param name="value-prefix"/> <xsl:text> * @</xsl:text> <xsl:value-of select="translate(concat($upper-case-prefix, $value-prefix, '_', @suffix), $lower, $upper)"/> - <xsl:text>: </xsl:text> + <xsl:text>: <![CDATA[</xsl:text> <xsl:value-of select="translate(string(tp:docstring), ' ', ' ')"/> - <xsl:text> </xsl:text> + <xsl:text>]]> </xsl:text> </xsl:template> <xsl:template match="tp:flag" mode="flag-or-enumvalue-gtkdoc"> <xsl:param name="value-prefix"/> <xsl:text> * @</xsl:text> <xsl:value-of select="translate(concat($upper-case-prefix, $value-prefix, '_', @suffix), $lower, $upper)"/> - <xsl:text>: </xsl:text> + <xsl:text>: <![CDATA[</xsl:text> <xsl:value-of select="translate(string(tp:docstring), ' ', ' ')"/> - <xsl:text> </xsl:text> + <xsl:text>]]> </xsl:text> </xsl:template> <xsl:template match="tp:enum"> + <xsl:variable name="name"> + <xsl:choose> + <xsl:when test="@singular"> + <xsl:value-of select="@singular"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@name"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> <xsl:variable name="value-prefix"> <xsl:choose> + <xsl:when test="@singular"> + <xsl:value-of select="@singular"/> + </xsl:when> <xsl:when test="@value-prefix"> <xsl:value-of select="@value-prefix"/> </xsl:when> @@ -93,35 +122,30 @@ typedef enum { <xsl:when test="@plural"> <xsl:value-of select="@plural"/> </xsl:when> - <!-- hack, remove these next 3 lines when the spec gets plurals --> - <xsl:when test="@name = 'Connection_Status'"> - <xsl:text>Connection_Statuses</xsl:text> - </xsl:when> <xsl:otherwise> <xsl:value-of select="@name"/><xsl:text>s</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:variable> /** - * <xsl:value-of select="translate(concat($mixed-case-prefix, @name), '_', '')"/>: + * <xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>: <xsl:apply-templates mode="flag-or-enumvalue-gtkdoc"> <xsl:with-param name="value-prefix" select="$value-prefix"/> </xsl:apply-templates> * <xsl:if test="tp:docstring"> - * <xsl:value-of select="translate(string (tp:docstring), ' ', ' ')"/> + * <![CDATA[[<xsl:value-of select="translate(string (tp:docstring), ' ', ' ')"/>]]> * </xsl:if> * Enumeration generated from the Telepathy specification. */ -<xsl:if test="tp:docstring">/* <xsl:value-of select="tp:docstring"/> */</xsl:if> typedef enum { <xsl:apply-templates> <xsl:with-param name="value-prefix" select="$value-prefix"/> -</xsl:apply-templates>} <xsl:value-of select="translate(concat($mixed-case-prefix, @name), '_', '')"/>; +</xsl:apply-templates>} <xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>; /** * NUM_<xsl:value-of select="translate(concat($upper-case-prefix, $name-plural), $lower, $upper)"/>: * - * 1 higher than the highest valid value of #<xsl:value-of select="translate(concat($mixed-case-prefix, @name), '_', '')"/>. + * 1 higher than the highest valid value of #<xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>. */ #define NUM_<xsl:value-of select="translate(concat($upper-case-prefix, $name-plural), $lower, $upper)"/> (<xsl:value-of select="tp:enumvalue[position() = last()]/@value"/>+1) @@ -129,24 +153,44 @@ typedef enum { <xsl:template match="tp:flags/tp:flag"> <xsl:param name="value-prefix"/> - <xsl:if test="@name or not(@suffix)"> - <xsl:message terminate="yes">Flag still has a name attr, or lacks suffix + <xsl:variable name="suffix"> + <xsl:choose> + <xsl:when test="@suffix"> + <xsl:value-of select="@suffix"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@name"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="name" select="translate(concat($upper-case-prefix, $value-prefix, '_', $suffix), $lower, $upper)"/> + + <xsl:if test="@name and @suffix and @name != @suffix"> + <xsl:message terminate="yes">Flag name <xsl:value-of select="@name"/> != suffix <xsl:value-of select="@suffix"/> </xsl:message> </xsl:if> - - <xsl:variable name="name" select="translate(concat($upper-case-prefix, $value-prefix, '_', @suffix), $lower, $upper)"/> <xsl:text> </xsl:text><xsl:value-of select="$name"/> = <xsl:value-of select="@value"/>, </xsl:template> <xsl:template match="tp:enum/tp:enumvalue"> <xsl:param name="value-prefix"/> - <xsl:if test="@name or not(@suffix)"> - <xsl:message terminate="yes">enumvalue has a name attr, or lacks suffix + <xsl:variable name="suffix"> + <xsl:choose> + <xsl:when test="@suffix"> + <xsl:value-of select="@suffix"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@name"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="name" select="translate(concat($upper-case-prefix, $value-prefix, '_', $suffix), $lower, $upper)"/> + + <xsl:if test="@name and @suffix and @name != @suffix"> + <xsl:message terminate="yes">Flag name <xsl:value-of select="@name"/> != suffix <xsl:value-of select="@suffix"/> </xsl:message> </xsl:if> - <xsl:variable name="name" select="translate(concat($upper-case-prefix, $value-prefix, '_', @suffix), $lower, $upper)"/> - <xsl:if test="preceding-sibling::tp:enumvalue and number(preceding-sibling::tp:enumvalue[1]/@value) > number(@value)"> <xsl:message terminate="yes">Enum values must be in ascending numeric order, but <xsl:value-of select="$name"/> is less than the previous value @@ -168,27 +212,43 @@ but <xsl:value-of select="$name"/> is less than the previous value <xsl:template match="text()"/> - <xsl:template match="/tp:spec">/* Generated from the Telepathy spec, version <xsl:value-of select="tp:version"/><xsl:text> + <xsl:template match="/tp:spec"> + <xsl:if test="$mixed-case-prefix = ''"> + <xsl:message terminate="yes"> + <xsl:text>mixed-case-prefix param must be set </xsl:text> + </xsl:message> + </xsl:if> -</xsl:text><xsl:for-each select="tp:copyright"> - <xsl:value-of select="."/><xsl:text> -</xsl:text> -</xsl:for-each> - <xsl:value-of select="tp:license"/><xsl:text> -</xsl:text><xsl:value-of select="tp:docstring"/> -*/ + <xsl:text>/* Generated from </xsl:text> + <xsl:value-of select="tp:title"/> + <xsl:if test="tp:version"> + <xsl:text>, version </xsl:text> + <xsl:value-of select="tp:version"/> + </xsl:if> + <xsl:text> </xsl:text> + <xsl:for-each select="tp:copyright"> + <xsl:value-of select="."/> + <xsl:text> </xsl:text> + </xsl:for-each> + <xsl:value-of select="tp:license"/> + <xsl:text> </xsl:text> + <xsl:value-of select="tp:docstring"/> + <xsl:text> */ #ifdef __cplusplus extern "C" { #endif -<xsl:apply-templates select="node"/> +</xsl:text> + <xsl:apply-templates select="node"/> + <xsl:text> #ifdef __cplusplus } #endif -</xsl:template> +</xsl:text> + </xsl:template> </xsl:stylesheet> |