Commit 3848adc6 authored by peastman's avatar peastman
Browse files

Bug fixes to wrapper generation. Implemented wrappers for AMOEBA.

parent 19266648
......@@ -175,6 +175,10 @@ private:
std::vector<AngleInfo> angles;
};
/**
* This is an internal class used to record information about an angle.
* @private
*/
class AmoebaAngleForce::AngleInfo {
public:
int particle1, particle2, particle3;
......
......@@ -147,6 +147,10 @@ private:
std::vector<BondInfo> bonds;
};
/**
* This is an internal class used to record information about a bond.
* @private
*/
class AmoebaBondForce::BondInfo {
public:
int particle1, particle2;
......
......@@ -174,6 +174,10 @@ private:
std::vector<ParticleInfo> particles;
};
/**
* This is an internal class used to record information about a particle.
* @private
*/
class AmoebaGeneralizedKirkwoodForce::ParticleInfo {
public:
double charge, radius, scalingFactor;
......
......@@ -180,6 +180,10 @@ private:
std::vector<AngleInfo> angles;
};
/**
* This is an internal class used to record information about an angle.
* @private
*/
class AmoebaInPlaneAngleForce::AngleInfo {
public:
int particle1, particle2, particle3, particle4;
......
......@@ -368,6 +368,10 @@ private:
std::vector<MultipoleInfo> multipoles;
};
/**
* This is an internal class used to record information about a multipole.
* @private
*/
class AmoebaMultipoleForce::MultipoleInfo {
public:
......
......@@ -172,6 +172,10 @@ private:
std::vector<OutOfPlaneBendInfo> outOfPlaneBends;
};
/**
* This is an internal class used to record information about a bend.
* @private
*/
class AmoebaOutOfPlaneBendForce::OutOfPlaneBendInfo {
public:
int particle1, particle2, particle3, particle4;
......
......@@ -121,6 +121,10 @@ private:
std::vector<PiTorsionInfo> piTorsions;
};
/**
* This is an internal class used to record information about a torsion.
* @private
*/
class AmoebaPiTorsionForce::PiTorsionInfo {
public:
int particle1, particle2, particle3, particle4, particle5, particle6;
......
......@@ -124,6 +124,10 @@ private:
std::vector<StretchBendInfo> stretchBends;
};
/**
* This is an internal class used to record information about a stretch-bend.
* @private
*/
class AmoebaStretchBendForce::StretchBendInfo {
public:
int particle1, particle2, particle3;
......
......@@ -145,6 +145,10 @@ private:
std::vector<TorsionTorsionGridInfo> torsionTorsionGrids;
};
/**
* This is an internal class used to record information about a torsion-torsion term.
* @private
*/
class AmoebaTorsionTorsionForce::TorsionTorsionInfo {
public:
......@@ -163,6 +167,10 @@ public:
}
};
/**
* This is an internal class used to record information about a grid.
* @private
*/
class AmoebaTorsionTorsionForce::TorsionTorsionGridInfo {
public:
......
......@@ -230,6 +230,10 @@ private:
std::vector< std::vector< std::vector<double> > > sigEpsTable;
};
/**
* This is an internal class used to record information about a particle.
* @private
*/
class AmoebaVdwForce::VdwInfo {
public:
int parentIndex;
......
......@@ -137,6 +137,10 @@ private:
std::vector<WcaDispersionInfo> parameters;
};
/**
* This is an internal class used to record information about a particle.
* @private
*/
class AmoebaWcaDispersionForce::WcaDispersionInfo {
public:
double radius, epsilon;
......
#set(GCCXML_EXTRA_ARGS "" CACHE STRING "Additional arguments to gccxml, such as '--gccxml-compiler;msvc8'")
#SET(GCCXML_ARGS) # start empty
#FOREACH(subdir ${API_INCLUDE_DIRS})
# SET(GCCXML_ARGS ${GCCXML_ARGS} -I${subdir})
#ENDFOREACH(subdir)
#SET(GCCXML_ARGS ${GCCXML_ARGS} ${GCCXML_EXTRA_ARGS})
SET(SAXON_JAR ${CMAKE_SOURCE_DIR}/wrappers/saxonb9-1-0-7j/saxon9.jar)
# OpenMMAmoeba
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMApi.xml COMMAND ${GCCXML_PATH} ${GCCXML_ARGS} -I${CMAKE_SOURCE_DIR}/openmmapi/include -I${CMAKE_SOURCE_DIR}/olla/include ${CMAKE_SOURCE_DIR}/plugins/amoeba/openmmapi/include/OpenMMAmoeba.h -fxml=AmoebaOpenMMApi.xml)
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMCWrapper.h COMMAND ${JAVA_RUNTIME} -jar ${SAXON_JAR} -t -s:AmoebaOpenMMApi.xml
-xsl:${CMAKE_SOURCE_DIR}/plugins/amoeba/wrappers/CWrapper_Header.xslt -o:AmoebaOpenMMCWrapper.h DEPENDS AmoebaOpenMMApi.xml)
#
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMCWrapper.cpp COMMAND ${JAVA_RUNTIME} -jar ${SAXON_JAR} -t -s:AmoebaOpenMMApi.xml
-xsl:${CMAKE_SOURCE_DIR}/plugins/amoeba/wrappers/CWrapper_Source.xslt -o:AmoebaOpenMMCWrapper.cpp DEPENDS AmoebaOpenMMApi.xml)
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMFortranModule.f90 COMMAND ${JAVA_RUNTIME} -jar ${SAXON_JAR} -t -s:AmoebaOpenMMApi.xml
-xsl:${CMAKE_SOURCE_DIR}/plugins/amoeba/wrappers/FortranWrapper_Header.xslt -o:AmoebaOpenMMFortranModule.f90 DEPENDS AmoebaOpenMMApi.xml ${CMAKE_SOURCE_DIR}/plugins/amoeba/wrappers/FortranWrapper_Header.xslt)
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMFortranWrapper.cpp COMMAND ${JAVA_RUNTIME} -jar ${SAXON_JAR} -t -s:AmoebaOpenMMApi.xml
-xsl:${CMAKE_SOURCE_DIR}/plugins/amoeba/wrappers/FortranWrapper_Source.xslt -o:AmoebaOpenMMFortranWrapper.cpp DEPENDS AmoebaOpenMMApi.xml)
ADD_CUSTOM_TARGET(AmoebaApiWrappers DEPENDS AmoebaOpenMMCWrapper.h AmoebaOpenMMCWrapper.cpp AmoebaOpenMMFortranModule.f90 AmoebaOpenMMFortranWrapper.cpp)
INSTALL_FILES(/include FILES AmoebaOpenMMCWrapper.h AmoebaOpenMMFortranModule.f90 )
# 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}")
# Step 1 - Create Doxyfile to point to OpenMM headers
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
${WRAPPER_DOXYGEN_DIR}/Doxyfile
@ONLY
)
# 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..."
)
# Step 3 - Generate the wrappers
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMCWrapper.h AmoebaOpenMMCWrapper.cpp AmoebaOpenMMFortranModule.f90 AmoebaOpenMMFortranWrapper.cpp
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/generateAmoebaWrappers.py" "${WRAPPER_DOXYGEN_DIR}/xml" "${CMAKE_CURRENT_BINARY_DIR}"
DEPENDS "${WRAPPER_DOXYGEN_DIR}/xml/index.xml" "${CMAKE_CURRENT_SOURCE_DIR}/generateAmoebaWrappers.py")
ADD_CUSTOM_TARGET(AmoebaApiWrappers DEPENDS AmoebaOpenMMCWrapper.h AmoebaOpenMMCWrapper.cpp AmoebaOpenMMFortranModule.f90 AmoebaOpenMMFortranWrapper.cpp)
INSTALL_FILES(/include FILES AmoebaOpenMMCWrapper.h AmoebaOpenMMFortranModule.f90)
This diff is collapsed.
This diff is collapsed.
......@@ -801,6 +801,8 @@ class FortranHeaderGenerator(WrapperGenerator):
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)',
......@@ -811,13 +813,14 @@ class FortranHeaderGenerator(WrapperGenerator):
'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("definition", memberNode))
vDef = convertOpenMMPrefix(getText("name", memberNode))
iDef = getText("initializer", memberNode)
if iDef.startswith("="):
iDef = iDef[1:]
......@@ -829,7 +832,7 @@ class FortranHeaderGenerator(WrapperGenerator):
className = getText("compoundname", classNode)
shortName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(className)
self.out.write("\n type OpenMM_%s\n" % typeName)
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
......@@ -858,6 +861,7 @@ class FortranHeaderGenerator(WrapperGenerator):
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):
......@@ -882,8 +886,8 @@ class FortranHeaderGenerator(WrapperGenerator):
suffix = ""
else:
suffix = "_%d" % numConstructors
self.out.write(" subroutine %s_create%s(result, " % (typeName, suffix))
self.writeArguments(methodNode, False)
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)
......@@ -960,7 +964,7 @@ class FortranHeaderGenerator(WrapperGenerator):
continue
name = getText('declname', node)
self.out.write("%s%s" % (separator, name))
separator = ", &\n "
separator = ", &\n"
numArgs += 1
return numArgs
......@@ -986,6 +990,8 @@ class FortranHeaderGenerator(WrapperGenerator):
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 '):
......
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