comparison vampyhost.cpp @ 2:e30eda0b5e2d

Fix peculiar return types
author Chris Cannam
date Thu, 31 Jan 2013 13:03:47 +0000
parents cb0d3af1be4d
children f12ab1553882
comparison
equal deleted inserted replaced
1:cb0d3af1be4d 2:e30eda0b5e2d
37 37
38 #define HOST_VERSION "1.1" 38 #define HOST_VERSION "1.1"
39 39
40 40
41 /* MODULE HELPER FUNCTIONS */ 41 /* MODULE HELPER FUNCTIONS */
42 PyDoc_STRVAR(xx_foo_doc, "Some description"); 42 PyDoc_STRVAR(xx_foo_doc, "Some description"); //!!!
43 43
44 /*obtain C plugin handle and key from pyCobject */ 44 /*obtain C plugin handle and key from pyCobject */
45 int getPluginHandle 45 bool getPluginHandle
46 (PyObject *pyPluginHandle, Plugin **plugin, string **pKey=NULL) { 46 (PyObject *pyPluginHandle, Plugin **plugin, string **pKey=NULL) {
47 47
48 //char errormsg[]="Wrong input argument: Plugin Handle required."; 48 //char errormsg[]="Wrong input argument: Plugin Handle required.";
49 49
50 *plugin = NULL; 50 *plugin = NULL;
51 if (!PyCObject_Check(pyPluginHandle)) return NULL; 51 if (!PyCObject_Check(pyPluginHandle)) return false;
52 52
53 //try to convert to Plugin pointer 53 //try to convert to Plugin pointer
54 Plugin *p = (Plugin*) PyCObject_AsVoidPtr(pyPluginHandle); 54 Plugin *p = (Plugin*) PyCObject_AsVoidPtr(pyPluginHandle);
55 if (!p) return NULL; 55 if (!p) return false;
56 56
57 string pId; 57 string pId;
58 58
59 if (pKey) { 59 if (pKey) {
60 *pKey = (string*) PyCObject_GetDesc(pyPluginHandle); 60 *pKey = (string*) PyCObject_GetDesc(pyPluginHandle);
61 if (!*pKey) return NULL; 61 if (!*pKey) return false;
62 pId = *(string*) *pKey; 62 pId = *(string*) *pKey;
63 63
64 } else { 64 } else {
65 65
66 void *pKey = PyCObject_GetDesc(pyPluginHandle); 66 void *pKey = PyCObject_GetDesc(pyPluginHandle);
67 if (!pKey) return NULL; 67 if (!pKey) return false;
68 pId = *(string*) pKey; 68 pId = *(string*) pKey;
69 } 69 }
70 70
71 string::size_type pos = pId.find(':'); 71 string::size_type pos = pId.find(':');
72 if (pos == string::npos) return NULL; 72 if (pos == string::npos) return false;
73 73
74 pId = pId.substr(pId.rfind(':')+1); 74 pId = pId.substr(pId.rfind(':')+1);
75 string identifier = p->getIdentifier(); 75 string identifier = p->getIdentifier();
76 76
77 if (pId.compare(identifier)) return NULL; 77 if (pId.compare(identifier)) return false;
78 78
79 *plugin = p; 79 *plugin = p;
80 return true; 80 return true;
81 } 81 }
82 82