CWrapper_Source.xslt 23.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text" omit-xml-declaration="yes"/>

<xsl:variable name="std_namespace_id" select="/GCC_XML/Namespace[@name='std']/@id"/>
<xsl:variable name="openmm_namespace_id" select="/GCC_XML/Namespace[@name='OpenMM']/@id"/>
<xsl:variable name="void_type_id" select="/GCC_XML/FundamentalType[@name='void']/@id"/>
<xsl:variable name="bool_type_id" select="/GCC_XML/FundamentalType[@name='bool']/@id"/>
10
<xsl:variable name="double_type_id" select="/GCC_XML/FundamentalType[@name='double']/@id"/>
11
12
13
14
15
16
17
<xsl:variable name="string_type_id" select="/GCC_XML/*[@name='string' and @context=$std_namespace_id]/@id"/>
<xsl:variable name="const_string_type_id" select="/GCC_XML/CvQualifiedType[@type=$string_type_id]/@id"/>
<xsl:variable name="const_ref_string_type_id" select="/GCC_XML/ReferenceType[@type=$const_string_type_id]/@id"/>
<xsl:variable name="vec3_type_id" select="/GCC_XML/Class[@name='Vec3' and @context=$openmm_namespace_id]/@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_bond_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;std::pair&lt;int, int')]/@id"/>
18
19
<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"/>
20
<xsl:variable name="vector_double_type_id" select="/GCC_XML/Class[starts-with(@name, 'vector&lt;double')]/@id"/>
21
22
23
24
25
26
27
28
29
30
31
<xsl:variable name="newline">
<xsl:text>
</xsl:text>
</xsl:variable>


<!-- Do not generate functions for the following classes -->
<xsl:variable name="skip_classes" select="('Vec3', 'Kernel', 'Stream', 'KernelImpl', 'StreamImpl', 'KernelFactory', 'StreamFactory')"/>
<!-- Do not generate the following functions -->
<xsl:variable name="skip_methods" select="('OpenMM_Context_getState', 'OpenMM_Platform_loadPluginsFromDirectory')"/>
<!-- Suppress any function which references any of the following classes -->
32
<xsl:variable name="hide_classes" select="('Kernel', 'Stream', 'KernelImpl', 'StreamImpl', 'KernelFactory', 'StreamFactory', 'ContextImpl')"/>
33
34
35
36

<!-- Main loop over all classes in the OpenMM namespace -->
<xsl:template match="/GCC_XML">
#include "OpenMM.h"
37
#include "OpenMMCWrapper.h"
38
39
40
41
42
43
44
45
46
#include &lt;cstring&gt;
#include &lt;vector&gt;

using namespace OpenMM;
using namespace std;

extern "C" {

/* OpenMM_Vec3 */
47
OPENMM_EXPORT OpenMM_Vec3 OpenMM_Vec3_scale(const OpenMM_Vec3 vec, double scale) {
48
49
50
51
52
    OpenMM_Vec3 result = {vec.x*scale, vec.y*scale, vec.z*scale};
    return result;
}

/* OpenMM_Vec3Array */
53
OPENMM_EXPORT OpenMM_Vec3Array* OpenMM_Vec3Array_create(int size) {
54
55
    return reinterpret_cast&lt;OpenMM_Vec3Array*&gt;(new vector&lt;Vec3&gt;(size));
}
56
OPENMM_EXPORT void OpenMM_Vec3Array_destroy(OpenMM_Vec3Array* array) {
57
58
    delete reinterpret_cast&lt;vector&lt;Vec3&gt;*&gt;(array);
}
59
OPENMM_EXPORT int OpenMM_Vec3Array_getSize(const OpenMM_Vec3Array* array) {
60
61
    return reinterpret_cast&lt;const vector&lt;Vec3&gt;*&gt;(array)->size();
}
62
OPENMM_EXPORT void OpenMM_Vec3Array_resize(OpenMM_Vec3Array* array, int size) {
63
64
    reinterpret_cast&lt;vector&lt;Vec3&gt;*&gt;(array)->resize(size);
}
65
OPENMM_EXPORT void OpenMM_Vec3Array_append(OpenMM_Vec3Array* array, const OpenMM_Vec3 vec) {
66
67
    reinterpret_cast&lt;vector&lt;Vec3&gt;*&gt;(array)->push_back(Vec3(vec.x, vec.y, vec.z));
}
68
OPENMM_EXPORT void OpenMM_Vec3Array_set(OpenMM_Vec3Array* array, int index, const OpenMM_Vec3 vec) {
69
70
    (*reinterpret_cast&lt;vector&lt;Vec3&gt;*&gt;(array))[index] = Vec3(vec.x, vec.y, vec.z);
}
71
OPENMM_EXPORT const OpenMM_Vec3* OpenMM_Vec3Array_get(const OpenMM_Vec3Array* array, int index) {
72
73
74
75
    return reinterpret_cast&lt;const OpenMM_Vec3*&gt;((&amp;(*reinterpret_cast&lt;const vector&lt;Vec3&gt;*&gt;(array))[index]));
}

/* OpenMM_StringArray */
76
OPENMM_EXPORT OpenMM_StringArray* OpenMM_StringArray_create(int size) {
77
78
    return reinterpret_cast&lt;OpenMM_StringArray*&gt;(new vector&lt;string&gt;(size));
}
79
OPENMM_EXPORT void OpenMM_StringArray_destroy(OpenMM_StringArray* array) {
80
81
    delete reinterpret_cast&lt;vector&lt;string&gt;*&gt;(array);
}
82
OPENMM_EXPORT int OpenMM_StringArray_getSize(const OpenMM_StringArray* array) {
83
84
    return reinterpret_cast&lt;const vector&lt;string&gt;*&gt;(array)->size();
}
85
OPENMM_EXPORT void OpenMM_StringArray_resize(OpenMM_StringArray* array, int size) {
86
87
    reinterpret_cast&lt;vector&lt;string&gt;*&gt;(array)->resize(size);
}
88
OPENMM_EXPORT void OpenMM_StringArray_append(OpenMM_StringArray* array, const char* str) {
89
90
    reinterpret_cast&lt;vector&lt;string&gt;*&gt;(array)->push_back(string(str));
}
91
OPENMM_EXPORT void OpenMM_StringArray_set(OpenMM_StringArray* array, int index, const char* str) {
92
93
    (*reinterpret_cast&lt;vector&lt;string&gt;*&gt;(array))[index] = string(str);
}
94
OPENMM_EXPORT const char* OpenMM_StringArray_get(const OpenMM_StringArray* array, int index) {
95
96
97
98
    return (*reinterpret_cast&lt;const vector&lt;string&gt;*&gt;(array))[index].c_str();
}

/* OpenMM_BondArray */
99
OPENMM_EXPORT OpenMM_BondArray* OpenMM_BondArray_create(int size) {
100
101
    return reinterpret_cast&lt;OpenMM_BondArray*&gt;(new vector&lt;pair&lt;int, int&gt; &gt;(size));
}
102
OPENMM_EXPORT void OpenMM_BondArray_destroy(OpenMM_BondArray* array) {
103
104
    delete reinterpret_cast&lt;vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array);
}
105
OPENMM_EXPORT int OpenMM_BondArray_getSize(const OpenMM_BondArray* array) {
106
107
    return reinterpret_cast&lt;const vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array)->size();
}
108
OPENMM_EXPORT void OpenMM_BondArray_resize(OpenMM_BondArray* array, int size) {
109
110
    reinterpret_cast&lt;vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array)->resize(size);
}
111
OPENMM_EXPORT void OpenMM_BondArray_append(OpenMM_BondArray* array, int particle1, int particle2) {
112
113
    reinterpret_cast&lt;vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array)->push_back(pair&lt;int, int&gt;(particle1, particle2));
}
114
OPENMM_EXPORT void OpenMM_BondArray_set(OpenMM_BondArray* array, int index, int particle1, int particle2) {
115
116
    (*reinterpret_cast&lt;vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array))[index] = pair&lt;int, int&gt;(particle1, particle2);
}
117
OPENMM_EXPORT void OpenMM_BondArray_get(const OpenMM_BondArray* array, int index, int* particle1, int* particle2) {
118
119
120
121
122
123
    pair&lt;int, int&gt; particles = (*reinterpret_cast&lt;const vector&lt;pair&lt;int, int&gt; &gt;*&gt;(array))[index];
    *particle1 = particles.first;
    *particle2 = particles.second;
}

/* OpenMM_ParameterArray */
124
OPENMM_EXPORT int OpenMM_ParameterArray_getSize(const OpenMM_ParameterArray* array) {
125
126
    return reinterpret_cast&lt;const map&lt;string, double&gt;*&gt;(array)->size();
}
127
OPENMM_EXPORT double OpenMM_ParameterArray_get(const OpenMM_ParameterArray* array, const char* name) {
128
129
130
131
132
133
    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));
    if (iter == params->end())
        throw OpenMMException("OpenMM_ParameterArray_get: No such parameter");
    return iter->second;
}
134
135
136
137
138
139
140
141
142
143
144
145

/* 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();
}
146
147
148
149
<xsl:call-template name="primitive_array">
 <xsl:with-param name="element_type" select="'double'"/>
 <xsl:with-param name="name" select="'OpenMM_DoubleArray'"/>
</xsl:call-template>
150
151
152

/* 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. */
153
OPENMM_EXPORT OpenMM_State* OpenMM_Context_getState(const OpenMM_Context* target, int types) {
154
155
156
    State result = reinterpret_cast&lt;const Context*&gt;(target)->getState(types);
    return reinterpret_cast&lt;OpenMM_State*&gt;(new State(result));
};
157
OPENMM_EXPORT OpenMM_StringArray* OpenMM_Platform_loadPluginsFromDirectory(const char* directory) {
158
159
160
161
162
163
164
165
166
167
168
169
    vector&lt;string&gt; result = Platform::loadPluginsFromDirectory(string(directory));
    return reinterpret_cast&lt;OpenMM_StringArray*&gt;(new vector&lt;string&gt;(result));
};

 <!-- Class members -->
 <xsl:for-each select="Class[@context=$openmm_namespace_id and empty(index-of($skip_classes, @name))]">
  <xsl:call-template name="class"/>
 </xsl:for-each>
 
}
</xsl:template>

170
171
172
173
174
<!-- Print out the definitions for a (Primitive)Array type -->
<xsl:template name="primitive_array">
 <xsl:param name="element_type"/>
 <xsl:param name="name"/>
/* <xsl:value-of select="$name"/> */
175
OPENMM_EXPORT <xsl:value-of select="$name"/>* <xsl:value-of select="$name"/>_create(int size) {
176
177
    return reinterpret_cast&lt;<xsl:value-of select="$name"/>*&gt;(new vector&lt;<xsl:value-of select="$element_type"/>&gt;(size));
}
178
OPENMM_EXPORT void <xsl:value-of select="$name"/>_destroy(<xsl:value-of select="$name"/>* array) {
179
180
    delete reinterpret_cast&lt;vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array);
}
181
OPENMM_EXPORT int <xsl:value-of select="$name"/>_getSize(const <xsl:value-of select="$name"/>* array) {
182
183
    return reinterpret_cast&lt;const vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array)->size();
}
184
OPENMM_EXPORT void <xsl:value-of select="$name"/>_resize(<xsl:value-of select="$name"/>* array, int size) {
185
186
    reinterpret_cast&lt;vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array)->resize(size);
}
187
OPENMM_EXPORT void <xsl:value-of select="$name"/>_append(<xsl:value-of select="$name"/>* array, <xsl:value-of select="$element_type"/> value) {
188
189
    reinterpret_cast&lt;vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array)->push_back(value);
}
190
OPENMM_EXPORT void <xsl:value-of select="$name"/>_set(<xsl:value-of select="$name"/>* array, int index, <xsl:value-of select="$element_type"/> value) {
191
192
    (*reinterpret_cast&lt;vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array))[index] = value;
}
193
OPENMM_EXPORT double <xsl:value-of select="$name"/>_get(const <xsl:value-of select="$name"/>* array, int index) {
194
195
196
197
    return (*reinterpret_cast&lt;const vector&lt;<xsl:value-of select="$element_type"/>&gt;*&gt;(array))[index];
}
</xsl:template>

198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!-- Print out information for a class -->
<xsl:template name="class">
 <xsl:variable name="class_name" select="@name"/>
 <xsl:variable name="class_id" select="@id"/>

/* OpenMM::<xsl:value-of select="concat(@name, '*/')"/>
 <!-- Constructors and destructor -->
 <xsl:if test="not(@abstract=1)">
  <xsl:variable name="constructors" select="/GCC_XML/Constructor[@context=$class_id and @access='public' and not(@artificial='1')]"/>
  <xsl:for-each select="$constructors">
   <xsl:call-template name="constructor">
    <xsl:with-param name="suffix" select="if (position() > 1) then concat('_', position()) else ''"/>
   </xsl:call-template>
  </xsl:for-each>
 </xsl:if>
213
OPENMM_EXPORT void OpenMM_<xsl:value-of select="concat(@name, '_destroy(OpenMM_', @name, '* target) {')"/>
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
    delete reinterpret_cast&lt;<xsl:value-of select="@name"/>*&gt;(target);
}
 <!-- Methods -->
 <xsl:variable name="methods" select="/GCC_XML/Method[@context=$class_id and @access='public']"/>
 <xsl:for-each select="$methods">
  <xsl:variable name="node" select="."/>
  <!-- The next line is to deal with overloaded methods that have a const and a non-const version. -->
  <xsl:if test="not(@const=1) or empty($methods[@name=$node/@name and not(@const=1)])">
   <xsl:variable name="hide">
    <xsl:call-template name="should_hide"/>
   </xsl:variable>
   <xsl:if test="string-length($hide)=0">
    <xsl:call-template name="method">
     <xsl:with-param name="class_name" select="$class_name"/>
     <xsl:with-param name="class_id" select="$class_id"/>
    </xsl:call-template>
   </xsl:if>
  </xsl:if>
 </xsl:for-each>
</xsl:template>

<!-- Print out the definition of a constructor -->
<xsl:template name="constructor">
 <xsl:param name="suffix"/>
238
OPENMM_EXPORT OpenMM_<xsl:value-of select="concat(@name, '* OpenMM_', @name, '_create', $suffix, '(')"/>
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
  <xsl:for-each select="Argument">
   <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:value-of select="concat(' ', @name)"/>
  </xsl:for-each>
  <xsl:value-of select="') {'"/>
    return reinterpret_cast&lt;OpenMM_<xsl:value-of select="@name"/>*&gt;(new <xsl:value-of select="concat(@name, '(')"/>
  <xsl:for-each select="Argument">
   <xsl:if test="position() > 1">, </xsl:if>
   <xsl:call-template name="unwrap_value">
    <xsl:with-param name="value" select="@name"/>
    <xsl:with-param name="type_id" select="@type"/>
   </xsl:call-template>
  </xsl:for-each>
  <xsl:value-of select="'));'"/>
}
</xsl:template>

<!-- Print out the definition of a method -->
<xsl:template name="method">
 <xsl:param name="class_name"/>
 <xsl:param name="class_id"/>
 <!-- First the method signature -->
 <xsl:value-of select="$newline"/>
263
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, '(')"/>
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
 <xsl:if test="not(@static='1')">
  <xsl:if test="@const='1'">
   <xsl:value-of select="'const '"/>
  </xsl:if>
  <xsl:value-of select="concat('OpenMM_', $class_name, '* target')"/>
 </xsl:if>
 <!-- Generate the list of arguments -->
 <xsl:variable name="method" select="."/>
 <xsl:for-each select="Argument">
  <xsl:if test="position() > 1 or not($method/@static='1')">, </xsl:if>
  <xsl:call-template name="wrap_type"><xsl:with-param name="type_id" select="@type"/></xsl:call-template>
  <xsl:value-of select="concat(' ', @name)"/>
 </xsl:for-each>
 <xsl:value-of select="concat(') {', $newline, '    ')"/>
 <!-- Now the method body -->
 <xsl:if test="not(@returns=$void_type_id)">
  <xsl:call-template name="unwrap_type"><xsl:with-param name="type_id" select="@returns"/></xsl:call-template>
  <xsl:value-of select="' result = '"/>
 </xsl:if>
 <xsl:variable name="return_type" select="/GCC_XML/*[@id=$method/@returns]"/>
 <xsl:if test="local-name($return_type)='ReferenceType'">
  <xsl:value-of select="'&amp;'"/>
 </xsl:if>
 <xsl:choose>
  <xsl:when test="@static='1'">
   <!-- Invoke the method on the class -->
   <xsl:value-of select="concat($class_name, '::')"/>
  </xsl:when>
  <xsl:otherwise>
   <!-- Invoke the method on the target object -->
   <xsl:value-of select="'reinterpret_cast&lt;'"/>
   <xsl:if test="@const='1'">
    <xsl:value-of select="'const '"/>
   </xsl:if>
   <xsl:value-of select="concat($class_name, '*&gt;(target)->')"/>
  </xsl:otherwise>
 </xsl:choose>
 <xsl:value-of select="concat(@name, '(')"/>
 <xsl:for-each select="Argument">
  <xsl:if test="position() > 1">, </xsl:if>
  <xsl:call-template name="unwrap_value">
   <xsl:with-param name="value" select="@name"/>
   <xsl:with-param name="type_id" select="@type"/>
  </xsl:call-template>
 </xsl:for-each>
 <xsl:value-of select="');'"/>
 <xsl:if test="not(@returns=$void_type_id)">
  <xsl:value-of select="concat($newline, '    return ')"/>
  <xsl:call-template name="wrap_value"><xsl:with-param name="value" select="'result'"/><xsl:with-param name="type_id" select="@returns"/></xsl:call-template>
  <xsl:value-of select="';'"/>
 </xsl:if>
};
</xsl:template>

<!-- Print out the description of a type in the wrapper API -->
<xsl:template name="wrap_type">
 <xsl:param name="type_id"/>
 <xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
 <xsl:choose>
  <xsl:when test="$type_id=$bool_type_id">
   <xsl:value-of select="'OpenMM_Boolean'"/>
  </xsl:when>
  <xsl:when test="$type_id=$string_type_id">
   <xsl:value-of select="'char*'"/>
  </xsl:when>
  <xsl:when test="$type_id=$const_ref_string_type_id">
   <xsl:value-of select="'const char*'"/>
  </xsl:when>
  <xsl:when test="$type_id=$vector_string_type_id">
   <xsl:value-of select="'OpenMM_StringArray'"/>
  </xsl:when>
  <xsl:when test="$type_id=$vector_vec3_type_id">
   <xsl:value-of select="'OpenMM_Vec3Array'"/>
  </xsl:when>
  <xsl:when test="$type_id=$vector_bond_type_id">
   <xsl:value-of select="'OpenMM_BondArray'"/>
  </xsl:when>
  <xsl:when test="$type_id=$map_parameter_type_id">
   <xsl:value-of select="'OpenMM_ParameterArray'"/>
  </xsl:when>
344
345
346
  <xsl:when test="$type_id=$map_property_type_id">
   <xsl:value-of select="'OpenMM_PropertyArray'"/>
  </xsl:when>
347
348
349
  <xsl:when test="$type_id=$vector_double_type_id">
   <xsl:value-of select="'OpenMM_DoubleArray'"/>
  </xsl:when>
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
  <xsl:when test="local-name($node)='ReferenceType' or local-name($node)='PointerType'">
   <xsl:call-template name="wrap_type">
    <xsl:with-param name="type_id" select="$node/@type"/>
   </xsl:call-template>
   <xsl:value-of select="'*'"/>
  </xsl:when>
  <xsl:when test="local-name($node)='CvQualifiedType'">
   <xsl:if test="$node/@const=1">
    <xsl:value-of select="'const '"/>
   </xsl:if>
   <xsl:call-template name="wrap_type">
    <xsl:with-param name="type_id" select="$node/@type"/>
   </xsl:call-template>
  </xsl:when>
  <xsl:when test="local-name($node)='Enumeration'">
   <xsl:variable name="class_name" select="/GCC_XML/Class[@id=$node/@context]/@name"/>
   <xsl:value-of select="concat('OpenMM_', $class_name, '_', $node/@name)"/>
  </xsl:when>
  <xsl:when test="$node/@context=$openmm_namespace_id">
   <xsl:value-of select="concat('OpenMM_', $node/@name)"/>
  </xsl:when>
  <xsl:otherwise>
   <xsl:value-of select="$node/@name"/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<!-- Print out the description of a type in the native API -->
<xsl:template name="unwrap_type">
 <xsl:param name="type_id"/>
 <xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
 <xsl:choose>
  <xsl:when test="$type_id=$vector_string_type_id">
   <xsl:value-of select="'vector&lt;string&gt;'"/>
  </xsl:when>
  <xsl:when test="$type_id=$vector_vec3_type_id">
   <xsl:value-of select="'vector&lt;Vec3&gt;'"/>
  </xsl:when>
  <xsl:when test="$type_id=$vector_bond_type_id">
   <xsl:value-of select="'vector&lt;pair&lt;int, int&gt; &gt;'"/>
  </xsl:when>
  <xsl:when test="$type_id=$map_parameter_type_id">
   <xsl:value-of select="'map&lt;string, double&gt;'"/>
  </xsl:when>
394
395
396
  <xsl:when test="$type_id=$map_property_type_id">
   <xsl:value-of select="'map&lt;string, string&gt;'"/>
  </xsl:when>
397
398
399
  <xsl:when test="$type_id=$vector_double_type_id">
   <xsl:value-of select="'vector&lt;double&gt;'"/>
  </xsl:when>
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
  <xsl:when test="local-name($node)='ReferenceType' or local-name($node)='PointerType'">
   <xsl:call-template name="unwrap_type">
    <xsl:with-param name="type_id" select="$node/@type"/>
   </xsl:call-template>
   <xsl:value-of select="'*'"/>
  </xsl:when>
  <xsl:when test="local-name($node)='CvQualifiedType'">
   <xsl:if test="$node/@const=1">
    <xsl:value-of select="'const '"/>
   </xsl:if>
   <xsl:call-template name="unwrap_type">
    <xsl:with-param name="type_id" select="$node/@type"/>
   </xsl:call-template>
  </xsl:when>
  <xsl:when test="local-name($node)='Enumeration'">
   <xsl:variable name="class_name" select="/GCC_XML/Class[@id=$node/@context]/@name"/>
   <xsl:value-of select="concat($class_name, '::', $node/@name)"/>
  </xsl:when>
  <xsl:otherwise>
   <xsl:value-of select="$node/@name"/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<!-- Print out a value, if necessary casting from a native type to a wrapped type -->
<xsl:template name="wrap_value">
 <xsl:param name="value"/>
 <xsl:param name="type_id"/>
 <xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
 <xsl:choose>
  <xsl:when test="$type_id=$bool_type_id">
   <xsl:value-of select="concat('(', $value, ' ? OpenMM_True : OpenMM_False)')"/>
  </xsl:when>
  <xsl:when test="$type_id=$string_type_id">
   <xsl:value-of select="concat($value, '.c_str()')"/>
  </xsl:when>
  <xsl:when test="$type_id=$const_ref_string_type_id">
   <xsl:value-of select="concat($value, '->c_str()')"/>
  </xsl:when>
  <xsl:when test="local-name($node)='FundamentalType'">
   <xsl:value-of select="$value"/>
  </xsl:when>
  <xsl:otherwise>
   <xsl:choose>
    <xsl:when test="local-name($node)='Enumeration'">
     <xsl:value-of select="'static_cast&lt;'"/>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="'reinterpret_cast&lt;'"/>
    </xsl:otherwise>
   </xsl:choose>
   <xsl:call-template name="wrap_type">
    <xsl:with-param name="type_id" select="$type_id"/>
   </xsl:call-template>
   <xsl:value-of select="concat('&gt;(', $value, ')')"/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<!-- Print out a value, if necessary casting from a wrapped type to a native type -->
<xsl:template name="unwrap_value">
 <xsl:param name="value"/>
 <xsl:param name="type_id"/>
 <xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
 <xsl:choose>
  <xsl:when test="$type_id=$bool_type_id">
   <xsl:value-of select="concat('(', $value, ' != OpenMM_False)')"/>
  </xsl:when>
  <xsl:when test="$type_id=$string_type_id">
   <xsl:value-of select="concat('string(', $value, ')')"/>
  </xsl:when>
  <xsl:when test="$type_id=$const_ref_string_type_id">
   <xsl:value-of select="concat('string(', $value, ')')"/>
  </xsl:when>
  <xsl:when test="local-name($node)='FundamentalType'">
   <xsl:value-of select="$value"/>
  </xsl:when>
  <xsl:when test="$type_id=$vec3_type_id">
   <xsl:value-of select="concat('Vec3(', $value, '.x, ', $value, '.y, ', $value, '.z)')"/>
  </xsl:when>
  <xsl:otherwise>
   <xsl:if test="local-name($node)='ReferenceType'"><xsl:value-of select="'*'"/></xsl:if>
   <xsl:choose>
    <xsl:when test="local-name($node)='Enumeration'">
     <xsl:value-of select="'static_cast&lt;'"/>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="'reinterpret_cast&lt;'"/>
    </xsl:otherwise>
   </xsl:choose>
   <xsl:call-template name="unwrap_type">
    <xsl:with-param name="type_id" select="$type_id"/>
   </xsl:call-template>
   <xsl:value-of select="concat(' &gt;(', $value, ')')"/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<!-- Determine whether a method should be hidden -->
<xsl:template name="should_hide">
 <xsl:variable name="class_id" select="@context"/>
 <xsl:variable name="method_name" select="concat('OpenMM_', /GCC_XML/Class[@id=$class_id]/@name, '_', @name)"/>
 <xsl:if test="not(empty(index-of($skip_methods, $method_name)))">1</xsl:if>
 <xsl:call-template name="hide_type">
  <xsl:with-param name="type_id" select="@returns"/>
 </xsl:call-template>
 <xsl:for-each select="Argument">
  <xsl:call-template name="hide_type">
   <xsl:with-param name="type_id" select="@type"/>
  </xsl:call-template>
 </xsl:for-each>
</xsl:template>

<!-- This is called by should_hide.  It generates output if the specified type should be hidden. -->
<xsl:template name="hide_type">
 <xsl:param name="type_id"/>
 <xsl:variable name="node" select="/GCC_XML/*[@id=$type_id]"/>
 <xsl:choose>
  <xsl:when test="local-name($node)='ReferenceType' or local-name($node)='PointerType' or local-name($node)='CvQualifiedType'">
   <xsl:call-template name="hide_type">
    <xsl:with-param name="type_id" select="$node/@type"/>
   </xsl:call-template>
  </xsl:when>
  <xsl:when test="local-name($node)='Enumeration'">
   <xsl:call-template name="hide_type">
    <xsl:with-param name="type_id" select="$node/@context"/>
   </xsl:call-template>
  </xsl:when>
  <xsl:when test="$node/@context=$openmm_namespace_id and not(empty(index-of($hide_classes, $node/@name)))">
   <xsl:value-of select="1"/>
  </xsl:when>
 </xsl:choose>
</xsl:template>

534
</xsl:stylesheet>