File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,18 @@ import simtk.unit as unit
3838 val[3 ] = unit.Quantity (val[3 ], unit.kilojoule_per_mole /unit.nanometer **4 )
3939%}
4040
41+ /*
42+ * Convert C++ exceptions to Python exceptions.
43+ */
44+ %exception {
45+ try {
46+ $action
47+ } catch (std::exception &e) {
48+ PyErr_SetString (PyExc_Exception, const_cast <char *>(e.what ()));
49+ return NULL ;
50+ }
51+ }
52+
4153
4254namespace ExamplePlugin {
4355
@@ -66,6 +78,19 @@ public:
6678 %clear int & particle2;
6779 %clear double & length;
6880 %clear double & k;
81+
82+ /*
83+ * Add methods for casting a Force to an ExampleForce.
84+ */
85+ %extend {
86+ static ExamplePlugin::ExampleForce& cast (OpenMM::Force& force) {
87+ return dynamic_cast <ExamplePlugin::ExampleForce&>(force);
88+ }
89+
90+ static bool isinstance (OpenMM::Force& force) {
91+ return (dynamic_cast <ExamplePlugin::ExampleForce*>(&force) != NULL );
92+ }
93+ }
6994};
7095
7196}
Original file line number Diff line number Diff line change 99exampleplugin_library_dir = '@EXAMPLEPLUGIN_LIBRARY_DIR@'
1010
1111# setup extra compile and link arguments on Mac
12- extra_compile_args = []
12+ extra_compile_args = ['-std=c++11' ]
1313extra_link_args = []
1414
1515if platform .system () == 'Darwin' :
You can’t perform that action at this time.
0 commit comments