1
1
openmpi/ompi/mpi/f90/xml/common-C.xsl
Rainer Keller 8e1b23779f - Replace combinations of
#if defined (c_plusplus)
          defined (__cplusplus)
   followed by
      extern "C" {
   and the closing counterpart by BEGIN_C_DECLS and END_C_DECLS.

   Notable exceptions are:
    - opal/include/opal_config_bottom.h:
      This is our generated code, that itself defines BEGIN_C_DECL and
      END_C_DECL
    - ompi/mpi/cxx/mpicxx.h:
      Here we do not include opal_config_bottom.h:                                 
    - Belongs to external code:                                                    
      opal/mca/backtrace/darwin/MoreBacktrace/MoreDebugging/MoreBacktrace.c        
      opal/mca/backtrace/darwin/MoreBacktrace/MoreDebugging/MoreBacktrace.h        
    - opal/include/opal/prefetch.h:
      Has C++ specific macros that are protected:                                  

    - Had #if ... } #endif  _and_ END_C_DECLS (aka end up with 2x
      END_C_DECLS)
      ompi/mca/btl/openib/btl_openib.h
    - opal/event/event.h has #ifdef __cplusplus as BEGIN_C_DECLS...
    - opal/win32/ompi_process.h: had extern "C"\n {...
      opal/win32/ompi_process.h: dito
    - ompi/mca/btl/pcie/btl_pcie_lex.l: needed to add *_C_DECLS
      ompi/mpi/f90/test/align_c.c: dito
    - ompi/debuggers/msgq_interface.h: used #ifdef __cplusplus
    - ompi/mpi/f90/xml/common-C.xsl: Amend

   Tested on linux using --with-openib and --with-mx

   The following do not contain either opal_config.h, orte_config.h or
   ompi_config.h
   (but possibly other header files, that include one of the above):
      ompi/mca/bml/r2/bml_r2_ft.h
      ompi/mca/btl/gm/btl_gm_endpoint.h
      ompi/mca/btl/gm/btl_gm_proc.h
      ompi/mca/btl/mx/btl_mx_endpoint.h
      ompi/mca/btl/ofud/btl_ofud_endpoint.h
      ompi/mca/btl/ofud/btl_ofud_frag.h
      ompi/mca/btl/ofud/btl_ofud_proc.h
      ompi/mca/btl/openib/btl_openib_mca.h
      ompi/mca/btl/portals/btl_portals_endpoint.h
      ompi/mca/btl/portals/btl_portals_frag.h
      ompi/mca/btl/sctp/btl_sctp_endpoint.h
      ompi/mca/btl/sctp/btl_sctp_proc.h
      ompi/mca/btl/tcp/btl_tcp_endpoint.h
      ompi/mca/btl/tcp/btl_tcp_ft.h
      ompi/mca/btl/tcp/btl_tcp_proc.h
      ompi/mca/btl/template/btl_template_endpoint.h
      ompi/mca/btl/template/btl_template_proc.h
      ompi/mca/btl/udapl/btl_udapl_eager_rdma.h
      ompi/mca/btl/udapl/btl_udapl_endpoint.h
      ompi/mca/btl/udapl/btl_udapl_mca.h
      ompi/mca/btl/udapl/btl_udapl_proc.h
      ompi/mca/mtl/mx/mtl_mx_endpoint.h
      ompi/mca/mtl/mx/mtl_mx.h
      ompi/mca/mtl/psm/mtl_psm_endpoint.h
      ompi/mca/mtl/psm/mtl_psm.h
      ompi/mca/pml/cm/pml_cm_component.h
      ompi/mca/pml/csum/pml_csum_comm.h
      ompi/mca/pml/dr/pml_dr_comm.h
      ompi/mca/pml/dr/pml_dr_component.h
      ompi/mca/pml/dr/pml_dr_endpoint.h
      ompi/mca/pml/dr/pml_dr_recvfrag.h
      ompi/mca/pml/example/pml_example.h
      ompi/mca/pml/ob1/pml_ob1_comm.h
      ompi/mca/pml/ob1/pml_ob1_component.h
      ompi/mca/pml/ob1/pml_ob1_endpoint.h
      ompi/mca/pml/ob1/pml_ob1_rdmafrag.h
      ompi/mca/pml/ob1/pml_ob1_recvfrag.h
      ompi/mca/pml/v/pml_v_output.h
      opal/include/opal/prefetch.h
      opal/mca/timer/aix/timer_aix.h
      opal/util/qsort.h
      test/support/components.h

This commit was SVN r21855.

The following SVN revision numbers were found above:
  r2 --> open-mpi/ompi@58fdc18855
2009-08-20 11:42:18 +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>#if defined(c_plusplus) || defined(__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>#if defined(c_plusplus) || defined(__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>