"platforms/common/vscode:/vscode.git/clone" did not exist on "0ad623417f701ddffd7d6b92ab94c26d9ba2310c"
Commit a6370f58 authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Adding wrappers

parent 1877eb67
#set(GCCXML_EXTRA_ARGS "" CACHE STRING "Additional arguments to gccxml, such as '--gccxml-compiler;msvc8'")
#SET(GCCXML_ARGS) # start empty
#FOREACH(subdir ${API_INCLUDE_DIRS})
# SET(GCCXML_ARGS ${GCCXML_ARGS} -I${subdir})
#ENDFOREACH(subdir)
#SET(GCCXML_ARGS ${GCCXML_ARGS} ${GCCXML_EXTRA_ARGS})
SET(SAXON_JAR ${CMAKE_SOURCE_DIR}/wrappers/saxonb9-1-0-7j/saxon9.jar)
# OpenMMAmoeba
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMApi.xml COMMAND ${GCCXML_PATH} ${GCCXML_ARGS} -I${CMAKE_SOURCE_DIR}/openmmapi/include -I${CMAKE_SOURCE_DIR}/olla/include ${CMAKE_SOURCE_DIR}/plugins/amoeba/openmmapi/include/OpenMMAmoeba.h -fxml=AmoebaOpenMMApi.xml)
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMCWrapper.h COMMAND ${JAVA_RUNTIME} -jar ${SAXON_JAR} -t -s:AmoebaOpenMMApi.xml
-xsl:${CMAKE_SOURCE_DIR}/plugins/amoeba/wrappers/CWrapper_Header.xslt -o:AmoebaOpenMMCWrapper.h DEPENDS AmoebaOpenMMApi.xml)
#
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMCWrapper.cpp COMMAND ${JAVA_RUNTIME} -jar ${SAXON_JAR} -t -s:AmoebaOpenMMApi.xml
-xsl:${CMAKE_SOURCE_DIR}/plugins/amoeba/wrappers/CWrapper_Source.xslt -o:AmoebaOpenMMCWrapper.cpp DEPENDS AmoebaOpenMMApi.xml)
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMFortranModule.f90 COMMAND ${JAVA_RUNTIME} -jar ${SAXON_JAR} -t -s:AmoebaOpenMMApi.xml
-xsl:${CMAKE_SOURCE_DIR}/plugins/amoeba/wrappers/FortranWrapper_Header.xslt -o:AmoebaOpenMMFortranModule.f90 DEPENDS AmoebaOpenMMApi.xml ${CMAKE_SOURCE_DIR}/plugins/amoeba/wrappers/FortranWrapper_Header.xslt)
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMFortranWrapper.cpp COMMAND ${JAVA_RUNTIME} -jar ${SAXON_JAR} -t -s:AmoebaOpenMMApi.xml
-xsl:${CMAKE_SOURCE_DIR}/plugins/amoeba/wrappers/FortranWrapper_Source.xslt -o:AmoebaOpenMMFortranWrapper.cpp DEPENDS AmoebaOpenMMApi.xml)
ADD_CUSTOM_TARGET(AmoebaApiWrappers DEPENDS AmoebaOpenMMCWrapper.h AmoebaOpenMMCWrapper.cpp AmoebaOpenMMFortranModule.f90 AmoebaOpenMMFortranWrapper.cpp)
INSTALL_FILES(/include FILES AmoebaOpenMMCWrapper.h AmoebaOpenMMFortranModule.f90 )
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes"/>
<xsl:variable name="std_namespace_id" select="/GCC_XML/Namespace[@name='std']/@id"/>
<xsl:variable name="openmm_namespace_id" select="/GCC_XML/Namespace[@name='OpenMM']/@id"/>
<xsl:variable name="bool_type_id" select="/GCC_XML/FundamentalType[@name='bool']/@id"/>
<xsl:variable name="double_type_id" select="/GCC_XML/FundamentalType[@name='double']/@id"/>
<xsl:variable name="string_type_id" select="/GCC_XML/*[@name='string' and @context=$std_namespace_id]/@id"/>
<xsl:variable name="const_string_type_id" select="/GCC_XML/CvQualifiedType[@type=$string_type_id]/@id"/>
<xsl:variable name="const_ref_string_type_id" select="/GCC_XML/ReferenceType[@type=$const_string_type_id]/@id"/>
<xsl:variable name="vector_string_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::basic_string')]/@id"/>
<xsl:variable name="vector_vec3_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;OpenMM::Vec3')]/@id"/>
<xsl:variable name="vector_bond_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::pair&lt;int, int')]/@id"/>
<xsl:variable name="vector_2d_int_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::vector&lt;int')]/@id"/>
<xsl:variable name="map_parameter_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and contains(@name, 'double')]/@id"/>
<xsl:variable name="map_property_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and not(contains(@name, 'double'))]/@id"/>
<xsl:variable name="vector_double_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;double')]/@id"/>
<xsl:variable name="vector_int_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;int')]/@id"/>
<xsl:variable name="vector_tortor_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::vector&lt;std::vector&lt;double')]/@id"/>
<!-- Do not generate functions for the following classes -->
<xsl:variable name="skip_classes" select="('Vec3', 'Kernel', 'Stream', 'KernelImpl', 'StreamImpl', 'KernelFactory', 'StreamFactory', 'ContextImpl', 'OpenMMException', 'Force', 'ForceImpl')"/>
<!-- Do not generate the following functions -->
<xsl:variable name="skip_methods" select="('OpenMM_Context_getState', 'OpenMM_Platform_loadPluginsFromDirectory')"/>
<!-- Suppress any function which references any of the following classes -->
<xsl:variable name="hide_classes" select="('Kernel', 'Stream', 'KernelImpl', 'StreamImpl', 'KernelFactory', 'StreamFactory', 'ContextImpl')"/>
<!-- Main loop over all classes in the OpenMM namespace -->
<xsl:template match="/GCC_XML">
#ifndef AMOEBA_OPENMM_CWRAPPER_H_
#define AMOEBA_OPENMM_CWRAPPER_H_
#ifndef OPENMM_EXPORT
#define OPENMM_EXPORT
#endif
/* Global Constants */
<xsl:for-each select="Variable[@context=$openmm_namespace_id]">
static <xsl:call-template name="wrap_type"><xsl:with-param name="type_id" select="@type"/></xsl:call-template><xsl:value-of select="concat(' OpenMM_', @name, ' = ', number(@init), ';')"/>
</xsl:for-each>
/* Type Declarations */
<xsl:for-each select="(Class | Struct)[@context=$openmm_namespace_id and empty(index-of($skip_classes, @name))]">
typedef struct OpenMM_<xsl:value-of select="concat(@name, '_struct OpenMM_', @name, ';')"/>
</xsl:for-each>
typedef struct OpenMM_IntArray_struct OpenMM_IntArray;
typedef struct OpenMM_2D_IntArray_struct OpenMM_2D_IntArray;
typedef struct OpenMM_3D_DoubleArray_struct OpenMM_3D_DoubleArray;
#if defined(__cplusplus)
extern "C" {
#endif
/* OpenMM_3D_DoubleArray */
OPENMM_EXPORT OpenMM_3D_DoubleArray* OpenMM_3D_DoubleArray_create(int size1, int size2, int size3);
OPENMM_EXPORT void OpenMM_3D_DoubleArray_set(OpenMM_3D_DoubleArray* array, int index1, int index2, OpenMM_DoubleArray* values);
OPENMM_EXPORT void OpenMM_3D_DoubleArray_destroy( OpenMM_3D_DoubleArray* array);
<xsl:call-template name="primitive_array">
<xsl:with-param name="element_type" select="'int'"/>
<xsl:with-param name="name" select="'OpenMM_IntArray'"/>
</xsl:call-template>
<!-- Class members -->
<xsl:for-each select="Class[@context=$openmm_namespace_id and empty(index-of($skip_classes, @name))]">
<xsl:call-template name="class"/>
</xsl:for-each>
#if defined(__cplusplus)
}
#endif
#endif /*AMOEBA_OPENMM_CWRAPPER_H_*/
</xsl:template>
<!-- Print out the declarations for a (Primitive)Array type -->
<xsl:template name="primitive_array">
<xsl:param name="element_type"/>
<xsl:param name="name"/>
/* <xsl:value-of select="$name"/> */
extern OPENMM_EXPORT <xsl:value-of select="$name"/>* <xsl:value-of select="$name"/>_create(int size);
extern OPENMM_EXPORT void <xsl:value-of select="$name"/>_destroy(<xsl:value-of select="$name"/>* array);
extern OPENMM_EXPORT int <xsl:value-of select="$name"/>_getSize(const <xsl:value-of select="$name"/>* array);
extern OPENMM_EXPORT void <xsl:value-of select="$name"/>_resize(<xsl:value-of select="$name"/>* array, int size);
extern OPENMM_EXPORT void <xsl:value-of select="$name"/>_append(<xsl:value-of select="$name"/>* array, <xsl:value-of select="$element_type"/> value);
extern OPENMM_EXPORT void <xsl:value-of select="$name"/>_set(<xsl:value-of select="$name"/>* array, int index, <xsl:value-of select="$element_type"/> value);
extern OPENMM_EXPORT <xsl:value-of select="concat($element_type, ' ', $name)"/>_get(const <xsl:value-of select="$name"/>* array, int index);
</xsl:template>
<!-- Print out information for a class -->
<xsl:template name="class">
<xsl:variable name="class_name" select="@name"/>
<xsl:variable name="class_id" select="@id"/>
/* OpenMM::<xsl:value-of select="concat(@name, '*/')"/>
<!-- Enumerations -->
<xsl:for-each select="/GCC_XML/Enumeration[@context=$class_id and @access='public']">
<xsl:call-template name="enumeration">
<xsl:with-param name="class_name" select="$class_name"/>
</xsl:call-template>
</xsl:for-each>
<!-- Constructors and destructor -->
<xsl:if test="not(@abstract=1)">
<xsl:variable name="constructors" select="/GCC_XML/Constructor[@context=$class_id and @access='public' and not(@artificial='1')]"/>
<xsl:for-each select="$constructors">
<xsl:call-template name="constructor">
<xsl:with-param name="suffix" select="if (position() > 1) then concat('_', position()) else ''"/>
</xsl:call-template>
</xsl:for-each>
</xsl:if>
extern OPENMM_EXPORT void OpenMM_<xsl:value-of select="concat(@name, '_destroy(OpenMM_', @name, '* target);')"/>
<!-- Methods -->
<xsl:variable name="methods" select="/GCC_XML/Method[@context=$class_id and @access='public']"/>
<xsl:for-each select="$methods">
<xsl:variable name="node" select="."/>
<!-- The next line is to deal with overloaded methods that have a const and a non-const version. -->
<xsl:if test="not(@const=1) or empty($methods[@name=$node/@name and not(@const=1)])">
<xsl:variable name="hide">
<xsl:call-template name="should_hide"/>
</xsl:variable>
<xsl:if test="string-length($hide)=0">
<xsl:call-template name="method">
<xsl:with-param name="class_name" select="$class_name"/>
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>
<!-- Print out the declaration for an enumeration -->
<xsl:template name="enumeration">
<xsl:param name="class_name"/>
typedef enum {
<xsl:for-each select="EnumValue">
<xsl:value-of select="concat('OpenMM_', $class_name, '_', @name, ' = ', @init)"/>
<xsl:if test="position() &lt; last()">, </xsl:if>
</xsl:for-each>
} OpenMM_<xsl:value-of select="concat($class_name, '_', @name, ';')"/>
</xsl:template>
<!-- Print out the declaration for a constructor -->
<xsl:template name="constructor">
<xsl:param name="suffix"/>
extern OPENMM_EXPORT OpenMM_<xsl:value-of select="concat(@name, '* OpenMM_', @name, '_create', $suffix, '(')"/>
<xsl:for-each select="Argument">
<xsl:if test="position() > 1">, </xsl:if>
<xsl:call-template name="wrap_type"><xsl:with-param name="type_id" select="@type"/></xsl:call-template>
<xsl:value-of select="concat(' ', @name)"/>
</xsl:for-each>
<xsl:value-of select="');'"/>
</xsl:template>
<!-- Print out the declaration for a method -->
<xsl:template name="method">
<xsl:param name="class_name"/>
extern OPENMM_EXPORT <xsl:call-template name="wrap_type"><xsl:with-param name="type_id" select="@returns"/></xsl:call-template><xsl:value-of select="concat(' OpenMM_', $class_name, '_', @name, '(')"/>
<xsl:if test="not(@static='1')">
<xsl:if test="@const='1'">
<xsl:value-of select="'const '"/>
</xsl:if>
<xsl:value-of select="concat('OpenMM_', $class_name, '* target')"/>
</xsl:if>
<xsl:variable name="static" select="@static"/>
<xsl:for-each select="Argument">
<xsl:if test="position() > 1 or not($static='1')">, </xsl:if>
<xsl:call-template name="wrap_type"><xsl:with-param name="type_id" select="@type"/></xsl:call-template>
<xsl:value-of select="concat(' ', @name)"/>
</xsl:for-each>
<xsl:value-of select="');'"/>
</xsl:template>
<!-- Print out the description of a type in the wrapper API -->
<xsl:template name="wrap_type">
<xsl:param name="type_id"/>
<xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:choose>
<xsl:when test="$type_id=$bool_type_id">
<xsl:value-of select="'OpenMM_Boolean'"/>
</xsl:when>
<xsl:when test="$type_id=$string_type_id">
<xsl:value-of select="'char*'"/>
</xsl:when>
<xsl:when test="$type_id=$const_ref_string_type_id">
<xsl:value-of select="'const char*'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_string_type_id">
<xsl:value-of select="'OpenMM_StringArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_vec3_type_id">
<xsl:value-of select="'OpenMM_Vec3Array'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_tortor_type_id">
<xsl:value-of select="'OpenMM_3D_DoubleArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_bond_type_id">
<xsl:value-of select="'OpenMM_BondArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_2d_int_type_id">
<xsl:value-of select="'OpenMM_2D_IntArray'"/>
</xsl:when>
<xsl:when test="$type_id=$map_parameter_type_id">
<xsl:value-of select="'OpenMM_ParameterArray'"/>
</xsl:when>
<xsl:when test="$type_id=$map_property_type_id">
<xsl:value-of select="'OpenMM_PropertyArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_double_type_id">
<xsl:value-of select="'OpenMM_DoubleArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_int_type_id">
<xsl:value-of select="'OpenMM_IntArray'"/>
</xsl:when>
<xsl:when test="local-name($node)='ReferenceType' or local-name($node)='PointerType'">
<xsl:call-template name="wrap_type">
<xsl:with-param name="type_id" select="$node/@type"/>
</xsl:call-template>
<xsl:value-of select="'*'"/>
</xsl:when>
<xsl:when test="local-name($node)='CvQualifiedType'">
<xsl:if test="$node/@const=1">
<xsl:value-of select="'const '"/>
</xsl:if>
<xsl:call-template name="wrap_type">
<xsl:with-param name="type_id" select="$node/@type"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="local-name($node)='Enumeration'">
<xsl:variable name="class_name" select="/GCC_XML/Class[@id=$node/@context]/@name"/>
<xsl:value-of select="concat('OpenMM_', $class_name, '_', $node/@name)"/>
</xsl:when>
<xsl:when test="$node/@context=$openmm_namespace_id">
<xsl:value-of select="concat('OpenMM_', $node/@name)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$node/@name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Determine whether a method should be hidden -->
<xsl:template name="should_hide">
<xsl:variable name="class_id" select="@context"/>
<xsl:variable name="method_name" select="concat('OpenMM_', /GCC_XML/Class[@id=$class_id]/@name, '_', @name)"/>
<xsl:if test="not(empty(index-of($skip_methods, $method_name)))">1</xsl:if>
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="@returns"/>
</xsl:call-template>
<xsl:for-each select="Argument">
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="@type"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<!-- This is called by should_hide. It generates output if the specified type should be hidden. -->
<xsl:template name="hide_type">
<xsl:param name="type_id"/>
<xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:choose>
<xsl:when test="local-name($node)='ReferenceType' or local-name($node)='PointerType' or local-name($node)='CvQualifiedType'">
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="$node/@type"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="local-name($node)='Enumeration'">
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="$node/@context"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$node/@context=$openmm_namespace_id and not(empty(index-of($hide_classes, $node/@name)))">
<xsl:value-of select="1"/>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes"/>
<xsl:variable name="std_namespace_id" select="/GCC_XML/Namespace[@name='std']/@id"/>
<xsl:variable name="openmm_namespace_id" select="/GCC_XML/Namespace[@name='OpenMM']/@id"/>
<xsl:variable name="void_type_id" select="/GCC_XML/FundamentalType[@name='void']/@id"/>
<xsl:variable name="bool_type_id" select="/GCC_XML/FundamentalType[@name='bool']/@id"/>
<xsl:variable name="double_type_id" select="/GCC_XML/FundamentalType[@name='double']/@id"/>
<xsl:variable name="string_type_id" select="/GCC_XML/*[@name='string' and @context=$std_namespace_id]/@id"/>
<xsl:variable name="const_string_type_id" select="/GCC_XML/CvQualifiedType[@type=$string_type_id]/@id"/>
<xsl:variable name="const_ref_string_type_id" select="/GCC_XML/ReferenceType[@type=$const_string_type_id]/@id"/>
<xsl:variable name="vec3_type_id" select="/GCC_XML/Class[@name='Vec3' and @context=$openmm_namespace_id]/@id"/>
<xsl:variable name="vector_string_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::basic_string')]/@id"/>
<xsl:variable name="vector_vec3_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;OpenMM::Vec3')]/@id"/>
<xsl:variable name="vector_bond_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::pair&lt;int, int')]/@id"/>
<xsl:variable name="vector_2d_int_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::vector&lt;int')]/@id"/>
<xsl:variable name="map_parameter_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and contains(@name, 'double')]/@id"/>
<xsl:variable name="map_property_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and not(contains(@name, 'double'))]/@id"/>
<xsl:variable name="vector_double_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;double')]/@id"/>
<xsl:variable name="vector_int_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;int')]/@id"/>
<xsl:variable name="vector_tortor_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::vector&lt;std::vector&lt;double')]/@id"/>
<xsl:variable name="newline">
<xsl:text>
</xsl:text>
</xsl:variable>
<!-- Do not generate functions for the following classes -->
<xsl:variable name="skip_classes" select="('Vec3', 'Kernel', 'Stream', 'KernelImpl', 'StreamImpl', 'KernelFactory', 'StreamFactory')"/>
<!-- Do not generate the following functions -->
<xsl:variable name="skip_methods" select="('OpenMM_Context_getState', 'OpenMM_Platform_loadPluginsFromDirectory')"/>
<!-- Suppress any function which references any of the following classes -->
<xsl:variable name="hide_classes" select="('Kernel', 'Stream', 'KernelImpl', 'StreamImpl', 'KernelFactory', 'StreamFactory', 'ContextImpl')"/>
<!-- Main loop over all classes in the OpenMM namespace -->
<xsl:template match="/GCC_XML">
#include "OpenMM.h"
#include "OpenMMAmoeba.h"
#include "../../../wrappers/OpenMMCWrapper.h"
#include "AmoebaOpenMMCWrapper.h"
#include &lt;cstring&gt;
#include &lt;vector&gt;
using namespace OpenMM;
using namespace std;
extern "C" {
/* OpenMM_2D_IntArray */
OPENMM_EXPORT OpenMM_2D_IntArray* OpenMM_2D_IntArray_create(int size) {
return reinterpret_cast&lt;OpenMM_2D_IntArray*&gt;(new vector&lt;vector&lt;int&gt; &gt;(size));
}
OPENMM_EXPORT void OpenMM_2D_IntArray_destroy(OpenMM_2D_IntArray* array) {
delete reinterpret_cast&lt;vector&lt;vector&lt;int&gt; &gt;*&gt;(array);
}
OPENMM_EXPORT int OpenMM_2D_IntArray_getSize(const OpenMM_2D_IntArray* array) {
return reinterpret_cast&lt;const vector&lt;vector&lt;int&gt; &gt;*&gt;(array)->size();
}
OPENMM_EXPORT void OpenMM_2D_IntArray_resize(OpenMM_2D_IntArray* array, int size) {
reinterpret_cast&lt;vector&lt;vector&lt;int&gt; &gt;*&gt;(array)->resize(size);
}
OPENMM_EXPORT void OpenMM_2D_IntArray_append(OpenMM_2D_IntArray* array, int index1, int value ) {
vector&lt;vector&lt;int&gt; &gt;* array2DInt = reinterpret_cast&lt;vector&lt;vector&lt;int&gt; &gt;*&gt;(array);
if( array2DInt->size() &lt;= index1 ){
array2DInt->resize( index1+1 );
}
(*array2DInt)[index1].push_back( value );
}
OPENMM_EXPORT void OpenMM_2D_IntArray_set(OpenMM_2D_IntArray* array, int index1, int index2, int value) {
vector&lt;vector&lt;int&gt; &gt;* array2DInt = reinterpret_cast&lt;vector&lt;vector&lt;int&gt; &gt;*&gt;(array);
if( array2DInt->size() &lt;= index1 ){
array2DInt->resize( index1+1 );
}
if( array2DInt[index1].size() &lt;= index2 ){
array2DInt[index1].resize( index2+1 );
}
(*array2DInt)[index1][index2] = value;
}
OPENMM_EXPORT void OpenMM_2D_IntArray_get(const OpenMM_2D_IntArray* array, int index1, int index2, int* value) {
const vector&lt;vector&lt;int&gt; &gt;* array2DInt = reinterpret_cast&lt;const vector&lt;vector&lt;int&gt; &gt;*&gt;(array);
if ( array2DInt->size() &lt;= index1 )
throw OpenMMException("OpenMM_2D_IntArray_get: first index out of range.");
if ( (*array2DInt)[index1].size() &lt;= index2 )
throw OpenMMException("OpenMM_2D_IntArray_get: second index out of range.");
*value = (*array2DInt)[index1][index2];
}
/* OpenMM_3D_DoubleArray */
OPENMM_EXPORT OpenMM_3D_DoubleArray* OpenMM_3D_DoubleArray_create(int size1, int size2, int size3) {
int ii, jj;
std::vector&lt; std::vector&lt; std::vector&lt;double&gt; &gt; &gt;* v3D_Array = new std::vector&lt;std::vector&lt;std::vector&lt;double&gt; &gt; &gt;(size1);
for( ii = 0; ii &lt; size1; ii++ ){
(*v3D_Array)[ii].resize(size2);
for( jj = 0; jj &lt; size2; jj++ ){
(*v3D_Array)[ii][jj].resize(size3);
}
}
return reinterpret_cast&lt;OpenMM_3D_DoubleArray*&gt;(v3D_Array);
}
OPENMM_EXPORT void OpenMM_3D_DoubleArray_set(OpenMM_3D_DoubleArray* array, int index1, int index2, OpenMM_DoubleArray* values) {
unsigned int ii;
std::vector&lt; std::vector&lt; std::vector&lt;double&gt; &gt; &gt;* v3D_Array = reinterpret_cast&lt;std::vector&lt;std::vector&lt;std::vector&lt;double&gt; &gt; &gt;*&gt;(array);
std::vector&lt;double&gt; * value_array = reinterpret_cast&lt;std::vector&lt;double&gt; *&gt;(values);
for( ii = 0; ii &lt; (*value_array).size(); ii++ ){
(*v3D_Array)[index1][index2][ii] = (*value_array)[ii];
}
}
OPENMM_EXPORT void OpenMM_3D_DoubleArray_destroy( OpenMM_3D_DoubleArray* array) {
delete reinterpret_cast&lt;std::vector&lt;std::vector&lt;std::vector&lt;double&gt; &gt; &gt;*&gt;(array);
}
<xsl:call-template name="primitive_array">
<xsl:with-param name="element_type" select="'int'"/>
<xsl:with-param name="name" select="'OpenMM_IntArray'"/>
</xsl:call-template>
<!-- Class members -->
<xsl:for-each select="Class[@context=$openmm_namespace_id and empty(index-of($skip_classes, @name))]">
<xsl:call-template name="class"/>
</xsl:for-each>
}
</xsl:template>
<!-- Print out the definitions for a (Primitive)Array type -->
<xsl:template name="primitive_array">
<xsl:param name="element_type"/>
<xsl:param name="name"/>
/* <xsl:value-of select="$name"/> */
OPENMM_EXPORT <xsl:value-of select="$name"/>* <xsl:value-of select="$name"/>_create(int size) {
return reinterpret_cast&lt;<xsl:value-of select="$name"/>*&gt;(new vector&lt;<xsl:value-of select="$element_type"/>&gt;(size));
}
OPENMM_EXPORT void <xsl:value-of select="$name"/>_destroy(<xsl:value-of select="$name"/>* array) {
delete reinterpret_cast&lt;vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array);
}
OPENMM_EXPORT int <xsl:value-of select="$name"/>_getSize(const <xsl:value-of select="$name"/>* array) {
return reinterpret_cast&lt;const vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array)->size();
}
OPENMM_EXPORT void <xsl:value-of select="$name"/>_resize(<xsl:value-of select="$name"/>* array, int size) {
reinterpret_cast&lt;vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array)->resize(size);
}
OPENMM_EXPORT void <xsl:value-of select="$name"/>_append(<xsl:value-of select="$name"/>* array, <xsl:value-of select="$element_type"/> value) {
reinterpret_cast&lt;vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array)->push_back(value);
}
OPENMM_EXPORT void <xsl:value-of select="$name"/>_set(<xsl:value-of select="$name"/>* array, int index, <xsl:value-of select="$element_type"/> value) {
(*reinterpret_cast&lt;vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array))[index] = value;
}
OPENMM_EXPORT <info xml:space="preserve"> <xsl:value-of select="$element_type"/> <xsl:value-of select="$name"/>_get(const <xsl:value-of select="$name"/>* array, int index) {
return (*reinterpret_cast&lt;const vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array))[index];
}
</info>
</xsl:template>
<!-- Print out information for a class -->
<xsl:template name="class">
<xsl:variable name="class_name" select="@name"/>
<xsl:variable name="class_id" select="@id"/>
/* OpenMM::<xsl:value-of select="concat(@name, '*/')"/>
<!-- Constructors and destructor -->
<xsl:if test="not(@abstract=1)">
<xsl:variable name="constructors" select="/GCC_XML/Constructor[@context=$class_id and @access='public' and not(@artificial='1')]"/>
<xsl:for-each select="$constructors">
<xsl:call-template name="constructor">
<xsl:with-param name="suffix" select="if (position() > 1) then concat('_', position()) else ''"/>
</xsl:call-template>
</xsl:for-each>
</xsl:if>
OPENMM_EXPORT void OpenMM_<xsl:value-of select="concat(@name, '_destroy(OpenMM_', @name, '* target) {')"/>
delete reinterpret_cast&lt;<xsl:value-of select="@name"/>*&gt;(target);
}
<!-- Methods -->
<xsl:variable name="methods" select="/GCC_XML/Method[@context=$class_id and @access='public']"/>
<xsl:for-each select="$methods">
<xsl:variable name="node" select="."/>
<!-- The next line is to deal with overloaded methods that have a const and a non-const version. -->
<xsl:if test="not(@const=1) or empty($methods[@name=$node/@name and not(@const=1)])">
<xsl:variable name="hide">
<xsl:call-template name="should_hide"/>
</xsl:variable>
<xsl:if test="string-length($hide)=0">
<xsl:call-template name="method">
<xsl:with-param name="class_name" select="$class_name"/>
<xsl:with-param name="class_id" select="$class_id"/>
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>
<!-- Print out the definition of a constructor -->
<xsl:template name="constructor">
<xsl:param name="suffix"/>
OPENMM_EXPORT OpenMM_<xsl:value-of select="concat(@name, '* OpenMM_', @name, '_create', $suffix, '(')"/>
<xsl:for-each select="Argument">
<xsl:if test="position() > 1">, </xsl:if>
<xsl:call-template name="wrap_type"><xsl:with-param name="type_id" select="@type"/></xsl:call-template>
<xsl:value-of select="concat(' ', @name)"/>
</xsl:for-each>
<xsl:value-of select="') {'"/>
return reinterpret_cast&lt;OpenMM_<xsl:value-of select="@name"/>*&gt;(new <xsl:value-of select="concat(@name, '(')"/>
<xsl:for-each select="Argument">
<xsl:if test="position() > 1">, </xsl:if>
<xsl:call-template name="unwrap_value">
<xsl:with-param name="value" select="@name"/>
<xsl:with-param name="type_id" select="@type"/>
</xsl:call-template>
</xsl:for-each>
<xsl:value-of select="'));'"/>
}
</xsl:template>
<!-- Print out the definition of a method -->
<xsl:template name="method">
<xsl:param name="class_name"/>
<xsl:param name="class_id"/>
<!-- First the method signature -->
<xsl:value-of select="$newline"/>
OPENMM_EXPORT <xsl:call-template name="wrap_type"><xsl:with-param name="type_id" select="@returns"/></xsl:call-template><xsl:value-of select="concat(' OpenMM_', $class_name, '_', @name, '(')"/>
<xsl:if test="not(@static='1')">
<xsl:if test="@const='1'">
<xsl:value-of select="'const '"/>
</xsl:if>
<xsl:value-of select="concat('OpenMM_', $class_name, '* target')"/>
</xsl:if>
<!-- Generate the list of arguments -->
<xsl:variable name="method" select="."/>
<xsl:for-each select="Argument">
<xsl:if test="position() > 1 or not($method/@static='1')">, </xsl:if>
<xsl:call-template name="wrap_type"><xsl:with-param name="type_id" select="@type"/></xsl:call-template>
<xsl:value-of select="concat(' ', @name)"/>
</xsl:for-each>
<xsl:value-of select="concat(') {', $newline, ' ')"/>
<!-- Now the method body -->
<xsl:if test="not(@returns=$void_type_id)">
<xsl:call-template name="unwrap_type"><xsl:with-param name="type_id" select="@returns"/></xsl:call-template>
<xsl:value-of select="' result = '"/>
</xsl:if>
<xsl:variable name="return_type" select="/GCC_XML/*[@id=$method/@returns]"/>
<xsl:if test="local-name($return_type)='ReferenceType'">
<xsl:value-of select="'&amp;'"/>
</xsl:if>
<xsl:choose>
<xsl:when test="@static='1'">
<!-- Invoke the method on the class -->
<xsl:value-of select="concat($class_name, '::')"/>
</xsl:when>
<xsl:otherwise>
<!-- Invoke the method on the target object -->
<xsl:value-of select="'reinterpret_cast&lt;'"/>
<xsl:if test="@const='1'">
<xsl:value-of select="'const '"/>
</xsl:if>
<xsl:value-of select="concat($class_name, '*&gt;(target)->')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="concat(@name, '(')"/>
<xsl:for-each select="Argument">
<xsl:if test="position() > 1">, </xsl:if>
<xsl:call-template name="unwrap_value">
<xsl:with-param name="value" select="@name"/>
<xsl:with-param name="type_id" select="@type"/>
</xsl:call-template>
</xsl:for-each>
<xsl:value-of select="');'"/>
<xsl:if test="not(@returns=$void_type_id)">
<xsl:value-of select="concat($newline, ' return ')"/>
<xsl:call-template name="wrap_value"><xsl:with-param name="value" select="'result'"/><xsl:with-param name="type_id" select="@returns"/></xsl:call-template>
<xsl:value-of select="';'"/>
</xsl:if>
};
</xsl:template>
<!-- Print out the description of a type in the wrapper API -->
<xsl:template name="wrap_type">
<xsl:param name="type_id"/>
<xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:choose>
<xsl:when test="$type_id=$bool_type_id">
<xsl:value-of select="'OpenMM_Boolean'"/>
</xsl:when>
<xsl:when test="$type_id=$string_type_id">
<xsl:value-of select="'char*'"/>
</xsl:when>
<xsl:when test="$type_id=$const_ref_string_type_id">
<xsl:value-of select="'const char*'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_string_type_id">
<xsl:value-of select="'OpenMM_StringArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_vec3_type_id">
<xsl:value-of select="'OpenMM_Vec3Array'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_bond_type_id">
<xsl:value-of select="'OpenMM_BondArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_tortor_type_id">
<xsl:value-of select="'OpenMM_3D_DoubleArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_2d_int_type_id">
<xsl:value-of select="'OpenMM_2D_IntArray'"/>
</xsl:when>
<xsl:when test="$type_id=$map_parameter_type_id">
<xsl:value-of select="'OpenMM_ParameterArray'"/>
</xsl:when>
<xsl:when test="$type_id=$map_property_type_id">
<xsl:value-of select="'OpenMM_PropertyArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_double_type_id">
<xsl:value-of select="'OpenMM_DoubleArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_int_type_id">
<xsl:value-of select="'OpenMM_IntArray'"/>
</xsl:when>
<xsl:when test="local-name($node)='ReferenceType' or local-name($node)='PointerType'">
<xsl:call-template name="wrap_type">
<xsl:with-param name="type_id" select="$node/@type"/>
</xsl:call-template>
<xsl:value-of select="'*'"/>
</xsl:when>
<xsl:when test="local-name($node)='CvQualifiedType'">
<xsl:if test="$node/@const=1">
<xsl:value-of select="'const '"/>
</xsl:if>
<xsl:call-template name="wrap_type">
<xsl:with-param name="type_id" select="$node/@type"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="local-name($node)='Enumeration'">
<xsl:variable name="class_name" select="/GCC_XML/Class[@id=$node/@context]/@name"/>
<xsl:value-of select="concat('OpenMM_', $class_name, '_', $node/@name)"/>
</xsl:when>
<xsl:when test="$node/@context=$openmm_namespace_id">
<xsl:value-of select="concat('OpenMM_', $node/@name)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$node/@name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Print out the description of a type in the native API -->
<xsl:template name="unwrap_type">
<xsl:param name="type_id"/>
<xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:choose>
<xsl:when test="$type_id=$vector_string_type_id">
<xsl:value-of select="'vector&lt;string&gt;'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_vec3_type_id">
<xsl:value-of select="'vector&lt;Vec3&gt;'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_bond_type_id">
<xsl:value-of select="'vector&lt;pair&lt;int, int&gt; &gt;'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_2d_int_type_id">
<xsl:value-of select="'vector&lt;vector&lt;int&gt; &gt;'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_tortor_type_id">
<xsl:value-of select="'vector&lt;vector&lt;vector&lt;double&gt; &gt; &gt;'"/>
</xsl:when>
<xsl:when test="$type_id=$map_parameter_type_id">
<xsl:value-of select="'map&lt;string, double&gt;'"/>
</xsl:when>
<xsl:when test="$type_id=$map_property_type_id">
<xsl:value-of select="'map&lt;string, string&gt;'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_double_type_id">
<xsl:value-of select="'vector&lt;double&gt;'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_int_type_id">
<xsl:value-of select="'vector&lt;int&gt;'"/>
</xsl:when>
<xsl:when test="local-name($node)='ReferenceType' or local-name($node)='PointerType'">
<xsl:call-template name="unwrap_type">
<xsl:with-param name="type_id" select="$node/@type"/>
</xsl:call-template>
<xsl:value-of select="'*'"/>
</xsl:when>
<xsl:when test="local-name($node)='CvQualifiedType'">
<xsl:if test="$node/@const=1">
<xsl:value-of select="'const '"/>
</xsl:if>
<xsl:call-template name="unwrap_type">
<xsl:with-param name="type_id" select="$node/@type"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="local-name($node)='Enumeration'">
<xsl:variable name="class_name" select="/GCC_XML/Class[@id=$node/@context]/@name"/>
<xsl:value-of select="concat($class_name, '::', $node/@name)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$node/@name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Print out a value, if necessary casting from a native type to a wrapped type -->
<xsl:template name="wrap_value">
<xsl:param name="value"/>
<xsl:param name="type_id"/>
<xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:choose>
<xsl:when test="$type_id=$bool_type_id">
<xsl:value-of select="concat('(', $value, ' ? OpenMM_True : OpenMM_False)')"/>
</xsl:when>
<xsl:when test="$type_id=$string_type_id">
<xsl:value-of select="concat($value, '.c_str()')"/>
</xsl:when>
<xsl:when test="$type_id=$const_ref_string_type_id">
<xsl:value-of select="concat($value, '->c_str()')"/>
</xsl:when>
<xsl:when test="local-name($node)='FundamentalType'">
<xsl:value-of select="$value"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="local-name($node)='Enumeration'">
<xsl:value-of select="'static_cast&lt;'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'reinterpret_cast&lt;'"/>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="wrap_type">
<xsl:with-param name="type_id" select="$type_id"/>
</xsl:call-template>
<xsl:value-of select="concat('&gt;(', $value, ')')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Print out a value, if necessary casting from a wrapped type to a native type -->
<xsl:template name="unwrap_value">
<xsl:param name="value"/>
<xsl:param name="type_id"/>
<xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:choose>
<xsl:when test="$type_id=$bool_type_id">
<xsl:value-of select="concat('(', $value, ' != OpenMM_False)')"/>
</xsl:when>
<xsl:when test="$type_id=$string_type_id">
<xsl:value-of select="concat('string(', $value, ')')"/>
</xsl:when>
<xsl:when test="$type_id=$const_ref_string_type_id">
<xsl:value-of select="concat('string(', $value, ')')"/>
</xsl:when>
<xsl:when test="local-name($node)='FundamentalType'">
<xsl:value-of select="$value"/>
</xsl:when>
<xsl:when test="$type_id=$vec3_type_id">
<xsl:value-of select="concat('Vec3(', $value, '.x, ', $value, '.y, ', $value, '.z)')"/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="local-name($node)='ReferenceType'"><xsl:value-of select="'*'"/></xsl:if>
<xsl:choose>
<xsl:when test="local-name($node)='Enumeration'">
<xsl:value-of select="'static_cast&lt;'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'reinterpret_cast&lt;'"/>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="unwrap_type">
<xsl:with-param name="type_id" select="$type_id"/>
</xsl:call-template>
<xsl:value-of select="concat(' &gt;(', $value, ')')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Determine whether a method should be hidden -->
<xsl:template name="should_hide">
<xsl:variable name="class_id" select="@context"/>
<xsl:variable name="method_name" select="concat('OpenMM_', /GCC_XML/Class[@id=$class_id]/@name, '_', @name)"/>
<xsl:if test="not(empty(index-of($skip_methods, $method_name)))">1</xsl:if>
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="@returns"/>
</xsl:call-template>
<xsl:for-each select="Argument">
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="@type"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<!-- This is called by should_hide. It generates output if the specified type should be hidden. -->
<xsl:template name="hide_type">
<xsl:param name="type_id"/>
<xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:choose>
<xsl:when test="local-name($node)='ReferenceType' or local-name($node)='PointerType' or local-name($node)='CvQualifiedType'">
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="$node/@type"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="local-name($node)='Enumeration'">
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="$node/@context"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$node/@context=$openmm_namespace_id and not(empty(index-of($hide_classes, $node/@name)))">
<xsl:value-of select="1"/>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes"/>
<xsl:variable name="std_namespace_id" select="/GCC_XML/Namespace[@name='std']/@id"/>
<xsl:variable name="openmm_namespace_id" select="/GCC_XML/Namespace[@name='OpenMM']/@id"/>
<xsl:variable name="void_type_id" select="/GCC_XML/FundamentalType[@name='void']/@id"/>
<xsl:variable name="int_type_id" select="/GCC_XML/FundamentalType[@name='int']/@id"/>
<xsl:variable name="double_type_id" select="/GCC_XML/FundamentalType[@name='double']/@id"/>
<xsl:variable name="bool_type_id" select="/GCC_XML/FundamentalType[@name='bool']/@id"/>
<xsl:variable name="char_type_id" select="/GCC_XML/FundamentalType[@name='char']/@id"/>
<xsl:variable name="string_type_id" select="/GCC_XML/*[@name='string' and @context=$std_namespace_id]/@id"/>
<xsl:variable name="vec3_type_id" select="/GCC_XML/*[@name='Vec3' and @context=$openmm_namespace_id]/@id"/>
<xsl:variable name="const_char_type_id" select="/GCC_XML/CvQualifiedType[@type=$char_type_id]/@id"/>
<xsl:variable name="ptr_const_char_type_id" select="/GCC_XML/PointerType[@type=$const_char_type_id]/@id"/>
<xsl:variable name="vector_string_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::basic_string')]/@id"/>
<xsl:variable name="vector_vec3_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;OpenMM::Vec3')]/@id"/>
<xsl:variable name="vector_bond_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::pair&lt;int, int')]/@id"/>
<xsl:variable name="map_parameter_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and contains(@name, 'double')]/@id"/>
<xsl:variable name="map_property_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and not(contains(@name, 'double'))]/@id"/>
<xsl:variable name="vector_double_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;double')]/@id"/>
<xsl:variable name="vector_int_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;int')]/@id"/>
<xsl:variable name="vector_tortor_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::vector&lt;std::vector&lt;double')]/@id"/>
<xsl:variable name="newline">
<xsl:text>
</xsl:text>
</xsl:variable>
<!-- Do not generate functions for the following classes -->
<xsl:variable name="skip_classes" select="('Vec3', 'Kernel', 'Stream', 'KernelImpl', 'StreamImpl', 'KernelFactory', 'StreamFactory')"/>
<!-- Suppress any function which references any of the following classes -->
<xsl:variable name="hide_classes" select="('Kernel', 'Stream', 'KernelImpl', 'StreamImpl', 'KernelFactory', 'StreamFactory', 'ContextImpl')"/>
<!-- Main loop over all classes in the OpenMM namespace -->
<xsl:template match="/GCC_XML">
MODULE OpenMM_Types
implicit none
! Global Constants
<xsl:for-each select="Variable[@context=$openmm_namespace_id]">
real*8 OpenMM_<xsl:value-of select="@name"/>
</xsl:for-each>
<xsl:for-each select="Variable[@context=$openmm_namespace_id]">
parameter(OpenMM_<xsl:value-of select="concat(@name, '=', number(@init), ')')"/>
</xsl:for-each>
! Type Declarations
<xsl:for-each select="(Class | Struct)[@context=$openmm_namespace_id and empty(index-of($skip_classes, @name))]">
type OpenMM_<xsl:value-of select="@name"/>
integer*8 :: handle = 0
end type
</xsl:for-each>
type OpenMM_Vec3Array
integer*8 :: handle = 0
end type
type OpenMM_StringArray
integer*8 :: handle = 0
end type
type OpenMM_BondArray
integer*8 :: handle = 0
end type
type OpenMM_ParameterArray
integer*8 :: handle = 0
end type
type OpenMM_PropertyArray
integer*8 :: handle = 0
end type
type OpenMM_DoubleArray
integer*8 :: handle = 0
end type
type OpenMM_3D_DoubleArray
integer*8 :: handle = 0
end type
type OpenMM_IntArray
integer*8 :: handle = 0
end type
! Enumerations
integer*4 OpenMM_False
integer*4 OpenMM_True
parameter(OpenMM_False=0)
parameter(OpenMM_True=1)
<xsl:for-each select="Class[@context=$openmm_namespace_id and empty(index-of($skip_classes, @name))]">
<xsl:variable name="class_id" select="@id"/>
<xsl:variable name="class_name" select="@name"/>
<xsl:for-each select="/GCC_XML/Enumeration[@context=$class_id and @access='public']">
<xsl:call-template name="enumeration">
<xsl:with-param name="class_name" select="$class_name"/>
</xsl:call-template>
</xsl:for-each>
</xsl:for-each>
END MODULE OpenMM_Types
MODULE OpenMM
use OpenMM_Types; implicit none
interface
! OpenMM_Vec3
subroutine OpenMM_Vec3_scale(vec, scale, result)
use OpenMM_Types; implicit none
real*8 vec(3)
real*8 scale
real*8 result(3)
end
! OpenMM_Vec3Array
subroutine OpenMM_Vec3Array_create(result, size)
use OpenMM_Types; implicit none
integer*4 size
type (OpenMM_Vec3Array) result
end
subroutine OpenMM_Vec3Array_destroy(destroy)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) destroy
end
function OpenMM_Vec3Array_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) target
integer*4 OpenMM_Vec3Array_getSize
end
subroutine OpenMM_Vec3Array_resize(target, size)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) target
integer*4 size
end
subroutine OpenMM_Vec3Array_append(target, vec)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) target
real*8 vec(3)
end
subroutine OpenMM_Vec3Array_set(target, index, vec)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) target
integer*4 index
real*8 vec(3)
end
subroutine OpenMM_Vec3Array_get(target, index, result)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) target
integer*4 index
real*8 result(3)
end
! OpenMM_StringArray
subroutine OpenMM_StringArray_create(result, size)
use OpenMM_Types; implicit none
integer*4 size
type (OpenMM_StringArray) result
end
subroutine OpenMM_StringArray_destroy(destroy)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) destroy
end
function OpenMM_StringArray_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
integer*4 OpenMM_StringArray_getSize
end
subroutine OpenMM_StringArray_resize(target, size)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
integer*4 size
end
subroutine OpenMM_StringArray_append(target, str)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
character(*) str
end
subroutine OpenMM_StringArray_set(target, index, str)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
integer*4 index
character(*) str
end
subroutine OpenMM_StringArray_get(target, index, result)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
integer*4 index
character(*) result
end
! OpenMM_BondArray
subroutine OpenMM_BondArray_create(result, size)
use OpenMM_Types; implicit none
integer*4 size
type (OpenMM_BondArray) result
end
subroutine OpenMM_BondArray_destroy(destroy)
use OpenMM_Types; implicit none
type (OpenMM_BondArray) destroy
end
function OpenMM_BondArray_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_BondArray) target
integer*4 OpenMM_BondArray_getSize
end
subroutine OpenMM_BondArray_resize(target, size)
use OpenMM_Types; implicit none
type (OpenMM_BondArray) target
integer*4 size
end
subroutine OpenMM_BondArray_append(target, particle1, particle2)
use OpenMM_Types; implicit none
type (OpenMM_BondArray) target
integer*4 particle1
integer*4 particle2
end
subroutine OpenMM_BondArray_set(target, index, particle1, particle2)
use OpenMM_Types; implicit none
type (OpenMM_BondArray) target
integer*4 index
integer*4 particle1
integer*4 particle2
end
subroutine OpenMM_BondArray_get(target, index, particle1, particle2)
use OpenMM_Types; implicit none
type (OpenMM_BondArray) target
integer*4 index
integer*4 particle1
integer*4 particle2
end
! OpenMM_ParameterArray
function OpenMM_ParameterArray_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_ParameterArray) target
integer*4 OpenMM_ParameterArray_getSize
end
subroutine OpenMM_ParameterArray_get(target, name, result)
use OpenMM_Types; implicit none
type (OpenMM_ParameterArray) target
character(*) name
character(*) result
end
! OpenMM_PropertyArray
function OpenMM_PropertyArray_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_ParameterArray) target
integer*4 OpenMM_PropertyArray_getSize
end
subroutine OpenMM_PropertyArray_get(target, name, result)
use OpenMM_Types; implicit none
type (OpenMM_PropertyArray) target
character(*) name
character(*) result
end
<xsl:call-template name="primitive_array">
<xsl:with-param name="element_type" select="'real*8'"/>
<xsl:with-param name="name" select="'OpenMM_DoubleArray'"/>
</xsl:call-template>
<xsl:call-template name="primitive_array">
<xsl:with-param name="element_type" select="'integer'"/>
<xsl:with-param name="name" select="'OpenMM_IntArray'"/>
</xsl:call-template>
<!-- Class members -->
<xsl:for-each select="Class[@context=$openmm_namespace_id and empty(index-of($skip_classes, @name))]">
<xsl:call-template name="class"/>
</xsl:for-each>
end interface
END MODULE OpenMM
</xsl:template>
<!-- Print out the declarations for a (Primitive)Array type -->
<xsl:template name="primitive_array">
<xsl:param name="element_type"/>
<xsl:param name="name"/>
! <xsl:value-of select="$name"/>
subroutine <xsl:value-of select="$name"/>_create(result, size)
use OpenMM_Types; implicit none
integer*4 size
type (<xsl:value-of select="$name"/>) result
end
subroutine <xsl:value-of select="$name"/>_destroy(destroy)
use OpenMM_Types; implicit none
type (<xsl:value-of select="$name"/>) destroy
end
function <xsl:value-of select="$name"/>_getSize(target)
use OpenMM_Types; implicit none
type (<xsl:value-of select="$name"/>) target
integer*4 <xsl:value-of select="$name"/>_getSize
end
subroutine <xsl:value-of select="$name"/>_resize(target, size)
use OpenMM_Types; implicit none
type (<xsl:value-of select="$name"/>) target
integer*4 size
end
subroutine <xsl:value-of select="$name"/>_append(target, value)
use OpenMM_Types; implicit none
type (<xsl:value-of select="$name"/>) target
<xsl:value-of select="$element_type"/> value
end
subroutine <xsl:value-of select="$name"/>_set(target, index, value)
use OpenMM_Types; implicit none
type (<xsl:value-of select="$name"/>) target
integer*4 index
<xsl:value-of select="$element_type"/> value
end
subroutine <xsl:value-of select="$name"/>_get(target, index, result)
use OpenMM_Types; implicit none
type (<xsl:value-of select="$name"/>) target
integer*4 index
<xsl:value-of select="$element_type"/> result
end
</xsl:template>
<!-- Print out information for a class -->
<xsl:template name="class">
<xsl:variable name="class_name" select="@name"/>
<xsl:variable name="class_id" select="@id"/>
! OpenMM::<xsl:value-of select="@name"/>
<!-- Constructors and destructor -->
<xsl:if test="not(@abstract=1)">
<xsl:variable name="constructors" select="/GCC_XML/Constructor[@context=$class_id and @access='public' and not(@artificial='1')]"/>
<xsl:for-each select="$constructors">
<xsl:call-template name="constructor">
<xsl:with-param name="suffix" select="if (position() > 1) then concat('_', position()) else ''"/>
</xsl:call-template>
</xsl:for-each>
<xsl:call-template name="destructor"/>
</xsl:if>
<!-- Methods -->
<xsl:variable name="methods" select="/GCC_XML/Method[@context=$class_id and @access='public']"/>
<xsl:for-each select="$methods">
<xsl:variable name="node" select="."/>
<!-- The next line is to deal with overloaded methods that have a const and a non-const version. -->
<xsl:if test="not(@const=1) or empty($methods[@name=$node/@name and not(@const=1)])">
<xsl:variable name="hide">
<xsl:call-template name="should_hide"/>
</xsl:variable>
<xsl:if test="string-length($hide)=0">
<xsl:call-template name="method">
<xsl:with-param name="class_name" select="$class_name"/>
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>
<!-- Print out the declaration for an enumeration -->
<xsl:template name="enumeration">
<xsl:param name="class_name"/>
<xsl:for-each select="EnumValue">
integer*4 OpenMM_<xsl:value-of select="concat($class_name, '_', @name)"/>
</xsl:for-each>
<xsl:for-each select="EnumValue">
parameter(OpenMM_<xsl:value-of select="concat($class_name, '_', @name, '=', @init, ')')"/>
</xsl:for-each>
<xsl:value-of select="$newline"/>
</xsl:template>
<!-- Print out the declaration for a constructor -->
<xsl:template name="constructor">
<xsl:param name="suffix"/>
subroutine OpenMM_<xsl:value-of select="concat(@name, '_create', $suffix, '(result')"/>
<xsl:for-each select="Argument">
<xsl:value-of select="concat(', ', @name)"/>
</xsl:for-each>
<xsl:value-of select="')'"/>
use OpenMM_Types; implicit none
type (OpenMM_<xsl:value-of select="concat(@name, ') result', $newline)"/>
<xsl:for-each select="Argument">
<xsl:value-of select="' '"/>
<xsl:call-template name="declare_argument">
<xsl:with-param name="type_id" select="@type"/>
<xsl:with-param name="value" select="@name"/>
</xsl:call-template>
<xsl:value-of select="$newline"/>
</xsl:for-each>
<xsl:value-of select="' end'"/>
</xsl:template>
<!-- Print out the declaration for a destructor -->
<xsl:template name="destructor">
subroutine OpenMM_<xsl:value-of select="concat(@name, '_destroy(destroy)')"/>
use OpenMM_Types; implicit none
type (OpenMM_<xsl:value-of select="concat(@name, ') destroy', $newline)"/>
<xsl:value-of select="' end'"/>
</xsl:template>
<!-- Print out the declaration for a method -->
<xsl:template name="method">
<xsl:param name="class_name"/>
<xsl:variable name="has_return" select="@returns=$int_type_id or @returns=$double_type_id"/>
<xsl:variable name="has_return_arg" select="not($has_return or @returns=$void_type_id)"/>
<xsl:variable name="method" select="."/>
<xsl:choose>
<xsl:when test="$has_return">
<xsl:text>
function </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>
subroutine </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="concat('OpenMM_', $class_name, '_', @name, '(')"/>
<xsl:if test="not(@static='1')">
<xsl:value-of select="'target'"/>
</xsl:if>
<xsl:for-each select="Argument">
<xsl:if test="position() > 1 or not($method/@static='1')">
<xsl:text>, &amp;
</xsl:text>
</xsl:if>
<xsl:value-of select="@name"/>
</xsl:for-each>
<xsl:if test="$has_return_arg">
<xsl:if test="not(@static='1') or not(empty(Argument))">
<xsl:text>, &amp;
</xsl:text>
</xsl:if>
<xsl:value-of select="'result'"/>
</xsl:if>
<xsl:value-of select="')'"/>
<xsl:text>
use OpenMM_Types; implicit none</xsl:text>
<!-- Generate the list of argument types -->
<xsl:if test="not(@static='1')">
type (OpenMM_<xsl:value-of select="concat($class_name, ') target')"/>
</xsl:if>
<xsl:value-of select="$newline"/>
<xsl:for-each select="Argument">
<xsl:value-of select="' '"/>
<xsl:call-template name="declare_argument">
<xsl:with-param name="type_id" select="@type"/>
<xsl:with-param name="value" select="@name"/>
</xsl:call-template>
<xsl:value-of select="$newline"/>
</xsl:for-each>
<xsl:if test="$has_return">
<xsl:value-of select="' '"/>
<xsl:call-template name="declare_argument">
<xsl:with-param name="type_id" select="@returns"/>
<xsl:with-param name="value" select="concat(' OpenMM_', $class_name, '_', @name)"/>
</xsl:call-template>
<xsl:value-of select="$newline"/>
</xsl:if>
<xsl:if test="$has_return_arg">
<xsl:value-of select="' '"/>
<xsl:call-template name="declare_argument">
<xsl:with-param name="type_id" select="@returns"/>
<xsl:with-param name="value" select="'result'"/>
</xsl:call-template>
<xsl:value-of select="$newline"/>
</xsl:if>
<xsl:value-of select="' end'"/>
</xsl:template>
<!-- Print out the description of an argument -->
<xsl:template name="declare_argument">
<xsl:param name="type_id"/>
<xsl:param name="value"/>
<xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:choose>
<xsl:when test="$type_id=$int_type_id">
<xsl:value-of select="concat('integer*4 ', $value)"/>
</xsl:when>
<xsl:when test="$type_id=$bool_type_id">
<xsl:value-of select="concat('integer*4 ', $value)"/>
</xsl:when>
<xsl:when test="$type_id=$double_type_id">
<xsl:value-of select="concat('real*8 ', $value)"/>
</xsl:when>
<xsl:when test="$type_id=$string_type_id or $type_id=$ptr_const_char_type_id">
<xsl:value-of select="concat('character(*) ', $value)"/>
</xsl:when>
<xsl:when test="$type_id=$vec3_type_id">
<xsl:value-of select="concat('real*8 ', $value, '(3)')"/>
</xsl:when>
<xsl:when test="$type_id=$vector_string_type_id">
<xsl:value-of select="concat('type (OpenMM_StringArray) ', $value)"/>
</xsl:when>
<xsl:when test="$type_id=$vector_vec3_type_id">
<xsl:value-of select="concat('type (OpenMM_Vec3Array) ', $value)"/>
</xsl:when>
<xsl:when test="$type_id=$vector_bond_type_id">
<xsl:value-of select="concat('type (OpenMM_BondArray) ', $value)"/>
</xsl:when>
<xsl:when test="$type_id=$map_parameter_type_id">
<xsl:value-of select="concat('type (OpenMM_ParameterArray) ', $value)"/>
</xsl:when>
<xsl:when test="$type_id=$map_property_type_id">
<xsl:value-of select="concat('type (OpenMM_PropertyArray) ', $value)"/>
</xsl:when>
<xsl:when test="$type_id=$vector_double_type_id">
<xsl:value-of select="concat('type (OpenMM_DoubleArray) ', $value)"/>
</xsl:when>
<xsl:when test="$type_id=$vector_int_type_id">
<xsl:value-of select="concat('type (OpenMM_IntArray) ', $value)"/>
</xsl:when>
<xsl:when test="local-name($node)='ReferenceType' or local-name($node)='PointerType'">
<xsl:call-template name="declare_argument">
<xsl:with-param name="type_id" select="$node/@type"/>
<xsl:with-param name="value" select="$value"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="local-name($node)='CvQualifiedType'">
<xsl:call-template name="declare_argument">
<xsl:with-param name="type_id" select="$node/@type"/>
<xsl:with-param name="value" select="$value"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="local-name($node)='Enumeration'">
<xsl:value-of select="concat('integer*4 ', $value)"/>
</xsl:when>
<xsl:when test="$node/@context=$openmm_namespace_id">
<xsl:value-of select="concat('type (OpenMM_', $node/@name, ') ', $value)"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- Determine whether a method should be hidden -->
<xsl:template name="should_hide">
<xsl:variable name="class_id" select="@context"/>
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="@returns"/>
</xsl:call-template>
<xsl:for-each select="Argument">
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="@type"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<!-- This is called by should_hide. It generates output if the specified type should be hidden. -->
<xsl:template name="hide_type">
<xsl:param name="type_id"/>
<xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:choose>
<xsl:when test="local-name($node)='ReferenceType' or local-name($node)='PointerType' or local-name($node)='CvQualifiedType'">
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="$node/@type"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="local-name($node)='Enumeration'">
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="$node/@context"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$node/@context=$openmm_namespace_id and not(empty(index-of($hide_classes, $node/@name)))">
<xsl:value-of select="1"/>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes"/>
<xsl:variable name="std_namespace_id" select="/GCC_XML/Namespace[@name='std']/@id"/>
<xsl:variable name="openmm_namespace_id" select="/GCC_XML/Namespace[@name='OpenMM']/@id"/>
<xsl:variable name="void_type_id" select="/GCC_XML/FundamentalType[@name='void']/@id"/>
<xsl:variable name="bool_type_id" select="/GCC_XML/FundamentalType[@name='bool']/@id"/>
<xsl:variable name="int_type_id" select="/GCC_XML/FundamentalType[@name='int']/@id"/>
<xsl:variable name="double_type_id" select="/GCC_XML/FundamentalType[@name='double']/@id"/>
<xsl:variable name="char_type_id" select="/GCC_XML/FundamentalType[@name='char']/@id"/>
<xsl:variable name="string_type_id" select="/GCC_XML/*[@name='string' and @context=$std_namespace_id]/@id"/>
<xsl:variable name="const_char_type_id" select="/GCC_XML/CvQualifiedType[@type=$char_type_id]/@id"/>
<xsl:variable name="ptr_const_char_type_id" select="/GCC_XML/PointerType[@type=$const_char_type_id]/@id"/>
<xsl:variable name="const_string_type_id" select="/GCC_XML/CvQualifiedType[@type=$string_type_id]/@id"/>
<xsl:variable name="const_ref_string_type_id" select="/GCC_XML/ReferenceType[@type=$const_string_type_id]/@id"/>
<xsl:variable name="vec3_type_id" select="/GCC_XML/Class[@name='Vec3' and @context=$openmm_namespace_id]/@id"/>
<xsl:variable name="vector_string_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::basic_string')]/@id"/>
<xsl:variable name="vector_vec3_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;OpenMM::Vec3')]/@id"/>
<xsl:variable name="vector_bond_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::pair&lt;int, int')]/@id"/>
<xsl:variable name="vector_2d_int_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::vector&lt;int')]/@id"/>
<xsl:variable name="map_parameter_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and contains(@name, 'double')]/@id"/>
<xsl:variable name="map_property_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and not(contains(@name, 'double'))]/@id"/>
<xsl:variable name="vector_double_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;double')]/@id"/>
<xsl:variable name="vector_int_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;int')]/@id"/>
<xsl:variable name="vector_tortor_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::vector&lt;std::vector&lt;double')]/@id"/>
<xsl:variable name="newline">
<xsl:text>
</xsl:text>
</xsl:variable>
<!-- Do not generate functions for the following classes -->
<xsl:variable name="skip_classes" select="('Vec3', 'Kernel', 'Stream', 'KernelImpl', 'StreamImpl', 'KernelFactory', 'StreamFactory')"/>
<!-- Do not generate the following functions -->
<xsl:variable name="skip_methods" select="('OpenMM_Context_getState', 'OpenMM_Platform_loadPluginsFromDirectory')"/>
<!-- Suppress any function which references any of the following classes -->
<xsl:variable name="hide_classes" select="('Kernel', 'Stream', 'KernelImpl', 'StreamImpl', 'KernelFactory', 'StreamFactory', 'ContextImpl')"/>
<!-- Main loop over all classes in the OpenMM namespace -->
<xsl:template match="/GCC_XML">
#include "OpenMM.h"
#include "OpenMMAmoeba.h"
#include "../../../wrappers/OpenMMCWrapper.h"
#include "AmoebaOpenMMCWrapper.h"
#include &lt;cstring&gt;
#include &lt;vector&gt;
using namespace OpenMM;
using namespace std;
/* Utilities for dealing with Fortran's blank-padded strings. */
static void copyAndPadString(char* dest, const char* source, int length) {
bool reachedEnd = false;
for (int i = 0; i &lt; length; i++) {
if (source[i] == 0)
reachedEnd = true;
dest[i] = (reachedEnd ? ' ' : source[i]);
}
}
static string makeString(const char* fsrc, int length) {
while (length &amp;&amp; fsrc[length-1]==' ')
--length;
return string(fsrc, length);
}
extern "C" {
/* OpenMM_Vec3 */
OPENMM_EXPORT void openmm_vec3_scale_(const OpenMM_Vec3&amp; vec, double const&amp; scale, OpenMM_Vec3&amp; result) {
result = OpenMM_Vec3_scale(vec, scale);
}
OPENMM_EXPORT void OPENMM_VEC3_SCALE(const OpenMM_Vec3&amp; vec, double const&amp; scale, OpenMM_Vec3&amp; result) {
result = OpenMM_Vec3_scale(vec, scale);
}
/* OpenMM_Vec3Array */
OPENMM_EXPORT void openmm_vec3array_create_(OpenMM_Vec3Array*&amp; result, const int&amp; size) {
result = OpenMM_Vec3Array_create(size);
}
OPENMM_EXPORT void OPENMM_VEC3ARRAY_CREATE(OpenMM_Vec3Array*&amp; result, const int&amp; size) {
result = OpenMM_Vec3Array_create(size);
}
OPENMM_EXPORT void openmm_vec3array_destroy_(OpenMM_Vec3Array*&amp; array) {
OpenMM_Vec3Array_destroy(array);
array = 0;
}
OPENMM_EXPORT void OPENMM_VEC3ARRAY_DESTROY(OpenMM_Vec3Array*&amp; array) {
OpenMM_Vec3Array_destroy(array);
array = 0;
}
OPENMM_EXPORT int openmm_vec3array_getsize_(const OpenMM_Vec3Array* const&amp; array) {
return OpenMM_Vec3Array_getSize(array);
}
OPENMM_EXPORT int OPENMM_VEC3ARRAY_GETSIZE(const OpenMM_Vec3Array* const&amp; array) {
return OpenMM_Vec3Array_getSize(array);
}
OPENMM_EXPORT void openmm_vec3array_resize_(OpenMM_Vec3Array* const&amp; array, const int&amp; size) {
OpenMM_Vec3Array_resize(array, size);
}
OPENMM_EXPORT void OPENMM_VEC3ARRAY_RESIZE(OpenMM_Vec3Array* const&amp; array, const int&amp; size) {
OpenMM_Vec3Array_resize(array, size);
}
OPENMM_EXPORT void openmm_vec3array_append_(OpenMM_Vec3Array* const&amp; array, const OpenMM_Vec3&amp; vec) {
OpenMM_Vec3Array_append(array, vec);
}
OPENMM_EXPORT void OPENMM_VEC3ARRAY_APPEND(OpenMM_Vec3Array* const&amp; array, const OpenMM_Vec3&amp; vec) {
OpenMM_Vec3Array_append(array, vec);
}
OPENMM_EXPORT void openmm_vec3array_set_(OpenMM_Vec3Array* const&amp; array, const int&amp; index, const OpenMM_Vec3&amp; vec) {
OpenMM_Vec3Array_set(array, index-1, vec);
}
OPENMM_EXPORT void OPENMM_VEC3ARRAY_SET(OpenMM_Vec3Array* const&amp; array, const int&amp; index, const OpenMM_Vec3&amp; vec) {
OpenMM_Vec3Array_set(array, index-1, vec);
}
OPENMM_EXPORT void openmm_vec3array_get_(const OpenMM_Vec3Array* const&amp; array, const int&amp; index, OpenMM_Vec3&amp; result) {
result = *OpenMM_Vec3Array_get(array, index-1);
}
OPENMM_EXPORT void OPENMM_VEC3ARRAY_GET(const OpenMM_Vec3Array* const&amp; array, const int&amp; index, OpenMM_Vec3&amp; result) {
result = *OpenMM_Vec3Array_get(array, index-1);
}
/* OpenMM_StringArray */
OPENMM_EXPORT void openmm_stringarray_create_(OpenMM_StringArray*&amp; result, const int&amp; size) {
result = OpenMM_StringArray_create(size);
}
OPENMM_EXPORT void OPENMM_STRINGARRAY_CREATE(OpenMM_StringArray*&amp; result, const int&amp; size) {
result = OpenMM_StringArray_create(size);
}
OPENMM_EXPORT void openmm_stringarray_destroy_(OpenMM_StringArray*&amp; array) {
OpenMM_StringArray_destroy(array);
array = 0;
}
OPENMM_EXPORT void OPENMM_STRINGARRAY_DESTROY(OpenMM_StringArray*&amp; array) {
OpenMM_StringArray_destroy(array);
array = 0;
}
OPENMM_EXPORT int openmm_stringarray_getsize_(const OpenMM_StringArray* const&amp; array) {
return OpenMM_StringArray_getSize(array);
}
OPENMM_EXPORT int OPENMM_STRINGARRAY_GETSIZE(const OpenMM_StringArray* const&amp; array) {
return OpenMM_StringArray_getSize(array);
}
OPENMM_EXPORT void openmm_stringarray_resize_(OpenMM_StringArray* const&amp; array, const int&amp; size) {
OpenMM_StringArray_resize(array, size);
}
OPENMM_EXPORT void OPENMM_STRINGARRAY_RESIZE(OpenMM_StringArray* const&amp; array, const int&amp; size) {
OpenMM_StringArray_resize(array, size);
}
OPENMM_EXPORT void openmm_stringarray_append_(OpenMM_StringArray* const&amp; array, const char* str, int length) {
OpenMM_StringArray_append(array, makeString(str, length).c_str());
}
OPENMM_EXPORT void OPENMM_STRINGARRAY_APPEND(OpenMM_StringArray* const&amp; array, const char* str, int length) {
OpenMM_StringArray_append(array, makeString(str, length).c_str());
}
OPENMM_EXPORT void openmm_stringarray_set_(OpenMM_StringArray* const&amp; array, const int&amp; index, const char* str, int length) {
OpenMM_StringArray_set(array, index-1, makeString(str, length).c_str());
}
OPENMM_EXPORT void OPENMM_STRINGARRAY_SET(OpenMM_StringArray* const&amp; array, const int&amp; index, const char* str, int length) {
OpenMM_StringArray_set(array, index-1, makeString(str, length).c_str());
}
OPENMM_EXPORT void openmm_stringarray_get_(const OpenMM_StringArray* const&amp; array, const int&amp; index, char* result, int length) {
const char* str = OpenMM_StringArray_get(array, index-1);
copyAndPadString(result, str, length);
}
OPENMM_EXPORT void OPENMM_STRINGARRAY_GET(const OpenMM_StringArray* const&amp; array, const int&amp; index, char* result, int length) {
const char* str = OpenMM_StringArray_get(array, index-1);
copyAndPadString(result, str, length);
}
/* OpenMM_BondArray */
OPENMM_EXPORT void openmm_bondarray_create_(OpenMM_BondArray*&amp; result, const int&amp; size) {
result = OpenMM_BondArray_create(size);
}
OPENMM_EXPORT void OPENMM_BONDARRAY_CREATE(OpenMM_BondArray*&amp; result, const int&amp; size) {
result = OpenMM_BondArray_create(size);
}
OPENMM_EXPORT void openmm_bondarray_destroy_(OpenMM_BondArray*&amp; array) {
OpenMM_BondArray_destroy(array);
array = 0;
}
OPENMM_EXPORT void OPENMM_BONDARRAY_DESTROY(OpenMM_BondArray*&amp; array) {
OpenMM_BondArray_destroy(array);
array = 0;
}
OPENMM_EXPORT int openmm_bondarray_getsize_(const OpenMM_BondArray* const&amp; array) {
return OpenMM_BondArray_getSize(array);
}
OPENMM_EXPORT int OPENMM_BONDARRAY_GETSIZE(const OpenMM_BondArray* const&amp; array) {
return OpenMM_BondArray_getSize(array);
}
OPENMM_EXPORT void openmm_bondarray_resize_(OpenMM_BondArray* const&amp; array, const int&amp; size) {
OpenMM_BondArray_resize(array, size);
}
OPENMM_EXPORT void OPENMM_BONDARRAY_RESIZE(OpenMM_BondArray* const&amp; array, const int&amp; size) {
OpenMM_BondArray_resize(array, size);
}
OPENMM_EXPORT void openmm_bondarray_append_(OpenMM_BondArray* const&amp; array, const int&amp; particle1, const int&amp; particle2) {
OpenMM_BondArray_append(array, particle1, particle2);
}
OPENMM_EXPORT void OPENMM_BONDARRAY_APPEND(OpenMM_BondArray* const&amp; array, const int&amp; particle1, const int&amp; particle2) {
OpenMM_BondArray_append(array, particle1, particle2);
}
OPENMM_EXPORT void openmm_bondarray_set_(OpenMM_BondArray* const&amp; array, const int&amp; index, const int&amp; particle1, const int&amp; particle2) {
OpenMM_BondArray_set(array, index-1, particle1, particle2);
}
OPENMM_EXPORT void OPENMM_BONDARRAY_SET(OpenMM_BondArray* const&amp; array, const int&amp; index, const int&amp; particle1, const int&amp; particle2) {
OpenMM_BondArray_set(array, index-1, particle1, particle2);
}
OPENMM_EXPORT void openmm_bondarray_get_(const OpenMM_BondArray* const&amp; array, const int&amp; index, int* particle1, int* particle2) {
OpenMM_BondArray_get(array, index-1, particle1, particle2);
}
OPENMM_EXPORT void OPENMM_BONDARRAY_GET(const OpenMM_BondArray* const&amp; array, const int&amp; index, int* particle1, int* particle2) {
OpenMM_BondArray_get(array, index-1, particle1, particle2);
}
/* OpenMM_ParameterArray */
OPENMM_EXPORT int openmm_parameterarray_getsize_(const OpenMM_ParameterArray* const&amp; array) {
return OpenMM_ParameterArray_getSize(array);
}
OPENMM_EXPORT int OPENMM_PARAMETERARRAY_GETSIZE(const OpenMM_ParameterArray* const&amp; array) {
return OpenMM_ParameterArray_getSize(array);
}
OPENMM_EXPORT double openmm_parameterarray_get_(const OpenMM_ParameterArray* const&amp; array, const char* name, int length) {
return OpenMM_ParameterArray_get(array, makeString(name, length).c_str());
}
OPENMM_EXPORT double OPENMM_PARAMETERARRAY_GET(const OpenMM_ParameterArray* const&amp; array, const char* name, int length) {
return OpenMM_ParameterArray_get(array, makeString(name, length).c_str());
}
/* OpenMM_PropertyArray */
OPENMM_EXPORT int openmm_propertyarray_getsize_(const OpenMM_PropertyArray* const&amp; array) {
return OpenMM_PropertyArray_getSize(array);
}
OPENMM_EXPORT int OPENMM_PROPERTYARRAY_GETSIZE(const OpenMM_PropertyArray* const&amp; array) {
return OpenMM_PropertyArray_getSize(array);
}
OPENMM_EXPORT const char* openmm_propertyarray_get_(const OpenMM_PropertyArray* const&amp; array, const char* name, int length) {
return OpenMM_PropertyArray_get(array, makeString(name, length).c_str());
}
OPENMM_EXPORT const char* OPENMM_PROPERTYARRAY_GET(const OpenMM_PropertyArray* const&amp; array, const char* name, int length) {
return OpenMM_PropertyArray_get(array, makeString(name, length).c_str());
}
<xsl:call-template name="primitive_array">
<xsl:with-param name="element_type" select="'int'"/>
<xsl:with-param name="name" select="'OpenMM_IntArray'"/>
</xsl:call-template>
/* These methods need to be handled specially, since their C++ APIs cannot be directly translated to C.
Unlike the C++ versions, the return value is allocated on the heap, and you must delete it yourself. */
OPENMM_EXPORT void openmm_context_getstate_(const OpenMM_Context*&amp; target, int const&amp; types, OpenMM_State*&amp; result) {
result = OpenMM_Context_getState(target, types);
};
OPENMM_EXPORT void OPENMM_CONTEXT_GETSTATE(const OpenMM_Context*&amp; target, int const&amp; types, OpenMM_State*&amp; result) {
result = OpenMM_Context_getState(target, types);
};
OPENMM_EXPORT void openmm_platform_loadpluginsfromdirectory_(const char* directory, OpenMM_StringArray*&amp; result, int length) {
result = OpenMM_Platform_loadPluginsFromDirectory(makeString(directory, length).c_str());
};
OPENMM_EXPORT void OPENMM_PLATFORM_LOADPLUGINSFROMDIRECTORY(const char* directory, OpenMM_StringArray*&amp; result, int length) {
result = OpenMM_Platform_loadPluginsFromDirectory(makeString(directory, length).c_str());
};
<!-- Class members -->
<xsl:for-each select="Class[@context=$openmm_namespace_id and empty(index-of($skip_classes, @name))]">
<xsl:call-template name="class"/>
</xsl:for-each>
}
</xsl:template>
<!-- Print out the definitions for a (Primitive)Array type -->
<xsl:template name="primitive_array">
<xsl:param name="element_type"/>
<xsl:param name="name"/>
<xsl:variable name="name_lower" select="lower-case($name)"/>
<xsl:variable name="name_upper" select="upper-case($name)"/>
/* <xsl:value-of select="$name"/> */
OPENMM_EXPORT void <xsl:value-of select="$name_lower"/>_create_(<xsl:value-of select="$name"/>*&amp; result, const int&amp; size) {
result = <xsl:value-of select="$name"/>_create(size);
}
OPENMM_EXPORT void <xsl:value-of select="$name_upper"/>_CREATE(<xsl:value-of select="$name"/>*&amp; result, const int&amp; size) {
result = <xsl:value-of select="$name"/>_create(size);
}
OPENMM_EXPORT void <xsl:value-of select="$name_lower"/>_destroy_(<xsl:value-of select="$name"/>*&amp; array) {
<xsl:value-of select="$name"/>_destroy(array);
array = 0;
}
OPENMM_EXPORT void <xsl:value-of select="$name_upper"/>_DESTROY(<xsl:value-of select="$name"/>*&amp; array) {
<xsl:value-of select="$name"/>_destroy(array);
array = 0;
}
OPENMM_EXPORT int <xsl:value-of select="$name_lower"/>_getsize_(const <xsl:value-of select="$name"/>* const&amp; array) {
return <xsl:value-of select="$name"/>_getSize(array);
}
OPENMM_EXPORT int <xsl:value-of select="$name_upper"/>_GETSIZE(const <xsl:value-of select="$name"/>* const&amp; array) {
return <xsl:value-of select="$name"/>_getSize(array);
}
OPENMM_EXPORT void <xsl:value-of select="$name_lower"/>_resize_(<xsl:value-of select="$name"/>* const&amp; array, const int&amp; size) {
<xsl:value-of select="$name"/>_resize(array, size);
}
OPENMM_EXPORT void <xsl:value-of select="$name_upper"/>_RESIZE(<xsl:value-of select="$name"/>* const&amp; array, const int&amp; size) {
<xsl:value-of select="$name"/>_resize(array, size);
}
OPENMM_EXPORT void <xsl:value-of select="$name_lower"/>_append_(<xsl:value-of select="$name"/>* const&amp; array, <xsl:value-of select="$element_type"/> value) {
<xsl:value-of select="$name"/>_append(array, value);
}
OPENMM_EXPORT void <xsl:value-of select="$name_upper"/>_APPEND(<xsl:value-of select="$name"/>* const&amp; array, <xsl:value-of select="$element_type"/> value) {
<xsl:value-of select="$name"/>_append(array, value);
}
OPENMM_EXPORT void <xsl:value-of select="$name_lower"/>_set_(<xsl:value-of select="$name"/>* const&amp; array, const int&amp; index, <xsl:value-of select="$element_type"/> value) {
<xsl:value-of select="$name"/>_set(array, index-1, value);
}
OPENMM_EXPORT void <xsl:value-of select="$name_upper"/>_SET(<xsl:value-of select="$name"/>* const&amp; array, const int&amp; index, <xsl:value-of select="$element_type"/> value) {
<xsl:value-of select="$name"/>_set(array, index-1, value);
}
OPENMM_EXPORT void <xsl:value-of select="$name_lower"/>_get_(const <xsl:value-of select="$name"/>* const&amp; array, const int&amp; index, <xsl:value-of select="$element_type"/>&amp; result) {
result = <xsl:value-of select="$name"/>_get(array, index-1);
}
OPENMM_EXPORT void <xsl:value-of select="$name_upper"/>_GET(const <xsl:value-of select="$name"/>* const&amp; array, const int&amp; index, <xsl:value-of select="$element_type"/>&amp; result) {
result = <xsl:value-of select="$name"/>_get(array, index-1);
}
</xsl:template>
<!-- Print out information for a class -->
<xsl:template name="class">
<xsl:variable name="class_name" select="@name"/>
<xsl:variable name="class_id" select="@id"/>
/* OpenMM::<xsl:value-of select="concat(@name, '*/', $newline)"/>
<!-- Constructors and destructor -->
<xsl:if test="not(@abstract=1)">
<xsl:variable name="constructors" select="/GCC_XML/Constructor[@context=$class_id and @access='public' and not(@artificial='1')]"/>
<xsl:for-each select="$constructors">
<xsl:variable name="suffix" select="if (position() > 1) then concat('_', position()) else ''"/>
<xsl:variable name="function_name" select="concat('openmm_', $class_name, '_create', $suffix)"/>
<xsl:call-template name="constructor">
<xsl:with-param name="function_name" select="lower-case(concat($function_name, '_'))"/>
<xsl:with-param name="suffix" select="$suffix"/>
</xsl:call-template>
<xsl:call-template name="constructor">
<xsl:with-param name="function_name" select="upper-case($function_name)"/>
<xsl:with-param name="suffix" select="$suffix"/>
</xsl:call-template>
</xsl:for-each>
</xsl:if>
<xsl:variable name="function_name" select="concat('openmm_', $class_name, '_destroy')"/>
<xsl:call-template name="destructor">
<xsl:with-param name="function_name" select="lower-case(concat($function_name, '_'))"/>
</xsl:call-template>
<xsl:call-template name="destructor">
<xsl:with-param name="function_name" select="upper-case($function_name)"/>
</xsl:call-template>
<!-- Methods -->
<xsl:variable name="methods" select="/GCC_XML/Method[@context=$class_id and @access='public']"/>
<xsl:for-each select="$methods">
<xsl:variable name="node" select="."/>
<!-- The next line is to deal with overloaded methods that have a const and a non-const version. -->
<xsl:if test="not(@const=1) or empty($methods[@name=$node/@name and not(@const=1)])">
<xsl:variable name="hide">
<xsl:call-template name="should_hide"/>
</xsl:variable>
<xsl:if test="string-length($hide)=0">
<xsl:variable name="function_name" select="concat('openmm_', $class_name, '_', @name)"/>
<xsl:call-template name="method">
<xsl:with-param name="class_name" select="$class_name"/>
<xsl:with-param name="class_id" select="$class_id"/>
<xsl:with-param name="function_name" select="lower-case(concat($function_name, '_'))"/>
</xsl:call-template>
<xsl:call-template name="method">
<xsl:with-param name="class_name" select="$class_name"/>
<xsl:with-param name="class_id" select="$class_id"/>
<xsl:with-param name="function_name" select="upper-case($function_name)"/>
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>
<!-- Print out the definition of a constructor -->
<xsl:template name="constructor">
<xsl:param name="function_name"/>
<xsl:param name="suffix"/>
OPENMM_EXPORT <xsl:value-of select="concat('void ', $function_name, '(OpenMM_', @name, '*&amp; result')"/>
<!-- Generate the list of arguments -->
<xsl:for-each select="Argument">
<xsl:value-of select="', '"/>
<xsl:call-template name="wrap_type"><xsl:with-param name="type_id" select="@type"/></xsl:call-template>
<xsl:variable name="is_handle">
<xsl:call-template name="is_handle_type">
<xsl:with-param name="type_id" select="@type"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="string-length($is_handle)>0">&amp;</xsl:if>
<xsl:variable name="type_id" select="@type"/>
<xsl:variable name="type_node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:if test="not(local-name($type_node)='ReferenceType' or local-name($type_node)='PointerType')"> const&amp;</xsl:if>
<xsl:value-of select="concat(' ', @name)"/>
</xsl:for-each>
<!-- If any argument is a string, include a length argument -->
<xsl:for-each select="Argument">
<xsl:if test="@type=$const_ref_string_type_id">
<xsl:value-of select="concat(', int ', @name, '_length')"/>
</xsl:if>
</xsl:for-each>
<!-- Now the constructor body -->
<xsl:value-of select="') {'"/>
result = OpenMM_<xsl:value-of select="concat(@name, '_create', $suffix, '(')"/>
<xsl:for-each select="Argument">
<xsl:if test="position() > 1">, </xsl:if>
<xsl:choose>
<xsl:when test="@type=$const_ref_string_type_id">
<xsl:value-of select="concat('makeString(', @name, ', ', @name, '_length).c_str()')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:value-of select="');'"/>
}
</xsl:template>
<!-- Print out the definition of a destructor -->
<xsl:template name="destructor">
<xsl:param name="function_name"/>
OPENMM_EXPORT <xsl:value-of select="concat('void ', $function_name, '(OpenMM_', @name, '*&amp; destroy) {')"/>
OpenMM_<xsl:value-of select="concat(@name, '_destroy(destroy);')"/>
destroy = 0;
}
</xsl:template>
<!-- Print out the definition of a method -->
<xsl:template name="method">
<xsl:param name="class_name"/>
<xsl:param name="class_id"/>
<xsl:param name="function_name"/>
<!-- First the method signature -->
<xsl:variable name="has_return" select="@returns=$int_type_id or @returns=$double_type_id"/>
<xsl:variable name="has_return_arg" select="not($has_return or @returns=$void_type_id)"/>
OPENMM_EXPORT <xsl:if test="$has_return">
<xsl:call-template name="wrap_type"><xsl:with-param name="type_id" select="@returns"/></xsl:call-template>
</xsl:if>
<xsl:if test="not($has_return)">
<xsl:value-of select="'void'"/>
</xsl:if>
<xsl:value-of select="concat(' ', $function_name, '(')"/>
<xsl:if test="not(@static='1')">
<xsl:if test="@const='1'">
<xsl:value-of select="'const '"/>
</xsl:if>
<xsl:value-of select="concat('OpenMM_', $class_name, '*&amp; target')"/>
</xsl:if>
<!-- Generate the list of arguments -->
<xsl:variable name="method" select="."/>
<xsl:for-each select="Argument">
<xsl:if test="position() > 1 or not($method/@static='1')">, </xsl:if>
<xsl:call-template name="wrap_type"><xsl:with-param name="type_id" select="@type"/></xsl:call-template>
<xsl:variable name="is_handle">
<xsl:call-template name="is_handle_type">
<xsl:with-param name="type_id" select="@type"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="string-length($is_handle)>0">&amp;</xsl:if>
<xsl:variable name="type_id" select="@type"/>
<xsl:variable name="type_node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:if test="not(local-name($type_node)='ReferenceType' or local-name($type_node)='PointerType')"> const&amp;</xsl:if>
<xsl:value-of select="concat(' ', @name)"/>
</xsl:for-each>
<xsl:if test="$has_return_arg">
<xsl:if test="not(@static='1') or not(empty(Argument)) or not($method/@static='1')">, </xsl:if>
<xsl:choose>
<xsl:when test="@returns=$const_ref_string_type_id or @returns=$ptr_const_char_type_id">
<xsl:value-of select="'char*'"/> <!-- We need a non-const buffer to copy the result into -->
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="wrap_type"><xsl:with-param name="type_id" select="@returns"/></xsl:call-template>
<xsl:value-of select="'&amp;'"/>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="' result'"/>
</xsl:if>
<!-- If any argument is a string, include a length argument -->
<xsl:for-each select="Argument">
<xsl:if test="@type=$const_ref_string_type_id or @type=$ptr_const_char_type_id">
<xsl:value-of select="concat(', int ', @name, '_length')"/>
</xsl:if>
</xsl:for-each>
<xsl:if test="$has_return_arg and (@returns=$const_ref_string_type_id or @returns=$ptr_const_char_type_id)">
<xsl:value-of select="', int result_length'"/>
</xsl:if>
<xsl:value-of select="concat(') {', $newline, ' ')"/>
<!-- Now the method body -->
<xsl:choose>
<xsl:when test="$has_return">
<xsl:value-of select="'return '"/>
</xsl:when>
<xsl:when test="$has_return_arg and (@returns=$const_ref_string_type_id or @returns=$ptr_const_char_type_id)">
<xsl:value-of select="'const char* result_chars = '"/>
</xsl:when>
<xsl:when test="$has_return_arg">
<xsl:value-of select="'result = '"/>
</xsl:when>
</xsl:choose>
<xsl:value-of select="concat('OpenMM_', $class_name, '_', @name, '(')"/>
<xsl:if test="not(@static='1')">target</xsl:if>
<xsl:for-each select="Argument">
<xsl:if test="position() > 1 or not($method/@static='1')">, </xsl:if>
<xsl:variable name="type_id" select="@type"/>
<xsl:variable name="type_node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:choose>
<xsl:when test="@type=$const_ref_string_type_id or @type=$ptr_const_char_type_id">
<xsl:value-of select="concat('makeString(', @name, ', ', @name, '_length).c_str()')"/>
</xsl:when>
<xsl:when test="local-name($type_node)='Enumeration'">
<xsl:variable name="enum_class" select="/GCC_XML/*[@id=$type_node/@context]"/>
<xsl:value-of select="concat('(OpenMM_', $enum_class/@name, '_', $type_node/@name, ') ', @name)"/>
</xsl:when>
<xsl:when test="local-name($type_node)='ReferenceType' and not(empty(/GCC_XML/Enumeration[@id=$type_node/@type]))">
<xsl:variable name="enum_node" select="/GCC_XML/Enumeration[@id=$type_node/@type]"/>
<xsl:variable name="enum_class" select="/GCC_XML/*[@id=$enum_node/@context]"/>
<xsl:value-of select="concat('(OpenMM_', $enum_class/@name, '_', $enum_node/@name, '*) ', @name)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:value-of select="');'"/>
<xsl:if test="$has_return_arg and (@returns=$const_ref_string_type_id or @returns=$ptr_const_char_type_id)">
copyAndPadString(result, result_chars, result_length);</xsl:if>
};
</xsl:template>
<!-- Print out the description of a type in the wrapper API -->
<xsl:template name="wrap_type">
<xsl:param name="type_id"/>
<xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:choose>
<xsl:when test="$type_id=$bool_type_id">
<xsl:value-of select="'OpenMM_Boolean'"/>
</xsl:when>
<xsl:when test="$type_id=$string_type_id">
<xsl:value-of select="'char*'"/>
</xsl:when>
<xsl:when test="$type_id=$const_ref_string_type_id">
<xsl:value-of select="'const char*'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_string_type_id">
<xsl:value-of select="'OpenMM_StringArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_vec3_type_id">
<xsl:value-of select="'OpenMM_Vec3Array'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_bond_type_id">
<xsl:value-of select="'OpenMM_BondArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_2d_int_type_id">
<xsl:value-of select="'OpenMM_2D_IntArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_tortor_type_id">
<xsl:value-of select="'OpenMM_3D_DoubleArray'"/>
</xsl:when>
<xsl:when test="$type_id=$map_parameter_type_id">
<xsl:value-of select="'OpenMM_ParameterArray'"/>
</xsl:when>
<xsl:when test="$type_id=$map_property_type_id">
<xsl:value-of select="'OpenMM_PropertyArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_double_type_id">
<xsl:value-of select="'OpenMM_DoubleArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_int_type_id">
<xsl:value-of select="'OpenMM_IntArray'"/>
</xsl:when>
<xsl:when test="local-name($node)='ReferenceType' or local-name($node)='PointerType'">
<xsl:call-template name="wrap_type">
<xsl:with-param name="type_id" select="$node/@type"/>
</xsl:call-template>
<xsl:value-of select="'*'"/>
</xsl:when>
<xsl:when test="local-name($node)='CvQualifiedType'">
<xsl:if test="$node/@const=1">
<xsl:value-of select="'const '"/>
</xsl:if>
<xsl:call-template name="wrap_type">
<xsl:with-param name="type_id" select="$node/@type"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="local-name($node)='Enumeration'">
<xsl:value-of select="'int'"/>
</xsl:when>
<xsl:when test="$node/@context=$openmm_namespace_id">
<xsl:value-of select="concat('OpenMM_', $node/@name)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$node/@name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Determine whether a type is one of the special handle types -->
<xsl:template name="is_handle_type">
<xsl:param name="type_id"/>
<xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:choose>
<xsl:when test="$type_id=$vec3_type_id"></xsl:when>
<xsl:when test="$type_id=$vector_string_type_id">1</xsl:when>
<xsl:when test="$type_id=$vector_vec3_type_id">1</xsl:when>
<xsl:when test="$type_id=$vector_bond_type_id">1</xsl:when>
<xsl:when test="$type_id=$vector_2d_int_type_id">1</xsl:when>
<xsl:when test="$type_id=$map_parameter_type_id">1</xsl:when>
<xsl:when test="$type_id=$map_property_type_id">1</xsl:when>
<xsl:when test="$type_id=$vector_double_type_id">1</xsl:when>
<xsl:when test="$type_id=$vector_int_type_id">1</xsl:when>
<xsl:when test="$type_id=$vector_string_type_id">1</xsl:when>
<xsl:when test="$type_id=$vector_tortor_type_id">1</xsl:when>
<xsl:when test="local-name($node)='Class' and $node/@context=$openmm_namespace_id">1</xsl:when>
<xsl:when test="local-name($node)='ReferenceType' or local-name($node)='PointerType'">
<xsl:call-template name="is_handle_type">
<xsl:with-param name="type_id" select="$node/@type"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="local-name($node)='CvQualifiedType'">
<xsl:call-template name="is_handle_type">
<xsl:with-param name="type_id" select="$node/@type"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- Determine whether a method should be hidden -->
<xsl:template name="should_hide">
<xsl:variable name="class_id" select="@context"/>
<xsl:variable name="method_name" select="concat('OpenMM_', /GCC_XML/Class[@id=$class_id]/@name, '_', @name)"/>
<xsl:if test="not(empty(index-of($skip_methods, $method_name)))">1</xsl:if>
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="@returns"/>
</xsl:call-template>
<xsl:for-each select="Argument">
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="@type"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<!-- This is called by should_hide. It generates output if the specified type should be hidden. -->
<xsl:template name="hide_type">
<xsl:param name="type_id"/>
<xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
<xsl:choose>
<xsl:when test="local-name($node)='ReferenceType' or local-name($node)='PointerType' or local-name($node)='CvQualifiedType'">
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="$node/@type"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="local-name($node)='Enumeration' or (local-name($node)='ReferenceType' and not(empty(/GCC_XML/Enumeration[@id=$node/@type])))">
<xsl:call-template name="hide_type">
<xsl:with-param name="type_id" select="$node/@context"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$node/@context=$openmm_namespace_id and not(empty(index-of($hide_classes, $node/@name)))">
<xsl:value-of select="1"/>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment