Ice Sheet System Model  4.18
Code documentation
wrapper_macros.h
Go to the documentation of this file.
1 /* \file matlab macros.h
2  * \brief: macros used for the matlab bindings
3  */
4 
5 #ifndef _MATLAB_MACROS_H_
6 #define _MATLAB_MACROS_H_
7 
8 #ifdef HAVE_CONFIG_H
9  #include <config.h>
10 #else
11 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
12 #endif
13 
14 #ifdef _HAVE_MATLAB_
15 /* MODULEBOOT/MODULEEND {{{*/
16 
17 /*The following macros hide the error exception handling in a matlab module. Just put
18  * MODULEBOOT(); and MODULEEND(); at the beginning and end of a module, and c++ exceptions
19  * will be trapped*/
20 #define MODULEBOOT(); try{ \
21  IssmComm::SetComm(); \
22  ToolkitOptions::Init();
23 
24 #define MODULEEND(); }\
25  catch(ErrorException &exception){\
26  mexErrMsgTxt(exception.WrapperReport()); \
27  }\
28  catch (exception &e){\
29  mexErrMsgTxt(e.what());\
30  }\
31  catch(...){\
32  mexErrMsgTxt("An unexpected error occurred");\
33  }
34 /*}}}*/
35 /* WRAPPER {{{*/
36 #define WRAPPER(modulename,...) void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
37 /*}}}*/
38 /* CHECKARGUMENTS {{{*/
39 #define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,functionpointer)
40 /*}}}*/
41 #endif
42 
43 #endif