Changeset 12073
- Timestamp:
- 04/20/12 08:41:10 (13 years ago)
- Location:
- issm/trunk-jpl/src/c/python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/python/include/python_macros.h
r12031 r12073 28 28 return output; 29 29 //}}} 30 /* WRAPPER {{{1*/ 30 #if _PYTHON_MAJOR_ >=3 31 /* WRAPPER 3.2 {{{1*/ 31 32 #define WRAPPER(modulename,...) \ 32 33 \ … … 54 55 static PyObject* modulename(PyObject* self,PyObject* args) 55 56 /*}}}*/ 57 #else 58 /* WRAPPER 2.7 {{{1*/ 59 #define WRAPPER(modulename,...) \ 60 \ 61 static PyObject* modulename(PyObject* self,PyObject* args);\ 62 static PyMethodDef modulename##_funcs[] = {\ 63 {#modulename, (PyCFunction)modulename, METH_VARARGS, ""},\ 64 {NULL,NULL,0,NULL}\ 65 };\ 66 \ 67 PyMODINIT_FUNC init##modulename(void){\ 68 \ 69 import_array();\ 70 (void) Py_InitModule(#modulename, modulename##_funcs);\ 71 }\ 72 \ 73 static PyObject* modulename(PyObject* self,PyObject* args) 74 /*}}}*/ 75 #endif 56 76 /* CHECKARGUMENTS {{{1*/ 57 77 #define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumPythonArguments(args, NRHS,functionpointer) -
issm/trunk-jpl/src/c/python/io/FetchPythonData.cpp
r12017 r12073 16 16 #include "../../shared/shared.h" 17 17 18 /*FUNCTION FetchData(char** pstring,PyObject* py_unicode){{{1*/ 19 void FetchData(char** pstring,PyObject* py_unicode){ 20 21 PyObject* py_bytes; 22 char* string=NULL; 23 24 25 /*convert to bytes format: */ 26 PyUnicode_FSConverter(py_unicode,&py_bytes); 27 28 /*convert from bytes to string: */ 29 string=PyBytes_AS_STRING(py_bytes); 30 31 *pstring=string; 32 } 18 /*Primitive data types*/ 33 19 /*FUNCTION FetchData(double* pscalar,PyObject* py_float){{{1*/ 34 20 void FetchData(double* pscalar,PyObject* py_float){ … … 71 57 } 72 58 /*}}}*/ 59 60 /*Python version dependent: */ 61 #if _PYTHON_MAJOR_ >= 3 62 /*FUNCTION FetchData(char** pstring,PyObject* py_unicode){{{1*/ 63 void FetchData(char** pstring,PyObject* py_unicode){ 64 65 PyObject* py_bytes; 66 char* string=NULL; 67 68 69 /*convert to bytes format: */ 70 PyUnicode_FSConverter(py_unicode,&py_bytes); 71 72 /*convert from bytes to string: */ 73 string=PyBytes_AS_STRING(py_bytes); 74 75 *pstring=string; 76 } 77 /*}}}*/ 78 #else 79 /*FUNCTION FetchData(char** pstring,PyObject* py_string){{{1*/ 80 void FetchData(char** pstring,PyObject* py_string){ 81 82 char* string=NULL; 83 84 /*extract internal string: */ 85 string=PyString_AsString(py_string); 86 87 *pstring=string; 88 } 89 /*}}}*/ 90 #endif
Note:
See TracChangeset
for help on using the changeset viewer.