Changeset 11943


Ignore:
Timestamp:
04/05/12 14:53:48 (13 years ago)
Author:
Eric.Larour
Message:

New macros for python and matlab wrappers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/include/macros.h

    r11918 r11943  
    4141/*}}}*/
    4242/* MODULEBOOT/MODULEEND {{{1*/
     43
    4344/*The following macros hide the error exception handling in a matlab module. Just put
    4445 * MODULEBOOT(); and MODULEEND(); at the beginning and end of a module, and c++ exceptions
    4546 * will be trapped. Really nifty!*/
     47
    4648#ifdef _SERIAL_
    47 
     49#ifdef _HAVE_MATLAB_ //{{{2
    4850#define MODULEBOOT(); ModuleBoot(); \
    4951        try{
     
    5860                mexErrMsgTxt(" ");\
    5961        }
     62#endif //}}}
     63#ifdef _HAVE_PYTHON_ //{{{2
     64#define MODULEBOOT(); ModuleBoot(); \
     65        try{
    6066
     67#define MODULEEND();  ModuleEnd(); }\
     68        catch(ErrorException &exception){\
     69                exception.Report(); \
     70                return; \
     71        }\
     72        catch (exception& e) {\
     73                _printf_(true,"Standard exception: %s\n",e.what());\
     74                return;\
     75        }
     76#endif //}}}
    6177#else
    62 
     78//{{{2
    6379#define MODULEBOOT(); \
    6480        try{
     
    7389                return 1;\
    7490        }
     91//}}}
     92#endif
     93/*}}}*/
     94/* WRAPPER {{{1*/
     95#ifdef _HAVE_MATLAB_
     96#define WRAPPER(modulename,...) void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
     97#endif
     98#ifdef _HAVE_PYTHON_
     99#define WRAPPER(modulename,...) void modulename(__VA_ARGS__)
     100#endif
     101/*}}}*/
     102/* CHECKARGUMENTS {{{1*/
     103#ifdef _HAVE_MATLAB_
     104#define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,functionpointer)
     105#endif
     106#ifdef _HAVE_PYTHON_
     107#define CHECKARGUMENTS(NLHS,NRHS,functionpointer)
    75108#endif
    76109/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.