"platforms/brook/src/BrookIntStreamImpl.h" did not exist on "45ed59f8fec3909475deca7196f590246cdf15a9"
Commit 6d356ddc authored by peastman's avatar peastman
Browse files

Merge pull request #277 from peastman/winvec

Fixed lots of compilation errors on Windows
parents a4f7ac48 72e81e04
......@@ -32,7 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/internal/windowsExportAmoebaSerialization.h"
#include "openmm/internal/windowsExportAmoeba.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
......@@ -41,7 +41,7 @@ namespace OpenMM {
* This is a proxy for serializing AmoebaGeneralizedKirkwoodForce objects.
*/
class OPENMM_EXPORT_AMOEBA_SERIALIZATION AmoebaGeneralizedKirkwoodForceProxy : public SerializationProxy {
class OPENMM_EXPORT_AMOEBA AmoebaGeneralizedKirkwoodForceProxy : public SerializationProxy {
public:
AmoebaGeneralizedKirkwoodForceProxy();
void serialize(const void* object, SerializationNode& node) const;
......
......@@ -32,7 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/internal/windowsExportAmoebaSerialization.h"
#include "openmm/internal/windowsExportAmoeba.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
......@@ -41,7 +41,7 @@ namespace OpenMM {
* This is a proxy for serializing AmoebaInPlaneAngleForce objects.
*/
class OPENMM_EXPORT_AMOEBA_SERIALIZATION AmoebaInPlaneAngleForceProxy : public SerializationProxy {
class OPENMM_EXPORT_AMOEBA AmoebaInPlaneAngleForceProxy : public SerializationProxy {
public:
AmoebaInPlaneAngleForceProxy();
void serialize(const void* object, SerializationNode& node) const;
......
......@@ -32,7 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/internal/windowsExportAmoebaSerialization.h"
#include "openmm/internal/windowsExportAmoeba.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
......@@ -41,7 +41,7 @@ namespace OpenMM {
* This is a proxy for serializing AmoebaMultipoleForce objects.
*/
class OPENMM_EXPORT_AMOEBA_SERIALIZATION AmoebaMultipoleForceProxy : public SerializationProxy {
class OPENMM_EXPORT_AMOEBA AmoebaMultipoleForceProxy : public SerializationProxy {
public:
AmoebaMultipoleForceProxy();
void serialize(const void* object, SerializationNode& node) const;
......
......@@ -32,7 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/internal/windowsExportAmoebaSerialization.h"
#include "openmm/internal/windowsExportAmoeba.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
......@@ -41,7 +41,7 @@ namespace OpenMM {
* This is a proxy for serializing AmoebaOutOfPlaneBendForce objects.
*/
class OPENMM_EXPORT_AMOEBA_SERIALIZATION AmoebaOutOfPlaneBendForceProxy : public SerializationProxy {
class OPENMM_EXPORT_AMOEBA AmoebaOutOfPlaneBendForceProxy : public SerializationProxy {
public:
AmoebaOutOfPlaneBendForceProxy();
void serialize(const void* object, SerializationNode& node) const;
......
......@@ -32,7 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/internal/windowsExportAmoebaSerialization.h"
#include "openmm/internal/windowsExportAmoeba.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
......@@ -41,7 +41,7 @@ namespace OpenMM {
* This is a proxy for serializing AmoebaPiTorsionForce objects.
*/
class OPENMM_EXPORT_AMOEBA_SERIALIZATION AmoebaPiTorsionForceProxy : public SerializationProxy {
class OPENMM_EXPORT_AMOEBA AmoebaPiTorsionForceProxy : public SerializationProxy {
public:
AmoebaPiTorsionForceProxy();
void serialize(const void* object, SerializationNode& node) const;
......
......@@ -32,7 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/internal/windowsExportAmoebaSerialization.h"
#include "openmm/internal/windowsExportAmoeba.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
......@@ -41,7 +41,7 @@ namespace OpenMM {
* This is a proxy for serializing AmoebaStretchBendForce objects.
*/
class OPENMM_EXPORT_AMOEBA_SERIALIZATION AmoebaStretchBendForceProxy : public SerializationProxy {
class OPENMM_EXPORT_AMOEBA AmoebaStretchBendForceProxy : public SerializationProxy {
public:
AmoebaStretchBendForceProxy();
void serialize(const void* object, SerializationNode& node) const;
......
......@@ -32,7 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/internal/windowsExportAmoebaSerialization.h"
#include "openmm/internal/windowsExportAmoeba.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
......@@ -41,7 +41,7 @@ namespace OpenMM {
* This is a proxy for serializing AmoebaTorsionTorsionForce objects.
*/
class OPENMM_EXPORT_AMOEBA_SERIALIZATION AmoebaTorsionTorsionForceProxy : public SerializationProxy {
class OPENMM_EXPORT_AMOEBA AmoebaTorsionTorsionForceProxy : public SerializationProxy {
public:
AmoebaTorsionTorsionForceProxy();
void serialize(const void* object, SerializationNode& node) const;
......
......@@ -32,7 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/internal/windowsExportAmoebaSerialization.h"
#include "openmm/internal/windowsExportAmoeba.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
......@@ -41,7 +41,7 @@ namespace OpenMM {
* This is a proxy for serializing AmoebaVdwForce objects.
*/
class OPENMM_EXPORT_AMOEBA_SERIALIZATION AmoebaVdwForceProxy : public SerializationProxy {
class OPENMM_EXPORT_AMOEBA AmoebaVdwForceProxy : public SerializationProxy {
public:
AmoebaVdwForceProxy();
void serialize(const void* object, SerializationNode& node) const;
......
......@@ -32,7 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/internal/windowsExportAmoebaSerialization.h"
#include "openmm/internal/windowsExportAmoeba.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
......@@ -41,7 +41,7 @@ namespace OpenMM {
* This is a proxy for serializing AmoebaWcaDispersionForce objects.
*/
class OPENMM_EXPORT_AMOEBA_SERIALIZATION AmoebaWcaDispersionForceProxy : public SerializationProxy {
class OPENMM_EXPORT_AMOEBA AmoebaWcaDispersionForceProxy : public SerializationProxy {
public:
AmoebaWcaDispersionForceProxy();
void serialize(const void* object, SerializationNode& node) const;
......
#ifndef OPENMM_WINDOWSEXPORTAMOEBASERIALIZATION_H_
#define OPENMM_WINDOWSEXPORTAMOEBASERIALIZATION_H_
/*
* Shared libraries are messy in Visual Studio. We have to distinguish three
* cases:
* (1) this header is being used to build the OpenMM shared library
* (dllexport)
* (2) this header is being used by a *client* of the OpenMM shared
* library (dllimport)
* (3) we are building the OpenMM static library, or the client is
* being compiled with the expectation of linking with the
* OpenMM static library (nothing special needed)
* In the CMake script for building this library, we define one of the symbols
* OPENMM_AMOEBA_SERIALIZATION_BUILDING_{SHARED|STATIC}_LIBRARY
* Client code normally has no special symbol defined, in which case we'll
* assume it wants to use the shared library. However, if the client defines
* the symbol OPENMM_USE_STATIC_LIBRARIES we'll suppress the dllimport so
* that the client code can be linked with static libraries. Note that
* the client symbol is not library dependent, while the library symbols
* affect only the OpenMM library, meaning that other libraries can
* be clients of this one. However, we are assuming all-static or all-shared.
*/
#ifdef _MSC_VER
// We don't want to hear about how sprintf is "unsafe".
#pragma warning(disable:4996)
// Keep MS VC++ quiet about lack of dll export of private members.
#pragma warning(disable:4251)
#if defined(OPENMM_AMOEBA_SERIALIZATION_BUILDING_SHARED_LIBRARY)
#define OPENMM_EXPORT_AMOEBA_SERIALIZATION __declspec(dllexport)
#elif defined(OPENMM_AMOEBA_SERIALIZATION_BUILDING_STATIC_LIBRARY) || defined(OPENMM_AMOEBA_SERIALIZATION_USE_STATIC_LIBRARIES)
#define OPENMM_EXPORT_AMOEBA_SERIALIZATION
#else
#define OPENMM_EXPORT_AMOEBA_SERIALIZATION __declspec(dllimport) // i.e., a client of a shared library
#endif
#else
#define OPENMM_EXPORT_AMOEBA_SERIALIZATION // Linux, Mac
#endif
#endif // OPENMM_WINDOWSEXPORTAMOEBASERIALIZATION_H_
......@@ -65,11 +65,10 @@
#include "openmm/serialization/AmoebaTorsionTorsionForceProxy.h"
#include "openmm/serialization/AmoebaVdwForceProxy.h"
#include "openmm/serialization/AmoebaWcaDispersionForceProxy.h"
#include "openmm/serialization/internal/windowsExportAmoebaSerialization.h"
#if defined(WIN32)
#include <windows.h>
extern "C" OPENMM_EXPORT_AMOEBA_SERIALIZATION void registerAmoebaSerializationProxies();
extern "C" OPENMM_EXPORT_AMOEBA void registerAmoebaSerializationProxies();
BOOL WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
registerAmoebaSerializationProxies();
......@@ -81,7 +80,7 @@
using namespace OpenMM;
extern "C" OPENMM_EXPORT_AMOEBA_SERIALIZATION void registerAmoebaSerializationProxies() {
extern "C" OPENMM_EXPORT_AMOEBA void registerAmoebaSerializationProxies() {
SerializationProxy::registerProxy(typeid(AmoebaGeneralizedKirkwoodForce), new AmoebaGeneralizedKirkwoodForceProxy());
SerializationProxy::registerProxy(typeid(AmoebaBondForce), new AmoebaBondForceProxy());
SerializationProxy::registerProxy(typeid(AmoebaAngleForce), new AmoebaAngleForceProxy());
......
from __future__ import print_function
import sys, os
import time
import getopt
......@@ -305,16 +306,16 @@ class CHeaderGenerator(WrapperGenerator):
return type
def writeOutput(self):
print >>self.out, """
print("""
#ifndef AMOEBA_OPENMM_CWRAPPER_H_
#define AMOEBA_OPENMM_CWRAPPER_H_
#ifndef OPENMM_EXPORT_AMOEBA
#define OPENMM_EXPORT_AMOEBA
#endif"""
#endif""", file=self.out)
self.writeGlobalConstants()
self.writeTypeDeclarations()
print >>self.out, """
print("""
typedef struct OpenMM_2D_IntArray_struct OpenMM_2D_IntArray;
typedef struct OpenMM_3D_DoubleArray_struct OpenMM_3D_DoubleArray;
......@@ -325,16 +326,16 @@ extern "C" {
/* OpenMM_3D_DoubleArray */
OPENMM_EXPORT_AMOEBA OpenMM_3D_DoubleArray* OpenMM_3D_DoubleArray_create(int size1, int size2, int size3);
OPENMM_EXPORT_AMOEBA void OpenMM_3D_DoubleArray_set(OpenMM_3D_DoubleArray* array, int index1, int index2, OpenMM_DoubleArray* values);
OPENMM_EXPORT_AMOEBA void OpenMM_3D_DoubleArray_destroy( OpenMM_3D_DoubleArray* array);"""
OPENMM_EXPORT_AMOEBA void OpenMM_3D_DoubleArray_destroy( OpenMM_3D_DoubleArray* array);""", file=self.out)
self.writeClasses()
print >>self.out, """
print("""
#if defined(__cplusplus)
}
#endif
#endif /*AMOEBA_OPENMM_CWRAPPER_H_*/"""
#endif /*AMOEBA_OPENMM_CWRAPPER_H_*/""", file=self.out)
class CSourceGenerator(WrapperGenerator):
......@@ -556,7 +557,7 @@ class CSourceGenerator(WrapperGenerator):
return 'reinterpret_cast<%s>(%s)' % (type, value)
def writeOutput(self):
print >>self.out, """
print("""
#include "OpenMM.h"
#include "OpenMMAmoeba.h"
#include "../../../wrappers/OpenMMCWrapper.h"
......@@ -634,10 +635,10 @@ OPENMM_EXPORT_AMOEBA void OpenMM_3D_DoubleArray_set(OpenMM_3D_DoubleArray* array
OPENMM_EXPORT_AMOEBA void OpenMM_3D_DoubleArray_destroy( OpenMM_3D_DoubleArray* array) {
delete reinterpret_cast<std::vector<std::vector<std::vector<double> > >*>(array);
}"""
}""", file=self.out)
self.writeClasses()
print >>self.out, "}\n"
print("}\n", file=self.out)
class FortranHeaderGenerator(WrapperGenerator):
"""This class generates the header file for the Fortran API wrappers."""
......@@ -845,33 +846,33 @@ class FortranHeaderGenerator(WrapperGenerator):
return type
def writeOutput(self):
print >>self.out, """
print("""
MODULE OpenMM_Types
implicit none
"""
""", file=self.out)
self.writeGlobalConstants()
self.writeTypeDeclarations()
print >>self.out, """
print("""
! Enumerations
integer*4, parameter :: OpenMM_False = 0
integer*4, parameter :: OpenMM_True = 1"""
integer*4, parameter :: OpenMM_True = 1""", file=self.out)
for classNode in self._orderedClassNodes:
self.writeEnumerations(classNode)
print >>self.out, """
print("""
END MODULE OpenMM_Types
MODULE OpenMM
use OpenMM_Types; implicit none
interface
"""
""", file=self.out)
self.writeClasses()
print >>self.out, """
print("""
end interface
END MODULE OpenMM"""
END MODULE OpenMM""", file=self.out)
class FortranSourceGenerator(WrapperGenerator):
......@@ -974,7 +975,7 @@ class FortranSourceGenerator(WrapperGenerator):
if methodName in (shortClassName, destructorName):
continue
if '~' in methodName:
print '***', methodName, destructorName
print('***', methodName, destructorName)
if self.shouldHideMethod(methodNode):
continue
isConstMethod = (methodNode.attrib['const'] == 'yes')
......@@ -1143,7 +1144,7 @@ class FortranSourceGenerator(WrapperGenerator):
return False
def writeOutput(self):
print >>self.out, """
print("""
#include "OpenMM.h"
#include "OpenMMAmoeba.h"
#include "../../../wrappers/OpenMMCWrapper.h"
......@@ -1171,10 +1172,10 @@ static string makeString(const char* fsrc, int length) {
}
extern "C" {
"""
""", file=self.out)
self.writeClasses()
print >>self.out, "}"
print("}", file=self.out)
inputDirname = sys.argv[1]
builder = CHeaderGenerator(inputDirname, open(os.path.join(sys.argv[2], 'AmoebaOpenMMCWrapper.h'), 'w'))
......
......@@ -32,8 +32,8 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/internal/windowsExportDrudeSerialization.h"
#include "openmm/serialization/SerializationProxy.h"
#include "openmm/internal/windowsExportDrude.h"
namespace OpenMM {
......@@ -41,7 +41,7 @@ namespace OpenMM {
* This is a proxy for serializing DrudeForce objects.
*/
class OPENMM_EXPORT_DRUDE_SERIALIZATION DrudeForceProxy : public SerializationProxy {
class OPENMM_EXPORT_DRUDE DrudeForceProxy : public SerializationProxy {
public:
DrudeForceProxy();
void serialize(const void* object, SerializationNode& node) const;
......
......@@ -32,8 +32,8 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/internal/windowsExportDrudeSerialization.h"
#include "openmm/serialization/SerializationProxy.h"
#include "openmm/internal/windowsExportDrude.h"
namespace OpenMM {
......@@ -41,7 +41,7 @@ namespace OpenMM {
* This is a proxy for serializing DrudeLangevinIntegrator objects.
*/
class OPENMM_EXPORT_DRUDE_SERIALIZATION DrudeLangevinIntegratorProxy : public SerializationProxy {
class OPENMM_EXPORT_DRUDE DrudeLangevinIntegratorProxy : public SerializationProxy {
public:
DrudeLangevinIntegratorProxy();
void serialize(const void* object, SerializationNode& node) const;
......
#ifndef OPENMM_WINDOWSEXPORTDRUDESERIALIZATION_H_
#define OPENMM_WINDOWSEXPORTDRUDESERIALIZATION_H_
/*
* Shared libraries are messy in Visual Studio. We have to distinguish three
* cases:
* (1) this header is being used to build the OpenMM shared library
* (dllexport)
* (2) this header is being used by a *client* of the OpenMM shared
* library (dllimport)
* (3) we are building the OpenMM static library, or the client is
* being compiled with the expectation of linking with the
* OpenMM static library (nothing special needed)
* In the CMake script for building this library, we define one of the symbols
* OPENMM_DRUDE_SERIALIZATION_BUILDING_{SHARED|STATIC}_LIBRARY
* Client code normally has no special symbol defined, in which case we'll
* assume it wants to use the shared library. However, if the client defines
* the symbol OPENMM_USE_STATIC_LIBRARIES we'll suppress the dllimport so
* that the client code can be linked with static libraries. Note that
* the client symbol is not library dependent, while the library symbols
* affect only the OpenMM library, meaning that other libraries can
* be clients of this one. However, we are assuming all-static or all-shared.
*/
#ifdef _MSC_VER
// We don't want to hear about how sprintf is "unsafe".
#pragma warning(disable:4996)
// Keep MS VC++ quiet about lack of dll export of private members.
#pragma warning(disable:4251)
#if defined(OPENMM_DRUDE_SERIALIZATION_BUILDING_SHARED_LIBRARY)
#define OPENMM_EXPORT_DRUDE_SERIALIZATION __declspec(dllexport)
#elif defined(OPENMM_DRUDE_SERIALIZATION_BUILDING_STATIC_LIBRARY) || defined(OPENMM_DRUDE_SERIALIZATION_USE_STATIC_LIBRARIES)
#define OPENMM_EXPORT_DRUDE_SERIALIZATION
#else
#define OPENMM_EXPORT_DRUDE_SERIALIZATION __declspec(dllimport) // i.e., a client of a shared library
#endif
#else
#define OPENMM_EXPORT_DRUDE_SERIALIZATION // Linux, Mac
#endif
#endif // OPENMM_WINDOWSEXPORTDRUDESERIALIZATION_H_
......@@ -47,11 +47,10 @@
#include "openmm/serialization/DrudeForceProxy.h"
#include "openmm/serialization/DrudeLangevinIntegratorProxy.h"
#include "openmm/serialization/internal/windowsExportDrudeSerialization.h"
#if defined(WIN32)
#include <windows.h>
extern "C" OPENMM_EXPORT_DRUDE_SERIALIZATION void registerDrudeSerializationProxies();
extern "C" OPENMM_EXPORT_DRUDE void registerDrudeSerializationProxies();
BOOL WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
registerDrudeSerializationProxies();
......@@ -63,7 +62,7 @@
using namespace OpenMM;
extern "C" OPENMM_EXPORT_DRUDE_SERIALIZATION void registerDrudeSerializationProxies() {
extern "C" OPENMM_EXPORT_DRUDE void registerDrudeSerializationProxies() {
SerializationProxy::registerProxy(typeid(DrudeForce), new DrudeForceProxy());
SerializationProxy::registerProxy(typeid(DrudeLangevinIntegrator), new DrudeLangevinIntegratorProxy());
}
from __future__ import print_function
import sys, os
import time
import getopt
......@@ -303,17 +304,17 @@ class CHeaderGenerator(WrapperGenerator):
return type
def writeOutput(self):
print >>self.out, """
print("""
#ifndef OPENMM_CWRAPPER_H_
#define OPENMM_CWRAPPER_H_
#ifndef OPENMM_EXPORT
#define OPENMM_EXPORT
#endif
"""
""", file=self.out)
self.writeGlobalConstants()
self.writeTypeDeclarations()
print >>self.out, """
print("""
typedef struct OpenMM_Vec3Array_struct OpenMM_Vec3Array;
typedef struct OpenMM_StringArray_struct OpenMM_StringArray;
typedef struct OpenMM_BondArray_struct OpenMM_BondArray;
......@@ -366,12 +367,12 @@ extern OPENMM_EXPORT double OpenMM_ParameterArray_get(const OpenMM_ParameterArra
/* 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);"""
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 >>self.out, """
print("""
/* %(name)s */
extern OPENMM_EXPORT %(name)s* %(name)s_create(int size);
extern OPENMM_EXPORT void %(name)s_destroy(%(name)s* array);
......@@ -379,19 +380,19 @@ 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
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 >>self.out, """
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
extern OPENMM_EXPORT void %(name)s_insert(%(name)s* set, %(type)s value);""" % values, file=self.out)
print >>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);
......@@ -401,16 +402,16 @@ extern OPENMM_EXPORT char* OpenMM_XmlSerializer_serializeState(const OpenMM_Stat
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);"""
extern OPENMM_EXPORT OpenMM_Integrator* OpenMM_XmlSerializer_deserializeIntegrator(const char* xml);""", file=self.out)
self.writeClasses()
print >>self.out, """
print("""
#if defined(__cplusplus)
}
#endif
#endif /*OPENMM_CWRAPPER_H_*/"""
#endif /*OPENMM_CWRAPPER_H_*/""", file=self.out)
class CSourceGenerator(WrapperGenerator):
......@@ -630,7 +631,7 @@ class CSourceGenerator(WrapperGenerator):
return 'reinterpret_cast<%s>(%s)' % (type, value)
def writeOutput(self):
print >>self.out, """
print("""
#include "OpenMM.h"
#include "OpenMMCWrapper.h"
#include <cstdlib>
......@@ -742,12 +743,12 @@ OPENMM_EXPORT const char* OpenMM_PropertyArray_get(const OpenMM_PropertyArray* a
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 >>self.out, """
print("""
/* %(name)s */
OPENMM_EXPORT %(name)s* %(name)s_create(int size) {
return reinterpret_cast<%(name)s*>(new vector<%(type)s>(size));
......@@ -769,12 +770,12 @@ OPENMM_EXPORT void %(name)s_set(%(name)s* array, int index, %(type)s value) {
}
OPENMM_EXPORT %(type)s %(name)s_get(const %(name)s* array, int index) {
return (*reinterpret_cast<const vector<%(type)s>*>(array))[index];
}""" % values
}""" % values, file=self.out)
for type in ('int',):
name = 'OpenMM_%sSet' % type.capitalize()
values = {'type':type, 'name':name}
print >>self.out, """
print("""
/* %(name)s */
OPENMM_EXPORT %(name)s* %(name)s_create() {
return reinterpret_cast<%(name)s*>(new set<%(type)s>());
......@@ -787,9 +788,9 @@ OPENMM_EXPORT int %(name)s_getSize(const %(name)s* s) {
}
OPENMM_EXPORT void %(name)s_insert(%(name)s* s, %(type)s value) {
reinterpret_cast<set<%(type)s>*>(s)->insert(value);
}""" % values
}""" % values, file=self.out)
print >>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) {
......@@ -836,9 +837,9 @@ OPENMM_EXPORT OpenMM_Integrator* OpenMM_XmlSerializer_deserializeIntegrator(cons
string input(xml);
stringstream stream(input);
return reinterpret_cast<OpenMM_Integrator*>(OpenMM::XmlSerializer::deserialize<OpenMM::Integrator>(stream));
}"""
}""", file=self.out)
self.writeClasses()
print >>self.out, "}\n"
print("}\n", file=self.out)
class FortranHeaderGenerator(WrapperGenerator):
"""This class generates the header file for the Fortran API wrappers."""
......@@ -1049,13 +1050,13 @@ class FortranHeaderGenerator(WrapperGenerator):
return type
def writeOutput(self):
print >>self.out, """
print("""
MODULE OpenMM_Types
implicit none
"""
""", file=self.out)
self.writeGlobalConstants()
self.writeTypeDeclarations()
print >>self.out, """
print("""
type OpenMM_Vec3Array
integer*8 :: handle = 0
end type
......@@ -1091,10 +1092,10 @@ MODULE OpenMM_Types
! Enumerations
integer*4, parameter :: OpenMM_False = 0
integer*4, parameter :: OpenMM_True = 1"""
integer*4, parameter :: OpenMM_True = 1""", file=self.out)
for classNode in self._orderedClassNodes:
self.writeEnumerations(classNode)
print >>self.out, """
print("""
END MODULE OpenMM_Types
MODULE OpenMM
......@@ -1250,12 +1251,12 @@ MODULE OpenMM
type (OpenMM_PropertyArray) target
character(*) name
character(*) result
end subroutine"""
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 >>self.out, """
print("""
! %(name)s
subroutine %(name)s_create(result, size)
use OpenMM_Types; implicit none
......@@ -1292,9 +1293,9 @@ MODULE OpenMM
type (%(name)s) target
integer*4 index
%(type)s result
end subroutine""" % values
end subroutine""" % values, file=self.out)
print >>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)
......@@ -1341,11 +1342,11 @@ MODULE OpenMM
use OpenMM_Types; implicit none
character(*) xml
type(OpenMM_Integrator) result
end subroutine"""
end subroutine""", file=self.out)
self.writeClasses()
print >>self.out, """
print("""
end interface
contains
......@@ -1404,7 +1405,7 @@ contains
end do
end subroutine
END MODULE OpenMM"""
END MODULE OpenMM""", file=self.out)
class FortranSourceGenerator(WrapperGenerator):
......@@ -1505,7 +1506,7 @@ class FortranSourceGenerator(WrapperGenerator):
if methodName in (shortClassName, destructorName):
continue
if '~' in methodName:
print '***', methodName, destructorName
print('***', methodName, destructorName)
if self.shouldHideMethod(methodNode):
continue
isConstMethod = (methodNode.attrib['const'] == 'yes')
......@@ -1674,7 +1675,7 @@ class FortranSourceGenerator(WrapperGenerator):
return False
def writeOutput(self):
print >>self.out, """
print("""
#include "OpenMM.h"
#include "OpenMMCWrapper.h"
#include <cstring>
......@@ -1883,12 +1884,12 @@ OPENMM_EXPORT const char* openmm_propertyarray_get_(const OpenMM_PropertyArray*
}
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 >>self.out, """
print("""
/* %(name)s */
OPENMM_EXPORT void %(name_lower)s_create_(%(name)s*& result, const int& size) {
result = %(name)s_create(size);
......@@ -1933,12 +1934,12 @@ OPENMM_EXPORT void %(name_lower)s_get_(const %(name)s* const& array, const int&
}
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
}""" % 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 >>self.out, """
print("""
/* %(name)s */
OPENMM_EXPORT void %(name_lower)s_create_(%(name)s*& result) {
result = %(name)s_create();
......@@ -1965,9 +1966,9 @@ OPENMM_EXPORT void %(name_lower)s_insert_(%(name)s* const& array, const %(type)s
}
OPENMM_EXPORT void %(name_upper)s_INSERT(%(name)s* const& array, const %(type)s& value) {
%(name)s_insert(array, value);
}""" % values
}""" % values, file=self.out)
print >>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) {
......@@ -2017,10 +2018,10 @@ OPENMM_EXPORT void openmm_xmlserializer_deserializeintegrator_(const char* xml,
}
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 >>self.out, "}"
print("}", file=self.out)
inputDirname = sys.argv[1]
builder = CHeaderGenerator(inputDirname, open(os.path.join(sys.argv[2], 'OpenMMCWrapper.h'), 'w'))
......
......@@ -600,7 +600,7 @@ RECURSIVE = YES
# 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 =
EXCLUDE = *Impl.h
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
# directories that are symbolic links (a Unix filesystem feature) are excluded
......
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