Changeset 12073


Ignore:
Timestamp:
04/20/12 08:41:10 (13 years ago)
Author:
Eric.Larour
Message:

Adapted PYTHON 3.2 API to PYTHON 2.7 API.

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  
    2828                                                 return output;
    2929//}}}
    30 /* WRAPPER {{{1*/
     30#if _PYTHON_MAJOR_ >=3
     31/* WRAPPER 3.2 {{{1*/
    3132#define WRAPPER(modulename,...)  \
    3233\
     
    5455static PyObject* modulename(PyObject* self,PyObject* args)
    5556/*}}}*/
     57#else
     58/* WRAPPER 2.7 {{{1*/
     59#define WRAPPER(modulename,...)  \
     60\
     61static PyObject* modulename(PyObject* self,PyObject* args);\
     62static PyMethodDef modulename##_funcs[] = {\
     63        {#modulename, (PyCFunction)modulename, METH_VARARGS, ""},\
     64        {NULL,NULL,0,NULL}\
     65};\
     66\
     67PyMODINIT_FUNC init##modulename(void){\
     68\
     69        import_array();\
     70        (void) Py_InitModule(#modulename, modulename##_funcs);\
     71}\
     72\
     73static PyObject* modulename(PyObject* self,PyObject* args)
     74/*}}}*/
     75#endif
    5676/* CHECKARGUMENTS {{{1*/
    5777#define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumPythonArguments(args, NRHS,functionpointer)
  • issm/trunk-jpl/src/c/python/io/FetchPythonData.cpp

    r12017 r12073  
    1616#include "../../shared/shared.h"
    1717
    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*/
    3319/*FUNCTION FetchData(double* pscalar,PyObject* py_float){{{1*/
    3420void FetchData(double* pscalar,PyObject* py_float){
     
    7157}
    7258/*}}}*/
     59
     60/*Python version dependent: */
     61#if _PYTHON_MAJOR_ >= 3
     62/*FUNCTION FetchData(char** pstring,PyObject* py_unicode){{{1*/
     63void 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*/
     80void 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.