Commit 19d2885a authored by Lee-Ping's avatar Lee-Ping
Browse files

Merge github.com:SimTk/openmm

parents 99ef4344 57a6768e
#---------------------------------------------------
# OpenMM Serialization Library
#
# Creates OpenMM serializatin library, base name=OpenMMSerialization.
# Default libraries are shared & optimized. Variants
# are created for static (_static) and debug (_d).
#
# Windows:
# OpenMMSerialization[_d].dll
# OpenMMSerialization[_d].lib
# Unix:
# libOpenMMSerialization[_d].so
# OpenMM Serialization Classes
#----------------------------------------------------
# The source is organized into subdirectories, but we handle them all from
# this CMakeLists file rather than letting CMake visit them as SUBDIRS.
SET(OPENMM_SOURCE_SUBDIRS .)
# Collect up information about the version of the OpenMM library we're building
# and make it available to the code so it can be built into the binaries.
SET(OPENMM_SERIALIZATION_LIBRARY_NAME OpenMMSerialization)
# Ensure that debug libraries have "_d" appended to their names.
# CMake gets this right on Windows automatically with this definition.
IF (${CMAKE_GENERATOR} MATCHES "Visual Studio")
SET(CMAKE_DEBUG_POSTFIX "_d" CACHE INTERNAL "" FORCE)
ENDIF (${CMAKE_GENERATOR} MATCHES "Visual Studio")
# But on Unix or Cygwin we have to add the suffix manually
IF (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
SET(OPENMM_SERIALIZATION_LIBRARY_NAME ${OPENMM_SERIALIZATION_LIBRARY_NAME}_d)
ENDIF (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
# These are all the places to search for header files which are
# to be part of the API.
SET(API_INCLUDE_DIRS) # start empty
FOREACH(subdir ${OPENMM_SOURCE_SUBDIRS})
# append
SET(API_INCLUDE_DIRS ${API_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/include
${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/include/internal)
ENDFOREACH(subdir)
# We'll need both *relative* path names, starting with their API_INCLUDE_DIRS,
# and absolute pathnames.
SET(API_REL_INCLUDE_FILES) # start these out empty
SET(API_ABS_INCLUDE_FILES)
FOREACH(dir ${API_INCLUDE_DIRS})
FILE(GLOB fullpaths ${dir}/*.h) # returns full pathnames
SET(API_ABS_INCLUDE_FILES ${API_ABS_INCLUDE_FILES} ${fullpaths})
FOREACH(pathname ${fullpaths})
GET_FILENAME_COMPONENT(filename ${pathname} NAME)
SET(API_REL_INCLUDE_FILES ${API_REL_INCLUDE_FILES} ${dir}/${filename})
ENDFOREACH(pathname)
ENDFOREACH(dir)
# collect up source files
SET(SOURCE_FILES) # empty
SET(SOURCE_INCLUDE_FILES)
FOREACH(subdir ${OPENMM_SOURCE_SUBDIRS})
FILE(GLOB_RECURSE src_files ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/src/*.c)
FILE(GLOB incl_files ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/src/*.h ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/src/*.hpp)
SET(SOURCE_FILES ${SOURCE_FILES} ${src_files}) #append
SET(SOURCE_INCLUDE_FILES ${SOURCE_INCLUDE_FILES} ${incl_files})
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/include)
ENDFOREACH(subdir)
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/src)
# Create the library
ADD_LIBRARY(${OPENMM_SERIALIZATION_LIBRARY_NAME} SHARED ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ${API_ABS_INCLUDE_FILES})
TARGET_LINK_LIBRARIES(${OPENMM_SERIALIZATION_LIBRARY_NAME} ${SHARED_TARGET})
SET_TARGET_PROPERTIES(${OPENMM_SERIALIZATION_LIBRARY_NAME} PROPERTIES COMPILE_FLAGS "-DOPENMM_BUILDING_SHARED_LIBRARY -DTIXML_USE_STL -DIEEE_8087")
INSTALL_TARGETS(/lib RUNTIME_DIRECTORY /lib ${OPENMM_SERIALIZATION_LIBRARY_NAME})
INSTALL_FILES(/include/openmm/serialization FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/openmm/serialization/SerializationNode.h)
INSTALL_FILES(/include/openmm/serialization FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/openmm/serialization/SerializationProxy.h)
INSTALL_FILES(/include/openmm/serialization FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/openmm/serialization/XmlSerializer.h)
......
......@@ -11,7 +11,8 @@ FOREACH(TEST_PROG ${TEST_PROGS})
# All tests use shared libraries
ADD_EXECUTABLE(${TEST_ROOT} ${TEST_PROG})
TARGET_LINK_LIBRARIES(${TEST_ROOT} ${OPENMM_SERIALIZATION_LIBRARY_NAME})
TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_TARGET})
SET_TARGET_PROPERTIES(${TEST_ROOT} PROPERTIES LINK_FLAGS "${EXTRA_COMPILE_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS}")
ADD_TEST(${TEST_ROOT} ${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT})
ENDFOREACH(TEST_PROG ${TEST_PROGS})
......@@ -11,6 +11,7 @@ FOREACH(TEST_PROG ${TEST_PROGS})
# All tests use shared library only
ADD_EXECUTABLE(${TEST_ROOT} ${TEST_PROG})
TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_TARGET})
SET_TARGET_PROPERTIES(${TEST_ROOT} PROPERTIES LINK_FLAGS "${EXTRA_COMPILE_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS}")
ADD_TEST(${TEST_ROOT} ${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT})
ENDFOREACH(TEST_PROG ${TEST_PROGS})
# INCLUDE(FindJava)
find_package(Doxygen REQUIRED)
mark_as_advanced(CLEAR DOXYGEN_EXECUTABLE)
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_CMD ${JAVA_RUNTIME} -jar ${CMAKE_SOURCE_DIR}/wrappers/saxonb9-1-0-7j/saxon9.jar)
# WRAPPER_DOXYGEN_DIR is a workspace directory where wrapper files will be created
set(WRAPPER_DOXYGEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/doxygen")
file(MAKE_DIRECTORY "${WRAPPER_DOXYGEN_DIR}")
# find_program(GCCXML_PATH gccxml PATH
# /usr/local/bin
# "C:/Program Files/gccxml 0.9/bin"
# )
# Step 1 - Create Doxyfile to point to OpenMM headers
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
${WRAPPER_DOXYGEN_DIR}/Doxyfile
@ONLY
)
ADD_CUSTOM_COMMAND(OUTPUT OpenMMApi.xml
COMMAND ${GCCXML_PATH} ${GCCXML_ARGS} ${CMAKE_SOURCE_DIR}/openmmapi/include/OpenMM.h -fxml=OpenMMApi.xml
DEPENDS ${CMAKE_SOURCE_DIR}/openmmapi/include/OpenMM.h)
ADD_CUSTOM_COMMAND(OUTPUT OpenMMCWrapper.h
COMMAND ${SAXON_CMD} -t -s:OpenMMApi.xml -xsl:${CMAKE_CURRENT_SOURCE_DIR}/CWrapper_Header.xslt -o:OpenMMCWrapper.h
DEPENDS OpenMMApi.xml ${CMAKE_CURRENT_SOURCE_DIR}/CWrapper_Header.xslt)
ADD_CUSTOM_COMMAND(OUTPUT OpenMMCWrapper.cpp
COMMAND ${SAXON_CMD} -t -s:OpenMMApi.xml -xsl:${CMAKE_CURRENT_SOURCE_DIR}/CWrapper_Source.xslt -o:OpenMMCWrapper.cpp
DEPENDS OpenMMApi.xml ${CMAKE_CURRENT_SOURCE_DIR}/CWrapper_Source.xslt)
ADD_CUSTOM_COMMAND(OUTPUT OpenMMFortranModule.f90
COMMAND ${SAXON_CMD} -t -s:OpenMMApi.xml -xsl:${CMAKE_CURRENT_SOURCE_DIR}/FortranWrapper_Header.xslt -o:OpenMMFortranModule.f90
DEPENDS OpenMMApi.xml ${CMAKE_CURRENT_SOURCE_DIR}/FortranWrapper_Header.xslt)
ADD_CUSTOM_COMMAND(OUTPUT OpenMMFortranWrapper.cpp
COMMAND ${SAXON_CMD} -t -s:OpenMMApi.xml -xsl:${CMAKE_CURRENT_SOURCE_DIR}/FortranWrapper_Source.xslt -o:OpenMMFortranWrapper.cpp
DEPENDS OpenMMApi.xml ${CMAKE_CURRENT_SOURCE_DIR}/FortranWrapper_Source.xslt)
# Step 2 - Run doxygen to analyze the headers
add_custom_command(
OUTPUT "${WRAPPER_DOXYGEN_DIR}/xml/index.xml"
COMMAND "${DOXYGEN_EXECUTABLE}"
DEPENDS "${WRAPPER_DOXYGEN_DIR}/Doxyfile"
WORKING_DIRECTORY "${WRAPPER_DOXYGEN_DIR}"
COMMENT "Parsing OpenMM header files with Doxygen..."
)
ADD_CUSTOM_TARGET(ApiWrappers DEPENDS OpenMMCWrapper.h OpenMMCWrapper.cpp OpenMMFortranModule.f90 OpenMMFortranWrapper.cpp)
# Step 3 - Generate the wrappers
ADD_CUSTOM_COMMAND(OUTPUT OpenMMCWrapper.h OpenMMCWrapper.cpp OpenMMFortranModule.f90 OpenMMFortranWrapper.cpp
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/generateWrappers.py" "${WRAPPER_DOXYGEN_DIR}/xml" "${CMAKE_CURRENT_BINARY_DIR}"
DEPENDS "${WRAPPER_DOXYGEN_DIR}/xml/index.xml" "${CMAKE_CURRENT_SOURCE_DIR}/generateWrappers.py")
ADD_CUSTOM_TARGET(ApiWrappers DEPENDS OpenMMCWrapper.h OpenMMCWrapper.cpp OpenMMFortranModule.f90 OpenMMFortranWrapper.cpp)
INSTALL_FILES(/include FILES OpenMMCWrapper.h OpenMMFortranModule.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="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="set_int_type_id" select="/GCC_XML/Class[starts-with(@name, 'set&lt;int')]/@id"/>
<!-- 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', 'OpenMM_Context_createCheckpoint', 'OpenMM_Context_loadCheckpoint')"/>
<!-- 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 OPENMM_CWRAPPER_H_
#define 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_Vec3Array_struct OpenMM_Vec3Array;
typedef struct OpenMM_StringArray_struct OpenMM_StringArray;
typedef struct OpenMM_BondArray_struct OpenMM_BondArray;
typedef struct OpenMM_ParameterArray_struct OpenMM_ParameterArray;
typedef struct OpenMM_PropertyArray_struct OpenMM_PropertyArray;
typedef struct OpenMM_DoubleArray_struct OpenMM_DoubleArray;
typedef struct OpenMM_IntArray_struct OpenMM_IntArray;
typedef struct OpenMM_IntSet_struct OpenMM_IntSet;
typedef struct {double x, y, z;} OpenMM_Vec3;
typedef enum {OpenMM_False = 0, OpenMM_True = 1} OpenMM_Boolean;
#if defined(__cplusplus)
extern "C" {
#endif
/* OpenMM_Vec3 */
extern OPENMM_EXPORT OpenMM_Vec3 OpenMM_Vec3_scale(const OpenMM_Vec3 vec, double scale);
/* OpenMM_Vec3Array */
extern OPENMM_EXPORT OpenMM_Vec3Array* OpenMM_Vec3Array_create(int size);
extern OPENMM_EXPORT void OpenMM_Vec3Array_destroy(OpenMM_Vec3Array* array);
extern OPENMM_EXPORT int OpenMM_Vec3Array_getSize(const OpenMM_Vec3Array* array);
extern OPENMM_EXPORT void OpenMM_Vec3Array_resize(OpenMM_Vec3Array* array, int size);
extern OPENMM_EXPORT void OpenMM_Vec3Array_append(OpenMM_Vec3Array* array, const OpenMM_Vec3 vec);
extern OPENMM_EXPORT void OpenMM_Vec3Array_set(OpenMM_Vec3Array* array, int index, const OpenMM_Vec3 vec);
extern OPENMM_EXPORT const OpenMM_Vec3* OpenMM_Vec3Array_get(const OpenMM_Vec3Array* array, int index);
/* OpenMM_StringArray */
extern OPENMM_EXPORT OpenMM_StringArray* OpenMM_StringArray_create(int size);
extern OPENMM_EXPORT void OpenMM_StringArray_destroy(OpenMM_StringArray* array);
extern OPENMM_EXPORT int OpenMM_StringArray_getSize(const OpenMM_StringArray* array);
extern OPENMM_EXPORT void OpenMM_StringArray_resize(OpenMM_StringArray* array, int size);
extern OPENMM_EXPORT void OpenMM_StringArray_append(OpenMM_StringArray* array, const char* string);
extern OPENMM_EXPORT void OpenMM_StringArray_set(OpenMM_StringArray* array, int index, const char* string);
extern OPENMM_EXPORT const char* OpenMM_StringArray_get(const OpenMM_StringArray* array, int index);
/* OpenMM_BondArray */
extern OPENMM_EXPORT OpenMM_BondArray* OpenMM_BondArray_create(int size);
extern OPENMM_EXPORT void OpenMM_BondArray_destroy(OpenMM_BondArray* array);
extern OPENMM_EXPORT int OpenMM_BondArray_getSize(const OpenMM_BondArray* array);
extern OPENMM_EXPORT void OpenMM_BondArray_resize(OpenMM_BondArray* array, int size);
extern OPENMM_EXPORT void OpenMM_BondArray_append(OpenMM_BondArray* array, int particle1, int particle2);
extern OPENMM_EXPORT void OpenMM_BondArray_set(OpenMM_BondArray* array, int index, int particle1, int particle2);
extern OPENMM_EXPORT void OpenMM_BondArray_get(const OpenMM_BondArray* array, int index, int* particle1, int* particle2);
/* OpenMM_ParameterArray */
extern OPENMM_EXPORT int OpenMM_ParameterArray_getSize(const OpenMM_ParameterArray* array);
extern OPENMM_EXPORT double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* array, const char* name);
/* OpenMM_PropertyArray */
extern OPENMM_EXPORT int OpenMM_PropertyArray_getSize(const OpenMM_PropertyArray* array);
extern OPENMM_EXPORT const char* OpenMM_PropertyArray_get(const OpenMM_PropertyArray* array, const char* name);
<xsl:call-template name="primitive_array">
<xsl:with-param name="element_type" select="'double'"/>
<xsl:with-param name="name" select="'OpenMM_DoubleArray'"/>
</xsl:call-template>
<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>
<xsl:call-template name="primitive_set">
<xsl:with-param name="element_type" select="'int'"/>
<xsl:with-param name="name" select="'OpenMM_IntSet'"/>
</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. */
extern OPENMM_EXPORT OpenMM_State* OpenMM_Context_getState(const OpenMM_Context* target, int types, int enforcePeriodicBox);
extern OPENMM_EXPORT OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directory);
<!-- 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 /*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 the declarations for a (Primitive)Set type -->
<xsl:template name="primitive_set">
<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();
extern OPENMM_EXPORT void <xsl:value-of select="$name"/>_destroy(<xsl:value-of select="$name"/>* set);
extern OPENMM_EXPORT int <xsl:value-of select="$name"/>_getSize(const <xsl:value-of select="$name"/>* set);
extern OPENMM_EXPORT void <xsl:value-of select="$name"/>_insert(<xsl:value-of select="$name"/>* set, <xsl:value-of select="$element_type"/> value);
</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_bond_type_id">
<xsl:value-of select="'OpenMM_BondArray'"/>
</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="$type_id=$set_int_type_id">
<xsl:value-of select="'OpenMM_IntSet'"/>
</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="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="set_int_type_id" select="/GCC_XML/Class[starts-with(@name, 'set&lt;int')]/@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', 'OpenMM_Context_createCheckpoint', 'OpenMM_Context_loadCheckpoint')"/>
<!-- 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 "OpenMMCWrapper.h"
#include &lt;cstring&gt;
#include &lt;vector&gt;
using namespace OpenMM;
using namespace std;
extern "C" {
/* OpenMM_Vec3 */
OPENMM_EXPORT OpenMM_Vec3 OpenMM_Vec3_scale(const OpenMM_Vec3 vec, double scale) {
OpenMM_Vec3 result = {vec.x*scale, vec.y*scale, vec.z*scale};
return result;
}
/* OpenMM_Vec3Array */
OPENMM_EXPORT OpenMM_Vec3Array* OpenMM_Vec3Array_create(int size) {
return reinterpret_cast&lt;OpenMM_Vec3Array*&gt;(new vector&lt;Vec3&gt;(size));
}
OPENMM_EXPORT void OpenMM_Vec3Array_destroy(OpenMM_Vec3Array* array) {
delete reinterpret_cast&lt;vector&lt;Vec3&gt;*&gt;(array);
}
OPENMM_EXPORT int OpenMM_Vec3Array_getSize(const OpenMM_Vec3Array* array) {
return reinterpret_cast&lt;const vector&lt;Vec3&gt;*&gt;(array)->size();
}
OPENMM_EXPORT void OpenMM_Vec3Array_resize(OpenMM_Vec3Array* array, int size) {
reinterpret_cast&lt;vector&lt;Vec3&gt;*&gt;(array)->resize(size);
}
OPENMM_EXPORT void OpenMM_Vec3Array_append(OpenMM_Vec3Array* array, const OpenMM_Vec3 vec) {
reinterpret_cast&lt;vector&lt;Vec3&gt;*&gt;(array)->push_back(Vec3(vec.x, vec.y, vec.z));
}
OPENMM_EXPORT void OpenMM_Vec3Array_set(OpenMM_Vec3Array* array, int index, const OpenMM_Vec3 vec) {
(*reinterpret_cast&lt;vector&lt;Vec3&gt;*&gt;(array))[index] = Vec3(vec.x, vec.y, vec.z);
}
OPENMM_EXPORT const OpenMM_Vec3* OpenMM_Vec3Array_get(const OpenMM_Vec3Array* array, int index) {
return reinterpret_cast&lt;const OpenMM_Vec3*&gt;((&amp;(*reinterpret_cast&lt;const vector&lt;Vec3&gt;*&gt;(array))[index]));
}
/* OpenMM_StringArray */
OPENMM_EXPORT OpenMM_StringArray* OpenMM_StringArray_create(int size) {
return reinterpret_cast&lt;OpenMM_StringArray*&gt;(new vector&lt;string&gt;(size));
}
OPENMM_EXPORT void OpenMM_StringArray_destroy(OpenMM_StringArray* array) {
delete reinterpret_cast&lt;vector&lt;string&gt;*&gt;(array);
}
OPENMM_EXPORT int OpenMM_StringArray_getSize(const OpenMM_StringArray* array) {
return reinterpret_cast&lt;const vector&lt;string&gt;*&gt;(array)->size();
}
OPENMM_EXPORT void OpenMM_StringArray_resize(OpenMM_StringArray* array, int size) {
reinterpret_cast&lt;vector&lt;string&gt;*&gt;(array)->resize(size);
}
OPENMM_EXPORT void OpenMM_StringArray_append(OpenMM_StringArray* array, const char* str) {
reinterpret_cast&lt;vector&lt;string&gt;*&gt;(array)->push_back(string(str));
}
OPENMM_EXPORT void OpenMM_StringArray_set(OpenMM_StringArray* array, int index, const char* str) {
(*reinterpret_cast&lt;vector&lt;string&gt;*&gt;(array))[index] = string(str);
}
OPENMM_EXPORT const char* OpenMM_StringArray_get(const OpenMM_StringArray* array, int index) {
return (*reinterpret_cast&lt;const vector&lt;string&gt;*&gt;(array))[index].c_str();
}
/* OpenMM_BondArray */
OPENMM_EXPORT OpenMM_BondArray* OpenMM_BondArray_create(int size) {
return reinterpret_cast&lt;OpenMM_BondArray*&gt;(new vector&lt;pair&lt;int, int&gt; &gt;(size));
}
OPENMM_EXPORT void OpenMM_BondArray_destroy(OpenMM_BondArray* array) {
delete reinterpret_cast&lt;vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array);
}
OPENMM_EXPORT int OpenMM_BondArray_getSize(const OpenMM_BondArray* array) {
return reinterpret_cast&lt;const vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array)->size();
}
OPENMM_EXPORT void OpenMM_BondArray_resize(OpenMM_BondArray* array, int size) {
reinterpret_cast&lt;vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array)->resize(size);
}
OPENMM_EXPORT void OpenMM_BondArray_append(OpenMM_BondArray* array, int particle1, int particle2) {
reinterpret_cast&lt;vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array)->push_back(pair&lt;int, int&gt;(particle1, particle2));
}
OPENMM_EXPORT void OpenMM_BondArray_set(OpenMM_BondArray* array, int index, int particle1, int particle2) {
(*reinterpret_cast&lt;vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array))[index] = pair&lt;int, int&gt;(particle1, particle2);
}
OPENMM_EXPORT void OpenMM_BondArray_get(const OpenMM_BondArray* array, int index, int* particle1, int* particle2) {
pair&lt;int, int&gt; particles = (*reinterpret_cast&lt;const vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array))[index];
*particle1 = particles.first;
*particle2 = particles.second;
}
/* OpenMM_ParameterArray */
OPENMM_EXPORT int OpenMM_ParameterArray_getSize(const OpenMM_ParameterArray* array) {
return reinterpret_cast&lt;const map&lt;string, double&gt;*&gt;(array)->size();
}
OPENMM_EXPORT double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* array, const char* name) {
const map&lt;string, double&gt;* params = reinterpret_cast&lt;const map&lt;string, double&gt;*&gt;(array);
const map&lt;string, double&gt;::const_iterator iter = params->find(string(name));
if (iter == params->end())
throw OpenMMException("OpenMM_ParameterArray_get: No such parameter");
return iter->second;
}
/* OpenMM_PropertyArray */
OPENMM_EXPORT int OpenMM_PropertyArray_getSize(const OpenMM_PropertyArray* array) {
return reinterpret_cast&lt;const map&lt;string, double&gt;*&gt;(array)->size();
}
OPENMM_EXPORT const char* OpenMM_PropertyArray_get(const OpenMM_PropertyArray* array, const char* name) {
const map&lt;string, string&gt;* params = reinterpret_cast&lt;const map&lt;string, string&gt;*&gt;(array);
const map&lt;string, string&gt;::const_iterator iter = params->find(string(name));
if (iter == params->end())
throw OpenMMException("OpenMM_PropertyArray_get: No such property");
return iter->second.c_str();
}
<xsl:call-template name="primitive_array">
<xsl:with-param name="element_type" select="'double'"/>
<xsl:with-param name="name" select="'OpenMM_DoubleArray'"/>
</xsl:call-template>
<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>
<xsl:call-template name="primitive_set">
<xsl:with-param name="element_type" select="'int'"/>
<xsl:with-param name="name" select="'OpenMM_IntSet'"/>
</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 OpenMM_State* OpenMM_Context_getState(const OpenMM_Context* target, int types, int enforcePeriodicBox) {
State result = reinterpret_cast&lt;const Context*&gt;(target)->getState(types, enforcePeriodicBox);
return reinterpret_cast&lt;OpenMM_State*&gt;(new State(result));
};
OPENMM_EXPORT OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directory) {
vector&lt;string&gt; result = Platform::loadPluginsFromDirectory(string(directory));
return reinterpret_cast&lt;OpenMM_StringArray*&gt;(new vector&lt;string&gt;(result));
};
<!-- 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 <xsl:value-of select="concat($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];
}
</xsl:template>
<!-- Print out the definitions for a (Primitive)Set type -->
<xsl:template name="primitive_set">
<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() {
return reinterpret_cast&lt;<xsl:value-of select="$name"/>*&gt;(new set&lt;<xsl:value-of select="$element_type"/>&gt;());
}
OPENMM_EXPORT void <xsl:value-of select="$name"/>_destroy(<xsl:value-of select="$name"/>* s) {
delete reinterpret_cast&lt;set&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(s);
}
OPENMM_EXPORT int <xsl:value-of select="$name"/>_getSize(const <xsl:value-of select="$name"/>* s) {
return reinterpret_cast&lt;const set&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(s)->size();
}
OPENMM_EXPORT void <xsl:value-of select="$name"/>_insert(<xsl:value-of select="$name"/>* s, <xsl:value-of select="$element_type"/> value) {
reinterpret_cast&lt;set&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(s)->insert(value);
}
</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=$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="$type_id=$set_int_type_id">
<xsl:value-of select="'OpenMM_IntSet'"/>
</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=$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>
# Doxyfile 1.5.9
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project
#
# All text after a hash (#) is considered a comment and will be ignored
# The format is:
# TAG = value [value, ...]
# For lists items can also be appended using:
# TAG += value [value, ...]
# Values that contain spaces should be placed between quotes (" ")
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
# This tag specifies the encoding used for all characters in the config file
# that follow. The default is UTF-8 which is also the encoding used for all
# text before the first occurrence of this tag. Doxygen uses libiconv (or the
# iconv built into libc) for the transcoding. See
# http://www.gnu.org/software/libiconv for the list of possible encodings.
DOXYFILE_ENCODING = UTF-8
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.
PROJECT_NAME =
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER =
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
OUTPUT_DIRECTORY =
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
# 4096 sub-directories (in 2 levels) under the output directory of each output
# format and will distribute the generated files over these directories.
# Enabling this option can be useful when feeding doxygen a huge amount of
# source files, where putting all generated files in the same directory would
# otherwise cause performance problems for the file system.
CREATE_SUBDIRS = NO
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
# documentation generated by doxygen is written. Doxygen will use this
# information to generate all constant output in the proper language.
# The default language is English, other supported languages are:
# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
OUTPUT_LANGUAGE = English
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
# include brief member descriptions after the members that are listed in
# the file and class documentation (similar to JavaDoc).
# Set to NO to disable this.
BRIEF_MEMBER_DESC = YES
# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
# the brief description of a member or function before the detailed description.
# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
# brief descriptions will be completely suppressed.
REPEAT_BRIEF = YES
# This tag implements a quasi-intelligent brief description abbreviator
# that is used to form the text in various listings. Each string
# in this list, if found as the leading text of the brief description, will be
# stripped from the text and the result after processing the whole list, is
# used as the annotated text. Otherwise, the brief description is used as-is.
# If left blank, the following values are used ("$name" is automatically
# replaced with the name of the entity): "The $name class" "The $name widget"
# "The $name file" "is" "provides" "specifies" "contains"
# "represents" "a" "an" "the"
ABBREVIATE_BRIEF =
# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
# Doxygen will generate a detailed section even if there is only a brief
# description.
ALWAYS_DETAILED_SEC = NO
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
# inherited members of a class in the documentation of that class as if those
# members were ordinary class members. Constructors, destructors and assignment
# operators of the base classes will not be shown.
INLINE_INHERITED_MEMB = NO
# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
# path before files name in the file list and in the header files. If set
# to NO the shortest path that makes the file name unique will be used.
FULL_PATH_NAMES = YES
# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
# can be used to strip a user-defined part of the path. Stripping is
# only done if one of the specified strings matches the left-hand part of
# the path. The tag can be used to show relative paths in the file list.
# If left blank the directory from which doxygen is run is used as the
# path to strip.
STRIP_FROM_PATH =
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
# the path mentioned in the documentation of a class, which tells
# the reader which header file to include in order to use a class.
# If left blank only the name of the header file containing the class
# definition is used. Otherwise one should specify the include paths that
# are normally passed to the compiler using the -I flag.
STRIP_FROM_INC_PATH =
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
# (but less readable) file names. This can be useful is your file systems
# doesn't support long names like on DOS, Mac, or CD-ROM.
SHORT_NAMES = NO
# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
# will interpret the first line (until the first dot) of a JavaDoc-style
# comment as the brief description. If set to NO, the JavaDoc
# comments will behave just like regular Qt-style comments
# (thus requiring an explicit @brief command for a brief description.)
JAVADOC_AUTOBRIEF = NO
# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
# interpret the first line (until the first dot) of a Qt-style
# comment as the brief description. If set to NO, the comments
# will behave just like regular Qt-style comments (thus requiring
# an explicit \brief command for a brief description.)
QT_AUTOBRIEF = NO
# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
# treat a multi-line C++ special comment block (i.e. a block of //! or ///
# comments) as a brief description. This used to be the default behaviour.
# The new default is to treat a multi-line C++ comment block as a detailed
# description. Set this tag to YES if you prefer the old behaviour instead.
MULTILINE_CPP_IS_BRIEF = NO
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
# member inherits the documentation from any documented member that it
# re-implements.
INHERIT_DOCS = YES
# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
# a new page for each member. If set to NO, the documentation of a member will
# be part of the file/class/namespace that contains it.
SEPARATE_MEMBER_PAGES = NO
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
# Doxygen uses this value to replace tabs by spaces in code fragments.
TAB_SIZE = 8
# This tag can be used to specify a number of aliases that acts
# as commands in the documentation. An alias has the form "name=value".
# For example adding "sideeffect=\par Side Effects:\n" will allow you to
# put the command \sideeffect (or @sideeffect) in the documentation, which
# will result in a user-defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines.
ALIASES =
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
# sources only. Doxygen will then generate output that is more tailored for C.
# For instance, some of the names that are used will be different. The list
# of all members will be omitted, etc.
OPTIMIZE_OUTPUT_FOR_C = NO
# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
# sources only. Doxygen will then generate output that is more tailored for
# Java. For instance, namespaces will be presented as packages, qualified
# scopes will look different, etc.
OPTIMIZE_OUTPUT_JAVA = NO
# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
# sources only. Doxygen will then generate output that is more tailored for
# Fortran.
OPTIMIZE_FOR_FORTRAN = NO
# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
# sources. Doxygen will then generate output that is tailored for
# VHDL.
OPTIMIZE_OUTPUT_VHDL = NO
# Doxygen selects the parser to use depending on the extension of the files it parses.
# With this tag you can assign which parser to use for a given extension.
# Doxygen has a built-in mapping, but you can override or extend it using this tag.
# The format is ext=language, where ext is a file extension, and language is one of
# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
EXTENSION_MAPPING =
# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
# to include (a tag file for) the STL sources as input, then you should
# set this tag to YES in order to let doxygen match functions declarations and
# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
# func(std::string) {}). This also make the inheritance and collaboration
# diagrams that involve STL classes more complete and accurate.
BUILTIN_STL_SUPPORT = NO
# If you use Microsoft's C++/CLI language, you should set this option to YES to
# enable parsing support.
CPP_CLI_SUPPORT = NO
# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
# Doxygen will parse them like normal C++ but will assume all classes use public
# instead of private inheritance when no explicit protection keyword is present.
SIP_SUPPORT = NO
# For Microsoft's IDL there are propget and propput attributes to indicate getter
# and setter methods for a property. Setting this option to YES (the default)
# will make doxygen to replace the get and set methods by a property in the
# documentation. This will only work if the methods are indeed getting or
# setting a simple type. If this is not the case, or you want to show the
# methods anyway, you should set this option to NO.
IDL_PROPERTY_SUPPORT = YES
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
# tag is set to YES, then doxygen will reuse the documentation of the first
# member in the group (if any) for the other members of the group. By default
# all members of a group must be documented explicitly.
DISTRIBUTE_GROUP_DOC = NO
# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
# the same type (for instance a group of public functions) to be put as a
# subgroup of that type (e.g. under the Public Functions section). Set it to
# NO to prevent subgrouping. Alternatively, this can be done per class using
# the \nosubgrouping command.
SUBGROUPING = YES
# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
# is documented as struct, union, or enum with the name of the typedef. So
# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
# with name TypeT. When disabled the typedef will appear as a member of a file,
# namespace, or class. And the struct will be named TypeS. This can typically
# be useful for C code in case the coding convention dictates that all compound
# types are typedef'ed and only the typedef is referenced, never the tag name.
TYPEDEF_HIDES_STRUCT = NO
# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
# determine which symbols to keep in memory and which to flush to disk.
# When the cache is full, less often used symbols will be written to disk.
# For small to medium size projects (<1000 input files) the default value is
# probably good enough. For larger projects a too small cache size can cause
# doxygen to be busy swapping symbols to and from disk most of the time
# causing a significant performance penality.
# If the system has enough physical memory increasing the cache will improve the
# performance by keeping more symbols in memory. Note that the value works on
# a logarithmic scale so increasing the size by one will rougly double the
# memory usage. The cache size is given by this formula:
# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
# corresponding to a cache size of 2^16 = 65536 symbols
SYMBOL_CACHE_SIZE = 0
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
# documentation are documented, even if no documentation was available.
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
EXTRACT_ALL = YES
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
EXTRACT_PRIVATE = NO
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
EXTRACT_STATIC = NO
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
# defined locally in source files will be included in the documentation.
# If set to NO only classes defined in header files are included.
EXTRACT_LOCAL_CLASSES = YES
# This flag is only useful for Objective-C code. When set to YES local
# methods, which are defined in the implementation section but not in
# the interface are included in the documentation.
# If set to NO (the default) only methods in the interface are included.
EXTRACT_LOCAL_METHODS = NO
# If this flag is set to YES, the members of anonymous namespaces will be
# extracted and appear in the documentation as a namespace called
# 'anonymous_namespace{file}', where file will be replaced with the base
# name of the file that contains the anonymous namespace. By default
# anonymous namespace are hidden.
EXTRACT_ANON_NSPACES = NO
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
# undocumented members of documented classes, files or namespaces.
# If set to NO (the default) these members will be included in the
# various overviews, but no documentation section is generated.
# This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_MEMBERS = NO
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy.
# If set to NO (the default) these classes will be included in the various
# overviews. This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_CLASSES = NO
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
# friend (class|struct|union) declarations.
# If set to NO (the default) these declarations will be included in the
# documentation.
HIDE_FRIEND_COMPOUNDS = NO
# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
# documentation blocks found inside the body of a function.
# If set to NO (the default) these blocks will be appended to the
# function's detailed documentation block.
HIDE_IN_BODY_DOCS = NO
# The INTERNAL_DOCS tag determines if documentation
# that is typed after a \internal command is included. If the tag is set
# to NO (the default) then the documentation will be excluded.
# Set it to YES to include the internal documentation.
INTERNAL_DOCS = NO
# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
# file names in lower-case letters. If set to YES upper-case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
# and Mac users are advised to set this option to NO.
CASE_SENSE_NAMES = YES
# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
# will show members with their full class and namespace scopes in the
# documentation. If set to YES the scope will be hidden.
HIDE_SCOPE_NAMES = NO
# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
# will put a list of the files that are included by a file in the documentation
# of that file.
SHOW_INCLUDE_FILES = YES
# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
# is inserted in the documentation for inline members.
INLINE_INFO = YES
# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
# will sort the (detailed) documentation of file and class members
# alphabetically by member name. If set to NO the members will appear in
# declaration order.
SORT_MEMBER_DOCS = YES
# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
# brief documentation of file, namespace and class members alphabetically
# by member name. If set to NO (the default) the members will appear in
# declaration order.
SORT_BRIEF_DOCS = NO
# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
# hierarchy of group names into alphabetical order. If set to NO (the default)
# the group names will appear in their defined order.
SORT_GROUP_NAMES = NO
# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
# sorted by fully-qualified names, including namespaces. If set to
# NO (the default), the class list will be sorted only by class name,
# not including the namespace part.
# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
# Note: This option applies only to the class list, not to the
# alphabetical list.
SORT_BY_SCOPE_NAME = NO
# The GENERATE_TODOLIST tag can be used to enable (YES) or
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
GENERATE_TODOLIST = YES
# The GENERATE_TESTLIST tag can be used to enable (YES) or
# disable (NO) the test list. This list is created by putting \test
# commands in the documentation.
GENERATE_TESTLIST = YES
# The GENERATE_BUGLIST tag can be used to enable (YES) or
# disable (NO) the bug list. This list is created by putting \bug
# commands in the documentation.
GENERATE_BUGLIST = YES
# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
# disable (NO) the deprecated list. This list is created by putting
# \deprecated commands in the documentation.
GENERATE_DEPRECATEDLIST= YES
# The ENABLED_SECTIONS tag can be used to enable conditional
# documentation sections, marked by \if sectionname ... \endif.
ENABLED_SECTIONS =
# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
# the initial value of a variable or define consists of for it to appear in
# the documentation. If the initializer consists of more lines than specified
# here it will be hidden. Use a value of 0 to hide initializers completely.
# The appearance of the initializer of individual variables and defines in the
# documentation can be controlled using \showinitializer or \hideinitializer
# command in the documentation regardless of this setting.
MAX_INITIALIZER_LINES = 30
# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
# at the bottom of the documentation of classes and structs. If set to YES the
# list will mention the files that were used to generate the documentation.
SHOW_USED_FILES = YES
# If the sources in your project are distributed over multiple directories
# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
# in the documentation. The default is NO.
SHOW_DIRECTORIES = NO
# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
# This will remove the Files entry from the Quick Index and from the
# Folder Tree View (if specified). The default is YES.
SHOW_FILES = YES
# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
# Namespaces page.
# This will remove the Namespaces entry from the Quick Index
# and from the Folder Tree View (if specified). The default is YES.
SHOW_NAMESPACES = YES
# The FILE_VERSION_FILTER tag can be used to specify a program or script that
# doxygen should invoke to get the current version for each file (typically from
# the version control system). Doxygen will invoke the program by executing (via
# popen()) the command <command> <input-file>, where <command> is the value of
# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
# provided by doxygen. Whatever the program writes to standard output
# is used as the file version. See the manual for examples.
FILE_VERSION_FILTER =
# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
# doxygen. The layout file controls the global structure of the generated output files
# in an output format independent way. The create the layout file that represents
# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
# file name after the option, if omitted DoxygenLayout.xml will be used as the name
# of the layout file.
LAYOUT_FILE =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
# The QUIET tag can be used to turn on/off the messages that are generated
# by doxygen. Possible values are YES and NO. If left blank NO is used.
QUIET = NO
# The WARNINGS tag can be used to turn on/off the warning messages that are
# generated by doxygen. Possible values are YES and NO. If left blank
# NO is used.
WARNINGS = NO
# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
# automatically be disabled.
WARN_IF_UNDOCUMENTED = NO
# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
# potential errors in the documentation, such as not documenting some
# parameters in a documented function, or documenting parameters that
# don't exist or using markup commands wrongly.
WARN_IF_DOC_ERROR = NO
# This WARN_NO_PARAMDOC option can be abled to get warnings for
# functions that are documented, but have no documentation for their parameters
# or return value. If set to NO (the default) doxygen will only warn about
# wrong or incomplete parameter documentation, but not about the absence of
# documentation.
WARN_NO_PARAMDOC = NO
# The WARN_FORMAT tag determines the format of the warning messages that
# doxygen can produce. The string should contain the $file, $line, and $text
# tags, which will be replaced by the file and line number from which the
# warning originated and the warning text. Optionally the format may contain
# $version, which will be replaced by the version of the file (if it could
# be obtained via FILE_VERSION_FILTER)
WARN_FORMAT = "$file:$line: $text"
# The WARN_LOGFILE tag can be used to specify a file to which warning
# and error messages should be written. If left blank the output is written
# to stderr.
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
# The INPUT tag can be used to specify the files and/or directories that contain
# documented source files. You may enter file names like "myfile.cpp" or
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = "@CMAKE_SOURCE_DIR@/openmmapi" \
"@CMAKE_SOURCE_DIR@/olla/include/openmm/Platform.h"
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
# also the default input encoding. Doxygen uses libiconv (or the iconv built
# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
# the list of possible encodings.
INPUT_ENCODING = UTF-8
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank the following patterns are tested:
# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
FILE_PATTERNS =
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
# If left blank NO is used.
RECURSIVE = YES
# The EXCLUDE tag can be used to specify files and/or directories that should
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE =
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
# directories that are symbolic links (a Unix filesystem feature) are excluded
# from the input.
EXCLUDE_SYMLINKS = NO
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
# certain files from those directories. Note that the wildcards are matched
# against the file with absolute path, so to exclude all test directories
# for example use the pattern */test/*
EXCLUDE_PATTERNS = */tests/* \
*/openmmapi/src/* \
*/internal/* \
*/.svn/* \
*amoebaKernels.h \
*DrudeKernels.h \
*RpmdKernels.h \
*OpenMMFortranModule.f90 \
*OpenMMCWrapper.h
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
# output. The symbol name can be a fully qualified name, a word, or if the
# wildcard * is used, a substring. Examples: ANamespace, AClass,
# AClass::ANamespace, ANamespace::*Test
EXCLUDE_SYMBOLS = GBSAOBCForceField::AtomInfo \
System::ConstraintInfo
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
# the \include command).
EXAMPLE_PATH =
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
EXAMPLE_PATTERNS =
# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
# searched for input files to be used with the \include or \dontinclude
# commands irrespective of the value of the RECURSIVE tag.
# Possible values are YES and NO. If left blank NO is used.
EXAMPLE_RECURSIVE = NO
# The IMAGE_PATH tag can be used to specify one or more files or
# directories that contain image that are included in the documentation (see
# the \image command).
IMAGE_PATH =
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
# by executing (via popen()) the command <filter> <input-file>, where <filter>
# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
# input file. Doxygen will then use the output that the filter program writes
# to standard output.
# If FILTER_PATTERNS is specified, this tag will be
# ignored.
INPUT_FILTER =
# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
# basis.
# Doxygen will compare the file name with each pattern and apply the
# filter if there is a match.
# The filters are a list of the form:
# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
# is applied to all files.
FILTER_PATTERNS =
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
# INPUT_FILTER) will be used to filter the input files when producing source
# files to browse (i.e. when SOURCE_BROWSER is set to YES).
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
# be generated. Documented entities will be cross-referenced with these sources.
# Note: To get rid of all source code in the generated output, make sure also
# VERBATIM_HEADERS is set to NO.
SOURCE_BROWSER = NO
# Setting the INLINE_SOURCES tag to YES will include the body
# of functions and classes directly in the documentation.
INLINE_SOURCES = NO
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
# doxygen to hide any special comment blocks from generated source code
# fragments. Normal C and C++ comments will always remain visible.
STRIP_CODE_COMMENTS = YES
# If the REFERENCED_BY_RELATION tag is set to YES
# then for each documented function all documented
# functions referencing it will be listed.
REFERENCED_BY_RELATION = NO
# If the REFERENCES_RELATION tag is set to YES
# then for each documented function all documented entities
# called/used by that function will be listed.
REFERENCES_RELATION = NO
# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
# link to the source code.
# Otherwise they will link to the documentation.
REFERENCES_LINK_SOURCE = YES
# If the USE_HTAGS tag is set to YES then the references to source code
# will point to the HTML generated by the htags(1) tool instead of doxygen
# built-in source browser. The htags tool is part of GNU's global source
# tagging system (see http://www.gnu.org/software/global/global.html). You
# will need version 4.8.6 or higher.
USE_HTAGS = NO
# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
# will generate a verbatim copy of the header file for each class for
# which an include is specified. Set to NO to disable this.
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
# of all compounds will be generated. Enable this if the project
# contains a lot of classes, structs, unions or interfaces.
ALPHABETICAL_INDEX = NO
# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
# in which this list will be split (can be a number in the range [1..20])
COLS_IN_ALPHA_INDEX = 5
# In case all classes in a project start with a common prefix, all
# classes will be put under the same header in the alphabetical index.
# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
# should be ignored while generating the index headers.
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
# generate HTML output.
GENERATE_HTML = NO
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `html' will be used as the default path.
HTML_OUTPUT = html
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
# doxygen will generate files with .html extension.
HTML_FILE_EXTENSION = .html
# The HTML_HEADER tag can be used to specify a personal HTML header for
# each generated HTML page. If it is left blank doxygen will generate a
# standard header.
HTML_HEADER =
# The HTML_FOOTER tag can be used to specify a personal HTML footer for
# each generated HTML page. If it is left blank doxygen will generate a
# standard footer.
HTML_FOOTER =
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
# style sheet that is used by each HTML page. It can be used to
# fine-tune the look of the HTML output. If the tag is left blank doxygen
# will generate a default style sheet. Note that doxygen will try to copy
# the style sheet file to the HTML output directory, so don't put your own
# stylesheet in the HTML output directory as well, or it will be erased!
HTML_STYLESHEET =
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
# files or namespaces will be aligned in HTML using tables. If set to
# NO a bullet list will be used.
HTML_ALIGN_MEMBERS = YES
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
# documentation will contain sections that can be hidden and shown after the
# page has loaded. For this to work a browser that supports
# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
HTML_DYNAMIC_SECTIONS = NO
# If the GENERATE_DOCSET tag is set to YES, additional index files
# will be generated that can be used as input for Apple's Xcode 3
# integrated development environment, introduced with OSX 10.5 (Leopard).
# To create a documentation set, doxygen will generate a Makefile in the
# HTML output directory. Running make will produce the docset in that
# directory and running "make install" will install the docset in
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
# it at startup.
# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
GENERATE_DOCSET = NO
# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
# feed. A documentation feed provides an umbrella under which multiple
# documentation sets from a single provider (such as a company or product suite)
# can be grouped.
DOCSET_FEEDNAME = "Doxygen generated docs"
# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
# should uniquely identify the documentation set bundle. This should be a
# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
# will append .docset to the name.
DOCSET_BUNDLE_ID = org.doxygen.Project
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
# will be generated that can be used as input for tools like the
# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
# of the generated HTML documentation.
GENERATE_HTMLHELP = NO
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
# be used to specify the file name of the resulting .chm file. You
# can add a path in front of the file if the result should not be
# written to the html output directory.
CHM_FILE =
# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
# be used to specify the location (absolute path including file name) of
# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
# the HTML help compiler on the generated index.hhp.
HHC_LOCATION =
# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
# controls if a separate .chi index file is generated (YES) or that
# it should be included in the master .chm file (NO).
GENERATE_CHI = NO
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
# is used to encode HtmlHelp index (hhk), content (hhc) and project file
# content.
CHM_INDEX_ENCODING =
# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
# controls whether a binary table of contents is generated (YES) or a
# normal table of contents (NO) in the .chm file.
BINARY_TOC = NO
# The TOC_EXPAND flag can be set to YES to add extra items for group members
# to the contents of the HTML help documentation and to the tree view.
TOC_EXPAND = NO
# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
# are set, an additional index file will be generated that can be used as input for
# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
# HTML documentation.
GENERATE_QHP = NO
# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
# be used to specify the file name of the resulting .qch file.
# The path specified is relative to the HTML output folder.
QCH_FILE =
# The QHP_NAMESPACE tag specifies the namespace to use when generating
# Qt Help Project output. For more information please see
# http://doc.trolltech.com/qthelpproject.html#namespace
QHP_NAMESPACE =
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
# Qt Help Project output. For more information please see
# http://doc.trolltech.com/qthelpproject.html#virtual-folders
QHP_VIRTUAL_FOLDER = doc
# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
# For more information please see
# http://doc.trolltech.com/qthelpproject.html#custom-filters
QHP_CUST_FILTER_NAME =
# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
QHP_CUST_FILTER_ATTRS =
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
# filter section matches.
# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
QHP_SECT_FILTER_ATTRS =
# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
# be used to specify the location of Qt's qhelpgenerator.
# If non-empty doxygen will try to run qhelpgenerator on the generated
# .qhp file.
QHG_LOCATION =
# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
# top of each HTML page. The value NO (the default) enables the index and
# the value YES disables it.
DISABLE_INDEX = NO
# This tag can be used to set the number of enum values (range [1..20])
# that doxygen will group on one line in the generated HTML documentation.
ENUM_VALUES_PER_LINE = 4
# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
# structure should be generated to display hierarchical information.
# If the tag value is set to FRAME, a side panel will be generated
# containing a tree-like index structure (just like the one that
# is generated for HTML Help). For this to work a browser that supports
# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
# probably better off using the HTML help feature. Other possible values
# for this tag are: HIERARCHIES, which will generate the Groups, Directories,
# and Class Hierarchy pages using a tree view instead of an ordered list;
# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which
# disables this behavior completely. For backwards compatibility with previous
# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE
# respectively.
GENERATE_TREEVIEW = NONE
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
# used to set the initial width (in pixels) of the frame in which the tree
# is shown.
TREEVIEW_WIDTH = 250
# Use this tag to change the font size of Latex formulas included
# as images in the HTML documentation. The default is 10. Note that
# when you change the font size after a successful doxygen run you need
# to manually remove any form_*.png images from the HTML output directory
# to force them to be regenerated.
FORMULA_FONTSIZE = 10
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
# generate Latex output.
GENERATE_LATEX = NO
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `latex' will be used as the default path.
LATEX_OUTPUT = latex
# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
# invoked. If left blank `latex' will be used as the default command name.
LATEX_CMD_NAME = latex
# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
# generate index for LaTeX. If left blank `makeindex' will be used as the
# default command name.
MAKEINDEX_CMD_NAME = makeindex
# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
# LaTeX documents. This may be useful for small projects and may help to
# save some trees in general.
COMPACT_LATEX = NO
# The PAPER_TYPE tag can be used to set the paper type that is used
# by the printer. Possible values are: a4, a4wide, letter, legal and
# executive. If left blank a4wide will be used.
PAPER_TYPE = a4wide
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
# packages that should be included in the LaTeX output.
EXTRA_PACKAGES =
# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
# the generated latex document. The header should contain everything until
# the first chapter. If it is left blank doxygen will generate a
# standard header. Notice: only use this tag if you know what you are doing!
LATEX_HEADER =
# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
# is prepared for conversion to pdf (using ps2pdf). The pdf file will
# contain links (just like the HTML output) instead of page references
# This makes the output suitable for online browsing using a pdf viewer.
PDF_HYPERLINKS = YES
# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
# plain latex in the generated Makefile. Set this option to YES to get a
# higher quality PDF documentation.
USE_PDFLATEX = YES
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
# command to the generated LaTeX files. This will instruct LaTeX to keep
# running if errors occur, instead of asking the user for help.
# This option is also used when generating formulas in HTML.
LATEX_BATCHMODE = NO
# If LATEX_HIDE_INDICES is set to YES then doxygen will not
# include the index chapters (such as File Index, Compound Index, etc.)
# in the output.
LATEX_HIDE_INDICES = NO
# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
LATEX_SOURCE_CODE = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
# The RTF output is optimized for Word 97 and may not look very pretty with
# other RTF readers or editors.
GENERATE_RTF = NO
# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `rtf' will be used as the default path.
RTF_OUTPUT = rtf
# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
# RTF documents. This may be useful for small projects and may help to
# save some trees in general.
COMPACT_RTF = NO
# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
# will contain hyperlink fields. The RTF file will
# contain links (just like the HTML output) instead of page references.
# This makes the output suitable for online browsing using WORD or other
# programs which support those fields.
# Note: wordpad (write) and others do not support links.
RTF_HYPERLINKS = NO
# Load stylesheet definitions from file. Syntax is similar to doxygen's
# config file, i.e. a series of assignments. You only have to provide
# replacements, missing definitions are set to their default value.
RTF_STYLESHEET_FILE =
# Set optional variables used in the generation of an rtf document.
# Syntax is similar to doxygen's config file.
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
# generate man pages
GENERATE_MAN = NO
# The MAN_OUTPUT tag is used to specify where the man pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `man' will be used as the default path.
MAN_OUTPUT = man
# The MAN_EXTENSION tag determines the extension that is added to
# the generated man pages (default is the subroutine's section .3)
MAN_EXTENSION = .3
# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
# then it will generate one additional man file for each entity
# documented in the real man page(s). These additional files
# only source the real man page, but without them the man command
# would be unable to find the correct page. The default is NO.
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
# If the GENERATE_XML tag is set to YES Doxygen will
# generate an XML file that captures the structure of
# the code including all documentation.
GENERATE_XML = YES
# The XML_OUTPUT tag is used to specify where the XML pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `xml' will be used as the default path.
XML_OUTPUT = xml
# The XML_SCHEMA tag can be used to specify an XML schema,
# which can be used by a validating XML parser to check the
# syntax of the XML files.
XML_SCHEMA =
# The XML_DTD tag can be used to specify an XML DTD,
# which can be used by a validating XML parser to check the
# syntax of the XML files.
XML_DTD =
# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
# dump the program listings (including syntax highlighting
# and cross-referencing information) to the XML output. Note that
# enabling this will significantly increase the size of the XML output.
XML_PROGRAMLISTING = NO
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
# generate an AutoGen Definitions (see autogen.sf.net) file
# that captures the structure of the code including all
# documentation. Note that this feature is still experimental
# and incomplete at the moment.
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
# If the GENERATE_PERLMOD tag is set to YES Doxygen will
# generate a Perl module file that captures the structure of
# the code including all documentation. Note that this
# feature is still experimental and incomplete at the
# moment.
GENERATE_PERLMOD = NO
# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
# the necessary Makefile rules, Perl scripts and LaTeX code to be able
# to generate PDF and DVI output from the Perl module output.
PERLMOD_LATEX = NO
# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
# nicely formatted so it can be parsed by a human reader.
# This is useful
# if you want to understand what is going on.
# On the other hand, if this
# tag is set to NO the size of the Perl module output will be much smaller
# and Perl will parse it just the same.
PERLMOD_PRETTY = YES
# The names of the make variables in the generated doxyrules.make file
# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
# This is useful so different doxyrules.make files included by the same
# Makefile don't overwrite each other's variables.
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
# evaluate all C-preprocessor directives found in the sources and include
# files.
ENABLE_PREPROCESSING = YES
# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
# names in the source code. If set to NO (the default) only conditional
# compilation will be performed. Macro expansion can be done in a controlled
# way by setting EXPAND_ONLY_PREDEF to YES.
MACRO_EXPANSION = YES
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
# PREDEFINED and EXPAND_AS_DEFINED tags.
EXPAND_ONLY_PREDEF = NO
# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
# in the INCLUDE_PATH (see below) will be search if a #include is found.
SEARCH_INCLUDES = YES
# The INCLUDE_PATH tag can be used to specify one or more directories that
# contain include files that are not input files but should be processed by
# the preprocessor.
INCLUDE_PATH =
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
# directories. If left blank, the patterns specified with FILE_PATTERNS will
# be used.
INCLUDE_FILE_PATTERNS =
# The PREDEFINED tag can be used to specify one or more macro names that
# are defined before the preprocessor is started (similar to the -D option of
# gcc). The argument of the tag is a list of macros of the form: name
# or name=definition (no spaces). If the definition and the = are
# omitted =1 is assumed. To prevent a macro definition from being
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.
PREDEFINED = OPENMM_EXPORT
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
# The macro definition that is found in the sources will be used.
# Use the PREDEFINED tag if you want to use a different macro definition.
EXPAND_AS_DEFINED =
# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
# doxygen's preprocessor will remove all function-like macros that are alone
# on a line, have an all uppercase name, and do not end with a semicolon. Such
# function macros are typically used for boiler-plate code, and will confuse
# the parser if not removed.
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
# The TAGFILES option can be used to specify one or more tagfiles.
# Optionally an initial location of the external documentation
# can be added for each tagfile. The format of a tag file without
# this location is as follows:
#
# TAGFILES = file1 file2 ...
# Adding location for the tag files is done as follows:
#
# TAGFILES = file1=loc1 "file2 = loc2" ...
# where "loc1" and "loc2" can be relative or absolute paths or
# URLs. If a location is present for each tag, the installdox tool
# does not have to be run to correct the links.
# Note that each tag file must have a unique name
# (where the name does NOT include the path)
# If a tag file is not located in the directory in which doxygen
# is run, you must also specify the path to the tagfile here.
TAGFILES =
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads.
GENERATE_TAGFILE =
# If the ALLEXTERNALS tag is set to YES all external classes will be listed
# in the class index. If set to NO only the inherited external classes
# will be listed.
ALLEXTERNALS = NO
# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
# in the modules index. If set to NO, only the current project's groups will
# be listed.
EXTERNAL_GROUPS = YES
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of `which perl').
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
# or super classes. Setting the tag to NO turns the diagrams off. Note that
# this option is superseded by the HAVE_DOT option below. This is only a
# fallback. It is recommended to install and use dot, since it yields more
# powerful graphs.
CLASS_DIAGRAMS = YES
# You can define message sequence charts within doxygen comments using the \msc
# command. Doxygen will then run the mscgen tool (see
# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
# documentation. The MSCGEN_PATH tag allows you to specify the directory where
# the mscgen tool resides. If left empty the tool is assumed to be found in the
# default search path.
MSCGEN_PATH =
# If set to YES, the inheritance and collaboration graphs will hide
# inheritance and usage relations if the target is undocumented
# or is not a class.
HIDE_UNDOC_RELATIONS = YES
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz, a graph visualization
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
HAVE_DOT = NO
# By default doxygen will write a font called FreeSans.ttf to the output
# directory and reference it in all dot files that doxygen generates. This
# font does not include all possible unicode characters however, so when you need
# these (or just want a differently looking font) you can specify the font name
# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
# which can be done by putting it in a standard location or by setting the
# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
# containing the font.
DOT_FONTNAME = FreeSans
# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
# The default size is 10pt.
DOT_FONTSIZE = 10
# By default doxygen will tell dot to use the output directory to look for the
# FreeSans.ttf font (which doxygen will put there itself). If you specify a
# different font using DOT_FONTNAME you can set the path where dot
# can find it using this tag.
DOT_FONTPATH =
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect inheritance relations. Setting this tag to YES will force the
# the CLASS_DIAGRAMS tag to NO.
CLASS_GRAPH = YES
# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect implementation dependencies (inheritance, containment, and
# class references variables) of the class with other documented classes.
COLLABORATION_GRAPH = YES
# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for groups, showing the direct groups dependencies
GROUP_GRAPHS = YES
# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
# collaboration diagrams in a style similar to the OMG's Unified Modeling
# Language.
UML_LOOK = NO
# If set to YES, the inheritance and collaboration graphs will show the
# relations between templates and their instances.
TEMPLATE_RELATIONS = NO
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
# tags are set to YES then doxygen will generate a graph for each documented
# file showing the direct and indirect include dependencies of the file with
# other documented files.
INCLUDE_GRAPH = YES
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
# documented header file showing the documented files that directly or
# indirectly include this file.
INCLUDED_BY_GRAPH = YES
# If the CALL_GRAPH and HAVE_DOT options are set to YES then
# doxygen will generate a call dependency graph for every global function
# or class method. Note that enabling this option will significantly increase
# the time of a run. So in most cases it will be better to enable call graphs
# for selected functions only using the \callgraph command.
CALL_GRAPH = NO
# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
# doxygen will generate a caller dependency graph for every global function
# or class method. Note that enabling this option will significantly increase
# the time of a run. So in most cases it will be better to enable caller
# graphs for selected functions only using the \callergraph command.
CALLER_GRAPH = NO
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
# will graphical hierarchy of all classes instead of a textual one.
GRAPHICAL_HIERARCHY = YES
# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
# then doxygen will show the dependencies a directory has on other directories
# in a graphical way. The dependency relations are determined by the #include
# relations between the files in the directories.
DIRECTORY_GRAPH = YES
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
# generated by dot. Possible values are png, jpg, or gif
# If left blank png will be used.
DOT_IMAGE_FORMAT = png
# The tag DOT_PATH can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found in the path.
DOT_PATH =
# The DOTFILE_DIRS tag can be used to specify one or more directories that
# contain dot files that are included in the documentation (see the
# \dotfile command).
DOTFILE_DIRS =
# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
# nodes that will be shown in the graph. If the number of nodes in a graph
# becomes larger than this value, doxygen will truncate the graph, which is
# visualized by representing a node as a red box. Note that doxygen if the
# number of direct children of the root node in a graph is already larger than
# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
DOT_GRAPH_MAX_NODES = 50
# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
# graphs generated by dot. A depth value of 3 means that only nodes reachable
# from the root by following a path via at most 3 edges will be shown. Nodes
# that lay further from the root node will be omitted. Note that setting this
# option to 1 or 2 may greatly reduce the computation time needed for large
# code bases. Also note that the size of a graph can be further restricted by
# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
MAX_DOT_GRAPH_DEPTH = 0
# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
# background. This is disabled by default, because dot on Windows does not
# seem to support this out of the box. Warning: Depending on the platform used,
# enabling this option may lead to badly anti-aliased labels on the edges of
# a graph (i.e. they become hard to read).
DOT_TRANSPARENT = NO
# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
# files in one run (i.e. multiple -o and -T options on the command line). This
# makes dot run faster, but since only newer versions of dot (>1.8.10)
# support this, this feature is disabled by default.
DOT_MULTI_TARGETS = NO
# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
# generate a legend page explaining the meaning of the various boxes and
# arrows in the dot generated graphs.
GENERATE_LEGEND = YES
# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
# remove the intermediate dot files that are used to generate
# the various graphs.
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Options related to the search engine
#---------------------------------------------------------------------------
# The SEARCHENGINE tag specifies whether or not a search engine should be
# used. If set to NO the values of all tags below this one will be ignored.
SEARCHENGINE = NO
<?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="set_int_type_id" select="/GCC_XML/Class[starts-with(@name, 'set&lt;int')]/@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', 'OpenMM_Context_createCheckpoint', 'OpenMM_Context_loadCheckpoint')"/>
<!-- 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, 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_IntArray
integer*8 :: handle = 0
end type
type OpenMM_IntSet
integer*8 :: handle = 0
end type
! Enumerations
integer*4, parameter :: OpenMM_False = 0
integer*4, 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 subroutine
! OpenMM_Vec3Array
subroutine OpenMM_Vec3Array_create(result, size)
use OpenMM_Types; implicit none
integer*4 size
type (OpenMM_Vec3Array) result
end subroutine
subroutine OpenMM_Vec3Array_destroy(destroy)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) destroy
end subroutine
function OpenMM_Vec3Array_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) target
integer*4 OpenMM_Vec3Array_getSize
end function
subroutine OpenMM_Vec3Array_resize(target, size)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) target
integer*4 size
end subroutine
subroutine OpenMM_Vec3Array_append(target, vec)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) target
real*8 vec(3)
end subroutine
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
subroutine OpenMM_Vec3Array_get(target, index, result)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) target
integer*4 index
real*8 result(3)
end subroutine
! OpenMM_StringArray
subroutine OpenMM_StringArray_create(result, size)
use OpenMM_Types; implicit none
integer*4 size
type (OpenMM_StringArray) result
end subroutine
subroutine OpenMM_StringArray_destroy(destroy)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) destroy
end subroutine
function OpenMM_StringArray_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
integer*4 OpenMM_StringArray_getSize
end function
subroutine OpenMM_StringArray_resize(target, size)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
integer*4 size
end subroutine
subroutine OpenMM_StringArray_append(target, str)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
character(*) str
end subroutine
subroutine OpenMM_StringArray_set(target, index, str)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
integer*4 index
character(*) str
end subroutine
subroutine OpenMM_StringArray_get(target, index, result)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
integer*4 index
character(*) result
end subroutine
! OpenMM_BondArray
subroutine OpenMM_BondArray_create(result, size)
use OpenMM_Types; implicit none
integer*4 size
type (OpenMM_BondArray) result
end subroutine
subroutine OpenMM_BondArray_destroy(destroy)
use OpenMM_Types; implicit none
type (OpenMM_BondArray) destroy
end subroutine
function OpenMM_BondArray_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_BondArray) target
integer*4 OpenMM_BondArray_getSize
end function
subroutine OpenMM_BondArray_resize(target, size)
use OpenMM_Types; implicit none
type (OpenMM_BondArray) target
integer*4 size
end subroutine
subroutine OpenMM_BondArray_append(target, particle1, particle2)
use OpenMM_Types; implicit none
type (OpenMM_BondArray) target
integer*4 particle1
integer*4 particle2
end subroutine
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
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 subroutine
! OpenMM_ParameterArray
function OpenMM_ParameterArray_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_ParameterArray) target
integer*4 OpenMM_ParameterArray_getSize
end function
subroutine OpenMM_ParameterArray_get(target, name, result)
use OpenMM_Types; implicit none
type (OpenMM_ParameterArray) target
character(*) name
character(*) result
end subroutine
! OpenMM_PropertyArray
function OpenMM_PropertyArray_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_ParameterArray) target
integer*4 OpenMM_PropertyArray_getSize
end function
subroutine OpenMM_PropertyArray_get(target, name, result)
use OpenMM_Types; implicit none
type (OpenMM_PropertyArray) target
character(*) name
character(*) result
end subroutine
<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*4'"/>
<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 Fortran.
! Unlike the C++ versions, the return value is allocated on the heap, and you must delete it yourself.
subroutine OpenMM_Context_getState(target, types, enforcePeriodicBox, result)
use OpenMM_Types; implicit none
type (OpenMM_Context) target
integer*4 types
integer*4 enforcePeriodicBox
type (OpenMM_State) result
end subroutine
subroutine OpenMM_Platform_loadPluginsFromDirectory(directory, result)
use OpenMM_Types; implicit none
character(*) directory
type (OpenMM_StringArray) result
end subroutine
<!-- 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
subroutine <xsl:value-of select="$name"/>_destroy(destroy)
use OpenMM_Types; implicit none
type (<xsl:value-of select="$name"/>) destroy
end subroutine
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 function
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
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
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
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 subroutine
</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, 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 subroutine'"/>
</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 subroutine'"/>
</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:choose>
<xsl:when test="$has_return">
<xsl:value-of select="' end function'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="' end subroutine'"/>
</xsl:otherwise>
</xsl:choose>
</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="$type_id=$set_int_type_id">
<xsl:value-of select="concat('type (OpenMM_IntSet) ', $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: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="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="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="set_int_type_id" select="/GCC_XML/Class[starts-with(@name, 'set&lt;int')]/@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', 'OpenMM_Context_createCheckpoint', 'OpenMM_Context_loadCheckpoint')"/>
<!-- 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 "OpenMMCWrapper.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="'double'"/>
<xsl:with-param name="name" select="'OpenMM_DoubleArray'"/>
</xsl:call-template>
<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>
<xsl:call-template name="primitive_set">
<xsl:with-param name="element_type" select="'int'"/>
<xsl:with-param name="name" select="'OpenMM_IntSet'"/>
</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, int const&amp; enforcePeriodicBox, OpenMM_State*&amp; result) {
result = OpenMM_Context_getState(target, types, enforcePeriodicBox);
};
OPENMM_EXPORT void OPENMM_CONTEXT_GETSTATE(const OpenMM_Context*&amp; target, int const&amp; types, int const&amp; enforcePeriodicBox, OpenMM_State*&amp; result) {
result = OpenMM_Context_getState(target, types, enforcePeriodicBox);
};
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, const <xsl:value-of select="$element_type"/>&amp; 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, const <xsl:value-of select="$element_type"/>&amp; 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, const <xsl:value-of select="$element_type"/>&amp; 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, const <xsl:value-of select="$element_type"/>&amp; 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 the definitions for a (Primitive)Set type -->
<xsl:template name="primitive_set">
<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) {
result = <xsl:value-of select="$name"/>_create();
}
OPENMM_EXPORT void <xsl:value-of select="$name_upper"/>_CREATE(<xsl:value-of select="$name"/>*&amp; result) {
result = <xsl:value-of select="$name"/>_create();
}
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"/>_insert_(<xsl:value-of select="$name"/>* const&amp; array, const <xsl:value-of select="$element_type"/>&amp; value) {
<xsl:value-of select="$name"/>_insert(array, value);
}
OPENMM_EXPORT void <xsl:value-of select="$name_upper"/>_INSERT(<xsl:value-of select="$name"/>* const&amp; array, const <xsl:value-of select="$element_type"/>&amp; value) {
<xsl:value-of select="$name"/>_insert(array, value);
}
</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=$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="$type_id=$set_int_type_id">
<xsl:value-of select="'OpenMM_IntSet'"/>
</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=$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=$set_int_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>
from __future__ import print_function
import sys, os
import time
import getopt
import re
import xml.etree.ElementTree as etree
def trimToSingleSpace(text):
if text is None or len(text) == 0:
return ""
t = text.strip()
if len(t) == 0:
return t
if text[0].isspace():
t = " %s" % t
if text[-1].isspace():
t = "%s " % t
return t
def getNodeText(node):
if node.text is not None:
s = node.text
else:
s = ""
for n in node:
if n.tag == "para":
s = "%s%s\n\n" % (s, getNodeText(n))
elif n.tag == "ref":
s = "%s%s" % (s, getNodeText(n))
if n.tail is not None:
s = "%s%s" % (s, n.tail)
return s
def getText(subNodePath, node):
s = ""
for n in node.findall(subNodePath):
s = "%s%s" % (s, trimToSingleSpace(getNodeText(n)))
if n.tag == "para":
s = "%s\n\n" % s
return s.strip()
def convertOpenMMPrefix(name):
return name.replace('OpenMM::', 'OpenMM_')
OPENMM_RE_PATTERN=re.compile("(.*)OpenMM:[a-zA-Z:]*:(.*)")
def stripOpenMMPrefix(name, rePattern=OPENMM_RE_PATTERN):
try:
m=rePattern.search(name)
rValue = "%s%s" % m.group(1,2)
rValue.strip()
return rValue
except:
return name
def findNodes(parent, path, **args):
nodes = []
for node in parent.findall(path):
match = True
for arg in args:
if arg not in node.attrib or node.attrib[arg] != args[arg]:
match = False
if match:
nodes.append(node)
return nodes
class WrapperGenerator:
"""This is the parent class of generators for various API wrapper files. It defines functions common to all of them."""
def __init__(self, inputDirname, output):
self.skipClasses = ['OpenMM::Vec3', 'OpenMM::XmlSerializer', 'OpenMM::Kernel', 'OpenMM::KernelImpl', 'OpenMM::KernelFactory', 'OpenMM::ContextImpl', 'OpenMM::SerializationNode', 'OpenMM::SerializationProxy']
self.skipMethods = ['OpenMM::Context::getState', 'OpenMM::Platform::loadPluginsFromDirectory', 'OpenMM::Context::createCheckpoint', 'OpenMM::Context::loadCheckpoint']
self.hideClasses = ['Kernel', 'KernelImpl', 'KernelFactory', 'ContextImpl', 'SerializationNode', 'SerializationProxy']
self.nodeByID={}
# Read all the XML files and merge them into a single document.
self.doc = etree.ElementTree(etree.Element('root'))
for file in os.listdir(inputDirname):
if file.lower().endswith('xml'):
root = etree.parse(os.path.join(inputDirname, file)).getroot()
for node in root:
self.doc.getroot().append(node)
self.out = output
self.typesByShortName = {}
self._orderedClassNodes = self.buildOrderedClassNodes()
def getNodeByID(self, id):
if id not in self.nodeByID:
for node in findNodes(self.doc.getroot(), "compounddef", id=id):
self.nodeByID[id] = node
return self.nodeByID[id]
def buildOrderedClassNodes(self):
orderedClassNodes=[]
for node in findNodes(self.doc.getroot(), "compounddef", kind="class", prot="public"):
self.findBaseNodes(node, orderedClassNodes)
return orderedClassNodes
def findBaseNodes(self, node, excludedClassNodes=[]):
if node in excludedClassNodes:
return
if node.attrib['prot'] == 'private':
return
nodeName = getText("compoundname", node)
if nodeName in self.skipClasses:
return
for baseNodePnt in findNodes(node, "basecompoundref", prot="public"):
if "refid" in baseNodePnt.attrib:
baseNodeID = baseNodePnt.attrib["refid"]
baseNode = self.getNodeByID(baseNodeID)
self.findBaseNodes(baseNode, excludedClassNodes)
excludedClassNodes.append(node)
def getClassMethods(self, classNode):
className = getText("compoundname", classNode)
shortClassName = stripOpenMMPrefix(className)
methodList = []
for section in findNodes(classNode, "sectiondef", kind="public-static-func")+findNodes(classNode, "sectiondef", kind="public-func"):
for memberNode in findNodes(section, "memberdef", kind="function", prot="public"):
methodDefinition = getText("definition", memberNode)
shortMethodDefinition = stripOpenMMPrefix(methodDefinition)
methodName = shortMethodDefinition.split()[-1]
if className+'::'+methodName in self.skipMethods:
continue
methodList.append(memberNode)
return methodList
def shouldHideType(self, typeName):
if typeName.startswith('const '):
typeName = typeName[6:].strip()
if typeName.endswith('&') or typeName.endswith('*'):
typeName = typeName[:-1].strip()
return typeName in self.hideClasses
def shouldHideMethod(self, methodNode):
paramList = findNodes(methodNode, 'param')
returnType = self.getType(getText("type", methodNode))
if self.shouldHideType(returnType):
return True
for node in paramList:
try:
type = getText('type', node)
except IndexError:
type = getText('type/ref', node)
if self.shouldHideType(type):
return True
return False
class CHeaderGenerator(WrapperGenerator):
"""This class generates the header file for the C API wrappers."""
def __init__(self, inputDirname, output):
WrapperGenerator.__init__(self, inputDirname, output)
self.typeTranslations = {'bool': 'OpenMM_Boolean',
'Vec3': 'OpenMM_Vec3',
'std::string': 'char*',
'const std::string &': 'const char*',
'std::vector< std::string >': 'OpenMM_StringArray',
'std::vector< Vec3 >': 'OpenMM_Vec3Array',
'std::vector< std::pair< int, int > >': 'OpenMM_BondArray',
'std::map< std::string, double >': 'OpenMM_ParameterArray',
'std::map< std::string, std::string >': 'OpenMM_PropertyArray',
'std::vector< double >': 'OpenMM_DoubleArray',
'std::vector< int >': 'OpenMM_IntArray',
'std::set< int >': 'OpenMM_IntSet'}
def writeGlobalConstants(self):
self.out.write("/* Global Constants */\n\n")
node = next((x for x in findNodes(self.doc.getroot(), "compounddef", kind="namespace") if x.findtext("compoundname") == "OpenMM"))
for section in findNodes(node, "sectiondef", kind="var"):
for memberNode in findNodes(section, "memberdef", kind="variable", mutable="no", prot="public", static="yes"):
vDef = convertOpenMMPrefix(getText("definition", memberNode))
iDef = getText("initializer", memberNode)
if iDef.startswith("="):
iDef = iDef[1:]
self.out.write("static %s = %s;\n" % (vDef, iDef))
def writeTypeDeclarations(self):
self.out.write("\n/* Type Declarations */\n\n")
for classNode in self._orderedClassNodes:
className = getText("compoundname", classNode)
shortName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className)
self.out.write("typedef struct %s_struct %s;\n" % (typeName, typeName))
self.typesByShortName[shortName] = typeName
def writeClasses(self):
for classNode in self._orderedClassNodes:
className = stripOpenMMPrefix(getText("compoundname", classNode))
self.out.write("\n/* %s */\n" % className)
self.writeEnumerations(classNode)
self.writeMethods(classNode)
self.out.write("\n")
def writeEnumerations(self, classNode):
enumNodes = []
for section in findNodes(classNode, "sectiondef", kind="public-type"):
for node in findNodes(section, "memberdef", kind="enum", prot="public"):
enumNodes.append(node)
className = getText("compoundname", classNode)
shortClassName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className)
for enumNode in enumNodes:
enumName = getText("name", enumNode)
enumTypeName = "%s_%s" % (typeName, enumName)
self.out.write("typedef enum {\n ")
argSep=""
for valueNode in findNodes(enumNode, "enumvalue", prot="public"):
vName = convertOpenMMPrefix(getText("name", valueNode))
vInit = getText("initializer", valueNode)
if vInit.startswith("="):
vInit = vInit[1:].strip()
self.out.write("%s%s_%s = %s" % (argSep, typeName, vName, vInit))
argSep=", "
self.out.write("\n} %s;\n" % enumTypeName)
self.typesByShortName[enumName] = enumTypeName
if len(enumNodes)>0: self.out.write("\n")
def writeMethods(self, classNode):
methodList = self.getClassMethods(classNode)
className = getText("compoundname", classNode)
shortClassName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className)
destructorName = '~'+shortClassName
isAbstract = any('virt' in method.attrib and method.attrib['virt'] == 'pure-virtual' for method in classNode.getiterator('memberdef'))
if not isAbstract:
# Write constructors
numConstructors = 0
for methodNode in methodList:
methodDefinition = getText("definition", methodNode)
shortMethodDefinition = stripOpenMMPrefix(methodDefinition)
methodName = shortMethodDefinition.split()[-1]
if methodName == shortClassName:
if self.shouldHideMethod(methodNode):
continue
numConstructors += 1
if numConstructors == 1:
suffix = ""
else:
suffix = "_%d" % numConstructors
self.out.write("extern OPENMM_EXPORT %s* %s_create%s(" % (typeName, typeName, suffix))
self.writeArguments(methodNode, False)
self.out.write(");\n")
# Write destructor
self.out.write("extern OPENMM_EXPORT void %s_destroy(%s* target);\n" % (typeName, typeName))
# Record method names for future reference.
methodNames = {}
for methodNode in methodList:
methodDefinition = getText("definition", methodNode)
shortMethodDefinition = stripOpenMMPrefix(methodDefinition)
methodNames[methodNode] = shortMethodDefinition.split()[-1]
# Write other methods
for methodNode in methodList:
methodName = methodNames[methodNode]
if methodName in (shortClassName, destructorName):
continue
if self.shouldHideMethod(methodNode):
continue
isConstMethod = (methodNode.attrib['const'] == 'yes')
if isConstMethod and any(methodNames[m] == methodName and m.attrib['const'] == 'no' for m in methodList):
# There are two identical methods that differ only in whether they are const. Skip the const one.
continue
returnType = self.getType(getText("type", methodNode))
self.out.write("extern OPENMM_EXPORT %s %s_%s(" % (returnType, typeName, methodName))
isInstanceMethod = (methodNode.attrib['static'] != 'yes')
if isInstanceMethod:
if isConstMethod:
self.out.write('const ')
self.out.write("%s* target" % typeName)
self.writeArguments(methodNode, isInstanceMethod)
self.out.write(");\n")
def writeArguments(self, methodNode, initialSeparator):
paramList = findNodes(methodNode, 'param')
if initialSeparator:
separator = ", "
else:
separator = ""
for node in paramList:
try:
type = getText('type', node)
except IndexError:
type = getText('type/ref', node)
if type == 'void':
continue
type = self.getType(type)
name = getText('declname', node)
self.out.write("%s%s %s" % (separator, type, name))
separator = ", "
def getType(self, type):
if type in self.typeTranslations:
return self.typeTranslations[type]
if type in self.typesByShortName:
return self.typesByShortName[type]
if type.startswith('const '):
return 'const '+self.getType(type[6:].strip())
if type.endswith('&') or type.endswith('*'):
return self.getType(type[:-1].strip())+'*'
return type
def writeOutput(self):
print("""
#ifndef OPENMM_CWRAPPER_H_
#define OPENMM_CWRAPPER_H_
#ifndef OPENMM_EXPORT
#define OPENMM_EXPORT
#endif
""", file=self.out)
self.writeGlobalConstants()
self.writeTypeDeclarations()
print("""
typedef struct OpenMM_Vec3Array_struct OpenMM_Vec3Array;
typedef struct OpenMM_StringArray_struct OpenMM_StringArray;
typedef struct OpenMM_BondArray_struct OpenMM_BondArray;
typedef struct OpenMM_ParameterArray_struct OpenMM_ParameterArray;
typedef struct OpenMM_PropertyArray_struct OpenMM_PropertyArray;
typedef struct OpenMM_DoubleArray_struct OpenMM_DoubleArray;
typedef struct OpenMM_IntArray_struct OpenMM_IntArray;
typedef struct OpenMM_IntSet_struct OpenMM_IntSet;
typedef struct {double x, y, z;} OpenMM_Vec3;
typedef enum {OpenMM_False = 0, OpenMM_True = 1} OpenMM_Boolean;
#if defined(__cplusplus)
extern "C" {
#endif
/* OpenMM_Vec3 */
extern OPENMM_EXPORT OpenMM_Vec3 OpenMM_Vec3_scale(const OpenMM_Vec3 vec, double scale);
/* OpenMM_Vec3Array */
extern OPENMM_EXPORT OpenMM_Vec3Array* OpenMM_Vec3Array_create(int size);
extern OPENMM_EXPORT void OpenMM_Vec3Array_destroy(OpenMM_Vec3Array* array);
extern OPENMM_EXPORT int OpenMM_Vec3Array_getSize(const OpenMM_Vec3Array* array);
extern OPENMM_EXPORT void OpenMM_Vec3Array_resize(OpenMM_Vec3Array* array, int size);
extern OPENMM_EXPORT void OpenMM_Vec3Array_append(OpenMM_Vec3Array* array, const OpenMM_Vec3 vec);
extern OPENMM_EXPORT void OpenMM_Vec3Array_set(OpenMM_Vec3Array* array, int index, const OpenMM_Vec3 vec);
extern OPENMM_EXPORT const OpenMM_Vec3* OpenMM_Vec3Array_get(const OpenMM_Vec3Array* array, int index);
/* OpenMM_StringArray */
extern OPENMM_EXPORT OpenMM_StringArray* OpenMM_StringArray_create(int size);
extern OPENMM_EXPORT void OpenMM_StringArray_destroy(OpenMM_StringArray* array);
extern OPENMM_EXPORT int OpenMM_StringArray_getSize(const OpenMM_StringArray* array);
extern OPENMM_EXPORT void OpenMM_StringArray_resize(OpenMM_StringArray* array, int size);
extern OPENMM_EXPORT void OpenMM_StringArray_append(OpenMM_StringArray* array, const char* string);
extern OPENMM_EXPORT void OpenMM_StringArray_set(OpenMM_StringArray* array, int index, const char* string);
extern OPENMM_EXPORT const char* OpenMM_StringArray_get(const OpenMM_StringArray* array, int index);
/* OpenMM_BondArray */
extern OPENMM_EXPORT OpenMM_BondArray* OpenMM_BondArray_create(int size);
extern OPENMM_EXPORT void OpenMM_BondArray_destroy(OpenMM_BondArray* array);
extern OPENMM_EXPORT int OpenMM_BondArray_getSize(const OpenMM_BondArray* array);
extern OPENMM_EXPORT void OpenMM_BondArray_resize(OpenMM_BondArray* array, int size);
extern OPENMM_EXPORT void OpenMM_BondArray_append(OpenMM_BondArray* array, int particle1, int particle2);
extern OPENMM_EXPORT void OpenMM_BondArray_set(OpenMM_BondArray* array, int index, int particle1, int particle2);
extern OPENMM_EXPORT void OpenMM_BondArray_get(const OpenMM_BondArray* array, int index, int* particle1, int* particle2);
/* OpenMM_ParameterArray */
extern OPENMM_EXPORT int OpenMM_ParameterArray_getSize(const OpenMM_ParameterArray* array);
extern OPENMM_EXPORT double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* array, const char* name);
/* OpenMM_PropertyArray */
extern OPENMM_EXPORT int OpenMM_PropertyArray_getSize(const OpenMM_PropertyArray* array);
extern OPENMM_EXPORT const char* OpenMM_PropertyArray_get(const OpenMM_PropertyArray* array, const char* name);""", file=self.out)
for type in ('double', 'int'):
name = 'OpenMM_%sArray' % type.capitalize()
values = {'type':type, 'name':name}
print("""
/* %(name)s */
extern OPENMM_EXPORT %(name)s* %(name)s_create(int size);
extern OPENMM_EXPORT void %(name)s_destroy(%(name)s* array);
extern OPENMM_EXPORT int %(name)s_getSize(const %(name)s* array);
extern OPENMM_EXPORT void %(name)s_resize(%(name)s* array, int size);
extern OPENMM_EXPORT void %(name)s_append(%(name)s* array, %(type)s value);
extern OPENMM_EXPORT void %(name)s_set(%(name)s* array, int index, %(type)s value);
extern OPENMM_EXPORT %(type)s %(name)s_get(const %(name)s* array, int index);""" % values, file=self.out)
for type in ('int',):
name = 'OpenMM_%sSet' % type.capitalize()
values = {'type':type, 'name':name}
print("""
/* %(name)s */
extern OPENMM_EXPORT %(name)s* %(name)s_create();
extern OPENMM_EXPORT void %(name)s_destroy(%(name)s* set);
extern OPENMM_EXPORT int %(name)s_getSize(const %(name)s* set);
extern OPENMM_EXPORT void %(name)s_insert(%(name)s* set, %(type)s value);""" % values, file=self.out)
print("""
/* 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. */
extern OPENMM_EXPORT OpenMM_State* OpenMM_Context_getState(const OpenMM_Context* target, int types, int enforcePeriodicBox);
extern OPENMM_EXPORT OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directory);
extern OPENMM_EXPORT char* OpenMM_XmlSerializer_serializeSystem(const OpenMM_System* system);
extern OPENMM_EXPORT char* OpenMM_XmlSerializer_serializeState(const OpenMM_State* state);
extern OPENMM_EXPORT char* OpenMM_XmlSerializer_serializeIntegrator(const OpenMM_Integrator* integrator);
extern OPENMM_EXPORT OpenMM_System* OpenMM_XmlSerializer_deserializeSystem(const char* xml);
extern OPENMM_EXPORT OpenMM_State* OpenMM_XmlSerializer_deserializeState(const char* xml);
extern OPENMM_EXPORT OpenMM_Integrator* OpenMM_XmlSerializer_deserializeIntegrator(const char* xml);""", file=self.out)
self.writeClasses()
print("""
#if defined(__cplusplus)
}
#endif
#endif /*OPENMM_CWRAPPER_H_*/""", file=self.out)
class CSourceGenerator(WrapperGenerator):
"""This class generates the source file for the C API wrappers."""
def __init__(self, inputDirname, output):
WrapperGenerator.__init__(self, inputDirname, output)
self.typeTranslations = {'bool': 'OpenMM_Boolean',
'Vec3': 'OpenMM_Vec3',
'std::string': 'char*',
'const std::string &': 'const char*',
'std::vector< std::string >': 'OpenMM_StringArray',
'std::vector< Vec3 >': 'OpenMM_Vec3Array',
'std::vector< std::pair< int, int > >': 'OpenMM_BondArray',
'std::map< std::string, double >': 'OpenMM_ParameterArray',
'std::map< std::string, std::string >': 'OpenMM_PropertyArray',
'std::vector< double >': 'OpenMM_DoubleArray',
'std::vector< int >': 'OpenMM_IntArray',
'std::set< int >': 'OpenMM_IntSet'}
self.inverseTranslations = dict((self.typeTranslations[key], key) for key in self.typeTranslations)
self.classesByShortName = {}
self.enumerationTypes = {}
self.findTypes()
def findTypes(self):
for classNode in self._orderedClassNodes:
className = getText("compoundname", classNode)
shortName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className)
self.typesByShortName[shortName] = typeName
self.classesByShortName[shortName] = className
def findEnumerations(self, classNode):
enumNodes = []
for section in findNodes(classNode, "sectiondef", kind="public-type"):
for node in findNodes(section, "memberdef", kind="enum", prot="public"):
enumNodes.append(node)
className = getText("compoundname", classNode)
typeName = convertOpenMMPrefix(className)
for enumNode in enumNodes:
enumName = getText("name", enumNode)
enumTypeName = "%s_%s" % (typeName, enumName)
enumClassName = "%s::%s" % (className, enumName)
self.typesByShortName[enumName] = enumTypeName
self.classesByShortName[enumName] = enumClassName
self.enumerationTypes[enumClassName] = enumTypeName
def writeClasses(self):
for classNode in self._orderedClassNodes:
className = stripOpenMMPrefix(getText("compoundname", classNode))
self.out.write("\n/* OpenMM::%s */\n" % className)
self.findEnumerations(classNode)
self.writeMethods(classNode)
self.out.write("\n")
def writeMethods(self, classNode):
methodList = self.getClassMethods(classNode)
className = getText("compoundname", classNode)
shortClassName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className)
destructorName = '~'+shortClassName
isAbstract = any('virt' in method.attrib and method.attrib['virt'] == 'pure-virtual' for method in classNode.getiterator('memberdef'))
if not isAbstract:
# Write constructors
numConstructors = 0
for methodNode in methodList:
methodDefinition = getText("definition", methodNode)
shortMethodDefinition = stripOpenMMPrefix(methodDefinition)
methodName = shortMethodDefinition.split()[-1]
if methodName == shortClassName:
if self.shouldHideMethod(methodNode):
continue
numConstructors += 1
if numConstructors == 1:
suffix = ""
else:
suffix = "_%d" % numConstructors
self.out.write("OPENMM_EXPORT %s* %s_create%s(" % (typeName, typeName, suffix))
self.writeArguments(methodNode, False)
self.out.write(") {\n")
self.out.write(" return reinterpret_cast<%s*>(new %s(" % (typeName, className))
self.writeInvocationArguments(methodNode, False)
self.out.write("));\n")
self.out.write("}\n")
# Write destructor
self.out.write("OPENMM_EXPORT void %s_destroy(%s* target) {\n" % (typeName, typeName))
self.out.write(" delete reinterpret_cast<%s*>(target);\n" % className)
self.out.write("}\n")
# Record method names for future reference.
methodNames = {}
for methodNode in methodList:
methodDefinition = getText("definition", methodNode)
shortMethodDefinition = stripOpenMMPrefix(methodDefinition)
methodNames[methodNode] = shortMethodDefinition.split()[-1]
# Write other methods
for methodNode in methodList:
methodName = methodNames[methodNode]
if methodName in (shortClassName, destructorName):
continue
if self.shouldHideMethod(methodNode):
continue
isConstMethod = (methodNode.attrib['const'] == 'yes')
if isConstMethod and any(methodNames[m] == methodName and m.attrib['const'] == 'no' for m in methodList):
# There are two identical methods that differ only in whether they are const. Skip the const one.
continue
methodType = getText("type", methodNode)
returnType = self.getType(methodType)
if methodType in self.classesByShortName:
methodType = self.classesByShortName[methodType]
self.out.write("OPENMM_EXPORT %s %s_%s(" % (returnType, typeName, methodName))
isInstanceMethod = (methodNode.attrib['static'] != 'yes')
if isInstanceMethod:
if isConstMethod:
self.out.write('const ')
self.out.write("%s* target" % typeName)
self.writeArguments(methodNode, isInstanceMethod)
self.out.write(") {\n")
self.out.write(" ")
if returnType != 'void':
if methodType.endswith('&'):
# Convert references to pointers
self.out.write('%s* result = &' % methodType[:-1].strip())
else:
self.out.write('%s result = ' % methodType)
if isInstanceMethod:
self.out.write('reinterpret_cast<')
if isConstMethod:
self.out.write('const ')
self.out.write('%s*>(target)->' % className)
else:
self.out.write('%s::' % className)
self.out.write('%s(' % methodName)
self.writeInvocationArguments(methodNode, False)
self.out.write(');\n')
if returnType != 'void':
self.out.write(' return %s;\n' % self.wrapValue(methodType, 'result'))
self.out.write("}\n")
def writeArguments(self, methodNode, initialSeparator):
paramList = findNodes(methodNode, 'param')
if initialSeparator:
separator = ", "
else:
separator = ""
for node in paramList:
try:
type = getText('type', node)
except IndexError:
type = getText('type/ref', node)
if type == 'void':
continue
type = self.getType(type)
name = getText('declname', node)
self.out.write("%s%s %s" % (separator, type, name))
separator = ", "
def writeInvocationArguments(self, methodNode, initialSeparator):
paramList = findNodes(methodNode, 'param')
if initialSeparator:
separator = ", "
else:
separator = ""
for node in paramList:
try:
type = getText('type', node)
except IndexError:
type = getText('type/ref', node)
if type == 'void':
continue
name = getText('declname', node)
if self.getType(type) != type:
name = self.unwrapValue(type, name)
self.out.write("%s%s" % (separator, name))
separator = ", "
def getType(self, type):
if type in self.typeTranslations:
return self.typeTranslations[type]
if type in self.typesByShortName:
return self.typesByShortName[type]
if type.startswith('const '):
return 'const '+self.getType(type[6:].strip())
if type.endswith('&') or type.endswith('*'):
return self.getType(type[:-1].strip())+'*'
return type
def wrapValue(self, type, value):
if type == 'bool':
return '(%s ? OpenMM_True : OpenMM_False)' % value
if type == 'std::string':
return '%s.c_str()' % value
if type == 'const std::string &':
return '%s->c_str()' % value
if type in self.enumerationTypes:
return 'static_cast<%s>(%s)' % (self.enumerationTypes[type], value)
wrappedType = self.getType(type)
if wrappedType == type:
return value;
if type.endswith('*') or type.endswith('&'):
return 'reinterpret_cast<%s>(%s)' % (wrappedType, value)
return 'static_cast<%s>(%s)' % (wrappedType, value)
def unwrapValue(self, type, value):
if type.endswith('&'):
unwrappedType = type[:-1].strip()
if unwrappedType in self.classesByShortName:
unwrappedType = self.classesByShortName[unwrappedType]
return '*'+self.unwrapValue(unwrappedType+'*', value)
if type in self.classesByShortName:
return 'static_cast<%s>(%s)' % (self.classesByShortName[type], value)
if type == 'bool':
return value
return 'reinterpret_cast<%s>(%s)' % (type, value)
def writeOutput(self):
print("""
#include "OpenMM.h"
#include "OpenMMCWrapper.h"
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <vector>
using namespace OpenMM;
using namespace std;
extern "C" {
/* OpenMM_Vec3 */
OPENMM_EXPORT OpenMM_Vec3 OpenMM_Vec3_scale(const OpenMM_Vec3 vec, double scale) {
OpenMM_Vec3 result = {vec.x*scale, vec.y*scale, vec.z*scale};
return result;
}
/* OpenMM_Vec3Array */
OPENMM_EXPORT OpenMM_Vec3Array* OpenMM_Vec3Array_create(int size) {
return reinterpret_cast<OpenMM_Vec3Array*>(new vector<Vec3>(size));
}
OPENMM_EXPORT void OpenMM_Vec3Array_destroy(OpenMM_Vec3Array* array) {
delete reinterpret_cast<vector<Vec3>*>(array);
}
OPENMM_EXPORT int OpenMM_Vec3Array_getSize(const OpenMM_Vec3Array* array) {
return reinterpret_cast<const vector<Vec3>*>(array)->size();
}
OPENMM_EXPORT void OpenMM_Vec3Array_resize(OpenMM_Vec3Array* array, int size) {
reinterpret_cast<vector<Vec3>*>(array)->resize(size);
}
OPENMM_EXPORT void OpenMM_Vec3Array_append(OpenMM_Vec3Array* array, const OpenMM_Vec3 vec) {
reinterpret_cast<vector<Vec3>*>(array)->push_back(Vec3(vec.x, vec.y, vec.z));
}
OPENMM_EXPORT void OpenMM_Vec3Array_set(OpenMM_Vec3Array* array, int index, const OpenMM_Vec3 vec) {
(*reinterpret_cast<vector<Vec3>*>(array))[index] = Vec3(vec.x, vec.y, vec.z);
}
OPENMM_EXPORT const OpenMM_Vec3* OpenMM_Vec3Array_get(const OpenMM_Vec3Array* array, int index) {
return reinterpret_cast<const OpenMM_Vec3*>((&(*reinterpret_cast<const vector<Vec3>*>(array))[index]));
}
/* OpenMM_StringArray */
OPENMM_EXPORT OpenMM_StringArray* OpenMM_StringArray_create(int size) {
return reinterpret_cast<OpenMM_StringArray*>(new vector<string>(size));
}
OPENMM_EXPORT void OpenMM_StringArray_destroy(OpenMM_StringArray* array) {
delete reinterpret_cast<vector<string>*>(array);
}
OPENMM_EXPORT int OpenMM_StringArray_getSize(const OpenMM_StringArray* array) {
return reinterpret_cast<const vector<string>*>(array)->size();
}
OPENMM_EXPORT void OpenMM_StringArray_resize(OpenMM_StringArray* array, int size) {
reinterpret_cast<vector<string>*>(array)->resize(size);
}
OPENMM_EXPORT void OpenMM_StringArray_append(OpenMM_StringArray* array, const char* str) {
reinterpret_cast<vector<string>*>(array)->push_back(string(str));
}
OPENMM_EXPORT void OpenMM_StringArray_set(OpenMM_StringArray* array, int index, const char* str) {
(*reinterpret_cast<vector<string>*>(array))[index] = string(str);
}
OPENMM_EXPORT const char* OpenMM_StringArray_get(const OpenMM_StringArray* array, int index) {
return (*reinterpret_cast<const vector<string>*>(array))[index].c_str();
}
/* OpenMM_BondArray */
OPENMM_EXPORT OpenMM_BondArray* OpenMM_BondArray_create(int size) {
return reinterpret_cast<OpenMM_BondArray*>(new vector<pair<int, int> >(size));
}
OPENMM_EXPORT void OpenMM_BondArray_destroy(OpenMM_BondArray* array) {
delete reinterpret_cast<vector<pair<int, int> >*>(array);
}
OPENMM_EXPORT int OpenMM_BondArray_getSize(const OpenMM_BondArray* array) {
return reinterpret_cast<const vector<pair<int, int> >*>(array)->size();
}
OPENMM_EXPORT void OpenMM_BondArray_resize(OpenMM_BondArray* array, int size) {
reinterpret_cast<vector<pair<int, int> >*>(array)->resize(size);
}
OPENMM_EXPORT void OpenMM_BondArray_append(OpenMM_BondArray* array, int particle1, int particle2) {
reinterpret_cast<vector<pair<int, int> >*>(array)->push_back(pair<int, int>(particle1, particle2));
}
OPENMM_EXPORT void OpenMM_BondArray_set(OpenMM_BondArray* array, int index, int particle1, int particle2) {
(*reinterpret_cast<vector<pair<int, int> >*>(array))[index] = pair<int, int>(particle1, particle2);
}
OPENMM_EXPORT void OpenMM_BondArray_get(const OpenMM_BondArray* array, int index, int* particle1, int* particle2) {
pair<int, int> particles = (*reinterpret_cast<const vector<pair<int, int> >*>(array))[index];
*particle1 = particles.first;
*particle2 = particles.second;
}
/* OpenMM_ParameterArray */
OPENMM_EXPORT int OpenMM_ParameterArray_getSize(const OpenMM_ParameterArray* array) {
return reinterpret_cast<const map<string, double>*>(array)->size();
}
OPENMM_EXPORT double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* array, const char* name) {
const map<string, double>* params = reinterpret_cast<const map<string, double>*>(array);
const map<string, double>::const_iterator iter = params->find(string(name));
if (iter == params->end())
throw OpenMMException("OpenMM_ParameterArray_get: No such parameter");
return iter->second;
}
/* OpenMM_PropertyArray */
OPENMM_EXPORT int OpenMM_PropertyArray_getSize(const OpenMM_PropertyArray* array) {
return reinterpret_cast<const map<string, double>*>(array)->size();
}
OPENMM_EXPORT const char* OpenMM_PropertyArray_get(const OpenMM_PropertyArray* array, const char* name) {
const map<string, string>* params = reinterpret_cast<const map<string, string>*>(array);
const map<string, string>::const_iterator iter = params->find(string(name));
if (iter == params->end())
throw OpenMMException("OpenMM_PropertyArray_get: No such property");
return iter->second.c_str();
}""", file=self.out)
for type in ('double', 'int'):
name = 'OpenMM_%sArray' % type.capitalize()
values = {'type':type, 'name':name}
print("""
/* %(name)s */
OPENMM_EXPORT %(name)s* %(name)s_create(int size) {
return reinterpret_cast<%(name)s*>(new vector<%(type)s>(size));
}
OPENMM_EXPORT void %(name)s_destroy(%(name)s* array) {
delete reinterpret_cast<vector<%(type)s>*>(array);
}
OPENMM_EXPORT int %(name)s_getSize(const %(name)s* array) {
return reinterpret_cast<const vector<%(type)s>*>(array)->size();
}
OPENMM_EXPORT void %(name)s_resize(%(name)s* array, int size) {
reinterpret_cast<vector<%(type)s>*>(array)->resize(size);
}
OPENMM_EXPORT void %(name)s_append(%(name)s* array, %(type)s value) {
reinterpret_cast<vector<%(type)s>*>(array)->push_back(value);
}
OPENMM_EXPORT void %(name)s_set(%(name)s* array, int index, %(type)s value) {
(*reinterpret_cast<vector<%(type)s>*>(array))[index] = value;
}
OPENMM_EXPORT %(type)s %(name)s_get(const %(name)s* array, int index) {
return (*reinterpret_cast<const vector<%(type)s>*>(array))[index];
}""" % values, file=self.out)
for type in ('int',):
name = 'OpenMM_%sSet' % type.capitalize()
values = {'type':type, 'name':name}
print("""
/* %(name)s */
OPENMM_EXPORT %(name)s* %(name)s_create() {
return reinterpret_cast<%(name)s*>(new set<%(type)s>());
}
OPENMM_EXPORT void %(name)s_destroy(%(name)s* s) {
delete reinterpret_cast<set<%(type)s>*>(s);
}
OPENMM_EXPORT int %(name)s_getSize(const %(name)s* s) {
return reinterpret_cast<const set<%(type)s>*>(s)->size();
}
OPENMM_EXPORT void %(name)s_insert(%(name)s* s, %(type)s value) {
reinterpret_cast<set<%(type)s>*>(s)->insert(value);
}""" % values, file=self.out)
print("""
/* 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 OpenMM_State* OpenMM_Context_getState(const OpenMM_Context* target, int types, int enforcePeriodicBox) {
State result = reinterpret_cast<const Context*>(target)->getState(types, enforcePeriodicBox);
return reinterpret_cast<OpenMM_State*>(new State(result));
}
OPENMM_EXPORT OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directory) {
vector<string> result = Platform::loadPluginsFromDirectory(string(directory));
return reinterpret_cast<OpenMM_StringArray*>(new vector<string>(result));
}
static char* createStringFromStream(stringstream& stream) {
int length = stream.str().size();
char* result = (char*) malloc(length+1);
stream.str().copy(result, length);
result[length] = 0;
return result;
}
OPENMM_EXPORT char* OpenMM_XmlSerializer_serializeSystem(const OpenMM_System* system) {
stringstream stream;
OpenMM::XmlSerializer::serialize<OpenMM::System>(reinterpret_cast<const OpenMM::System*>(system), "System", stream);
return createStringFromStream(stream);
}
OPENMM_EXPORT char* OpenMM_XmlSerializer_serializeState(const OpenMM_State* state) {
stringstream stream;
OpenMM::XmlSerializer::serialize<OpenMM::State>(reinterpret_cast<const OpenMM::State*>(state), "State", stream);
return createStringFromStream(stream);
}
OPENMM_EXPORT char* OpenMM_XmlSerializer_serializeIntegrator(const OpenMM_Integrator* integrator) {
stringstream stream;
OpenMM::XmlSerializer::serialize<OpenMM::Integrator>(reinterpret_cast<const OpenMM::Integrator*>(integrator), "Integrator", stream);
return createStringFromStream(stream);
}
OPENMM_EXPORT OpenMM_System* OpenMM_XmlSerializer_deserializeSystem(const char* xml) {
string input(xml);
stringstream stream(input);
return reinterpret_cast<OpenMM_System*>(OpenMM::XmlSerializer::deserialize<OpenMM::System>(stream));
}
OPENMM_EXPORT OpenMM_State* OpenMM_XmlSerializer_deserializeState(const char* xml) {
string input(xml);
stringstream stream(input);
return reinterpret_cast<OpenMM_State*>(OpenMM::XmlSerializer::deserialize<OpenMM::State>(stream));
}
OPENMM_EXPORT OpenMM_Integrator* OpenMM_XmlSerializer_deserializeIntegrator(const char* xml) {
string input(xml);
stringstream stream(input);
return reinterpret_cast<OpenMM_Integrator*>(OpenMM::XmlSerializer::deserialize<OpenMM::Integrator>(stream));
}""", file=self.out)
self.writeClasses()
print("}\n", file=self.out)
class FortranHeaderGenerator(WrapperGenerator):
"""This class generates the header file for the Fortran API wrappers."""
def __init__(self, inputDirname, output):
WrapperGenerator.__init__(self, inputDirname, output)
self.typeTranslations = {'int': 'integer*4',
'bool': 'integer*4',
'double': 'real*8',
'char *': 'character(*)',
'const char *': 'character(*)',
'std::string': 'character(*)',
'const std::string &': 'character(*)',
'std::vector< std::string >': 'type (OpenMM_StringArray)',
'std::vector< Vec3 >': 'type (OpenMM_Vec3Array)',
'std::vector< std::pair< int, int > >': 'type (OpenMM_BondArray)',
'std::map< std::string, double >': 'type (OpenMM_ParameterArray)',
'std::map< std::string, std::string >': 'type (OpenMM_PropertyArray)',
'std::vector< double >': 'type (OpenMM_DoubleArray)',
'std::vector< int >': 'type (OpenMM_IntArray)',
'std::set< int >': 'type (OpenMM_IntSet)'}
self.enumerationTypes = set()
def writeGlobalConstants(self):
self.out.write(" ! Global Constants\n\n")
node = next((x for x in findNodes(self.doc.getroot(), "compounddef", kind="namespace") if x.findtext("compoundname") == "OpenMM"))
for section in findNodes(node, "sectiondef", kind="var"):
for memberNode in findNodes(section, "memberdef", kind="variable", mutable="no", prot="public", static="yes"):
vDef = convertOpenMMPrefix(getText("name", memberNode))
iDef = getText("initializer", memberNode)
if iDef.startswith("="):
iDef = iDef[1:]
self.out.write(" real*8, parameter :: OpenMM_%s = %s\n" % (vDef, iDef))
def writeTypeDeclarations(self):
self.out.write("\n ! Type Declarations\n")
for classNode in self._orderedClassNodes:
className = getText("compoundname", classNode)
shortName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className)
self.out.write("\n type %s\n" % typeName)
self.out.write(" integer*8 :: handle = 0\n")
self.out.write(" end type\n")
self.typesByShortName[shortName] = typeName
def writeClasses(self):
for classNode in self._orderedClassNodes:
className = getText("compoundname", classNode)
self.out.write("\n ! %s\n" % className)
self.writeMethods(classNode)
self.out.write("\n")
def writeEnumerations(self, classNode):
enumNodes = []
for section in findNodes(classNode, "sectiondef", kind="public-type"):
for node in findNodes(section, "memberdef", kind="enum", prot="public"):
enumNodes.append(node)
className = getText("compoundname", classNode)
typeName = convertOpenMMPrefix(className)
for enumNode in enumNodes:
for valueNode in findNodes(enumNode, "enumvalue", prot="public"):
vName = convertOpenMMPrefix(getText("name", valueNode))
vInit = getText("initializer", valueNode)
if vInit.startswith("="):
vInit = vInit[1:].strip()
self.out.write(" integer*4, parameter :: %s_%s = %s\n" % (typeName, vName, vInit))
enumName = getText("name", enumNode)
enumTypeName = "%s_%s" % (typeName, enumName)
self.typesByShortName[enumName] = enumTypeName
self.enumerationTypes.add(enumName)
if len(enumNodes)>0: self.out.write("\n")
def writeMethods(self, classNode):
methodList = self.getClassMethods(classNode)
className = getText("compoundname", classNode)
shortClassName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className)
destructorName = '~'+shortClassName
isAbstract = any('virt' in method.attrib and method.attrib['virt'] == 'pure-virtual' for method in classNode.getiterator('memberdef'))
if not isAbstract:
# Write constructors
numConstructors = 0
for methodNode in methodList:
methodDefinition = getText("definition", methodNode)
shortMethodDefinition = stripOpenMMPrefix(methodDefinition)
methodName = shortMethodDefinition.split()[-1]
if methodName == shortClassName:
if self.shouldHideMethod(methodNode):
continue
numConstructors += 1
if numConstructors == 1:
suffix = ""
else:
suffix = "_%d" % numConstructors
self.out.write(" subroutine %s_create%s(result" % (typeName, suffix))
self.writeArguments(methodNode, True)
self.out.write(")\n")
self.out.write(" use OpenMM_Types; implicit none\n")
self.out.write(" type (%s) result\n" % typeName)
self.declareArguments(methodNode)
self.out.write(" end subroutine\n")
# Write destructor
self.out.write(" subroutine %s_destroy(destroy)\n" % typeName)
self.out.write(" use OpenMM_Types; implicit none\n")
self.out.write(" type (%s) destroy\n" % typeName)
self.out.write(" end subroutine\n")
# Record method names for future reference.
methodNames = {}
for methodNode in methodList:
methodDefinition = getText("definition", methodNode)
shortMethodDefinition = stripOpenMMPrefix(methodDefinition)
methodNames[methodNode] = shortMethodDefinition.split()[-1]
# Write other methods
for methodNode in methodList:
methodName = methodNames[methodNode]
if methodName in (shortClassName, destructorName):
continue
if self.shouldHideMethod(methodNode):
continue
isConstMethod = (methodNode.attrib['const'] == 'yes')
if isConstMethod and any(methodNames[m] == methodName and m.attrib['const'] == 'no' for m in methodList):
# There are two identical methods that differ only in whether they are const. Skip the const one.
continue
returnType = self.getType(getText("type", methodNode))
hasReturnValue = (returnType in ('integer*4', 'real*8'))
hasReturnArg = not (hasReturnValue or returnType == 'void')
functionName = "%s_%s" % (typeName, methodName)
if hasReturnValue:
self.out.write(" function ")
else:
self.out.write(" subroutine ")
self.out.write("%s(" % functionName)
isInstanceMethod = (methodNode.attrib['static'] != 'yes')
if isInstanceMethod:
self.out.write("target")
numArgs = self.writeArguments(methodNode, isInstanceMethod)
if hasReturnArg:
if isInstanceMethod or numArgs > 0:
self.out.write(", ")
self.out.write("result")
self.out.write(")\n")
self.out.write(" use OpenMM_Types; implicit none\n")
self.out.write(" type (%s) target\n" % typeName)
self.declareArguments(methodNode)
if hasReturnValue:
self.declareOneArgument(returnType, functionName)
if hasReturnArg:
self.declareOneArgument(returnType, 'result')
if hasReturnValue:
self.out.write(" end function\n")
else:
self.out.write(" end subroutine\n")
def writeArguments(self, methodNode, initialSeparator):
paramList = findNodes(methodNode, 'param')
if initialSeparator:
separator = ", "
else:
separator = ""
numArgs = 0
for node in paramList:
try:
type = getText('type', node)
except IndexError:
type = getText('type/ref', node)
if type == 'void':
continue
name = getText('declname', node)
self.out.write("%s%s" % (separator, name))
separator = ", &\n"
numArgs += 1
return numArgs
def declareOneArgument(self, type, name):
if type == 'void':
return
type = self.getType(type)
if type == 'Vec3':
self.out.write(" real*8 %s(3)\n" % name)
else:
self.out.write(" %s %s\n" % (type, name))
def declareArguments(self, methodNode):
paramList = findNodes(methodNode, 'param')
for node in paramList:
try:
type = getText('type', node)
except IndexError:
type = getText('type/ref', node)
name = getText('declname', node)
self.declareOneArgument(type, name)
def getType(self, type):
if type in self.typeTranslations:
return self.typeTranslations[type]
if type in self.enumerationTypes:
return 'integer*4'
if type in self.typesByShortName:
return 'type (%s)' % self.typesByShortName[type]
if type.startswith('const '):
return self.getType(type[6:].strip())
if type.endswith('&') or type.endswith('*'):
return self.getType(type[:-1].strip())
return type
def writeOutput(self):
print("""
MODULE OpenMM_Types
implicit none
""", file=self.out)
self.writeGlobalConstants()
self.writeTypeDeclarations()
print("""
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_IntArray
integer*8 :: handle = 0
end type
type OpenMM_IntSet
integer*8 :: handle = 0
end type
! Enumerations
integer*4, parameter :: OpenMM_False = 0
integer*4, parameter :: OpenMM_True = 1""", file=self.out)
for classNode in self._orderedClassNodes:
self.writeEnumerations(classNode)
print("""
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 subroutine
! OpenMM_Vec3Array
subroutine OpenMM_Vec3Array_create(result, size)
use OpenMM_Types; implicit none
integer*4 size
type (OpenMM_Vec3Array) result
end subroutine
subroutine OpenMM_Vec3Array_destroy(destroy)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) destroy
end subroutine
function OpenMM_Vec3Array_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) target
integer*4 OpenMM_Vec3Array_getSize
end function
subroutine OpenMM_Vec3Array_resize(target, size)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) target
integer*4 size
end subroutine
subroutine OpenMM_Vec3Array_append(target, vec)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) target
real*8 vec(3)
end subroutine
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
subroutine OpenMM_Vec3Array_get(target, index, result)
use OpenMM_Types; implicit none
type (OpenMM_Vec3Array) target
integer*4 index
real*8 result(3)
end subroutine
! OpenMM_StringArray
subroutine OpenMM_StringArray_create(result, size)
use OpenMM_Types; implicit none
integer*4 size
type (OpenMM_StringArray) result
end subroutine
subroutine OpenMM_StringArray_destroy(destroy)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) destroy
end subroutine
function OpenMM_StringArray_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
integer*4 OpenMM_StringArray_getSize
end function
subroutine OpenMM_StringArray_resize(target, size)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
integer*4 size
end subroutine
subroutine OpenMM_StringArray_append(target, str)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
character(*) str
end subroutine
subroutine OpenMM_StringArray_set(target, index, str)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
integer*4 index
character(*) str
end subroutine
subroutine OpenMM_StringArray_get(target, index, result)
use OpenMM_Types; implicit none
type (OpenMM_StringArray) target
integer*4 index
character(*) result
end subroutine
! OpenMM_BondArray
subroutine OpenMM_BondArray_create(result, size)
use OpenMM_Types; implicit none
integer*4 size
type (OpenMM_BondArray) result
end subroutine
subroutine OpenMM_BondArray_destroy(destroy)
use OpenMM_Types; implicit none
type (OpenMM_BondArray) destroy
end subroutine
function OpenMM_BondArray_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_BondArray) target
integer*4 OpenMM_BondArray_getSize
end function
subroutine OpenMM_BondArray_resize(target, size)
use OpenMM_Types; implicit none
type (OpenMM_BondArray) target
integer*4 size
end subroutine
subroutine OpenMM_BondArray_append(target, particle1, particle2)
use OpenMM_Types; implicit none
type (OpenMM_BondArray) target
integer*4 particle1
integer*4 particle2
end subroutine
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
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 subroutine
! OpenMM_ParameterArray
function OpenMM_ParameterArray_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_ParameterArray) target
integer*4 OpenMM_ParameterArray_getSize
end function
subroutine OpenMM_ParameterArray_get(target, name, result)
use OpenMM_Types; implicit none
type (OpenMM_ParameterArray) target
character(*) name
character(*) result
end subroutine
! OpenMM_PropertyArray
function OpenMM_PropertyArray_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_ParameterArray) target
integer*4 OpenMM_PropertyArray_getSize
end function
subroutine OpenMM_PropertyArray_get(target, name, result)
use OpenMM_Types; implicit none
type (OpenMM_PropertyArray) target
character(*) name
character(*) result
end subroutine""", file=self.out)
arrayTypes = {'OpenMM_DoubleArray':'real*8', 'OpenMM_IntArray':'integer*4'}
for name in arrayTypes:
values = {'type':arrayTypes[name], 'name':name}
print("""
! %(name)s
subroutine %(name)s_create(result, size)
use OpenMM_Types; implicit none
integer*4 size
type (%(name)s) result
end subroutine
subroutine %(name)s_destroy(destroy)
use OpenMM_Types; implicit none
type (%(name)s) destroy
end subroutine
function %(name)s_getSize(target)
use OpenMM_Types; implicit none
type (%(name)s) target
integer*4 %(name)s_getSize
end function
subroutine %(name)s_resize(target, size)
use OpenMM_Types; implicit none
type (%(name)s) target
integer*4 size
end subroutine
subroutine %(name)s_append(target, value)
use OpenMM_Types; implicit none
type (%(name)s) target
%(type)s value
end subroutine
subroutine %(name)s_set(target, index, value)
use OpenMM_Types; implicit none
type (%(name)s) target
integer*4 index
%(type)s value
end subroutine
subroutine %(name)s_get(target, index, result)
use OpenMM_Types; implicit none
type (%(name)s) target
integer*4 index
%(type)s result
end subroutine""" % values, file=self.out)
print("""
! These methods need to be handled specially, since their C++ APIs cannot be directly translated to Fortran.
! Unlike the C++ versions, the return value is allocated on the heap, and you must delete it yourself.
subroutine OpenMM_Context_getState(target, types, enforcePeriodicBox, result)
use OpenMM_Types; implicit none
type (OpenMM_Context) target
integer*4 types
integer*4 enforcePeriodicBox
type(OpenMM_State) result
end subroutine
subroutine OpenMM_Platform_loadPluginsFromDirectory(directory, result)
use OpenMM_Types; implicit none
character(*) directory
type(OpenMM_StringArray) result
end subroutine
subroutine OpenMM_XmlSerializer_serializeSystemToC(system, result, result_length)
use iso_c_binding; use OpenMM_Types; implicit none
type(OpenMM_System), intent(in) :: system
type(c_ptr), intent(out) :: result
integer, intent(out) :: result_length
end subroutine
subroutine OpenMM_XmlSerializer_serializeStateToC(state, result, result_length)
use iso_c_binding; use OpenMM_Types; implicit none
type(OpenMM_State), intent(in) :: state
type(c_ptr), intent(out) :: result
integer, intent(out) :: result_length
end subroutine
subroutine OpenMM_XmlSerializer_serializeIntegratorToC(integrator, result, result_length)
use iso_c_binding; use OpenMM_Types; implicit none
type(OpenMM_Integrator), intent(in) :: integrator
type(c_ptr), intent(out) :: result
integer, intent(out) :: result_length
end subroutine
subroutine OpenMM_XmlSerializer_deserializeSystem(xml, result)
use OpenMM_Types; implicit none
character(*) xml
type(OpenMM_System) result
end subroutine
subroutine OpenMM_XmlSerializer_deserializeState(xml, result)
use OpenMM_Types; implicit none
character(*) xml
type(OpenMM_State) result
end subroutine
subroutine OpenMM_XmlSerializer_deserializeIntegrator(xml, result)
use OpenMM_Types; implicit none
character(*) xml
type(OpenMM_Integrator) result
end subroutine""", file=self.out)
self.writeClasses()
print("""
end interface
contains
subroutine OpenMM_XmlSerializer_serializeSystem(system, result)
use iso_c_binding, only: c_ptr, c_int, c_char, c_f_pointer
type(OpenMM_System), intent(in) :: system
character(len=1), allocatable, dimension(:), intent(out) :: result
character(kind=c_char), pointer, dimension(:) :: fstr
type(c_ptr) :: cstr
integer :: i
integer(kind=c_int) :: result_length
call OpenMM_XmlSerializer_serializeSystemToC(system, cstr, result_length)
call c_f_pointer(cstr, fstr, [ result_length ])
allocate(character(len=1) :: result(result_length))
do i=1,result_length
result(i) = fstr(i)
end do
end subroutine
subroutine OpenMM_XmlSerializer_serializeState(state, result)
use iso_c_binding, only: c_ptr, c_int, c_char, c_f_pointer
type(OpenMM_State), intent(in) :: state
character(len=1), allocatable, dimension(:), intent(out) :: result
character(kind=c_char), pointer, dimension(:) :: fstr
type(c_ptr) :: cstr
integer :: i
integer(kind=c_int) :: result_length
call OpenMM_XmlSerializer_serializeStateToC(state, cstr, result_length)
call c_f_pointer(cstr, fstr, [ result_length ])
allocate(character(len=1) :: result(result_length))
do i=1,result_length
result(i) = fstr(i)
end do
end subroutine
subroutine OpenMM_XmlSerializer_serializeIntegrator(integrator, result)
use iso_c_binding, only: c_ptr, c_int, c_char, c_f_pointer
type(OpenMM_Integrator), intent(in) :: integrator
character(len=1), allocatable, dimension(:), intent(out) :: result
character(kind=c_char), pointer, dimension(:) :: fstr
type(c_ptr) :: cstr
integer :: i
integer(kind=c_int) :: result_length
call OpenMM_XmlSerializer_serializeIntegratorToC(integrator, cstr, result_length)
call c_f_pointer(cstr, fstr, [ result_length ])
allocate(character(len=1) :: result(result_length))
do i=1,result_length
result(i) = fstr(i)
end do
end subroutine
END MODULE OpenMM""", file=self.out)
class FortranSourceGenerator(WrapperGenerator):
"""This class generates the source file for the Fortran API wrappers."""
def __init__(self, inputDirname, output):
WrapperGenerator.__init__(self, inputDirname, output)
self.typeTranslations = {'bool': 'OpenMM_Boolean',
'Vec3': 'OpenMM_Vec3',
'std::string': 'char*',
'const std::string &': 'const char*',
'std::vector< std::string >': 'OpenMM_StringArray',
'std::vector< Vec3 >': 'OpenMM_Vec3Array',
'std::vector< std::pair< int, int > >': 'OpenMM_BondArray',
'std::map< std::string, double >': 'OpenMM_ParameterArray',
'std::map< std::string, std::string >': 'OpenMM_PropertyArray',
'std::vector< double >': 'OpenMM_DoubleArray',
'std::vector< int >': 'OpenMM_IntArray',
'std::set< int >': 'OpenMM_IntSet'}
self.inverseTranslations = dict((self.typeTranslations[key], key) for key in self.typeTranslations)
self.classesByShortName = {}
self.enumerationTypes = {}
self.findTypes()
def findTypes(self):
for classNode in self._orderedClassNodes:
className = getText("compoundname", classNode)
shortName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className)
self.typesByShortName[shortName] = typeName
self.classesByShortName[shortName] = className
def findEnumerations(self, classNode):
enumNodes = []
for section in findNodes(classNode, "sectiondef", kind="public-type"):
for node in findNodes(section, "memberdef", kind="enum", prot="public"):
enumNodes.append(node)
className = getText("compoundname", classNode)
typeName = convertOpenMMPrefix(className)
for enumNode in enumNodes:
enumName = getText("name", enumNode)
enumTypeName = "%s_%s" % (typeName, enumName)
enumClassName = "%s::%s" % (className, enumName)
self.typesByShortName[enumName] = enumTypeName
self.classesByShortName[enumName] = enumClassName
self.enumerationTypes[enumClassName] = enumTypeName
def writeClasses(self):
for classNode in self._orderedClassNodes:
className = stripOpenMMPrefix(getText("compoundname", classNode))
self.out.write("\n/* OpenMM::%s */\n" % className)
self.findEnumerations(classNode)
self.writeMethods(classNode)
self.out.write("\n")
def writeMethods(self, classNode):
methodList = self.getClassMethods(classNode)
className = getText("compoundname", classNode)
shortClassName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className)
destructorName = '~'+shortClassName
isAbstract = any('virt' in method.attrib and method.attrib['virt'] == 'pure-virtual' for method in classNode.getiterator('memberdef'))
if not isAbstract:
# Write constructors
numConstructors = 0
for methodNode in methodList:
methodDefinition = getText("definition", methodNode)
shortMethodDefinition = stripOpenMMPrefix(methodDefinition)
methodName = shortMethodDefinition.split()[-1]
if methodName == shortClassName:
if self.shouldHideMethod(methodNode):
continue
numConstructors += 1
if numConstructors == 1:
suffix = ""
else:
suffix = "_%d" % numConstructors
functionName = "%s_create%s" % (typeName, suffix)
self.writeOneConstructor(classNode, methodNode, functionName, functionName.lower()+'_')
self.writeOneConstructor(classNode, methodNode, functionName, functionName.upper())
# Write destructor
functionName = "%s_destroy" % typeName
self.writeOneDestructor(typeName, functionName.lower()+'_')
self.writeOneDestructor(typeName, functionName.upper())
# Record method names for future reference.
methodNames = {}
for methodNode in methodList:
methodDefinition = getText("definition", methodNode)
shortMethodDefinition = stripOpenMMPrefix(methodDefinition)
methodNames[methodNode] = shortMethodDefinition.split()[-1]
# Write other methods
for methodNode in methodList:
methodName = methodNames[methodNode]
if methodName in (shortClassName, destructorName):
continue
if '~' in methodName:
print('***', methodName, destructorName)
if self.shouldHideMethod(methodNode):
continue
isConstMethod = (methodNode.attrib['const'] == 'yes')
if isConstMethod and any(methodNames[m] == methodName and m.attrib['const'] == 'no' for m in methodList):
# There are two identical methods that differ only in whether they are const. Skip the const one.
continue
functionName = "%s_%s" % (typeName, methodName)
self.writeOneMethod(classNode, methodNode, functionName, functionName.lower()+'_')
self.writeOneMethod(classNode, methodNode, functionName, functionName.upper())
def writeOneConstructor(self, classNode, methodNode, functionName, wrapperFunctionName):
className = getText("compoundname", classNode)
shortClassName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className)
self.out.write("OPENMM_EXPORT void %s(%s*& result" % (wrapperFunctionName, typeName))
self.writeArguments(methodNode, True)
self.out.write(") {\n")
self.out.write(" result = %s(" % functionName)
self.writeInvocationArguments(methodNode, False)
self.out.write(");\n")
self.out.write("}\n")
def writeOneDestructor(self, typeName, wrapperFunctionName):
self.out.write("OPENMM_EXPORT void %s(%s*& destroy) {\n" % (wrapperFunctionName, typeName))
self.out.write(" %s_destroy(destroy);\n" % typeName)
self.out.write(" destroy = 0;\n")
self.out.write("}\n")
def writeOneMethod(self, classNode, methodNode, methodName, wrapperFunctionName):
className = getText("compoundname", classNode)
typeName = convertOpenMMPrefix(className)
isConstMethod = (methodNode.attrib['const'] == 'yes')
methodType = getText("type", methodNode)
returnType = self.getType(methodType)
hasReturnValue = (returnType in ('int', 'bool', 'double'))
hasReturnArg = not (hasReturnValue or returnType == 'void')
if methodType in self.classesByShortName:
methodType = self.classesByShortName[methodType]
self.out.write("OPENMM_EXPORT ")
if hasReturnValue:
self.out.write(returnType)
else:
self.out.write('void')
self.out.write(" %s(" % wrapperFunctionName)
isInstanceMethod = (methodNode.attrib['static'] != 'yes')
if isInstanceMethod:
if isConstMethod:
self.out.write('const ')
self.out.write("%s*& target" % typeName)
returnArg = None
if hasReturnArg:
if returnType == 'const char*':
# We need a non-const buffer to copy the result into
returnArg = 'char* result'
else:
returnArg = "%s& result" % returnType
numArgs = self.writeArguments(methodNode, isInstanceMethod, returnArg)
if hasReturnArg and returnType == 'const char*':
self.out.write(", int result_length")
self.out.write(") {\n")
self.out.write(" ")
if hasReturnValue:
self.out.write("return ")
if hasReturnArg:
if returnType == 'const char*':
self.out.write("const char* result_chars = ")
else:
self.out.write("result = ")
self.out.write("%s(" % methodName)
if isInstanceMethod:
self.out.write("target")
self.writeInvocationArguments(methodNode, isInstanceMethod)
self.out.write(');\n')
if hasReturnArg and returnType == 'const char*':
self.out.write(" copyAndPadString(result, result_chars, result_length);\n")
self.out.write("}\n")
def writeArguments(self, methodNode, initialSeparator, extraArg=None):
paramList = findNodes(methodNode, 'param')
if initialSeparator:
separator = ", "
else:
separator = ""
numArgs = 0
# Write the arguments.
for node in paramList:
try:
type = getText('type', node)
except IndexError:
type = getText('type/ref', node)
if type == 'void':
continue
type = self.getType(type)
if self.isHandleType(type):
type = type+'&'
elif type[-1] not in ('&', '*'):
type = type+' const&'
name = getText('declname', node)
self.out.write("%s%s %s" % (separator, type, name))
separator = ", "
numArgs += 1
# If an extra argument is needed for the return value, write it.
if extraArg is not None:
self.out.write("%s%s" % (separator, extraArg))
separator = ", "
numArgs += 1
# Write length arguments for strings.
for node in paramList:
try:
type = getText('type', node)
except IndexError:
type = getText('type/ref', node)
if type == 'const std::string &':
name = getText('declname', node)
self.out.write(", int %s_length" % name)
numArgs += 1
return numArgs
def writeInvocationArguments(self, methodNode, initialSeparator):
paramList = findNodes(methodNode, 'param')
if initialSeparator:
separator = ", "
else:
separator = ""
for node in paramList:
try:
type = getText('type', node)
except IndexError:
type = getText('type/ref', node)
if type == 'void':
continue
name = getText('declname', node)
if type == 'const std::string &':
name = 'makeString(%s, %s_length).c_str()' % (name, name)
self.out.write("%s%s" % (separator, name))
separator = ", "
def getType(self, type):
if type in self.typeTranslations:
return self.typeTranslations[type]
if type in self.typesByShortName:
return self.typesByShortName[type]
if type.startswith('const '):
return 'const '+self.getType(type[6:].strip())
if type.endswith('&') or type.endswith('*'):
return self.getType(type[:-1].strip())+'*'
return type
def isHandleType(self, type):
if type.startswith('OpenMM_'):
return True;
if type == 'Vec3':
return True
if type.endswith('*') or type.endswith('&'):
return self.isHandleType(type[:-1].strip())
if type.startswith('const '):
return self.isHandleType(type[6:].strip())
return False
def writeOutput(self):
print("""
#include "OpenMM.h"
#include "OpenMMCWrapper.h"
#include <cstring>
#include <vector>
#include <cstdlib>
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 < length; i++) {
if (source[i] == 0)
reachedEnd = true;
dest[i] = (reachedEnd ? ' ' : source[i]);
}
}
static string makeString(const char* fsrc, int length) {
while (length && fsrc[length-1]==' ')
--length;
return string(fsrc, length);
}
static void convertStringToChars(char* source, char*& cstr, int& length) {
length = strlen(source);
cstr = new char[length+1];
strcpy(cstr, source);
free(source);
}
extern "C" {
/* OpenMM_Vec3 */
OPENMM_EXPORT void openmm_vec3_scale_(const OpenMM_Vec3& vec, double const& scale, OpenMM_Vec3& result) {
result = OpenMM_Vec3_scale(vec, scale);
}
OPENMM_EXPORT void OPENMM_VEC3_SCALE(const OpenMM_Vec3& vec, double const& scale, OpenMM_Vec3& result) {
result = OpenMM_Vec3_scale(vec, scale);
}
/* OpenMM_Vec3Array */
OPENMM_EXPORT void openmm_vec3array_create_(OpenMM_Vec3Array*& result, const int& size) {
result = OpenMM_Vec3Array_create(size);
}
OPENMM_EXPORT void OPENMM_VEC3ARRAY_CREATE(OpenMM_Vec3Array*& result, const int& size) {
result = OpenMM_Vec3Array_create(size);
}
OPENMM_EXPORT void openmm_vec3array_destroy_(OpenMM_Vec3Array*& array) {
OpenMM_Vec3Array_destroy(array);
array = 0;
}
OPENMM_EXPORT void OPENMM_VEC3ARRAY_DESTROY(OpenMM_Vec3Array*& array) {
OpenMM_Vec3Array_destroy(array);
array = 0;
}
OPENMM_EXPORT int openmm_vec3array_getsize_(const OpenMM_Vec3Array* const& array) {
return OpenMM_Vec3Array_getSize(array);
}
OPENMM_EXPORT int OPENMM_VEC3ARRAY_GETSIZE(const OpenMM_Vec3Array* const& array) {
return OpenMM_Vec3Array_getSize(array);
}
OPENMM_EXPORT void openmm_vec3array_resize_(OpenMM_Vec3Array* const& array, const int& size) {
OpenMM_Vec3Array_resize(array, size);
}
OPENMM_EXPORT void OPENMM_VEC3ARRAY_RESIZE(OpenMM_Vec3Array* const& array, const int& size) {
OpenMM_Vec3Array_resize(array, size);
}
OPENMM_EXPORT void openmm_vec3array_append_(OpenMM_Vec3Array* const& array, const OpenMM_Vec3& vec) {
OpenMM_Vec3Array_append(array, vec);
}
OPENMM_EXPORT void OPENMM_VEC3ARRAY_APPEND(OpenMM_Vec3Array* const& array, const OpenMM_Vec3& vec) {
OpenMM_Vec3Array_append(array, vec);
}
OPENMM_EXPORT void openmm_vec3array_set_(OpenMM_Vec3Array* const& array, const int& index, const OpenMM_Vec3& vec) {
OpenMM_Vec3Array_set(array, index-1, vec);
}
OPENMM_EXPORT void OPENMM_VEC3ARRAY_SET(OpenMM_Vec3Array* const& array, const int& index, const OpenMM_Vec3& vec) {
OpenMM_Vec3Array_set(array, index-1, vec);
}
OPENMM_EXPORT void openmm_vec3array_get_(const OpenMM_Vec3Array* const& array, const int& index, OpenMM_Vec3& result) {
result = *OpenMM_Vec3Array_get(array, index-1);
}
OPENMM_EXPORT void OPENMM_VEC3ARRAY_GET(const OpenMM_Vec3Array* const& array, const int& index, OpenMM_Vec3& result) {
result = *OpenMM_Vec3Array_get(array, index-1);
}
/* OpenMM_StringArray */
OPENMM_EXPORT void openmm_stringarray_create_(OpenMM_StringArray*& result, const int& size) {
result = OpenMM_StringArray_create(size);
}
OPENMM_EXPORT void OPENMM_STRINGARRAY_CREATE(OpenMM_StringArray*& result, const int& size) {
result = OpenMM_StringArray_create(size);
}
OPENMM_EXPORT void openmm_stringarray_destroy_(OpenMM_StringArray*& array) {
OpenMM_StringArray_destroy(array);
array = 0;
}
OPENMM_EXPORT void OPENMM_STRINGARRAY_DESTROY(OpenMM_StringArray*& array) {
OpenMM_StringArray_destroy(array);
array = 0;
}
OPENMM_EXPORT int openmm_stringarray_getsize_(const OpenMM_StringArray* const& array) {
return OpenMM_StringArray_getSize(array);
}
OPENMM_EXPORT int OPENMM_STRINGARRAY_GETSIZE(const OpenMM_StringArray* const& array) {
return OpenMM_StringArray_getSize(array);
}
OPENMM_EXPORT void openmm_stringarray_resize_(OpenMM_StringArray* const& array, const int& size) {
OpenMM_StringArray_resize(array, size);
}
OPENMM_EXPORT void OPENMM_STRINGARRAY_RESIZE(OpenMM_StringArray* const& array, const int& size) {
OpenMM_StringArray_resize(array, size);
}
OPENMM_EXPORT void openmm_stringarray_append_(OpenMM_StringArray* const& array, const char* str, int length) {
OpenMM_StringArray_append(array, makeString(str, length).c_str());
}
OPENMM_EXPORT void OPENMM_STRINGARRAY_APPEND(OpenMM_StringArray* const& array, const char* str, int length) {
OpenMM_StringArray_append(array, makeString(str, length).c_str());
}
OPENMM_EXPORT void openmm_stringarray_set_(OpenMM_StringArray* const& array, const int& 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& array, const int& 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& array, const int& 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& array, const int& 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*& result, const int& size) {
result = OpenMM_BondArray_create(size);
}
OPENMM_EXPORT void OPENMM_BONDARRAY_CREATE(OpenMM_BondArray*& result, const int& size) {
result = OpenMM_BondArray_create(size);
}
OPENMM_EXPORT void openmm_bondarray_destroy_(OpenMM_BondArray*& array) {
OpenMM_BondArray_destroy(array);
array = 0;
}
OPENMM_EXPORT void OPENMM_BONDARRAY_DESTROY(OpenMM_BondArray*& array) {
OpenMM_BondArray_destroy(array);
array = 0;
}
OPENMM_EXPORT int openmm_bondarray_getsize_(const OpenMM_BondArray* const& array) {
return OpenMM_BondArray_getSize(array);
}
OPENMM_EXPORT int OPENMM_BONDARRAY_GETSIZE(const OpenMM_BondArray* const& array) {
return OpenMM_BondArray_getSize(array);
}
OPENMM_EXPORT void openmm_bondarray_resize_(OpenMM_BondArray* const& array, const int& size) {
OpenMM_BondArray_resize(array, size);
}
OPENMM_EXPORT void OPENMM_BONDARRAY_RESIZE(OpenMM_BondArray* const& array, const int& size) {
OpenMM_BondArray_resize(array, size);
}
OPENMM_EXPORT void openmm_bondarray_append_(OpenMM_BondArray* const& array, const int& particle1, const int& particle2) {
OpenMM_BondArray_append(array, particle1, particle2);
}
OPENMM_EXPORT void OPENMM_BONDARRAY_APPEND(OpenMM_BondArray* const& array, const int& particle1, const int& particle2) {
OpenMM_BondArray_append(array, particle1, particle2);
}
OPENMM_EXPORT void openmm_bondarray_set_(OpenMM_BondArray* const& array, const int& index, const int& particle1, const int& particle2) {
OpenMM_BondArray_set(array, index-1, particle1, particle2);
}
OPENMM_EXPORT void OPENMM_BONDARRAY_SET(OpenMM_BondArray* const& array, const int& index, const int& particle1, const int& particle2) {
OpenMM_BondArray_set(array, index-1, particle1, particle2);
}
OPENMM_EXPORT void openmm_bondarray_get_(const OpenMM_BondArray* const& array, const int& index, int* particle1, int* particle2) {
OpenMM_BondArray_get(array, index-1, particle1, particle2);
}
OPENMM_EXPORT void OPENMM_BONDARRAY_GET(const OpenMM_BondArray* const& array, const int& 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& array) {
return OpenMM_ParameterArray_getSize(array);
}
OPENMM_EXPORT int OPENMM_PARAMETERARRAY_GETSIZE(const OpenMM_ParameterArray* const& array) {
return OpenMM_ParameterArray_getSize(array);
}
OPENMM_EXPORT double openmm_parameterarray_get_(const OpenMM_ParameterArray* const& 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& 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& array) {
return OpenMM_PropertyArray_getSize(array);
}
OPENMM_EXPORT int OPENMM_PROPERTYARRAY_GETSIZE(const OpenMM_PropertyArray* const& array) {
return OpenMM_PropertyArray_getSize(array);
}
OPENMM_EXPORT const char* openmm_propertyarray_get_(const OpenMM_PropertyArray* const& 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& array, const char* name, int length) {
return OpenMM_PropertyArray_get(array, makeString(name, length).c_str());
}""", file=self.out)
for type in ('double', 'int'):
name = 'OpenMM_%sArray' % type.capitalize()
values = {'type':type, 'name':name, 'name_lower':name.lower(), 'name_upper':name.upper()}
print("""
/* %(name)s */
OPENMM_EXPORT void %(name_lower)s_create_(%(name)s*& result, const int& size) {
result = %(name)s_create(size);
}
OPENMM_EXPORT void %(name_upper)s_CREATE(%(name)s*& result, const int& size) {
result = %(name)s_create(size);
}
OPENMM_EXPORT void %(name_lower)s_destroy_(%(name)s*& array) {
%(name)s_destroy(array);
array = 0;
}
OPENMM_EXPORT void %(name_upper)s_DESTROY(%(name)s*& array) {
%(name)s_destroy(array);
array = 0;
}
OPENMM_EXPORT int %(name_lower)s_getsize_(const %(name)s* const& array) {
return %(name)s_getSize(array);
}
OPENMM_EXPORT int %(name_upper)s_GETSIZE(const %(name)s* const& array) {
return %(name)s_getSize(array);
}
OPENMM_EXPORT void %(name_lower)s_resize_(%(name)s* const& array, const int& size) {
%(name)s_resize(array, size);
}
OPENMM_EXPORT void %(name_upper)s_RESIZE(%(name)s* const& array, const int& size) {
%(name)s_resize(array, size);
}
OPENMM_EXPORT void %(name_lower)s_append_(%(name)s* const& array, const %(type)s& value) {
%(name)s_append(array, value);
}
OPENMM_EXPORT void %(name_upper)s_APPEND(%(name)s* const& array, const %(type)s& value) {
%(name)s_append(array, value);
}
OPENMM_EXPORT void %(name_lower)s_set_(%(name)s* const& array, const int& index, const %(type)s& value) {
%(name)s_set(array, index-1, value);
}
OPENMM_EXPORT void %(name_upper)s_SET(%(name)s* const& array, const int& index, const %(type)s& value) {
%(name)s_set(array, index-1, value);
}
OPENMM_EXPORT void %(name_lower)s_get_(const %(name)s* const& array, const int& index, %(type)s& result) {
result = %(name)s_get(array, index-1);
}
OPENMM_EXPORT void %(name_upper)s_GET(const %(name)s* const& array, const int& index, %(type)s& result) {
result = %(name)s_get(array, index-1);
}""" % values, file=self.out)
for type in ('int', ):
name = 'OpenMM_%sSet' % type.capitalize()
values = {'type':type, 'name':name, 'name_lower':name.lower(), 'name_upper':name.upper()}
print("""
/* %(name)s */
OPENMM_EXPORT void %(name_lower)s_create_(%(name)s*& result) {
result = %(name)s_create();
}
OPENMM_EXPORT void %(name_upper)s_CREATE(%(name)s*& result) {
result = %(name)s_create();
}
OPENMM_EXPORT void %(name_lower)s_destroy_(%(name)s*& array) {
%(name)s_destroy(array);
array = 0;
}
OPENMM_EXPORT void %(name_upper)s_DESTROY(%(name)s*& array) {
%(name)s_destroy(array);
array = 0;
}
OPENMM_EXPORT int %(name_lower)s_getsize_(const %(name)s* const& array) {
return %(name)s_getSize(array);
}
OPENMM_EXPORT int %(name_upper)s_GETSIZE(const %(name)s* const& array) {
return %(name)s_getSize(array);
}
OPENMM_EXPORT void %(name_lower)s_insert_(%(name)s* const& array, const %(type)s& value) {
%(name)s_insert(array, value);
}
OPENMM_EXPORT void %(name_upper)s_INSERT(%(name)s* const& array, const %(type)s& value) {
%(name)s_insert(array, value);
}""" % values, file=self.out)
print("""
/* 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*& target, int const& types, int const& enforcePeriodicBox, OpenMM_State*& result) {
result = OpenMM_Context_getState(target, types, enforcePeriodicBox);
}
OPENMM_EXPORT void OPENMM_CONTEXT_GETSTATE(const OpenMM_Context*& target, int const& types, int const& enforcePeriodicBox, OpenMM_State*& result) {
result = OpenMM_Context_getState(target, types, enforcePeriodicBox);
}
OPENMM_EXPORT void openmm_platform_loadpluginsfromdirectory_(const char* directory, OpenMM_StringArray*& result, int length) {
result = OpenMM_Platform_loadPluginsFromDirectory(makeString(directory, length).c_str());
}
OPENMM_EXPORT void OPENMM_PLATFORM_LOADPLUGINSFROMDIRECTORY(const char* directory, OpenMM_StringArray*& result, int length) {
result = OpenMM_Platform_loadPluginsFromDirectory(makeString(directory, length).c_str());
}
OPENMM_EXPORT void openmm_xmlserializer_serializesystemtoc_(OpenMM_System*& system, char*& result, int& result_length) {
convertStringToChars(OpenMM_XmlSerializer_serializeSystem(system), result, result_length);
}
OPENMM_EXPORT void OPENMM_XMLSERIALIZER_SERIALIZESYSTEMTOC(OpenMM_System*& system, char*& result, int& result_length) {
convertStringToChars(OpenMM_XmlSerializer_serializeSystem(system), result, result_length);
}
OPENMM_EXPORT void openmm_xmlserializer_serializestatetoc_(OpenMM_State*& state, char*& result, int& result_length) {
convertStringToChars(OpenMM_XmlSerializer_serializeState(state), result, result_length);
}
OPENMM_EXPORT void OPENMM_XMLSERIALIZER_SERIALIZESTATETOC(OpenMM_State*& state, char*& result, int& result_length) {
convertStringToChars(OpenMM_XmlSerializer_serializeState(state), result, result_length);
}
OPENMM_EXPORT void openmm_xmlserializer_serializeintegratortoc_(OpenMM_Integrator*& integrator, char*& result, int& result_length) {
convertStringToChars(OpenMM_XmlSerializer_serializeIntegrator(integrator), result, result_length);
}
OPENMM_EXPORT void OPENMM_XMLSERIALIZER_SERIALIZEINTEGRATORTOC(OpenMM_Integrator*& integrator, char*& result, int& result_length) {
convertStringToChars(OpenMM_XmlSerializer_serializeIntegrator(integrator), result, result_length);
}
OPENMM_EXPORT void openmm_xmlserializer_deserializesystem_(const char* xml, OpenMM_System*& result, int length) {
result = OpenMM_XmlSerializer_deserializeSystem(makeString(xml, length).c_str());
}
OPENMM_EXPORT void OPENMM_XMLSERIALIZER_DESERIALIZESYSTEM(const char* xml, OpenMM_System*& result, int length) {
result = OpenMM_XmlSerializer_deserializeSystem(makeString(xml, length).c_str());
}
OPENMM_EXPORT void openmm_xmlserializer_deserializestate_(const char* xml, OpenMM_State*& result, int length) {
result = OpenMM_XmlSerializer_deserializeState(makeString(xml, length).c_str());
}
OPENMM_EXPORT void OPENMM_XMLSERIALIZER_DESERIALIZESTATE(const char* xml, OpenMM_State*& result, int length) {
result = OpenMM_XmlSerializer_deserializeState(makeString(xml, length).c_str());
}
OPENMM_EXPORT void openmm_xmlserializer_deserializeintegrator_(const char* xml, OpenMM_Integrator*& result, int length) {
result = OpenMM_XmlSerializer_deserializeIntegrator(makeString(xml, length).c_str());
}
OPENMM_EXPORT void OPENMM_XMLSERIALIZER_DESERIALIZEINTEGRATOR(const char* xml, OpenMM_Integrator*& result, int length) {
result = OpenMM_XmlSerializer_deserializeIntegrator(makeString(xml, length).c_str());
}""", file=self.out)
self.writeClasses()
print("}", file=self.out)
inputDirname = sys.argv[1]
builder = CHeaderGenerator(inputDirname, open(os.path.join(sys.argv[2], 'OpenMMCWrapper.h'), 'w'))
builder.writeOutput()
builder = CSourceGenerator(inputDirname, open(os.path.join(sys.argv[2], 'OpenMMCWrapper.cpp'), 'w'))
builder.writeOutput()
builder = FortranHeaderGenerator(inputDirname, open(os.path.join(sys.argv[2], 'OpenMMFortranModule.f90'), 'w'))
builder.writeOutput()
builder = FortranSourceGenerator(inputDirname, open(os.path.join(sys.argv[2], 'OpenMMFortranWrapper.cpp'), 'w'))
builder.writeOutput()
find_program(PYTHON_EXECUTABLE NAMES python)
#############################################
### Copy all source files to staging area ###
#############################################
......
from __future__ import print_function
import sys
# Doxygen does a bad job of generating documentation based on docstrings. This script is run as a filter
......@@ -14,10 +15,10 @@ while True:
split = stripped.split()
if split[0] == 'class' and split[1][0].islower():
# Classes that start with a lowercase letter were defined by SWIG. We want to hide them.
print "%s## @private" % prefix
print("%s## @private" % prefix)
if split[1][0] == '_' and split[1][1] != '_':
# Names starting with a single _ are assumed to be private.
print "%s## @private" % prefix
print("%s## @private" % prefix)
# We're at the start of a class or function definition. Find all lines that contain the declaration.
......@@ -51,9 +52,9 @@ while True:
# Print out the docstring in Doxygen syntax, followed by the declaration.
for s in docstrings:
print "%s##%s" % (prefix, s.strip())
print declaration
print("%s##%s" % (prefix, s.strip()))
print(declaration)
if len(docstrings) == 0:
print line
print(line)
else:
print line
\ No newline at end of file
print(line)
\ No newline at end of file
......@@ -166,7 +166,6 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM,
('MINOR_VERSION', minor_version_num)]
libraries=['OpenMM',
'OpenMMSerialization',
'OpenMMAmoeba',
'OpenMMRPMD',
'OpenMMDrude',
......@@ -196,11 +195,8 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM,
extra_compile_args.append('/EHsc')
else:
if platform.system() == 'Darwin':
macVersion = [int(x) for x in platform.mac_ver()[0].split('.')]
if tuple(macVersion) < (10, 6):
os.environ['MACOSX_DEPLOYMENT_TARGET']='10.5'
extra_link_args.append('-Wl,-rpath,'+openmm_lib_path)
extra_compile_args += ['-stdlib=libc++', '-mmacosx-version-min=10.7']
extra_link_args += ['-stdlib=libc++', '-mmacosx-version-min=10.7', '-Wl', '-rpath', openmm_lib_path]
library_dirs=[openmm_lib_path]
include_dirs=openmm_include_path.split(';')
......
#
#
#
"""
Package simtk.openmm
......@@ -13,25 +9,7 @@ It also tries to load any plugin modules it can find.
__author__ = "Randall J. Radmer"
import os, sys, glob, os.path
if sys.platform == "win32":
libPrefix=""
libExt="dll"
elif sys.platform == 'darwin':
libPrefix="lib"
libExt="dylib"
else:
libPrefix="lib"
libExt="so"
# The following is an evil incantation that is needed to permit
# the POSIX "dlopen" function to work. I do not understand
# it. If a better solution is known, please forward to the
# PyOpenMM code maintainers.
import ctypes
flags = sys.getdlopenflags()
sys.setdlopenflags(flags | ctypes.RTLD_GLOBAL)
import os, os.path
from simtk.openmm.openmm import *
from simtk.openmm.vec3 import Vec3
from simtk.openmm import version
......
......@@ -15,7 +15,7 @@ from pdbfile import PDBFile
from forcefield import ForceField
from simulation import Simulation
from pdbreporter import PDBReporter
from amberprmtopfile import AmberPrmtopFile
from amberprmtopfile import AmberPrmtopFile, HCT, OBC1, OBC2, GBn, GBn2
from amberinpcrdfile import AmberInpcrdFile
from dcdfile import DCDFile
from gromacsgrofile import GromacsGroFile
......@@ -37,8 +37,3 @@ PME = forcefield.PME
HBonds = forcefield.HBonds
AllBonds = forcefield.AllBonds
HAngles = forcefield.HAngles
HCT = amberprmtopfile.HCT
OBC1 = amberprmtopfile.OBC1
OBC2 = amberprmtopfile.OBC2
GBn = amberprmtopfile.GBn
......@@ -141,8 +141,10 @@ class AmberPrmtopFile(object):
top.setUnitCellDimensions(tuple(x.value_in_unit(unit.nanometer) for x in prmtop.getBoxBetaAndDimensions()[1:4])*unit.nanometer)
def createSystem(self, nonbondedMethod=ff.NoCutoff, nonbondedCutoff=1.0*unit.nanometer,
constraints=None, rigidWater=True, implicitSolvent=None, soluteDielectric=1.0, solventDielectric=78.5, removeCMMotion=True,
hydrogenMass=None, ewaldErrorTolerance=0.0005):
constraints=None, rigidWater=True, implicitSolvent=None,
implicitSolventKappa=0.0*(1/unit.nanometer),
soluteDielectric=1.0, solventDielectric=78.5,
removeCMMotion=True, hydrogenMass=None, ewaldErrorTolerance=0.0005):
"""Construct an OpenMM System representing the topology described by this prmtop file.
Parameters:
......@@ -153,6 +155,7 @@ class AmberPrmtopFile(object):
Allowed values are None, HBonds, AllBonds, or HAngles.
- rigidWater (boolean=True) If true, water molecules will be fully rigid regardless of the value passed for the constraints argument
- implicitSolvent (object=None) If not None, the implicit solvent model to use. Allowed values are HCT, OBC1, OBC2, GBn, or GBn2.
- implicitSolventKappa (float=0.0*1/unit.nanometer) The Debye-screening parameter corresponding to ionic strength used for implicit solvent
- soluteDielectric (float=1.0) The solute dielectric constant to use in the implicit solvent model.
- solventDielectric (float=78.5) The solvent dielectric constant to use in the implicit solvent model.
- removeCMMotion (boolean=True) If true, a CMMotionRemover will be added to the System
......@@ -196,8 +199,8 @@ class AmberPrmtopFile(object):
raise ValueError('Illegal value for implicit solvent model')
sys = amber_file_parser.readAmberSystem(prmtop_loader=self._prmtop, shake=constraintString, nonbondedCutoff=nonbondedCutoff,
nonbondedMethod=methodMap[nonbondedMethod], flexibleConstraints=False, gbmodel=implicitString,
soluteDielectric=soluteDielectric, solventDielectric=solventDielectric, rigidWater=rigidWater,
elements=self.elements)
soluteDielectric=soluteDielectric, solventDielectric=solventDielectric, implicitSolventKappa=implicitSolventKappa,
rigidWater=rigidWater, elements=self.elements)
if hydrogenMass is not None:
for atom1, atom2 in self.topology.bonds():
if atom1.element == elem.hydrogen:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -12,7 +12,7 @@
<Atom name="H2" type="swm4ndp-H"/>
<Atom name="M" type="swm4ndp-M"/>
<Atom name="OD" type="swm4ndp-OD"/>
<VirtualSite type="average3" index="3" atom1="0" atom2="1" atom3="2" weight1="0.786646558" weight2="0.106676721" weight3="0.106676721"/>
<VirtualSite type="average3" index="3" atom1="0" atom2="1" atom3="2" weight1="0.589781071" weight2="0.2051094645" weight3="0.2051094645"/>
<Bond from="0" to="1"/>
<Bond from="0" to="2"/>
</Residue>
......
......@@ -35,8 +35,9 @@ __version__ = "1.0"
from simtk.unit import daltons
import copy_reg
class Element:
class Element(object):
"""An Element represents a chemical element.
The simtk.openmm.app.element module contains objects for all the standard chemical elements,
......@@ -85,6 +86,10 @@ def get_by_symbol(symbol):
s = symbol.strip().upper()
return Element._elements_by_symbol[s]
def _pickle_element(element):
return (get_by_symbol, (element.symbol,))
copy_reg.pickle(Element, _pickle_element)
hydrogen = Element( 1, "hydrogen", "H", 1.007947*daltons)
deuterium = Element( 1, "deuterium", "D", 2.01355321270*daltons)
......
......@@ -40,7 +40,7 @@ import simtk.unit as unit
import simtk.openmm as mm
import math
import os
import distutils
import distutils.spawn
HBonds = ff.HBonds
AllBonds = ff.AllBonds
......@@ -358,7 +358,7 @@ class GromacsTopFile(object):
raise ValueError('Unsupported function type in [ cmaptypes ] line: '+line);
self._cmapTypes[tuple(fields[:5])] = fields
def __init__(self, file, unitCellDimensions=None, includeDir=None, defines={}):
def __init__(self, file, unitCellDimensions=None, includeDir=None, defines=None):
"""Load a top file.
Parameters:
......@@ -368,12 +368,18 @@ class GromacsTopFile(object):
included from the top file. If not specified, we will attempt to locate a gromacs
installation on your system. When gromacs is installed in /usr/local, this will resolve
to /usr/local/gromacs/share/gromacs/top
- defines (map={}) preprocessor definitions that should be predefined when parsing the file
- defines (dict={}) preprocessor definitions that should be predefined when parsing the file
"""
if includeDir is None:
includeDir = _defaultGromacsIncludeDir()
self._includeDirs = (os.path.dirname(file), includeDir)
self._defines = defines
# Most of the gromacs water itp files for different forcefields,
# unless the preprocessor #define FLEXIBLE is given, don't define
# bonds between the water hydrogen and oxygens, but only give the
# constraint distances and exclusions.
self._defines = {'FLEXIBLE': True}
if defines is not None:
self._defines.update(defines)
# Parse the file.
......
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