closed brace for qt_metacall function
[lqt.git] / xslt / lqt2cppxml.xsl
blob12e3c32ae4162256326475f959ec03d2986f1f8e
1 <?xml version="1.0" encoding="utf-8"?>
2 <xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4 <xsl:output method="xml" indent="yes"/>
5 <xsl:strip-space elements="*"/>
7 <xsl:template match="/">
8 <lib>
9 <xsl:apply-templates/>
10 </lib>
11 </xsl:template>
13 <xsl:template match="Class">
14 <type name="{@fullname}">
15 <struct>
16 <xsl:call-template name="base-classes">
17 <xsl:with-param name="bases" select="@bases"/>
18 </xsl:call-template>
19 <xsl:apply-templates match="Function|FunctionDefinition" mode="member"/>
20 </struct>
21 </type>
22 </xsl:template>
24 <xsl:template match="Function|FunctionDefinition" mode="member">
25 <xsl:variable name="type">
26 <xsl:choose>
27 <xsl:when test="@name = ../@name">
28 <xsl:value-of select="'constructor'"/>
29 </xsl:when>
30 <xsl:when test="@name = concat('~', ../@name)">
31 <xsl:value-of select="'destructor'"/>
32 </xsl:when>
33 <xsl:when test="@static">
34 <xsl:value-of select="'function'"/>
35 </xsl:when>
36 <xsl:otherwise>
37 <xsl:value-of select="'method'"/>
38 </xsl:otherwise>
39 </xsl:choose>
40 </xsl:variable>
41 <xsl:element name="{$type}">
42 <xsl:attribute name="name">
43 <xsl:value-of select="@name"/>
44 </xsl:attribute>
45 <xsl:attribute name="access"><xsl:value-of select="@access"/></xsl:attribute>
46 <return>
47 <xsl:call-template name="convert-type">
48 <xsl:with-param name="reference" select="@type_reference"/>
49 <xsl:with-param name="indirections" select="@indirections"/>
50 <xsl:with-param name="type" select="@type_base"/>
51 <xsl:with-param name="qualifier">
52 <xsl:call-template name="make-qualifier">
53 <xsl:with-param name="const" select="@type_constant"/>
54 <xsl:with-param name="volatile" select="@type_volatile"/>
55 </xsl:call-template>
56 </xsl:with-param>
57 </xsl:call-template>
58 </return>
59 <xsl:if test="not(@static)">
60 <this>
61 <xsl:call-template name="convert-type">
62 <xsl:with-param name="indirections" select="1"/>
63 <xsl:with-param name="type" select="@member_of_class"/>
64 <xsl:with-param name="qualifier">
65 <xsl:call-template name="make-qualifier">
66 <xsl:with-param name="const" select="@constant"/>
67 <xsl:with-param name="volatile" select="@volatile"/>
68 </xsl:call-template>
69 </xsl:with-param>
70 </xsl:call-template>
71 </this>
72 </xsl:if>
73 <xsl:apply-templates match="Argument" mode="param"/>
74 <xsl:choose>
75 <xsl:when test="@abstract"><abstract/></xsl:when>
76 <xsl:when test="@virtual"><virtual/></xsl:when>
77 </xsl:choose>
78 </xsl:element>
79 </xsl:template>
81 <xsl:template match="Argument" mode="param">
82 <param>
83 <xsl:if test="@name != ''">
84 <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
85 </xsl:if>
86 <xsl:if test="@default='1'">
87 <default value="{@defaultvalue}"/>
88 </xsl:if>
89 <xsl:call-template name="convert-type">
90 <xsl:with-param name="reference" select="@type_reference"/>
91 <xsl:with-param name="indirections" select="@indirections"/>
92 <xsl:with-param name="type" select="@type_base"/>
93 <xsl:with-param name="qualifier">
94 <xsl:call-template name="make-qualifier">
95 <xsl:with-param name="const" select="@type_constant"/>
96 <xsl:with-param name="volatile" select="@type_volatile"/>
97 </xsl:call-template>
98 </xsl:with-param>
99 </xsl:call-template>
100 </param>
101 </xsl:template>
103 <xsl:template name="make-qualifier">
104 <xsl:param name="const"/>
105 <xsl:param name="volatile"/>
106 <xsl:choose>
107 <xsl:when test="$const and $volatile"><xsl:value-of select="'const volatile'"/></xsl:when>
108 <xsl:when test="$const"><xsl:value-of select="'const'"/></xsl:when>
109 <xsl:when test="$volatile"><xsl:value-of select="'volatile'"/></xsl:when>
110 </xsl:choose>
111 </xsl:template>
113 <xsl:template name="convert-type">
114 <xsl:param name="reference"/>
115 <xsl:param name="indirections"/>
116 <xsl:param name="type"/>
117 <xsl:param name="qualifier"/>
119 <xsl:choose>
120 <xsl:when test="$reference">
121 <reference>
122 <xsl:call-template name="convert-type">
123 <xsl:with-param name="indirections" select="$indirections"/>
124 <xsl:with-param name="type" select="$type"/>
125 <xsl:with-param name="qualifier" select="$qualifier"/>
126 </xsl:call-template>
127 </reference>
128 </xsl:when>
129 <xsl:when test="$indirections and $indirections &gt; 0">
130 <pointer>
131 <xsl:call-template name="convert-type">
132 <xsl:with-param name="indirections" select="$indirections - 1"/>
133 <xsl:with-param name="type" select="$type"/>
134 <xsl:with-param name="qualifier" select="$qualifier"/>
135 </xsl:call-template>
136 </pointer>
137 </xsl:when>
138 <xsl:otherwise>
139 <type name="{$type}">
140 <xsl:if test="$qualifier != ''">
141 <xsl:attribute name="qualifier"><xsl:value-of select="$qualifier"/></xsl:attribute>
142 </xsl:if>
143 </type>
144 </xsl:otherwise>
145 </xsl:choose>
146 </xsl:template>
148 <xsl:template name="base-classes">
149 <xsl:param name="bases"/>
150 <xsl:if test="contains($bases, ';')">
151 <base class="{substring-before($bases, ';')}" access="public"/>
152 <xsl:call-template name="base-classes">
153 <xsl:with-param name="bases" select="substring-after($bases, ';')"/>
154 </xsl:call-template>
155 </xsl:if>
156 </xsl:template>
158 </xsl:stylesheet>