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: Fri, 11 Aug 2017 14:23:43 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0

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

I tested the new API function with the attached mexprop.c and tst_mexprop.m
using a container.Map object.  It seems to work nicely.

mexprop.c:


#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");

  plhs[0] = mxGetProperty (prhs[0], 0, mxArrayToString (prhs[1]));
  
}


tst_mexprop.m


# Needed once, to compile file
# mex mexprop.c
x = containers.Map;
assert (mexprop (x, "KeyType"), "char")
assert (mexprop (x, "ValueType"), "any")
assert (mexprop (x, "FooBar"), [])




(file #41487, file #41488)
    _______________________________________________________

Additional Item Attachment:

File name: mexprop.c                      Size:0 KB
File name: tst_mexprop.m                  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]