#include "lsl_common.h" /* function [DescPtr] = lsl_first_child(LibHandle,DescPtr) */ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { /* handle of the desired field */ mxArray *field; /* temp pointer */ uintptr_t *pTmp; /* function handle */ lsl_first_child_t func; /* input/output variables */ xml_ptr in; xml_ptr out; if (nrhs != 2) mexErrMsgTxt("2 input argument(s) required."); if (nlhs != 1) mexErrMsgTxt("1 output argument(s) required."); /* get function handle */ field = mxGetField(prhs[0],0,"lsl_first_child"); if (!field) mexErrMsgTxt("The field does not seem to exist."); pTmp = (uintptr_t*)mxGetData(field); if (!pTmp) mexErrMsgTxt("The field seems to be empty."); func = (lsl_first_child_t*)*pTmp; /* get additional inputs */ in = (xml_ptr)*(uintptr_t*)mxGetData(prhs[1]); /* invoke & return */ out = func(in); plhs[0] = mxCreateNumericMatrix(1,1,PTR_CLASS,mxREAL); *(uintptr_t*)mxGetData(plhs[0]) = (uintptr_t)out; }