Warning, /utilities/okteta/kasten/controllers/view/structures/gccxml-to-osd.xsl is written in an unsupported language. File is not indexed.
0001 <?xml version="1.0"?> 0002 <!-- 0003 0004 This stylesheet transoforms the output of gccxml into a structure definition 0005 compatible with Okteta. 0006 0007 Usage: 0008 gccxml example.cpp -fxml=example.gcc.xml 0009 xsltproc -stringparam structs complex gccxml-to-osd.xsl example.gcc.xml > example.osd 0010 0011 See: 0012 https://frinring.wordpress.com/2010/01/16/tutorial-create-your-own-okteta-structure-definitions/ 0013 https://gccxml.github.io/HTML/Index.html 0014 https://apps.kde.org/okteta 0015 0016 In case of doubts you can contact me at ale@clearmind.me 0017 0018 --> 0019 0020 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 0021 <xsl:output indent="yes" /> 0022 <!-- With this parameter you can filter the structs you're interested in --> 0023 <xsl:param name="structs" /> 0024 0025 <xsl:template match="/GCC_XML"> 0026 <data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../structuredefs.xsd"> 0027 0028 <!-- TODO: Filter only necessary enumerations --> 0029 <xsl:for-each select="Enumeration"> 0030 <xsl:call-template name="CreateEnum" select="." /> 0031 </xsl:for-each> 0032 0033 <xsl:for-each select="Struct"> 0034 <xsl:if test="not($structs) or contains(concat(' ', $structs, ' '), concat(' ', @name, ' '))"> 0035 <xsl:apply-templates select="." /> 0036 </xsl:if> 0037 </xsl:for-each> 0038 0039 </data> 0040 </xsl:template> 0041 0042 <xsl:template name="CreateEnum"> 0043 <enumDef name="{@name}" type="Int{@size}"> 0044 <xsl:for-each select="EnumValue"> 0045 <entry name="{@name}" value="{@init}" /> 0046 </xsl:for-each> 0047 </enumDef> 0048 </xsl:template> 0049 0050 <xsl:template match="Struct"> 0051 <xsl:param name="name" select="@name" /> 0052 <struct name="{$name}"> 0053 <xsl:call-template name="split"> 0054 <xsl:with-param name="list" select="@members" /> 0055 <xsl:with-param name="separator" select="' '" /> 0056 0057 </xsl:call-template> 0058 </struct> 0059 </xsl:template> 0060 0061 <xsl:template match="Union"> 0062 <xsl:param name="name" select="@name" /> 0063 <union name="{$name}"> 0064 <xsl:call-template name="split"> 0065 <xsl:with-param name="list" select="@members" /> 0066 <xsl:with-param name="separator" select="' '" /> 0067 0068 </xsl:call-template> 0069 </union> 0070 0071 </xsl:template> 0072 0073 <xsl:template match="PointerType"> 0074 <xsl:param name="name" select="false()" /> 0075 <primitive name="{$name}" type="UInt{@size}" /> 0076 </xsl:template> 0077 0078 <xsl:template match="ReferenceType"> 0079 <xsl:param name="name" select="false()" /> 0080 <primitive name="{$name}" type="UInt{@size}" /> 0081 </xsl:template> 0082 0083 0084 <xsl:template match="FundamentalType"> 0085 <xsl:param name="name" select="false()" /> 0086 <xsl:variable name="typename" select="translate(@name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnoprstuvwxyz')" /> 0087 0088 <primitive> 0089 <xsl:if test="$name"> 0090 <xsl:attribute name="name"> 0091 <xsl:value-of select="$name" /> 0092 </xsl:attribute> 0093 </xsl:if> 0094 <xsl:attribute name="type"> 0095 <xsl:choose> 0096 <xsl:when test="contains($typename, 'char')">Char</xsl:when> 0097 <xsl:when test="contains($typename, 'double')">Double</xsl:when> 0098 <xsl:when test="contains($typename, 'float')">Float</xsl:when> 0099 <xsl:otherwise> 0100 <xsl:choose> 0101 <xsl:when test="contains($typename, 'bool')">Bool</xsl:when> 0102 <xsl:when test="contains($typename, 'unsigned')">UInt</xsl:when> 0103 <xsl:otherwise>Int</xsl:otherwise> 0104 </xsl:choose><xsl:value-of select="@size" /> 0105 </xsl:otherwise> 0106 </xsl:choose> 0107 </xsl:attribute> 0108 </primitive> 0109 0110 </xsl:template> 0111 0112 <xsl:template match="ArrayType"> 0113 <xsl:param name="name" /> 0114 <xsl:variable name="typename" select="@type" /> 0115 <array name="{$name}" length="{translate(@max, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', '')+1}"> 0116 <xsl:apply-templates select="/GCC_XML/*[@id=$typename]" /> 0117 </array> 0118 </xsl:template> 0119 0120 <xsl:template match="Typedef"> 0121 <xsl:param name="name" select="@name" /> 0122 <xsl:variable name="typename" select="@type" /> 0123 <xsl:apply-templates select="/GCC_XML/*[@id=$typename]"> 0124 <xsl:with-param name="name" select="$name" /> 0125 </xsl:apply-templates> 0126 </xsl:template> 0127 0128 <xsl:template match="Enumeration"> 0129 <xsl:param name="name" select="@name" /> 0130 <enum name="{$name}" enum="{@name}" type="Int{@size}" /> 0131 </xsl:template> 0132 0133 <!-- TODO: There could be an offset --> 0134 <xsl:template match="Field"> 0135 <xsl:variable name="type" select="@type" /> 0136 <xsl:variable name="typeelement" select="/GCC_XML/*[@id=$type]" /> 0137 <xsl:variable name="name" select="@name" /> 0138 0139 <!-- We have to propagate down the field name --> 0140 <xsl:apply-templates select="$typeelement"> 0141 <xsl:with-param name="name" select="$name" /> 0142 </xsl:apply-templates> 0143 0144 </xsl:template> 0145 0146 <xsl:template name="split"> 0147 <xsl:param name="list" select="''" /> 0148 <xsl:param name="separator" select="','" /> 0149 0150 <xsl:if test="not($list = '' or $separator = '')"> 0151 <xsl:variable name="head" select="substring-before(concat($list, $separator), $separator)" /> 0152 <xsl:variable name="tail" select="substring-after($list, $separator)" /> 0153 0154 <xsl:apply-templates select="/GCC_XML/Field[@id=$head]" /> 0155 0156 <!-- Recurse --> 0157 <xsl:call-template name="split"> 0158 <xsl:with-param name="list" select="$tail" /> 0159 <xsl:with-param name="separator" select="$separator" /> 0160 </xsl:call-template> 0161 </xsl:if> 0162 </xsl:template> 0163 0164 </xsl:stylesheet>