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

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

[Octave-bug-tracker] [bug #55755] mxGetProperty does not work with prope


From: anonymous
Subject: [Octave-bug-tracker] [bug #55755] mxGetProperty does not work with properties marked as Dependent
Date: Thu, 21 Feb 2019 12:18:34 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0

URL:
  <https://savannah.gnu.org/bugs/?55755>

                 Summary: mxGetProperty does not work with properties marked
as Dependent
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Thu 21 Feb 2019 05:18:32 PM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: Tim
        Originator Email: address@hidden
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.4.1
        Operating System: Microsoft Windows

    _______________________________________________________

Details:

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.







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55755>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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