Commit 15a92011 authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed errors in API wrapper generation

parent 803b8678
...@@ -353,7 +353,7 @@ public: ...@@ -353,7 +353,7 @@ public:
* value is being calculated, and "2" to indicate the particle it is interacting with. * value is being calculated, and "2" to indicate the particle it is interacting with.
* @param type the method to use for computing this value * @param type the method to use for computing this value
*/ */
void getComputedValueParameters(int index, std::string& name, std::string& expression, ComputationType& type) const; void getComputedValueParameters(int index, std::string& name, std::string& expression, ComputationType type) const;
/** /**
* Set the properties of a computed value. * Set the properties of a computed value.
* *
...@@ -404,7 +404,7 @@ public: ...@@ -404,7 +404,7 @@ public:
* in the pair and "2" to indicate the second particle in the pair. * in the pair and "2" to indicate the second particle in the pair.
* @param type the method to use for computing this value * @param type the method to use for computing this value
*/ */
void getEnergyTermParameters(int index, std::string& expression, ComputationType& type) const; void getEnergyTermParameters(int index, std::string& expression, ComputationType type) const;
/** /**
* Set the properties of a term to the energy computation. * Set the properties of a term to the energy computation.
* *
......
...@@ -117,7 +117,7 @@ int CustomGBForce::addComputedValue(const std::string& name, const std::string& ...@@ -117,7 +117,7 @@ int CustomGBForce::addComputedValue(const std::string& name, const std::string&
return computedValues.size()-1; return computedValues.size()-1;
} }
void CustomGBForce::getComputedValueParameters(int index, std::string& name, std::string& expression, ComputationType& type) const { void CustomGBForce::getComputedValueParameters(int index, std::string& name, std::string& expression, ComputationType type) const {
name = computedValues[index].name; name = computedValues[index].name;
expression = computedValues[index].expression; expression = computedValues[index].expression;
type = computedValues[index].type; type = computedValues[index].type;
...@@ -134,7 +134,7 @@ int CustomGBForce::addEnergyTerm(const std::string& expression, ComputationType ...@@ -134,7 +134,7 @@ int CustomGBForce::addEnergyTerm(const std::string& expression, ComputationType
return energyTerms.size()-1; return energyTerms.size()-1;
} }
void CustomGBForce::getEnergyTermParameters(int index, std::string& expression, ComputationType& type) const { void CustomGBForce::getEnergyTermParameters(int index, std::string& expression, ComputationType type) const {
expression = energyTerms[index].expression; expression = energyTerms[index].expression;
type = energyTerms[index].type; type = energyTerms[index].type;
} }
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
<xsl:variable name="vector_string_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::basic_string')]/@id"/> <xsl:variable name="vector_string_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::basic_string')]/@id"/>
<xsl:variable name="vector_vec3_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;OpenMM::Vec3')]/@id"/> <xsl:variable name="vector_vec3_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;OpenMM::Vec3')]/@id"/>
<xsl:variable name="vector_bond_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::pair&lt;int, int')]/@id"/> <xsl:variable name="vector_bond_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::pair&lt;int, int')]/@id"/>
<xsl:variable name="map_parameter_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string')]/@id"/> <xsl:variable name="map_parameter_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and contains(@name, 'double')]/@id"/>
<xsl:variable name="map_property_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and not(contains(@name, 'double'))]/@id"/>
<xsl:variable name="vector_double_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;double')]/@id"/> <xsl:variable name="vector_double_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;double')]/@id"/>
<!-- Do not generate functions for the following classes --> <!-- Do not generate functions for the following classes -->
...@@ -45,6 +46,7 @@ typedef struct OpenMM_Vec3Array_struct OpenMM_Vec3Array; ...@@ -45,6 +46,7 @@ typedef struct OpenMM_Vec3Array_struct OpenMM_Vec3Array;
typedef struct OpenMM_StringArray_struct OpenMM_StringArray; typedef struct OpenMM_StringArray_struct OpenMM_StringArray;
typedef struct OpenMM_BondArray_struct OpenMM_BondArray; typedef struct OpenMM_BondArray_struct OpenMM_BondArray;
typedef struct OpenMM_ParameterArray_struct OpenMM_ParameterArray; typedef struct OpenMM_ParameterArray_struct OpenMM_ParameterArray;
typedef struct OpenMM_PropertyArray_struct OpenMM_PropertyArray;
typedef struct OpenMM_DoubleArray_struct OpenMM_DoubleArray; typedef struct OpenMM_DoubleArray_struct OpenMM_DoubleArray;
typedef struct {double x, y, z;} OpenMM_Vec3; typedef struct {double x, y, z;} OpenMM_Vec3;
...@@ -87,6 +89,10 @@ extern OPENMM_EXPORT void OpenMM_BondArray_get(const OpenMM_BondArray* array, in ...@@ -87,6 +89,10 @@ extern OPENMM_EXPORT void OpenMM_BondArray_get(const OpenMM_BondArray* array, in
/* OpenMM_ParameterArray */ /* OpenMM_ParameterArray */
extern OPENMM_EXPORT int OpenMM_ParameterArray_getSize(const OpenMM_ParameterArray* array); extern OPENMM_EXPORT int OpenMM_ParameterArray_getSize(const OpenMM_ParameterArray* array);
extern OPENMM_EXPORT double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* array, const char* name); extern OPENMM_EXPORT double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* array, const char* name);
/* OpenMM_PropertyArray */
extern OPENMM_EXPORT int OpenMM_PropertyArray_getSize(const OpenMM_PropertyArray* array);
extern OPENMM_EXPORT const char* OpenMM_PropertyArray_get(const OpenMM_PropertyArray* array, const char* name);
<xsl:call-template name="primitive_array"> <xsl: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'"/>
...@@ -231,6 +237,9 @@ extern OPENMM_EXPORT <xsl:call-template name="wrap_type"><xsl:with-param name="t ...@@ -231,6 +237,9 @@ extern OPENMM_EXPORT <xsl:call-template name="wrap_type"><xsl:with-param name="t
<xsl:when test="$type_id=$map_parameter_type_id"> <xsl:when test="$type_id=$map_parameter_type_id">
<xsl:value-of select="'OpenMM_ParameterArray'"/> <xsl:value-of select="'OpenMM_ParameterArray'"/>
</xsl:when> </xsl:when>
<xsl:when test="$type_id=$map_property_type_id">
<xsl:value-of select="'OpenMM_PropertyArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_double_type_id"> <xsl:when test="$type_id=$vector_double_type_id">
<xsl:value-of select="'OpenMM_DoubleArray'"/> <xsl:value-of select="'OpenMM_DoubleArray'"/>
</xsl:when> </xsl:when>
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
<xsl:variable name="vector_string_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::basic_string')]/@id"/> <xsl:variable name="vector_string_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::basic_string')]/@id"/>
<xsl:variable name="vector_vec3_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;OpenMM::Vec3')]/@id"/> <xsl:variable name="vector_vec3_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;OpenMM::Vec3')]/@id"/>
<xsl:variable name="vector_bond_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::pair&lt;int, int')]/@id"/> <xsl:variable name="vector_bond_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::pair&lt;int, int')]/@id"/>
<xsl:variable name="map_parameter_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string')]/@id"/> <xsl:variable name="map_parameter_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and contains(@name, 'double')]/@id"/>
<xsl:variable name="map_property_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and not(contains(@name, 'double'))]/@id"/>
<xsl:variable name="vector_double_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;double')]/@id"/> <xsl:variable name="vector_double_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;double')]/@id"/>
<xsl:variable name="newline"> <xsl:variable name="newline">
<xsl:text> <xsl:text>
...@@ -130,6 +131,18 @@ OPENMM_EXPORT double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* arra ...@@ -130,6 +131,18 @@ OPENMM_EXPORT double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* arra
throw OpenMMException("OpenMM_ParameterArray_get: No such parameter"); throw OpenMMException("OpenMM_ParameterArray_get: No such parameter");
return iter->second; return iter->second;
} }
/* OpenMM_PropertyArray */
OPENMM_EXPORT int OpenMM_PropertyArray_getSize(const OpenMM_PropertyArray* array) {
return reinterpret_cast&lt;const map&lt;string, double&gt;*&gt;(array)->size();
}
OPENMM_EXPORT const char* OpenMM_PropertyArray_get(const OpenMM_PropertyArray* array, const char* name) {
const map&lt;string, string&gt;* params = reinterpret_cast&lt;const map&lt;string, string&gt;*&gt;(array);
const map&lt;string, string&gt;::const_iterator iter = params->find(string(name));
if (iter == params->end())
throw OpenMMException("OpenMM_PropertyArray_get: No such property");
return iter->second.c_str();
}
<xsl:call-template name="primitive_array"> <xsl: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'"/>
...@@ -328,6 +341,9 @@ OPENMM_EXPORT <xsl:call-template name="wrap_type"><xsl:with-param name="type_id" ...@@ -328,6 +341,9 @@ OPENMM_EXPORT <xsl:call-template name="wrap_type"><xsl:with-param name="type_id"
<xsl:when test="$type_id=$map_parameter_type_id"> <xsl:when test="$type_id=$map_parameter_type_id">
<xsl:value-of select="'OpenMM_ParameterArray'"/> <xsl:value-of select="'OpenMM_ParameterArray'"/>
</xsl:when> </xsl:when>
<xsl:when test="$type_id=$map_property_type_id">
<xsl:value-of select="'OpenMM_PropertyArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_double_type_id"> <xsl:when test="$type_id=$vector_double_type_id">
<xsl:value-of select="'OpenMM_DoubleArray'"/> <xsl:value-of select="'OpenMM_DoubleArray'"/>
</xsl:when> </xsl:when>
...@@ -375,6 +391,9 @@ OPENMM_EXPORT <xsl:call-template name="wrap_type"><xsl:with-param name="type_id" ...@@ -375,6 +391,9 @@ OPENMM_EXPORT <xsl:call-template name="wrap_type"><xsl:with-param name="type_id"
<xsl:when test="$type_id=$map_parameter_type_id"> <xsl:when test="$type_id=$map_parameter_type_id">
<xsl:value-of select="'map&lt;string, double&gt;'"/> <xsl:value-of select="'map&lt;string, double&gt;'"/>
</xsl:when> </xsl:when>
<xsl:when test="$type_id=$map_property_type_id">
<xsl:value-of select="'map&lt;string, string&gt;'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_double_type_id"> <xsl:when test="$type_id=$vector_double_type_id">
<xsl:value-of select="'vector&lt;double&gt;'"/> <xsl:value-of select="'vector&lt;double&gt;'"/>
</xsl:when> </xsl:when>
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
<xsl:variable name="vector_string_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::basic_string')]/@id"/> <xsl:variable name="vector_string_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::basic_string')]/@id"/>
<xsl:variable name="vector_vec3_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;OpenMM::Vec3')]/@id"/> <xsl:variable name="vector_vec3_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;OpenMM::Vec3')]/@id"/>
<xsl:variable name="vector_bond_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::pair&lt;int, int')]/@id"/> <xsl:variable name="vector_bond_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::pair&lt;int, int')]/@id"/>
<xsl:variable name="map_parameter_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string')]/@id"/> <xsl:variable name="map_parameter_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and contains(@name, 'double')]/@id"/>
<xsl:variable name="map_property_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and not(contains(@name, 'double'))]/@id"/>
<xsl:variable name="vector_double_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;double')]/@id"/> <xsl:variable name="vector_double_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;double')]/@id"/>
<xsl:variable name="newline"> <xsl:variable name="newline">
<xsl:text> <xsl:text>
...@@ -64,6 +65,10 @@ MODULE OpenMM_Types ...@@ -64,6 +65,10 @@ MODULE OpenMM_Types
integer*8 :: handle = 0 integer*8 :: handle = 0
end type end type
type OpenMM_PropertyArray
integer*8 :: handle = 0
end type
type OpenMM_DoubleArray type OpenMM_DoubleArray
integer*8 :: handle = 0 integer*8 :: handle = 0
end type end type
...@@ -226,6 +231,19 @@ MODULE OpenMM ...@@ -226,6 +231,19 @@ MODULE OpenMM
character(*) name character(*) name
character(*) result character(*) result
end end
! OpenMM_PropertyArray
function OpenMM_PropertyArray_getSize(target)
use OpenMM_Types; implicit none
type (OpenMM_ParameterArray) target
integer*4 OpenMM_PropertyArray_getSize
end
subroutine OpenMM_PropertyArray_get(target, name, result)
use OpenMM_Types; implicit none
type (OpenMM_PropertyArray) target
character(*) name
character(*) result
end
<xsl:call-template name="primitive_array"> <xsl:call-template name="primitive_array">
<xsl:with-param name="element_type" select="'real*8'"/> <xsl:with-param name="element_type" select="'real*8'"/>
<xsl:with-param name="name" select="'OpenMM_DoubleArray'"/> <xsl:with-param name="name" select="'OpenMM_DoubleArray'"/>
...@@ -453,6 +471,9 @@ END MODULE OpenMM ...@@ -453,6 +471,9 @@ END MODULE OpenMM
<xsl:when test="$type_id=$map_parameter_type_id"> <xsl:when test="$type_id=$map_parameter_type_id">
<xsl:value-of select="concat('type (OpenMM_ParameterArray) ', $value)"/> <xsl:value-of select="concat('type (OpenMM_ParameterArray) ', $value)"/>
</xsl:when> </xsl:when>
<xsl:when test="$type_id=$map_property_type_id">
<xsl:value-of select="concat('type (OpenMM_PropertyArray) ', $value)"/>
</xsl:when>
<xsl:when test="$type_id=$vector_double_type_id"> <xsl:when test="$type_id=$vector_double_type_id">
<xsl:value-of select="concat('type (OpenMM_DoubleArray) ', $value)"/> <xsl:value-of select="concat('type (OpenMM_DoubleArray) ', $value)"/>
</xsl:when> </xsl:when>
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
<xsl:variable name="vector_string_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::basic_string')]/@id"/> <xsl:variable name="vector_string_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::basic_string')]/@id"/>
<xsl:variable name="vector_vec3_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;OpenMM::Vec3')]/@id"/> <xsl:variable name="vector_vec3_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;OpenMM::Vec3')]/@id"/>
<xsl:variable name="vector_bond_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::pair&lt;int, int')]/@id"/> <xsl:variable name="vector_bond_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::pair&lt;int, int')]/@id"/>
<xsl:variable name="map_parameter_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string')]/@id"/> <xsl:variable name="map_parameter_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and contains(@name, 'double')]/@id"/>
<xsl:variable name="map_property_type_id" select="/GCC_XML/Class[starts-with(@name, 'map&lt;std::basic_string') and not(contains(@name, 'double'))]/@id"/>
<xsl:variable name="vector_double_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;double')]/@id"/> <xsl:variable name="vector_double_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;double')]/@id"/>
<xsl:variable name="newline"> <xsl:variable name="newline">
<xsl:text> <xsl:text>
...@@ -223,6 +224,20 @@ OPENMM_EXPORT double openmm_parameterarray_get_(const OpenMM_ParameterArray* con ...@@ -223,6 +224,20 @@ OPENMM_EXPORT double openmm_parameterarray_get_(const OpenMM_ParameterArray* con
OPENMM_EXPORT double OPENMM_PARAMETERARRAY_GET(const OpenMM_ParameterArray* const&amp; array, const char* name, int length) { OPENMM_EXPORT double OPENMM_PARAMETERARRAY_GET(const OpenMM_ParameterArray* const&amp; array, const char* name, int length) {
return OpenMM_ParameterArray_get(array, makeString(name, length).c_str()); return OpenMM_ParameterArray_get(array, makeString(name, length).c_str());
} }
/* OpenMM_PropertyArray */
OPENMM_EXPORT int openmm_propertyarray_getsize_(const OpenMM_PropertyArray* const&amp; array) {
return OpenMM_PropertyArray_getSize(array);
}
OPENMM_EXPORT int OPENMM_PROPERTYARRAY_GETSIZE(const OpenMM_PropertyArray* const&amp; array) {
return OpenMM_PropertyArray_getSize(array);
}
OPENMM_EXPORT const char* openmm_propertyarray_get_(const OpenMM_PropertyArray* const&amp; array, const char* name, int length) {
return OpenMM_PropertyArray_get(array, makeString(name, length).c_str());
}
OPENMM_EXPORT const char* OPENMM_PROPERTYARRAY_GET(const OpenMM_PropertyArray* const&amp; array, const char* name, int length) {
return OpenMM_PropertyArray_get(array, makeString(name, length).c_str());
}
<xsl:call-template name="primitive_array"> <xsl: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'"/>
...@@ -535,6 +550,9 @@ OPENMM_EXPORT <xsl:if test="$has_return"> ...@@ -535,6 +550,9 @@ OPENMM_EXPORT <xsl:if test="$has_return">
<xsl:when test="$type_id=$map_parameter_type_id"> <xsl:when test="$type_id=$map_parameter_type_id">
<xsl:value-of select="'OpenMM_ParameterArray'"/> <xsl:value-of select="'OpenMM_ParameterArray'"/>
</xsl:when> </xsl:when>
<xsl:when test="$type_id=$map_property_type_id">
<xsl:value-of select="'OpenMM_PropertyArray'"/>
</xsl:when>
<xsl:when test="$type_id=$vector_double_type_id"> <xsl:when test="$type_id=$vector_double_type_id">
<xsl:value-of select="'OpenMM_DoubleArray'"/> <xsl:value-of select="'OpenMM_DoubleArray'"/>
</xsl:when> </xsl:when>
...@@ -574,6 +592,7 @@ OPENMM_EXPORT <xsl:if test="$has_return"> ...@@ -574,6 +592,7 @@ OPENMM_EXPORT <xsl:if test="$has_return">
<xsl:when test="$type_id=$vector_vec3_type_id">1</xsl:when> <xsl:when test="$type_id=$vector_vec3_type_id">1</xsl:when>
<xsl:when test="$type_id=$vector_bond_type_id">1</xsl:when> <xsl:when test="$type_id=$vector_bond_type_id">1</xsl:when>
<xsl:when test="$type_id=$map_parameter_type_id">1</xsl:when> <xsl:when test="$type_id=$map_parameter_type_id">1</xsl:when>
<xsl:when test="$type_id=$map_property_type_id">1</xsl:when>
<xsl:when test="$type_id=$vector_double_type_id">1</xsl:when> <xsl:when test="$type_id=$vector_double_type_id">1</xsl:when>
<xsl:when test="$type_id=$vector_string_type_id">1</xsl:when> <xsl:when test="$type_id=$vector_string_type_id">1</xsl:when>
<xsl:when test="local-name($node)='Class' and $node/@context=$openmm_namespace_id">1</xsl:when> <xsl:when test="local-name($node)='Class' and $node/@context=$openmm_namespace_id">1</xsl:when>
......
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