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: ...@@ -175,6 +175,10 @@ private:
std::vector<AngleInfo> angles; std::vector<AngleInfo> angles;
}; };
/**
* This is an internal class used to record information about an angle.
* @private
*/
class AmoebaAngleForce::AngleInfo { class AmoebaAngleForce::AngleInfo {
public: public:
int particle1, particle2, particle3; int particle1, particle2, particle3;
......
...@@ -147,6 +147,10 @@ private: ...@@ -147,6 +147,10 @@ private:
std::vector<BondInfo> bonds; std::vector<BondInfo> bonds;
}; };
/**
* This is an internal class used to record information about a bond.
* @private
*/
class AmoebaBondForce::BondInfo { class AmoebaBondForce::BondInfo {
public: public:
int particle1, particle2; int particle1, particle2;
......
...@@ -174,6 +174,10 @@ private: ...@@ -174,6 +174,10 @@ private:
std::vector<ParticleInfo> particles; std::vector<ParticleInfo> particles;
}; };
/**
* This is an internal class used to record information about a particle.
* @private
*/
class AmoebaGeneralizedKirkwoodForce::ParticleInfo { class AmoebaGeneralizedKirkwoodForce::ParticleInfo {
public: public:
double charge, radius, scalingFactor; double charge, radius, scalingFactor;
......
...@@ -180,6 +180,10 @@ private: ...@@ -180,6 +180,10 @@ private:
std::vector<AngleInfo> angles; std::vector<AngleInfo> angles;
}; };
/**
* This is an internal class used to record information about an angle.
* @private
*/
class AmoebaInPlaneAngleForce::AngleInfo { class AmoebaInPlaneAngleForce::AngleInfo {
public: public:
int particle1, particle2, particle3, particle4; int particle1, particle2, particle3, particle4;
......
...@@ -368,6 +368,10 @@ private: ...@@ -368,6 +368,10 @@ private:
std::vector<MultipoleInfo> multipoles; std::vector<MultipoleInfo> multipoles;
}; };
/**
* This is an internal class used to record information about a multipole.
* @private
*/
class AmoebaMultipoleForce::MultipoleInfo { class AmoebaMultipoleForce::MultipoleInfo {
public: public:
......
...@@ -172,6 +172,10 @@ private: ...@@ -172,6 +172,10 @@ private:
std::vector<OutOfPlaneBendInfo> outOfPlaneBends; std::vector<OutOfPlaneBendInfo> outOfPlaneBends;
}; };
/**
* This is an internal class used to record information about a bend.
* @private
*/
class AmoebaOutOfPlaneBendForce::OutOfPlaneBendInfo { class AmoebaOutOfPlaneBendForce::OutOfPlaneBendInfo {
public: public:
int particle1, particle2, particle3, particle4; int particle1, particle2, particle3, particle4;
......
...@@ -121,6 +121,10 @@ private: ...@@ -121,6 +121,10 @@ private:
std::vector<PiTorsionInfo> piTorsions; std::vector<PiTorsionInfo> piTorsions;
}; };
/**
* This is an internal class used to record information about a torsion.
* @private
*/
class AmoebaPiTorsionForce::PiTorsionInfo { class AmoebaPiTorsionForce::PiTorsionInfo {
public: public:
int particle1, particle2, particle3, particle4, particle5, particle6; int particle1, particle2, particle3, particle4, particle5, particle6;
......
...@@ -124,6 +124,10 @@ private: ...@@ -124,6 +124,10 @@ private:
std::vector<StretchBendInfo> stretchBends; std::vector<StretchBendInfo> stretchBends;
}; };
/**
* This is an internal class used to record information about a stretch-bend.
* @private
*/
class AmoebaStretchBendForce::StretchBendInfo { class AmoebaStretchBendForce::StretchBendInfo {
public: public:
int particle1, particle2, particle3; int particle1, particle2, particle3;
......
...@@ -145,6 +145,10 @@ private: ...@@ -145,6 +145,10 @@ private:
std::vector<TorsionTorsionGridInfo> torsionTorsionGrids; std::vector<TorsionTorsionGridInfo> torsionTorsionGrids;
}; };
/**
* This is an internal class used to record information about a torsion-torsion term.
* @private
*/
class AmoebaTorsionTorsionForce::TorsionTorsionInfo { class AmoebaTorsionTorsionForce::TorsionTorsionInfo {
public: public:
...@@ -163,6 +167,10 @@ public: ...@@ -163,6 +167,10 @@ public:
} }
}; };
/**
* This is an internal class used to record information about a grid.
* @private
*/
class AmoebaTorsionTorsionForce::TorsionTorsionGridInfo { class AmoebaTorsionTorsionForce::TorsionTorsionGridInfo {
public: public:
......
...@@ -230,6 +230,10 @@ private: ...@@ -230,6 +230,10 @@ private:
std::vector< std::vector< std::vector<double> > > sigEpsTable; std::vector< std::vector< std::vector<double> > > sigEpsTable;
}; };
/**
* This is an internal class used to record information about a particle.
* @private
*/
class AmoebaVdwForce::VdwInfo { class AmoebaVdwForce::VdwInfo {
public: public:
int parentIndex; int parentIndex;
......
...@@ -137,6 +137,10 @@ private: ...@@ -137,6 +137,10 @@ private:
std::vector<WcaDispersionInfo> parameters; std::vector<WcaDispersionInfo> parameters;
}; };
/**
* This is an internal class used to record information about a particle.
* @private
*/
class AmoebaWcaDispersionForce::WcaDispersionInfo { class AmoebaWcaDispersionForce::WcaDispersionInfo {
public: public:
double radius, epsilon; double radius, epsilon;
......
#set(GCCXML_EXTRA_ARGS "" CACHE STRING "Additional arguments to gccxml, such as '--gccxml-compiler;msvc8'") # WRAPPER_DOXYGEN_DIR is a workspace directory where wrapper files will be created
#SET(GCCXML_ARGS) # start empty set(WRAPPER_DOXYGEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/doxygen")
#FOREACH(subdir ${API_INCLUDE_DIRS}) file(MAKE_DIRECTORY "${WRAPPER_DOXYGEN_DIR}")
# SET(GCCXML_ARGS ${GCCXML_ARGS} -I${subdir})
#ENDFOREACH(subdir) # Step 1 - Create Doxyfile to point to OpenMM headers
#SET(GCCXML_ARGS ${GCCXML_ARGS} ${GCCXML_EXTRA_ARGS}) configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
SET(SAXON_JAR ${CMAKE_SOURCE_DIR}/wrappers/saxonb9-1-0-7j/saxon9.jar) ${WRAPPER_DOXYGEN_DIR}/Doxyfile
@ONLY
# 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) # Step 2 - Run doxygen to analyze the headers
add_custom_command(
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMCWrapper.h COMMAND ${JAVA_RUNTIME} -jar ${SAXON_JAR} -t -s:AmoebaOpenMMApi.xml OUTPUT "${WRAPPER_DOXYGEN_DIR}/xml/index.xml"
-xsl:${CMAKE_SOURCE_DIR}/plugins/amoeba/wrappers/CWrapper_Header.xslt -o:AmoebaOpenMMCWrapper.h DEPENDS AmoebaOpenMMApi.xml) COMMAND "${DOXYGEN_EXECUTABLE}"
# DEPENDS "${WRAPPER_DOXYGEN_DIR}/Doxyfile"
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMCWrapper.cpp COMMAND ${JAVA_RUNTIME} -jar ${SAXON_JAR} -t -s:AmoebaOpenMMApi.xml WORKING_DIRECTORY "${WRAPPER_DOXYGEN_DIR}"
-xsl:${CMAKE_SOURCE_DIR}/plugins/amoeba/wrappers/CWrapper_Source.xslt -o:AmoebaOpenMMCWrapper.cpp DEPENDS AmoebaOpenMMApi.xml) COMMENT "Parsing OpenMM header files with Doxygen..."
)
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) # Step 3 - Generate the wrappers
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMCWrapper.h AmoebaOpenMMCWrapper.cpp AmoebaOpenMMFortranModule.f90 AmoebaOpenMMFortranWrapper.cpp
ADD_CUSTOM_COMMAND(OUTPUT AmoebaOpenMMFortranWrapper.cpp COMMAND ${JAVA_RUNTIME} -jar ${SAXON_JAR} -t -s:AmoebaOpenMMApi.xml COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/generateAmoebaWrappers.py" "${WRAPPER_DOXYGEN_DIR}/xml" "${CMAKE_CURRENT_BINARY_DIR}"
-xsl:${CMAKE_SOURCE_DIR}/plugins/amoeba/wrappers/FortranWrapper_Source.xslt -o:AmoebaOpenMMFortranWrapper.cpp DEPENDS AmoebaOpenMMApi.xml) 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) ADD_CUSTOM_TARGET(AmoebaApiWrappers DEPENDS AmoebaOpenMMCWrapper.h AmoebaOpenMMCWrapper.cpp AmoebaOpenMMFortranModule.f90 AmoebaOpenMMFortranWrapper.cpp)
INSTALL_FILES(/include FILES AmoebaOpenMMCWrapper.h AmoebaOpenMMFortranModule.f90 ) INSTALL_FILES(/include FILES AmoebaOpenMMCWrapper.h AmoebaOpenMMFortranModule.f90)
This diff is collapsed.
This diff is collapsed.
...@@ -801,6 +801,8 @@ class FortranHeaderGenerator(WrapperGenerator): ...@@ -801,6 +801,8 @@ class FortranHeaderGenerator(WrapperGenerator):
self.typeTranslations = {'int': 'integer*4', self.typeTranslations = {'int': 'integer*4',
'bool': 'integer*4', 'bool': 'integer*4',
'double': 'real*8', 'double': 'real*8',
'char *': 'character(*)',
'const char *': 'character(*)',
'std::string': 'character(*)', 'std::string': 'character(*)',
'const std::string &': 'character(*)', 'const std::string &': 'character(*)',
'std::vector< std::string >': 'type (OpenMM_StringArray)', 'std::vector< std::string >': 'type (OpenMM_StringArray)',
...@@ -811,13 +813,14 @@ class FortranHeaderGenerator(WrapperGenerator): ...@@ -811,13 +813,14 @@ class FortranHeaderGenerator(WrapperGenerator):
'std::vector< double >': 'type (OpenMM_DoubleArray)', 'std::vector< double >': 'type (OpenMM_DoubleArray)',
'std::vector< int >': 'type (OpenMM_IntArray)', 'std::vector< int >': 'type (OpenMM_IntArray)',
'std::set< int >': 'type (OpenMM_IntSet)'} 'std::set< int >': 'type (OpenMM_IntSet)'}
self.enumerationTypes = set()
def writeGlobalConstants(self): def writeGlobalConstants(self):
self.out.write(" ! Global Constants\n\n") 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")) 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 section in findNodes(node, "sectiondef", kind="var"):
for memberNode in findNodes(section, "memberdef", kind="variable", mutable="no", prot="public", static="yes"): 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) iDef = getText("initializer", memberNode)
if iDef.startswith("="): if iDef.startswith("="):
iDef = iDef[1:] iDef = iDef[1:]
...@@ -829,7 +832,7 @@ class FortranHeaderGenerator(WrapperGenerator): ...@@ -829,7 +832,7 @@ class FortranHeaderGenerator(WrapperGenerator):
className = getText("compoundname", classNode) className = getText("compoundname", classNode)
shortName = stripOpenMMPrefix(className) shortName = stripOpenMMPrefix(className)
typeName = convertOpenMMPrefix(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(" integer*8 :: handle = 0\n")
self.out.write(" end type\n") self.out.write(" end type\n")
self.typesByShortName[shortName] = typeName self.typesByShortName[shortName] = typeName
...@@ -858,6 +861,7 @@ class FortranHeaderGenerator(WrapperGenerator): ...@@ -858,6 +861,7 @@ class FortranHeaderGenerator(WrapperGenerator):
enumName = getText("name", enumNode) enumName = getText("name", enumNode)
enumTypeName = "%s_%s" % (typeName, enumName) enumTypeName = "%s_%s" % (typeName, enumName)
self.typesByShortName[enumName] = enumTypeName self.typesByShortName[enumName] = enumTypeName
self.enumerationTypes.add(enumName)
if len(enumNodes)>0: self.out.write("\n") if len(enumNodes)>0: self.out.write("\n")
def writeMethods(self, classNode): def writeMethods(self, classNode):
...@@ -882,8 +886,8 @@ class FortranHeaderGenerator(WrapperGenerator): ...@@ -882,8 +886,8 @@ class FortranHeaderGenerator(WrapperGenerator):
suffix = "" suffix = ""
else: else:
suffix = "_%d" % numConstructors suffix = "_%d" % numConstructors
self.out.write(" subroutine %s_create%s(result, " % (typeName, suffix)) self.out.write(" subroutine %s_create%s(result" % (typeName, suffix))
self.writeArguments(methodNode, False) self.writeArguments(methodNode, True)
self.out.write(")\n") self.out.write(")\n")
self.out.write(" use OpenMM_Types; implicit none\n") self.out.write(" use OpenMM_Types; implicit none\n")
self.out.write(" type (%s) result\n" % typeName) self.out.write(" type (%s) result\n" % typeName)
...@@ -960,7 +964,7 @@ class FortranHeaderGenerator(WrapperGenerator): ...@@ -960,7 +964,7 @@ class FortranHeaderGenerator(WrapperGenerator):
continue continue
name = getText('declname', node) name = getText('declname', node)
self.out.write("%s%s" % (separator, name)) self.out.write("%s%s" % (separator, name))
separator = ", &\n " separator = ", &\n"
numArgs += 1 numArgs += 1
return numArgs return numArgs
...@@ -986,6 +990,8 @@ class FortranHeaderGenerator(WrapperGenerator): ...@@ -986,6 +990,8 @@ class FortranHeaderGenerator(WrapperGenerator):
def getType(self, type): def getType(self, type):
if type in self.typeTranslations: if type in self.typeTranslations:
return self.typeTranslations[type] return self.typeTranslations[type]
if type in self.enumerationTypes:
return 'integer*4'
if type in self.typesByShortName: if type in self.typesByShortName:
return 'type (%s)' % self.typesByShortName[type] return 'type (%s)' % self.typesByShortName[type]
if type.startswith('const '): 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