Improved error handling on entry to mex files
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "bridge.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include <exception>
|
||||
#include <opencv2/{{includes}}.hpp>
|
||||
using namespace cv;
|
||||
@@ -29,9 +30,10 @@ void mexFunction(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[]) {
|
||||
|
||||
// assertions
|
||||
mxAssert(nrhs >= {{fun.req|length - fun.req|outputs|length}}, "Too few required input arguments specified");
|
||||
mxAssert(nrhs <= {{fun.req|length + fun.opt|length - fun.req|outputs|length - fun.opt|outputs|length}}, "Too many input arguments specified");
|
||||
mxAssert(nlhs <= {{ fun.rtp|void|not + fun.req|outputs|length + fun.opt|outputs|length}}, "Too many output arguments specified");
|
||||
mexPrintf("nrhs: %d, nlhs: %d\n", nrhs, nlhs);
|
||||
conditionalError(nrhs >= {{fun.req|length - fun.req|outputs|length}}, "Too few required input arguments specified");
|
||||
conditionalError(nrhs <= {{fun.req|length + fun.opt|length - fun.req|outputs|length - fun.opt|outputs|length}}, "Too many input arguments specified");
|
||||
conditionalError(nlhs <= {{ fun.rtp|void|not + fun.req|outputs|length + fun.opt|outputs|length}}, "Too many output arguments specified");
|
||||
|
||||
// setup
|
||||
std::vector<Bridge> inputs(plhs, plhs+nrhs);
|
||||
|
Reference in New Issue
Block a user