summaryrefslogtreecommitdiff
path: root/qpid/cpp/etc/stylesheets/code_gen.xsl
blob: 055c40e9ea432ddd1267b4a31717e570bc2db860 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?xml version='1.0'?> 
<!--
 -
 - Licensed to the Apache Software Foundation (ASF) under one
 - or more contributor license agreements.  See the NOTICE file
 - distributed with this work for additional information
 - regarding copyright ownership.  The ASF licenses this file
 - to you under the Apache License, Version 2.0 (the
 - "License"); you may not use this file except in compliance
 - with the License.  You may obtain a copy of the License at
 - 
 -   http://www.apache.org/licenses/LICENSE-2.0
 - 
 - Unless required by applicable law or agreed to in writing,
 - software distributed under the License is distributed on an
 - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 - KIND, either express or implied.  See the License for the
 - specific language governing permissions and limitations
 - under the License.
 -
 -->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amqp="http://amqp.org"> 

  <xsl:import href="convert_0.81.xsl"/>
  <xsl:import href="amqp_consts.xsl"/>
  <xsl:import href="amqp_server_operations.xsl"/>
  <xsl:import href="amqp_client_operations.xsl"/>
  <xsl:import href="amqp_server.xsl"/>
  <xsl:import href="amqp_client.xsl"/>
  <xsl:import href="amqp_server_handler_impl.xsl"/>
  <xsl:import href="amqp_client_handler_impl.xsl"/>

  <xsl:output method="text" indent="yes" name="textFormat"/> 
  <xsl:key name="domain-lookup" match="domains/domain" use="@domain-name"/>

  <xsl:template match="/">

    <!-- 0. Convert to 0.81 format -->
    <!--
    NOTE: The XML specification change from 0.8 to 0.81 is primarily a change to
    the XML itself, not the protocol it represents. However, at the time of this
    commit, the 0.81 specification has not been approved by the AMQP working group,
    so this converter from the 0.8 format to the 0.81 format has been included as
    a temporary measure. When the 0.81 format becomes official, then this conversion
    should be removed, and all of the templates below will revert to select=".".

    TODO: Remove this conversion when the new 0.81 spec is checked in.
    -->
    <xsl:variable name="format-v081">
      <xsl:apply-templates mode="do-amqp" select="amqp"/>
    </xsl:variable>
    <!-- == Uncomment this to view output for debugging ==
    <xsl:result-document href="convert_081.out">
        <xsl:copy-of select="$format-v081"/> 
    </xsl:result-document>
    -->

    <!-- 1. Domain to C++ type lookup table -->
    <xsl:variable name="domain-cpp-table">
      <xsl:apply-templates mode="domain-table" select="$format-v081"/>
    </xsl:variable>
    <!-- == Uncomment this to view output for debugging ==
    <xsl:result-document href="domain_cpp_table.out">
        <xsl:copy-of select="$domain-cpp-table"/> 
    </xsl:result-document>
    -->

    <!-- 2. Constant declarations (AMQP_Constants.h) -->
    <xsl:apply-templates mode="domain-consts" select="$format-v081"/>

    <!-- 3. Client and server handler pure virtual classes -->
    <xsl:apply-templates mode="server-operations-h" select="$format-v081">
      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
    </xsl:apply-templates>
    <xsl:apply-templates mode="client-operations-h" select="$format-v081">
      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
    </xsl:apply-templates>

    <!-- 4. Client and server output classes -->
    <xsl:apply-templates mode="server_h" select="$format-v081">
      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
    </xsl:apply-templates>
    <xsl:apply-templates mode="client_h" select="$format-v081">
      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
    </xsl:apply-templates>
    <xsl:apply-templates mode="server_cpp" select="$format-v081">
      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
    </xsl:apply-templates>
    <xsl:apply-templates mode="client_cpp" select="$format-v081">
      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
    </xsl:apply-templates>

    <!-- 5. Client and server handler stub classes -->
    <xsl:apply-templates mode="server_handler_impl_h" select="$format-v081">
      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
    </xsl:apply-templates>
    <xsl:apply-templates mode="client_handler_impl_h" select="$format-v081">
      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
    </xsl:apply-templates>
    <!-- TODO: Find a way to only run the .cpp stub generator when required, as
    running this will overwrite any stub code in existance! -->
    <xsl:apply-templates mode="server_handler_impl_cpp" select="$format-v081">
      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
    </xsl:apply-templates>
    <xsl:apply-templates mode="client_handler_impl_cpp" select="$format-v081">
      <xsl:with-param name="domain-cpp-table" select="$domain-cpp-table"/>
    </xsl:apply-templates>

 </xsl:template>

</xsl:stylesheet>