Mercurial > hg > vampy
comparison PyPlugin.h @ 66:5664fe298af2
Update to Python 2.7 and clean up the build (avoid using deprecated NumPy API, fix compiler warnings)
author | Chris Cannam |
---|---|
date | Mon, 17 Nov 2014 09:37:59 +0000 |
parents | c1e4f706ca9a |
children | 146d14ab15e7 |
comparison
equal
deleted
inserted
replaced
65:0df94e3f0fdb | 66:5664fe298af2 |
---|---|
127 | 127 |
128 void setProcessType(); | 128 void setProcessType(); |
129 | 129 |
130 FeatureSet processMethodCall(const float *const *inputBuffers,Vamp::RealTime timestamp); | 130 FeatureSet processMethodCall(const float *const *inputBuffers,Vamp::RealTime timestamp); |
131 | 131 |
132 bool getBooleanFlag(char flagName[],bool) const; | 132 bool getBooleanFlag(const char flagName[],bool) const; |
133 int getBinaryFlags(char flagName[], eVampyFlags) const; | 133 int getBinaryFlags(const char flagName[], eVampyFlags) const; |
134 void typeErrorHandler(char *method, bool process = false) const; | 134 void typeErrorHandler(const char *method, bool process = false) const; |
135 | 135 |
136 /// simple 'void return' call with no args | 136 /// simple 'void return' call with no args |
137 void genericMethodCall(char *method) const | 137 void genericMethodCall(const char *method) const |
138 { | 138 { |
139 if (m_debugFlag) cerr << DEBUG_NAME << endl; | 139 if (m_debugFlag) cerr << DEBUG_NAME << endl; |
140 if ( PyObject_HasAttrString(m_pyInstance,method) ) | 140 if ( PyObject_HasAttrString(m_pyInstance,method) ) |
141 { | 141 { |
142 PyObject *pyValue = PyObject_CallMethod(m_pyInstance, method, NULL); | 142 PyObject *pyValue = PyObject_CallMethod(m_pyInstance, (char *)method, NULL); |
143 if (!pyValue) { | 143 if (!pyValue) { |
144 cerr << PLUGIN_ERROR << "Failed to call method." << endl; | 144 cerr << PLUGIN_ERROR << "Failed to call method." << endl; |
145 if (PyErr_Occurred()) {PyErr_Print(); PyErr_Clear();} | 145 if (PyErr_Occurred()) {PyErr_Print(); PyErr_Clear();} |
146 } | 146 } |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 /// 'no arg with default return value' call | 150 /// 'no arg with default return value' call |
151 template<typename RET> | 151 template<typename RET> |
152 RET &genericMethodCall(char *method, RET &rValue) const | 152 RET &genericMethodCall(const char *method, RET &rValue) const |
153 { | 153 { |
154 if (m_debugFlag) cerr << DEBUG_NAME << endl; | 154 if (m_debugFlag) cerr << DEBUG_NAME << endl; |
155 if ( PyObject_HasAttrString(m_pyInstance,method) ) | 155 if ( PyObject_HasAttrString(m_pyInstance,method) ) |
156 { | 156 { |
157 PyObject *pyValue = PyObject_CallMethod(m_pyInstance, method, NULL); | 157 PyObject *pyValue = PyObject_CallMethod(m_pyInstance, (char *)method, NULL); |
158 if (!pyValue) { | 158 if (!pyValue) { |
159 cerr << PLUGIN_ERROR << "Failed to call method." << endl; | 159 cerr << PLUGIN_ERROR << "Failed to call method." << endl; |
160 if (PyErr_Occurred()) {PyErr_Print(); PyErr_Clear();} | 160 if (PyErr_Occurred()) {PyErr_Print(); PyErr_Clear();} |
161 return rValue; | 161 return rValue; |
162 } | 162 } |
175 return rValue; | 175 return rValue; |
176 } | 176 } |
177 | 177 |
178 /// unary call | 178 /// unary call |
179 template<typename RET,typename A1> | 179 template<typename RET,typename A1> |
180 RET genericMethodCallArgs(char *method, A1 arg1) const | 180 RET genericMethodCallArgs(const char *method, A1 arg1) const |
181 { | 181 { |
182 RET rValue = RET(); | 182 RET rValue = RET(); |
183 if (m_debugFlag) cerr << DEBUG_NAME << endl; | 183 if (m_debugFlag) cerr << DEBUG_NAME << endl; |
184 if (!PyObject_HasAttrString(m_pyInstance,method)) { | 184 if (!PyObject_HasAttrString(m_pyInstance,method)) { |
185 if (m_debugFlag) cerr << DEAFULT_RETURN << endl; | 185 if (m_debugFlag) cerr << DEAFULT_RETURN << endl; |
241 return rValue; | 241 return rValue; |
242 } | 242 } |
243 | 243 |
244 /// binary call | 244 /// binary call |
245 template<typename RET,typename A1,typename A2> | 245 template<typename RET,typename A1,typename A2> |
246 RET genericMethodCallArgs(char *method, A1 arg1, A2 arg2) const | 246 RET genericMethodCallArgs(const char *method, A1 arg1, A2 arg2) const |
247 { | 247 { |
248 RET rValue = RET(); | 248 RET rValue = RET(); |
249 if (m_debugFlag) cerr << DEBUG_NAME << endl; | 249 if (m_debugFlag) cerr << DEBUG_NAME << endl; |
250 if (!PyObject_HasAttrString(m_pyInstance,method)) { | 250 if (!PyObject_HasAttrString(m_pyInstance,method)) { |
251 if (m_debugFlag) cerr << DEAFULT_RETURN << endl; | 251 if (m_debugFlag) cerr << DEAFULT_RETURN << endl; |
313 return rValue; | 313 return rValue; |
314 } | 314 } |
315 | 315 |
316 /// trenary call | 316 /// trenary call |
317 template<typename RET,typename A1,typename A2,typename A3> | 317 template<typename RET,typename A1,typename A2,typename A3> |
318 RET genericMethodCallArgs(char *method, A1 arg1, A2 arg2, A3 arg3) const | 318 RET genericMethodCallArgs(const char *method, A1 arg1, A2 arg2, A3 arg3) const |
319 { | 319 { |
320 RET rValue = RET(); | 320 RET rValue = RET(); |
321 if (m_debugFlag) cerr << DEBUG_NAME << endl; | 321 if (m_debugFlag) cerr << DEBUG_NAME << endl; |
322 if (!PyObject_HasAttrString(m_pyInstance,method)) { | 322 if (!PyObject_HasAttrString(m_pyInstance,method)) { |
323 if (m_debugFlag) cerr << DEAFULT_RETURN << endl; | 323 if (m_debugFlag) cerr << DEAFULT_RETURN << endl; |