Changeset d04ac05 in sasview for src/sas/sascalc/file_converter
- Timestamp:
- Sep 22, 2017 11:47:05 PM (7 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 9e308a3
- Parents:
- 7b50f14
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/file_converter/c_ext/bsl_loader.c
r2ab9c432 rd04ac05 1 1 #include <Python.h> 2 //#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION2 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION 3 3 #include <numpy/arrayobject.h> 4 4 #include <stdio.h> … … 44 44 static void CLoader_dealloc(CLoader *self) { 45 45 free(self->params.filename); 46 self->ob_type->tp_free((PyObject *)self);46 Py_TYPE(self)->tp_free((PyObject *)self); 47 47 } 48 48 … … 237 237 238 238 static PyTypeObject CLoaderType = { 239 PyObject_HEAD_INIT(NULL) 240 0, /*ob_size*/ 239 //PyObject_HEAD_INIT(NULL) 240 //0, /*ob_size*/ 241 PyVarObject_HEAD_INIT(NULL, 0) 241 242 "CLoader", /*tp_name*/ 242 243 sizeof(CLoader), /*tp_basicsize*/ … … 278 279 }; 279 280 280 PyMODINIT_FUNC 281 initbsl_loader(void) 282 { 283 PyObject *module; 284 module = Py_InitModule("bsl_loader", NULL); 285 import_array(); 286 281 static PyMethodDef module_methods[] = { 282 {NULL} 283 }; 284 285 /** 286 * Function used to add the model class to a module 287 * @param module: module to add the class to 288 */ 289 void addCLoader(PyObject *module) { 287 290 if (PyType_Ready(&CLoaderType) < 0) 288 291 return; 289 292 290 293 Py_INCREF(&CLoaderType); 291 PyModule_AddObject(module, "CLoader", (PyObject *)&CLoaderType); 292 } 294 PyModule_AddObject(module, "bsl_loader", (PyObject *)&CLoaderType); 295 } 296 297 298 #define MODULE_DOC "C module for loading bsl." 299 #define MODULE_NAME "bsl_loader" 300 #define MODULE_INIT2 initbsl_loader 301 #define MODULE_INIT3 PyInit_bsl_loader 302 #define MODULE_METHODS module_methods 303 304 /* ==== boilerplate python 2/3 interface bootstrap ==== */ 305 306 307 #if defined(WIN32) && !defined(__MINGW32__) 308 #define DLL_EXPORT __declspec(dllexport) 309 #else 310 #define DLL_EXPORT 311 #endif 312 313 #if PY_MAJOR_VERSION >= 3 314 315 DLL_EXPORT PyMODINIT_FUNC MODULE_INIT3(void) 316 { 317 static struct PyModuleDef moduledef = { 318 PyModuleDef_HEAD_INIT, 319 MODULE_NAME, /* m_name */ 320 MODULE_DOC, /* m_doc */ 321 -1, /* m_size */ 322 MODULE_METHODS, /* m_methods */ 323 NULL, /* m_reload */ 324 NULL, /* m_traverse */ 325 NULL, /* m_clear */ 326 NULL, /* m_free */ 327 }; 328 PyObject* m = PyModule_Create(&moduledef); 329 addCLoader(m); 330 return m; 331 } 332 333 #else /* !PY_MAJOR_VERSION >= 3 */ 334 335 DLL_EXPORT PyMODINIT_FUNC MODULE_INIT2(void) 336 { 337 PyObject* m = Py_InitModule4(MODULE_NAME, 338 MODULE_METHODS, 339 MODULE_DOC, 340 0, 341 PYTHON_API_VERSION 342 ); 343 addCLoader(m); 344 } 345 346 #endif /* !PY_MAJOR_VERSION >= 3 */
Note: See TracChangeset
for help on using the changeset viewer.