Changeset 8710
- Timestamp:
- Feb 21, 2013, 3:16:55 PM (12 years ago)
- Location:
- trunk/anuga_core/source/anuga/utilities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/utilities/quad_tree_ext.c
r8709 r8710 165 165 */ 166 166 167 static void delete_quad_tree_cap(PyObject * cap){ 168 167 #ifdef PYVERSION273 168 169 170 void delete_quad_tree_cap(PyObject * cap){ 169 171 quad_tree * kill = (quad_tree*) PyCapsule_GetPointer(cap,"quad tree"); 170 172 if(kill!=NULL){ 171 173 delete_quad_tree(kill); 172 } 173 } 174 } else{ 175 } 176 } 177 178 179 180 #else 181 182 // If using python earlier version, build with PyCObject 183 184 // Delete cobj containing a quad tree 185 void delete_quad_tree_cobj(void * cobj){ 186 quad_tree * kill = (quad_tree*) cobj; 187 if(kill!=NULL){ 188 delete_quad_tree(kill); 189 } 190 } 191 192 193 #endif 174 194 175 195 //----------------------- PYTHON WRAPPER FUNCTION ----------------------------- -
trunk/anuga_core/source/anuga/utilities/sparse_matrix_ext.c
r8691 r8710 11 11 #include "sparse_dok.h" 12 12 13 13 #include "patchlevel.h" 14 15 // PYVERSION273 used to check python version for use of PyCapsule 16 #if PY_MAJOR_VERSION>=2 && PY_MINOR_VERSION>=7 && PY_MICRO_VERSION>=3 17 #define PYVERSION273 18 #endif 14 19 15 20 … … 92 97 }; 93 98 99 // ---------------------------------------------------------------------------- 100 101 // If using python 2.7.3 or later, build with PyCapsules 102 103 // Delete capsule containing a quad tree - name of capsule must be exactly 104 // "quad tree". 105 106 #ifdef PYVERSION273 94 107 95 108 // Delete capsule containing a sparse_dok - name of capsule must be exactly 96 109 // "sparse dok". 97 static void delete_sparse_dok_cap(PyObject *cap){110 void delete_dok_cap(PyObject *cap){ 98 111 99 112 sparse_dok * kill = (sparse_dok*) PyCapsule_GetPointer(cap,"sparse dok"); … … 101 114 delete_dok_matrix(kill); 102 115 } 103 104 } 116 } 117 118 #else 119 120 // If using python earlier version, build with PyCObject 121 122 123 // Delete cobj containing a sparse_dok 124 void delete_dok_cobj(void *cobj){ 125 126 sparse_dok * kill = (sparse_dok*) cobj; 127 if(kill!=NULL){ 128 delete_dok_matrix(kill); 129 } 130 } 131 132 #endif 105 133 //----------------------- PYTHON WRAPPER FUNCTION ----------------------------- 106 134 … … 119 147 return NULL; 120 148 } 121 149 #ifdef PYVERSION273 122 150 sparse_dok * dok = (sparse_dok*) PyCapsule_GetPointer(sparse_dok_cap,"sparse dok"); 151 #else 152 sparse_dok * dok = (sparse_dok*) PyCObject_AsVoidPtr(sparse_dok_cap); 153 #endif 123 154 124 155 serial_sparse_dok = PyDict_New(); … … 155 186 err = _deserialise(dok,serial_sparse_dok); 156 187 188 #ifdef PYVERSION273 157 189 return PyCapsule_New((void*) dok, 158 190 "sparse dok", 159 &delete_sparse_dok_cap); 191 &delete_dok_cap); 192 #else 193 return PyCObject_FromVoidPtr((void*) dok, 194 &delete_dok_obj); 195 #endif 160 196 161 197 }
Note: See TracChangeset
for help on using the changeset viewer.