Changeset 0957bb3a in sasview for src/sas/sascalc/calculator/c_extensions/sld2i_module.c
- Timestamp:
- Nov 7, 2017 10:00:25 AM (7 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 54b0650
- Parents:
- 0fc5a03
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/calculator/c_extensions/sld2i_module.c
r1d014cb r0957bb3a 4 4 #include <Python.h> 5 5 #include <stdio.h> 6 #include <sld2i.h h>6 #include <sld2i.h> 7 7 8 8 #if PY_MAJOR_VERSION < 3 … … 35 35 void 36 36 del_sld2i(PyObject *obj){ 37 GenI* sld2i = static_cast<GenI *>(PyCapsule_GetPointer(obj, "GenI")); 38 delete sld2i; 39 return; 37 GenI* sld2i = (GenI *)(PyCapsule_GetPointer(obj, "GenI")); 38 PyMem_Free((void *)sld2i); 40 39 } 41 40 … … 43 42 * Create a GenI as a python object by supplying arrays 44 43 */ 45 PyObject * new_GenI(PyObject * , PyObject *args) {44 PyObject * new_GenI(PyObject *self, PyObject *args) { 46 45 PyObject *x_val_obj; 47 46 PyObject *y_val_obj; … … 79 78 OUTVECTOR(mz_val_obj, mz_val, n_x); 80 79 OUTVECTOR(vol_pix_obj, vol_pix, n_x); 81 GenI* sld2i = new GenI(n_pix,x_val,y_val,z_val,sldn_val,mx_val,my_val,mz_val,vol_pix,inspin,outspin,stheta); 80 GenI* sld2i = PyMem_Malloc(sizeof(GenI)); 81 if (sld2i != NULL) { 82 initGenI(sld2i, n_pix,x_val,y_val,z_val,sldn_val,mx_val,my_val,mz_val,vol_pix,inspin,outspin,stheta); 83 } 82 84 return PyCapsule_New(sld2i, "GenI", del_sld2i); 83 85 } … … 86 88 * GenI the given input (2D) according to a given object 87 89 */ 88 PyObject * genicom_inputXY(PyObject * , PyObject *args) {90 PyObject * genicom_inputXY(PyObject *self, PyObject *args) { 89 91 int npoints; 90 92 PyObject *qx_obj; … … 106 108 107 109 // Set the array pointers 108 void *temp = PyCapsule_GetPointer(gen_obj, "GenI"); 109 GenI* s = static_cast<GenI *>(temp); 110 111 s->genicomXY(npoints, qx, qy, I_out); 110 GenI* sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI"); 111 112 genicomXY(sld2i, npoints, qx, qy, I_out); 112 113 //return PyCObject_FromVoidPtr(s, del_genicom); 113 114 return Py_BuildValue("i",1); … … 117 118 * GenI the given 1D input according to a given object 118 119 */ 119 PyObject * genicom_input(PyObject * , PyObject *args) {120 PyObject * genicom_input(PyObject *self, PyObject *args) { 120 121 int npoints; 121 122 PyObject *q_obj; … … 134 135 135 136 // Set the array pointers 136 void *temp = PyCapsule_GetPointer(gen_obj, "GenI"); 137 GenI* s = static_cast<GenI *>(temp); 138 139 s->genicom(npoints, q, I_out); 137 GenI *sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI"); 138 139 genicom(sld2i, npoints, q, I_out); 140 140 //return PyCObject_FromVoidPtr(s, del_genicom); 141 141 return Py_BuildValue("i",1);
Note: See TracChangeset
for help on using the changeset viewer.