octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #51725] Adding mxGetProperty to Matlab API


From: Rik
Subject: [Octave-bug-tracker] [bug #51725] Adding mxGetProperty to Matlab API
Date: Sat, 12 Aug 2017 11:03:24 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0

Follow-up Comment #11, bug #51725 (project octave):

The problem seems to be cset 23893:75eff5b667b3 (new mxSetProperty function
for MEX API).  The function mxGetProperty no longer returns NULL for a
non-matching property name.

I modified mexprop.c to


#include "mex.h"

/*
Octave syntax: val = mexprop (Map_obj, "property_name")
Fetches property "property_name" from containers.Map object.
*/

void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
  if (nrhs != 2)
    mexErrMsgTxt ("mexprop: syntax is mexprop (Map_obj, property_name)");

  /* Check for Map object. */
  if (! mxIsClass (prhs[0], "containers.Map"))
    mexErrMsgTxt ("mexprop: first argument must be a containers.map object");

  if (! mxIsChar (prhs[1]))
    mexErrMsgTxt ("mexprop: second argument must be a property name");

  mxArray *retval = mxGetProperty (prhs[0], 0, mxArrayToString (prhs[1]));
  mexPrintf ("retval = %ld\n", retval);

  plhs[0] = retval;
}


And after compiling and running tst_mexprop I get


octave:1> mex mexprop.c
octave:2> tst_mexprop
retval = 26828816
retval = 27562656
retval = 27574032
error: assert (mexprop (x, "FooBar"),[]) failed
error: called from
    assert at line 92 column 11
    tst_mexprop at line 6 column 1


With cset 23892:ba46a8015b26 just before I get


octave:4> tst_mexprop
retval = 20596784
retval = 21330992
retval = 0


I'm attaching the new mexprop.c to the bug report.  I also made some tests of
null pointers for the MEX API that I will post.


(file #41493)
    _______________________________________________________

Additional Item Attachment:

File name: mexprop.c                      Size:0 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51725>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]