aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--header-generator.xsl150
1 files changed, 104 insertions, 46 deletions
diff --git a/header-generator.xsl b/header-generator.xsl
index fc33bc6c..a9d23a21 100644
--- a/header-generator.xsl
+++ b/header-generator.xsl
@@ -23,13 +23,55 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
don't work ideally in the presence of two things that want to use the
absence of a prefix, sadly. -->
- <xsl:strip-space elements="node interface property tp:errors tp:mapping
- tp:member"/>
+ <xsl:strip-space elements="node interface property tp:errors tp:mapping tp:member"/>
<xsl:template match="*" mode="identity">
<xsl:copy>
<xsl:apply-templates mode="identity"/>
</xsl:copy>
</xsl:template>
+ <xsl:template name="CamelCase">
+ <xsl:param name="text" />
+ <xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'"/>
+ <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
+ <xsl:if test="$text">
+ <!-- get word to title-case -->
+ <xsl:variable name="word">
+ <xsl:choose>
+ <xsl:when test="contains($text, '_')">
+ <xsl:value-of select="substring-before($text, '_')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$text"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <!-- uppercase first character in word -->
+ <xsl:value-of select="translate(substring($word,1,1), $lowercase, $uppercase)"/>
+ <!-- lowercase all remaining characters in word -->
+ <xsl:value-of select="translate(substring($word,2), $uppercase, $lowercase)"/>
+ <!-- if any next chunk, recall template -->
+ <xsl:call-template name="CamelCase">
+ <xsl:with-param name="text" select="substring-after(substring($text,2), '_')"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>
+<!--
+ <xsl:variable name="thisletter" select="substring($text,1,1)"/>
+ <xsl:choose>
+ <xsl:when test="$lastletter=' ' or $lastletter='_'">
+ <xsl:value-of select="translate($thisletter,'abcdefghijklmnopqrstuvwxyz',
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="translate($thisletter,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:call-template name="TitleCase">
+ <xsl:with-param name="text" select="substring($text,2)"/>
+ <xsl:with-param name="lastletter" select="$thisletter"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>-->
<xsl:template match="tp:docstring">
</xsl:template>
<xsl:template match="tp:realdocstring">
@@ -68,49 +110,55 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
<xsl:template match="tp:flags">
/* <xsl:value-of select="@name"/> flag values */
-<xsl:apply-templates select="tp:docstring" />
- <xsl:variable name="value-prefix">
- <xsl:choose>
- <xsl:when test="@value-prefix">
- <xsl:value-of select="@value-prefix"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="@name"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:for-each select="tp:flag">
- <xsl:choose>
- <xsl:when test="tp:docstring">
- <xsl:apply-templates select="tp:docstring"/>
- </xsl:when>
- </xsl:choose>
-#define <xsl:value-of select="concat($value-prefix, '_', @suffix)"/><xsl:text> </xsl:text><xsl:value-of select="@value"/>
- </xsl:for-each><xsl:text>
+ <xsl:apply-templates select="tp:docstring" />
+ <xsl:variable name="value-prefix">
+ <xsl:choose>
+ <xsl:when test="@value-prefix">
+ <xsl:value-of select="@value-prefix"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@name"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="enum-name">
+ <xsl:call-template name="CamelCase">
+ <xsl:with-param name="text" select="substring-after(@name,'MM_')"/>
+ </xsl:call-template>
+ </xsl:variable>
+typedef enum {
+<xsl:for-each select="tp:flag">
+<xsl:text> </xsl:text><xsl:value-of select="concat($value-prefix, '_', @suffix)"/><xsl:text> = </xsl:text><xsl:value-of select="@value"/><xsl:text>,
+</xsl:text>
+</xsl:for-each>
+<xsl:text>} </xsl:text><xsl:value-of select="concat('MM',$enum-name)"/><xsl:text>;
</xsl:text>
</xsl:template>
<xsl:template match="tp:enum">
/* <xsl:value-of select="@name"/> enum values */
-<xsl:apply-templates select="tp:docstring" />
- <xsl:variable name="value-prefix">
- <xsl:choose>
- <xsl:when test="@value-prefix">
- <xsl:value-of select="@value-prefix"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="@name"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:for-each select="tp:enumvalue">
- <xsl:choose>
- <xsl:when test="tp:docstring">
- <xsl:apply-templates select="tp:docstring" />
- </xsl:when>
- </xsl:choose>
-#define <xsl:value-of select="concat($value-prefix, '_', @suffix, ' ')"/><xsl:value-of select="@value"/>
- </xsl:for-each><xsl:text>
+ <xsl:apply-templates select="tp:docstring" />
+ <xsl:variable name="value-prefix">
+ <xsl:choose>
+ <xsl:when test="@value-prefix">
+ <xsl:value-of select="@value-prefix"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@name"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="enum-name">
+ <xsl:call-template name="CamelCase">
+ <xsl:with-param name="text" select="substring-after(@name,'MM_')"/>
+ </xsl:call-template>
+ </xsl:variable>
+typedef enum {
+<xsl:for-each select="tp:enumvalue">
+<xsl:text> </xsl:text><xsl:value-of select="concat($value-prefix, '_', @suffix)"/><xsl:text> = </xsl:text><xsl:value-of select="@value"/><xsl:text>,
+</xsl:text>
+</xsl:for-each>
+<xsl:text>} </xsl:text><xsl:value-of select="concat('MM',$enum-name)"/><xsl:text>;
</xsl:text>
</xsl:template>
@@ -204,8 +252,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef _MODEM_MANAGER_H_
#define _MODEM_MANAGER_H_
-#define MM_MODEMMANAGER_PATH "/org/freedesktop/ModemManager"
-#define MM_MODEMMANAGER_SERVICE "org.freedesktop.ModemManager"
+#define MM_DBUS_PATH "/org/freedesktop/ModemManager"
+#define MM_DBUS_SERVICE "org.freedesktop.ModemManager"
/**************
* Interfaces *
@@ -220,13 +268,22 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="translate(substring-after(@name, 'org.freedesktop.'),
- 'abcdefghijklmnopqrstuvwxyz. ',
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/>
+ <xsl:text></xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
-#define <xsl:value-of select="concat('MM_', $varname, '_INTERFACE ')"/> "<xsl:value-of select="@name"/>"</xsl:for-each>
+ <xsl:variable name="prefix">
+ <xsl:choose>
+ <xsl:when test="string-length($varname) > 0">
+ <xsl:text>_</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text></xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:if test="starts-with(@name, 'org.freedesktop.ModemManager')">
+#define <xsl:value-of select="concat('MM_DBUS_INTERFACE', $prefix, $varname)"/> "<xsl:value-of select="@name"/>"</xsl:if></xsl:for-each>
/***********************
* Methods/Enums/Flags *
@@ -248,6 +305,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
<xsl:apply-templates select="tp:enum"/>
<xsl:apply-templates select="tp:flags"/>
</xsl:for-each>
+
/**********
* Errors *
**********/