gmtmex icon indicating copy to clipboard operation
gmtmex copied to clipboard

Shrink gmtmex.c by growing gmtmex_parser.c to be included in GMT core

Open PaulWessel opened this issue 5 years ago • 6 comments

Description of the desired feature

The gmtmex.extension library with the mexFunction needs to be built using the user's MATLAB version. Hence, we want to move as much of the code in gmtmex.c into the gmtmex_parser.c as possible to keep things simple. It seems to me that the ultimate mexFunction would just be something like this:

#include "gmtmex.h"
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
	gmt_mexfunction (nlhs, plus, nrhs, prhs);
	return;
}

Does gmtmex.c really need more in it, @joa-quim if we just place the rest in gmt_mexfunction and stick in the gmtmex_parser.c in libgmt?

PaulWessel avatar Sep 22 '20 23:09 PaulWessel

👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. We appreciate that you took the time to contribute!

welcome[bot] avatar Sep 22 '20 23:09 welcome[bot]

The benefit of the above is you can write a short paragraph to tell people just make this 5-line file and compile it with max or similar.

PaulWessel avatar Sep 22 '20 23:09 PaulWessel

I don't think you can shrink it that much. If you move any mxArray (or family) to the GMT lib than the entire GMT would depend on Matlab.

joa-quim avatar Sep 22 '20 23:09 joa-quim

Hm, well gmtmex_parser.c calls mexErrMsgTxt, mxCreateNumericMatrix and lots of things, so it is all requiring a matlab include file, so perhaps there is nothing we can supply that does not require mex include/lib?

PaulWessel avatar Sep 22 '20 23:09 PaulWessel

Yes, had forgotten about those. So, nope it seems there is nothing valuable that we can move.

joa-quim avatar Sep 22 '20 23:09 joa-quim

I will look but it reduces the scope.

PaulWessel avatar Sep 22 '20 23:09 PaulWessel