diff PyPlugin.h @ 71:40a01bb24209 vampyhost

Pull apart some type conversion classes for possible use in VamPy Host
author Chris Cannam
date Thu, 20 Nov 2014 13:02:50 +0000
parents 146d14ab15e7
children ffaa1fb3d7de
line wrap: on
line diff
--- a/PyPlugin.h	Mon Nov 17 14:07:00 2014 +0000
+++ b/PyPlugin.h	Thu Nov 20 13:02:50 2014 +0000
@@ -9,40 +9,6 @@
 
 */
 
-/*
-    Vamp
-
-    An API for audio analysis and feature extraction plugins.
-
-    Centre for Digital Music, Queen Mary, University of London.
-    Copyright 2006 Chris Cannam.
-  
-    Permission is hereby granted, free of charge, to any person
-    obtaining a copy of this software and associated documentation
-    files (the "Software"), to deal in the Software without
-    restriction, including without limitation the rights to use, copy,
-    modify, merge, publish, distribute, sublicense, and/or sell copies
-    of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be
-    included in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
-    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
-    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-    Except as contained in this notice, the names of the Centre for
-    Digital Music; Queen Mary, University of London; and Chris Cannam
-    shall not be used in advertising or otherwise to promote the sale,
-    use or other dealings in this Software without prior written
-    authorization.
-*/
-
 #ifndef _PYTHON_WRAPPER_PLUGIN_H_
 #define _PYTHON_WRAPPER_PLUGIN_H_
 
@@ -55,6 +21,7 @@
 #include <Python.h>
 #include "PyExtensionModule.h"
 #include "PyTypeInterface.h"
+#include "PyTypeConversions.h"
 #include "vamp-sdk/Plugin.h"
 #include "Mutex.h"
 
@@ -117,6 +84,7 @@
 	PyObject *m_pyProcess;
 	PyObject *m_pyProcessCallable;
 	mutable InputDomain m_inputDomain;
+	PyTypeConversions m_tc;
 	PyTypeInterface m_ti;
 	int m_vampyFlags;
 	bool m_quitOnErrorFlag;
@@ -187,7 +155,7 @@
 		}
 		
 		/// prepare arguments for fast method call
-		PyObject *pyMethod = m_ti.PyValue_From_CValue(method);
+		PyObject *pyMethod = m_tc.PyValue_From_CValue(method);
 		PyObject *pyCallable = PyObject_GetAttr(m_pyInstance,pyMethod);
 		PyObject* pyArgs = PyTuple_New(1);
 		if (!(pyArgs && pyCallable && pyMethod)) {
@@ -198,8 +166,8 @@
 			return rValue;
 		}
 		
-		PyObject *pyArg1 = m_ti.PyValue_From_CValue(arg1);
-		if (m_ti.error) {
+		PyObject *pyArg1 = m_tc.PyValue_From_CValue(arg1);
+		if (m_tc.error) {
 			cerr << PLUGIN_ERROR << "Failed to convert argument for calling method." << endl;
 			typeErrorHandler(method);
 			Py_CLEAR(pyMethod);
@@ -253,7 +221,7 @@
 		}
 		
 		/// prepare arguments for fast method call
-		PyObject *pyMethod = m_ti.PyValue_From_CValue(method);
+		PyObject *pyMethod = m_tc.PyValue_From_CValue(method);
 		PyObject *pyCallable = PyObject_GetAttr(m_pyInstance,pyMethod);
 		PyObject* pyArgs = PyTuple_New(2);
 		if (!(pyArgs && pyCallable && pyMethod)) {
@@ -264,9 +232,9 @@
 			return rValue;
 		}
 		
-		PyObject *pyArg1 = m_ti.PyValue_From_CValue(arg1);
-		PyObject *pyArg2 = m_ti.PyValue_From_CValue(arg2);
-		if (m_ti.error) {
+		PyObject *pyArg1 = m_tc.PyValue_From_CValue(arg1);
+		PyObject *pyArg2 = m_tc.PyValue_From_CValue(arg2);
+		if (m_tc.error) {
 			cerr << PLUGIN_ERROR << "Failed to convert arguments for calling method." << endl;
 			typeErrorHandler(method);
 			Py_CLEAR(pyMethod);
@@ -325,7 +293,7 @@
 		}
 		
 		/// prepare arguments for fast method call
-		PyObject *pyMethod = m_ti.PyValue_From_CValue(method);
+		PyObject *pyMethod = m_tc.PyValue_From_CValue(method);
 		PyObject *pyCallable = PyObject_GetAttr(m_pyInstance,pyMethod);
 		PyObject* pyArgs = PyTuple_New(3);
 		if (!(pyArgs && pyCallable && pyMethod)) {
@@ -336,10 +304,10 @@
 			return rValue;
 		}
 		
-		PyObject *pyArg1 = m_ti.PyValue_From_CValue(arg1);
-		PyObject *pyArg2 = m_ti.PyValue_From_CValue(arg2);
-		PyObject *pyArg3 = m_ti.PyValue_From_CValue(arg3);
-		if (m_ti.error) {
+		PyObject *pyArg1 = m_tc.PyValue_From_CValue(arg1);
+		PyObject *pyArg2 = m_tc.PyValue_From_CValue(arg2);
+		PyObject *pyArg3 = m_tc.PyValue_From_CValue(arg3);
+		if (m_tc.error) {
 			cerr << PLUGIN_ERROR << "Failed to convert arguments for calling method." << endl;
 			typeErrorHandler(method);
 			Py_CLEAR(pyMethod);