Commit bcbc4eec authored by Michael Sherman's avatar Michael Sherman
Browse files

Fixed wrapper generation to work on Windows (mostly inolved dllexport issues).

Deleted all the old hand-generated wrappers.
parent 9438fa83
...@@ -242,6 +242,7 @@ ENDFOREACH(subdir) ...@@ -242,6 +242,7 @@ ENDFOREACH(subdir)
# If API wrappers are being generated, and add them to the build. # If API wrappers are being generated, and add them to the build.
SET(OPENMM_BUILD_API_WRAPPERS OFF CACHE BOOL "Build wrappers for C and Fortran") SET(OPENMM_BUILD_API_WRAPPERS OFF CACHE BOOL "Build wrappers for C and Fortran")
IF(OPENMM_BUILD_API_WRAPPERS) IF(OPENMM_BUILD_API_WRAPPERS)
ADD_SUBDIRECTORY(wrappers)
SET(SOURCE_FILES ${SOURCE_FILES} wrappers/OpenMMCWrapper.cpp wrappers/OpenMMFortranWrapper.cpp) SET(SOURCE_FILES ${SOURCE_FILES} wrappers/OpenMMCWrapper.cpp wrappers/OpenMMFortranWrapper.cpp)
ENDIF(OPENMM_BUILD_API_WRAPPERS) ENDIF(OPENMM_BUILD_API_WRAPPERS)
...@@ -253,6 +254,11 @@ SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES COMPILE_FLAGS "-DOPENMM_BUILDI ...@@ -253,6 +254,11 @@ SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES COMPILE_FLAGS "-DOPENMM_BUILDI
ADD_LIBRARY(${STATIC_TARGET} STATIC ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ${API_ABS_INCLUDE_FILES}) ADD_LIBRARY(${STATIC_TARGET} STATIC ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ${API_ABS_INCLUDE_FILES})
SET_TARGET_PROPERTIES(${STATIC_TARGET} PROPERTIES COMPILE_FLAGS "-DOPENMM_USE_STATIC_LIBRARIES -DOPENMM_BUILDING_STATIC_LIBRARY -DLEPTON_USE_STATIC_LIBRARIES -DLEPTON_BUILDING_STATIC_LIBRARY") SET_TARGET_PROPERTIES(${STATIC_TARGET} PROPERTIES COMPILE_FLAGS "-DOPENMM_USE_STATIC_LIBRARIES -DOPENMM_BUILDING_STATIC_LIBRARY -DLEPTON_USE_STATIC_LIBRARIES -DLEPTON_BUILDING_STATIC_LIBRARY")
IF(OPENMM_BUILD_API_WRAPPERS)
ADD_DEPENDENCIES(${SHARED_TARGET} ApiWrappers)
ADD_DEPENDENCIES(${STATIC_TARGET} ApiWrappers)
ENDIF(OPENMM_BUILD_API_WRAPPERS)
# On Linux need to link to libdl # On Linux need to link to libdl
FIND_LIBRARY(DL_LIBRARY dl) FIND_LIBRARY(DL_LIBRARY dl)
IF(DL_LIBRARY) IF(DL_LIBRARY)
...@@ -312,10 +318,3 @@ ENDIF (EXECUTABLE_OUTPUT_PATH) ...@@ -312,10 +318,3 @@ ENDIF (EXECUTABLE_OUTPUT_PATH)
INCLUDE(ApiDoxygen.cmake) INCLUDE(ApiDoxygen.cmake)
#
# Generate API wrappers if requested.
#
IF(OPENMM_BUILD_API_WRAPPERS)
ADD_SUBDIRECTORY(wrappers)
ENDIF(OPENMM_BUILD_API_WRAPPERS)
...@@ -17,18 +17,6 @@ SET(OpenMM_CWRAPPER "OpenMMCWrapper") ...@@ -17,18 +17,6 @@ SET(OpenMM_CWRAPPER "OpenMMCWrapper")
SET(OpenMM_FWRAPPER "OpenMMFortranWrapper") SET(OpenMM_FWRAPPER "OpenMMFortranWrapper")
SET(OpenMM_FMODULE "OpenMMFortranModule") SET(OpenMM_FMODULE "OpenMMFortranModule")
# CWrapper is always a static library but you need a different
# one if you want to link with the OpenMM static library.
SET(CWRAPPER_FOR_SHARED ${OpenMM_CWRAPPER})
SET(CWRAPPER_FOR_STATIC ${OpenMM_CWRAPPER}_static)
# Visual Studio will add "_d" to target names automatically
# but on Unix or Cygwin we have to add the suffix manually
IF (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
SET(CWRAPPER_FOR_SHARED ${CWRAPPER_FOR_SHARED}_d)
SET(CWRAPPER_FOR_STATIC ${CWRAPPER_FOR_STATIC}_d)
ENDIF (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
SET(CPP_EXAMPLES HelloArgon HelloSodiumChloride HelloEthane HelloWaterBox) SET(CPP_EXAMPLES HelloArgon HelloSodiumChloride HelloEthane HelloWaterBox)
SET(C_EXAMPLES HelloArgonInC HelloSodiumChlorideInC) SET(C_EXAMPLES HelloArgonInC HelloSodiumChlorideInC)
SET(F_EXAMPLES HelloArgonInFortran HelloSodiumChlorideInFortran) SET(F_EXAMPLES HelloArgonInFortran HelloSodiumChlorideInFortran)
...@@ -36,23 +24,6 @@ SET(F_EXAMPLES HelloArgonInFortran HelloSodiumChlorideInFortran) ...@@ -36,23 +24,6 @@ SET(F_EXAMPLES HelloArgonInFortran HelloSodiumChlorideInFortran)
SET(BUILD_TESTING_SHARED 1) SET(BUILD_TESTING_SHARED 1)
SET(BUILD_TESTING_STATIC 1) SET(BUILD_TESTING_STATIC 1)
ADD_LIBRARY(${CWRAPPER_FOR_SHARED}
${OpenMM_CWRAPPER}.cpp ${OpenMM_FWRAPPER}.cpp ${OpenMM_CWRAPPER}.h)
SET_TARGET_PROPERTIES(${CWRAPPER_FOR_SHARED}
PROPERTIES
PROJECT_LABEL "C Bindings")
TARGET_LINK_LIBRARIES(${CWRAPPER_FOR_SHARED} ${SHARED_TARGET})
ADD_LIBRARY(${CWRAPPER_FOR_STATIC}
${OpenMM_CWRAPPER}.cpp ${OpenMM_FWRAPPER}.cpp ${OpenMM_CWRAPPER}.h)
SET_TARGET_PROPERTIES(${CWRAPPER_FOR_STATIC}
PROPERTIES
COMPILE_FLAGS "-DOPENMM_USE_STATIC_LIBRARIES"
PROJECT_LABEL "C Bindings for static OpenMM")
INSTALL_TARGETS(/lib RUNTIME_DIRECTORY /lib ${CWRAPPER_FOR_SHARED})
INSTALL_TARGETS(/lib RUNTIME_DIRECTORY /lib ${CWRAPPER_FOR_STATIC})
FOREACH(EX_ROOT ${CPP_EXAMPLES}) FOREACH(EX_ROOT ${CPP_EXAMPLES})
IF (BUILD_TESTING_SHARED) IF (BUILD_TESTING_SHARED)
...@@ -88,7 +59,7 @@ FOREACH(EX_ROOT ${C_EXAMPLES}) ...@@ -88,7 +59,7 @@ FOREACH(EX_ROOT ${C_EXAMPLES})
SET_TARGET_PROPERTIES(${EX_ROOT} SET_TARGET_PROPERTIES(${EX_ROOT}
PROPERTIES PROPERTIES
PROJECT_LABEL "Example C - ${EX_ROOT}") PROJECT_LABEL "Example C - ${EX_ROOT}")
TARGET_LINK_LIBRARIES(${EX_ROOT} ${CWRAPPER_FOR_SHARED} ${SHARED_TARGET}) TARGET_LINK_LIBRARIES(${EX_ROOT} ${SHARED_TARGET})
ENDIF (BUILD_TESTING_SHARED) ENDIF (BUILD_TESTING_SHARED)
IF (BUILD_TESTING_STATIC) IF (BUILD_TESTING_STATIC)
...@@ -101,7 +72,7 @@ FOREACH(EX_ROOT ${C_EXAMPLES}) ...@@ -101,7 +72,7 @@ FOREACH(EX_ROOT ${C_EXAMPLES})
PROPERTIES PROPERTIES
COMPILE_FLAGS "-DOPENMM_USE_STATIC_LIBRARIES" COMPILE_FLAGS "-DOPENMM_USE_STATIC_LIBRARIES"
PROJECT_LABEL "Example C - ${EX_STATIC}") PROJECT_LABEL "Example C - ${EX_STATIC}")
TARGET_LINK_LIBRARIES(${EX_STATIC} ${CWRAPPER_FOR_STATIC} ${STATIC_TARGET}) TARGET_LINK_LIBRARIES(${EX_STATIC} ${STATIC_TARGET})
ENDIF (BUILD_TESTING_STATIC) ENDIF (BUILD_TESTING_STATIC)
INSTALL(FILES ${EX_ROOT}.c DESTINATION examples) INSTALL(FILES ${EX_ROOT}.c DESTINATION examples)
...@@ -112,9 +83,6 @@ FOREACH(EX_ROOT ${F_EXAMPLES}) ...@@ -112,9 +83,6 @@ FOREACH(EX_ROOT ${F_EXAMPLES})
INSTALL(FILES ${EX_ROOT}.f90 DESTINATION examples) INSTALL(FILES ${EX_ROOT}.f90 DESTINATION examples)
ENDFOREACH(EX_ROOT ${F_EXAMPLES}) ENDFOREACH(EX_ROOT ${F_EXAMPLES})
INSTALL(FILES ${OpenMM_CWRAPPER}.h ${OpenMM_CWRAPPER}.cpp ${OpenMM_FWRAPPER}.cpp
DESTINATION examples)
INSTALL(FILES ${OpenMM_FMODULE}.f90 DESTINATION examples)
INSTALL(FILES README.txt DESTINATION examples) INSTALL(FILES README.txt DESTINATION examples)
INSTALL(FILES Makefile NMakefile DESTINATION examples) INSTALL(FILES Makefile NMakefile DESTINATION examples)
......
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Makefile for OpenMM Preview Release 3 workshop "hello world" examples. # Makefile for OpenMM Preview Release 4 workshop "hello world" examples.
# June 24, 2009. # August 18, 2009
# See https://simtk.org/home/openmm. # See https://simtk.org/home/openmm.
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# This assumes you have gcc compilers for whatever language you are # This assumes you have gcc compilers for whatever language you are
# using: g++ for C++ and C, gfortran for Fortran 95. # using: g++ for C++ and C, gfortran for Fortran 95.
# #
# Note: the C Wrappers and Fortran Module are just prototypes. They are # For the C and Fortran examples, we're depending on your version of
# incomplete but have enough functionality to get through these examples. # OpenMM to have been built with the automatically-generated API
# We would like more complete and better-thought-out interfaces; if you # wrappers.
# have code or ideas please post to the OpenMM forum at the above URL
# (select "Advanced/Public Forums").
# #
# This has had only minimal testing, although it has been known to # This has had only minimal testing, although it has been known to
# work. It is likely to work fine for C and C++. For Fortran, you # work. It is likely to work fine for C and C++. For Fortran, you
...@@ -32,8 +30,6 @@ FCPPLIBS = -lstdc++ ...@@ -32,8 +30,6 @@ FCPPLIBS = -lstdc++
LIB_DIR=$(OpenMM_INSTALL_DIR)/lib LIB_DIR=$(OpenMM_INSTALL_DIR)/lib
INCLUDE_DIR=$(OpenMM_INSTALL_DIR)/include INCLUDE_DIR=$(OpenMM_INSTALL_DIR)/include
# assume local directory for C and Fortran wrappers
WRAPPER_DIR=.
LIBS= -lOpenMM LIBS= -lOpenMM
ALL_CPP_EXAMPLES = HelloArgon HelloSodiumChloride HelloEthane HelloWaterBox ALL_CPP_EXAMPLES = HelloArgon HelloSodiumChloride HelloEthane HelloWaterBox
...@@ -46,40 +42,30 @@ default: HelloArgon ...@@ -46,40 +42,30 @@ default: HelloArgon
all : $(ALL_PROGS) all : $(ALL_PROGS)
# Treat all .cpp source files the same way (except the one that # Treat all .cpp source files the same way.
# implements the C Wrappers).
.cpp : .cpp :
g++ $(CFLAGS) -I$(INCLUDE_DIR) $< -L$(LIB_DIR) $(LIBS) -o $* g++ $(CFLAGS) -I$(INCLUDE_DIR) $< -L$(LIB_DIR) $(LIBS) -o $*
HelloArgonInC: HelloArgonInC.c OpenMMCWrapper.o HelloArgonInC: HelloArgonInC.c
g++ $(CFLAGS) -I$(WRAPPER_DIR) HelloArgonInC.c OpenMMCWrapper.o \ g++ $(CFLAGS) HelloArgonInC.c \
-L$(LIB_DIR) $(LIBS) -o HelloArgonInC -L$(LIB_DIR) $(LIBS) -o HelloArgonInC
HelloSodiumChlorideInC: HelloSodiumChlorideInC.c OpenMMCWrapper.o HelloSodiumChlorideInC: HelloSodiumChlorideInC.c
g++ $(CFLAGS) -I$(WRAPPER_DIR) HelloSodiumChlorideInC.c OpenMMCWrapper.o \ g++ $(CFLAGS) HelloSodiumChlorideInC.c \
-L$(LIB_DIR) $(LIBS) -o HelloSodiumChlorideInC -L$(LIB_DIR) $(LIBS) -o HelloSodiumChlorideInC
HelloArgonInFortran: HelloArgonInFortran.f90 openmm.mod OpenMMFortranWrapper.o OpenMMCWrapper.o HelloArgonInFortran: HelloArgonInFortran.f90 openmm.mod
gfortran $(FFLAGS) HelloArgonInFortran.f90 OpenMMFortranWrapper.o OpenMMCWrapper.o \ gfortran $(FFLAGS) HelloArgonInFortran.f90 \
-L$(LIB_DIR) $(LIBS) $(FCPPLIBS) -o HelloArgonInFortran -L$(LIB_DIR) $(LIBS) $(FCPPLIBS) -o HelloArgonInFortran
HelloSodiumChlorideInFortran: HelloSodiumChlorideInFortran.f90 openmm.mod OpenMMFortranWrapper.o OpenMMCWrapper.o HelloSodiumChlorideInFortran: HelloSodiumChlorideInFortran.f90 openmm.mod
gfortran $(FFLAGS) HelloSodiumChlorideInFortran.f90 OpenMMFortranWrapper.o OpenMMCWrapper.o \ gfortran $(FFLAGS) HelloSodiumChlorideInFortran.f90 \
-L$(LIB_DIR) $(LIBS) $(FCPPLIBS) -o HelloSodiumChlorideInFortran -L$(LIB_DIR) $(LIBS) $(FCPPLIBS) -o HelloSodiumChlorideInFortran
# Build C Wrappers (Fortran depends on this too)
OpenMMCWrapper.o:
g++ -c $(CFLAGS) -I$(WRAPPER_DIR) -I$(INCLUDE_DIR) \
$(WRAPPER_DIR)/OpenMMCWrapper.cpp -o OpenMMCWrapper.o
# Build Fortran Wrappers
OpenMMFortranWrapper.o:
g++ -c $(CFLAGS) -I$(WRAPPER_DIR) -I$(INCLUDE_DIR) \
$(WRAPPER_DIR)/OpenMMFortranWrapper.cpp -o OpenMMFortranWrapper.o
# Build Fortran 95 Module file # Build Fortran 95 Module file
openmm.mod: openmm.mod:
gfortran -c $(FFLAGS) $(WRAPPER_DIR)/OpenMMFortranModule.f90 gfortran -c $(FFLAGS) $(INCLUDE_DIR)/OpenMMFortranModule.f90
clean : clean :
rm $(ALL_PROGS) *.o *.mod *.obj *.exe rm $(ALL_PROGS) *.o *.mod *.obj *.exe
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* --------------------------------------------------------------------------
* OpenMM(tm) PROTOTYPE C wrapper function declarations (June 2009)
* --------------------------------------------------------------------------
* This header should be included by a C main program that would like to
* access the OpenMM API through the C wrappers. Please note that this is an
* experimental prototype, not an official part of OpenMM; it is just an
* example of how the C++ API can be wrapped for access from C.
*
* This set of wrappers is incomplete. If you add more, please send them
* to us. Improvements in substance and style would also be greatly
* appreciated. If you have ideas (or better code) please post to the OpenMM
* forum on simtk.org/home/openmm or if you're shy you can email Michael
* Sherman at msherman@stanford.edu.
*
* Note: this header must be includable in both ANSI C and C++ code, because
* the function declarations must be common to both the users and the
* implementing code, which is in C++.
* -------------------------------------------------------------------------- */
#ifndef OPENMM_CWRAPPER_H_
#define OPENMM_CWRAPPER_H_
/* Declare incomplete types corresponding to each of the OpenMM objects that
* we want to make available. This allows us to have unique pointer types
* for each object to maintain some semblance of type safety.
*/
/* These first three types represent the three OpenMM runtime objects that
* must persist from call to call during an OpenMM-powered simulation.
* OpenMM_Integrator is the generic type of all Integrator objects. */
typedef struct OpenMM_System_s OpenMM_System;
typedef struct OpenMM_Integrator_s OpenMM_Integrator;
typedef struct OpenMM_Context_s OpenMM_Context;
/* This is the generic type of all Force objects. */
typedef struct OpenMM_Force_s OpenMM_Force;
/* This struct collects all the runtime object pointers together to
* facilitate use of an opaque handle in high-level C or Fortran code
* that doesn't have (or want) access to OpenMM declarations. This
* does not have an equivalent in the OpenMM C++ API. */
typedef struct OpenMM_RuntimeObjects_s {
OpenMM_System* system;
OpenMM_Integrator* integrator;
OpenMM_Context* context;
} OpenMM_RuntimeObjects;
typedef double OpenMM_Vec3[3];
typedef struct OpenMM_Vec3Array_s OpenMM_Vec3Array;
typedef struct OpenMM_BondArray_s OpenMM_BondArray;
typedef struct OpenMM_String_s OpenMM_String;
/*
* OpenMM_Integrator is the generic type for all integrators. Cast your
* specific pointer type to the generic one for communication with functions
* that take type OpenMM_Integrator.
*/
typedef struct OpenMM_VerletIntegrator_s OpenMM_VerletIntegrator;
typedef struct OpenMM_LangevinIntegrator_s OpenMM_LangevinIntegrator;
/*
* OpenMM_Force is the generic type for all Force objects. Create the
* concrete Force object and then cast it to the generic type.
*/
typedef struct OpenMM_NonbondedForce_s OpenMM_NonbondedForce;
typedef struct OpenMM_GBSAOBCForce_s OpenMM_GBSAOBCForce;
typedef struct OpenMM_HarmonicBondForce_s OpenMM_HarmonicBondForce;
typedef struct OpenMM_HarmonicAngleForce_s OpenMM_HarmonicAngleForce;
typedef struct OpenMM_PeriodicTorsionForce_s OpenMM_PeriodicTorsionForce;
typedef struct OpenMM_AndersenThermostat_s OpenMM_AndersenThermostat;
typedef enum {
OpenMM_NonbondedForce_NoCutoff = 0,
OpenMM_NonbondedForce_CutoffNonPeriodic = 1,
OpenMM_NonbondedForce_CutoffPeriodic = 2,
OpenMM_NonbondedForce_Ewald = 3
} OpenMM_NonbondedForce_NonbondedMethod;
typedef struct OpenMM_State_s OpenMM_State;
typedef enum {
OpenMM_State_Positions = 1,
OpenMM_State_Velocities = 2,
OpenMM_State_Forces = 4,
OpenMM_State_Energy = 8,
OpenMM_State_Parameters = 16
} OpenMM_State_DataType;
/* Conversion constants from openmm/Units.h */
/*
* The number of nanometers in an Angstrom.
*/
static const double OpenMM_NmPerAngstrom = 0.1;
/*
* The number of Angstroms in a nanometer.
*/
static const double OpenMM_AngstromsPerNm = 10.0;
/*
* The number of picoseconds in a femtosecond.
*/
static const double OpenMM_PsPerFs = 0.001;
/*
* The number of femtoseconds in a picosecond.
*/
static const double OpenMM_FsPerPs = 1000.0;
/*
* The number of kJ in a kcal.
*/
static const double OpenMM_KJPerKcal = 4.184;
/*
* The number of kcal in a kJ.
*/
static const double OpenMM_KcalPerKJ = 1.0/4.184;
/*
* The number of radians in a degree.
*/
static const double OpenMM_RadiansPerDegree = 3.1415926535897932385/180.0;
/*
* The number of degrees in a radian.
*/
static const double OpenMM_DegreesPerRadian = 180.0/3.1415926535897932385;
/*
* This is the conversion factor that takes you from a van der Waals radius
* (defined as 1/2 the minimum energy separation) to the related Lennard Jones
* "sigma" parameter (defined as the zero crossing separation). The value
* is 2*pow(2, -1/6).
*/
static const double OpenMM_SigmaPerVdwRadius = 1.7817974362806786095;
#if defined(__cplusplus)
extern "C" {
#endif
/* OpenMM_Vec3Array */
extern OpenMM_Vec3Array* OpenMM_Vec3Array_create(int n);
extern int OpenMM_Vec3Array_size(const OpenMM_Vec3Array*);
extern void OpenMM_Vec3Array_resize(OpenMM_Vec3Array*, int n);
extern void OpenMM_Vec3Array_destroy(OpenMM_Vec3Array*);
extern void OpenMM_Vec3Array_append(OpenMM_Vec3Array*, const double[3]);
extern void OpenMM_Vec3Array_get(const OpenMM_Vec3Array*, int i, double[3]);
extern void OpenMM_Vec3Array_getScaled(const OpenMM_Vec3Array*, int i, double s, double[3]);
extern void OpenMM_Vec3Array_set(OpenMM_Vec3Array*, int i, const double[3]);
extern void OpenMM_Vec3Array_setScaled(OpenMM_Vec3Array*, int i, const double[3], double s);
extern void OpenMM_Vec3_scale(const double in[3], double s, double out[3]);
/* OpenMM_BondArray */
extern OpenMM_BondArray* OpenMM_BondArray_create(int n);
extern int OpenMM_BondArray_size(const OpenMM_BondArray*);
extern void OpenMM_BondArray_resize(OpenMM_BondArray*, int n);
extern void OpenMM_BondArray_destroy(OpenMM_BondArray*);
extern void OpenMM_BondArray_append(OpenMM_BondArray*, int p1, int p2);
extern void OpenMM_BondArray_get(const OpenMM_BondArray*, int i, int* p1, int* p2);
extern void OpenMM_BondArray_set(OpenMM_BondArray*, int i, int p1, int p2);
/* OpenMM_String */
extern OpenMM_String* OpenMM_String_create(const char* init);
extern void OpenMM_String_destroy(OpenMM_String*);
extern int OpenMM_String_length(const OpenMM_String*);
extern const char* OpenMM_String_getAsC(const OpenMM_String*);
extern void OpenMM_String_get(const OpenMM_String*, char* buf, int buflen);
extern void OpenMM_String_set(OpenMM_String*, const char* buf);
/* OpenMM::Platform */
extern void OpenMM_Platform_loadPluginsFromDirectory(const char*);
extern const char* OpenMM_Platform_getDefaultPluginsDirectory();
/* OpenMM::System */
extern OpenMM_System* OpenMM_System_create();
extern void OpenMM_System_destroy (OpenMM_System*);
extern int OpenMM_System_addParticle(OpenMM_System*, double mass);
extern void OpenMM_System_setParticleMass(OpenMM_System*, int ix, double mass);
extern double OpenMM_System_getParticleMass(const OpenMM_System*, int ix);
extern int OpenMM_System_addConstraint(OpenMM_System*, int p1, int p2, double distance);
extern void OpenMM_System_setConstraintParameters(OpenMM_System*, int ix,
int p1, int p2, double distance);
extern void OpenMM_System_getConstraintParameters(const OpenMM_System*, int ix,
int* p1, int* p2, double* distance);
extern int OpenMM_System_addForce(OpenMM_System*, OpenMM_Force*);
extern OpenMM_Force* OpenMM_System_updForce(OpenMM_System*, int ix);
extern const OpenMM_Force* OpenMM_System_getForce(const OpenMM_System*, int ix);
extern int OpenMM_System_getNumParticles(const OpenMM_System*);
extern int OpenMM_System_getNumConstraints(const OpenMM_System*);
extern int OpenMM_System_getNumForces(const OpenMM_System*);
/* OpenMM::NonbondedForce */
extern OpenMM_NonbondedForce* OpenMM_NonbondedForce_create();
extern void OpenMM_NonbondedForce_destroy (OpenMM_NonbondedForce*);
extern void OpenMM_NonbondedForce_setNonbondedMethod (OpenMM_NonbondedForce*,
OpenMM_NonbondedForce_NonbondedMethod);
extern OpenMM_NonbondedForce_NonbondedMethod
OpenMM_NonbondedForce_getNonbondedMethod (const OpenMM_NonbondedForce*);
extern void OpenMM_NonbondedForce_setCutoffDistance (OpenMM_NonbondedForce*, double);
extern double OpenMM_NonbondedForce_getCutoffDistance (const OpenMM_NonbondedForce*);
extern void OpenMM_NonbondedForce_setPeriodicBoxVectors(OpenMM_NonbondedForce*,
const OpenMM_Vec3,const OpenMM_Vec3,const OpenMM_Vec3);
extern void OpenMM_NonbondedForce_getPeriodicBoxVectors(const OpenMM_NonbondedForce*,
OpenMM_Vec3, OpenMM_Vec3, OpenMM_Vec3);
extern int OpenMM_NonbondedForce_addParticle(OpenMM_NonbondedForce*,
double charge,
double sigmaInNm,
double vdwEnergyInKJ);
extern void OpenMM_NonbondedForce_setParticleParameters(OpenMM_NonbondedForce*, int index,
double charge,
double sigmaInNm,
double vdwEnergyInKJ);
extern void OpenMM_NonbondedForce_getParticleParameters(const OpenMM_NonbondedForce*, int index,
double* charge,
double* sigmaInNm,
double* vdwEnergyInKJ);
extern int OpenMM_NonbondedForce_getNumParticles(const OpenMM_NonbondedForce*);
extern int OpenMM_NonbondedForce_getNumExceptions(const OpenMM_NonbondedForce*);
extern int OpenMM_NonbondedForce_addException(OpenMM_NonbondedForce*, int p1, int p2,
double chargeProd, double sigma, double epsilon);
extern void OpenMM_NonbondedForce_getExceptionParameters(const OpenMM_NonbondedForce*, int index, int* p1, int* p2,
double* chargeProd, double* sigma, double* epsilon);
extern void OpenMM_NonbondedForce_setExceptionParameters(OpenMM_NonbondedForce*, int index, int p1, int p2,
double chargeProd, double sigma, double epsilon);
extern void OpenMM_NonbondedForces_createExceptionsFromBonds(OpenMM_NonbondedForce*, const OpenMM_BondArray*,
double coulomb14Scale, double lj14Scale);
/* OpenMM::GBSAOBCForce */
extern OpenMM_GBSAOBCForce* OpenMM_GBSAOBCForce_create();
extern void OpenMM_GBSAOBCForce_destroy (OpenMM_GBSAOBCForce*);
extern void OpenMM_GBSAOBCForce_setSolventDielectric(OpenMM_GBSAOBCForce*, double);
extern void OpenMM_GBSAOBCForce_setSoluteDielectric (OpenMM_GBSAOBCForce*, double);
extern int OpenMM_GBSAOBCForce_addParticle(OpenMM_GBSAOBCForce*,
double charge,
double radiusInNm,
double scalingFactor);
/* OpenMM::HarmonicBondForce */
extern OpenMM_HarmonicBondForce* OpenMM_HarmonicBondForce_create();
extern void OpenMM_HarmonicBondForce_destroy(OpenMM_HarmonicBondForce*);
extern int OpenMM_HarmonicBondForce_getNumBonds(const OpenMM_HarmonicBondForce*);
extern int OpenMM_HarmonicBondForce_addBond(OpenMM_HarmonicBondForce*, int p1, int p2, double len, double k);
extern void OpenMM_HarmonicBondForce_getBondParameters(const OpenMM_HarmonicBondForce*, int ix, int* p1, int* p2, double* len, double* k);
extern void OpenMM_HarmonicBondForce_setBondParameters(OpenMM_HarmonicBondForce*, int ix, int p1, int p2, double len, double k);
/* OpenMM::HarmonicAngleForce */
extern OpenMM_HarmonicAngleForce* OpenMM_HarmonicAngleForce_create();
extern void OpenMM_HarmonicAngleForce_destroy(OpenMM_HarmonicAngleForce*);
extern int OpenMM_HarmonicAngleForce_getNumAngles(const OpenMM_HarmonicAngleForce*);
extern int OpenMM_HarmonicAngleForce_addAngle(OpenMM_HarmonicAngleForce*, int p1, int p2, int p3, double angle, double k);
extern void OpenMM_HarmonicAngleForce_getAngleParameters(const OpenMM_HarmonicAngleForce*, int ix, int* p1, int* p2, int* p3, double* angle, double* k);
extern void OpenMM_HarmonicAngleForce_setAngleParameters(OpenMM_HarmonicAngleForce*, int ix, int p1, int p2, int p3, double angle, double k);
/* OpenMM::PeriodicTorsionForce */
extern OpenMM_PeriodicTorsionForce* OpenMM_PeriodicTorsionForce_create();
extern void OpenMM_PeriodicTorsionForce_destroy(OpenMM_PeriodicTorsionForce*);
extern int OpenMM_PeriodicTorsionForce_getNumTorsions(const OpenMM_PeriodicTorsionForce*);
extern int OpenMM_PeriodicTorsionForce_addTorsion(OpenMM_PeriodicTorsionForce*, int p1, int p2, int p3, int p4,
int periodicity, double phase, double k);
extern void OpenMM_PeriodicTorsionForce_getTorsionParameters(const OpenMM_PeriodicTorsionForce*, int ix, int* p1, int* p2, int* p3, int* p4,
int* periodicity, double* phase, double* k);
extern void OpenMM_PeriodicTorsionForce_setTorsionParameters(OpenMM_PeriodicTorsionForce*, int ix, int p1, int p2, int p3, int p4,
int periodicity, double phase, double k);
/* OpenMM::AndersenThermostat */
extern OpenMM_AndersenThermostat* OpenMM_AndersenThermostat_create(double temp, double collisionFreqInPerPs);
extern void OpenMM_AndersenThermostat_destroy(OpenMM_AndersenThermostat*);
extern double OpenMM_AndersenThermostat_getDefaultTemperature(const OpenMM_AndersenThermostat*);
extern double OpenMM_AndersenThermostat_getDefaultCollisionFrequency(const OpenMM_AndersenThermostat*);
extern int OpenMM_AndersenThermostat_getRandomNumberSeed(const OpenMM_AndersenThermostat*);
extern void OpenMM_AndersenThermostat_setRandomNumberSeed(OpenMM_AndersenThermostat*, int seed);
/* OpenMM::Integrator */
extern void OpenMM_Integrator_step(OpenMM_Integrator*, int numSteps);
extern void OpenMM_Integrator_destroy(OpenMM_Integrator*);
/* OpenMM::VerletIntegrator */
extern OpenMM_VerletIntegrator* OpenMM_VerletIntegrator_create(double stepSzInPs);
extern void OpenMM_VerletIntegrator_destroy(OpenMM_VerletIntegrator*);
extern void OpenMM_VerletIntegrator_step(OpenMM_VerletIntegrator*, int numSteps);
/* OpenMM::LangevinIntegrator */
extern OpenMM_LangevinIntegrator* OpenMM_LangevinIntegrator_create(double temperature, double frictionInPerPs, double stepSzInPs);
extern void OpenMM_LangevinIntegrator_destroy(OpenMM_LangevinIntegrator*);
extern void OpenMM_LangevinIntegrator_step(OpenMM_LangevinIntegrator*, int numSteps);
/* OpenMM::Context */
extern OpenMM_Context* OpenMM_Context_create(OpenMM_System*, OpenMM_Integrator*);
extern void OpenMM_Context_destroy(OpenMM_Context*);
extern void OpenMM_Context_setPositions(OpenMM_Context*, const OpenMM_Vec3Array*);
extern void OpenMM_Context_setVelocities(OpenMM_Context*, const OpenMM_Vec3Array*);
extern OpenMM_State* OpenMM_Context_createState(const OpenMM_Context*, int types);
extern const char* OpenMM_Context_getPlatformName(const OpenMM_Context*);
/* OpenMM::State */
extern void OpenMM_State_destroy(OpenMM_State*);
extern double OpenMM_State_getTime(const OpenMM_State*);
extern double OpenMM_State_getPotentialEnergy(const OpenMM_State*);
extern double OpenMM_State_getKineticEnergy(const OpenMM_State*);
extern const OpenMM_Vec3Array* OpenMM_State_getPositions(const OpenMM_State*);
extern const OpenMM_Vec3Array* OpenMM_State_getVelocities(const OpenMM_State*);
/* OpenMM_Runtime_Objects */
extern OpenMM_RuntimeObjects* OpenMM_RuntimeObjects_create();
extern void OpenMM_RuntimeObjects_clear(OpenMM_RuntimeObjects*);
extern void OpenMM_RuntimeObjects_destroy(OpenMM_RuntimeObjects*);
extern void OpenMM_RuntimeObjects_setSystem(OpenMM_RuntimeObjects*, OpenMM_System*);
extern void OpenMM_RuntimeObjects_setIntegrator(OpenMM_RuntimeObjects*, OpenMM_Integrator*);
extern void OpenMM_RuntimeObjects_setContext(OpenMM_RuntimeObjects*, OpenMM_Context*);
extern OpenMM_System* OpenMM_RuntimeObjects_getSystem(OpenMM_RuntimeObjects*);
extern OpenMM_Integrator* OpenMM_RuntimeObjects_getIntegrator(OpenMM_RuntimeObjects*);
extern OpenMM_Context* OpenMM_RuntimeObjects_getContext(OpenMM_RuntimeObjects*);
#if defined(__cplusplus)
}
#endif
#endif /*OPENMM_CWRAPPER_H_*/
This diff is collapsed.
...@@ -19,7 +19,5 @@ ADD_CUSTOM_COMMAND(OUTPUT OpenMMFortranWrapper.cpp COMMAND ${JAVA_RUNTIME} -jar ...@@ -19,7 +19,5 @@ ADD_CUSTOM_COMMAND(OUTPUT OpenMMFortranWrapper.cpp COMMAND ${JAVA_RUNTIME} -jar
ADD_CUSTOM_TARGET(ApiWrappers DEPENDS OpenMMCWrapper.h OpenMMCWrapper.cpp OpenMMFortranModule.f90 OpenMMFortranWrapper.cpp) ADD_CUSTOM_TARGET(ApiWrappers DEPENDS OpenMMCWrapper.h OpenMMCWrapper.cpp OpenMMFortranModule.f90 OpenMMFortranWrapper.cpp)
ADD_DEPENDENCIES(${SHARED_TARGET} ApiWrappers)
ADD_DEPENDENCIES(${STATIC_TARGET} ApiWrappers)
INSTALL_FILES(/include FILES OpenMMCWrapper.h OpenMMFortranModule.f90) INSTALL_FILES(/include FILES OpenMMCWrapper.h OpenMMFortranModule.f90)
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
#ifndef OPENMM_CWRAPPER_H_ #ifndef OPENMM_CWRAPPER_H_
#define OPENMM_CWRAPPER_H_ #define OPENMM_CWRAPPER_H_
#ifndef OPENMM_EXPORT
#define OPENMM_EXPORT
#endif
/* Global Constants */ /* Global Constants */
<xsl:for-each select="Variable[@context=$openmm_namespace_id]"> <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), ';')"/> 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), ';')"/>
...@@ -51,38 +55,38 @@ extern "C" { ...@@ -51,38 +55,38 @@ extern "C" {
#endif #endif
/* OpenMM_Vec3 */ /* OpenMM_Vec3 */
extern OpenMM_Vec3 OpenMM_Vec3_scale(const OpenMM_Vec3 vec, double scale); extern OPENMM_EXPORT OpenMM_Vec3 OpenMM_Vec3_scale(const OpenMM_Vec3 vec, double scale);
/* OpenMM_Vec3Array */ /* OpenMM_Vec3Array */
extern OpenMM_Vec3Array* OpenMM_Vec3Array_create(int size); extern OPENMM_EXPORT OpenMM_Vec3Array* OpenMM_Vec3Array_create(int size);
extern void OpenMM_Vec3Array_destroy(OpenMM_Vec3Array* array); extern OPENMM_EXPORT void OpenMM_Vec3Array_destroy(OpenMM_Vec3Array* array);
extern int OpenMM_Vec3Array_getSize(const OpenMM_Vec3Array* array); extern OPENMM_EXPORT int OpenMM_Vec3Array_getSize(const OpenMM_Vec3Array* array);
extern void OpenMM_Vec3Array_resize(OpenMM_Vec3Array* array, int size); extern OPENMM_EXPORT void OpenMM_Vec3Array_resize(OpenMM_Vec3Array* array, int size);
extern void OpenMM_Vec3Array_append(OpenMM_Vec3Array* array, const OpenMM_Vec3 vec); extern OPENMM_EXPORT void OpenMM_Vec3Array_append(OpenMM_Vec3Array* array, const OpenMM_Vec3 vec);
extern void OpenMM_Vec3Array_set(OpenMM_Vec3Array* array, int index, const OpenMM_Vec3 vec); extern OPENMM_EXPORT void OpenMM_Vec3Array_set(OpenMM_Vec3Array* array, int index, const OpenMM_Vec3 vec);
extern const OpenMM_Vec3* OpenMM_Vec3Array_get(const OpenMM_Vec3Array* array, int index); extern OPENMM_EXPORT const OpenMM_Vec3* OpenMM_Vec3Array_get(const OpenMM_Vec3Array* array, int index);
/* OpenMM_StringArray */ /* OpenMM_StringArray */
extern OpenMM_StringArray* OpenMM_StringArray_create(int size); extern OPENMM_EXPORT OpenMM_StringArray* OpenMM_StringArray_create(int size);
extern void OpenMM_StringArray_destroy(OpenMM_StringArray* array); extern OPENMM_EXPORT void OpenMM_StringArray_destroy(OpenMM_StringArray* array);
extern int OpenMM_StringArray_getSize(const OpenMM_StringArray* array); extern OPENMM_EXPORT int OpenMM_StringArray_getSize(const OpenMM_StringArray* array);
extern void OpenMM_StringArray_resize(OpenMM_StringArray* array, int size); extern OPENMM_EXPORT void OpenMM_StringArray_resize(OpenMM_StringArray* array, int size);
extern void OpenMM_StringArray_append(OpenMM_StringArray* array, const char* string); extern OPENMM_EXPORT void OpenMM_StringArray_append(OpenMM_StringArray* array, const char* string);
extern void OpenMM_StringArray_set(OpenMM_StringArray* array, int index, const char* string); extern OPENMM_EXPORT void OpenMM_StringArray_set(OpenMM_StringArray* array, int index, const char* string);
extern const char* OpenMM_StringArray_get(const OpenMM_StringArray* array, int index); extern OPENMM_EXPORT const char* OpenMM_StringArray_get(const OpenMM_StringArray* array, int index);
/* OpenMM_BondArray */ /* OpenMM_BondArray */
extern OpenMM_BondArray* OpenMM_BondArray_create(int size); extern OPENMM_EXPORT OpenMM_BondArray* OpenMM_BondArray_create(int size);
extern void OpenMM_BondArray_destroy(OpenMM_BondArray* array); extern OPENMM_EXPORT void OpenMM_BondArray_destroy(OpenMM_BondArray* array);
extern int OpenMM_BondArray_getSize(const OpenMM_BondArray* array); extern OPENMM_EXPORT int OpenMM_BondArray_getSize(const OpenMM_BondArray* array);
extern void OpenMM_BondArray_resize(OpenMM_BondArray* array, int size); extern OPENMM_EXPORT void OpenMM_BondArray_resize(OpenMM_BondArray* array, int size);
extern void OpenMM_BondArray_append(OpenMM_BondArray* array, int particle1, int particle2); extern OPENMM_EXPORT void OpenMM_BondArray_append(OpenMM_BondArray* array, int particle1, int particle2);
extern void OpenMM_BondArray_set(OpenMM_BondArray* array, int index, int particle1, int particle2); extern OPENMM_EXPORT void OpenMM_BondArray_set(OpenMM_BondArray* array, int index, int particle1, int particle2);
extern void OpenMM_BondArray_get(const 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 */ /* OpenMM_ParameterArray */
extern int OpenMM_ParameterArray_getSize(const OpenMM_ParameterArray* array); extern OPENMM_EXPORT int OpenMM_ParameterArray_getSize(const OpenMM_ParameterArray* array);
extern double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* array, const char* name); extern OPENMM_EXPORT double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* array, const char* name);
<xsl:call-template name="primitive_array"> <xsl:call-template name="primitive_array">
<xsl:with-param name="element_type" select="'double'"/> <xsl:with-param name="element_type" select="'double'"/>
<xsl:with-param name="name" select="'OpenMM_DoubleArray'"/> <xsl:with-param name="name" select="'OpenMM_DoubleArray'"/>
...@@ -90,8 +94,8 @@ extern double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* array, cons ...@@ -90,8 +94,8 @@ extern double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* array, cons
/* These methods need to be handled specially, since their C++ APIs cannot be directly translated to C. /* 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. */ Unlike the C++ versions, the return value is allocated on the heap, and you must delete it yourself. */
extern OpenMM_State* OpenMM_Context_getState(const OpenMM_Context* target, int types); extern OPENMM_EXPORT OpenMM_State* OpenMM_Context_getState(const OpenMM_Context* target, int types);
extern OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directory); extern OPENMM_EXPORT OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directory);
<!-- Class members --> <!-- Class members -->
<xsl:for-each select="Class[@context=$openmm_namespace_id and empty(index-of($skip_classes, @name))]"> <xsl:for-each select="Class[@context=$openmm_namespace_id and empty(index-of($skip_classes, @name))]">
...@@ -110,13 +114,13 @@ extern OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* ...@@ -110,13 +114,13 @@ extern OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char*
<xsl:param name="element_type"/> <xsl:param name="element_type"/>
<xsl:param name="name"/> <xsl:param name="name"/>
/* <xsl:value-of select="$name"/> */ /* <xsl:value-of select="$name"/> */
extern <xsl:value-of select="$name"/>* <xsl:value-of select="$name"/>_create(int size); extern OPENMM_EXPORT <xsl:value-of select="$name"/>* <xsl:value-of select="$name"/>_create(int size);
extern void <xsl:value-of select="$name"/>_destroy(<xsl:value-of select="$name"/>* array); extern OPENMM_EXPORT void <xsl:value-of select="$name"/>_destroy(<xsl:value-of select="$name"/>* array);
extern int <xsl:value-of select="$name"/>_getSize(const <xsl:value-of select="$name"/>* array); extern OPENMM_EXPORT int <xsl:value-of select="$name"/>_getSize(const <xsl:value-of select="$name"/>* array);
extern void <xsl:value-of select="$name"/>_resize(<xsl:value-of select="$name"/>* array, int size); extern OPENMM_EXPORT void <xsl:value-of select="$name"/>_resize(<xsl:value-of select="$name"/>* array, int size);
extern 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"/>_append(<xsl:value-of select="$name"/>* array, <xsl:value-of select="$element_type"/> value);
extern 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 void <xsl:value-of select="$name"/>_set(<xsl:value-of select="$name"/>* array, int index, <xsl:value-of select="$element_type"/> value);
extern <xsl:value-of select="concat($element_type, ' ', $name)"/>_get(const <xsl:value-of select="$name"/>* array, int index); extern OPENMM_EXPORT <xsl:value-of select="concat($element_type, ' ', $name)"/>_get(const <xsl:value-of select="$name"/>* array, int index);
</xsl:template> </xsl:template>
<!-- Print out information for a class --> <!-- Print out information for a class -->
...@@ -140,7 +144,7 @@ extern <xsl:value-of select="concat($element_type, ' ', $name)"/>_get(const <xsl ...@@ -140,7 +144,7 @@ extern <xsl:value-of select="concat($element_type, ' ', $name)"/>_get(const <xsl
</xsl:call-template> </xsl:call-template>
</xsl:for-each> </xsl:for-each>
</xsl:if> </xsl:if>
extern void OpenMM_<xsl:value-of select="concat(@name, '_destroy(OpenMM_', @name, '* target);')"/> extern OPENMM_EXPORT void OpenMM_<xsl:value-of select="concat(@name, '_destroy(OpenMM_', @name, '* target);')"/>
<!-- Methods --> <!-- Methods -->
<xsl:variable name="methods" select="/GCC_XML/Method[@context=$class_id and @access='public']"/> <xsl:variable name="methods" select="/GCC_XML/Method[@context=$class_id and @access='public']"/>
<xsl:for-each select="$methods"> <xsl:for-each select="$methods">
...@@ -173,7 +177,7 @@ typedef enum { ...@@ -173,7 +177,7 @@ typedef enum {
<!-- Print out the declaration for a constructor --> <!-- Print out the declaration for a constructor -->
<xsl:template name="constructor"> <xsl:template name="constructor">
<xsl:param name="suffix"/> <xsl:param name="suffix"/>
extern OpenMM_<xsl:value-of select="concat(@name, '* OpenMM_', @name, '_create', $suffix, '(')"/> extern OPENMM_EXPORT OpenMM_<xsl:value-of select="concat(@name, '* OpenMM_', @name, '_create', $suffix, '(')"/>
<xsl:for-each select="Argument"> <xsl:for-each select="Argument">
<xsl:if test="position() > 1">, </xsl:if> <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:call-template name="wrap_type"><xsl:with-param name="type_id" select="@type"/></xsl:call-template>
...@@ -185,7 +189,7 @@ extern OpenMM_<xsl:value-of select="concat(@name, '* OpenMM_', @name, '_create', ...@@ -185,7 +189,7 @@ extern OpenMM_<xsl:value-of select="concat(@name, '* OpenMM_', @name, '_create',
<!-- Print out the declaration for a method --> <!-- Print out the declaration for a method -->
<xsl:template name="method"> <xsl:template name="method">
<xsl:param name="class_name"/> <xsl:param name="class_name"/>
extern <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, '(')"/> 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="not(@static='1')">
<xsl:if test="@const='1'"> <xsl:if test="@const='1'">
<xsl:value-of select="'const '"/> <xsl:value-of select="'const '"/>
......
...@@ -32,100 +32,98 @@ ...@@ -32,100 +32,98 @@
<!-- Main loop over all classes in the OpenMM namespace --> <!-- Main loop over all classes in the OpenMM namespace -->
<xsl:template match="/GCC_XML"> <xsl:template match="/GCC_XML">
#include "OpenMMCWrapper.h"
#include "OpenMM.h" #include "OpenMM.h"
#include "OpenMMCWrapper.h"
#include &lt;cstring&gt; #include &lt;cstring&gt;
#include &lt;vector&gt; #include &lt;vector&gt;
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
#if defined(__cplusplus)
extern "C" { extern "C" {
#endif
/* OpenMM_Vec3 */ /* OpenMM_Vec3 */
OpenMM_Vec3 OpenMM_Vec3_scale(const OpenMM_Vec3 vec, double scale) { 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}; OpenMM_Vec3 result = {vec.x*scale, vec.y*scale, vec.z*scale};
return result; return result;
} }
/* OpenMM_Vec3Array */ /* OpenMM_Vec3Array */
OpenMM_Vec3Array* OpenMM_Vec3Array_create(int size) { OPENMM_EXPORT OpenMM_Vec3Array* OpenMM_Vec3Array_create(int size) {
return reinterpret_cast&lt;OpenMM_Vec3Array*&gt;(new vector&lt;Vec3&gt;(size)); return reinterpret_cast&lt;OpenMM_Vec3Array*&gt;(new vector&lt;Vec3&gt;(size));
} }
void OpenMM_Vec3Array_destroy(OpenMM_Vec3Array* array) { OPENMM_EXPORT void OpenMM_Vec3Array_destroy(OpenMM_Vec3Array* array) {
delete reinterpret_cast&lt;vector&lt;Vec3&gt;*&gt;(array); delete reinterpret_cast&lt;vector&lt;Vec3&gt;*&gt;(array);
} }
int OpenMM_Vec3Array_getSize(const OpenMM_Vec3Array* array) { OPENMM_EXPORT int OpenMM_Vec3Array_getSize(const OpenMM_Vec3Array* array) {
return reinterpret_cast&lt;const vector&lt;Vec3&gt;*&gt;(array)->size(); return reinterpret_cast&lt;const vector&lt;Vec3&gt;*&gt;(array)->size();
} }
void OpenMM_Vec3Array_resize(OpenMM_Vec3Array* array, int size) { OPENMM_EXPORT void OpenMM_Vec3Array_resize(OpenMM_Vec3Array* array, int size) {
reinterpret_cast&lt;vector&lt;Vec3&gt;*&gt;(array)->resize(size); reinterpret_cast&lt;vector&lt;Vec3&gt;*&gt;(array)->resize(size);
} }
void OpenMM_Vec3Array_append(OpenMM_Vec3Array* array, const OpenMM_Vec3 vec) { 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)); reinterpret_cast&lt;vector&lt;Vec3&gt;*&gt;(array)->push_back(Vec3(vec.x, vec.y, vec.z));
} }
void OpenMM_Vec3Array_set(OpenMM_Vec3Array* array, int index, const OpenMM_Vec3 vec) { 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); (*reinterpret_cast&lt;vector&lt;Vec3&gt;*&gt;(array))[index] = Vec3(vec.x, vec.y, vec.z);
} }
const OpenMM_Vec3* OpenMM_Vec3Array_get(const OpenMM_Vec3Array* array, int index) { 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])); return reinterpret_cast&lt;const OpenMM_Vec3*&gt;((&amp;(*reinterpret_cast&lt;const vector&lt;Vec3&gt;*&gt;(array))[index]));
} }
/* OpenMM_StringArray */ /* OpenMM_StringArray */
OpenMM_StringArray* OpenMM_StringArray_create(int size) { OPENMM_EXPORT OpenMM_StringArray* OpenMM_StringArray_create(int size) {
return reinterpret_cast&lt;OpenMM_StringArray*&gt;(new vector&lt;string&gt;(size)); return reinterpret_cast&lt;OpenMM_StringArray*&gt;(new vector&lt;string&gt;(size));
} }
void OpenMM_StringArray_destroy(OpenMM_StringArray* array) { OPENMM_EXPORT void OpenMM_StringArray_destroy(OpenMM_StringArray* array) {
delete reinterpret_cast&lt;vector&lt;string&gt;*&gt;(array); delete reinterpret_cast&lt;vector&lt;string&gt;*&gt;(array);
} }
int OpenMM_StringArray_getSize(const OpenMM_StringArray* array) { OPENMM_EXPORT int OpenMM_StringArray_getSize(const OpenMM_StringArray* array) {
return reinterpret_cast&lt;const vector&lt;string&gt;*&gt;(array)->size(); return reinterpret_cast&lt;const vector&lt;string&gt;*&gt;(array)->size();
} }
void OpenMM_StringArray_resize(OpenMM_StringArray* array, int size) { OPENMM_EXPORT void OpenMM_StringArray_resize(OpenMM_StringArray* array, int size) {
reinterpret_cast&lt;vector&lt;string&gt;*&gt;(array)->resize(size); reinterpret_cast&lt;vector&lt;string&gt;*&gt;(array)->resize(size);
} }
void OpenMM_StringArray_append(OpenMM_StringArray* array, const char* str) { 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)); reinterpret_cast&lt;vector&lt;string&gt;*&gt;(array)->push_back(string(str));
} }
void OpenMM_StringArray_set(OpenMM_StringArray* array, int index, const char* 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); (*reinterpret_cast&lt;vector&lt;string&gt;*&gt;(array))[index] = string(str);
} }
const char* OpenMM_StringArray_get(const OpenMM_StringArray* array, int index) { 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(); return (*reinterpret_cast&lt;const vector&lt;string&gt;*&gt;(array))[index].c_str();
} }
/* OpenMM_BondArray */ /* OpenMM_BondArray */
OpenMM_BondArray* OpenMM_BondArray_create(int size) { 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)); return reinterpret_cast&lt;OpenMM_BondArray*&gt;(new vector&lt;pair&lt;int, int&gt; &gt;(size));
} }
void OpenMM_BondArray_destroy(OpenMM_BondArray* array) { OPENMM_EXPORT void OpenMM_BondArray_destroy(OpenMM_BondArray* array) {
delete reinterpret_cast&lt;vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array); delete reinterpret_cast&lt;vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array);
} }
int OpenMM_BondArray_getSize(const OpenMM_BondArray* 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(); return reinterpret_cast&lt;const vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array)->size();
} }
void OpenMM_BondArray_resize(OpenMM_BondArray* array, int 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); reinterpret_cast&lt;vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array)->resize(size);
} }
void OpenMM_BondArray_append(OpenMM_BondArray* array, int particle1, int particle2) { 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)); reinterpret_cast&lt;vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array)->push_back(pair&lt;int, int&gt;(particle1, particle2));
} }
void OpenMM_BondArray_set(OpenMM_BondArray* array, int index, int particle1, int 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); (*reinterpret_cast&lt;vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array))[index] = pair&lt;int, int&gt;(particle1, particle2);
} }
void OpenMM_BondArray_get(const OpenMM_BondArray* array, int index, int* particle1, int* 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]; pair&lt;int, int&gt; particles = (*reinterpret_cast&lt;const vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array))[index];
*particle1 = particles.first; *particle1 = particles.first;
*particle2 = particles.second; *particle2 = particles.second;
} }
/* OpenMM_ParameterArray */ /* OpenMM_ParameterArray */
int OpenMM_ParameterArray_getSize(const OpenMM_ParameterArray* array) { OPENMM_EXPORT int OpenMM_ParameterArray_getSize(const OpenMM_ParameterArray* array) {
return reinterpret_cast&lt;const map&lt;string, double&gt;*&gt;(array)->size(); return reinterpret_cast&lt;const map&lt;string, double&gt;*&gt;(array)->size();
} }
double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* array, const char* name) { 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;* 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)); const map&lt;string, double&gt;::const_iterator iter = params->find(string(name));
if (iter == params->end()) if (iter == params->end())
...@@ -139,11 +137,11 @@ double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* array, const char* ...@@ -139,11 +137,11 @@ double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* array, const char*
/* These methods need to be handled specially, since their C++ APIs cannot be directly translated to C. /* 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. */ Unlike the C++ versions, the return value is allocated on the heap, and you must delete it yourself. */
OpenMM_State* OpenMM_Context_getState(const OpenMM_Context* target, int types) { OPENMM_EXPORT OpenMM_State* OpenMM_Context_getState(const OpenMM_Context* target, int types) {
State result = reinterpret_cast&lt;const Context*&gt;(target)->getState(types); State result = reinterpret_cast&lt;const Context*&gt;(target)->getState(types);
return reinterpret_cast&lt;OpenMM_State*&gt;(new State(result)); return reinterpret_cast&lt;OpenMM_State*&gt;(new State(result));
}; };
OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directory) { OPENMM_EXPORT OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directory) {
vector&lt;string&gt; result = Platform::loadPluginsFromDirectory(string(directory)); vector&lt;string&gt; result = Platform::loadPluginsFromDirectory(string(directory));
return reinterpret_cast&lt;OpenMM_StringArray*&gt;(new vector&lt;string&gt;(result)); return reinterpret_cast&lt;OpenMM_StringArray*&gt;(new vector&lt;string&gt;(result));
}; };
...@@ -153,9 +151,7 @@ OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directo ...@@ -153,9 +151,7 @@ OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directo
<xsl:call-template name="class"/> <xsl:call-template name="class"/>
</xsl:for-each> </xsl:for-each>
#if defined(__cplusplus)
} }
#endif
</xsl:template> </xsl:template>
<!-- Print out the definitions for a (Primitive)Array type --> <!-- Print out the definitions for a (Primitive)Array type -->
...@@ -163,25 +159,25 @@ OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directo ...@@ -163,25 +159,25 @@ OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directo
<xsl:param name="element_type"/> <xsl:param name="element_type"/>
<xsl:param name="name"/> <xsl:param name="name"/>
/* <xsl:value-of select="$name"/> */ /* <xsl:value-of select="$name"/> */
<xsl:value-of select="$name"/>* <xsl:value-of select="$name"/>_create(int size) { 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)); return reinterpret_cast&lt;<xsl:value-of select="$name"/>*&gt;(new vector&lt;<xsl:value-of select="$element_type"/>&gt;(size));
} }
void <xsl:value-of select="$name"/>_destroy(<xsl:value-of select="$name"/>* array) { 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); delete reinterpret_cast&lt;vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array);
} }
int <xsl:value-of select="$name"/>_getSize(const <xsl:value-of select="$name"/>* 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(); return reinterpret_cast&lt;const vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array)->size();
} }
void <xsl:value-of select="$name"/>_resize(<xsl:value-of select="$name"/>* array, int 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); reinterpret_cast&lt;vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array)->resize(size);
} }
void <xsl:value-of select="$name"/>_append(<xsl:value-of select="$name"/>* array, <xsl:value-of select="$element_type"/> value) { 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); reinterpret_cast&lt;vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array)->push_back(value);
} }
void <xsl:value-of select="$name"/>_set(<xsl:value-of select="$name"/>* array, int index, <xsl:value-of select="$element_type"/> 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; (*reinterpret_cast&lt;vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array))[index] = value;
} }
double <xsl:value-of select="$name"/>_get(const <xsl:value-of select="$name"/>* array, int index) { OPENMM_EXPORT double <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]; return (*reinterpret_cast&lt;const vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array))[index];
} }
</xsl:template> </xsl:template>
...@@ -201,7 +197,7 @@ double <xsl:value-of select="$name"/>_get(const <xsl:value-of select="$name"/>* ...@@ -201,7 +197,7 @@ double <xsl:value-of select="$name"/>_get(const <xsl:value-of select="$name"/>*
</xsl:call-template> </xsl:call-template>
</xsl:for-each> </xsl:for-each>
</xsl:if> </xsl:if>
void OpenMM_<xsl:value-of select="concat(@name, '_destroy(OpenMM_', @name, '* target) {')"/> 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); delete reinterpret_cast&lt;<xsl:value-of select="@name"/>*&gt;(target);
} }
<!-- Methods --> <!-- Methods -->
...@@ -226,7 +222,7 @@ void OpenMM_<xsl:value-of select="concat(@name, '_destroy(OpenMM_', @name, '* ta ...@@ -226,7 +222,7 @@ void OpenMM_<xsl:value-of select="concat(@name, '_destroy(OpenMM_', @name, '* ta
<!-- Print out the definition of a constructor --> <!-- Print out the definition of a constructor -->
<xsl:template name="constructor"> <xsl:template name="constructor">
<xsl:param name="suffix"/> <xsl:param name="suffix"/>
OpenMM_<xsl:value-of select="concat(@name, '* OpenMM_', @name, '_create', $suffix, '(')"/> OPENMM_EXPORT OpenMM_<xsl:value-of select="concat(@name, '* OpenMM_', @name, '_create', $suffix, '(')"/>
<xsl:for-each select="Argument"> <xsl:for-each select="Argument">
<xsl:if test="position() > 1">, </xsl:if> <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:call-template name="wrap_type"><xsl:with-param name="type_id" select="@type"/></xsl:call-template>
...@@ -251,7 +247,7 @@ OpenMM_<xsl:value-of select="concat(@name, '* OpenMM_', @name, '_create', $suffi ...@@ -251,7 +247,7 @@ OpenMM_<xsl:value-of select="concat(@name, '* OpenMM_', @name, '_create', $suffi
<xsl:param name="class_id"/> <xsl:param name="class_id"/>
<!-- First the method signature --> <!-- First the method signature -->
<xsl:value-of select="$newline"/> <xsl:value-of select="$newline"/>
<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, '(')"/> 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="not(@static='1')">
<xsl:if test="@const='1'"> <xsl:if test="@const='1'">
<xsl:value-of select="'const '"/> <xsl:value-of select="'const '"/>
......
This diff is collapsed.
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