1
1
openmpi/ompi/mpi/f90/xml/common-C.xsl
Jeff Squyres f8e634d6ca Bring over /tmp/f90-stuff branch to the trunk.
svn merge -r 9453:9609 https://svn.open-mpi.org/svn/ompi/tmp/f90-stuff .

Several improvements over the current F90 MPI bindings:

- The capability to make 4 sizes of the F90 bindings:
  - trivial: only the F90-specific MPI functions (sizeof and a few
    others)
  - small: (this is the default) all MPI functions that do not take
    choice buffers
  - medium: small + all MPI functions that take one choice buffer
    (e.g., MPI_SEND)
  - large: all MPI functions, but those that take 2 choice buffers
    (e.g., MPI_GATHER) only allow both buffers to be of the same type
- Remove all non-standard MPI types (LOGICAL*x, CHARACTER*x)
- Remove use of selected_*_kind() and only use MPI-defined types
  (INTEGER*x, etc.)
- Decrease complexity of the F90 configure and build system

This commit was SVN r9610.
2006-04-11 03:33:38 +00:00

447 строки
11 KiB
XML

<!--
...........................................................................
Copyright (c) 2004-2006 The Regents of the University of California.
All rights reserved.
$COPYRIGHT$
Additional copyrights may follow
$HEADER$
...........................................................................
-->
<!--
- common templates for creating C files
-
- templates:
-
- openFile ([filename=''])
- closeFile ([filename=''])
-
- openExternC
- closeExternC
-
- function-decl ([id=function-id, ws='']) <method>
- param-type-list <method>
- param-list <method>
- param-decl ([id=param-id]) <arg>
-
- function-def ([id=function-id, ws='', module]) <method>
- param-type-id-list <method>
- param-id-list <method>
-
- compound-statement <method>
- decl-list <method>
- decl-list-decl-rtn <method>
- decl-list-decl-arg <method>
-
- statement-list <method>
- call-statement <method>
-
- arg-list <method>
- arg-list-hidden <method>
-
- type-conv-name-ext <arg/type>
-
- function-id <method>
- param-id <arg>
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="type-conversions.xsl"/>
<xsl:output method="text"/>
<!--
- openFile: print file header information
-->
<xsl:template name="openFile">
<xsl:param name="filename" select="''"/>
<xsl:text>/**</xsl:text> <xsl:value-of select="$nl"/>
<xsl:text> * </xsl:text>
<xsl:if test="$filename != ''">
<xsl:value-of select="$filename"/>
</xsl:if>
<xsl:text> - this file is automatically generated</xsl:text>
<xsl:value-of select="$nl"/>
<xsl:text> */</xsl:text> <xsl:value-of select="$nl"/>
<xsl:value-of select="$nl"/>
</xsl:template>
<!--
- closeFile: finish up
-->
<xsl:template name="closeFile">
<xsl:param name="filename" select="''"/>
</xsl:template>
<!--
- openExternC: open extern "C" declaration
-->
<xsl:template name="openExternC">
<xsl:text>#ifdef __cplusplus</xsl:text> <xsl:value-of select="$nl"/>
<xsl:text>extern "C" {</xsl:text> <xsl:value-of select="$nl"/>
<xsl:text>#endif</xsl:text> <xsl:value-of select="$nl"/>
<xsl:value-of select="$nl"/>
</xsl:template>
<!--
- closeExternC: close extern "C" declaration
-->
<xsl:template name="closeExternC">
<xsl:text>#ifdef __cplusplus</xsl:text> <xsl:value-of select="$nl"/>
<xsl:text>}</xsl:text> <xsl:value-of select="$nl"/>
<xsl:text>#endif</xsl:text> <xsl:value-of select="$nl"/>
<xsl:value-of select="$nl"/>
</xsl:template>
<!--
- function-decl <method>
- type-qual type-spec function-id ( param-type-list );
-->
<xsl:template name="function-decl">
<xsl:param name="id">
<xsl:call-template name="function-id"/>
</xsl:param>
<xsl:param name="ws" select="''"/>
<xsl:value-of select="$ws"/>
<xsl:if test="@kind = 'static'">
<xsl:text>static </xsl:text>
</xsl:if>
<xsl:for-each select="return[1]/type">
<xsl:call-template name="type-spec"/>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:value-of select="$id"/>
<xsl:text>(</xsl:text>
<xsl:call-template name="param-type-list"/>
<xsl:text>);</xsl:text>
<xsl:value-of select="$nl"/>
</xsl:template>
<!--
- param-type-list <method>
-->
<xsl:template name="param-type-list">
<xsl:param name="with_hidden" select="'no'"/>
<xsl:call-template name="param-list">
<xsl:with-param name="with_hidden" select="$with_hidden"/>
</xsl:call-template>
</xsl:template>
<!--
- param-list <method>
-
- NOTE, changed to use apply-templates to get around Xalan-C bug in ver 1.9.
-->
<xsl:template name="param-list">
<xsl:param name="with_hidden" select="'no'"/>
<xsl:apply-templates select="arg" mode="param-decl">
<xsl:with-param name="with_hidden" select="$with_hidden"/>
</xsl:apply-templates>
<xsl:apply-templates select="arg" mode="param-decl-hidden">
<xsl:with-param name="with_hidden" select="$with_hidden"/>
</xsl:apply-templates>
</xsl:template>
<!--
- param-decl - arg node
-->
<xsl:template match="arg" mode="param-decl">
<xsl:variable name="hide_arg">
<xsl:call-template name="hide-arg"/>
</xsl:variable>
<xsl:if test="$hide_arg = 'no'">
<xsl:call-template name="param-decl"/>
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:if>
</xsl:template>
<!--
- param-decl-hidden - arg node
-->
<xsl:template match="arg" mode="param-decl-hidden">
<xsl:param name="with_hidden" select="'no'"/>
<xsl:if test="$with_hidden = 'yes'">
<xsl:variable name="hidden">
<xsl:call-template name="param-decl-hidden"/>
</xsl:variable>
<xsl:if test="$hidden != ''">
<xsl:value-of select="concat(', ', $hidden)"/>
</xsl:if>
</xsl:if>
</xsl:template>
<!--
- param-decl <arg>
- type-qual type-spec pointer param-id
-->
<xsl:template name="param-decl">
<xsl:param name="id">
<xsl:call-template name="param-id"/>
</xsl:param>
<xsl:variable name="type_qual">
<xsl:call-template name="type-qual"/>
</xsl:variable>
<xsl:if test="$type_qual != ''">
<xsl:value-of select="concat($type_qual, ' ')"/>
</xsl:if>
<xsl:for-each select="type[1]">
<xsl:call-template name="type-spec"/>
<xsl:call-template name="pointer"/>
</xsl:for-each>
<xsl:if test="$id != ''">
<xsl:value-of select="concat(' ', $id)"/>
</xsl:if>
</xsl:template>
<!--
- param-decl-hidden <arg>
-->
<xsl:template name="param-decl-hidden">
</xsl:template>
<!--
- function-def <method>
- type-qual-rtn type-spec-rtn function-id ( param-type-id-list )
- compound-statement = { decl-list statement-list }
-->
<xsl:template name="function-def">
<xsl:param name="id">
<xsl:call-template name="function-id"/>
</xsl:param>
<xsl:param name="ws" select="''"/>
<xsl:param name="module"/>
<xsl:value-of select="$ws"/>
<xsl:for-each select="return[1]/type">
<xsl:call-template name="type-qual-rtn"/>
</xsl:for-each>
<xsl:for-each select="return[1]/type">
<xsl:call-template name="type-spec-rtn"/>
</xsl:for-each>
<xsl:value-of select="$nl"/>
<xsl:value-of select="$id"/>
<xsl:text>(</xsl:text>
<xsl:call-template name="param-type-id-list">
<xsl:with-param name="module" select="$module"/>
</xsl:call-template>
<xsl:text>)</xsl:text> <xsl:value-of select="$nl"/>
<xsl:call-template name="compound-statement">
<xsl:with-param name="function_id" select="$id"/>
</xsl:call-template>
<xsl:value-of select="$nl"/>
</xsl:template>
<!--
- param-type-id-list ([module]) <method>
-->
<xsl:template name="param-type-id-list">
<xsl:param name="module"/>
<xsl:call-template name="param-id-list">
<xsl:with-param name="module" select="$module"/>
</xsl:call-template>
</xsl:template>
<!--
- param-id-list ([module]) <method>
-->
<xsl:template name="param-id-list">
<xsl:param name="module"/>
<xsl:for-each select="arg">
<xsl:call-template name="param-decl">
<xsl:with-param name="id" select="@name"/>
</xsl:call-template>
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
<!--
- compound-statement <method>
- decl-list statement-list
-->
<xsl:template name="compound-statement">
<xsl:param name="function_id">
<xsl:call-template name="function-id"/>
</xsl:param>
<xsl:text>{</xsl:text> <xsl:value-of select="$nl"/>
<xsl:call-template name="decl-list"/>
<xsl:call-template name="statement-list">
<xsl:with-param name="function_id" select="$function_id"/>
</xsl:call-template>
<xsl:text>}</xsl:text> <xsl:value-of select="$nl"/>
</xsl:template>
<!--
- decl-list <method>
-->
<xsl:template name="decl-list">
<xsl:for-each select="return[1]/type">
<xsl:call-template name="decl-list-decl-rtn"/>
</xsl:for-each>
<xsl:for-each select="arg/type">
<xsl:call-template name="decl-list-decl-arg"/>
</xsl:for-each>
</xsl:template>
<!--
- decl-list-decl-rtn ([rtn_id=rtn-id, ws=' ']) <return/type>
-->
<xsl:template name="decl-list-decl-rtn">
</xsl:template>
<!--
- decl-list-decl-arg ([arg_id=arg-id, ws=' ']) <arg/type>
-->
<xsl:template name="decl-list-decl-arg">
</xsl:template>
<!--
- statement-list <method>
-->
<xsl:template name="statement-list">
<xsl:param name="function_id">
<xsl:call-template name="function-id"/>
</xsl:param>
<xsl:call-template name="statement-list-pre-call"/>
<xsl:call-template name="call-statement">
<xsl:with-param name="id">
<xsl:text>PTR_</xsl:text> <xsl:value-of select="$function_id"/>
</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="statement-list-post-call"/>
</xsl:template>
<!--
- statement-list-pre-call <method>
-->
<xsl:template name="statement-list-pre-call">
<xsl:param name="ws" select="' '"/>
</xsl:template>
<!--
- statement-list-post-call <method>
-->
<xsl:template name="statement-list-post-call">
<xsl:param name="ws" select="' '"/>
</xsl:template>
<!--
- call-statement <method>
- rtn-id assignment-operator function-id (arg-list)
-->
<xsl:template name="call-statement">
<xsl:param name="id">
<xsl:call-template name="function-id"/>
</xsl:param>
<xsl:param name="ws" select="' '"/>
<xsl:value-of select="$ws"/>
<xsl:for-each select="return[1]/type">
<xsl:call-template name="rtn-id"/>
<xsl:call-template name="assignment-operator"/>
</xsl:for-each>
<xsl:value-of select="$id"/>
<xsl:text>(</xsl:text>
<xsl:call-template name="arg-list"/>
<xsl:text>)</xsl:text>
<xsl:text>;</xsl:text> <xsl:value-of select="$nl"/>
</xsl:template>
<!--
- arg-list <method>
-->
<xsl:template name="arg-list">
<xsl:for-each select="arg/type">
<xsl:variable name="ext">
<xsl:call-template name="type-conv-name-ext"/>
</xsl:variable>
<xsl:call-template name="address-operator"/>
<xsl:call-template name="arg-id"/>
<xsl:value-of select="$ext"/>
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:call-template name="arg-list-hidden"/>
</xsl:template>
<!--
- arg-list-hidden <method>
-->
<xsl:template name="arg-list-hidden">
</xsl:template>
<!--
- type-conv-name-ext <arg/type>
-->
<xsl:template name="type-conv-name-ext">
<xsl:param name="depth" select="0"/>
</xsl:template>
<!--
- type-conv-statement <method/arg/type>
-->
<xsl:template name="type-conv-statement">
<xsl:param name="depth" select="0"/>
<xsl:param name="ws"/>
<xsl:param name="arg_name"/>
<xsl:param name="ext"/>
</xsl:template>
<!--
- function-id <method>
-->
<xsl:template name="function-id">
<xsl:value-of select="@name"/>
</xsl:template>
<!--
- param-id <method>
-->
<xsl:template name="param-id"/>
<!--
- hide-arg <arg>
- return yes if arg is not to be included in parameter list
-->
<xsl:template name="hide-arg">
<xsl:text>no</xsl:text>
</xsl:template>
</xsl:stylesheet>