xpidl.xsl revision c8395d73ef52e47d81a2baf3b6a46b7255d02669
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington<?xml version="1.0"?>
816e576f77e2c46df3e3d97d65822aa8aded7c4bDavid Lawrence<!-- $Id$ -->
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson
69b641bf31d95fd79a50dcea2cdb0fcb23fe22c6David Lawrence<!--
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson * A template to generate a XPCOM IDL compatible interface definition file
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson * from the generic interface definition expressed in XML.
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson Copyright (C) 2006-2014 Oracle Corporation
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson This file is part of VirtualBox Open Source Edition (OSE), as
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson available from http://www.virtualbox.org. This file is free software;
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson you can redistribute it and/or modify it under the terms of the GNU
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson General Public License (GPL) as published by the Free Software
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson Foundation, in version 2 as it comes in the "COPYING" file of the
adb6b4397091d2380f0cb412c603816610638f95Brian Wellington VirtualBox OSE distribution. VirtualBox OSE is distributed in the
adb6b4397091d2380f0cb412c603816610638f95Brian Wellington hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson-->
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson<xsl:output method="text"/>
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson
59ddb53fd74be6c4d76536e45465f34f1a08b834Andreas Gustafsson<xsl:strip-space elements="*"/>
59ddb53fd74be6c4d76536e45465f34f1a08b834Andreas Gustafsson
59ddb53fd74be6c4d76536e45465f34f1a08b834Andreas Gustafsson
59ddb53fd74be6c4d76536e45465f34f1a08b834Andreas Gustafsson<!--
59ddb53fd74be6c4d76536e45465f34f1a08b834Andreas Gustafsson// helper definitions
59ddb53fd74be6c4d76536e45465f34f1a08b834Andreas Gustafsson/////////////////////////////////////////////////////////////////////////////
35b61b8fb1f377ec9b68bbc8e4e43fbd2756a04dAndreas Gustafsson-->
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson
35b61b8fb1f377ec9b68bbc8e4e43fbd2756a04dAndreas Gustafsson<!--
35b61b8fb1f377ec9b68bbc8e4e43fbd2756a04dAndreas Gustafsson * capitalizes the first letter
35b61b8fb1f377ec9b68bbc8e4e43fbd2756a04dAndreas Gustafsson-->
35b61b8fb1f377ec9b68bbc8e4e43fbd2756a04dAndreas Gustafsson<xsl:template name="capitalize">
35b61b8fb1f377ec9b68bbc8e4e43fbd2756a04dAndreas Gustafsson <xsl:param name="str" select="."/>
5c62008dee307058a7f70511bf260fdea6f5b1d6Andreas Gustafsson <xsl:value-of select="
5c62008dee307058a7f70511bf260fdea6f5b1d6Andreas Gustafsson concat(
35b61b8fb1f377ec9b68bbc8e4e43fbd2756a04dAndreas Gustafsson translate(substring($str,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
074ae7bf0993ced96b32e3e85553a401f3f3eca9Andreas Gustafsson substring($str,2)
074ae7bf0993ced96b32e3e85553a401f3f3eca9Andreas Gustafsson )
074ae7bf0993ced96b32e3e85553a401f3f3eca9Andreas Gustafsson "/>
074ae7bf0993ced96b32e3e85553a401f3f3eca9Andreas Gustafsson</xsl:template>
074ae7bf0993ced96b32e3e85553a401f3f3eca9Andreas Gustafsson
074ae7bf0993ced96b32e3e85553a401f3f3eca9Andreas Gustafsson<!--
074ae7bf0993ced96b32e3e85553a401f3f3eca9Andreas Gustafsson * uncapitalizes the first letter only if the second one is not capital
074ae7bf0993ced96b32e3e85553a401f3f3eca9Andreas Gustafsson * otherwise leaves the string unchanged
074ae7bf0993ced96b32e3e85553a401f3f3eca9Andreas Gustafsson-->
074ae7bf0993ced96b32e3e85553a401f3f3eca9Andreas Gustafsson<xsl:template name="uncapitalize">
074ae7bf0993ced96b32e3e85553a401f3f3eca9Andreas Gustafsson <xsl:param name="str" select="."/>
074ae7bf0993ced96b32e3e85553a401f3f3eca9Andreas Gustafsson <xsl:choose>
074ae7bf0993ced96b32e3e85553a401f3f3eca9Andreas Gustafsson <xsl:when test="not(contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', substring($str,2,1)))">
074ae7bf0993ced96b32e3e85553a401f3f3eca9Andreas Gustafsson <xsl:value-of select="
322445da85b6a318cb2506d216442b3e5af7c3c0Andreas Gustafsson concat(
533df4efdafcf7a8b7292a298f45df9ab7f7f7f9Mark Andrews translate(substring($str,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
533df4efdafcf7a8b7292a298f45df9ab7f7f7f9Mark Andrews substring($str,2)
a488e91e5dedfd055b6a6e6dc3018866478facceAndreas Gustafsson )
a488e91e5dedfd055b6a6e6dc3018866478facceAndreas Gustafsson "/>
95940593a680fd37704b74849902ca7fd2ff8f2aAndreas Gustafsson </xsl:when>
322445da85b6a318cb2506d216442b3e5af7c3c0Andreas Gustafsson <xsl:otherwise>
692f5c282d13b6a0276e5a60c87ab4af013d3b80Mark Andrews <xsl:value-of select="string($str)"/>
692f5c282d13b6a0276e5a60c87ab4af013d3b80Mark Andrews </xsl:otherwise>
692f5c282d13b6a0276e5a60c87ab4af013d3b80Mark Andrews </xsl:choose>
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson</xsl:template>
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson<!--
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson * translates the string to uppercase
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson-->
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson<xsl:template name="uppercase">
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson <xsl:param name="str" select="."/>
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson <xsl:value-of select="
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson translate($str,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson "/>
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson</xsl:template>
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson<!--
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson// templates
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson/////////////////////////////////////////////////////////////////////////////
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson-->
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson<!--
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson * not explicitly matched elements and attributes
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson-->
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson<xsl:template match="*"/>
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson<!--
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson * header
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson-->
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson<xsl:template match="/idl">
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson <xsl:text>
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson/*
4e0ab18258915b14c163aa9087390402f5ff599bAndreas Gustafsson * DO NOT EDIT! This is a generated file.
4e0ab18258915b14c163aa9087390402f5ff599bAndreas Gustafsson *
4e0ab18258915b14c163aa9087390402f5ff599bAndreas Gustafsson * XPCOM IDL (XPIDL) definition for VirtualBox Main API (COM interfaces)
4e0ab18258915b14c163aa9087390402f5ff599bAndreas Gustafsson * generated from XIDL (XML interface definition).
4e0ab18258915b14c163aa9087390402f5ff599bAndreas Gustafsson *
4e0ab18258915b14c163aa9087390402f5ff599bAndreas Gustafsson * Source : src/VBox/Main/idl/VirtualBox.xidl
4e0ab18258915b14c163aa9087390402f5ff599bAndreas Gustafsson * Generator : src/VBox/Main/idl/xpidl.xsl
4e0ab18258915b14c163aa9087390402f5ff599bAndreas Gustafsson */
4e0ab18258915b14c163aa9087390402f5ff599bAndreas Gustafsson
4e0ab18258915b14c163aa9087390402f5ff599bAndreas Gustafsson#include "nsISupports.idl"
4e0ab18258915b14c163aa9087390402f5ff599bAndreas Gustafsson#include "nsIException.idl"
4e0ab18258915b14c163aa9087390402f5ff599bAndreas Gustafsson
8011cb06c90d9b87e241b3efeb8a2eca2b8edddcAndreas Gustafsson</xsl:text>
8011cb06c90d9b87e241b3efeb8a2eca2b8edddcAndreas Gustafsson <!-- native typedefs for the 'mod="ptr"' attribute -->
a488e91e5dedfd055b6a6e6dc3018866478facceAndreas Gustafsson <xsl:text>
a488e91e5dedfd055b6a6e6dc3018866478facceAndreas Gustafsson[ptr] native booleanPtr (PRBool);
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson[ptr] native octetPtr (PRUint8);
d8417b5f3406f4ace0f3bdb228b05a7b701976d6Andreas Gustafsson[ptr] native shortPtr (PRInt16);
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson[ptr] native ushortPtr (PRUint16);
5dbccb84737c96fef00663919c83ee8f3d6e887aAndreas Gustafsson[ptr] native longPtr (PRInt32);
5dbccb84737c96fef00663919c83ee8f3d6e887aAndreas Gustafsson[ptr] native llongPtr (PRInt64);
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson[ptr] native ulongPtr (PRUint32);
a488e91e5dedfd055b6a6e6dc3018866478facceAndreas Gustafsson[ptr] native ullongPtr (PRUint64);
a488e91e5dedfd055b6a6e6dc3018866478facceAndreas Gustafsson<!-- charPtr is already defined in nsrootidl.idl -->
a488e91e5dedfd055b6a6e6dc3018866478facceAndreas Gustafsson<!-- [ptr] native charPtr (char) -->
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson[ptr] native stringPtr (string);
a488e91e5dedfd055b6a6e6dc3018866478facceAndreas Gustafsson[ptr] native wcharPtr (wchar);
a488e91e5dedfd055b6a6e6dc3018866478facceAndreas Gustafsson[ptr] native wstringPtr (wstring);
a488e91e5dedfd055b6a6e6dc3018866478facceAndreas Gustafsson
a488e91e5dedfd055b6a6e6dc3018866478facceAndreas Gustafsson</xsl:text>
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson <xsl:apply-templates/>
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson</xsl:template>
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson<!--
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson * ignore all |if|s except those for XPIDL target
a488e91e5dedfd055b6a6e6dc3018866478facceAndreas Gustafsson-->
9769d3146777ca71af80b459ecec1ef8e2d05950Andreas Gustafsson<xsl:template match="if">
2e28950b721fcdd29dac6bf306b444ee7642cdf6Andreas Gustafsson <xsl:if test="@target='xpidl'">
2e28950b721fcdd29dac6bf306b444ee7642cdf6Andreas Gustafsson <xsl:apply-templates/>
2e28950b721fcdd29dac6bf306b444ee7642cdf6Andreas Gustafsson </xsl:if>
2e28950b721fcdd29dac6bf306b444ee7642cdf6Andreas Gustafsson</xsl:template>
2e28950b721fcdd29dac6bf306b444ee7642cdf6Andreas Gustafsson<xsl:template match="if" mode="forward">
2e28950b721fcdd29dac6bf306b444ee7642cdf6Andreas Gustafsson <xsl:if test="@target='xpidl'">
4fd7e256467539b0486c1ffac9dcea7a3c9d1d5bAndreas Gustafsson <xsl:apply-templates mode="forward"/>
5dbccb84737c96fef00663919c83ee8f3d6e887aAndreas Gustafsson </xsl:if>
5dbccb84737c96fef00663919c83ee8f3d6e887aAndreas Gustafsson</xsl:template>
5dbccb84737c96fef00663919c83ee8f3d6e887aAndreas Gustafsson<xsl:template match="if" mode="forwarder">
5dbccb84737c96fef00663919c83ee8f3d6e887aAndreas Gustafsson <xsl:if test="@target='midl'">
5dbccb84737c96fef00663919c83ee8f3d6e887aAndreas Gustafsson <xsl:apply-templates mode="forwarder"/>
5dbccb84737c96fef00663919c83ee8f3d6e887aAndreas Gustafsson </xsl:if>
5dbccb84737c96fef00663919c83ee8f3d6e887aAndreas Gustafsson</xsl:template>
9f245fe68267d99dab5e1d1c2124b77886e758bdAndreas Gustafsson
9f245fe68267d99dab5e1d1c2124b77886e758bdAndreas Gustafsson
9f245fe68267d99dab5e1d1c2124b77886e758bdAndreas Gustafsson<!--
9f245fe68267d99dab5e1d1c2124b77886e758bdAndreas Gustafsson * cpp_quote
9f245fe68267d99dab5e1d1c2124b77886e758bdAndreas Gustafsson-->
9f245fe68267d99dab5e1d1c2124b77886e758bdAndreas Gustafsson<xsl:template match="cpp">
5dbccb84737c96fef00663919c83ee8f3d6e887aAndreas Gustafsson <xsl:if test="text()">
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson <xsl:text>%{C++</xsl:text>
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson <xsl:value-of select="text()"/>
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson <xsl:text>&#x0A;%}&#x0A;&#x0A;</xsl:text>
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson </xsl:if>
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson <xsl:if test="not(text()) and @line">
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson <xsl:text>%{C++&#x0A;</xsl:text>
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson <xsl:value-of select="@line"/>
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson <xsl:text>&#x0A;%}&#x0A;&#x0A;</xsl:text>
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson </xsl:if>
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson</xsl:template>
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson<!--
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson * #if statement (@if attribute)
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson * @note
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson * xpidl doesn't support any preprocessor defines other than #include
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson * (it just ignores them), so the generated IDL will most likely be
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson * invalid. So for now we forbid using @if attributes
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson-->
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson<xsl:template match="@if" mode="begin">
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson <xsl:message terminate="yes">
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson @if attributes are not currently allowed because xpidl lacks
ecbe731ce428d243b0c7eea5d2d2b24732a698a1Andreas Gustafsson support for #ifdef and stuff.
923cbf79eb621bb82f8a648f4ecb947667a1e5d3Andreas Gustafsson </xsl:message>
923cbf79eb621bb82f8a648f4ecb947667a1e5d3Andreas Gustafsson <xsl:text>#if </xsl:text>
923cbf79eb621bb82f8a648f4ecb947667a1e5d3Andreas Gustafsson <xsl:value-of select="."/>
923cbf79eb621bb82f8a648f4ecb947667a1e5d3Andreas Gustafsson <xsl:text>&#x0A;</xsl:text>
db9c64f8efa42d9e0327111ac510c69eaa7429e2Brian Wellington</xsl:template>
a488e91e5dedfd055b6a6e6dc3018866478facceAndreas Gustafsson<xsl:template match="@if" mode="end">
923cbf79eb621bb82f8a648f4ecb947667a1e5d3Andreas Gustafsson <xsl:text>#endif&#x0A;</xsl:text>
923cbf79eb621bb82f8a648f4ecb947667a1e5d3Andreas Gustafsson</xsl:template>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson<!--
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson * libraries
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson-->
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson<xsl:template match="library">
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:text>%{C++&#x0A;</xsl:text>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:text>#ifndef VBOX_EXTERN_C&#x0A;</xsl:text>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:text># ifdef __cplusplus&#x0A;</xsl:text>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:text># define VBOX_EXTERN_C extern "C"&#x0A;</xsl:text>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:text># else // !__cplusplus&#x0A;</xsl:text>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:text># define VBOX_EXTERN_C extern&#x0A;</xsl:text>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:text># endif // !__cplusplus&#x0A;</xsl:text>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:text>#endif // !VBOX_EXTERN_C&#x0A;</xsl:text>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <!-- result codes -->
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:text>// result codes declared in API spec&#x0A;</xsl:text>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:for-each select="result">
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:apply-templates select="."/>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson </xsl:for-each>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:text>%}&#x0A;&#x0A;</xsl:text>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <!-- forward declarations -->
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:apply-templates select="if | interface" mode="forward"/>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:text>&#x0A;</xsl:text>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <!-- all enums go first -->
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:apply-templates select="enum | if/enum"/>
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <!-- everything else but result codes and enums -->
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson <xsl:apply-templates select="*[not(self::result or self::enum) and
1593eff60a5efda85f97f819c3b1ed8aafc56c60Andreas Gustafsson not(self::if[result] or self::if[enum])]"/>
4fd7e256467539b0486c1ffac9dcea7a3c9d1d5bAndreas Gustafsson <!-- -->
</xsl:template>
<!--
* result codes
-->
<xsl:template match="result">
<xsl:value-of select="concat('#define ',@name,' ',@value)"/>
<xsl:text>&#x0A;</xsl:text>
</xsl:template>
<!--
* forward declarations
-->
<xsl:template match="interface" mode="forward">
<xsl:text>interface </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>;&#x0A;</xsl:text>
</xsl:template>
<!--
* interfaces
-->
<xsl:template match="interface">[
uuid(<xsl:value-of select="@uuid"/>),
scriptable
]
<xsl:text>interface </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text> : </xsl:text>
<xsl:choose>
<xsl:when test="@extends='$unknown'">nsISupports</xsl:when>
<xsl:when test="@extends='$dispatched'">nsISupports</xsl:when>
<xsl:when test="@extends='$errorinfo'">nsIException</xsl:when>
<xsl:otherwise><xsl:value-of select="@extends"/></xsl:otherwise>
</xsl:choose>
<xsl:text>&#x0A;{&#x0A;</xsl:text>
<!-- attributes (properties) -->
<xsl:apply-templates select="attribute"/>
<!-- methods -->
<xsl:apply-templates select="method"/>
<!-- 'if' enclosed elements, unsorted -->
<xsl:apply-templates select="if"/>
<!-- -->
<xsl:text>}; /* interface </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text> */&#x0A;&#x0A;</xsl:text>
<!-- Interface implementation forwarder macro -->
<xsl:text>/* Interface implementation forwarder macro */&#x0A;</xsl:text>
<xsl:text>%{C++&#x0A;</xsl:text>
<!-- 1) individual methods -->
<xsl:apply-templates select="attribute" mode="forwarder"/>
<xsl:apply-templates select="method" mode="forwarder"/>
<xsl:apply-templates select="if" mode="forwarder"/>
<!-- 2) COM_FORWARD_Interface_TO(smth) -->
<xsl:text>#define COM_FORWARD_</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>_TO(smth) NS_FORWARD_</xsl:text>
<xsl:call-template name="uppercase">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text> (smth)&#x0A;</xsl:text>
<!-- 3) COM_FORWARD_Interface_TO_OBJ(obj) -->
<xsl:text>#define COM_FORWARD_</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>_TO ((obj)->)&#x0A;</xsl:text>
<!-- 4) COM_FORWARD_Interface_TO_BASE(base) -->
<xsl:text>#define COM_FORWARD_</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>_TO (base::)&#x0A;&#x0A;</xsl:text>
<!-- -->
<xsl:text>// for compatibility with Win32&#x0A;</xsl:text>
<xsl:text>VBOX_EXTERN_C const nsID IID_</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>;&#x0A;</xsl:text>
<xsl:text>%}&#x0A;&#x0A;</xsl:text>
<!-- end -->
</xsl:template>
<!--
* attributes
-->
<xsl:template match="interface//attribute">
<xsl:apply-templates select="@if" mode="begin"/>
<xsl:if test="@mod='ptr'">
<!-- attributes using native types must be non-scriptable -->
<xsl:text> [noscript]&#x0A;</xsl:text>
</xsl:if>
<xsl:choose>
<!-- safearray pseudo attribute -->
<xsl:when test="@safearray='yes'">
<!-- getter -->
<xsl:text> void get</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text> (&#x0A;</xsl:text>
<!-- array size -->
<xsl:text> out unsigned long </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>Size,&#x0A;</xsl:text>
<!-- array pointer -->
<xsl:text> [array, size_is(</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>Size), retval] out </xsl:text>
<xsl:apply-templates select="@type"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>&#x0A; );&#x0A;</xsl:text>
<!-- setter -->
<xsl:if test="not(@readonly='yes')">
<xsl:text> void set</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text> (&#x0A;</xsl:text>
<!-- array size -->
<xsl:text> in unsigned long </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>Size,&#x0A;</xsl:text>
<!-- array pointer -->
<xsl:text> [array, size_is(</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>Size)] in </xsl:text>
<xsl:apply-templates select="@type"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>&#x0A; );&#x0A;</xsl:text>
</xsl:if>
</xsl:when>
<!-- normal attribute -->
<xsl:otherwise>
<xsl:text> </xsl:text>
<xsl:if test="@readonly='yes'">
<xsl:text>readonly </xsl:text>
</xsl:if>
<xsl:text>attribute </xsl:text>
<xsl:apply-templates select="@type"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>;&#x0A;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="@if" mode="end"/>
<xsl:text>&#x0A;</xsl:text>
</xsl:template>
<xsl:template match="interface//attribute" mode="forwarder">
<xsl:variable name="parent" select="ancestor::interface"/>
<xsl:apply-templates select="@if" mode="begin"/>
<!-- getter: COM_FORWARD_Interface_GETTER_Name_TO(smth) -->
<xsl:text>#define COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_GETTER_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO(smth) NS_IMETHOD Get</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text> (</xsl:text>
<xsl:if test="@safearray='yes'">
<xsl:text>PRUint32 * a</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>Size, </xsl:text>
</xsl:if>
<xsl:apply-templates select="@type" mode="forwarder"/>
<xsl:if test="@safearray='yes'">
<xsl:text> *</xsl:text>
</xsl:if>
<xsl:text> * a</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>) { return smth Get</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text> (</xsl:text>
<xsl:if test="@safearray='yes'">
<xsl:text>a</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>Size, </xsl:text>
</xsl:if>
<xsl:text>a</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>); }&#x0A;</xsl:text>
<!-- getter: COM_FORWARD_Interface_GETTER_Name_TO_OBJ(obj) -->
<xsl:text>#define COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_GETTER_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_GETTER_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO ((obj)->)&#x0A;</xsl:text>
<!-- getter: COM_FORWARD_Interface_GETTER_Name_TO_BASE(base) -->
<xsl:text>#define COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_GETTER_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_GETTER_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO (base::)&#x0A;</xsl:text>
<!-- -->
<xsl:if test="not(@readonly='yes')">
<!-- setter: COM_FORWARD_Interface_SETTER_Name_TO(smth) -->
<xsl:text>#define COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_SETTER_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO(smth) NS_IMETHOD Set</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text> (</xsl:text>
<xsl:if test="@safearray='yes'">
<xsl:text>PRUint32 a</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>Size, </xsl:text>
</xsl:if>
<xsl:if test="not(@safearray='yes') and (@type='string' or @type='wstring')">
<xsl:text>const </xsl:text>
</xsl:if>
<xsl:apply-templates select="@type" mode="forwarder"/>
<xsl:if test="@safearray='yes'">
<xsl:text> *</xsl:text>
</xsl:if>
<xsl:text> a</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>) { return smth Set</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text> (a</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>); }&#x0A;</xsl:text>
<!-- setter: COM_FORWARD_Interface_SETTER_Name_TO_OBJ(obj) -->
<xsl:text>#define COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_SETTER_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_SETTER_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO ((obj)->)&#x0A;</xsl:text>
<!-- setter: COM_FORWARD_Interface_SETTER_Name_TO_BASE(base) -->
<xsl:text>#define COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_SETTER_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_SETTER_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO (base::)&#x0A;</xsl:text>
</xsl:if>
<xsl:apply-templates select="@if" mode="end"/>
</xsl:template>
<!--
* methods
-->
<xsl:template match="interface//method">
<xsl:apply-templates select="@if" mode="begin"/>
<xsl:if test="param/@mod='ptr'">
<!-- methods using native types must be non-scriptable -->
<xsl:text> [noscript]&#x0A;</xsl:text>
</xsl:if>
<xsl:text> void </xsl:text>
<xsl:value-of select="@name"/>
<xsl:if test="param">
<xsl:text> (&#x0A;</xsl:text>
<xsl:for-each select="param [position() != last()]">
<xsl:text> </xsl:text>
<xsl:apply-templates select="."/>
<xsl:text>,&#x0A;</xsl:text>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:apply-templates select="param [last()]"/>
<xsl:text>&#x0A; );&#x0A;</xsl:text>
</xsl:if>
<xsl:if test="not(param)">
<xsl:text>();&#x0A;</xsl:text>
</xsl:if>
<xsl:apply-templates select="@if" mode="end"/>
<xsl:text>&#x0A;</xsl:text>
</xsl:template>
<xsl:template match="interface//method" mode="forwarder">
<xsl:variable name="parent" select="ancestor::interface"/>
<xsl:apply-templates select="@if" mode="begin"/>
<xsl:text>#define COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO(smth) NS_IMETHOD </xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="param">
<xsl:text> (</xsl:text>
<xsl:for-each select="param [position() != last()]">
<xsl:apply-templates select="." mode="forwarder"/>
<xsl:text>, </xsl:text>
</xsl:for-each>
<xsl:apply-templates select="param [last()]" mode="forwarder"/>
<xsl:text>) { return smth </xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text> (</xsl:text>
<xsl:for-each select="param [position() != last()]">
<xsl:if test="@safearray='yes'">
<xsl:text>a</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>Size+++, </xsl:text>
</xsl:if>
<xsl:text>a</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>, </xsl:text>
</xsl:for-each>
<xsl:if test="param [last()]/@safearray='yes'">
<xsl:text>a</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="param [last()]/@name"/>
</xsl:call-template>
<xsl:text>Size, </xsl:text>
</xsl:if>
<xsl:text>a</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="param [last()]/@name"/>
</xsl:call-template>
<xsl:text>); }</xsl:text>
</xsl:when>
<xsl:otherwise test="not(param)">
<xsl:text>() { return smth </xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>(); }</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&#x0A;</xsl:text>
<!-- COM_FORWARD_Interface_Method_TO_OBJ(obj) -->
<xsl:text>#define COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO ((obj)->)&#x0A;</xsl:text>
<!-- COM_FORWARD_Interface_Method_TO_BASE(base) -->
<xsl:text>#define COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text>
<xsl:value-of select="$parent/@name"/>
<xsl:text>_</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_TO (base::)&#x0A;</xsl:text>
<xsl:apply-templates select="@if" mode="end"/>
</xsl:template>
<!--
* modules
-->
<xsl:template match="module">
<xsl:apply-templates select="class"/>
</xsl:template>
<!--
* co-classes
-->
<xsl:template match="module/class">
<!-- class and contract id -->
<xsl:text>%{C++&#x0A;</xsl:text>
<xsl:text>// Definitions for module </xsl:text>
<xsl:value-of select="../@name"/>
<xsl:text>, class </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>:&#x0A;</xsl:text>
<xsl:text>#define NS_</xsl:text>
<xsl:call-template name="uppercase">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_CID { \&#x0A;</xsl:text>
<xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
<xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
<xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
<xsl:text>, \&#x0A; </xsl:text>
<xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
<xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
<xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
<xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
<xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
<xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
<xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
<xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
<xsl:text> } \&#x0A;}&#x0A;</xsl:text>
<xsl:text>#define NS_</xsl:text>
<xsl:call-template name="uppercase">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<!-- Contract ID -->
<xsl:text>_CONTRACTID &quot;@</xsl:text>
<xsl:value-of select="@namespace"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>;1&quot;&#x0A;</xsl:text>
<!-- CLSID_xxx declarations for XPCOM, for compatibility with Win32 -->
<xsl:text>// for compatibility with Win32&#x0A;</xsl:text>
<xsl:text>VBOX_EXTERN_C const nsCID CLSID_</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>;&#x0A;</xsl:text>
<xsl:text>%}&#x0A;&#x0A;</xsl:text>
</xsl:template>
<!--
* enums
-->
<xsl:template match="enum">[
uuid(<xsl:value-of select="@uuid"/>),
scriptable
]
<xsl:text>interface </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>&#x0A;{&#x0A;</xsl:text>
<xsl:for-each select="const">
<xsl:text> const PRUint32 </xsl:text>
<xsl:value-of select="@name"/> = <xsl:value-of select="@value"/>
<xsl:text>;&#x0A;</xsl:text>
</xsl:for-each>
<xsl:text>};&#x0A;&#x0A;</xsl:text>
<!-- -->
<xsl:value-of select="concat('/* cross-platform type name for ', @name, ' */&#x0A;')"/>
<xsl:text>%{C++&#x0A;</xsl:text>
<xsl:value-of select="concat('#define ', @name, '_T', ' ',
'PRUint32&#x0A;')"/>
<xsl:text>%}&#x0A;&#x0A;</xsl:text>
<!-- -->
<xsl:value-of select="concat('/* cross-platform constants for ', @name, ' */&#x0A;')"/>
<xsl:text>%{C++&#x0A;</xsl:text>
<xsl:for-each select="const">
<xsl:value-of select="concat('#define ', ../@name, '_', @name, ' ',
../@name, '::', @name, '&#x0A;')"/>
</xsl:for-each>
<xsl:text>%}&#x0A;&#x0A;</xsl:text>
</xsl:template>
<!--
* method parameters
-->
<xsl:template match="method/param">
<xsl:choose>
<!-- safearray parameters -->
<xsl:when test="@safearray='yes'">
<!-- array size -->
<xsl:choose>
<xsl:when test="@dir='in'">in </xsl:when>
<xsl:when test="@dir='out'">out </xsl:when>
<xsl:when test="@dir='return'">out </xsl:when>
<xsl:otherwise>in </xsl:otherwise>
</xsl:choose>
<xsl:text>unsigned long </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>Size,&#x0A;</xsl:text>
<!-- array pointer -->
<xsl:text> [array, size_is(</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>Size)</xsl:text>
<xsl:choose>
<xsl:when test="@dir='in'">] in </xsl:when>
<xsl:when test="@dir='out'">] out </xsl:when>
<xsl:when test="@dir='return'"> , retval] out </xsl:when>
<xsl:otherwise>] in </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="@type"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
</xsl:when>
<!-- normal and array parameters -->
<xsl:otherwise>
<xsl:choose>
<xsl:when test="@dir='in'">in </xsl:when>
<xsl:when test="@dir='out'">out </xsl:when>
<xsl:when test="@dir='return'">[retval] out </xsl:when>
<xsl:otherwise>in </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="@type"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="method/param" mode="forwarder">
<xsl:if test="@safearray='yes'">
<xsl:text>PRUint32</xsl:text>
<xsl:if test="@dir='out' or @dir='return'">
<xsl:text> *</xsl:text>
</xsl:if>
<xsl:text> a</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>Size, </xsl:text>
</xsl:if>
<xsl:apply-templates select="@type" mode="forwarder"/>
<xsl:if test="@dir='out' or @dir='return'">
<xsl:text> *</xsl:text>
</xsl:if>
<xsl:if test="@safearray='yes'">
<xsl:text> *</xsl:text>
</xsl:if>
<xsl:text> a</xsl:text>
<xsl:call-template name="capitalize">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
</xsl:template>
<!--
* attribute/parameter type conversion
-->
<xsl:template match="attribute/@type | param/@type">
<xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
<xsl:choose>
<!-- modifiers (ignored for 'enumeration' attributes)-->
<xsl:when test="name(current())='type' and ../@mod">
<xsl:choose>
<xsl:when test="../@mod='ptr'">
<xsl:choose>
<!-- standard types -->
<!--xsl:when test=".='result'">??</xsl:when-->
<xsl:when test=".='boolean'">booleanPtr</xsl:when>
<xsl:when test=".='octet'">octetPtr</xsl:when>
<xsl:when test=".='short'">shortPtr</xsl:when>
<xsl:when test=".='unsigned short'">ushortPtr</xsl:when>
<xsl:when test=".='long'">longPtr</xsl:when>
<xsl:when test=".='long long'">llongPtr</xsl:when>
<xsl:when test=".='unsigned long'">ulongPtr</xsl:when>
<xsl:when test=".='unsigned long long'">ullongPtr</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
<xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
<xsl:text>attribute 'mod=</xsl:text>
<xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
<xsl:text>' cannot be used with type </xsl:text>
<xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="../@mod='string'">
<xsl:choose>
<!-- standard types -->
<!--xsl:when test=".='result'">??</xsl:when-->
<xsl:when test=".='uuid'">wstring</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
<xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
<xsl:text>attribute 'mod=</xsl:text>
<xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
<xsl:text>' cannot be used with type </xsl:text>
<xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
<xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
<xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
<xsl:text>of attribute 'mod' is invalid!</xsl:text>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- no modifiers -->
<xsl:otherwise>
<xsl:choose>
<!-- standard types -->
<xsl:when test=".='result'">nsresult</xsl:when>
<xsl:when test=".='boolean'">boolean</xsl:when>
<xsl:when test=".='octet'">octet</xsl:when>
<xsl:when test=".='short'">short</xsl:when>
<xsl:when test=".='unsigned short'">unsigned short</xsl:when>
<xsl:when test=".='long'">long</xsl:when>
<xsl:when test=".='long long'">long long</xsl:when>
<xsl:when test=".='unsigned long'">unsigned long</xsl:when>
<xsl:when test=".='unsigned long long'">unsigned long long</xsl:when>
<xsl:when test=".='char'">char</xsl:when>
<xsl:when test=".='wchar'">wchar</xsl:when>
<xsl:when test=".='string'">string</xsl:when>
<xsl:when test=".='wstring'">wstring</xsl:when>
<!-- UUID type -->
<xsl:when test=".='uuid'">
<xsl:choose>
<xsl:when test="name(..)='attribute'">
<xsl:choose>
<xsl:when test="../@readonly='yes'">
<xsl:text>nsIDPtr</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
<xsl:value-of select="../@name"/>
<xsl:text>: Non-readonly uuid attributes are not supported!</xsl:text>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="name(..)='param'">
<xsl:choose>
<xsl:when test="../@dir='in' and not(../@safearray='yes')">
<xsl:text>nsIDRef</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>nsIDPtr</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:when>
<!-- system interface types -->
<xsl:when test=".='$unknown'">nsISupports</xsl:when>
<xsl:otherwise>
<xsl:choose>
<!-- enum types -->
<xsl:when test="
(ancestor::library/enum[@name=current()]) or
(ancestor::library/if[@target=$self_target]/enum[@name=current()])
">
<xsl:text>PRUint32</xsl:text>
</xsl:when>
<!-- custom interface types -->
<xsl:when test="
(ancestor::library/interface[@name=current()]) or
(ancestor::library/if[@target=$self_target]/interface[@name=current()])
">
<xsl:value-of select="."/>
</xsl:when>
<!-- other types -->
<xsl:otherwise>
<xsl:message terminate="yes">
<xsl:text>Unknown parameter type: </xsl:text>
<xsl:value-of select="."/>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="attribute/@type | param/@type" mode="forwarder">
<xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
<xsl:choose>
<!-- modifiers (ignored for 'enumeration' attributes)-->
<xsl:when test="name(current())='type' and ../@mod">
<xsl:choose>
<xsl:when test="../@mod='ptr'">
<xsl:choose>
<!-- standard types -->
<!--xsl:when test=".='result'">??</xsl:when-->
<xsl:when test=".='boolean'">PRBool *</xsl:when>
<xsl:when test=".='octet'">PRUint8 *</xsl:when>
<xsl:when test=".='short'">PRInt16 *</xsl:when>
<xsl:when test=".='unsigned short'">PRUint16 *</xsl:when>
<xsl:when test=".='long'">PRInt32 *</xsl:when>
<xsl:when test=".='long long'">PRInt64 *</xsl:when>
<xsl:when test=".='unsigned long'">PRUint32 *</xsl:when>
<xsl:when test=".='unsigned long long'">PRUint64 *</xsl:when>
<xsl:when test=".='char'">char *</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
<xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
<xsl:text>attribute 'mod=</xsl:text>
<xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
<xsl:text>' cannot be used with type </xsl:text>
<xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="../@mod='string'">
<xsl:choose>
<!-- standard types -->
<!--xsl:when test=".='result'">??</xsl:when-->
<xsl:when test=".='uuid'">PRUnichar *</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
<xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
<xsl:text>attribute 'mod=</xsl:text>
<xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
<xsl:text>' cannot be used with type </xsl:text>
<xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:when>
<!-- no modifiers -->
<xsl:otherwise>
<xsl:choose>
<!-- standard types -->
<xsl:when test=".='result'">nsresult</xsl:when>
<xsl:when test=".='boolean'">PRBool</xsl:when>
<xsl:when test=".='octet'">PRUint8</xsl:when>
<xsl:when test=".='short'">PRInt16</xsl:when>
<xsl:when test=".='unsigned short'">PRUint16</xsl:when>
<xsl:when test=".='long'">PRInt32</xsl:when>
<xsl:when test=".='long long'">PRInt64</xsl:when>
<xsl:when test=".='unsigned long'">PRUint32</xsl:when>
<xsl:when test=".='unsigned long long'">PRUint64</xsl:when>
<xsl:when test=".='char'">char</xsl:when>
<xsl:when test=".='wchar'">PRUnichar</xsl:when>
<!-- string types -->
<xsl:when test=".='string'">char *</xsl:when>
<xsl:when test=".='wstring'">PRUnichar *</xsl:when>
<!-- UUID type -->
<xsl:when test=".='uuid'">
<xsl:choose>
<xsl:when test="name(..)='attribute'">
<xsl:choose>
<xsl:when test="../@readonly='yes'">
<xsl:text>nsID *</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="name(..)='param'">
<xsl:choose>
<xsl:when test="../@dir='in' and not(../@safearray='yes')">
<xsl:text>const nsID &amp;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>nsID *</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:when>
<!-- system interface types -->
<xsl:when test=".='$unknown'">nsISupports *</xsl:when>
<xsl:otherwise>
<xsl:choose>
<!-- enum types -->
<xsl:when test="
(ancestor::library/enum[@name=current()]) or
(ancestor::library/if[@target=$self_target]/enum[@name=current()])
">
<xsl:text>PRUint32</xsl:text>
</xsl:when>
<!-- custom interface types -->
<xsl:when test="
(ancestor::library/interface[@name=current()]) or
(ancestor::library/if[@target=$self_target]/interface[@name=current()])
">
<xsl:value-of select="."/>
<xsl:text> *</xsl:text>
</xsl:when>
<!-- other types -->
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>