--- a/mono/gir2gapi.xslt Mon Aug 04 19:09:19 2014 -0500
+++ b/mono/gir2gapi.xslt Tue Dec 09 20:11:44 2014 -0600
@@ -2,7 +2,7 @@
// This stylesheet converts gir to gapi format
@@ -11,6 +11,7 @@
// Andreia Gaita (shana@spoiledcat.net)
+// Stephan Sundermann (stephansundermann@gmail.com) // Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -19,10 +20,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -33,17 +34,13 @@
-<xsl:stylesheet version="1.0"
-xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-xmlns:exsl="http://exslt.org/common"
-xmlns:gir="http://www.gtk.org/introspection/core/1.0"
-xmlns:c="http://www.gtk.org/introspection/c/1.0"
-xmlns:glib="http://www.gtk.org/introspection/glib/1.0"
-exclude-result-prefixes="xsl exsl gir c glib"
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:exsl="http://exslt.org/common" xmlns:gir="http://www.gtk.org/introspection/core/1.0" + xmlns:c="http://www.gtk.org/introspection/c/1.0" + xmlns:glib="http://www.gtk.org/introspection/glib/1.0" + exclude-result-prefixes="xsl exsl gir c glib"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
- <xsl:strip-space elements="*" />
+ <xsl:strip-space elements="*"/> <!--- maps svg names into xaml names -->
<xsl:variable name="mappings">
@@ -51,14 +48,22 @@
<mapping from="default" to="_default"/>
<mapping from="object" to="_object"/>
<mapping from="GObjectObject" to="GObject"/>
+ <mapping from="ret" to="_ret"/> + <mapping from="result" to="_result"/> <xsl:variable name="consttypes">
- <type name="gfilename*" />
+ <type name="gfilename*"/> + <type name="gpointer"/> @@ -66,314 +71,1061 @@
<mapping from="gchararray" to="gchar*"/>
<mapping from="any*" to="gpointer*"/>
+ <mapping from="utf8" to="gchar*"/> + <mapping from="none" to="void"/> + <mapping from="any*" to="gpointer*"/> + <mapping from="GPtrArray*" to="GPtrArray"/> + <mapping from="filename" to="gfilename*"/> - <xsl:apply-templates />
+ <xsl:apply-templates select="gir:repository"/> <xsl:template match="gir:repository">
- <api parser_version="2">
+ <xsl:variable name="external"> + <xsl:apply-templates select="gir:include"/> + <xsl:call-template name="map-gtype"> + <xsl:with-param name="type">Soup.Message</xsl:with-param> + <xsl:with-param name="external" select="$external"/> - This file was automatically generated.
- Please DO NOT MODIFY THIS FILE, modify .metadata files instead.
+ <xsl:call-template name="output-type"> + <xsl:with-param name="nodename">return-type</xsl:with-param> + <xsl:with-param name="typename">Soup.Message</xsl:with-param> + <xsl:with-param name="type"/> + <xsl:with-param name="transfer-ownership">none</xsl:with-param> + <xsl:with-param name="doname">1</xsl:with-param> + <xsl:with-param name="external" select="$external" /> + <api parser_version="3"> + <xsl:apply-templates select="gir:namespace"> + <xsl:with-param name="external" select="$external"/>
- <xsl:apply-templates select="gir:namespace"/>
+ <xsl:template match="gir:include"> + <include name="{@name}"> + <xsl:copy-of select="document(concat('@GIRDIR@', @name, '-', @version, '.gir'), .)"/> <xsl:template match="gir:namespace">
- <xsl:variable name="split1"><xsl:value-of select="substring-after(@shared-library, 'lib')" /></xsl:variable>
- <xsl:variable name="library"><xsl:value-of select="substring-before($split1, '.so')" /></xsl:variable>
+ <xsl:param name="external"/> + <xsl:variable name="split1"> + <xsl:value-of select="substring-after(@shared-library, 'lib')"/> + <xsl:variable name="library"> + <xsl:value-of select="substring-before($split1, '.so')"/> <namespace name="{@name}" library="{$library}">
- <xsl:apply-templates select="gir:enumeration"/>
- <xsl:apply-templates select="gir:class"/>
+ <xsl:apply-templates select="gir:alias"> + <xsl:with-param name="external" select="$external"/> + <xsl:apply-templates select="gir:enumeration"> + <xsl:with-param name="external" select="$external"/> + <xsl:apply-templates select="gir:bitfield"> + <xsl:with-param name="external" select="$external"/> + <xsl:apply-templates select="gir:callback"> + <xsl:with-param name="external" select="$external"/> + <xsl:apply-templates select="gir:interface"> + <xsl:with-param name="external" select="$external"/> + <xsl:apply-templates select="gir:class"> + <xsl:with-param name="external" select="$external"/> + <xsl:apply-templates select="gir:union"> + <xsl:with-param name="external" select="$external"/> + <xsl:apply-templates select="gir:record[not(@glib:is-gtype-struct-for)]"> + <xsl:with-param name="external" select="$external"/> <object name="Global" cname="{@name}Global" opaque="true">
- <xsl:for-each select="gir:function">
- <xsl:call-template name="output-method"><xsl:with-param name="shared">true</xsl:with-param></xsl:call-template>
+ <xsl:for-each select="gir:function[not(@introspectable=0)]"> + <xsl:call-template name="output-method"> + <xsl:with-param name="shared">true</xsl:with-param> + <xsl:with-param name="external" select="$external"/> + <xsl:for-each select="gir:method[not(@introspectable=0)]"> + <xsl:call-template name="output-method"> + <xsl:with-param name="shared">true</xsl:with-param> + <xsl:with-param name="external" select="$external"/> + <object name="Constants" cname="{@name}Constants" opaque="true"> + <xsl:for-each select="gir:constant"> + <constant value="{@value}"> + <xsl:call-template name="map-gtype"> + <xsl:with-param name="type" select="gir:type/@c:type"/> + <xsl:with-param name="nopointer">1</xsl:with-param> + <xsl:with-param name="external" select="$external"/> + <xsl:attribute name="name"> + <xsl:call-template name="sanitize"> + <xsl:with-param name="name"> + <xsl:call-template name="map-name"> + <xsl:with-param name="name" select="@name"/> - <xsl:template match="gir:class">
+ <xsl:template match="gir:class | gir:interface"> + <xsl:param name="external"/> + <xsl:variable name="ptype"> + <xsl:call-template name="map-gtype"> + <xsl:with-param name="type" select="@parent"/> + <xsl:with-param name="external" select="$external"/> <xsl:variable name="parent">
- <xsl:call-template name="map-name">
- <xsl:with-param name="name">
- <xsl:choose><xsl:when test="contains(@parent, '.')">
- <xsl:call-template name="capitalize">
- <xsl:with-param name="string" select="@parent" />
- <xsl:with-param name="sep">.</xsl:with-param>
- </xsl:when><xsl:otherwise>
- <xsl:value-of select="../@name"/><xsl:value-of select="@parent"/>
- </xsl:otherwise></xsl:choose>
+ <xsl:value-of select="exsl:node-set($ptype)/type/@gtype"/> + <xsl:variable name="type"> + <xsl:call-template name="map-type"> + <xsl:with-param name="type" select="@c:type"/> + <xsl:with-param name="name" select="@name"/> + <xsl:with-param name="external" select="$external"/> + <xsl:variable name="name"> + <xsl:call-template name="sanitize"> + <xsl:with-param name="name" select="@name"/> + <xsl:variable name="opaque"> + test="contains(gir:doc/text(), 'opaque') or @disguised='1' or @glib:fundamental='1'" + <xsl:otherwise>false</xsl:otherwise> + <xsl:variable name="hidden"> + <xsl:when test="@private='1'">true</xsl:when> + <xsl:otherwise>false</xsl:otherwise> + <xsl:variable name="nodename"> + <xsl:when test="name()='interface'">interface</xsl:when> + <xsl:when test="@glib:fundamental='1'">struct</xsl:when> + <xsl:otherwise>object</xsl:otherwise> + <xsl:element name="{$nodename}"> + <xsl:attribute name="name"> + <xsl:value-of select="$name"/> + <xsl:attribute name="cname"> + <xsl:value-of select="exsl:node-set($type)/type/@gtype"/> + <xsl:if test="@abstract=1"> + <xsl:attribute name="defaultconstructoraccess">protected</xsl:attribute> + <xsl:attribute name="opaque"> + <xsl:value-of select="$opaque"/> + <xsl:attribute name="hidden"> + <xsl:value-of select="$hidden"/> + <xsl:if test="not(@glib:type-struct) and $nodename='interface'"> + <xsl:attribute name="consume_only">true</xsl:attribute> + <xsl:if test="@parent"> + <xsl:attribute name="parent"> + <xsl:value-of select="$parent"/> + <xsl:if test="gir:implements"> + <xsl:for-each select="gir:implements"> + <xsl:variable name="interfacetype"> + <xsl:call-template name="map-type"> + <xsl:with-param name="name" select="@name"/> + <xsl:with-param name="external" select="$external"/> + <interface cname="{exsl:node-set($interfacetype)/type/@gtype}"/> + <xsl:variable name="type-struct" select="@glib:type-struct"/> + <xsl:if test="@glib:type-struct"> + <xsl:apply-templates select="//gir:record[@name=$type-struct]"> + <xsl:with-param name="external" select="$external"/> + <xsl:with-param name="class-struct-for" select="current()"/> + <method name="GetType" cname="{@glib:get-type}" shared="true"> + <return-type type="GType"/> + <xsl:if test="@glib:get-value-func"> + <constructor cname="{@glib:get-value-func}"> + <parameter name="value" type="GValue*"/> + <xsl:if test="@glib:set-value-func"> + <method name="SetGValue" cname="{@glib:set-value-func}" shared="true"> + <return-type type="void"/> + <parameter name="value" type="GValue*" pass_as="ref"/> + <parameter name="obj" type="{exsl:node-set($type)/type/@gtype}*"/> + <xsl:if test="@glib:ref-func"> + <method name="Ref" cname="{@glib:ref-func}"> + <return-type type="{exsl:node-set($type)/type/@gtype}*" owned="true"/> + <xsl:if test="@glib:unref-func"> + <method name="Unref" cname="{@glib:unref-func}"> + <return-type type="void"/> + <xsl:with-param name="external" select="$external"/> + <xsl:template match="gir:union"> + <xsl:param name="external"/> + <xsl:variable name="type"> + <xsl:call-template name="map-type"> + <xsl:with-param name="type" select="@c:type"/> + <xsl:with-param name="name" select="@name"/> + <xsl:with-param name="external" select="$external"/> + <xsl:variable name="name"> + <xsl:call-template name="sanitize"> + <xsl:with-param name="name" select="@name"/> - <xsl:variable name="type"><xsl:call-template name="map-type"><xsl:with-param name="type" select="@c:type"/></xsl:call-template></xsl:variable>
- <object name="{@name}" cname="{$type}" parent="{$parent}">
- <method name="GetType" cname="{@glib:get-type}" shared="true">
- <return-type type="GType" />
- <xsl:apply-templates />
+ <union name="{$name}" cname="{exsl:node-set($type)/type/@ctype}"> + <xsl:with-param name="external" select="$external"/> + <xsl:template match="gir:record"> + <xsl:param name="external"/> + <xsl:param name="class-struct-for"/> + <xsl:when test="not(@glib:is-gtype-struct-for)"> + <xsl:variable name="type"> + <xsl:call-template name="map-type"> + <xsl:with-param name="type" select="@c:type"/> + <xsl:with-param name="name" select="@name"/> + <xsl:with-param name="external" select="$external"/> - <xsl:template match="gir:record">
- <xsl:if test="not(@glib:is-gtype-struct-for)">
- <xsl:variable name="type"><xsl:call-template name="map-type"><xsl:with-param name="type" select="@c:type"/></xsl:call-template></xsl:variable>
- <struct name="{@name}" cname="{$type}">
- <xsl:apply-templates />
+ <xsl:variable name="name"> + <xsl:call-template name="sanitize"> + <xsl:with-param name="name" select="@name"/> + <xsl:variable name="opaque"> + <xsl:when test="contains(gir:doc/text(), 'opaque') or @disguised='1'" + <xsl:otherwise>false</xsl:otherwise> + <xsl:variable name="hidden"> + <xsl:when test="@private='1' or contains(@name, 'Private')">true</xsl:when> + <xsl:otherwise>false</xsl:otherwise> + <xsl:variable name="nodename"> + <xsl:when test="@glib:get-type">boxed</xsl:when> + <xsl:otherwise>struct</xsl:otherwise> + <xsl:element name="{$nodename}"> + <xsl:attribute name="name"> + <xsl:value-of select="$name"/> + <xsl:attribute name="cname"> + <xsl:value-of select="exsl:node-set($type)/type/@gtype"/> + <xsl:attribute name="opaque"> + <xsl:value-of select="$opaque"/> + <xsl:attribute name="hidden"> + <xsl:value-of select="$hidden"/> + <xsl:if test="$nodename='boxed'"> + <method name="GetType" cname="{@glib:get-type}" shared="true"> + <return-type type="GType"/> + <xsl:with-param name="external" select="$external"/> + <xsl:attribute name="cname"> + <xsl:value-of select="@c:type"/> + <xsl:for-each select="gir:field"> + <xsl:apply-templates select="current()"> + <xsl:with-param name="external" select="$external"/> + <xsl:if test="gir:callback"> + test="$class-struct-for/glib:signal[current()/@name = translate(@name, '-', '_')]"> + <xsl:attribute name="signal_vm"> + <xsl:value-of select="@name"/> + <xsl:attribute name="vm"> + <xsl:value-of select="@name"/> + <!-- We have to convert all field/callback when there is no method in the original class to virtual_methods --> + <xsl:for-each select="gir:field/gir:callback"> + <xsl:if test="not($class-struct-for/gir:virtual-method[@name=current()/@name])"> + <xsl:variable name="introspectable"> + <xsl:when test="../@introspectable">0</xsl:when> + <xsl:otherwise>1</xsl:otherwise> + <xsl:call-template name="output-method"> + <xsl:with-param name="cname" select="@name"/> + <xsl:with-param name="nodename">virtual_method</xsl:with-param> + <xsl:with-param name="shared">true</xsl:with-param> + <xsl:with-param name="introspectable" select="$introspectable"/> + <xsl:with-param name="external" select="$external"/> + <xsl:for-each select="gir:method[not(@introspectable=0)]"> + <xsl:call-template name="output-method"> + <xsl:with-param name="shared">true</xsl:with-param> + <xsl:with-param name="external" select="$external"/> - <xsl:template match="gir:method">
- <xsl:call-template name="output-method" />
+ <xsl:template match="gir:namespace/gir:method[not(@introspectable=0)]"/> + <xsl:template match="gir:method[not(@introspectable=0)]"> + <xsl:param name="external"/> + <xsl:call-template name="output-method"> + <xsl:with-param name="external" select="$external"/> <xsl:template match="gir:virtual-method">
- <xsl:call-template name="output-method">
- <xsl:with-param name="nodename">virtual_method</xsl:with-param>
- <xsl:with-param name="cname" select="@name"/>
+ <xsl:param name="external"/> + <xsl:variable name="introspectable"> + <xsl:when test="@introspectable=0">0</xsl:when> + <xsl:otherwise>1</xsl:otherwise> + <xsl:if test="not(../glib:signal[@name = translate(current()/@name,'_','-')])"> + <xsl:call-template name="output-method"> + <xsl:with-param name="nodename">virtual_method</xsl:with-param> + <xsl:with-param name="cname" select="@name"/> + <xsl:with-param name="introspectable" select="$introspectable"/> + <xsl:with-param name="external" select="$external"/> - <xsl:template match="gir:namespace/gir:function" />
+ <xsl:template match="gir:namespace/gir:function[not(@introspectable=0)]"/> - <xsl:template match="gir:function">
+ <xsl:template match="gir:function[not(@introspectable=0)]"> + <xsl:param name="external"/> <xsl:call-template name="output-method">
<xsl:with-param name="shared">true</xsl:with-param>
+ <xsl:with-param name="external" select="$external"/> <xsl:template match="gir:callback">
+ <xsl:param name="shared">false</xsl:param> + <xsl:param name="nodename">callback</xsl:param> + <xsl:param name="doname">1</xsl:param> + <xsl:param name="external"/> <xsl:variable name="name">
<xsl:call-template name="capitalize">
- <xsl:with-param name="string" select="@name" />
+ <xsl:with-param name="string" select="@name"/>
- <callback name="{$name}" cname="{@c:type}">
+ <xsl:variable name="type"> + <xsl:when test="@c:type"> + <xsl:value-of select="@c:type"/> + <xsl:otherwise><xsl:value-of select="//gir:repository/gir:namespace/@name" + /><xsl:value-of select="$name"/>Func</xsl:otherwise> + <xsl:element name="{$nodename}"> + <xsl:if test="@introspectable"> + <xsl:attribute name="hidden"> + <xsl:value-of select="@introspectable"/> + <xsl:attribute name="name"> + <xsl:value-of select="$name"/> + <xsl:attribute name="cname"> + <xsl:when test="$doname='0'"> + <xsl:value-of select="@name"/> + <xsl:value-of select="$type"/> + <xsl:if test="$shared = 'true'"> + <xsl:attribute name="shared">true</xsl:attribute>
- <xsl:call-template name="output-type">
- <xsl:with-param name="nodename">return-type</xsl:with-param>
- <xsl:with-param name="type" select="gir:return-value/gir:type/@c:type" />
- <xsl:with-param name="transfer-ownership" select="gir:return-value/@transfer-ownership" />
- <xsl:with-param name="doname">0</xsl:with-param>
+ <!-- xsl:if test="gir:return-value/gir:type/@name != 'none'" --> + <xsl:for-each select="gir:return-value"> + <xsl:call-template name="output-type"> + <xsl:with-param name="nodename">return-type</xsl:with-param> + <xsl:with-param name="typename" select="gir:type/@name"/> + <xsl:with-param name="type" select="gir:type/@c:type"/> + <xsl:with-param name="transfer-ownership" select="@transfer-ownership"/> + <xsl:with-param name="doname">0</xsl:with-param> + <xsl:with-param name="external" select="$external"/> <xsl:if test="gir:parameters">
+ <!-- For some wtf reason, some callbacks inside fields in the gir file include + the pointer to the #$$@#$ parent type, which is something that gets added + automatically. Remove the first such parameter if it's stupid --> + <xsl:variable name="parent"> + <xsl:call-template name="get-real-type-name"> + <xsl:with-param name="node" select="../.."/> + <xsl:with-param name="external" select="$external"/> - <xsl:for-each select="gir:parameters/gir:parameter">
+ <xsl:if test="@throws"> + <xsl:attribute name="throws"> + <xsl:value-of select="@throws"/> + <!-- xsl:for-each select="gir:parameters/gir:parameter[position()>1 or gir:type/@name!=$parent]" --> + <xsl:for-each select="gir:parameters/gir:parameter"> + <xsl:attribute name="scope"> + <xsl:value-of select="@scope"/>
- <xsl:call-template name="output-type">
- <xsl:with-param name="name" select="@name" />
- <xsl:with-param name="type" select="gir:type/@c:type" />
- <xsl:with-param name="transfer-ownership" select="@transfer-ownership" />
+ <xsl:if test="@allow-none"> + <xsl:attribute name="allow-none"> + <xsl:value-of select="@allow-none"/> + <xsl:if test="@closure"> + <xsl:attribute name="closure"> + <xsl:value-of select="@closure"/>
+ <xsl:if test="@destroy"> + <xsl:attribute name="destroy"> + <xsl:value-of select="@destroy"/> + <xsl:call-template name="output-type"> + <xsl:with-param name="name" select="@name"/> + <xsl:with-param name="typename" select="gir:type/@name"/> + <xsl:with-param name="type" select="gir:type/@c:type"/> + <xsl:with-param name="transfer-ownership" + select="@transfer-ownership"/> + <xsl:with-param name="external" select="$external"/> + <xsl:if test="@throws"> + <parameter name="error" type="GError**"/>
- <xsl:template match="gir:constructor">
+ <xsl:template match="gir:constructor[not(@introspectable=0)]"> + <xsl:param name="external"/> + <xsl:variable name="t" select="gir:parameters/gir:parameter/gir:type/@name"/> <constructor cname="{@c:identifier}">
- <xsl:if test="gir:parameters">
- <xsl:for-each select="gir:parameters/gir:parameter">
+ <xsl:if test="count(gir:parameters/gir:parameter)=0"> + <xsl:attribute name="disable_void_ctor"/> + test="count(gir:parameters/gir:parameter) = 1 and exsl:node-set($consttypes)/types/ctor/type[@name=$t]"> + <xsl:attribute name="disable_raw_ctor"/>
- <xsl:call-template name="output-type">
- <xsl:with-param name="name" select="@name" />
- <xsl:with-param name="type" select="gir:type/@c:type" />
- <xsl:with-param name="transfer-ownership" select="@transfer-ownership" />
+ <xsl:if test="gir:parameters"> + <xsl:element name="parameters"> + <xsl:for-each select="gir:parameters/gir:parameter">
+ <xsl:element name="parameter"> + <xsl:call-template name="output-type"> + <xsl:with-param name="name" select="@name"/> + <xsl:with-param name="typename" select="gir:type/@name"/> + <xsl:with-param name="type" select="gir:type/@c:type"/> + <xsl:with-param name="transfer-ownership" + select="@transfer-ownership"/> + <xsl:with-param name="external" select="$external"/> <xsl:template match="glib:signal">
- <xsl:variable name="name">
+ <xsl:param name="external"/> + <xsl:variable name="name" > <xsl:call-template name="capitalize">
- <xsl:with-param name="string" select="@name" />
- <xsl:with-param name="sep"><xsl:text>-</xsl:text></xsl:with-param>
+ <xsl:with-param name="string" select="@name"/> + <xsl:with-param name="sep"> + <xsl:if test="../gir:method[@name = translate(current()/@name,'-','_')]">Event</xsl:if> + <signal name="{$name}" cname="{@name}" when="{@when}"> + <xsl:if test="../gir:virtual-method[@name = translate(current()/@name,'-','_')]"> + <xsl:attribute name="field_name"> + <xsl:value-of select="translate(current()/@name,'-','_')"/> + <!-- xsl:if test="gir:return-value/gir:type/@name != 'none'" --> + <xsl:for-each select="gir:return-value"> + <xsl:call-template name="output-type"> + <xsl:with-param name="typename" select="gir:type/@name"/> + <xsl:with-param name="type" select="gir:type/@c:type"/> + <xsl:with-param name="transfer-ownership" select="@transfer-ownership"/> + <xsl:with-param name="doname">0</xsl:with-param> + <xsl:with-param name="external" select="$external"/> + <xsl:variable name="prtypemap"> + <xsl:call-template name="map-type"> + <xsl:with-param name="type" select="../@c:type"/> + <xsl:with-param name="name" select="../@name"/> + <xsl:with-param name="external" select="$external"/> + <xsl:for-each select="gir:parameters/gir:parameter"> + <xsl:attribute name="scope"> + <xsl:value-of select="@scope"/> + <xsl:if test="@allow-none"> + <xsl:attribute name="allow-none"> + <xsl:value-of select="@allow-none"/> + <xsl:call-template name="output-type"> + <xsl:with-param name="name" select="@name"/> + <xsl:with-param name="typename" select="gir:type/@name"/> + <xsl:with-param name="type" select="gir:type/@c:type"/> + <xsl:with-param name="transfer-ownership" select="@transfer-ownership"/> + <xsl:with-param name="external" select="$external"/> + <xsl:if test="../gir:method[@name = translate(current()/@name,'-','_')]"> + <warning>Signal renamed because of existing method with same name</warning> + <xsl:template match="gir:enumeration"> + <xsl:param name="external"/> + <xsl:variable name="name"> + <xsl:call-template name="sanitize"> + <xsl:with-param name="name" select="@name"/> - <xsl:if test="not(../gir:method[@name = translate(current()/@name,'-','_')]) and not(../gir:virtual-method[@name = translate(current()/@name,'-','_')])">
- <signal name="{$name}" cname="{@name}">
- <xsl:call-template name="output-type">
- <xsl:with-param name="typename" select="gir:return-value/gir:type/@name" />
- <xsl:with-param name="type" select="gir:return-value/gir:type/@c:type" />
- <xsl:with-param name="transfer-ownership" select="gir:return-value/@transfer-ownership" />
- <xsl:with-param name="doname">0</xsl:with-param>
- <xsl:variable name="prtypemap"><xsl:call-template name="map-type"><xsl:with-param name="type" select="../@c:type"/></xsl:call-template></xsl:variable>
+ <enum name="{$name}" cname="{@c:type}" type="enum"> + <xsl:if test="@glib:get-type"> + <xsl:attribute name="gtype"> + <xsl:value-of select="@glib:get-type"/> + <xsl:for-each select="gir:member"> + <xsl:sort select="@value" data-type="number"/>
- name="{translate(../@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')}"
- type="{$prtypemap}*" />
- <xsl:for-each select="gir:parameters/gir:parameter">
- <xsl:call-template name="output-type">
- <xsl:with-param name="name" select="@name" />
- <xsl:with-param name="type" select="gir:type/@c:type" />
- <xsl:with-param name="transfer-ownership" select="@transfer-ownership" />
+ <xsl:variable name="ename"> + <xsl:variable name="mname"> + <xsl:when test="@name = @value"> + <xsl:call-template name="sanitize"> + <xsl:with-param name="name" select="@c:identifier"/> + <xsl:call-template name="sanitize"> + <xsl:with-param name="name" select="@name"/> + <xsl:call-template name="capitalize"> + <xsl:with-param name="string" select="$mname"/> + <xsl:variable name="mname"> + <xsl:call-template name="map-name"> + <xsl:with-param name="name" select="$ename"/> + <member cname="{@c:identifier}" name="{$mname}"> + <xsl:attribute name="value"> + <xsl:value-of select="@value"/> - <xsl:template match="gir:enumeration">
- <enum name="{@name}" cname="{@c:type}">
- <xsl:when test="@glib:get-type">
- <xsl:attribute name="gtype"><xsl:value-of select="@glib:get-type" /></xsl:attribute>
- <xsl:attribute name="type">enum</xsl:attribute>
- <xsl:attribute name="type">enum</xsl:attribute>
+ <xsl:template match="gir:bitfield"> + <xsl:param name="external"/> + <xsl:variable name="name"> + <xsl:call-template name="sanitize"> + <xsl:with-param name="name" select="@name"/> + <enum name="{$name}" cname="{@c:type}" type="flags"> + <xsl:if test="@glib:get-type"> + <xsl:attribute name="gtype"> + <xsl:value-of select="@glib:get-type"/> <xsl:for-each select="gir:member">
- <xsl:sort select="@value" />
+ <xsl:sort select="@value" data-type="number"/> <xsl:variable name="ename">
- <xsl:choose><xsl:when test="@name = @value">
- <xsl:call-template name="capitalize"><xsl:with-param name="string" select="@c:identifier"/></xsl:call-template>
- </xsl:when><xsl:otherwise>
- <xsl:call-template name="capitalize"><xsl:with-param name="string" select="@name"/></xsl:call-template>
- </xsl:otherwise></xsl:choose>
+ <xsl:variable name="mname"> + <xsl:when test="@name = @value"> + <xsl:call-template name="sanitize"> + <xsl:with-param name="name" select="@c:identifier"/> + <xsl:call-template name="sanitize"> + <xsl:with-param name="name" select="@name"/> + <xsl:call-template name="capitalize"> + <xsl:with-param name="string" select="$mname"/> - <xsl:variable name="name"><xsl:call-template name="map-name"><xsl:with-param name="name" select="$ename"/></xsl:call-template></xsl:variable>
- <member cname="{@c:identifier}" name="{$name}" />
+ <xsl:variable name="mname"> + <xsl:call-template name="map-name"> + <xsl:with-param name="name" select="$ename"/> + <member cname="{@c:identifier}" name="{$mname}"> + <xsl:attribute name="value"> + <xsl:value-of select="@value"/> <xsl:template match="gir:field">
- <xsl:if test="not(../gir:property[@name = translate(current()/@name,'_','-')]) and not(../gir:method[@name = current()/@name])">
- <xsl:variable name="name"><xsl:call-template name="capitalize"><xsl:with-param name="string" select="@name"/></xsl:call-template></xsl:variable>
+ <xsl:param name="external"/> + <!-- Let's skip fields whose types are callbacks, for now --> + <xsl:if test="not(gir:callback)"> + <xsl:variable name="writable"> + <xsl:when test="@writable=1"> + <xsl:text>true</xsl:text> + <xsl:text>false</xsl:text> + <xsl:variable name="readable"> + <xsl:when test="@readable=0"> + <xsl:text>false</xsl:text> + <xsl:text>true</xsl:text> - <field cname="{@name}">
+ <xsl:variable name="access"> + <xsl:when test="@private">private</xsl:when> + <xsl:otherwise>public</xsl:otherwise> + <xsl:variable name="name"> + <xsl:call-template name="capitalize"> + <xsl:with-param name="string" select="@name"/> + test="../gir:property[@name = translate(current()/@name,'_','-')] or ../gir:method[@name = current()/@name]"> + <xsl:when test="//gir:callback[@name = current()/gir:type/@name]" + <xsl:otherwise>Field</xsl:otherwise> + <field cname="{@name}" access="{$access}" writeable="{$writable}" readable="{$readable}"> + <xsl:attribute name="bits"> + <xsl:value-of select="@bits"/> <xsl:call-template name="output-type">
- <xsl:with-param name="name" select="$name" />
- <xsl:with-param name="type" select="gir:type/@c:type" />
- <xsl:with-param name="transfer-ownership" select="@transfer-ownership" />
+ <xsl:with-param name="name" select="$name"/> + <xsl:with-param name="typename" select="gir:type/@name"/> + <xsl:with-param name="type" select="gir:type/@c:type"/> + <xsl:with-param name="transfer-ownership" select="@transfer-ownership"/> + <xsl:with-param name="external" select="$external"/> - <xsl:template match="gir:property">
- <xsl:if test="not(../gir:method[@name = translate(current()/@name,'-','_')]) and not(../gir:virtual-method[@name = translate(current()/@name,'-','_')])">
+ <xsl:template match="gir:property[not(@private)]"> + <xsl:param name="external"/> + <xsl:variable name="name"> + <xsl:call-template name="capitalize"> + <xsl:with-param name="string"> + <xsl:when test="../gir:method[@name = translate(current()/@name,'-','_')] or ../gir:virtual-method[@name = translate(current()/@name,'-','_')]"> + <xsl:value-of select="@name"/>Prop + <xsl:value-of select="@name"/> + <xsl:with-param name="sep">-</xsl:with-param> + <xsl:variable name="typemap"> + <xsl:call-template name="map-type"> + <xsl:with-param name="type" select="gir:type/@c:type"/> + <xsl:with-param name="name" select="gir:type/@name"/> + <xsl:with-param name="external" select="$external"/> - <xsl:variable name="name"><xsl:call-template name="capitalize"><xsl:with-param name="string" select="@name"/><xsl:with-param name="sep">-</xsl:with-param></xsl:call-template></xsl:variable>
- <xsl:variable name="typemap"><xsl:call-template name="map-type"><xsl:with-param name="type" select="gir:type/@c:type"/></xsl:call-template></xsl:variable>
<xsl:variable name="type">
- <xsl:when test="//*/gir:namespace/gir:enumeration[@c:type=gir:type/@c:type]">
- <xsl:text>int</xsl:text>
- <xsl:when test="../../gir:class[@name=current()/gir:type/@name]">
- <xsl:value-of select="../../gir:class[@name=current()/gir:type/@name]/@c:type"/><xsl:text>*</xsl:text>
- <xsl:when test="../../gir:record[@name=current()/gir:type/@name]">
- <xsl:value-of select="../../gir:record[@name=current()/gir:type/@name]/@c:type"/><xsl:text>*</xsl:text>
- <xsl:when test="@transfer-ownership='none' and exsl:node-set($consttypes)/types/type[@name=$typemap]">
- <xsl:text>const-</xsl:text><xsl:value-of select="$typemap"/>
- <xsl:value-of select="$typemap"/>
+ <xsl:when test="//*/gir:namespace/gir:enumeration[@c:type=gir:type/@c:type]"> + <xsl:text>int</xsl:text> + <xsl:value-of select="exsl:node-set($typemap)/type/@ctype"/> + <xsl:variable name="construct"> + <xsl:when test="@construct and @construct=1">true</xsl:when> + <xsl:otherwise>false</xsl:otherwise> + <xsl:variable name="construct-only"> + <xsl:when test="@construct-only and @construct-only=1">true</xsl:when> + <xsl:otherwise>false</xsl:otherwise> <xsl:variable name="writable">
- <xsl:choose><xsl:when test="@writable and @writable=1">
- <xsl:text>true</xsl:text>
- </xsl:when><xsl:otherwise>
- <xsl:text>false</xsl:text>
- </xsl:otherwise></xsl:choose>
+ <xsl:when test="@writable=1"> + <xsl:text>true</xsl:text> + <xsl:text>false</xsl:text> - <property name="{$name}" cname="{@name}" type="{$type}" readable="true" writable="{$writable}"/>
+ <xsl:variable name="readable"> + <xsl:when test="@readable=0"> + <xsl:text>false</xsl:text> + <xsl:text>true</xsl:text> + <xsl:if test="$type!=''"> + <property name="{$name}" cname="{@name}" type="{$type}" readable="{$readable}" + writeable="{$writable}" construct="{$construct}" + construct-only="{$construct-only}"/> - <xsl:template match="gir:*">
- <xsl:template match="text()" mode="#all" />
+ <xsl:template match="gir:*"/> + <xsl:template match="text()" mode="#all"/> + <!-- Helper templates --> <xsl:template name="output-method">
<xsl:param name="shared">false</xsl:param>
<xsl:param name="nodename">method</xsl:param>
<xsl:param name="cname"/>
+ <xsl:param name="introspectable"/> + <xsl:param name="external"/> <xsl:variable name="name">
<xsl:call-template name="capitalize">
- <xsl:with-param name="string" select="@name" />
+ <xsl:with-param name="string" select="@name"/> <xsl:element name="{$nodename}">
- <xsl:attribute name="name"><xsl:value-of select="$name"/></xsl:attribute>
- <xsl:choose><xsl:when test="$cname">
- <xsl:attribute name="cname"><xsl:value-of select="$cname"/></xsl:attribute>
- </xsl:when><xsl:otherwise>
- <xsl:attribute name="cname"><xsl:value-of select="@c:identifier"/></xsl:attribute>
- </xsl:otherwise></xsl:choose>
- <xsl:if test="$shared = 'true'"><xsl:attribute name="shared">true</xsl:attribute></xsl:if>
+ <xsl:attribute name="name"> + <xsl:value-of select="$name"/> + <xsl:when test="$cname"> + <xsl:attribute name="cname"> + <xsl:value-of select="$cname"/> + <xsl:attribute name="cname"> + <xsl:value-of select="@c:identifier"/> + <xsl:if test="$shared = 'true'"> + <xsl:attribute name="shared">true</xsl:attribute> + <xsl:if test="@private = '1'"> + <xsl:attribute name="hidden">true</xsl:attribute> + <xsl:if test="@disguised = '1'"> + <xsl:attribute name="opaque">true</xsl:attribute> + <xsl:if test="@deprecated"> + <xsl:attribute name="deprecated">true</xsl:attribute> + <xsl:if test="$introspectable=0"> + <xsl:attribute name="hidden">true</xsl:attribute>
- <xsl:call-template name="output-type">
- <xsl:with-param name="type" select="gir:return-value/gir:type/@c:type" />
- <xsl:with-param name="transfer-ownership" select="gir:return-value/@transfer-ownership" />
+ <!-- xsl:if test="gir:return-value/gir:type/@name != 'none'" --> + <xsl:for-each select="gir:return-value"> + <xsl:call-template name="output-type"> + <xsl:with-param name="typename" select="gir:type/@name"/> + <xsl:with-param name="type" select="gir:type/@c:type"/> + <xsl:with-param name="transfer-ownership" select="@transfer-ownership"/> + <xsl:with-param name="external" select="$external"/> <xsl:if test="gir:parameters">
- <xsl:for-each select="gir:parameters/gir:parameter">
- <xsl:call-template name="output-type">
- <xsl:with-param name="name" select="@name" />
- <xsl:with-param name="type" select="gir:type/@c:type" />
- <xsl:with-param name="transfer-ownership" select="@transfer-ownership" />
+ <xsl:if test="@throws"> + <xsl:attribute name="throws"> + <xsl:value-of select="@throws"/> + <xsl:for-each select="gir:parameters/gir:parameter"> + <xsl:if test="@closure"> + <xsl:attribute name="closure"> + <xsl:value-of select="@closure"/> + <xsl:if test="@destroy"> + <xsl:attribute name="destroy"> + <xsl:value-of select="@destroy"/> + <xsl:attribute name="scope"> + <xsl:value-of select="@scope"/> + <xsl:if test="@allow-none"> + <xsl:attribute name="allow-none"> + <xsl:value-of select="@allow-none"/> + <xsl:call-template name="output-type"> + <xsl:with-param name="name" select="@name"/> + <xsl:with-param name="typename" select="gir:type/@name"/> + <xsl:with-param name="type" select="gir:type/@c:type"/> + <xsl:with-param name="transfer-ownership" + select="@transfer-ownership"/> + <xsl:with-param name="external" select="$external"/> + <xsl:if test="@throws"> + <parameter name="error" type="GError**"/> @@ -385,63 +1137,217 @@
<xsl:param name="transfer-ownership"/>
<xsl:param name="dotype">1</xsl:param>
+ <xsl:param name="external"/> - <xsl:variable name="pname"><xsl:call-template name="map-name"><xsl:with-param name="name" select="$name"/></xsl:call-template></xsl:variable>
- <xsl:variable name="ptypemap"><xsl:call-template name="map-type"><xsl:with-param name="type" select="$type"/></xsl:call-template></xsl:variable>
- <!-- hack to replace enums with int because gapi is silly and doesn't register their types -->
+ <xsl:variable name="pname"> + <xsl:call-template name="map-name"> + <xsl:with-param name="name" select="$name"/> + <xsl:variable name="thetype"> + <xsl:when test="$type"> + <xsl:call-template name="map-ctype"> + <xsl:with-param name="ctype" select="$type"/> + <xsl:when test="$typename"> + <xsl:value-of select="$typename"/> + <xsl:value-of select="$pname"/> + <xsl:variable name="ptypemap"> + <xsl:call-template name="map-type"> + <xsl:with-param name="type" select="$thetype"/> + <xsl:with-param name="name" select="$typename"/> + <xsl:with-param name="transfer-ownership" select="@transfer-ownership"/> + <xsl:with-param name="external" select="$external"/> <xsl:variable name="ptype">
- <xsl:when test="//*/gir:namespace/gir:enumeration[@name=$typename] and not(//*/gir:namespace/gir:enumeration[@name=$typename]/@glib:get-type) ">
- <xsl:text>int</xsl:text>
- <!--xsl:when test="//*/gir:namespace/gir:enumeration[@name=$type]">
- <xsl:text>int</xsl:text>
- <xsl:when test="//*/gir:namespace/gir:enumeration[@c:type=$ptypemap]">
- <xsl:text>int</xsl:text>
- <xsl:when test="$transfer-ownership='none' and exsl:node-set($consttypes)/types/type[@name=$ptypemap]">
- <xsl:text>const-</xsl:text><xsl:value-of select="$ptypemap"/>
- <xsl:value-of select="$ptypemap"/>
+ test="$transfer-ownership='none' and exsl:node-set($consttypes)/types/type[@name=exsl:node-set($ptypemap)/type/@ctype]"> + <xsl:text>const-</xsl:text> + <xsl:value-of select="exsl:node-set($ptypemap)/type/@ctype"/> + <xsl:when test="exsl:node-set($ptypemap)/type/@ctype"> + <xsl:value-of select="exsl:node-set($ptypemap)/type/@ctype"/> + <xsl:when test="gir:callback[@name=$name]"> + <xsl:value-of select="//gir:repository/gir:namespace/@name" + /><xsl:value-of select="@name"/>Func </xsl:when> + <xsl:otherwise>none</xsl:otherwise> <xsl:if test="$pname!=''">
- <xsl:attribute name="name"><xsl:value-of select="$pname"/></xsl:attribute>
+ <xsl:attribute name="name"> + <xsl:value-of select="$pname"/> <xsl:if test="$dotype=1">
- <xsl:attribute name="type"><xsl:value-of select="$ptype"/></xsl:attribute>
+ <xsl:when test="exsl:node-set($ptypemap)/type/@element_type"> + <!-- these get switched around in case of a GList or GSList --> + <xsl:attribute name="type"> + <xsl:value-of select="exsl:node-set($ptypemap)/type/@element_type"/> + <xsl:attribute name="element_type"> + <xsl:value-of select="$ptype"/> + <xsl:attribute name="type"> + <xsl:value-of select="$ptype"/> + <xsl:if test="exsl:node-set($ptypemap)/type/@elements_owned"> + <xsl:attribute name="elements_owned"> + <xsl:value-of select="exsl:node-set($ptypemap)/type/@elements_owned"/> + <xsl:if test="exsl:node-set($ptypemap)/type/@owned"> + <xsl:attribute name="elements_owned"> + <xsl:value-of select="exsl:node-set($ptypemap)/type/@owned"/> + <xsl:if test="@transfer-ownership='full'"> + <xsl:attribute name="owned">true</xsl:attribute> + <xsl:if test="@direction"> + <!-- it seems that we can just convert inout to ref --> + <xsl:when test="@direction='inout'"> + <xsl:attribute name="pass_as">ref</xsl:attribute> + <xsl:attribute name="pass_as"> + <xsl:value-of select="@direction"/> + <xsl:variable name="pos" select="position()"></xsl:variable> + <xsl:variable name="arrayIndex"> + <xsl:value-of select="count(..//gir:parameter[$pos = (gir:array/@length+1)]/preceding-sibling::gir:parameter)"/> + <xsl:if test="$arrayIndex != 0"> + <xsl:attribute name="array_index"><xsl:value-of select="$arrayIndex"/></xsl:attribute> <xsl:if test="gir:array">
- <xsl:attribute name="array_len"><xsl:value-of select="gir:array/@length"/></xsl:attribute>
+ <xsl:attribute name="array">true</xsl:attribute> + <xsl:when test="gir:array/@length"> + <xsl:attribute name="array_length_param_index"> + <xsl:value-of select="gir:array/@length"/> + <xsl:when test="gir:array/@fixed-size"> + <xsl:attribute name="array_len"> + <xsl:value-of select="gir:array/@fixed-size"/> + <xsl:if test="not(gir:array/@zero-terminated) or gir:array/@zero-terminated='1'"> + <xsl:attribute name="null_term_array">true</xsl:attribute> + <xsl:if test="exsl:node-set($ptypemap)/type/@warning"> + <xsl:value-of select="exsl:node-set($ptypemap)/type/@warning"/> + <!-- debug s="1" name="{$name}" pname="{$pname}" ptypemap="{$ptypemap}" typename="{$typename}" typea="{$type}" transfer-ownership="{$transfer-ownership}" mapping="{exsl:node-set($typemappings)/mappings/mapping[@from=$typename]/@to}" dotype="{$dotype}" / --> + <name><xsl:value-of select="$typename" /></name> + <aname><xsl:value-of select="@name" /></aname> + <thetype><xsl:value-of select="$thetype" /></thetype> + <xsl:copy-of select="$ptypemap" /> + <xsl:call-template name="map-gtype"> + <xsl:with-param name="type" select="$typename"/> + <xsl:with-param name="external" select="$external"/> <xsl:template name="map-name">
<xsl:when test="not($name) and gir:varargs">var_args</xsl:when>
- <xsl:when test="not(exsl:node-set($mappings)/mappings/mapping[@from=$name])"><xsl:value-of select="$name" /></xsl:when>
- <xsl:otherwise><xsl:value-of select="exsl:node-set($mappings)/mappings/mapping[@from=$name]/@to" /></xsl:otherwise>
+ <xsl:when test="not(exsl:node-set($mappings)/mappings/mapping[@from=$name])"> + <xsl:value-of select="$name"/> + <xsl:value-of select="exsl:node-set($mappings)/mappings/mapping[@from=$name]/@to"/> + <xsl:template name="sanitize"> + <xsl:param name="name"/> + test="starts-with($name, '0') or starts-with($name, '1') or starts-with($name, '2') or starts-with($name, '3') or starts-with($name, '4') or starts-with($name, '5') or starts-with($name, '6') or starts-with($name, '7') or starts-with($name, '8') or starts-with($name, '9')"> + <xsl:when test="@c:type"> + <xsl:value-of select="@c:type"/> + <xsl:otherwise>_<xsl:value-of select="$name"/></xsl:otherwise> + <xsl:value-of select="$name"/> <xsl:template name="capitalize">
<xsl:param name="string"/>
<xsl:param name="sep">_</xsl:param>
- <xsl:value-of select="translate(substring($string,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
- <xsl:choose><xsl:when test="contains($string,$sep)">
- <xsl:value-of select="substring-before(substring($string,2),$sep)"/>
- </xsl:when><xsl:otherwise>
- <xsl:value-of select="substring($string,2)"/>
- </xsl:otherwise></xsl:choose>
+ select="translate(substring($string,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> + <xsl:when test="contains($string,$sep)"> + <xsl:value-of select="substring-before(substring($string,2),$sep)"/> + <xsl:value-of select="substring($string,2)"/> <xsl:if test="contains($string,$sep)">
<xsl:call-template name="capitalize">
<xsl:with-param name="string" select="substring-after($string,$sep)"/>
@@ -451,13 +1357,317 @@
<xsl:template name="map-type">
- <xsl:param name="type" />
+ <xsl:param name="type"/> + <xsl:param name="name"/> + <xsl:param name="transfer-ownership">none</xsl:param> + <xsl:param name="nopointer"/> + <xsl:param name="external"/> + <xsl:when test="gir:varargs"> + <xsl:attribute name="ctype">va_list</xsl:attribute> + <xsl:attribute name="gtype">va_list</xsl:attribute> + <xsl:when test="gir:array"> + <xsl:call-template name="map-gtype"> + <xsl:with-param name="type" select="gir:array/@c:type"/> + <xsl:with-param name="transfer-ownership" select="$transfer-ownership"/> + <xsl:with-param name="nopointer" select="$nopointer"/> + <xsl:with-param name="external" select="$external"/> + <xsl:when test="gir:type/gir:type"> + <xsl:call-template name="map-gtype"> + <xsl:with-param name="type" select="gir:type/gir:type/@name"/> + <xsl:with-param name="external" select="$external"/> + <xsl:attribute name="element_type"> + <xsl:value-of select="gir:type/@c:type"/> + <xsl:if test="$transfer-ownership = 'container'"> + <xsl:attribute name="owned">true</xsl:attribute> + <xsl:if test="$transfer-ownership = 'full'"> + <xsl:attribute name="elements_owned">true</xsl:attribute> + <xsl:attribute name="owned">true</xsl:attribute> + <xsl:when test="not($name)"> + <xsl:call-template name="map-gtype"> + <xsl:with-param name="type" select="$type"/> + <xsl:with-param name="transfer-ownership" select="$transfer-ownership"/> + <xsl:with-param name="nopointer" select="$nopointer"/> + <xsl:with-param name="external" select="$external"/> + <xsl:call-template name="map-gtype"> + <xsl:with-param name="type" select="$name"/> + <xsl:with-param name="transfer-ownership" select="$transfer-ownership"/> + <xsl:with-param name="nopointer" select="$nopointer"/> + <xsl:with-param name="external" select="$external"/> + <xsl:template name="map-gtype"> + <xsl:param name="type"/> + <xsl:param name="transfer-ownership">none</xsl:param> + <xsl:param name="nopointer"/> + <xsl:param name="external"/> + <xsl:when test="contains($type, '.')"> + <xsl:variable name="ns" select="substring-before($type, '.')"/> + <xsl:variable name="t" select="substring-after($type, '.')"/> + select="exsl:node-set($external)/include[@name=$ns]/gir:repository/gir:namespace[@name=$ns]"/> + <xsl:call-template name="map-gtype-inner"> + <xsl:with-param name="type" select="$type"/> + <xsl:with-param name="transfer-ownership" select="$transfer-ownership"/> + <xsl:with-param name="l" select="$l"/> + <xsl:with-param name="t" select="$t"/> + <xsl:with-param name="nopointer" select="$nopointer"/> + <xsl:variable name="t" select="$type"/> + <xsl:variable name="l" select="ancestor::gir:namespace"/> + <xsl:call-template name="map-gtype-inner"> + <xsl:with-param name="type" select="$type"/> + <xsl:with-param name="transfer-ownership" select="$transfer-ownership"/> + <xsl:with-param name="l" select="$l"/> + <xsl:with-param name="t" select="$t"/> + <xsl:with-param name="nopointer" select="$nopointer"/> + <xsl:template name="map-gtype-inner"> + <xsl:param name="type"/> + <xsl:param name="transfer-ownership"/> + <xsl:param name="nopointer"/> - <xsl:when test="not($type) and gir:varargs">va_list</xsl:when>
- <xsl:when test="not($type) and gir:array"><xsl:value-of select="gir:array/@c:type" /></xsl:when>
- <xsl:when test="exsl:node-set($typemappings)/mappings/mapping[@from=$type]"><xsl:value-of select="exsl:node-set($typemappings)/mappings/mapping[@from=$type]/@to" /></xsl:when>
- <xsl:otherwise><xsl:value-of select="$type" /></xsl:otherwise>
+ <xsl:when test="exsl:node-set($typemappings)/mappings/mapping[@from=$t]"> + <xsl:attribute name="ctype"> + select="exsl:node-set($typemappings)/mappings/mapping[@from=$t]/@to"/> + <xsl:attribute name="gtype"> + select="exsl:node-set($typemappings)/mappings/mapping[@from=$t]/@to"/> + <xsl:when test="exsl:node-set($typemappings)/mappings/mapping[@from=$type]"> + <xsl:attribute name="ctype"> + select="exsl:node-set($typemappings)/mappings/mapping[@from=$type]/@to"/> + <xsl:attribute name="gtype"> + select="exsl:node-set($typemappings)/mappings/mapping[@from=$type]/@to"/> + <xsl:when test="$l/gir:class[@name=$t]"> + <xsl:attribute name="ctype"><xsl:value-of select="$l/gir:class[@name=$t]/@c:type" + <xsl:attribute name="gtype"> + <xsl:value-of select="$l/gir:class[@name=$t]/@glib:type-name"/> + <xsl:when test="$l/gir:record[@name=$t]"> + test="gir:type/@c:type and concat($l/gir:record[@name=$t]/@c:type,'*') != string(gir:type/@c:type)"> + <xsl:attribute name="warning">type does not match c:type - + record:<xsl:value-of select="$l/@name"/>/<xsl:value-of select="$t" + />. '<xsl:value-of select="$l/gir:record[@name=$t]/@c:type"/>*' == + '<xsl:value-of select="gir:type/@c:type"/>'(ctype)</xsl:attribute> + <xsl:attribute name="ctype"> + <xsl:call-template name="map-ctype"> + <xsl:with-param name="ctype" select="gir:type/@c:type"/> + <xsl:attribute name="ctype"><xsl:call-template name="map-ctype" + ><xsl:with-param name="ctype" + select="$l/gir:record[@name=$t]/@c:type" + /></xsl:call-template>*</xsl:attribute> + <xsl:when test="$l/gir:record[@name=$t]/@glib:type-name"> + <xsl:attribute name="gtype"> + <xsl:value-of select="$l/gir:record[@name=$t]/@glib:type-name"/> + <xsl:attribute name="gtype"> + <xsl:call-template name="map-ctype"> + <xsl:with-param name="ctype" + select="$l/gir:record[@name=$t]/@c:type"/> + <xsl:attribute name="warning">missing glib:type-name</xsl:attribute> + <xsl:attribute name="warning">missing glib:type-name</xsl:attribute> + <xsl:when test="$l/gir:union[@name=$t]"> + <xsl:attribute name="ctype"><xsl:value-of select="$l/gir:union[@name=$t]/@c:type" + <xsl:attribute name="gtype"> + <xsl:value-of select="$l/gir:union[@name=$t]/@glib:type-name"/> + <xsl:when test="$l/gir:boxed[@name=$t]"> + <xsl:attribute name="ctype"><xsl:value-of select="$l/gir:boxed[@name=$t]/@c:type" + <xsl:attribute name="gtype"> + <xsl:value-of select="$l/gir:boxed[@name=$t]/@glib:type-name"/> + <xsl:when test="$l/gir:interface[@name=$t]"> + <xsl:attribute name="ctype"> + <xsl:when test="$l/gir:interface[@name=$t]/@c:type"> + <xsl:value-of select="$l/gir:interface[@name=$t]/@c:type"/> + <xsl:value-of select="$l/gir:interface[@name=$t]/@glib:type-name"/> + <xsl:if test="$nopointer!=1">*</xsl:if> + <xsl:attribute name="gtype"> + <xsl:value-of select="$l/gir:interface[@name=$t]/@glib:type-name"/> + <xsl:when test="$l/gir:bitfield[@name=$t]"> + <xsl:attribute name="ctype"> + <xsl:value-of select="$l/gir:bitfield[@name=$t]/@c:type"/> + <xsl:attribute name="gtype"> + <xsl:value-of select="$l/gir:bitfield[@name=$t]/@glib:type-name"/> + <xsl:when test="$l/gir:enumeration[@name=$t]"> + <xsl:attribute name="ctype"> + <xsl:value-of select="$l/gir:enumeration[@name=$t]/@c:type"/> + <xsl:attribute name="gtype"> + <xsl:value-of select="$l/gir:enumeration[@name=$t]/@glib:type-name"/> + <xsl:when test="$l/gir:callback[@name=$t]"> + <!-- It appears callbacks need to have the name as the type (and not the c:type) --> + <xsl:when test="$l/gir:callback[@name=$t]/@c:type"> + <xsl:attribute name="ctype"> + <xsl:value-of select="$l/gir:callback[@name=$t]/@c:type"/> + <xsl:attribute name="ctype"> + <xsl:value-of select="$t"/> + <xsl:attribute name="gtype"> + <xsl:value-of select="$l/gir:callback[@name=$t]/@glib:type-name"/> + <xsl:when test="$l/gir:alias[@name=$t]"> + <xsl:attribute name="ctype"> + <xsl:value-of select="$l/gir:alias[@name=$t]/gir:type/@c:type"/> + <xsl:attribute name="gtype"> + <xsl:value-of select="$l/gir:alias[@name=$t]/gir:type/@glib:type-name"/> + <xsl:when test="gir:callback[@name=current()/@name]"> + <xsl:attribute name="ctype"><xsl:value-of select="$l/@name"/><xsl:value-of + select="$type"/>Func</xsl:attribute> + <xsl:attribute name="gtype"><xsl:value-of select="$l/@name"/><xsl:value-of + select="$type"/>Func</xsl:attribute> + <xsl:when test="$transfer-ownership='full'"> + <xsl:attribute name="ctype"><xsl:value-of select="$type"/>*</xsl:attribute> + <xsl:attribute name="gtype"> + <xsl:value-of select="$type"/> + <xsl:attribute name="ctype"> + <xsl:value-of select="$type"/> + <xsl:attribute name="gtype"> + <xsl:value-of select="$type"/> + <xsl:template name="get-real-type-name"> + <xsl:param name="node"/> + <xsl:param name="external"/> + <xsl:when test="$node/@glib:is-gtype-struct-for"> + <xsl:variable name="name"> + <xsl:value-of select="$node/@glib:is-gtype-struct-for"/> + <xsl:value-of select="$name"/> + <xsl:variable name="name"> + <xsl:value-of select="$node/@name"/> + <xsl:value-of select="$name"/> + <xsl:template name="map-ctype"> + <xsl:param name="ctype"/> + <xsl:when test="contains($ctype, 'const ')"> + <xsl:value-of select="substring($ctype, 7)"/> + <xsl:value-of select="$ctype"/>