[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #49077] Missing MEX functions mxGetProperty, m
From: |
Guillaume |
Subject: |
[Octave-bug-tracker] [bug #49077] Missing MEX functions mxGetProperty, mxSetProperty, mxArrayToUTF8String |
Date: |
Tue, 13 Sep 2016 14:54:13 +0000 (UTC) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0 |
Follow-up Comment #1, bug #49077 (project octave):
What about something like this for mxGetProperty?
mxArray *mxGetProperty(const mxArray *pa, mwIndex index, const char *propname)
{
mxArray *mx = NULL, *mc = NULL, *me = NULL, *md = NULL;
mxArray *mo[1], *m[2];
const char **fields = (const char *[]){"type", "subs"};
mx = mxCreateStructMatrix(1, 2, 2, fields);
mxSetFieldByNumber(mx, 0, 0, mxCreateString("()"));
mc = mxCreateCellMatrix(1,1);
mxSetCell(mc,0,mxCreateDoubleScalar(index+1));
mxSetFieldByNumber(mx, 0, 1, mc);
mxSetFieldByNumber(mx, 1, 0, mxCreateString("."));
mxSetFieldByNumber(mx, 1, 1, mxCreateString(propname));
m[0] = (mxArray *)pa;
m[1] = mx;
me = mexCallMATLABWithTrap(1, mo, 2, m, "subsref");
mxDestroyArray(mx);
if (me == NULL) {
md = mxDuplicateArray((const mxArray*)mo[0]);
}
return md;
}
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?49077>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/