bugGNU Octave - Bugs: bug #55755, mxGetProperty does not work with...

 
 

bug #55755: mxGetProperty does not work with properties marked as Dependent

Submitter:  None
Submitted:  Thu 21 Feb 2019 05:18:32 PM UTC
 
Category:  Libraries Severity:  1 - Wish
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Tim Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * dev
Operating System:  * Any
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Thu 21 Feb 2019 06:44:23 PM UTC, comment #1: 

Confirmed with 4.4, 5, and default branch. I'm attaching a cleaned up and renamed version of the original example as propclass.m and proptest.c.

>> x = propclass;
>> proptest (x)
Actual property
Property: 10.000000
Dependent property
PropertyArray is a nullptr.

(file #46328, file #46329)

Mike Miller <mtmiller>
Project Administrator
Thu 21 Feb 2019 05:18:32 PM UTC, original submission:  

In the c-mex interface of matlab the mxGetProperty-function returns values of dependent properties. Using octaves mex-functions it instead returns nullptrs.
A simple example.

foo.m:
classdef foo
  properties
    bar = 10;
  end

  properties(Dependent)
    baaz
  end

  methods
    function out = get.baaz(this)
      out = this.bar * 2;
    end
  end
end

property_test.cpp:
#include "mex.h"
#include "matrix.h"
#include <cstdio>
#include <cstdlib>

void mexFunction(int OutputArgumentCount, mxArray* OutputArguments[], int InputArgumentCount, const mxArray* InputArguments[]) {
  printf("Actual property\n");
  {
    const mxArray* PropertyArray = mxGetProperty(InputArguments[0], 0, "bar");
    if ( PropertyArray ) {
      const double* Property = mxGetPr(PropertyArray);
      printf("Property: %f\n", Property[0]);
    } else {
      printf("PropertyArray is a nullptr.\n");
    }
  }
  printf("Dependent property\n");
  {
    const mxArray* PropertyArray = mxGetProperty(InputArguments[0], 0, "baaz");
    if ( PropertyArray ) {
      const double* Property = mxGetPr(PropertyArray);
      printf("Property: %f\n", Property[0]);
    } else {
      printf("PropertyArray is a nullptr.\n");
    }
  }
}

And running this whole thing on the shell:
octave:1> input = foo();
octave:2> input.bar
ans =  10
octave:3> input.baaz
ans =  20
octave:4> mex property_test.cpp -o ptest
octave:5> ptest(input)
Actual property
Property: 10.000000
Dependent property
PropertyArray is a nullptr.
octave:6>

In matlab accessing baaz this way would have yielded an array with its first value being 20, not a nullptr.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #46328:  propclass.m added by mtmiller (228B - text/x-objcsrc)
file #46329:  proptest.c added by mtmiller (824B - text/x-csrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.

     

     

     

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-02-21 mtmiller Attached File- Added propclass.m, #46328
        Attached File- Added proptest.c, #46329
        CategoryOctave Function Libraries
        Severity3 - Normal 1 - Wish
        StatusNone Confirmed
        Release4.4.1 dev
        Operating SystemMicrosoft Windows Any

    Back to the top


    Powered by Savane 3.9